7 |
|
* Externals declared in resolu.h |
8 |
|
* |
9 |
|
* newheader(t,fp) start new information header identified by string t |
10 |
– |
* isheadid(s) returns true if s is a header id line |
10 |
|
* headidval(r,s) copy header identifier value in s to r |
11 |
< |
* dateval(t,s) get capture date value |
12 |
< |
* isdate(s) returns true if s is a date line |
13 |
< |
* fputdate(t,fp) put out the given capture date and time |
11 |
> |
* dateval(t,s) get capture date value as UTC |
12 |
> |
* gmtval(t,s) get GMT as UTC |
13 |
> |
* fputdate(t,fp) put out the given UTC |
14 |
|
* fputnow(fp) put out the current date and time |
15 |
|
* printargs(ac,av,fp) print an argument list to fp, followed by '\n' |
17 |
– |
* isformat(s) returns true if s is of the form "FORMAT=*" |
16 |
|
* formatval(r,s) copy the format value in s to r |
17 |
|
* fputformat(s,fp) write "FORMAT=%s" to fp |
18 |
|
* getheader(fp,f,p) read header from fp, calling f(s,p) on each line |
29 |
|
#include "rtio.h" |
30 |
|
#include "resolu.h" |
31 |
|
|
32 |
< |
#define MAXLINE 512 |
32 |
> |
#define MAXLINE 2048 |
33 |
|
|
34 |
< |
char HDRSTR[] = "#?"; /* information header magic number */ |
34 |
> |
const char HDRSTR[] = "#?"; /* information header magic number */ |
35 |
|
|
36 |
< |
char FMTSTR[] = "FORMAT="; /* format identifier */ |
36 |
> |
const char FMTSTR[] = "FORMAT="; /* format identifier */ |
37 |
|
|
38 |
< |
char TMSTR[] = "CAPDATE="; /* capture date identifier */ |
38 |
> |
const char TMSTR[] = "CAPDATE="; /* capture date identifier */ |
39 |
> |
const char GMTSTR[] = "GMT="; /* GMT identifier */ |
40 |
|
|
41 |
|
static gethfunc mycheck; |
42 |
|
|
44 |
|
extern void |
45 |
|
newheader( /* identifying line of information header */ |
46 |
|
char *s, |
47 |
< |
register FILE *fp |
47 |
> |
FILE *fp |
48 |
|
) |
49 |
|
{ |
50 |
|
fputs(HDRSTR, fp); |
55 |
|
|
56 |
|
extern int |
57 |
|
headidval( /* get header id (return true if is id) */ |
58 |
< |
register char *r, |
59 |
< |
register char *s |
58 |
> |
char *r, |
59 |
> |
char *s |
60 |
|
) |
61 |
|
{ |
62 |
< |
register char *cp = HDRSTR; |
62 |
> |
const char *cp = HDRSTR; |
63 |
|
|
64 |
|
while (*cp) if (*cp++ != *s++) return(0); |
65 |
|
if (r == NULL) return(1); |
70 |
|
|
71 |
|
|
72 |
|
extern int |
73 |
< |
isheadid( /* check to see if line is header id */ |
75 |
< |
char *s |
76 |
< |
) |
77 |
< |
{ |
78 |
< |
return(headidval(NULL, s)); |
79 |
< |
} |
80 |
< |
|
81 |
< |
|
82 |
< |
extern int |
83 |
< |
dateval( /* get capture date value */ |
73 |
> |
dateval( /* convert capture date line to UTC */ |
74 |
|
time_t *tloc, |
75 |
|
char *s |
76 |
|
) |
77 |
|
{ |
78 |
|
struct tm tms; |
79 |
< |
register char *cp = TMSTR; |
79 |
> |
const char *cp = TMSTR; |
80 |
|
|
81 |
|
while (*cp) if (*cp++ != *s++) return(0); |
82 |
|
while (isspace(*s)) s++; |
96 |
|
|
97 |
|
|
98 |
|
extern int |
99 |
< |
isdate( /* is the given line a capture date? */ |
100 |
< |
char *s |
99 |
> |
gmtval( /* convert GMT date line to UTC */ |
100 |
> |
time_t *tloc, |
101 |
> |
char *s |
102 |
|
) |
103 |
|
{ |
104 |
< |
return(dateval(NULL, s)); |
104 |
> |
struct tm tms; |
105 |
> |
const char *cp = GMTSTR; |
106 |
> |
|
107 |
> |
while (*cp) if (*cp++ != *s++) return(0); |
108 |
> |
while (isspace(*s)) s++; |
109 |
> |
if (!*s) return(0); |
110 |
> |
if (sscanf(s, "%d:%d:%d %d:%d:%d", |
111 |
> |
&tms.tm_year, &tms.tm_mon, &tms.tm_mday, |
112 |
> |
&tms.tm_hour, &tms.tm_min, &tms.tm_sec) != 6) |
113 |
> |
return(0); |
114 |
> |
if (tloc == NULL) |
115 |
> |
return(1); |
116 |
> |
tms.tm_mon--; |
117 |
> |
tms.tm_year -= 1900; |
118 |
> |
*tloc = timegm(&tms); |
119 |
> |
return(1); |
120 |
|
} |
121 |
|
|
122 |
|
|
123 |
|
extern void |
124 |
< |
fputdate( /* write out the given time value */ |
124 |
> |
fputdate( /* write out the given time value (local & GMT) */ |
125 |
|
time_t tv, |
126 |
|
FILE *fp |
127 |
|
) |
128 |
|
{ |
129 |
< |
struct tm *tm = localtime(&tv); |
130 |
< |
if (tm == NULL) |
131 |
< |
return; |
132 |
< |
fprintf(fp, "%s %04d:%02d:%02d %02d:%02d:%02d\n", TMSTR, |
133 |
< |
tm->tm_year+1900, tm->tm_mon+1, tm->tm_mday, |
134 |
< |
tm->tm_hour, tm->tm_min, tm->tm_sec); |
129 |
> |
struct tm *tms; |
130 |
> |
|
131 |
> |
tms = localtime(&tv); |
132 |
> |
if (tms != NULL) |
133 |
> |
fprintf(fp, "%s %04d:%02d:%02d %02d:%02d:%02d\n", TMSTR, |
134 |
> |
tms->tm_year+1900, tms->tm_mon+1, tms->tm_mday, |
135 |
> |
tms->tm_hour, tms->tm_min, tms->tm_sec); |
136 |
> |
tms = gmtime(&tv); |
137 |
> |
if (tms != NULL) |
138 |
> |
fprintf(fp, "%s %04d:%02d:%02d %02d:%02d:%02d\n", GMTSTR, |
139 |
> |
tms->tm_year+1900, tms->tm_mon+1, tms->tm_mday, |
140 |
> |
tms->tm_hour, tms->tm_min, tms->tm_sec); |
141 |
|
} |
142 |
|
|
143 |
|
|
168 |
|
|
169 |
|
extern int |
170 |
|
formatval( /* get format value (return true if format) */ |
171 |
< |
register char *r, |
172 |
< |
register char *s |
171 |
> |
char *r, |
172 |
> |
char *s |
173 |
|
) |
174 |
|
{ |
175 |
< |
register char *cp = FMTSTR; |
175 |
> |
const char *cp = FMTSTR; |
176 |
|
|
177 |
|
while (*cp) if (*cp++ != *s++) return(0); |
178 |
|
while (isspace(*s)) s++; |
186 |
|
} |
187 |
|
|
188 |
|
|
177 |
– |
extern int |
178 |
– |
isformat( /* is line a format line? */ |
179 |
– |
char *s |
180 |
– |
) |
181 |
– |
{ |
182 |
– |
return(formatval(NULL, s)); |
183 |
– |
} |
184 |
– |
|
185 |
– |
|
189 |
|
extern void |
190 |
|
fputformat( /* put out a format value */ |
191 |
|
char *s, |
249 |
|
|
250 |
|
extern int |
251 |
|
globmatch( /* check for match of s against pattern p */ |
252 |
< |
register char *p, |
253 |
< |
register char *s |
252 |
> |
char *p, |
253 |
> |
char *s |
254 |
|
) |
255 |
|
{ |
256 |
|
int setmatch; |
323 |
|
) |
324 |
|
{ |
325 |
|
struct check cdat; |
326 |
< |
register char *cp; |
326 |
> |
char *cp; |
327 |
|
|
328 |
|
cdat.fp = fout; |
329 |
|
cdat.fs[0] = '\0'; |