| 10 |
|
|
| 11 |
|
#include "standard.h" |
| 12 |
|
|
| 13 |
+ |
#include <sys/fcntl.h> |
| 14 |
+ |
|
| 15 |
|
#include "view.h" |
| 16 |
|
|
| 17 |
|
#include "color.h" |
| 18 |
|
|
| 19 |
+ |
#ifndef BSD |
| 20 |
+ |
#define vfork fork |
| 21 |
+ |
#endif |
| 22 |
+ |
|
| 23 |
|
#define pscan(y) (ourpict+(y)*hresolu) |
| 24 |
|
#define zscan(y) (ourzbuf+(y)*hresolu) |
| 25 |
|
|
| 153 |
|
if (argv[i][2] != 'f') |
| 154 |
|
goto badopt; |
| 155 |
|
check(3,1); |
| 156 |
< |
gotvfile = viewfile(argv[++i], &ourview); |
| 156 |
> |
gotvfile = viewfile(argv[++i], &ourview, 0, 0); |
| 157 |
|
if (gotvfile < 0) { |
| 158 |
|
perror(argv[i]); |
| 159 |
|
exit(1); |
| 247 |
|
char *pfile, *zspec; |
| 248 |
|
{ |
| 249 |
|
extern double atof(); |
| 250 |
< |
FILE *pfp, *zfp; |
| 250 |
> |
FILE *pfp; |
| 251 |
> |
int zfd; |
| 252 |
|
char *err; |
| 253 |
|
COLR *scanin; |
| 254 |
|
float *zin; |
| 286 |
|
if (scanin == NULL || zin == NULL || plast == NULL) |
| 287 |
|
syserror(); |
| 288 |
|
/* get z specification or file */ |
| 289 |
< |
if ((zfp = fopen(zspec, "r")) == NULL) { |
| 289 |
> |
if ((zfd = open(zspec, O_RDONLY)) == -1) { |
| 290 |
|
double zvalue; |
| 291 |
|
register int x; |
| 292 |
|
if (!isfloat(zspec) || (zvalue = atof(zspec)) <= 0.0) { |
| 302 |
|
fprintf(stderr, "%s: read error\n", pfile); |
| 303 |
|
exit(1); |
| 304 |
|
} |
| 305 |
< |
if (zfp != NULL |
| 306 |
< |
&& fread(zin,sizeof(float),thresolu,zfp) < thresolu) { |
| 305 |
> |
if (zfd != -1 && read(zfd,zin,thresolu*sizeof(float)) |
| 306 |
> |
< thresolu*sizeof(float)) { |
| 307 |
|
fprintf(stderr, "%s: read error\n", zspec); |
| 308 |
|
exit(1); |
| 309 |
|
} |
| 314 |
|
free((char *)zin); |
| 315 |
|
free((char *)plast); |
| 316 |
|
fclose(pfp); |
| 317 |
< |
if (zfp != NULL) |
| 318 |
< |
fclose(zfp); |
| 317 |
> |
if (zfd != -1) |
| 318 |
> |
close(zfd); |
| 319 |
|
} |
| 320 |
|
|
| 321 |
|
|
| 366 |
|
struct position lastx, newpos; |
| 367 |
|
register int x; |
| 368 |
|
|
| 369 |
+ |
lastx.z = 0; |
| 370 |
|
for (x = thresolu-1; x >= 0; x--) { |
| 371 |
|
pos[0] = (x+.5)/thresolu + theirview.hoff - .5; |
| 372 |
|
pos[1] = (y+.5)/tvresolu + theirview.voff - .5; |
| 568 |
|
{ |
| 569 |
|
extern double sqrt(); |
| 570 |
|
int donorm = normdist && ourview.type == VT_PER; |
| 571 |
< |
FILE *fp; |
| 571 |
> |
int fd; |
| 572 |
|
int y; |
| 573 |
|
float *zout; |
| 574 |
|
|
| 575 |
< |
if ((fp = fopen(fname, "w")) == NULL) { |
| 575 |
> |
if ((fd = open(fname, O_WRONLY|O_CREAT|O_TRUNC, 0666)) == -1) { |
| 576 |
|
perror(fname); |
| 577 |
|
exit(1); |
| 578 |
|
} |
| 592 |
|
} |
| 593 |
|
} else |
| 594 |
|
zout = zscan(y); |
| 595 |
< |
if (fwrite(zout, sizeof(float), hresolu, fp) < hresolu) { |
| 595 |
> |
if (write(fd, zout, hresolu*sizeof(float)) |
| 596 |
> |
< hresolu*sizeof(float)) { |
| 597 |
|
perror(fname); |
| 598 |
|
exit(1); |
| 599 |
|
} |
| 600 |
|
} |
| 601 |
|
if (donorm) |
| 602 |
|
free((char *)zout); |
| 603 |
< |
fclose(fp); |
| 603 |
> |
close(fd); |
| 604 |
|
} |
| 605 |
|
|
| 606 |
|
|