/* $OpenXM: OpenXM/src/util/oxreplace.c,v 1.4 2005/04/14 07:11:58 takayama Exp $ */ /* cf. fb/src/misc/nan-tfb2.c */ #include #include int ReplaceLine=0; char *readAsString(FILE *fp) { static char *s = NULL; static int size= 102400; int p = 0; char *s2; int c; if (s == NULL) { s = (char *) malloc(size); if (s == NULL) { fprintf(stderr,"no more memory.\n"); exit(10); } } s[0] = 0; while ((c=fgetc(fp)) != EOF) { s[p++] = c; s[p] = 0; if (p >= size-2) { s2 = s; size = 2*size; s = (char *) malloc(size); if (s == NULL) { fprintf(stderr,"no more memory.\n"); exit(10); } strcpy(s,s2); free(s2); } } return s; } matches(char *word,char *s,int j) { int i; for (i=0; i= '0') && (c<='9')) return 1; if ((c >= 'A') && (c<='F')) return 1; if ((c >= 'a') && (c<='f')) return 1; return 0; } char *hex2str(char hstr[]) { int i,n,c,k; char *s; char ts[3]; /* printf("%s\n",hstr); */ n = strlen(hstr); s = (char *) malloc(n/2+2); if (s == NULL) {fprintf(stderr,"Memory exhausted.\n"); exit(10);} k = 0; i = 0; s[k] = 0; while (i