| 1 |
< |
/* Copyright (c) 1988 Regents of the University of California */ |
| 1 |
> |
/* Copyright (c) 1992 Regents of the University of California */ |
| 2 |
|
|
| 3 |
|
#ifndef lint |
| 4 |
|
static char SCCSid[] = "$SunId$ LBL"; |
| 9 |
|
* |
| 10 |
|
* 8/19/88 |
| 11 |
|
* |
| 12 |
< |
* printargs(ac,av,fp) print an argument list to fp, followed by '\n' |
| 12 |
> |
* printargs(ac,av,fp) print an argument list to fp, followed by '\n' |
| 13 |
|
* isformat(s) returns true if s is of the form "FORMAT=*" |
| 14 |
|
* formatval(r,s) copy the format value in s to r |
| 15 |
|
* fputformat(s,fp) write "FORMAT=%s" to fp |
| 22 |
|
#include <stdio.h> |
| 23 |
|
#include <ctype.h> |
| 24 |
|
|
| 25 |
< |
#define MAXLINE 512 |
| 25 |
> |
#define MAXLINE 512 |
| 26 |
|
|
| 27 |
+ |
#ifndef BSD |
| 28 |
+ |
#define index strchr |
| 29 |
+ |
#endif |
| 30 |
+ |
|
| 31 |
+ |
extern char *index(); |
| 32 |
+ |
|
| 33 |
|
char FMTSTR[] = "FORMAT="; |
| 34 |
|
int FMTSTRL = 7; |
| 35 |
|
|
| 37 |
|
printargs(ac, av, fp) /* print arguments to a file */ |
| 38 |
|
int ac; |
| 39 |
|
char **av; |
| 40 |
< |
FILE *fp; |
| 40 |
> |
register FILE *fp; |
| 41 |
|
{ |
| 42 |
+ |
int quote; |
| 43 |
+ |
|
| 44 |
|
while (ac-- > 0) { |
| 45 |
< |
fputs(*av++, fp); |
| 45 |
> |
if (index(*av, ' ') != NULL) { /* quote it */ |
| 46 |
> |
if (index(*av, '\'') != NULL) |
| 47 |
> |
quote = '"'; |
| 48 |
> |
else |
| 49 |
> |
quote = '\''; |
| 50 |
> |
putc(quote, fp); |
| 51 |
> |
fputs(*av++, fp); |
| 52 |
> |
putc(quote, fp); |
| 53 |
> |
} else |
| 54 |
> |
fputs(*av++, fp); |
| 55 |
|
putc(' ', fp); |
| 56 |
|
} |
| 57 |
|
putc('\n', fp); |
| 97 |
|
|
| 98 |
|
for ( ; ; ) { |
| 99 |
|
buf[MAXLINE-2] = '\n'; |
| 100 |
< |
if (fgets(buf, sizeof(buf), fp) == NULL) |
| 100 |
> |
if (fgets(buf, MAXLINE, fp) == NULL) |
| 101 |
|
return(-1); |
| 102 |
|
if (buf[0] == '\n') |
| 103 |
|
return(0); |
| 104 |
+ |
#ifdef MSDOS |
| 105 |
+ |
if (buf[0] == '\r' && buf[1] == '\n') |
| 106 |
+ |
return(0); |
| 107 |
+ |
#endif |
| 108 |
|
if (buf[MAXLINE-2] != '\n') { |
| 109 |
|
ungetc(buf[MAXLINE-2], fp); /* prevent false end */ |
| 110 |
|
buf[MAXLINE-2] = '\0'; |
| 155 |
|
case '*': /* match any string */ |
| 156 |
|
while (p[1] == '*') p++; |
| 157 |
|
do |
| 158 |
< |
if ( (p[1] == '?' || p[1] == *s) |
| 158 |
> |
if ( (p[1]=='?' || p[1]==*s) |
| 159 |
|
&& copymatch(p+1,s) ) { |
| 160 |
|
strcpy(pat, str); |
| 161 |
|
return(1); |
| 185 |
|
* Checkheader(fin,fmt,fout) returns a value of 1 if the input format |
| 186 |
|
* matches the specification in fmt, 0 if no input format was found, |
| 187 |
|
* and -1 if the input format does not match or there is an |
| 188 |
< |
* error reading the header. If fmt is NULL, then -1 is returned |
| 188 |
> |
* error reading the header. If fmt is empty, then -1 is returned |
| 189 |
|
* if any input format is found (or there is an error), and 0 otherwise. |
| 190 |
|
* If fmt contains any '*' or '?' characters, then checkheader |
| 191 |
|
* does wildcard expansion and copies a matching result into fmt. |
| 204 |
|
cdat.fp = fout; |
| 205 |
|
cdat.fs[0] = '\0'; |
| 206 |
|
if (getheader(fin, mycheck, &cdat) < 0) |
| 186 |
– |
return(-1); |
| 187 |
– |
if (fmt == NULL && cdat.fs[0] != '\0') |
| 207 |
|
return(-1); |
| 208 |
|
if (cdat.fs[0] != '\0') |
| 209 |
|
return(copymatch(fmt, cdat.fs) ? 1 : -1); |