--- ray/src/common/header.c 2012/06/10 02:46:12 2.27 +++ ray/src/common/header.c 2017/05/07 16:14:19 2.30 @@ -1,5 +1,5 @@ #ifndef lint -static const char RCSid[] = "$Id: header.c,v 2.27 2012/06/10 02:46:12 greg Exp $"; +static const char RCSid[] = "$Id: header.c,v 2.30 2017/05/07 16:14:19 greg Exp $"; #endif /* * header.c - routines for reading and writing information headers. @@ -43,7 +43,7 @@ const char GMTSTR[] = "GMT="; /* GMT identifier */ static gethfunc mycheck; -extern void +void newheader( /* identifying line of information header */ char *s, FILE *fp @@ -55,7 +55,7 @@ newheader( /* identifying line of information header } -extern int +int headidval( /* get header id (return true if is id) */ char *r, char *s @@ -71,7 +71,7 @@ headidval( /* get header id (return true if is id) * } -extern int +int dateval( /* convert capture date line to UTC */ time_t *tloc, char *s @@ -97,7 +97,7 @@ dateval( /* convert capture date line to UTC */ } -extern int +int gmtval( /* convert GMT date line to UTC */ time_t *tloc, char *s @@ -122,7 +122,7 @@ gmtval( /* convert GMT date line to UTC */ } -extern void +void fputdate( /* write out the given time value (local & GMT) */ time_t tv, FILE *fp @@ -143,7 +143,7 @@ fputdate( /* write out the given time value (local & } -extern void +void fputnow( /* write out the current time */ FILE *fp ) @@ -154,7 +154,7 @@ fputnow( /* write out the current time */ } -extern void +void printargs( /* print arguments to a file */ int ac, char **av, @@ -168,7 +168,7 @@ printargs( /* print arguments to a file */ } -extern int +int formatval( /* get format value (return true if format) */ char *r, char *s @@ -182,13 +182,13 @@ formatval( /* get format value (return true if forma if (r == NULL) return(1); do *r++ = *s++; - while(*s && !isspace(*s)); + while (*s && !isspace(*s)); *r = '\0'; return(1); } -extern void +void fputformat( /* put out a format value */ char *s, FILE *fp @@ -200,27 +200,30 @@ fputformat( /* put out a format value */ } -extern int +int getheader( /* get header from file */ FILE *fp, gethfunc *f, void *p ) { + int rtotal = 0; char buf[MAXLINE]; for ( ; ; ) { + int rval = 0; buf[MAXLINE-2] = '\n'; if (fgets(buf, MAXLINE, fp) == NULL) return(-1); - if (buf[0] == '\n') - return(0); + if (buf[buf[0]=='\r'] == '\n') + return(rtotal); if (buf[MAXLINE-2] != '\n') { ungetc(buf[MAXLINE-2], fp); /* prevent false end */ buf[MAXLINE-2] = '\0'; } - if (f != NULL && (*f)(buf, p) < 0) + if (f != NULL && (rval = (*f)(buf, p)) < 0) return(-1); + rtotal += rval; } } @@ -245,7 +248,7 @@ mycheck( /* check a header line for format info. */ } -extern int +int globmatch( /* check for match of s against pattern p */ char *p, char *s @@ -262,7 +265,7 @@ globmatch( /* check for match of s against pattern p case '*': /* match any string */ while (p[1] == '*') p++; do - if ( (p[1]=='?' || p[1]==*s) && + if ( (p[1]=='?') | (p[1]==*s) && globmatch(p+1,s) ) return(1); while (*s++); @@ -275,11 +278,11 @@ globmatch( /* check for match of s against pattern p if (!*p) return(0); if (*p == '-') { - setmatch += p[-1] <= *s && *s <= p[1]; + setmatch += (p[-1] <= *s && *s <= p[1]); if (!*++p) break; } else - setmatch += *p == *s; + setmatch += (*p == *s); } if (!setmatch) return(0); @@ -313,7 +316,7 @@ globmatch( /* check for match of s against pattern p * if fout is not NULL. */ -extern int +int checkheader( FILE *fin, char *fmt,