17 |
|
* formatval(r,s) copy the format value in s to r |
18 |
|
* fputformat(s,fp) write "FORMAT=%s" to fp |
19 |
|
* getheader(fp,f,p) read header from fp, calling f(s,p) on each line |
20 |
+ |
* copymatch(pat, str) copy str into pat if glob match |
21 |
|
* checkheader(i,p,o) check header format from i against p and copy to o |
22 |
|
* |
23 |
|
* To copy header from input to output, use getheader(fin, fputs, fout) |
49 |
|
} |
50 |
|
|
51 |
|
|
52 |
+ |
int |
53 |
|
headidval(r,s) /* get header id (return true if is id) */ |
54 |
|
register char *r, *s; |
55 |
|
{ |
63 |
|
} |
64 |
|
|
65 |
|
|
66 |
+ |
int |
67 |
|
isheadid(s) /* check to see if line is header id */ |
68 |
|
char *s; |
69 |
|
{ |
95 |
|
} |
96 |
|
|
97 |
|
|
98 |
+ |
int |
99 |
|
formatval(r, s) /* get format value (return true if format) */ |
100 |
|
register char *r; |
101 |
|
register char *s; |
106 |
|
while (isspace(*s)) s++; |
107 |
|
if (!*s) return(0); |
108 |
|
if (r == NULL) return(1); |
109 |
< |
while(*s) *r++ = *s++; |
110 |
< |
while (isspace(r[-1])) r--; |
109 |
> |
do |
110 |
> |
*r++ = *s++; |
111 |
> |
while(*s && !isspace(*s)); |
112 |
|
*r = '\0'; |
113 |
|
return(1); |
114 |
|
} |
115 |
|
|
116 |
|
|
117 |
+ |
int |
118 |
|
isformat(s) /* is line a format line? */ |
119 |
|
char *s; |
120 |
|
{ |
132 |
|
} |
133 |
|
|
134 |
|
|
135 |
+ |
int |
136 |
|
getheader(fp, f, p) /* get header from file */ |
137 |
|
FILE *fp; |
138 |
|
int (*f)(); |
181 |
|
* copies str into pat if there is a match (returning true). |
182 |
|
*/ |
183 |
|
|
184 |
< |
#ifdef COPYMATCH |
184 |
> |
int |
185 |
|
copymatch(pat, str) |
186 |
|
char *pat, *str; |
187 |
|
{ |
219 |
|
strcpy(pat, str); |
220 |
|
return(1); |
221 |
|
} |
215 |
– |
#else |
216 |
– |
#define copymatch(pat, s) (!strcmp(pat, s)) |
217 |
– |
#endif |
222 |
|
|
223 |
|
|
224 |
|
/* |
234 |
|
* if fout is not NULL. |
235 |
|
*/ |
236 |
|
|
237 |
+ |
int |
238 |
|
checkheader(fin, fmt, fout) |
239 |
|
FILE *fin; |
240 |
|
char *fmt; |