| 24 | 
  | 
  #define RENAMECMD "mv" | 
| 25 | 
  | 
  #include <sys/types.h> | 
| 26 | 
  | 
  #include <sys/wait.h> | 
| 27 | 
+ | 
  #include <signal.h> | 
| 28 | 
  | 
#endif | 
| 29 | 
  | 
 | 
| 30 | 
  | 
                                /* variables (alphabetical by name) */ | 
| 36 | 
  | 
#define INDIRECT        5               /* indirection in lighting */ | 
| 37 | 
  | 
#define MATERIAL        6               /* material files */ | 
| 38 | 
  | 
#define MKILLUM         7               /* mkillum options */ | 
| 39 | 
< | 
#define OBJECT          8               /* object files */ | 
| 40 | 
< | 
#define OCONV           9               /* oconv options */ | 
| 41 | 
< | 
#define OCTREE          10              /* octree file name */ | 
| 42 | 
< | 
#define OPTFILE         11              /* rendering options file */ | 
| 43 | 
< | 
#define PENUMBRAS       12              /* shadow penumbras are desired */ | 
| 44 | 
< | 
#define PFILT           13              /* pfilt options */ | 
| 45 | 
< | 
#define PICTURE         14              /* picture file root name */ | 
| 46 | 
< | 
#define QUALITY         15              /* desired rendering quality */ | 
| 47 | 
< | 
#define RAWFILE         16              /* raw picture file root name */ | 
| 48 | 
< | 
#define RENDER          17              /* rendering options */ | 
| 49 | 
< | 
#define REPORT          18              /* report frequency and errfile */ | 
| 50 | 
< | 
#define RESOLUTION      19              /* maximum picture resolution */ | 
| 51 | 
< | 
#define SCENE           20              /* scene files */ | 
| 52 | 
< | 
#define UP              21              /* view up (X, Y or Z) */ | 
| 53 | 
< | 
#define VARIABILITY     22              /* level of light variability */ | 
| 54 | 
< | 
#define VIEWS           23              /* view(s) for picture(s) */ | 
| 55 | 
< | 
#define ZFILE           24              /* distance file root name */ | 
| 56 | 
< | 
#define ZONE            25              /* simulation zone */ | 
| 39 | 
> | 
#define MKPMAP          8               /* mkpmap options */ | 
| 40 | 
> | 
#define OBJECT          9               /* object files */ | 
| 41 | 
> | 
#define OCONV           10              /* oconv options */ | 
| 42 | 
> | 
#define OCTREE          11              /* octree file name */ | 
| 43 | 
> | 
#define OPTFILE         12              /* rendering options file */ | 
| 44 | 
> | 
#define PCMAP           13              /* caustic photon map */ | 
| 45 | 
> | 
#define PENUMBRAS       14              /* shadow penumbras are desired */ | 
| 46 | 
> | 
#define PFILT           15              /* pfilt options */ | 
| 47 | 
> | 
#define PGMAP           16              /* global photon map */ | 
| 48 | 
> | 
#define PICTURE         17              /* picture file root name */ | 
| 49 | 
> | 
#define QUALITY         18              /* desired rendering quality */ | 
| 50 | 
> | 
#define RAWFILE         19              /* raw picture file root name */ | 
| 51 | 
> | 
#define RENDER          20              /* rendering options */ | 
| 52 | 
> | 
#define REPORT          21              /* report frequency and errfile */ | 
| 53 | 
> | 
#define RESOLUTION      22              /* maximum picture resolution */ | 
| 54 | 
> | 
#define RPICT           23              /* rpict parameters */ | 
| 55 | 
> | 
#define RVU             24              /* rvu parameters */ | 
| 56 | 
> | 
#define SCENE           25              /* scene files */ | 
| 57 | 
> | 
#define UP              26              /* view up (X, Y or Z) */ | 
| 58 | 
> | 
#define VARIABILITY     27              /* level of light variability */ | 
| 59 | 
> | 
#define VIEWS           28              /* view(s) for picture(s) */ | 
| 60 | 
> | 
#define ZFILE           29              /* distance file root name */ | 
| 61 | 
> | 
#define ZONE            30              /* simulation zone */ | 
| 62 | 
  | 
                                /* total number of variables */ | 
| 63 | 
< | 
int NVARS = 26; | 
| 63 | 
> | 
int NVARS = 31; | 
| 64 | 
  | 
 | 
| 65 | 
  | 
VARIABLE        vv[] = {                /* variable-value pairs */ | 
| 66 | 
  | 
        {"AMBFILE",     3,      0,      NULL,   onevalue}, | 
| 71 | 
  | 
        {"INDIRECT",    3,      0,      NULL,   intvalue}, | 
| 72 | 
  | 
        {"materials",   3,      0,      NULL,   catvalues}, | 
| 73 | 
  | 
        {"mkillum",     3,      0,      NULL,   catvalues}, | 
| 74 | 
+ | 
        {"mkpmap",      3,      0,      NULL,   catvalues}, | 
| 75 | 
  | 
        {"objects",     3,      0,      NULL,   catvalues}, | 
| 76 | 
  | 
        {"oconv",       3,      0,      NULL,   catvalues}, | 
| 77 | 
  | 
        {"OCTREE",      3,      0,      NULL,   onevalue}, | 
| 78 | 
  | 
        {"OPTFILE",     3,      0,      NULL,   onevalue}, | 
| 79 | 
+ | 
        {"PCMAP",       2,      0,      NULL,   onevalue}, | 
| 80 | 
  | 
        {"PENUMBRAS",   3,      0,      NULL,   boolvalue}, | 
| 81 | 
  | 
        {"pfilt",       2,      0,      NULL,   catvalues}, | 
| 82 | 
+ | 
        {"PGMAP",       2,      0,      NULL,   onevalue}, | 
| 83 | 
  | 
        {"PICTURE",     3,      0,      NULL,   onevalue}, | 
| 84 | 
  | 
        {"QUALITY",     3,      0,      NULL,   qualvalue}, | 
| 85 | 
  | 
        {"RAWFILE",     3,      0,      NULL,   onevalue}, | 
| 86 | 
  | 
        {"render",      3,      0,      NULL,   catvalues}, | 
| 87 | 
  | 
        {"REPORT",      3,      0,      NULL,   onevalue}, | 
| 88 | 
  | 
        {"RESOLUTION",  3,      0,      NULL,   onevalue}, | 
| 89 | 
+ | 
        {"rpict",       3,      0,      NULL,   catvalues}, | 
| 90 | 
+ | 
        {"rvu",         3,      0,      NULL,   catvalues}, | 
| 91 | 
  | 
        {"scene",       3,      0,      NULL,   catvalues}, | 
| 92 | 
  | 
        {"UP",          2,      0,      NULL,   onevalue}, | 
| 93 | 
  | 
        {"VARIABILITY", 3,      0,      NULL,   qualvalue}, | 
| 114 | 
  | 
char    *oct1name;              /* name of post-mkillum octree */ | 
| 115 | 
  | 
time_t  oct1date;               /* date of post-mkillum octree (>= matdate) */ | 
| 116 | 
  | 
 | 
| 117 | 
+ | 
char    *pgmapname;             /* name of global photon map */ | 
| 118 | 
+ | 
time_t  pgmapdate;              /* date of global photon map (>= oct1date) */ | 
| 119 | 
+ | 
char    *pcmapname;             /* name of caustic photon map */ | 
| 120 | 
+ | 
time_t  pcmapdate;              /* date of caustic photon map (>= oct1date) */ | 
| 121 | 
+ | 
 | 
| 122 | 
  | 
int     nowarn = 0;             /* no warnings */ | 
| 123 | 
  | 
int     explicate = 0;          /* explicate variables */ | 
| 124 | 
  | 
int     silent = 0;             /* do work silently */ | 
| 128 | 
  | 
char    *rvdevice = NULL;       /* rvu output device */ | 
| 129 | 
  | 
char    *viewselect = NULL;     /* specific view only */ | 
| 130 | 
  | 
 | 
| 131 | 
+ | 
#define DEF_RPICT_PATH  "rpict"         /* default rpict path */ | 
| 132 | 
+ | 
 | 
| 133 | 
+ | 
                                /* command paths */ | 
| 134 | 
+ | 
char    c_oconv[256] = "oconv"; | 
| 135 | 
+ | 
char    c_mkillum[256] = "mkillum"; | 
| 136 | 
+ | 
char    c_mkpmap[256] = "mkpmap"; | 
| 137 | 
+ | 
char    c_rvu[256] = "rvu"; | 
| 138 | 
+ | 
char    c_rpict[256] = DEF_RPICT_PATH; | 
| 139 | 
+ | 
char    c_rpiece[] = "rpiece"; | 
| 140 | 
+ | 
char    c_pfilt[256] = "pfilt"; | 
| 141 | 
+ | 
 | 
| 142 | 
  | 
int     overture = 0;           /* overture calculation needed */ | 
| 143 | 
  | 
 | 
| 144 | 
  | 
int     children_running = 0;   /* set negative in children */ | 
| 157 | 
  | 
static void getoctcube(double   org[3], double  *sizp); | 
| 158 | 
  | 
static void setdefaults(void); | 
| 159 | 
  | 
static void oconv(void); | 
| 160 | 
+ | 
static void mkpmap(void); | 
| 161 | 
  | 
static char * addarg(char       *op, char       *arg); | 
| 162 | 
  | 
static void oconvopts(char      *oo); | 
| 163 | 
  | 
static void mkillumopts(char    *mo); | 
| 164 | 
+ | 
static void mkpmapopts(char     *mo); | 
| 165 | 
  | 
static void checkambfile(void); | 
| 166 | 
  | 
static double ambval(void); | 
| 167 | 
  | 
static void renderopts(char     *op, char       *po); | 
| 180 | 
  | 
static int runcom(char  *cs); | 
| 181 | 
  | 
static int rmfile(char  *fn); | 
| 182 | 
  | 
static int mvfile(char  *fold, char     *fnew); | 
| 183 | 
< | 
static int next_process(void); | 
| 183 | 
> | 
static int next_process(int     reserve); | 
| 184 | 
  | 
static void wait_process(int    all); | 
| 185 | 
  | 
static void finish_process(void); | 
| 186 | 
  | 
static void badvalue(int        vc); | 
| 236 | 
  | 
        if (i >= argc) | 
| 237 | 
  | 
                goto userr; | 
| 238 | 
  | 
        rifname = argv[i]; | 
| 210 | 
– | 
                                /* check command-line options */ | 
| 211 | 
– | 
        if ((nprocs > 1) & (viewselect != NULL)) | 
| 212 | 
– | 
                nprocs = 1; | 
| 239 | 
  | 
                                /* assign Radiance root file name */ | 
| 240 | 
  | 
        rootname(radname, rifname); | 
| 241 | 
  | 
                                /* load variable values */ | 
| 258 | 
  | 
                printvars(stdout); | 
| 259 | 
  | 
                                /* build octree (and run mkillum) */ | 
| 260 | 
  | 
        oconv(); | 
| 261 | 
+ | 
                                /* run mkpmap if indicated */ | 
| 262 | 
+ | 
        mkpmap(); | 
| 263 | 
  | 
                                /* check date on ambient file */ | 
| 264 | 
  | 
        checkambfile(); | 
| 265 | 
  | 
                                /* run simulation */ | 
| 281 | 
  | 
 | 
| 282 | 
  | 
static void | 
| 283 | 
  | 
rootname(               /* remove tail from end of fn */ | 
| 284 | 
< | 
        register char   *rn, | 
| 285 | 
< | 
        register char   *fn | 
| 284 | 
> | 
        char    *rn, | 
| 285 | 
> | 
        char    *fn | 
| 286 | 
  | 
) | 
| 287 | 
  | 
{ | 
| 288 | 
  | 
        char    *tp, *dp; | 
| 299 | 
  | 
 | 
| 300 | 
  | 
static time_t | 
| 301 | 
  | 
checklast(                      /* check files and find most recent */ | 
| 302 | 
< | 
        register char   *fnames | 
| 302 | 
> | 
        char    *fnames | 
| 303 | 
  | 
) | 
| 304 | 
  | 
{ | 
| 305 | 
  | 
        char    thisfile[PATH_MAX]; | 
| 329 | 
  | 
        int     pred | 
| 330 | 
  | 
) | 
| 331 | 
  | 
{ | 
| 332 | 
< | 
        register char   *cp; | 
| 333 | 
< | 
        register int    n; | 
| 332 | 
> | 
        char    *cp; | 
| 333 | 
> | 
        int     n; | 
| 334 | 
  | 
        int     suffix; | 
| 335 | 
  | 
 | 
| 336 | 
  | 
        n = 0; cp = orig; suffix = -1;          /* suffix position, length */ | 
| 352 | 
  | 
static void | 
| 353 | 
  | 
checkfiles(void)                        /* check for existence and modified times */ | 
| 354 | 
  | 
{ | 
| 355 | 
+ | 
        char    fntemp[256]; | 
| 356 | 
  | 
        time_t  objdate; | 
| 357 | 
  | 
 | 
| 358 | 
  | 
        if (!vdef(OCTREE)) { | 
| 382 | 
  | 
                                vnam(OCTREE), vnam(SCENE), vnam(ILLUM)); | 
| 383 | 
  | 
                quit(1); | 
| 384 | 
  | 
        } | 
| 385 | 
+ | 
        if (vdef(PGMAP)) { | 
| 386 | 
+ | 
                if (!*sskip2(vval(PGMAP),1)) { | 
| 387 | 
+ | 
                        fprintf(stderr, "%s: '%s' missing # photons argument\n", | 
| 388 | 
+ | 
                                        progname, vnam(PGMAP)); | 
| 389 | 
+ | 
                        quit(1); | 
| 390 | 
+ | 
                } | 
| 391 | 
+ | 
                atos(fntemp, sizeof(fntemp), vval(PGMAP)); | 
| 392 | 
+ | 
                pgmapname = savqstr(fntemp); | 
| 393 | 
+ | 
                pgmapdate = fdate(pgmapname); | 
| 394 | 
+ | 
        } | 
| 395 | 
+ | 
        if (vdef(PCMAP)) { | 
| 396 | 
+ | 
                if (!*sskip2(vval(PCMAP),1)) { | 
| 397 | 
+ | 
                        fprintf(stderr, "%s: '%s' missing # photons argument\n", | 
| 398 | 
+ | 
                                        progname, vnam(PCMAP)); | 
| 399 | 
+ | 
                        quit(1); | 
| 400 | 
+ | 
                } | 
| 401 | 
+ | 
                atos(fntemp, sizeof(fntemp), vval(PCMAP)); | 
| 402 | 
+ | 
                pcmapname = savqstr(fntemp); | 
| 403 | 
+ | 
                pcmapdate = fdate(pcmapname); | 
| 404 | 
+ | 
        } | 
| 405 | 
  | 
        matdate = checklast(vval(MATERIAL)); | 
| 406 | 
  | 
}        | 
| 407 | 
  | 
 | 
| 416 | 
  | 
        double  min[3], max[3]; | 
| 417 | 
  | 
        char    buf[1024]; | 
| 418 | 
  | 
        FILE    *fp; | 
| 419 | 
< | 
        register int    i; | 
| 419 | 
> | 
        int     i; | 
| 420 | 
  | 
 | 
| 421 | 
  | 
        if (osiz <= FTINY) { | 
| 422 | 
  | 
                if (!nprocs && fdate(oct1name) < | 
| 529 | 
  | 
                        touch(vval(OCTREE)); | 
| 530 | 
  | 
                else {                          /* build command */ | 
| 531 | 
  | 
                        if (vdef(MATERIAL)) | 
| 532 | 
< | 
                                sprintf(combuf, "oconv%s %s %s > %s", ocopts, | 
| 533 | 
< | 
                                                vval(MATERIAL), vval(SCENE), | 
| 534 | 
< | 
                                                vval(OCTREE)); | 
| 532 | 
> | 
                                sprintf(combuf, "%s%s %s %s > %s", c_oconv, | 
| 533 | 
> | 
                                                ocopts, vval(MATERIAL), | 
| 534 | 
> | 
                                                vval(SCENE), vval(OCTREE)); | 
| 535 | 
  | 
                        else | 
| 536 | 
< | 
                                sprintf(combuf, "oconv%s %s > %s", ocopts, | 
| 536 | 
> | 
                                sprintf(combuf, "%s%s %s > %s", c_oconv, ocopts, | 
| 537 | 
  | 
                                                vval(SCENE), vval(OCTREE)); | 
| 538 | 
  | 
                         | 
| 539 | 
  | 
                        if (runcom(combuf)) {           /* run it */ | 
| 559 | 
  | 
                        touch(oct0name); | 
| 560 | 
  | 
                else {                          /* build command */ | 
| 561 | 
  | 
                        if (octreedate) | 
| 562 | 
< | 
                                sprintf(combuf, "oconv%s -i %s %s > %s", ocopts, | 
| 563 | 
< | 
                                        vval(OCTREE), vval(ILLUM), oct0name); | 
| 562 | 
> | 
                                sprintf(combuf, "%s%s -i %s %s > %s", c_oconv, | 
| 563 | 
> | 
                                        ocopts, vval(OCTREE), | 
| 564 | 
> | 
                                        vval(ILLUM), oct0name); | 
| 565 | 
  | 
                        else if (vdef(MATERIAL)) | 
| 566 | 
< | 
                                sprintf(combuf, "oconv%s %s %s > %s", ocopts, | 
| 567 | 
< | 
                                        vval(MATERIAL), vval(ILLUM), oct0name); | 
| 518 | 
< | 
                        else | 
| 519 | 
< | 
                                sprintf(combuf, "oconv%s %s > %s", ocopts, | 
| 566 | 
> | 
                                sprintf(combuf, "%s%s %s %s > %s", c_oconv, | 
| 567 | 
> | 
                                        ocopts, vval(MATERIAL), | 
| 568 | 
  | 
                                        vval(ILLUM), oct0name); | 
| 569 | 
+ | 
                        else | 
| 570 | 
+ | 
                                sprintf(combuf, "%s%s %s > %s", c_oconv, | 
| 571 | 
+ | 
                                        ocopts, vval(ILLUM), oct0name); | 
| 572 | 
  | 
                        if (runcom(combuf)) {           /* run it */ | 
| 573 | 
  | 
                                fprintf(stderr, | 
| 574 | 
  | 
                                "%s: error generating octree\n\t%s removed\n", | 
| 588 | 
  | 
        else { | 
| 589 | 
  | 
                mkillumopts(mkopts);            /* build mkillum command */ | 
| 590 | 
  | 
                mktemp(illumtmp); | 
| 591 | 
< | 
                sprintf(combuf, "mkillum%s %s \"<\" %s > %s", mkopts, | 
| 591 | 
> | 
                sprintf(combuf, "%s%s %s \"<\" %s > %s", c_mkillum, mkopts, | 
| 592 | 
  | 
                                oct0name, vval(ILLUM), illumtmp); | 
| 593 | 
  | 
                if (runcom(combuf)) {                   /* run it */ | 
| 594 | 
< | 
                        fprintf(stderr, "%s: error running mkillum\n", | 
| 595 | 
< | 
                                        progname); | 
| 594 | 
> | 
                        fprintf(stderr, "%s: error running %s\n", | 
| 595 | 
> | 
                                        progname, c_mkillum); | 
| 596 | 
  | 
                        unlink(illumtmp); | 
| 597 | 
  | 
                        quit(1); | 
| 598 | 
  | 
                } | 
| 599 | 
+ | 
                rmfile(oct0name); | 
| 600 | 
  | 
                                                /* make octree1 (frozen) */ | 
| 601 | 
  | 
                if (octreedate) | 
| 602 | 
< | 
                        sprintf(combuf, "oconv%s -f -i %s %s > %s", ocopts, | 
| 603 | 
< | 
                                vval(OCTREE), illumtmp, oct1name); | 
| 602 | 
> | 
                        sprintf(combuf, "%s%s -f -i %s %s > %s", c_oconv, | 
| 603 | 
> | 
                                ocopts, vval(OCTREE), illumtmp, oct1name); | 
| 604 | 
  | 
                else if (vdef(MATERIAL)) | 
| 605 | 
< | 
                        sprintf(combuf, "oconv%s -f %s %s > %s", ocopts, | 
| 606 | 
< | 
                                vval(MATERIAL), illumtmp, oct1name); | 
| 605 | 
> | 
                        sprintf(combuf, "%s%s -f %s %s > %s", c_oconv, | 
| 606 | 
> | 
                                ocopts, vval(MATERIAL), illumtmp, oct1name); | 
| 607 | 
  | 
                else | 
| 608 | 
< | 
                        sprintf(combuf, "oconv%s -f %s > %s", ocopts, | 
| 608 | 
> | 
                        sprintf(combuf, "%s%s -f %s > %s", c_oconv, ocopts, | 
| 609 | 
  | 
                                illumtmp, oct1name); | 
| 610 | 
  | 
                if (runcom(combuf)) {           /* run it */ | 
| 611 | 
  | 
                        fprintf(stderr, | 
| 623 | 
  | 
} | 
| 624 | 
  | 
 | 
| 625 | 
  | 
 | 
| 626 | 
+ | 
static void | 
| 627 | 
+ | 
mkpmap(void)                    /* run mkpmap if indicated */ | 
| 628 | 
+ | 
{ | 
| 629 | 
+ | 
        char    combuf[2048], *cp; | 
| 630 | 
+ | 
        time_t  tnow; | 
| 631 | 
+ | 
                                /* nothing to do? */ | 
| 632 | 
+ | 
        if ((pgmapname == NULL) | (pgmapdate >= oct1date) && | 
| 633 | 
+ | 
                        (pcmapname == NULL) | (pcmapdate >= oct1date)) | 
| 634 | 
+ | 
                return; | 
| 635 | 
+ | 
                                /* just update existing file dates? */ | 
| 636 | 
+ | 
        if (touchonly && (pgmapname == NULL) | (pgmapdate > 0) && | 
| 637 | 
+ | 
                        (pcmapname == NULL) | (pcmapdate > 0)) { | 
| 638 | 
+ | 
                if (pgmapname != NULL) | 
| 639 | 
+ | 
                        touch(pgmapname); | 
| 640 | 
+ | 
                if (pcmapname != NULL) | 
| 641 | 
+ | 
                        touch(pcmapname); | 
| 642 | 
+ | 
        } else {                /* else need to (re)run pkpmap */ | 
| 643 | 
+ | 
                strcpy(combuf, c_mkpmap); | 
| 644 | 
+ | 
                for (cp = combuf; *cp; cp++) | 
| 645 | 
+ | 
                        ; | 
| 646 | 
+ | 
                mkpmapopts(cp); | 
| 647 | 
+ | 
                if (vdef(REPORT)) { | 
| 648 | 
+ | 
                        char    errfile[256]; | 
| 649 | 
+ | 
                        int     n; | 
| 650 | 
+ | 
                        double  minutes; | 
| 651 | 
+ | 
                        n = sscanf(vval(REPORT), "%lf %s", &minutes, errfile); | 
| 652 | 
+ | 
                        if (n == 2) | 
| 653 | 
+ | 
                                sprintf(cp, " -t %d -e %s", (int)(minutes*60), errfile); | 
| 654 | 
+ | 
                        else if (n == 1) | 
| 655 | 
+ | 
                                sprintf(cp, " -t %d", (int)(minutes*60)); | 
| 656 | 
+ | 
                        else | 
| 657 | 
+ | 
                                badvalue(REPORT); | 
| 658 | 
+ | 
                } | 
| 659 | 
+ | 
                if (pgmapname != NULL && pgmapdate < oct1date) { | 
| 660 | 
+ | 
                        unlink(pgmapname); | 
| 661 | 
+ | 
                        cp = addarg(cp, "-apg"); | 
| 662 | 
+ | 
                        addarg(cp, vval(PGMAP)); | 
| 663 | 
+ | 
                        cp = sskip(sskip(cp));  /* remove any bandwidth */ | 
| 664 | 
+ | 
                        *cp = '\0'; | 
| 665 | 
+ | 
                } | 
| 666 | 
+ | 
                if (pcmapname != NULL && pcmapdate < oct1date) { | 
| 667 | 
+ | 
                        unlink(pcmapname); | 
| 668 | 
+ | 
                        cp = addarg(cp, "-apc"); | 
| 669 | 
+ | 
                        addarg(cp, vval(PCMAP)); | 
| 670 | 
+ | 
                        cp = sskip(sskip(cp));  /* remove any bandwidth */ | 
| 671 | 
+ | 
                        *cp = '\0'; | 
| 672 | 
+ | 
                } | 
| 673 | 
+ | 
                cp = addarg(cp, oct1name); | 
| 674 | 
+ | 
                if (runcom(combuf)) { | 
| 675 | 
+ | 
                        fprintf(stderr, "%s: error running %s\n", | 
| 676 | 
+ | 
                                        progname, c_mkpmap); | 
| 677 | 
+ | 
                        if (pgmapname != NULL && pgmapdate < oct1date) | 
| 678 | 
+ | 
                                unlink(pgmapname); | 
| 679 | 
+ | 
                        if (pcmapname != NULL && pcmapdate < oct1date) | 
| 680 | 
+ | 
                                unlink(pcmapname); | 
| 681 | 
+ | 
                        quit(1); | 
| 682 | 
+ | 
                } | 
| 683 | 
+ | 
        } | 
| 684 | 
+ | 
        tnow = time((time_t *)NULL); | 
| 685 | 
+ | 
        if (pgmapname != NULL) | 
| 686 | 
+ | 
                pgmapdate = tnow; | 
| 687 | 
+ | 
        if (pcmapname != NULL) | 
| 688 | 
+ | 
                pcmapdate = tnow; | 
| 689 | 
+ | 
        oct1date = tnow;        /* trigger ambient file removal if needed */ | 
| 690 | 
+ | 
} | 
| 691 | 
+ | 
 | 
| 692 | 
+ | 
 | 
| 693 | 
  | 
static char * | 
| 694 | 
< | 
addarg(                         /* add argument and advance pointer */ | 
| 695 | 
< | 
register char   *op, | 
| 696 | 
< | 
register char   *arg | 
| 694 | 
> | 
addarg(                         /* append argument and advance pointer */ | 
| 695 | 
> | 
char    *op, | 
| 696 | 
> | 
char    *arg | 
| 697 | 
  | 
) | 
| 698 | 
  | 
{ | 
| 699 | 
+ | 
        while (*op) | 
| 700 | 
+ | 
                op++; | 
| 701 | 
  | 
        *op = ' '; | 
| 702 | 
  | 
        while ( (*++op = *arg++) ) | 
| 703 | 
  | 
                ; | 
| 707 | 
  | 
 | 
| 708 | 
  | 
static void | 
| 709 | 
  | 
oconvopts(                              /* get oconv options */ | 
| 710 | 
< | 
        register char   *oo | 
| 710 | 
> | 
        char    *oo | 
| 711 | 
  | 
) | 
| 712 | 
  | 
{ | 
| 713 | 
  | 
        /* BEWARE:  This may be called via setdefaults(), so no assumptions */ | 
| 714 | 
  | 
 | 
| 715 | 
  | 
        *oo = '\0'; | 
| 716 | 
< | 
        if (vdef(OCONV)) | 
| 717 | 
< | 
                addarg(oo, vval(OCONV)); | 
| 716 | 
> | 
        if (!vdef(OCONV)) | 
| 717 | 
> | 
                return; | 
| 718 | 
> | 
        if (vval(OCONV)[0] != '-') { | 
| 719 | 
> | 
                atos(c_oconv, sizeof(c_oconv), vval(OCONV)); | 
| 720 | 
> | 
                oo = addarg(oo, sskip2(vval(OCONV), 1)); | 
| 721 | 
> | 
        } else | 
| 722 | 
> | 
                oo = addarg(oo, vval(OCONV)); | 
| 723 | 
  | 
} | 
| 724 | 
  | 
 | 
| 725 | 
  | 
 | 
| 730 | 
  | 
{ | 
| 731 | 
  | 
        /* BEWARE:  This may be called via setdefaults(), so no assumptions */ | 
| 732 | 
  | 
 | 
| 733 | 
< | 
        if (nprocs > 1) { | 
| 733 | 
> | 
        if (nprocs > 1) | 
| 734 | 
  | 
                sprintf(mo, " -n %d", nprocs); | 
| 735 | 
< | 
                while (*mo) | 
| 610 | 
< | 
                        mo++; | 
| 611 | 
< | 
        } else | 
| 735 | 
> | 
        else | 
| 736 | 
  | 
                *mo = '\0'; | 
| 737 | 
< | 
        if (vdef(MKILLUM)) | 
| 738 | 
< | 
                addarg(mo, vval(MKILLUM)); | 
| 737 | 
> | 
        if (!vdef(MKILLUM)) | 
| 738 | 
> | 
                return; | 
| 739 | 
> | 
        if (vval(MKILLUM)[0] != '-') { | 
| 740 | 
> | 
                atos(c_mkillum, sizeof(c_mkillum), vval(MKILLUM)); | 
| 741 | 
> | 
                mo = addarg(mo, sskip2(vval(MKILLUM), 1)); | 
| 742 | 
> | 
        } else | 
| 743 | 
> | 
                mo = addarg(mo, vval(MKILLUM)); | 
| 744 | 
  | 
} | 
| 745 | 
  | 
 | 
| 746 | 
  | 
 | 
| 747 | 
  | 
static void | 
| 748 | 
+ | 
mkpmapopts(                             /* get mkpmap options */ | 
| 749 | 
+ | 
        char    *mo | 
| 750 | 
+ | 
) | 
| 751 | 
+ | 
{ | 
| 752 | 
+ | 
        /* BEWARE:  This may be called via setdefaults(), so no assumptions */ | 
| 753 | 
+ | 
 | 
| 754 | 
+ | 
        *mo = '\0'; | 
| 755 | 
+ | 
        if (!vdef(MKPMAP)) | 
| 756 | 
+ | 
                return; | 
| 757 | 
+ | 
        if (vval(MKPMAP)[0] != '-') { | 
| 758 | 
+ | 
                atos(c_mkpmap, sizeof(c_mkpmap), vval(MKPMAP)); | 
| 759 | 
+ | 
                mo = addarg(mo, sskip2(vval(MKPMAP), 1)); | 
| 760 | 
+ | 
        } else | 
| 761 | 
+ | 
                mo = addarg(mo, vval(MKPMAP)); | 
| 762 | 
+ | 
} | 
| 763 | 
+ | 
 | 
| 764 | 
+ | 
 | 
| 765 | 
+ | 
static void | 
| 766 | 
  | 
checkambfile(void)                      /* check date on ambient file */ | 
| 767 | 
  | 
{ | 
| 768 | 
  | 
        time_t  afdate; | 
| 803 | 
  | 
        char    *po | 
| 804 | 
  | 
) | 
| 805 | 
  | 
{ | 
| 806 | 
+ | 
        char    pmapf[256], *bw; | 
| 807 | 
+ | 
 | 
| 808 | 
  | 
        switch(vscale(QUALITY)) { | 
| 809 | 
  | 
        case LOW: | 
| 810 | 
  | 
                lowqopts(op, po); | 
| 816 | 
  | 
                hiqopts(op, po); | 
| 817 | 
  | 
                break; | 
| 818 | 
  | 
        } | 
| 819 | 
+ | 
        if (vdef(PGMAP)) { | 
| 820 | 
+ | 
                bw = sskip2(vval(PGMAP), 2); | 
| 821 | 
+ | 
                atos(pmapf, sizeof(pmapf), vval(PGMAP)); | 
| 822 | 
+ | 
                op = addarg(addarg(op, "-ap"), pmapf); | 
| 823 | 
+ | 
                if (atoi(bw) > 0) op = addarg(op, bw); | 
| 824 | 
+ | 
        } | 
| 825 | 
+ | 
        if (vdef(PCMAP)) { | 
| 826 | 
+ | 
                bw = sskip2(vval(PCMAP), 2); | 
| 827 | 
+ | 
                atos(pmapf, sizeof(pmapf), vval(PCMAP)); | 
| 828 | 
+ | 
                op = addarg(addarg(op, "-ap"), pmapf); | 
| 829 | 
+ | 
                if (atoi(bw) > 0) op = addarg(op, bw); | 
| 830 | 
+ | 
        } | 
| 831 | 
+ | 
        if (vdef(RENDER)) | 
| 832 | 
+ | 
                op = addarg(op, vval(RENDER)); | 
| 833 | 
+ | 
        if (rvdevice != NULL) { | 
| 834 | 
+ | 
                if (vdef(RVU)) | 
| 835 | 
+ | 
                        if (vval(RVU)[0] != '-') { | 
| 836 | 
+ | 
                                atos(c_rvu, sizeof(c_rvu), vval(RVU)); | 
| 837 | 
+ | 
                                po = addarg(po, sskip2(vval(RVU), 1)); | 
| 838 | 
+ | 
                        } else | 
| 839 | 
+ | 
                                po = addarg(po, vval(RVU)); | 
| 840 | 
+ | 
        } else { | 
| 841 | 
+ | 
                if (vdef(RPICT)) | 
| 842 | 
+ | 
                        if (vval(RPICT)[0] != '-') { | 
| 843 | 
+ | 
                                atos(c_rpict, sizeof(c_rpict), vval(RPICT)); | 
| 844 | 
+ | 
                                po = addarg(po, sskip2(vval(RPICT), 1)); | 
| 845 | 
+ | 
                        } else | 
| 846 | 
+ | 
                                po = addarg(po, vval(RPICT)); | 
| 847 | 
+ | 
        } | 
| 848 | 
  | 
} | 
| 849 | 
  | 
 | 
| 850 | 
  | 
 | 
| 851 | 
  | 
static void | 
| 852 | 
  | 
lowqopts(                       /* low quality rendering options */ | 
| 853 | 
< | 
        register char   *op, | 
| 853 | 
> | 
        char    *op, | 
| 854 | 
  | 
        char    *po | 
| 855 | 
  | 
) | 
| 856 | 
  | 
{ | 
| 891 | 
  | 
                op = addarg(op, "-ds .4"); | 
| 892 | 
  | 
        else | 
| 893 | 
  | 
                op = addarg(op, "-ds 0"); | 
| 894 | 
< | 
        op = addarg(op, "-dt .2 -dc .25 -dr 0 -sj 0 -st .5"); | 
| 894 | 
> | 
        op = addarg(op, "-dt .2 -dc .25 -dr 0 -ss 0 -st .5"); | 
| 895 | 
  | 
        if (vdef(AMBFILE)) { | 
| 896 | 
  | 
                sprintf(op, " -af %s", vval(AMBFILE)); | 
| 897 | 
  | 
                op += strlen(op); | 
| 912 | 
  | 
        d = ambval(); | 
| 913 | 
  | 
        sprintf(op, " -av %.2g %.2g %.2g", d, d, d); | 
| 914 | 
  | 
        op += strlen(op); | 
| 915 | 
< | 
        op = addarg(op, "-lr 6 -lw .01"); | 
| 738 | 
< | 
        if (vdef(RENDER)) | 
| 739 | 
< | 
                op = addarg(op, vval(RENDER)); | 
| 915 | 
> | 
        op = addarg(op, "-lr 6 -lw .003"); | 
| 916 | 
  | 
} | 
| 917 | 
  | 
 | 
| 918 | 
  | 
 | 
| 919 | 
  | 
static void | 
| 920 | 
  | 
medqopts(                       /* medium quality rendering options */ | 
| 921 | 
< | 
        register char   *op, | 
| 921 | 
> | 
        char    *op, | 
| 922 | 
  | 
        char    *po | 
| 923 | 
  | 
) | 
| 924 | 
  | 
{ | 
| 963 | 
  | 
        } | 
| 964 | 
  | 
        po = addarg(po, "-pt .08"); | 
| 965 | 
  | 
        if (vbool(PENUMBRAS)) | 
| 966 | 
< | 
                op = addarg(op, "-ds .2 -dj .5"); | 
| 966 | 
> | 
                op = addarg(op, "-ds .2 -dj .9"); | 
| 967 | 
  | 
        else | 
| 968 | 
  | 
                op = addarg(op, "-ds .3"); | 
| 969 | 
< | 
        op = addarg(op, "-dt .1 -dc .5 -dr 1 -sj .7 -st .1"); | 
| 969 | 
> | 
        op = addarg(op, "-dt .1 -dc .5 -dr 1 -ss 1 -st .1"); | 
| 970 | 
  | 
        if ( (overture = vint(INDIRECT)) ) { | 
| 971 | 
  | 
                sprintf(op, " -ab %d", overture); | 
| 972 | 
  | 
                op += strlen(op); | 
| 990 | 
  | 
        d = ambval(); | 
| 991 | 
  | 
        sprintf(op, " -av %.2g %.2g %.2g", d, d, d); | 
| 992 | 
  | 
        op += strlen(op); | 
| 993 | 
< | 
        op = addarg(op, "-lr 8 -lw .002"); | 
| 818 | 
< | 
        if (vdef(RENDER)) | 
| 819 | 
< | 
                op = addarg(op, vval(RENDER)); | 
| 993 | 
> | 
        op = addarg(op, "-lr 8 -lw 1e-4"); | 
| 994 | 
  | 
} | 
| 995 | 
  | 
 | 
| 996 | 
  | 
 | 
| 997 | 
  | 
static void | 
| 998 | 
  | 
hiqopts(                                /* high quality rendering options */ | 
| 999 | 
< | 
        register char   *op, | 
| 999 | 
> | 
        char    *op, | 
| 1000 | 
  | 
        char    *po | 
| 1001 | 
  | 
) | 
| 1002 | 
  | 
{ | 
| 1041 | 
  | 
        } | 
| 1042 | 
  | 
        po = addarg(po, "-pt .04"); | 
| 1043 | 
  | 
        if (vbool(PENUMBRAS)) | 
| 1044 | 
< | 
                op = addarg(op, "-ds .1 -dj .65"); | 
| 1044 | 
> | 
                op = addarg(op, "-ds .1 -dj .9"); | 
| 1045 | 
  | 
        else | 
| 1046 | 
  | 
                op = addarg(op, "-ds .2"); | 
| 1047 | 
< | 
        op = addarg(op, "-dt .05 -dc .75 -dr 3 -sj 1 -st .01"); | 
| 1047 | 
> | 
        op = addarg(op, "-dt .05 -dc .75 -dr 3 -ss 16 -st .01"); | 
| 1048 | 
  | 
        sprintf(op, " -ab %d", overture=vint(INDIRECT)+1); | 
| 1049 | 
  | 
        op += strlen(op); | 
| 1050 | 
  | 
        if (vdef(AMBFILE)) { | 
| 1066 | 
  | 
        d = ambval(); | 
| 1067 | 
  | 
        sprintf(op, " -av %.2g %.2g %.2g", d, d, d); | 
| 1068 | 
  | 
        op += strlen(op); | 
| 1069 | 
< | 
        op = addarg(op, "-lr 12 -lw .0005"); | 
| 896 | 
< | 
        if (vdef(RENDER)) | 
| 897 | 
< | 
                op = addarg(op, vval(RENDER)); | 
| 1069 | 
> | 
        op = addarg(op, "-lr 12 -lw 1e-5"); | 
| 1070 | 
  | 
} | 
| 1071 | 
  | 
 | 
| 1072 | 
  | 
 | 
| 1073 | 
+ | 
#ifdef _WIN32 | 
| 1074 | 
  | 
static void | 
| 1075 | 
+ | 
setenv(                 /* set an environment variable */ | 
| 1076 | 
+ | 
        char    *vname, | 
| 1077 | 
+ | 
        char    *value | 
| 1078 | 
+ | 
) | 
| 1079 | 
+ | 
{ | 
| 1080 | 
+ | 
        char    *evp; | 
| 1081 | 
+ | 
 | 
| 1082 | 
+ | 
        evp = bmalloc(strlen(vname)+strlen(value)+2); | 
| 1083 | 
+ | 
        if (evp == NULL) | 
| 1084 | 
+ | 
                syserr(progname); | 
| 1085 | 
+ | 
        sprintf(evp, "%s=%s", vname, value); | 
| 1086 | 
+ | 
        if (putenv(evp) != 0) { | 
| 1087 | 
+ | 
                fprintf(stderr, "%s: out of environment space\n", progname); | 
| 1088 | 
+ | 
                quit(1); | 
| 1089 | 
+ | 
        } | 
| 1090 | 
+ | 
        if (!silent) | 
| 1091 | 
+ | 
                printf("set %s\n", evp); | 
| 1092 | 
+ | 
} | 
| 1093 | 
+ | 
#endif | 
| 1094 | 
+ | 
 | 
| 1095 | 
+ | 
 | 
| 1096 | 
+ | 
static void | 
| 1097 | 
  | 
xferopts(                               /* transfer options if indicated */ | 
| 1098 | 
  | 
        char    *ro | 
| 1099 | 
  | 
) | 
| 1100 | 
  | 
{ | 
| 1101 | 
  | 
        int     fd, n; | 
| 1102 | 
< | 
        register char   *cp; | 
| 1102 | 
> | 
        char    *cp; | 
| 1103 | 
  | 
         | 
| 1104 | 
  | 
        n = strlen(ro); | 
| 1105 | 
  | 
        if (n < 2) | 
| 1128 | 
  | 
 | 
| 1129 | 
  | 
static void | 
| 1130 | 
  | 
pfiltopts(                              /* get pfilt options */ | 
| 1131 | 
< | 
        register char   *po | 
| 1131 | 
> | 
        char    *po | 
| 1132 | 
  | 
) | 
| 1133 | 
  | 
{ | 
| 1134 | 
  | 
        *po = '\0'; | 
| 1145 | 
  | 
                break; | 
| 1146 | 
  | 
        } | 
| 1147 | 
  | 
        if (vdef(PFILT)) | 
| 1148 | 
< | 
                po = addarg(po, vval(PFILT)); | 
| 1148 | 
> | 
                if (vval(PFILT)[0] != '-') { | 
| 1149 | 
> | 
                        atos(c_pfilt, sizeof(c_pfilt), vval(PFILT)); | 
| 1150 | 
> | 
                        po = addarg(po, sskip2(vval(PFILT), 1)); | 
| 1151 | 
> | 
                } else | 
| 1152 | 
> | 
                        po = addarg(po, vval(PFILT)); | 
| 1153 | 
  | 
} | 
| 1154 | 
  | 
 | 
| 1155 | 
  | 
 | 
| 1156 | 
  | 
static int | 
| 1157 | 
  | 
matchword(                      /* match white-delimited words */ | 
| 1158 | 
< | 
        register char   *s1, | 
| 1159 | 
< | 
        register char   *s2 | 
| 1158 | 
> | 
        char    *s1, | 
| 1159 | 
> | 
        char    *s2 | 
| 1160 | 
  | 
) | 
| 1161 | 
  | 
{ | 
| 1162 | 
  | 
        while (isspace(*s1)) s1++; | 
| 1170 | 
  | 
 | 
| 1171 | 
  | 
static char * | 
| 1172 | 
  | 
specview(                               /* get proper view spec from vs */ | 
| 1173 | 
< | 
        register char   *vs | 
| 1173 | 
> | 
        char    *vs | 
| 1174 | 
  | 
) | 
| 1175 | 
  | 
{ | 
| 1176 | 
  | 
        static char     vup[7][12] = {"-vu 0 0 -1","-vu 0 -1 0","-vu -1 0 0", | 
| 1177 | 
  | 
                        "-vu 0 0 1", "-vu 1 0 0","-vu 0 1 0","-vu 0 0 1"}; | 
| 1178 | 
  | 
        static char     viewopts[128]; | 
| 1179 | 
< | 
        register char   *cp; | 
| 1179 | 
> | 
        char    *cp; | 
| 1180 | 
  | 
        int     xpos, ypos, zpos, viewtype, upax; | 
| 1181 | 
< | 
        register int    i; | 
| 1181 | 
> | 
        int     i; | 
| 1182 | 
  | 
        double  cent[3], dim[3], mult, d; | 
| 1183 | 
  | 
 | 
| 1184 | 
  | 
        if (vs == NULL || *vs == '-') | 
| 1211 | 
  | 
        } else if (*vs == 'z') { | 
| 1212 | 
  | 
                zpos = -1; vs++; | 
| 1213 | 
  | 
        } | 
| 1214 | 
< | 
        viewtype = 'v'; | 
| 1215 | 
< | 
        if((*vs == 'v') | (*vs == 'l') | (*vs == 'a') | (*vs == 'h') | (*vs == 'c')) | 
| 1214 | 
> | 
        switch (*vs) { | 
| 1215 | 
> | 
        case VT_PER: | 
| 1216 | 
> | 
        case VT_PAR: | 
| 1217 | 
> | 
        case VT_ANG: | 
| 1218 | 
> | 
        case VT_HEM: | 
| 1219 | 
> | 
        case VT_PLS: | 
| 1220 | 
> | 
        case VT_CYL: | 
| 1221 | 
  | 
                viewtype = *vs++; | 
| 1222 | 
+ | 
                break; | 
| 1223 | 
+ | 
        default: | 
| 1224 | 
+ | 
                viewtype = VT_PER; | 
| 1225 | 
+ | 
                break; | 
| 1226 | 
+ | 
        } | 
| 1227 | 
  | 
        cp = viewopts; | 
| 1228 | 
  | 
        if ((!*vs || isspace(*vs)) && (xpos|ypos|zpos)) {       /* got one! */ | 
| 1229 | 
  | 
                *cp++ = '-'; *cp++ = 'v'; *cp++ = 't'; *cp++ = viewtype; | 
| 1238 | 
  | 
                        cent[i] += .5*dim[i]; | 
| 1239 | 
  | 
                } | 
| 1240 | 
  | 
                mult = vlet(ZONE)=='E' ? 2. : .45 ; | 
| 1241 | 
< | 
                sprintf(cp, " -vp %.2g %.2g %.2g -vd %.2g %.2g %.2g", | 
| 1241 | 
> | 
                sprintf(cp, " -vp %.3g %.3g %.3g -vd %.3g %.3g %.3g", | 
| 1242 | 
  | 
                                cent[0]+xpos*mult*dim[0], | 
| 1243 | 
  | 
                                cent[1]+ypos*mult*dim[1], | 
| 1244 | 
  | 
                                cent[2]+zpos*mult*dim[2], | 
| 1265 | 
  | 
                } | 
| 1266 | 
  | 
                cp = addarg(cp, vup[upax+3]); | 
| 1267 | 
  | 
                switch (viewtype) { | 
| 1268 | 
< | 
                case 'v': | 
| 1268 | 
> | 
                case VT_PER: | 
| 1269 | 
  | 
                        cp = addarg(cp, "-vh 45 -vv 45"); | 
| 1270 | 
  | 
                        break; | 
| 1271 | 
< | 
                case 'l': | 
| 1271 | 
> | 
                case VT_PAR: | 
| 1272 | 
  | 
                        d = sqrt(dim[0]*dim[0]+dim[1]*dim[1]+dim[2]*dim[2]); | 
| 1273 | 
< | 
                        sprintf(cp, " -vh %.2g -vv %.2g", d, d); | 
| 1273 | 
> | 
                        sprintf(cp, " -vh %.3g -vv %.3g", d, d); | 
| 1274 | 
  | 
                        cp += strlen(cp); | 
| 1275 | 
  | 
                        break; | 
| 1276 | 
< | 
                case 'a': | 
| 1277 | 
< | 
                case 'h': | 
| 1276 | 
> | 
                case VT_ANG: | 
| 1277 | 
> | 
                case VT_HEM: | 
| 1278 | 
> | 
                case VT_PLS: | 
| 1279 | 
  | 
                        cp = addarg(cp, "-vh 180 -vv 180"); | 
| 1280 | 
  | 
                        break; | 
| 1281 | 
< | 
                case 'c': | 
| 1281 | 
> | 
                case VT_CYL: | 
| 1282 | 
  | 
                        cp = addarg(cp, "-vh 180 -vv 90"); | 
| 1283 | 
  | 
                        break; | 
| 1284 | 
  | 
                } | 
| 1286 | 
  | 
                while (!isspace(*vs))           /* else skip id */ | 
| 1287 | 
  | 
                        if (!*vs++) | 
| 1288 | 
  | 
                                return(NULL); | 
| 1289 | 
< | 
                if (upax) {                     /* specify up vector */ | 
| 1289 | 
> | 
                if (upax) {                     /* prepend up vector */ | 
| 1290 | 
  | 
                        strcpy(cp, vup[upax+3]); | 
| 1291 | 
  | 
                        cp += strlen(cp); | 
| 1292 | 
  | 
                } | 
| 1310 | 
  | 
        char    *vn             /* returned view name */ | 
| 1311 | 
  | 
) | 
| 1312 | 
  | 
{ | 
| 1313 | 
< | 
        register char   *mv; | 
| 1313 | 
> | 
        char    *mv; | 
| 1314 | 
  | 
 | 
| 1315 | 
  | 
        if (viewselect != NULL) {               /* command-line selected */ | 
| 1316 | 
  | 
                if (n)                          /* only do one */ | 
| 1317 | 
  | 
                        return(NULL); | 
| 1318 | 
+ | 
                                         | 
| 1319 | 
+ | 
                if (isint(viewselect)) {        /* view number? */ | 
| 1320 | 
+ | 
                        n = atoi(viewselect)-1; | 
| 1321 | 
+ | 
                        goto numview; | 
| 1322 | 
+ | 
                } | 
| 1323 | 
  | 
                if (viewselect[0] == '-') {     /* already specified */ | 
| 1324 | 
< | 
                        if (vn != NULL) *vn = '\0'; | 
| 1324 | 
> | 
                        if (vn != NULL) | 
| 1325 | 
> | 
                                strcpy(vn, "0"); | 
| 1326 | 
  | 
                        return(viewselect); | 
| 1327 | 
  | 
                } | 
| 1328 | 
  | 
                if (vn != NULL) { | 
| 1331 | 
  | 
                                ; | 
| 1332 | 
  | 
                        *vn = '\0'; | 
| 1333 | 
  | 
                } | 
| 1118 | 
– | 
                                                /* view number? */ | 
| 1119 | 
– | 
                if (isint(viewselect)) | 
| 1120 | 
– | 
                        return(specview(nvalue(VIEWS, atoi(viewselect)-1))); | 
| 1334 | 
  | 
                                                /* check list */ | 
| 1335 | 
  | 
                while ((mv = nvalue(VIEWS, n++)) != NULL) | 
| 1336 | 
  | 
                        if (matchword(viewselect, mv)) | 
| 1337 | 
  | 
                                return(specview(mv)); | 
| 1338 | 
+ | 
 | 
| 1339 | 
  | 
                return(specview(viewselect));   /* standard view? */ | 
| 1340 | 
  | 
        } | 
| 1341 | 
+ | 
numview: | 
| 1342 | 
  | 
        mv = nvalue(VIEWS, n);          /* use view n */ | 
| 1343 | 
< | 
        if ((vn != NULL) & (mv != NULL)) { | 
| 1344 | 
< | 
                register char   *mv2 = mv; | 
| 1345 | 
< | 
                if (*mv2 != '-') | 
| 1343 | 
> | 
        if ((vn != NULL) & (mv != NULL)) | 
| 1344 | 
> | 
                if (*mv != '-') { | 
| 1345 | 
> | 
                        char    *mv2 = mv; | 
| 1346 | 
  | 
                        while (*mv2 && !isspace(*mv2)) | 
| 1347 | 
  | 
                                *vn++ = *mv2++; | 
| 1348 | 
< | 
                *vn = '\0'; | 
| 1349 | 
< | 
        } | 
| 1348 | 
> | 
                        *vn = '\0'; | 
| 1349 | 
> | 
                } else | 
| 1350 | 
> | 
                        sprintf(vn, "%d", n+1); | 
| 1351 | 
> | 
 | 
| 1352 | 
  | 
        return(specview(mv)); | 
| 1353 | 
  | 
} | 
| 1354 | 
  | 
 | 
| 1355 | 
  | 
 | 
| 1356 | 
  | 
static int | 
| 1357 | 
  | 
myprintview(                    /* print out selected view */ | 
| 1358 | 
< | 
        register char   *vopts, | 
| 1358 | 
> | 
        char    *vopts, | 
| 1359 | 
  | 
        FILE    *fp | 
| 1360 | 
  | 
) | 
| 1361 | 
  | 
{ | 
| 1362 | 
  | 
        VIEW    vwr; | 
| 1363 | 
  | 
        char    buf[128]; | 
| 1364 | 
< | 
        register char   *cp; | 
| 1364 | 
> | 
        char    *cp; | 
| 1365 | 
  | 
#ifdef _WIN32 | 
| 1366 | 
  | 
/* XXX Should we allow something like this for all platforms? */ | 
| 1367 | 
  | 
/* XXX Or is it still required at all? */ | 
| 1402 | 
  | 
                return; | 
| 1403 | 
  | 
        if (sayview) | 
| 1404 | 
  | 
                myprintview(vw, stdout); | 
| 1405 | 
< | 
        sprintf(combuf, "rvu %s%s%s -R %s ", vw, po, opts, rifname); | 
| 1405 | 
> | 
        sprintf(combuf, "%s %s%s%s -R %s ", c_rvu, vw, opts, po, rifname); | 
| 1406 | 
> | 
        if (nprocs > 1) | 
| 1407 | 
> | 
                sprintf(combuf+strlen(combuf), "-n %d ", nprocs); | 
| 1408 | 
  | 
        if (rvdevice != NULL) | 
| 1409 | 
  | 
                sprintf(combuf+strlen(combuf), "-o %s ", rvdevice); | 
| 1410 | 
  | 
        if (vdef(EXPOSURE)) | 
| 1411 | 
  | 
                sprintf(combuf+strlen(combuf), "-pe %s ", vval(EXPOSURE)); | 
| 1412 | 
  | 
        strcat(combuf, oct1name); | 
| 1413 | 
  | 
        if (runcom(combuf)) {           /* run it */ | 
| 1414 | 
< | 
                fprintf(stderr, "%s: error running rvu\n", progname); | 
| 1414 | 
> | 
                fprintf(stderr, "%s: error running %s\n", progname, c_rvu); | 
| 1415 | 
  | 
                quit(1); | 
| 1416 | 
  | 
        } | 
| 1417 | 
  | 
} | 
| 1418 | 
  | 
 | 
| 1419 | 
  | 
 | 
| 1420 | 
+ | 
static int | 
| 1421 | 
+ | 
syncf_done(                     /* check if an rpiece sync file is complete */ | 
| 1422 | 
+ | 
        char *sfname | 
| 1423 | 
+ | 
) | 
| 1424 | 
+ | 
{ | 
| 1425 | 
+ | 
        FILE    *fp = fopen(sfname, "r"); | 
| 1426 | 
+ | 
        int     todo = 1; | 
| 1427 | 
+ | 
        int     x, y; | 
| 1428 | 
+ | 
 | 
| 1429 | 
+ | 
        if (fp == NULL) | 
| 1430 | 
+ | 
                return(0); | 
| 1431 | 
+ | 
        if (fscanf(fp, "%d %d", &x, &y) != 2) | 
| 1432 | 
+ | 
                goto checked; | 
| 1433 | 
+ | 
        todo = x*y;             /* total number of tiles */ | 
| 1434 | 
+ | 
        if (fscanf(fp, "%d %d", &x, &y) != 2 || (x != 0) | (y != 0)) | 
| 1435 | 
+ | 
                goto checked; | 
| 1436 | 
+ | 
                                /* XXX assume no redundant tiles */ | 
| 1437 | 
+ | 
        while (fscanf(fp, "%d %d", &x, &y) == 2) | 
| 1438 | 
+ | 
                if (!--todo) | 
| 1439 | 
+ | 
                        break; | 
| 1440 | 
+ | 
checked: | 
| 1441 | 
+ | 
        fclose(fp); | 
| 1442 | 
+ | 
        return(!todo); | 
| 1443 | 
+ | 
} | 
| 1444 | 
+ | 
 | 
| 1445 | 
+ | 
 | 
| 1446 | 
  | 
static void | 
| 1447 | 
  | 
rpict(                          /* run rpict and pfilt for each view */ | 
| 1448 | 
  | 
        char    *opts, | 
| 1449 | 
  | 
        char    *po | 
| 1450 | 
  | 
) | 
| 1451 | 
  | 
{ | 
| 1452 | 
< | 
        char    combuf[PATH_MAX]; | 
| 1452 | 
> | 
#define do_rpiece       (sfile[0]!='\0') | 
| 1453 | 
> | 
        char    combuf[5*PATH_MAX+512]; | 
| 1454 | 
  | 
        char    rawfile[PATH_MAX], picfile[PATH_MAX]; | 
| 1455 | 
  | 
        char    zopt[PATH_MAX+4], rep[PATH_MAX+16], res[32]; | 
| 1456 | 
< | 
        char    rppopt[128], *pfile = NULL; | 
| 1456 | 
> | 
        char    rppopt[32], sfile[PATH_MAX], *pfile = NULL; | 
| 1457 | 
  | 
        char    pfopts[128]; | 
| 1458 | 
  | 
        char    vs[32], *vw; | 
| 1459 | 
  | 
        int     vn, mult; | 
| 1460 | 
  | 
        FILE    *fp; | 
| 1461 | 
  | 
        time_t  rfdt, pfdt; | 
| 1462 | 
+ | 
        int     xres, yres; | 
| 1463 | 
+ | 
        double  aspect; | 
| 1464 | 
+ | 
        int     n; | 
| 1465 | 
  | 
                                        /* get pfilt options */ | 
| 1466 | 
  | 
        pfiltopts(pfopts); | 
| 1467 | 
  | 
                                        /* get resolution, reporting */ | 
| 1476 | 
  | 
                mult = 3; | 
| 1477 | 
  | 
                break; | 
| 1478 | 
  | 
        } | 
| 1479 | 
< | 
        { | 
| 1480 | 
< | 
                int     xres, yres; | 
| 1481 | 
< | 
                double  aspect; | 
| 1482 | 
< | 
                int     n; | 
| 1483 | 
< | 
                n = sscanf(vval(RESOLUTION), "%d %d %lf", &xres, &yres, &aspect); | 
| 1484 | 
< | 
                if (n == 3) | 
| 1485 | 
< | 
                        sprintf(res, "-x %d -y %d -pa %.3f", | 
| 1486 | 
< | 
                                        mult*xres, mult*yres, aspect); | 
| 1487 | 
< | 
                else if (n) { | 
| 1488 | 
< | 
                        if (n == 1) yres = xres; | 
| 1240 | 
< | 
                        sprintf(res, "-x %d -y %d", mult*xres, mult*yres); | 
| 1241 | 
< | 
                } else | 
| 1242 | 
< | 
                        badvalue(RESOLUTION); | 
| 1243 | 
< | 
        } | 
| 1479 | 
> | 
        n = sscanf(vval(RESOLUTION), "%d %d %lf", &xres, &yres, &aspect); | 
| 1480 | 
> | 
        if (n == 3) | 
| 1481 | 
> | 
                sprintf(res, "-x %d -y %d -pa %.3f", | 
| 1482 | 
> | 
                                mult*xres, mult*yres, aspect); | 
| 1483 | 
> | 
        else if (n) { | 
| 1484 | 
> | 
                aspect = 1.; | 
| 1485 | 
> | 
                if (n == 1) yres = xres; | 
| 1486 | 
> | 
                sprintf(res, "-x %d -y %d", mult*xres, mult*yres); | 
| 1487 | 
> | 
        } else | 
| 1488 | 
> | 
                badvalue(RESOLUTION); | 
| 1489 | 
  | 
        rep[0] = '\0'; | 
| 1490 | 
  | 
        if (vdef(REPORT)) { | 
| 1491 | 
  | 
                double  minutes; | 
| 1247 | 
– | 
                int     n; | 
| 1492 | 
  | 
                n = sscanf(vval(REPORT), "%lf %s", &minutes, rawfile); | 
| 1493 | 
  | 
                if (n == 2) | 
| 1494 | 
  | 
                        sprintf(rep, " -t %d -e %s", (int)(minutes*60), rawfile); | 
| 1498 | 
  | 
                        badvalue(REPORT); | 
| 1499 | 
  | 
        } | 
| 1500 | 
  | 
                                        /* set up parallel rendering */ | 
| 1501 | 
< | 
        if ((nprocs > 1) & (!vdef(ZFILE))) { | 
| 1502 | 
< | 
                strcpy(rppopt, "-S 1 -PP pfXXXXXX"); | 
| 1503 | 
< | 
                pfile = rppopt+9; | 
| 1504 | 
< | 
                if (mktemp(pfile) == NULL) | 
| 1501 | 
> | 
        sfile[0] = '\0'; | 
| 1502 | 
> | 
        if ((nprocs > 1) & !touchonly & !vdef(ZFILE) && | 
| 1503 | 
> | 
                                        getview(0, vs) != NULL) { | 
| 1504 | 
> | 
                if (!strcmp(c_rpict, DEF_RPICT_PATH) && | 
| 1505 | 
> | 
                                getview(1, NULL) == NULL) { | 
| 1506 | 
> | 
                        sprintf(sfile, "%s_%s_rpsync.txt",  | 
| 1507 | 
> | 
                                vdef(RAWFILE) ? vval(RAWFILE) : vval(PICTURE), | 
| 1508 | 
> | 
                                        vs); | 
| 1509 | 
> | 
                        strcpy(rppopt, "-PP pfXXXXXX"); | 
| 1510 | 
> | 
                } else { | 
| 1511 | 
> | 
                        strcpy(rppopt, "-S 1 -PP pfXXXXXX"); | 
| 1512 | 
> | 
                } | 
| 1513 | 
> | 
                pfile = rppopt + strlen(rppopt) - 8; | 
| 1514 | 
> | 
                if (mktemp(pfile) == NULL) { | 
| 1515 | 
> | 
                        if (do_rpiece) { | 
| 1516 | 
> | 
                                fprintf(stderr, "%s: cannot create\n", pfile); | 
| 1517 | 
> | 
                                quit(1); | 
| 1518 | 
> | 
                        } | 
| 1519 | 
  | 
                        pfile = NULL; | 
| 1520 | 
+ | 
                } | 
| 1521 | 
  | 
        } | 
| 1522 | 
  | 
        vn = 0;                                 /* do each view */ | 
| 1523 | 
  | 
        while ((vw = getview(vn++, vs)) != NULL) { | 
| 1524 | 
  | 
                if (sayview) | 
| 1525 | 
  | 
                        myprintview(vw, stdout); | 
| 1526 | 
< | 
                if (!vs[0]) | 
| 1268 | 
< | 
                        sprintf(vs, "%d", vn); | 
| 1269 | 
< | 
                sprintf(picfile, "%s_%s.pic", vval(PICTURE), vs); | 
| 1526 | 
> | 
                sprintf(picfile, "%s_%s.hdr", vval(PICTURE), vs); | 
| 1527 | 
  | 
                if (vdef(ZFILE)) | 
| 1528 | 
  | 
                        sprintf(zopt, " -z %s_%s.zbf", vval(ZFILE), vs); | 
| 1529 | 
  | 
                else | 
| 1544 | 
  | 
                                touch(picfile); | 
| 1545 | 
  | 
                        continue; | 
| 1546 | 
  | 
                } | 
| 1547 | 
< | 
                if (next_process()) {           /* parallel running? */ | 
| 1547 | 
> | 
                                                /* parallel running? */ | 
| 1548 | 
> | 
                if (do_rpiece) { | 
| 1549 | 
> | 
                        if (rfdt < oct1date || !fdate(sfile)) { | 
| 1550 | 
> | 
                                int     xdiv = 8+nprocs/3, ydiv = 8+nprocs/3; | 
| 1551 | 
> | 
                                if (rfdt >= oct1date) { | 
| 1552 | 
> | 
                                        fprintf(stderr, | 
| 1553 | 
> | 
                "%s: partial output not created with %s\n", rawfile, c_rpiece); | 
| 1554 | 
> | 
                                        quit(1); | 
| 1555 | 
> | 
                                } | 
| 1556 | 
> | 
                                if (rfdt) {     /* start fresh */ | 
| 1557 | 
> | 
                                        rmfile(rawfile); | 
| 1558 | 
> | 
                                        rfdt = 0; | 
| 1559 | 
> | 
                                } | 
| 1560 | 
> | 
                                if (!silent) | 
| 1561 | 
> | 
                                        printf("\techo %d %d > %s\n", | 
| 1562 | 
> | 
                                                        xdiv, ydiv, sfile); | 
| 1563 | 
> | 
                                if ((fp = fopen(sfile, "w")) == NULL) { | 
| 1564 | 
> | 
                                        fprintf(stderr, "%s: cannot create\n", | 
| 1565 | 
> | 
                                                        sfile); | 
| 1566 | 
> | 
                                        quit(1); | 
| 1567 | 
> | 
                                } | 
| 1568 | 
> | 
                                fprintf(fp, "%d %d\n", xdiv, ydiv); | 
| 1569 | 
> | 
                                fclose(fp); | 
| 1570 | 
> | 
                        } | 
| 1571 | 
> | 
                } else if (next_process(0)) { | 
| 1572 | 
  | 
                        if (pfile != NULL) | 
| 1573 | 
< | 
                                sleep(20); | 
| 1573 | 
> | 
                                sleep(10); | 
| 1574 | 
  | 
                        continue; | 
| 1575 | 
< | 
                } | 
| 1575 | 
> | 
                } else if (!inchild()) | 
| 1576 | 
> | 
                        pfile = NULL; | 
| 1577 | 
  | 
                /* XXX Remember to call finish_process() */ | 
| 1578 | 
  | 
                                                /* build rpict command */ | 
| 1579 | 
< | 
                if (rfdt >= oct1date) {         /* recover */ | 
| 1580 | 
< | 
                        sprintf(combuf, "rpict%s%s%s%s -ro %s %s", | 
| 1581 | 
< | 
                                rep, po, opts, zopt, rawfile, oct1name); | 
| 1582 | 
< | 
                        if (runcom(combuf))     /* run rpict */ | 
| 1579 | 
> | 
                if (rfdt >= oct1date) {         /* already in progress */ | 
| 1580 | 
> | 
                        if (do_rpiece) { | 
| 1581 | 
> | 
                                sprintf(combuf, "%s -R %s %s%s %s %s%s%s -o %s %s", | 
| 1582 | 
> | 
                                                c_rpiece, sfile, rppopt, rep, vw, | 
| 1583 | 
> | 
                                                res, opts, po, rawfile, oct1name); | 
| 1584 | 
> | 
                                while (next_process(1)) { | 
| 1585 | 
> | 
                                        sleep(10); | 
| 1586 | 
> | 
                                        combuf[strlen(c_rpiece)+2] = 'F'; | 
| 1587 | 
> | 
                                } | 
| 1588 | 
> | 
                        } else | 
| 1589 | 
> | 
                                sprintf(combuf, "%s%s%s%s%s -ro %s %s", c_rpict, | 
| 1590 | 
> | 
                                        rep, opts, po, zopt, rawfile, oct1name); | 
| 1591 | 
> | 
                        if (runcom(combuf))     /* run rpict/rpiece */ | 
| 1592 | 
  | 
                                goto rperror; | 
| 1593 | 
  | 
                } else { | 
| 1594 | 
  | 
                        if (overture) {         /* run overture calculation */ | 
| 1595 | 
  | 
                                sprintf(combuf, | 
| 1596 | 
< | 
                                "rpict%s %s%s -x 64 -y 64 -ps 1 %s > %s", | 
| 1597 | 
< | 
                                                rep, vw, opts, | 
| 1596 | 
> | 
                                        "%s%s %s%s -x 64 -y 64 -ps 1 %s > %s", | 
| 1597 | 
> | 
                                                c_rpict, rep, vw, opts, | 
| 1598 | 
  | 
                                                oct1name, overfile); | 
| 1599 | 
< | 
                                if (runcom(combuf)) { | 
| 1600 | 
< | 
                                        fprintf(stderr, | 
| 1599 | 
> | 
                                if (!do_rpiece || !next_process(0)) { | 
| 1600 | 
> | 
                                        if (runcom(combuf)) { | 
| 1601 | 
> | 
                                                fprintf(stderr, | 
| 1602 | 
  | 
                                        "%s: error in overture for view %s\n", | 
| 1603 | 
< | 
                                                progname, vs); | 
| 1604 | 
< | 
                                        quit(1); | 
| 1605 | 
< | 
                                } | 
| 1603 | 
> | 
                                                        progname, vs); | 
| 1604 | 
> | 
                                                quit(1); | 
| 1605 | 
> | 
                                        } | 
| 1606 | 
  | 
#ifndef NULL_DEVICE | 
| 1607 | 
< | 
                                rmfile(overfile); | 
| 1607 | 
> | 
                                        rmfile(overfile); | 
| 1608 | 
  | 
#endif | 
| 1609 | 
+ | 
                                } else if (do_rpiece) | 
| 1610 | 
+ | 
                                        sleep(20); | 
| 1611 | 
  | 
                        } | 
| 1612 | 
< | 
                        sprintf(combuf, "rpict%s %s %s%s%s%s %s > %s", | 
| 1613 | 
< | 
                                        rep, vw, res, po, opts, | 
| 1614 | 
< | 
                                        zopt, oct1name, rawfile); | 
| 1615 | 
< | 
                        if (pfile != NULL && inchild()) { | 
| 1616 | 
< | 
                                                /* rpict persistent mode */ | 
| 1617 | 
< | 
                                if (!silent) { | 
| 1612 | 
> | 
                        if (do_rpiece) { | 
| 1613 | 
> | 
                                sprintf(combuf, "%s -F %s %s%s %s %s%s%s -o %s %s", | 
| 1614 | 
> | 
                                                c_rpiece, sfile, rppopt, rep, vw, | 
| 1615 | 
> | 
                                                res, opts, po, rawfile, oct1name); | 
| 1616 | 
> | 
                                while (next_process(1)) | 
| 1617 | 
> | 
                                        sleep(10); | 
| 1618 | 
> | 
                        } else { | 
| 1619 | 
> | 
                                sprintf(combuf, "%s%s %s %s%s%s%s %s > %s", | 
| 1620 | 
> | 
                                                c_rpict, rep, vw, res, opts, po, | 
| 1621 | 
> | 
                                                zopt, oct1name, rawfile); | 
| 1622 | 
> | 
                        } | 
| 1623 | 
> | 
                        if ((pfile != NULL) & !do_rpiece) { | 
| 1624 | 
> | 
                                if (!silent) | 
| 1625 | 
  | 
                                        printf("\t%s\n", combuf); | 
| 1325 | 
– | 
                                        fflush(stdout); | 
| 1326 | 
– | 
                                } | 
| 1327 | 
– | 
                                sprintf(combuf, "rpict%s %s %s%s%s %s > %s", | 
| 1328 | 
– | 
                                                rep, rppopt, res, po, opts, | 
| 1329 | 
– | 
                                                oct1name, rawfile); | 
| 1626 | 
  | 
                                fflush(stdout); | 
| 1627 | 
+ | 
                                sprintf(combuf, "%s%s %s %s%s%s %s > %s", | 
| 1628 | 
+ | 
                                                c_rpict, rep, rppopt, res, | 
| 1629 | 
+ | 
                                                opts, po, oct1name, rawfile); | 
| 1630 | 
  | 
                                fp = popen(combuf, "w"); | 
| 1631 | 
  | 
                                if (fp == NULL) | 
| 1632 | 
  | 
                                        goto rperror; | 
| 1633 | 
  | 
                                myprintview(vw, fp); | 
| 1634 | 
  | 
                                if (pclose(fp)) | 
| 1635 | 
  | 
                                        goto rperror; | 
| 1636 | 
< | 
                        } else {                /* rpict normal mode */ | 
| 1637 | 
< | 
                                if (runcom(combuf)) | 
| 1638 | 
< | 
                                        goto rperror; | 
| 1636 | 
> | 
                        } else if (runcom(combuf)) | 
| 1637 | 
> | 
                                goto rperror; | 
| 1638 | 
> | 
                } | 
| 1639 | 
> | 
                if (do_rpiece) {                /* need to finish raw, first */ | 
| 1640 | 
> | 
                        finish_process(); | 
| 1641 | 
> | 
                        wait_process(1); | 
| 1642 | 
> | 
                        if (!syncf_done(sfile)) { | 
| 1643 | 
> | 
                                fprintf(stderr, | 
| 1644 | 
> | 
                        "%s: %s did not complete rendering of view %s\n", | 
| 1645 | 
> | 
                                                progname, c_rpiece, vs); | 
| 1646 | 
> | 
                                quit(1); | 
| 1647 | 
  | 
                        } | 
| 1648 | 
  | 
                } | 
| 1649 | 
  | 
                if (!vdef(RAWFILE) || strcmp(vval(RAWFILE),vval(PICTURE))) { | 
| 1650 | 
  | 
                                                /* build pfilt command */ | 
| 1651 | 
< | 
                        if (mult > 1) | 
| 1652 | 
< | 
                                sprintf(combuf, "pfilt%s -x /%d -y /%d %s > %s", | 
| 1653 | 
< | 
                                        pfopts, mult, mult, rawfile, picfile); | 
| 1651 | 
> | 
                        if (do_rpiece) | 
| 1652 | 
> | 
                                sprintf(combuf, | 
| 1653 | 
> | 
                                        "%s%s -x %d -y %d -p %.3f %s > %s", | 
| 1654 | 
> | 
                                        c_pfilt, pfopts, xres, yres, aspect, | 
| 1655 | 
> | 
                                        rawfile, picfile); | 
| 1656 | 
> | 
                        else if (mult > 1) | 
| 1657 | 
> | 
                                sprintf(combuf, "%s%s -x /%d -y /%d %s > %s", | 
| 1658 | 
> | 
                                        c_pfilt, pfopts, mult, mult, | 
| 1659 | 
> | 
                                        rawfile, picfile); | 
| 1660 | 
  | 
                        else | 
| 1661 | 
< | 
                                sprintf(combuf, "pfilt%s %s > %s", pfopts, | 
| 1662 | 
< | 
                                                rawfile, picfile); | 
| 1661 | 
> | 
                                sprintf(combuf, "%s%s %s > %s", c_pfilt, | 
| 1662 | 
> | 
                                        pfopts, rawfile, picfile); | 
| 1663 | 
  | 
                        if (runcom(combuf)) {   /* run pfilt */ | 
| 1664 | 
  | 
                                fprintf(stderr, | 
| 1665 | 
  | 
                                "%s: error filtering view %s\n\t%s removed\n", | 
| 1670 | 
  | 
                } | 
| 1671 | 
  | 
                                                /* remove/rename raw file */ | 
| 1672 | 
  | 
                if (vdef(RAWFILE)) { | 
| 1673 | 
< | 
                        sprintf(combuf, "%s_%s.pic", vval(RAWFILE), vs); | 
| 1673 | 
> | 
                        sprintf(combuf, "%s_%s.hdr", vval(RAWFILE), vs); | 
| 1674 | 
  | 
                        mvfile(rawfile, combuf); | 
| 1675 | 
  | 
                } else | 
| 1676 | 
  | 
                        rmfile(rawfile); | 
| 1677 | 
< | 
                finish_process();               /* exit if child */ | 
| 1677 | 
> | 
                if (do_rpiece)                  /* done with sync file */ | 
| 1678 | 
> | 
                        rmfile(sfile); | 
| 1679 | 
> | 
                else | 
| 1680 | 
> | 
                        finish_process();       /* exit if child */ | 
| 1681 | 
  | 
        } | 
| 1682 | 
  | 
        wait_process(1);                /* wait for children to finish */ | 
| 1683 | 
< | 
        if (pfile != NULL) {            /* clean up rpict persistent mode */ | 
| 1684 | 
< | 
                int     pid; | 
| 1683 | 
> | 
        if (pfile != NULL) {            /* clean up persistent rpict */ | 
| 1684 | 
> | 
                RT_PID  pid; | 
| 1685 | 
  | 
                fp = fopen(pfile, "r"); | 
| 1686 | 
  | 
                if (fp != NULL) { | 
| 1687 | 
  | 
                        if (fscanf(fp, "%*s %d", &pid) != 1 || | 
| 1694 | 
  | 
rperror: | 
| 1695 | 
  | 
        fprintf(stderr, "%s: error rendering view %s\n", progname, vs); | 
| 1696 | 
  | 
        quit(1); | 
| 1697 | 
+ | 
#undef do_rpiece | 
| 1698 | 
  | 
} | 
| 1699 | 
  | 
 | 
| 1700 | 
  | 
 | 
| 1707 | 
  | 
                printf("\ttouch %s\n", fn); | 
| 1708 | 
  | 
        if (!nprocs) | 
| 1709 | 
  | 
                return(0); | 
| 1393 | 
– | 
#ifdef notused | 
| 1394 | 
– | 
        if (access(fn, F_OK) == -1)             /* create it */ | 
| 1395 | 
– | 
                if (close(open(fn, O_WRONLY|O_CREAT, 0666)) == -1) | 
| 1396 | 
– | 
                        return(-1); | 
| 1397 | 
– | 
#endif | 
| 1710 | 
  | 
        return(setfdate(fn, time((time_t *)NULL))); | 
| 1711 | 
  | 
} | 
| 1712 | 
  | 
 | 
| 1720 | 
  | 
                printf("\t%s\n", cs); | 
| 1721 | 
  | 
        if (!nprocs) | 
| 1722 | 
  | 
                return(0); | 
| 1723 | 
< | 
        fflush(stdout);         /* flush output and pass to shell */ | 
| 1723 | 
> | 
        fflush(NULL);           /* flush output and pass to shell */ | 
| 1724 | 
  | 
        return(system(cs)); | 
| 1725 | 
  | 
} | 
| 1726 | 
  | 
 | 
| 1754 | 
  | 
 | 
| 1755 | 
  | 
#ifdef RHAS_FORK_EXEC | 
| 1756 | 
  | 
static int | 
| 1757 | 
< | 
next_process(void)                      /* fork the next process (max. nprocs) */ | 
| 1757 | 
> | 
next_process(int reserve)               /* fork the next process */ | 
| 1758 | 
  | 
{ | 
| 1759 | 
< | 
        int     child_pid; | 
| 1759 | 
> | 
        RT_PID  child_pid; | 
| 1760 | 
  | 
 | 
| 1761 | 
  | 
        if (nprocs <= 1) | 
| 1762 | 
  | 
                return(0);              /* it's us or no one */ | 
| 1765 | 
  | 
                                progname); | 
| 1766 | 
  | 
                quit(1); | 
| 1767 | 
  | 
        } | 
| 1768 | 
+ | 
        if (reserve > 0 && children_running >= nprocs-reserve) | 
| 1769 | 
+ | 
                return(0);              /* caller holding back process(es) */ | 
| 1770 | 
  | 
        if (children_running >= nprocs) | 
| 1771 | 
  | 
                wait_process(0);        /* wait for someone to finish */ | 
| 1772 | 
< | 
        fflush(stdout); | 
| 1772 | 
> | 
        fflush(NULL);                   /* flush output */ | 
| 1773 | 
  | 
        child_pid = fork();             /* split process */ | 
| 1774 | 
  | 
        if (child_pid == 0) {           /* we're the child */ | 
| 1775 | 
  | 
                children_running = -1; | 
| 1776 | 
+ | 
                nprocs = 1; | 
| 1777 | 
  | 
                return(0); | 
| 1778 | 
  | 
        } | 
| 1779 | 
  | 
        if (child_pid > 0) {            /* we're the parent */ | 
| 1789 | 
  | 
        int     all | 
| 1790 | 
  | 
) | 
| 1791 | 
  | 
{ | 
| 1792 | 
< | 
        int     ourstatus = 0; | 
| 1793 | 
< | 
        int     pid, status; | 
| 1792 | 
> | 
        int     ourstatus = 0, status; | 
| 1793 | 
> | 
        RT_PID  pid; | 
| 1794 | 
  | 
 | 
| 1795 | 
  | 
        if (all) | 
| 1796 | 
  | 
                all = children_running; | 
| 1815 | 
  | 
} | 
| 1816 | 
  | 
#else   /* ! RHAS_FORK_EXEC */ | 
| 1817 | 
  | 
static int | 
| 1818 | 
< | 
next_process(void) | 
| 1818 | 
> | 
next_process(int reserve) | 
| 1819 | 
  | 
{ | 
| 1820 | 
  | 
        return(0);                      /* cannot start new process */ | 
| 1821 | 
  | 
} | 
| 1827 | 
  | 
} | 
| 1828 | 
  | 
int | 
| 1829 | 
  | 
kill(pid, sig) /* win|unix_process.c should also wait and kill */ | 
| 1830 | 
< | 
int pid, sig; | 
| 1830 | 
> | 
RT_PID pid; | 
| 1831 | 
> | 
int sig; | 
| 1832 | 
  | 
{ | 
| 1833 | 
  | 
        return 0; | 
| 1834 | 
  | 
} | 
| 1841 | 
  | 
                return;                 /* in parent -- noop */ | 
| 1842 | 
  | 
        exit(0); | 
| 1843 | 
  | 
} | 
| 1528 | 
– | 
 | 
| 1529 | 
– | 
#ifdef _WIN32 | 
| 1530 | 
– | 
setenv(vname, value)            /* set an environment variable */ | 
| 1531 | 
– | 
char    *vname, *value; | 
| 1532 | 
– | 
{ | 
| 1533 | 
– | 
        register char   *evp; | 
| 1534 | 
– | 
 | 
| 1535 | 
– | 
        evp = bmalloc(strlen(vname)+strlen(value)+2); | 
| 1536 | 
– | 
        if (evp == NULL) | 
| 1537 | 
– | 
                syserr(progname); | 
| 1538 | 
– | 
        sprintf(evp, "%s=%s", vname, value); | 
| 1539 | 
– | 
        if (putenv(evp) != 0) { | 
| 1540 | 
– | 
                fprintf(stderr, "%s: out of environment space\n", progname); | 
| 1541 | 
– | 
                quit(1); | 
| 1542 | 
– | 
        } | 
| 1543 | 
– | 
        if (!silent) | 
| 1544 | 
– | 
                printf("set %s\n", evp); | 
| 1545 | 
– | 
} | 
| 1546 | 
– | 
#endif | 
| 1844 | 
  | 
 | 
| 1845 | 
  | 
 | 
| 1846 | 
  | 
static void |