| 20 |
|
#define MAXMODLIST 1024 /* maximum modifiers we'll track */ |
| 21 |
|
#endif |
| 22 |
|
|
| 23 |
< |
int treebufsiz = BUFSIZ; /* current tree buffer size */ |
| 23 |
> |
size_t treebufsiz = BUFSIZ; /* current tree buffer size */ |
| 24 |
|
|
| 25 |
|
typedef double DCOLOR[3]; /* double-precision color */ |
| 26 |
|
|
| 92 |
|
struct rtproc *next; /* next in list of processes */ |
| 93 |
|
SUBPROC pd; /* rtrace pipe descriptors */ |
| 94 |
|
unsigned long raynum; /* ray number for this tree */ |
| 95 |
< |
int bsiz; /* ray tree buffer length */ |
| 95 |
> |
size_t bsiz; /* ray tree buffer length */ |
| 96 |
|
char *buf; /* ray tree buffer */ |
| 97 |
< |
int nbr; /* number of bytes from rtrace */ |
| 97 |
> |
size_t nbr; /* number of bytes from rtrace */ |
| 98 |
|
}; /* rtrace process buffer */ |
| 99 |
|
|
| 100 |
|
/* rtrace command and defaults */ |
| 107 |
|
char *myrtopts[] = { "-h-", "-x", "1", "-y", "0", |
| 108 |
|
"-dt", "0", "-as", "0", "-aa", "0", NULL }; |
| 109 |
|
|
| 110 |
< |
#define RTCOEFF "-o~~TmWdp" /* compute coefficients only */ |
| 111 |
< |
#define RTCONTRIB "-o~~TmVdp" /* compute ray contributions */ |
| 110 |
> |
#define RTCOEFF "-o~~~TmWdp" /* compute coefficients only */ |
| 111 |
> |
#define RTCONTRIB "-o~~~TmVdp" /* compute ray contributions */ |
| 112 |
|
|
| 113 |
|
struct rtproc rt0; /* head of rtrace process list */ |
| 114 |
|
|
| 378 |
|
rtargv[rtargc++] = contrib ? RTCONTRIB : RTCOEFF; |
| 379 |
|
/* just asking for defaults? */ |
| 380 |
|
if (!strcmp(argv[i], "-defaults")) { |
| 381 |
< |
char sxres[16], syres[16]; |
| 381 |
> |
char nps[8], sxres[16], syres[16]; |
| 382 |
|
char *rtpath; |
| 383 |
– |
printf("-n %-2d\t\t\t\t# number of processes\n", nprocs); |
| 383 |
|
printf("-c %-5d\t\t\t# accumulated rays per record\n", |
| 384 |
|
accumulate); |
| 385 |
|
printf("-V%c\t\t\t\t# output %s\n", contrib ? '+' : '-', |
| 386 |
|
contrib ? "contributions" : "coefficients"); |
| 387 |
|
fflush(stdout); /* report OUR options */ |
| 388 |
+ |
rtargv[rtargc++] = "-n"; |
| 389 |
+ |
sprintf(nps, "%d", nprocs); |
| 390 |
+ |
rtargv[rtargc++] = nps; |
| 391 |
|
rtargv[rtargc++] = header ? "-h+" : "-h-"; |
| 392 |
|
sprintf(fmt, "-f%c%c", inpfmt, outfmt); |
| 393 |
|
rtargv[rtargc++] = fmt; |
| 545 |
|
raysleft = 0; |
| 546 |
|
if ((account = accumulate) > 0) |
| 547 |
|
raysleft *= accumulate; |
| 548 |
< |
waitflush = xres; |
| 548 |
> |
waitflush = (yres > 0) & (xres > 1) ? 0 : xres; |
| 549 |
|
if (!recover) |
| 550 |
|
return; |
| 551 |
|
/* recover previous values */ |
| 736 |
|
{ |
| 737 |
|
if ((xr > 0) & (yr > 0)) /* resolution string */ |
| 738 |
|
fprtresolu(xr, yr, fout); |
| 737 |
– |
if (xres > 0) /* global flush flag */ |
| 738 |
– |
fflush(fout); |
| 739 |
|
} |
| 740 |
|
|
| 741 |
|
/* Get output stream pointer (open and write header if new and noopen==0) */ |
| 756 |
|
if (header) |
| 757 |
|
printheader(stdout, NULL); |
| 758 |
|
printresolu(stdout, xres, yres); |
| 759 |
+ |
if (waitflush > 0) |
| 760 |
+ |
fflush(stdout); |
| 761 |
|
stdos.xr = xres; stdos.yr = yres; |
| 762 |
|
using_stdout = 1; |
| 763 |
|
} |
| 826 |
|
if (outfmt == 'a') |
| 827 |
|
putc('\n', sop->ofp); |
| 828 |
|
} |
| 829 |
< |
if (xres > 0) |
| 829 |
> |
if (waitflush > 0) |
| 830 |
|
fflush(sop->ofp); |
| 831 |
|
} |
| 832 |
|
sop->reclen += noopen; /* add to length if noopen */ |
| 993 |
|
if (using_stdout & (outfmt == 'a')) |
| 994 |
|
putc('\n', stdout); |
| 995 |
|
if (!waitflush) { |
| 996 |
< |
waitflush = xres; |
| 996 |
> |
waitflush = (yres > 0) & (xres > 1) ? 0 : xres; |
| 997 |
|
if (using_stdout) |
| 998 |
|
fflush(stdout); |
| 999 |
|
} |
| 1075 |
|
{ |
| 1076 |
|
struct rtproc *rtfree = NULL; |
| 1077 |
|
fd_set readset, errset; |
| 1078 |
< |
int nr; |
| 1078 |
> |
ssize_t nr; |
| 1079 |
|
struct rtproc *rt; |
| 1080 |
|
int n; |
| 1081 |
|
|
| 1106 |
|
continue; |
| 1107 |
|
if (rt->buf == NULL) { |
| 1108 |
|
rt->bsiz = treebufsiz; |
| 1109 |
< |
rt->buf = (char *)malloc(treebufsiz); |
| 1109 |
> |
rt->buf = (char *)malloc(rt->bsiz); |
| 1110 |
|
} else if (rt->nbr + BUFSIZ > rt->bsiz) { |
| 1111 |
|
if (rt->bsiz + BUFSIZ <= treebufsiz) |
| 1112 |
|
rt->bsiz = treebufsiz; |
| 1120 |
|
if (nr <= 0) |
| 1121 |
|
error(USER, "rtrace process died"); |
| 1122 |
|
rt->nbr += nr; /* advance & check */ |
| 1123 |
< |
if (rt->nbr >= 4 && !memcmp(rt->buf+rt->nbr-4, |
| 1124 |
< |
"~\t~\t", 4)) { |
| 1125 |
< |
rt->nbr -= 4; /* elide terminator */ |
| 1123 |
> |
if (rt->nbr >= 6 && !memcmp(rt->buf+rt->nbr-6, |
| 1124 |
> |
"~\t~\t~\t", 6)) { |
| 1125 |
> |
rt->nbr -= 6; /* elide terminator */ |
| 1126 |
|
queue_raytree(rt); |
| 1127 |
|
rtfree = rt; /* ready for next ray */ |
| 1128 |
|
} |
| 1164 |
|
lastray+1 < lastray) { |
| 1165 |
|
while (wait_rproc() != NULL) |
| 1166 |
|
process_queue(); |
| 1167 |
< |
if (lastray+1 < lastray) |
| 1166 |
< |
lastdone = lastray = 0; |
| 1167 |
> |
lastdone = lastray = 0; |
| 1168 |
|
} |
| 1169 |
|
rtp = get_rproc(); /* get avail. rtrace process */ |
| 1170 |
|
rtp->raynum = ++lastray; /* assign ray */ |