149 |
|
} |
150 |
|
|
151 |
|
|
152 |
– |
closeheader() /* done with header output */ |
153 |
– |
{ |
154 |
– |
if (hfname == NULL) |
155 |
– |
return; |
156 |
– |
if (fflush(stdout) == EOF || (hfp = fopen(hfname, "r")) == NULL) |
157 |
– |
error(SYSTEM, "error reopening header file"); |
158 |
– |
#ifdef MSDOS |
159 |
– |
setmode(fileno(hfp), O_BINARY); |
160 |
– |
#endif |
161 |
– |
} |
162 |
– |
|
163 |
– |
|
152 |
|
dupheader() /* repeat header on standard output */ |
153 |
|
{ |
154 |
|
register int c; |
155 |
|
|
156 |
< |
if (fseek(hfp, 0L, 0) < 0) |
156 |
> |
if (hfp == NULL) { |
157 |
> |
if ((hfp = fopen(hfname, "r")) == NULL) |
158 |
> |
error(SYSTEM, "error reopening header file"); |
159 |
> |
#ifdef MSDOS |
160 |
> |
setmode(fileno(hfp), O_BINARY); |
161 |
> |
#endif |
162 |
> |
} else if (fseek(hfp, 0L, 0) < 0) |
163 |
|
error(SYSTEM, "seek error on header file"); |
164 |
|
while ((c = getc(hfp)) != EOF) |
165 |
|
putchar(c); |
186 |
|
register char *cp; |
187 |
|
RESOLU rs; |
188 |
|
double pa; |
195 |
– |
/* finished writing header */ |
196 |
– |
closeheader(); |
189 |
|
/* check sampling */ |
190 |
|
if (psample < 1) |
191 |
|
psample = 1; |
209 |
|
error(USER, "unexpected EOF on view input"); |
210 |
|
prvr = fbuf; /* mark for renaming */ |
211 |
|
} |
212 |
< |
if (pout != NULL) { |
212 |
> |
if (pout != NULL & prvr != NULL) { |
213 |
|
sprintf(fbuf, pout, seq); |
214 |
< |
if (prvr != NULL && !strcmp(prvr, fbuf)) { /* rename */ |
215 |
< |
fbuf2[0] = '\0'; |
216 |
< |
if ((cp = rindex(fbuf, '/')) != NULL) |
217 |
< |
strncpy(fbuf2, fbuf, cp-fbuf+1); |
218 |
< |
strcat(fbuf2, RFTEMPLATE); |
214 |
> |
if (!strcmp(prvr, fbuf)) { /* rename */ |
215 |
> |
strcpy(fbuf2, fbuf); |
216 |
> |
for (cp = fbuf2; *cp; cp++) |
217 |
> |
; |
218 |
> |
while (cp > fbuf2 && !ISDIRSEP(cp[-1])) |
219 |
> |
cp--; |
220 |
> |
strcpy(cp, RFTEMPLATE); |
221 |
|
prvr = mktemp(fbuf2); |
222 |
|
if (rename(fbuf, prvr) < 0 && errno != ENOENT) { |
223 |
|
sprintf(errmsg, |