11 |
|
|
12 |
|
#include <sys/types.h> |
13 |
|
|
14 |
< |
#ifndef NIX |
14 |
> |
#ifndef NON_POSIX |
15 |
|
#ifdef BSD |
16 |
|
#include <sys/time.h> |
17 |
|
#include <sys/resource.h> |
21 |
|
#endif |
22 |
|
#endif |
23 |
|
|
24 |
< |
extern time_t time(); |
25 |
< |
|
24 |
> |
#include <time.h> |
25 |
|
#include <signal.h> |
26 |
|
|
27 |
+ |
#include "platform.h" |
28 |
|
#include "view.h" |
29 |
– |
|
29 |
|
#include "random.h" |
31 |
– |
|
30 |
|
#include "paths.h" |
31 |
|
|
32 |
+ |
|
33 |
|
#define RFTEMPLATE "rfXXXXXX" |
34 |
|
|
35 |
|
#ifndef SIGCONT |
36 |
+ |
#ifdef SIGIO /* XXX can we live without this? */ |
37 |
|
#define SIGCONT SIGIO |
38 |
|
#endif |
39 |
+ |
#endif |
40 |
|
|
41 |
|
CUBE thescene; /* our scene */ |
42 |
|
OBJECT nsceneobjs; /* number of objects in our scene */ |
109 |
|
|
110 |
|
static VIEW lastview; /* the previous view input */ |
111 |
|
|
112 |
< |
extern char *mktemp(); |
112 |
> |
extern char *mktemp(); /* XXX should be in stdlib.h or unistd.h */ |
113 |
|
|
114 |
|
void report(); |
115 |
|
|
116 |
|
double pixvalue(); |
117 |
|
|
118 |
< |
#ifdef NIX |
118 |
< |
#define file_exists(f) (access(f,F_OK)==0) |
119 |
< |
#else |
118 |
> |
#ifdef RHAS_STAT |
119 |
|
#include <sys/types.h> |
120 |
|
#include <sys/stat.h> |
121 |
|
int |
126 |
|
if (stat(fname, &sbuf) < 0) return(0); |
127 |
|
return((sbuf.st_mode & S_IFREG) != 0); |
128 |
|
} |
129 |
+ |
#else |
130 |
+ |
#define file_exists(f) (access(f,F_OK)==0) |
131 |
|
#endif |
132 |
|
|
133 |
|
|
137 |
|
{ |
138 |
|
if (code) /* report status */ |
139 |
|
report(); |
140 |
< |
#ifndef NIX |
140 |
> |
#ifndef NON_POSIX |
141 |
|
headclean(); /* delete header file */ |
142 |
|
pfclean(); /* clean up persist files */ |
143 |
|
#endif |
145 |
|
} |
146 |
|
|
147 |
|
|
148 |
< |
#ifndef NIX |
148 |
> |
#ifndef NON_POSIX |
149 |
|
void |
150 |
|
report() /* report progress */ |
151 |
|
{ |
182 |
|
nrays, pctdone, u/3600., s/3600., |
183 |
|
(tlastrept-tstart)/3600., myhostname()); |
184 |
|
eputs(errmsg); |
185 |
< |
#ifndef BSD |
185 |
> |
#ifdef SIGCONT |
186 |
|
signal(SIGCONT, report); |
187 |
|
#endif |
188 |
|
} |
290 |
|
"cannot open output file \"%s\"", fbuf); |
291 |
|
error(SYSTEM, errmsg); |
292 |
|
} |
293 |
< |
#ifdef MSDOS |
293 |
< |
setmode(fileno(stdout), O_BINARY); |
294 |
< |
#endif |
293 |
> |
SET_FILE_BINARY(stdout); |
294 |
|
dupheader(); |
295 |
|
} |
296 |
|
hres = hresolu; vres = vresolu; pa = pixaspect; |
322 |
|
putchar('\n'); |
323 |
|
if (pa < .99 || pa > 1.01) |
324 |
|
fputaspect(pa, stdout); |
325 |
+ |
fputnow(); |
326 |
|
fputformat(COLRFMT, stdout); |
327 |
|
putchar('\n'); |
328 |
|
if (zout != NULL) |
393 |
|
sprintf(errmsg, "cannot open z-file \"%s\"", zfile); |
394 |
|
error(SYSTEM, errmsg); |
395 |
|
} |
396 |
< |
#ifdef MSDOS |
397 |
< |
setmode(zfd, O_BINARY); |
398 |
< |
#endif |
396 |
> |
SET_FD_BINARY(zfd); |
397 |
|
for (i = 0; i <= psample; i++) { |
398 |
|
zbar[i] = (float *)malloc(hres*sizeof(float)); |
399 |
|
if (zbar[i] == NULL) |
416 |
|
pctdone = 100.0*i/vres; |
417 |
|
if (ralrm > 0) /* report init stats */ |
418 |
|
report(); |
419 |
< |
#ifndef BSD |
419 |
> |
#ifdef SIGCONT |
420 |
|
else |
423 |
– |
#endif |
421 |
|
signal(SIGCONT, report); |
422 |
+ |
#endif |
423 |
|
ypos = vres-1 - i; /* initialize sampling */ |
424 |
|
if (directvis) |
425 |
|
init_drawsources(psample); |
445 |
|
if (directvis) /* add bitty sources */ |
446 |
|
drawsources(scanbar, zbar, 0, hres, ypos, ystep); |
447 |
|
/* write it out */ |
448 |
< |
#ifndef BSD |
448 |
> |
#ifdef SIGCONT |
449 |
|
signal(SIGCONT, SIG_IGN); /* don't interrupt writes */ |
450 |
|
#endif |
451 |
|
for (i = ystep; i > 0; i--) { |
462 |
|
pctdone = 100.0*(vres-1-ypos)/vres; |
463 |
|
if (ralrm > 0 && time((time_t *)NULL) >= tlastrept+ralrm) |
464 |
|
report(); |
465 |
< |
#ifndef BSD |
465 |
> |
#ifdef SIGCONT |
466 |
|
else |
467 |
|
signal(SIGCONT, report); |
468 |
|
#endif |
469 |
|
} |
470 |
|
/* clean up */ |
471 |
+ |
#ifdef SIGCONT |
472 |
|
signal(SIGCONT, SIG_IGN); |
473 |
+ |
#endif |
474 |
|
if (zfd != -1 && write(zfd, (char *)zbar[0], hres*sizeof(float)) |
475 |
|
< hres*sizeof(float)) |
476 |
|
goto writerr; |
491 |
|
pctdone = 100.0; |
492 |
|
if (ralrm > 0) |
493 |
|
report(); |
494 |
+ |
#ifdef SIGCONT |
495 |
|
signal(SIGCONT, SIG_DFL); |
496 |
+ |
#endif |
497 |
|
return; |
498 |
|
writerr: |
499 |
|
error(SYSTEM, "write error in render"); |
679 |
|
error(WARNING, errmsg); |
680 |
|
goto gotzip; |
681 |
|
} |
682 |
< |
#ifdef MSDOS |
681 |
< |
setmode(fileno(fp), O_BINARY); |
682 |
< |
#endif |
682 |
> |
SET_FILE_BINARY(fp); |
683 |
|
/* discard header */ |
684 |
|
getheader(fp, NULL, NULL); |
685 |
|
/* get picture size */ |