97 |
|
return(fnum); |
98 |
|
} |
99 |
|
|
100 |
+ |
/* Retrieve the indexed field from parameter (first field index is 1) */ |
101 |
+ |
IDF_FIELD * |
102 |
+ |
idf_getfield(IDF_PARAMETER *param, int fn) |
103 |
+ |
{ |
104 |
+ |
IDF_FIELD *fld; |
105 |
+ |
|
106 |
+ |
if ((param == NULL) | (fn <= 0)) |
107 |
+ |
return(NULL); |
108 |
+ |
fld = param->flist; |
109 |
+ |
while ((--fn > 0) & (fld != NULL)) |
110 |
+ |
fld = fld->next; |
111 |
+ |
return(fld); |
112 |
+ |
} |
113 |
+ |
|
114 |
|
/* Delete the specified parameter from loaded IDF */ |
115 |
|
int |
116 |
|
idf_delparam(IDF_LOADED *idf, IDF_PARAMETER *param) |
200 |
|
buf = &dummyc; |
201 |
|
len = 1; |
202 |
|
} |
203 |
< |
while ((c = getc(fp)) != EOF && isspace(c) | incomm) { |
204 |
< |
if (c == '!') |
205 |
< |
++incomm; |
192 |
< |
else if (c == '\n') |
203 |
> |
while ((c = getc(fp)) != EOF && |
204 |
> |
(isspace(c) || (incomm += (c == '!')))) { |
205 |
> |
if (c == '\n') |
206 |
|
incomm = 0; |
207 |
|
if (cp-buf < len-1) |
208 |
|
*cp++ = c; |
230 |
|
idf_addfield(pnew, abuf, cbuf); |
231 |
|
} |
232 |
|
if (delim != ';') |
233 |
< |
fprintf(stderr, "Expected ';' at end of parameter list\n"); |
233 |
> |
fputs("Expected ';' at end of parameter list!\n", stderr); |
234 |
|
return(pnew); |
235 |
|
} |
236 |
|
|
273 |
|
IDF_LOADED * |
274 |
|
idf_load(const char *fname) |
275 |
|
{ |
276 |
< |
char *hdrcomm; |
276 |
> |
char hdrcomm[300*IF_MAXLINE]; |
277 |
|
FILE *fp; |
278 |
|
IDF_LOADED *idf; |
279 |
|
|
282 |
|
else if ((fp = fopen(fname, "r")) == NULL) |
283 |
|
return(NULL); |
284 |
|
/* read header comments */ |
285 |
< |
hdrcomm = (char *)malloc(100*IDF_MAXLINE); |
273 |
< |
idf_read_comment(hdrcomm, 100*IDF_MAXLINE, fp); |
285 |
> |
idf_read_comment(hdrcomm, sizeof(hdrcomm), fp); |
286 |
|
idf = idf_create(hdrcomm); /* create IDF struct */ |
275 |
– |
free(hdrcomm); |
287 |
|
if (idf == NULL) |
288 |
|
return(NULL); |
289 |
|
/* read each parameter */ |