40 |
|
|
41 |
|
char TMSTR[] = "CAPDATE="; /* capture date identifier */ |
42 |
|
|
43 |
< |
static int mycheck(); |
43 |
> |
static gethfunc mycheck; |
44 |
|
|
45 |
|
|
46 |
< |
void |
47 |
< |
newheader(s, fp) /* identifying line of information header */ |
48 |
< |
char *s; |
49 |
< |
register FILE *fp; |
46 |
> |
extern void |
47 |
> |
newheader( /* identifying line of information header */ |
48 |
> |
char *s, |
49 |
> |
register FILE *fp |
50 |
> |
) |
51 |
|
{ |
52 |
|
fputs(HDRSTR, fp); |
53 |
|
fputs(s, fp); |
55 |
|
} |
56 |
|
|
57 |
|
|
58 |
< |
int |
59 |
< |
headidval(r,s) /* get header id (return true if is id) */ |
60 |
< |
register char *r, *s; |
58 |
> |
extern int |
59 |
> |
headidval( /* get header id (return true if is id) */ |
60 |
> |
register char *r, |
61 |
> |
register char *s |
62 |
> |
) |
63 |
|
{ |
64 |
|
register char *cp = HDRSTR; |
65 |
|
|
71 |
|
} |
72 |
|
|
73 |
|
|
74 |
< |
int |
75 |
< |
isheadid(s) /* check to see if line is header id */ |
76 |
< |
char *s; |
74 |
> |
extern int |
75 |
> |
isheadid( /* check to see if line is header id */ |
76 |
> |
char *s |
77 |
> |
) |
78 |
|
{ |
79 |
|
return(headidval(NULL, s)); |
80 |
|
} |
81 |
|
|
82 |
|
|
83 |
< |
int |
84 |
< |
dateval(tloc, s) /* get capture date value */ |
85 |
< |
time_t *tloc; |
86 |
< |
char *s; |
83 |
> |
extern int |
84 |
> |
dateval( /* get capture date value */ |
85 |
> |
time_t *tloc, |
86 |
> |
char *s |
87 |
> |
) |
88 |
|
{ |
89 |
|
struct tm tms; |
90 |
|
register char *cp = TMSTR; |
106 |
|
} |
107 |
|
|
108 |
|
|
109 |
< |
int |
110 |
< |
isdate(s) /* is the given line a capture date? */ |
111 |
< |
char *s; |
109 |
> |
extern int |
110 |
> |
isdate( /* is the given line a capture date? */ |
111 |
> |
char *s |
112 |
> |
) |
113 |
|
{ |
114 |
|
return(dateval(NULL, s)); |
115 |
|
} |
116 |
|
|
117 |
|
|
118 |
< |
void |
119 |
< |
fputdate(tv, fp) /* write out the given time value */ |
120 |
< |
time_t tv; |
121 |
< |
FILE *fp; |
118 |
> |
extern void |
119 |
> |
fputdate( /* write out the given time value */ |
120 |
> |
time_t tv, |
121 |
> |
FILE *fp |
122 |
> |
) |
123 |
|
{ |
124 |
|
struct tm *tm = localtime(&tv); |
125 |
|
if (tm == NULL) |
130 |
|
} |
131 |
|
|
132 |
|
|
133 |
< |
void |
134 |
< |
fputnow(fp) /* write out the current time */ |
135 |
< |
FILE *fp; |
133 |
> |
extern void |
134 |
> |
fputnow( /* write out the current time */ |
135 |
> |
FILE *fp |
136 |
> |
) |
137 |
|
{ |
138 |
|
time_t tv; |
139 |
|
time(&tv); |
141 |
|
} |
142 |
|
|
143 |
|
|
144 |
< |
void |
145 |
< |
printargs(ac, av, fp) /* print arguments to a file */ |
146 |
< |
int ac; |
147 |
< |
char **av; |
148 |
< |
FILE *fp; |
144 |
> |
extern void |
145 |
> |
printargs( /* print arguments to a file */ |
146 |
> |
int ac, |
147 |
> |
char **av, |
148 |
> |
FILE *fp |
149 |
> |
) |
150 |
|
{ |
151 |
|
while (ac-- > 0) { |
152 |
|
fputword(*av++, fp); |
155 |
|
} |
156 |
|
|
157 |
|
|
158 |
< |
int |
159 |
< |
formatval(r, s) /* get format value (return true if format) */ |
160 |
< |
register char *r; |
161 |
< |
register char *s; |
158 |
> |
extern int |
159 |
> |
formatval( /* get format value (return true if format) */ |
160 |
> |
register char *r, |
161 |
> |
register char *s |
162 |
> |
) |
163 |
|
{ |
164 |
|
register char *cp = FMTSTR; |
165 |
|
|
175 |
|
} |
176 |
|
|
177 |
|
|
178 |
< |
int |
179 |
< |
isformat(s) /* is line a format line? */ |
180 |
< |
char *s; |
178 |
> |
extern int |
179 |
> |
isformat( /* is line a format line? */ |
180 |
> |
char *s |
181 |
> |
) |
182 |
|
{ |
183 |
|
return(formatval(NULL, s)); |
184 |
|
} |
185 |
|
|
186 |
|
|
187 |
< |
void |
188 |
< |
fputformat(s, fp) /* put out a format value */ |
189 |
< |
char *s; |
190 |
< |
FILE *fp; |
187 |
> |
extern void |
188 |
> |
fputformat( /* put out a format value */ |
189 |
> |
char *s, |
190 |
> |
FILE *fp |
191 |
> |
) |
192 |
|
{ |
193 |
|
fputs(FMTSTR, fp); |
194 |
|
fputs(s, fp); |
196 |
|
} |
197 |
|
|
198 |
|
|
199 |
< |
int |
200 |
< |
getheader(fp, f, p) /* get header from file */ |
201 |
< |
FILE *fp; |
202 |
< |
int (*f)(char *, char *); |
203 |
< |
char *p; |
199 |
> |
extern int |
200 |
> |
getheader( /* get header from file */ |
201 |
> |
FILE *fp, |
202 |
> |
gethfunc *f, |
203 |
> |
void *p |
204 |
> |
) |
205 |
|
{ |
206 |
|
char buf[MAXLINE]; |
207 |
|
|
232 |
|
|
233 |
|
|
234 |
|
static int |
235 |
< |
mycheck(s, cp) /* check a header line for format info. */ |
236 |
< |
char *s; |
237 |
< |
register struct check *cp; |
235 |
> |
mycheck( /* check a header line for format info. */ |
236 |
> |
char *s, |
237 |
> |
void *cp |
238 |
> |
) |
239 |
|
{ |
240 |
< |
if (!formatval(cp->fs, s) && cp->fp != NULL) |
241 |
< |
fputs(s, cp->fp); |
240 |
> |
if (!formatval(((struct check*)cp)->fs, s) |
241 |
> |
&& ((struct check*)cp)->fp != NULL) { |
242 |
> |
fputs(s, ((struct check*)cp)->fp); |
243 |
> |
} |
244 |
|
return(0); |
245 |
|
} |
246 |
|
|
247 |
|
|
248 |
< |
int |
249 |
< |
globmatch(p, s) /* check for match of s against pattern p */ |
250 |
< |
register char *p, *s; |
248 |
> |
extern int |
249 |
> |
globmatch( /* check for match of s against pattern p */ |
250 |
> |
register char *p, |
251 |
> |
register char *s |
252 |
> |
) |
253 |
|
{ |
254 |
|
int setmatch; |
255 |
|
|
313 |
|
* if fout is not NULL. |
314 |
|
*/ |
315 |
|
|
316 |
< |
int |
317 |
< |
checkheader(fin, fmt, fout) |
318 |
< |
FILE *fin; |
319 |
< |
char *fmt; |
320 |
< |
FILE *fout; |
316 |
> |
extern int |
317 |
> |
checkheader( |
318 |
> |
FILE *fin, |
319 |
> |
char *fmt, |
320 |
> |
FILE *fout |
321 |
> |
) |
322 |
|
{ |
323 |
|
struct check cdat; |
324 |
|
register char *cp; |
325 |
|
|
326 |
|
cdat.fp = fout; |
327 |
|
cdat.fs[0] = '\0'; |
328 |
< |
if (getheader(fin, mycheck, (char *)&cdat) < 0) |
328 |
> |
if (getheader(fin, mycheck, &cdat) < 0) |
329 |
|
return(-1); |
330 |
|
if (!cdat.fs[0]) |
331 |
|
return(0); |