10 |
|
|
11 |
|
#include "standard.h" |
12 |
|
|
13 |
+ |
#include <sys/fcntl.h> |
14 |
+ |
|
15 |
|
#include "view.h" |
16 |
|
|
17 |
|
#include "color.h" |
149 |
|
if (argv[i][2] != 'f') |
150 |
|
goto badopt; |
151 |
|
check(3,1); |
152 |
< |
gotvfile = viewfile(argv[++i], &ourview); |
152 |
> |
gotvfile = viewfile(argv[++i], &ourview, 0, 0); |
153 |
|
if (gotvfile < 0) { |
154 |
|
perror(argv[i]); |
155 |
|
exit(1); |
243 |
|
char *pfile, *zspec; |
244 |
|
{ |
245 |
|
extern double atof(); |
246 |
< |
FILE *pfp, *zfp; |
246 |
> |
FILE *pfp; |
247 |
> |
int zfd; |
248 |
|
char *err; |
249 |
|
COLR *scanin; |
250 |
|
float *zin; |
282 |
|
if (scanin == NULL || zin == NULL || plast == NULL) |
283 |
|
syserror(); |
284 |
|
/* get z specification or file */ |
285 |
< |
if ((zfp = fopen(zspec, "r")) == NULL) { |
285 |
> |
if ((zfd = open(zspec, O_RDONLY)) == -1) { |
286 |
|
double zvalue; |
287 |
|
register int x; |
288 |
|
if (!isfloat(zspec) || (zvalue = atof(zspec)) <= 0.0) { |
298 |
|
fprintf(stderr, "%s: read error\n", pfile); |
299 |
|
exit(1); |
300 |
|
} |
301 |
< |
if (zfp != NULL |
302 |
< |
&& fread(zin,sizeof(float),thresolu,zfp) < thresolu) { |
301 |
> |
if (zfd != -1 && read(zfd,zin,thresolu*sizeof(float)) |
302 |
> |
< thresolu*sizeof(float)) { |
303 |
|
fprintf(stderr, "%s: read error\n", zspec); |
304 |
|
exit(1); |
305 |
|
} |
310 |
|
free((char *)zin); |
311 |
|
free((char *)plast); |
312 |
|
fclose(pfp); |
313 |
< |
if (zfp != NULL) |
314 |
< |
fclose(zfp); |
313 |
> |
if (zfd != -1) |
314 |
> |
close(zfd); |
315 |
|
} |
316 |
|
|
317 |
|
|
362 |
|
struct position lastx, newpos; |
363 |
|
register int x; |
364 |
|
|
365 |
+ |
lastx.z = 0; |
366 |
|
for (x = thresolu-1; x >= 0; x--) { |
367 |
|
pos[0] = (x+.5)/thresolu + theirview.hoff - .5; |
368 |
|
pos[1] = (y+.5)/tvresolu + theirview.voff - .5; |
564 |
|
{ |
565 |
|
extern double sqrt(); |
566 |
|
int donorm = normdist && ourview.type == VT_PER; |
567 |
< |
FILE *fp; |
567 |
> |
int fd; |
568 |
|
int y; |
569 |
|
float *zout; |
570 |
|
|
571 |
< |
if ((fp = fopen(fname, "w")) == NULL) { |
571 |
> |
if ((fd = open(fname, O_WRONLY|O_CREAT|O_TRUNC, 0666)) == -1) { |
572 |
|
perror(fname); |
573 |
|
exit(1); |
574 |
|
} |
588 |
|
} |
589 |
|
} else |
590 |
|
zout = zscan(y); |
591 |
< |
if (fwrite(zout, sizeof(float), hresolu, fp) < hresolu) { |
591 |
> |
if (write(fd, zout, hresolu*sizeof(float)) |
592 |
> |
< hresolu*sizeof(float)) { |
593 |
|
perror(fname); |
594 |
|
exit(1); |
595 |
|
} |
596 |
|
} |
597 |
|
if (donorm) |
598 |
|
free((char *)zout); |
599 |
< |
fclose(fp); |
599 |
> |
close(fd); |
600 |
|
} |
601 |
|
|
602 |
|
|