1 |
< |
/* Copyright (c) 1991 Regents of the University of California */ |
1 |
> |
/* Copyright (c) 1993 Regents of the University of California */ |
2 |
|
|
3 |
|
#ifndef lint |
4 |
|
static char SCCSid[] = "$SunId$ LBL"; |
12 |
|
|
13 |
|
#include "standard.h" |
14 |
|
|
15 |
– |
#include <fcntl.h> |
16 |
– |
|
15 |
|
#include <ctype.h> |
16 |
|
|
17 |
|
#include "view.h" |
20 |
|
|
21 |
|
#include "resolu.h" |
22 |
|
|
25 |
– |
#ifndef BSD |
26 |
– |
#define vfork fork |
27 |
– |
#endif |
28 |
– |
|
23 |
|
#define pscan(y) (ourpict+(y)*hresolu) |
24 |
|
#define zscan(y) (ourzbuf+(y)*hresolu) |
25 |
|
|
165 |
|
goto badopt; |
166 |
|
check(3,"s"); |
167 |
|
gotvfile = viewfile(argv[++i], &ourview, 0, 0); |
168 |
< |
if (gotvfile < 0) { |
169 |
< |
perror(argv[i]); |
170 |
< |
exit(1); |
177 |
< |
} else if (gotvfile == 0) { |
168 |
> |
if (gotvfile < 0) |
169 |
> |
syserror(argv[i]); |
170 |
> |
else if (gotvfile == 0) { |
171 |
|
fprintf(stderr, "%s: bad view file\n", |
172 |
|
argv[i]); |
173 |
|
exit(1); |
195 |
|
ourpict = (COLR *)bmalloc(hresolu*vresolu*sizeof(COLR)); |
196 |
|
ourzbuf = (float *)bmalloc(hresolu*vresolu*sizeof(float)); |
197 |
|
if (ourpict == NULL || ourzbuf == NULL) |
198 |
< |
syserror(); |
198 |
> |
syserror(progname); |
199 |
|
bzero((char *)ourzbuf, hresolu*vresolu*sizeof(float)); |
200 |
|
/* get input */ |
201 |
|
for ( ; i < argc; i += 2) |
269 |
|
struct position *plast; |
270 |
|
int y; |
271 |
|
/* open picture file */ |
272 |
< |
if ((pfp = fopen(pfile, "r")) == NULL) { |
273 |
< |
perror(pfile); |
281 |
< |
exit(1); |
282 |
< |
} |
272 |
> |
if ((pfp = fopen(pfile, "r")) == NULL) |
273 |
> |
syserror(pfile); |
274 |
|
/* get header with exposure and view */ |
275 |
|
theirexp = 1.0; |
276 |
|
gotview = 0; |
296 |
|
plast = (struct position *)calloc(scanlen(&tresolu), |
297 |
|
sizeof(struct position)); |
298 |
|
if (scanin == NULL || zin == NULL || plast == NULL) |
299 |
< |
syserror(); |
299 |
> |
syserror(progname); |
300 |
|
/* get z specification or file */ |
301 |
|
if ((zfd = open(zspec, O_RDONLY)) == -1) { |
302 |
|
double zvalue; |
303 |
|
register int x; |
304 |
< |
if (!isfloat(zspec) || (zvalue = atof(zspec)) <= 0.0) { |
305 |
< |
perror(zspec); |
304 |
> |
if (!isfloat(zspec) || (zvalue = atof(zspec)) <= 0.0) |
305 |
> |
syserror(zspec); |
306 |
|
exit(1); |
316 |
– |
} |
307 |
|
for (x = scanlen(&tresolu); x-- > 0; ) |
308 |
|
zin[x] = zvalue; |
309 |
|
} |
378 |
|
float *zline; |
379 |
|
struct position *lasty; /* input/output */ |
380 |
|
{ |
391 |
– |
extern double sqrt(); |
381 |
|
FVECT pos; |
382 |
|
struct position lastx, newpos; |
383 |
|
register int x; |
514 |
|
/* get back buffer */ |
515 |
|
yback = (int *)malloc(hresolu*sizeof(int)); |
516 |
|
if (yback == NULL) |
517 |
< |
syserror(); |
517 |
> |
syserror(progname); |
518 |
|
for (x = 0; x < hresolu; x++) |
519 |
|
yback[x] = -2; |
520 |
|
/* |
618 |
|
fprtresolu(hresolu, vresolu, stdout); |
619 |
|
for (y = vresolu-1; y >= 0; y--) |
620 |
|
if (fwritecolrs(pscan(y), hresolu, stdout) < 0) |
621 |
< |
syserror(); |
621 |
> |
syserror(progname); |
622 |
|
} |
623 |
|
|
624 |
|
|
625 |
|
writedistance(fname) /* write out z file */ |
626 |
|
char *fname; |
627 |
|
{ |
639 |
– |
extern double sqrt(); |
628 |
|
int donorm = normdist && ourview.type == VT_PER; |
629 |
|
int fd; |
630 |
|
int y; |
631 |
|
float *zout; |
632 |
|
|
633 |
< |
if ((fd = open(fname, O_WRONLY|O_CREAT|O_TRUNC, 0666)) == -1) { |
634 |
< |
perror(fname); |
647 |
< |
exit(1); |
648 |
< |
} |
633 |
> |
if ((fd = open(fname, O_WRONLY|O_CREAT|O_TRUNC, 0666)) == -1) |
634 |
> |
syserror(fname); |
635 |
|
if (donorm |
636 |
|
&& (zout = (float *)malloc(hresolu*sizeof(float))) == NULL) |
637 |
< |
syserror(); |
637 |
> |
syserror(progname); |
638 |
|
for (y = vresolu-1; y >= 0; y--) { |
639 |
|
if (donorm) { |
640 |
|
double vx, yzn2; |
649 |
|
} else |
650 |
|
zout = zscan(y); |
651 |
|
if (write(fd, (char *)zout, hresolu*sizeof(float)) |
652 |
< |
< hresolu*sizeof(float)) { |
653 |
< |
perror(fname); |
668 |
< |
exit(1); |
669 |
< |
} |
652 |
> |
< hresolu*sizeof(float)) |
653 |
> |
syserror(fname); |
654 |
|
} |
655 |
|
if (donorm) |
656 |
|
free((char *)zout); |
696 |
|
cp = combuf; |
697 |
|
wp = argv; |
698 |
|
for ( ; ; ) { |
699 |
< |
while (isspace(*cp)) cp++; |
700 |
< |
if (!*cp) break; |
701 |
< |
*wp++ = cp; |
702 |
< |
while (!isspace(*cp)) |
703 |
< |
if (!*cp++) goto done; |
704 |
< |
*cp++ = '\0'; |
699 |
> |
while (isspace(*cp)) /* nullify spaces */ |
700 |
> |
*cp++ = '\0'; |
701 |
> |
if (!*cp) /* all done? */ |
702 |
> |
break; |
703 |
> |
*wp++ = cp; /* add argument to list */ |
704 |
> |
while (*++cp && !isspace(*cp)) |
705 |
> |
; |
706 |
|
} |
722 |
– |
done: |
707 |
|
*wp = NULL; |
708 |
|
/* start process */ |
709 |
|
if ((rval = open_process(PDesc, argv)) < 0) |
710 |
< |
syserror(); |
710 |
> |
syserror(progname); |
711 |
|
if (rval == 0) { |
712 |
|
fprintf(stderr, "%s: command not found\n", argv[0]); |
713 |
|
exit(1); |
748 |
|
register float *fbp; |
749 |
|
register int i; |
750 |
|
|
751 |
+ |
if (queuesiz == 0) |
752 |
+ |
return; |
753 |
|
fbp = fbuf; |
754 |
|
for (i = 0; i < queuesiz; i++) { |
755 |
|
viewray(orig, dir, &ourview, |
783 |
|
} |
784 |
|
|
785 |
|
|
786 |
< |
syserror() /* report error and exit */ |
786 |
> |
syserror(s) /* report error and exit */ |
787 |
> |
char *s; |
788 |
|
{ |
789 |
< |
perror(progname); |
789 |
> |
perror(s); |
790 |
|
exit(1); |
791 |
|
} |