| 1 | 
– | 
/* Copyright (c) 1996 Regents of the University of California */ | 
| 2 | 
– | 
 | 
| 1 | 
  | 
#ifndef lint | 
| 2 | 
< | 
static char SCCSid[] = "$SunId$ LBL"; | 
| 2 | 
> | 
static const char RCSid[] = "$Id$"; | 
| 3 | 
  | 
#endif | 
| 6 | 
– | 
 | 
| 4 | 
  | 
/* | 
| 5 | 
  | 
 * Radiance animation control program | 
| 6 | 
+ | 
 * | 
| 7 | 
+ | 
 * The main difference between this program and ranimove is that | 
| 8 | 
+ | 
 * we have many optimizations here for camera motion in static | 
| 9 | 
+ | 
 * environments, calling rpict and pinterp on multiple processors, | 
| 10 | 
+ | 
 * where ranimove puts its emphasis on object motion, and does | 
| 11 | 
+ | 
 * not use any external programs for image generation. | 
| 12 | 
+ | 
 * | 
| 13 | 
+ | 
 * See the ranimate(1) man page for further details. | 
| 14 | 
  | 
 */ | 
| 15 | 
  | 
 | 
| 16 | 
+ | 
#include "copyright.h" | 
| 17 | 
+ | 
 | 
| 18 | 
  | 
#include "standard.h" | 
| 19 | 
  | 
#include <ctype.h> | 
| 13 | 
– | 
#include <sys/types.h> | 
| 20 | 
  | 
#include <sys/stat.h> | 
| 21 | 
  | 
#include "view.h" | 
| 22 | 
  | 
#include "vars.h" | 
| 23 | 
  | 
#include "netproc.h" | 
| 24 | 
+ | 
                                /* default blur samples */ | 
| 25 | 
+ | 
#ifndef DEF_NBLUR | 
| 26 | 
+ | 
#define DEF_NBLUR       5 | 
| 27 | 
+ | 
#endif | 
| 28 | 
  | 
                                /* default remote shell */ | 
| 29 | 
  | 
#ifdef _AUX_SOURCE | 
| 30 | 
  | 
#define REMSH           "remsh" | 
| 31 | 
  | 
#else | 
| 32 | 
  | 
#define REMSH           "rsh" | 
| 33 | 
  | 
#endif | 
| 34 | 
< | 
                                /* input variables */ | 
| 35 | 
< | 
#define HOST            0               /* rendering host machine */ | 
| 36 | 
< | 
#define RENDER          1               /* rendering options */ | 
| 37 | 
< | 
#define PFILT           2               /* pfilt options */ | 
| 38 | 
< | 
#define PINTERP         3               /* pinterp options */ | 
| 39 | 
< | 
#define OCTREE          4               /* octree file name */ | 
| 40 | 
< | 
#define DIRECTORY       5               /* working (sub)directory */ | 
| 41 | 
< | 
#define BASENAME        6               /* output image base name */ | 
| 42 | 
< | 
#define VIEWFILE        7               /* animation frame views */ | 
| 43 | 
< | 
#define START           8               /* starting frame number */ | 
| 44 | 
< | 
#define END             9               /* ending frame number */ | 
| 45 | 
< | 
#define RIF             10              /* rad input file */ | 
| 46 | 
< | 
#define NEXTANIM        11              /* next animation file */ | 
| 47 | 
< | 
#define ANIMATE         12              /* animation command */ | 
| 48 | 
< | 
#define TRANSFER        13              /* frame transfer command */ | 
| 49 | 
< | 
#define ARCHIVE         14              /* archiving command */ | 
| 50 | 
< | 
#define INTERP          15              /* # frames to interpolate */ | 
| 51 | 
< | 
#define OVERSAMP        16              /* # times to oversample image */ | 
| 52 | 
< | 
#define MBLUR           17              /* samples for motion blur */ | 
| 53 | 
< | 
#define RTRACE          18              /* use rtrace with pinterp? */ | 
| 54 | 
< | 
#define DISKSPACE       19              /* how much disk space to use */ | 
| 55 | 
< | 
#define RESOLUTION      20              /* desired final resolution */ | 
| 56 | 
< | 
#define EXPOSURE        21              /* how to compute exposure */ | 
| 57 | 
< | 
#define RSH             22              /* remote shell script or program */ | 
| 34 | 
> | 
                                /* input variables (alphabetical by name) */ | 
| 35 | 
> | 
#define ANIMATE         0               /* animation command */ | 
| 36 | 
> | 
#define ARCHIVE         1               /* archiving command */ | 
| 37 | 
> | 
#define BASENAME        2               /* output image base name */ | 
| 38 | 
> | 
#define DIRECTORY       3               /* working (sub)directory */ | 
| 39 | 
> | 
#define DISKSPACE       4               /* how much disk space to use */ | 
| 40 | 
> | 
#define END             5               /* ending frame number */ | 
| 41 | 
> | 
#define EXPOSURE        6               /* how to compute exposure */ | 
| 42 | 
> | 
#define HOST            7               /* rendering host machine */ | 
| 43 | 
> | 
#define INTERP          8               /* # frames to interpolate */ | 
| 44 | 
> | 
#define MBLUR           9               /* motion blur parameters */ | 
| 45 | 
> | 
#define NEXTANIM        10              /* next animation file */ | 
| 46 | 
> | 
#define OCTREE          11              /* octree file name */ | 
| 47 | 
> | 
#define OVERSAMP        12              /* # times to oversample image */ | 
| 48 | 
> | 
#define PFILT           13              /* pfilt options */ | 
| 49 | 
> | 
#define PINTERP         14              /* pinterp options */ | 
| 50 | 
> | 
#define RENDER          15              /* rendering options */ | 
| 51 | 
> | 
#define RESOLUTION      16              /* desired final resolution */ | 
| 52 | 
> | 
#define RIF             17              /* rad input file */ | 
| 53 | 
> | 
#define RSH             18              /* remote shell script or program */ | 
| 54 | 
> | 
#define RTRACE          19              /* use rtrace with pinterp? */ | 
| 55 | 
> | 
#define START           20              /* starting frame number */ | 
| 56 | 
> | 
#define TRANSFER        21              /* frame transfer command */ | 
| 57 | 
> | 
#define VIEWFILE        22              /* animation frame views */ | 
| 58 | 
  | 
 | 
| 59 | 
  | 
int     NVARS = 23;             /* total number of variables */ | 
| 60 | 
  | 
 | 
| 61 | 
  | 
VARIABLE        vv[] = {                /* variable-value pairs */ | 
| 52 | 
– | 
        {"host",        4,      0,      NULL,   NULL}, | 
| 53 | 
– | 
        {"render",      3,      0,      NULL,   catvalues}, | 
| 54 | 
– | 
        {"pfilt",       2,      0,      NULL,   catvalues}, | 
| 55 | 
– | 
        {"pinterp",     2,      0,      NULL,   catvalues}, | 
| 56 | 
– | 
        {"OCTREE",      3,      0,      NULL,   onevalue}, | 
| 57 | 
– | 
        {"DIRECTORY",   3,      0,      NULL,   onevalue}, | 
| 58 | 
– | 
        {"BASENAME",    3,      0,      NULL,   onevalue}, | 
| 59 | 
– | 
        {"VIEWFILE",    2,      0,      NULL,   onevalue}, | 
| 60 | 
– | 
        {"START",       2,      0,      NULL,   intvalue}, | 
| 61 | 
– | 
        {"END",         2,      0,      NULL,   intvalue}, | 
| 62 | 
– | 
        {"RIF",         3,      0,      NULL,   onevalue}, | 
| 63 | 
– | 
        {"NEXTANIM",    3,      0,      NULL,   onevalue}, | 
| 62 | 
  | 
        {"ANIMATE",     2,      0,      NULL,   onevalue}, | 
| 65 | 
– | 
        {"TRANSFER",    2,      0,      NULL,   onevalue}, | 
| 63 | 
  | 
        {"ARCHIVE",     2,      0,      NULL,   onevalue}, | 
| 64 | 
+ | 
        {"BASENAME",    3,      0,      NULL,   onevalue}, | 
| 65 | 
+ | 
        {"DIRECTORY",   3,      0,      NULL,   onevalue}, | 
| 66 | 
+ | 
        {"DISKSPACE",   3,      0,      NULL,   fltvalue}, | 
| 67 | 
+ | 
        {"END",         2,      0,      NULL,   intvalue}, | 
| 68 | 
+ | 
        {"EXPOSURE",    3,      0,      NULL,   onevalue}, | 
| 69 | 
+ | 
        {"host",        4,      0,      NULL,   NULL}, | 
| 70 | 
  | 
        {"INTERPOLATE", 3,      0,      NULL,   intvalue}, | 
| 68 | 
– | 
        {"OVERSAMPLE",  2,      0,      NULL,   fltvalue}, | 
| 71 | 
  | 
        {"MBLUR",       2,      0,      NULL,   onevalue}, | 
| 72 | 
< | 
        {"RTRACE",      2,      0,      NULL,   boolvalue}, | 
| 73 | 
< | 
        {"DISKSPACE",   3,      0,      NULL,   fltvalue}, | 
| 72 | 
> | 
        {"NEXTANIM",    3,      0,      NULL,   onevalue}, | 
| 73 | 
> | 
        {"OCTREE",      3,      0,      NULL,   onevalue}, | 
| 74 | 
> | 
        {"OVERSAMPLE",  2,      0,      NULL,   fltvalue}, | 
| 75 | 
> | 
        {"pfilt",       2,      0,      NULL,   catvalues}, | 
| 76 | 
> | 
        {"pinterp",     2,      0,      NULL,   catvalues}, | 
| 77 | 
> | 
        {"render",      3,      0,      NULL,   catvalues}, | 
| 78 | 
  | 
        {"RESOLUTION",  3,      0,      NULL,   onevalue}, | 
| 79 | 
< | 
        {"EXPOSURE",    3,      0,      NULL,   onevalue}, | 
| 79 | 
> | 
        {"RIF",         3,      0,      NULL,   onevalue}, | 
| 80 | 
  | 
        {"RSH",         3,      0,      NULL,   onevalue}, | 
| 81 | 
+ | 
        {"RTRACE",      2,      0,      NULL,   boolvalue}, | 
| 82 | 
+ | 
        {"START",       2,      0,      NULL,   intvalue}, | 
| 83 | 
+ | 
        {"TRANSFER",    2,      0,      NULL,   onevalue}, | 
| 84 | 
+ | 
        {"VIEWFILE",    2,      0,      NULL,   onevalue}, | 
| 85 | 
  | 
}; | 
| 86 | 
  | 
 | 
| 87 | 
  | 
#define SFNAME  "STATUS"                /* status file name */ | 
| 103 | 
  | 
int     noaction = 0;           /* take no action? */ | 
| 104 | 
  | 
 | 
| 105 | 
  | 
char    *remsh;                 /* remote shell program/script */ | 
| 106 | 
< | 
char    rendopt[2048] = "";     /* rendering options */ | 
| 106 | 
> | 
char    rendopt[2048];          /* rendering options */ | 
| 107 | 
  | 
char    rresopt[32];            /* rendering resolution options */ | 
| 108 | 
  | 
char    fresopt[32];            /* filter resolution options */ | 
| 109 | 
  | 
int     pfiltalways;            /* always use pfilt? */ | 
| 118 | 
  | 
}       *pslot;                 /* process slots */ | 
| 119 | 
  | 
int     npslots;                /* number of process slots */ | 
| 120 | 
  | 
 | 
| 111 | 
– | 
int     lastpid;                /* ID of last completed background process */ | 
| 112 | 
– | 
PSERVER *lastpserver;           /* last process server used */ | 
| 113 | 
– | 
 | 
| 121 | 
  | 
#define phostname(ps)   ((ps)->hostname[0] ? (ps)->hostname : astat.host) | 
| 122 | 
  | 
 | 
| 123 | 
  | 
struct pslot    *findpslot(); | 
| 124 | 
  | 
 | 
| 125 | 
+ | 
PSERVER *lastpserver;           /* last process server with error */ | 
| 126 | 
+ | 
 | 
| 127 | 
  | 
VIEW    *getview(); | 
| 128 | 
< | 
char    *getexp(); | 
| 128 | 
> | 
char    *getexp(), *dirfile(); | 
| 129 | 
> | 
int     getblur(); | 
| 130 | 
  | 
 | 
| 131 | 
< | 
extern time_t   fdate(), time(); | 
| 131 | 
> | 
extern time_t   time(); | 
| 132 | 
  | 
 | 
| 133 | 
  | 
 | 
| 134 | 
  | 
main(argc, argv) | 
| 161 | 
  | 
        cfname = argv[i]; | 
| 162 | 
  | 
                                                /* load variables */ | 
| 163 | 
  | 
        loadvars(cfname); | 
| 164 | 
+ | 
                                                /* check variables */ | 
| 165 | 
+ | 
        checkvalues(); | 
| 166 | 
  | 
                                                /* did we get DIRECTORY? */ | 
| 167 | 
  | 
        checkdir(); | 
| 168 | 
  | 
                                                /* check status */ | 
| 243 | 
  | 
                } | 
| 244 | 
  | 
                /* assume it is dead */ | 
| 245 | 
  | 
        } | 
| 246 | 
< | 
        if (strcmp(cfname, astat.cfname) && astat.tnext != 0) { /* other's */ | 
| 246 | 
> | 
        if (strcmp(cfname, astat.cfname) && astat.pid != 0) {   /* other's */ | 
| 247 | 
  | 
                fprintf(stderr, "%s: unfinished job \"%s\"\n", | 
| 248 | 
  | 
                                progname, astat.cfname); | 
| 249 | 
  | 
                return(-1); | 
| 313 | 
  | 
setdefaults()                   /* set default values */ | 
| 314 | 
  | 
{ | 
| 315 | 
  | 
        extern char     *atos(); | 
| 316 | 
+ | 
        int     decades; | 
| 317 | 
  | 
        char    buf[256]; | 
| 318 | 
  | 
 | 
| 319 | 
  | 
        if (vdef(ANIMATE)) { | 
| 347 | 
  | 
                quit(1); | 
| 348 | 
  | 
        } | 
| 349 | 
  | 
        if (!vdef(BASENAME)) { | 
| 350 | 
< | 
                sprintf(buf, "%s/frame%%03d", vval(DIRECTORY)); | 
| 350 | 
> | 
                decades = (int)log10((double)vint(END)) + 1; | 
| 351 | 
> | 
                if (decades < 3) decades = 3; | 
| 352 | 
> | 
                sprintf(buf, "%s/frame%%0%dd", vval(DIRECTORY), decades); | 
| 353 | 
  | 
                vval(BASENAME) = savqstr(buf); | 
| 354 | 
  | 
                vdef(BASENAME)++; | 
| 355 | 
  | 
        } | 
| 461 | 
  | 
        char    combuf[256]; | 
| 462 | 
  | 
        register int    i; | 
| 463 | 
  | 
        register char   *cp; | 
| 464 | 
+ | 
        char    *pippt; | 
| 465 | 
  | 
                                        /* create rad command */ | 
| 466 | 
  | 
        sprintf(rendopt, " @%s/render.opt", vval(DIRECTORY)); | 
| 467 | 
  | 
        sprintf(combuf, | 
| 468 | 
  | 
        "rad -v 0 -s -e -w %s OPTFILE=%s | egrep '^[ \t]*(NOMATCH", | 
| 469 | 
  | 
                        rfargs, rendopt+2); | 
| 470 | 
  | 
        cp = combuf; | 
| 471 | 
< | 
        while (*cp) cp++;               /* match unset variables */ | 
| 471 | 
> | 
        while (*cp) { | 
| 472 | 
> | 
                if (*cp == '|') pippt = cp; | 
| 473 | 
> | 
                cp++; | 
| 474 | 
> | 
        }                               /* match unset variables */ | 
| 475 | 
  | 
        for (i = 0; mvar[i] >= 0; i++) | 
| 476 | 
  | 
                if (!vdef(mvar[i])) { | 
| 477 | 
  | 
                        *cp++ = '|'; | 
| 478 | 
  | 
                        strcpy(cp, vnam(mvar[i])); | 
| 479 | 
  | 
                        while (*cp) cp++; | 
| 480 | 
+ | 
                        pippt = NULL; | 
| 481 | 
  | 
                } | 
| 482 | 
< | 
        sprintf(cp, ")[ \t]*=' > %s/radset.var", vval(DIRECTORY)); | 
| 483 | 
< | 
        cp += 11;                       /* point to file name */ | 
| 484 | 
< | 
        if (system(combuf)) { | 
| 485 | 
< | 
                fprintf(stderr, "%s: error executing rad command:\n\t%s\n", | 
| 486 | 
< | 
                                progname, combuf); | 
| 467 | 
< | 
                quit(1); | 
| 482 | 
> | 
        if (pippt != NULL) | 
| 483 | 
> | 
                strcpy(pippt, "> /dev/null");   /* nothing to match */ | 
| 484 | 
> | 
        else { | 
| 485 | 
> | 
                sprintf(cp, ")[ \t]*=' > %s/radset.var", vval(DIRECTORY)); | 
| 486 | 
> | 
                cp += 11;               /* point to file name */ | 
| 487 | 
  | 
        } | 
| 488 | 
< | 
        loadvars(cp);                   /* load variables and remove file */ | 
| 489 | 
< | 
        unlink(cp); | 
| 488 | 
> | 
        system(combuf);                 /* ignore exit code */ | 
| 489 | 
> | 
        if (pippt == NULL) {            /* load variables and remove file */ | 
| 490 | 
> | 
                loadvars(cp); | 
| 491 | 
> | 
                unlink(cp); | 
| 492 | 
> | 
        } | 
| 493 | 
  | 
} | 
| 494 | 
  | 
 | 
| 495 | 
  | 
 | 
| 504 | 
  | 
        i = sscanf(vval(RESOLUTION), "%d %d %f", &xres, &yres, &pa); | 
| 505 | 
  | 
        mult = vflt(OVERSAMP); | 
| 506 | 
  | 
        if (i == 3) { | 
| 507 | 
< | 
                sprintf(rresopt, "-x %d -y %d -pa %f", (int)(mult*xres), | 
| 507 | 
> | 
                sprintf(rresopt, "-x %d -y %d -pa %.3f", (int)(mult*xres), | 
| 508 | 
  | 
                                (int)(mult*yres), pa); | 
| 509 | 
< | 
                sprintf(fresopt, "-x %d -y %d -pa %f", xres, yres, pa); | 
| 509 | 
> | 
                sprintf(fresopt, "-x %d -y %d -pa %.3f", xres, yres, pa); | 
| 510 | 
  | 
        } else if (i) { | 
| 511 | 
  | 
                if (i == 1) yres = xres; | 
| 512 | 
  | 
                sprintf(rresopt, "-x %d -y %d", (int)(mult*xres), | 
| 523 | 
  | 
                                                progname, vnam(INTERP)); | 
| 524 | 
  | 
                        vval(INTERP) = "0"; | 
| 525 | 
  | 
                } | 
| 526 | 
< | 
                if (atoi(vval(MBLUR))) {        /* can't handle this yet */ | 
| 526 | 
> | 
                if (strcmp(vval(MBLUR),"0")) {  /* can't handle this */ | 
| 527 | 
  | 
                        if (!nowarn) | 
| 528 | 
  | 
                                fprintf(stderr, | 
| 529 | 
  | 
                                        "%s: resetting %s=0 for animation\n", | 
| 533 | 
  | 
        } | 
| 534 | 
  | 
                                        /* figure # frames per batch */ | 
| 535 | 
  | 
        d1 = mult*xres*mult*yres*4;             /* space for orig. picture */ | 
| 536 | 
< | 
        if ((i=vint(INTERP)) || atoi(vval(MBLUR))) | 
| 537 | 
< | 
                d1 += mult*xres*mult*yres*4;    /* space for z-buffer */ | 
| 536 | 
> | 
        if ((i=vint(INTERP)) || getblur(NULL) > 1) | 
| 537 | 
> | 
                d1 += mult*xres*mult*yres*sizeof(float);        /* Z-buffer */ | 
| 538 | 
  | 
        d2 = xres*yres*4;                       /* space for final picture */ | 
| 539 | 
  | 
        frames_batch = (i+1)*(vflt(DISKSPACE)*1048576.-d1)/(d1+i*d2); | 
| 540 | 
  | 
        if (frames_batch < i+2) { | 
| 543 | 
  | 
                quit(1); | 
| 544 | 
  | 
        } | 
| 545 | 
  | 
                                        /* initialize archive argument list */ | 
| 546 | 
< | 
        i = 16; | 
| 525 | 
< | 
        if (vdef(ARCHIVE) && strlen(vval(ARCHIVE)) > i) | 
| 526 | 
< | 
                i = strlen(vval(ARCHIVE)); | 
| 546 | 
> | 
        i = vdef(ARCHIVE) ? strlen(vval(ARCHIVE))+132 : 132; | 
| 547 | 
  | 
        arcnext = arcfirst = arcargs + i; | 
| 548 | 
  | 
                                        /* initialize status file */ | 
| 549 | 
  | 
        if (astat.rnext == 0) | 
| 647 | 
  | 
 | 
| 648 | 
  | 
transferframes()                        /* catch up with picture transfers */ | 
| 649 | 
  | 
{ | 
| 650 | 
< | 
        char    combuf[10240]; | 
| 650 | 
> | 
        char    combuf[10240], *fbase; | 
| 651 | 
  | 
        register char   *cp; | 
| 652 | 
  | 
        register int    i; | 
| 653 | 
  | 
 | 
| 658 | 
  | 
                putastat();             /* update status */ | 
| 659 | 
  | 
                return; | 
| 660 | 
  | 
        } | 
| 661 | 
< | 
        strcpy(combuf, vval(TRANSFER)); /* start transfer command */ | 
| 662 | 
< | 
        cp = combuf + strlen(combuf); | 
| 661 | 
> | 
        strcpy(combuf, "cd ");          /* start transfer command */ | 
| 662 | 
> | 
        fbase = dirfile(cp = combuf+3, vval(BASENAME)); | 
| 663 | 
> | 
        if (*cp) { | 
| 664 | 
> | 
                while (*++cp) ; | 
| 665 | 
> | 
                *cp++ = ';'; *cp++ = ' '; | 
| 666 | 
> | 
        } else | 
| 667 | 
> | 
                cp = combuf; | 
| 668 | 
> | 
        strcpy(cp, vval(TRANSFER)); | 
| 669 | 
> | 
        while (*cp) cp++; | 
| 670 | 
  | 
                                        /* make argument list */ | 
| 671 | 
  | 
        for (i = astat.tnext; i < astat.fnext; i++) { | 
| 672 | 
  | 
                *cp++ = ' '; | 
| 673 | 
< | 
                sprintf(cp, vval(BASENAME), i); | 
| 673 | 
> | 
                sprintf(cp, fbase, i); | 
| 674 | 
  | 
                while (*cp) cp++; | 
| 675 | 
  | 
                strcpy(cp, ".pic"); | 
| 676 | 
  | 
                cp += 4; | 
| 707 | 
  | 
int     first, last; | 
| 708 | 
  | 
char    *vfn; | 
| 709 | 
  | 
{ | 
| 710 | 
+ | 
        double  blurf; | 
| 711 | 
+ | 
        int     nblur = getblur(&blurf); | 
| 712 | 
  | 
        char    combuf[2048]; | 
| 713 | 
< | 
        char    *inspoint; | 
| 713 | 
> | 
        register char   *inspoint; | 
| 714 | 
  | 
        register int    i; | 
| 715 | 
  | 
 | 
| 716 | 
  | 
        if (!noaction && vint(INTERP))          /* create dummy frames */ | 
| 721 | 
  | 
                                close(open(combuf, O_RDONLY|O_CREAT, 0666)); | 
| 722 | 
  | 
                        } | 
| 723 | 
  | 
                                        /* create command */ | 
| 724 | 
< | 
        sprintf(combuf, "rpict%s -w0", rendopt); | 
| 725 | 
< | 
        if (vint(INTERP) || atoi(vval(MBLUR))) | 
| 726 | 
< | 
                sprintf(combuf+strlen(combuf), " -z %s.zbf", vval(BASENAME)); | 
| 727 | 
< | 
        sprintf(combuf+strlen(combuf), " -o %s.unf %s -S %d", | 
| 724 | 
> | 
        sprintf(combuf, "rpict%s%s -w0", rendopt, | 
| 725 | 
> | 
                        viewopt(getview(first>1 ? first-1 : 1))); | 
| 726 | 
> | 
        inspoint = combuf; | 
| 727 | 
> | 
        while (*inspoint) inspoint++; | 
| 728 | 
> | 
        if (nblur) { | 
| 729 | 
> | 
                sprintf(inspoint, " -pm %.3f", blurf/nblur); | 
| 730 | 
> | 
                while (*inspoint) inspoint++; | 
| 731 | 
> | 
        } | 
| 732 | 
> | 
        if (nblur > 1 || vint(INTERP)) { | 
| 733 | 
> | 
                sprintf(inspoint, " -z %s.zbf", vval(BASENAME)); | 
| 734 | 
> | 
                while (*inspoint) inspoint++; | 
| 735 | 
> | 
        } | 
| 736 | 
> | 
        sprintf(inspoint, " -o %s.unf %s -S %d", | 
| 737 | 
  | 
                        vval(BASENAME), rresopt, first); | 
| 738 | 
< | 
        inspoint = combuf + strlen(combuf); | 
| 738 | 
> | 
        while (*inspoint) inspoint++; | 
| 739 | 
  | 
        sprintf(inspoint, " %s < %s", vval(OCTREE), vfn); | 
| 740 | 
  | 
                                        /* run in parallel */ | 
| 741 | 
  | 
        i = (last-first+1)/(vint(INTERP)+1); | 
| 761 | 
  | 
{ | 
| 762 | 
  | 
        static int      *rfrm;          /* list of recovered frames */ | 
| 763 | 
  | 
        static int      nrfrms = 0; | 
| 764 | 
+ | 
        double  blurf; | 
| 765 | 
+ | 
        int     nblur = getblur(&blurf); | 
| 766 | 
  | 
        char    combuf[2048]; | 
| 767 | 
  | 
        char    fname[128]; | 
| 768 | 
  | 
        register char   *cp; | 
| 778 | 
  | 
                                vval(ANIMATE), frame, rendopt); | 
| 779 | 
  | 
        else | 
| 780 | 
  | 
                sprintf(combuf, "rpict%s -w0", rendopt); | 
| 781 | 
< | 
        cp = combuf + strlen(combuf); | 
| 782 | 
< | 
        if (vint(INTERP) || atoi(vval(MBLUR))) { | 
| 781 | 
> | 
        cp = combuf; | 
| 782 | 
> | 
        while (*cp) cp++; | 
| 783 | 
> | 
        if (nblur) { | 
| 784 | 
> | 
                sprintf(cp, " -pm %.3f", blurf/nblur); | 
| 785 | 
> | 
                while (*cp) cp++; | 
| 786 | 
> | 
        } | 
| 787 | 
> | 
        if (nblur > 1 || vint(INTERP)) { | 
| 788 | 
  | 
                sprintf(cp, " -z %s.zbf", fname); | 
| 789 | 
  | 
                while (*cp) cp++; | 
| 790 | 
  | 
        } | 
| 798 | 
  | 
                return(1); | 
| 799 | 
  | 
                                        /* add frame to recovered list */ | 
| 800 | 
  | 
        if (nrfrms) | 
| 801 | 
< | 
                rfrm = (int *)realloc((char *)rfrm, (nrfrms+1)*sizeof(int)); | 
| 801 | 
> | 
                rfrm = (int *)realloc((void *)rfrm, (nrfrms+1)*sizeof(int)); | 
| 802 | 
  | 
        else | 
| 803 | 
  | 
                rfrm = (int *)malloc(sizeof(int)); | 
| 804 | 
  | 
        if (rfrm == NULL) { | 
| 829 | 
  | 
{ | 
| 830 | 
  | 
#define RMCOML  (sizeof(rmcom)-1) | 
| 831 | 
  | 
        static char     rmcom[] = "rm -f"; | 
| 832 | 
< | 
        register int    i; | 
| 832 | 
> | 
        char    basedir[128]; | 
| 833 | 
> | 
        int     dlen, alen; | 
| 834 | 
> | 
        register int    j; | 
| 835 | 
  | 
 | 
| 836 | 
  | 
        if (arcnext == arcfirst) | 
| 837 | 
  | 
                return;                         /* nothing to do */ | 
| 838 | 
+ | 
        dirfile(basedir, vval(BASENAME)); | 
| 839 | 
+ | 
        dlen = strlen(basedir); | 
| 840 | 
  | 
        if (vdef(ARCHIVE)) {                    /* run archive command */ | 
| 841 | 
< | 
                i = strlen(vval(ARCHIVE)); | 
| 842 | 
< | 
                strncpy(arcfirst-i, vval(ARCHIVE), i); | 
| 843 | 
< | 
                if (runcom(arcfirst-i)) { | 
| 841 | 
> | 
                alen = strlen(vval(ARCHIVE)); | 
| 842 | 
> | 
                if (dlen) { | 
| 843 | 
> | 
                        j = alen + dlen + 5; | 
| 844 | 
> | 
                        strncpy(arcfirst-j, "cd ", 3); | 
| 845 | 
> | 
                        strncpy(arcfirst-j+3, basedir, dlen); | 
| 846 | 
> | 
                        (arcfirst-j)[dlen+3] = ';'; (arcfirst-j)[dlen+4] = ' '; | 
| 847 | 
> | 
                } else | 
| 848 | 
> | 
                        j = alen; | 
| 849 | 
> | 
                strncpy(arcfirst-alen, vval(ARCHIVE), alen); | 
| 850 | 
> | 
                if (runcom(arcfirst-j)) { | 
| 851 | 
  | 
                        fprintf(stderr, "%s: error running archive command\n", | 
| 852 | 
  | 
                                        progname); | 
| 853 | 
  | 
                        quit(1); | 
| 854 | 
  | 
                } | 
| 855 | 
  | 
        } | 
| 856 | 
+ | 
        if (dlen) { | 
| 857 | 
+ | 
                j = RMCOML + dlen + 5; | 
| 858 | 
+ | 
                strncpy(arcfirst-j, "cd ", 3); | 
| 859 | 
+ | 
                strncpy(arcfirst-j+3, basedir, dlen); | 
| 860 | 
+ | 
                (arcfirst-j)[dlen+3] = ';'; (arcfirst-j)[dlen+4] = ' '; | 
| 861 | 
+ | 
        } else | 
| 862 | 
+ | 
                j = RMCOML; | 
| 863 | 
  | 
                                                /* run remove command */ | 
| 864 | 
  | 
        strncpy(arcfirst-RMCOML, rmcom, RMCOML); | 
| 865 | 
< | 
        runcom(arcfirst-RMCOML); | 
| 865 | 
> | 
        runcom(arcfirst-j); | 
| 866 | 
  | 
        arcnext = arcfirst;                     /* reset argument list */ | 
| 867 | 
  | 
#undef RMCOML | 
| 868 | 
  | 
} | 
| 877 | 
  | 
{ | 
| 878 | 
  | 
        extern int      frecover(); | 
| 879 | 
  | 
        static int      iter = 0; | 
| 880 | 
< | 
        char    fnbefore[128], fnafter[128]; | 
| 880 | 
> | 
        double  blurf; | 
| 881 | 
> | 
        int     nblur = getblur(&blurf); | 
| 882 | 
> | 
        char    fnbefore[128], fnafter[128], *fbase; | 
| 883 | 
  | 
        char    combuf[1024], fname0[128], fname1[128]; | 
| 884 | 
  | 
        int     usepinterp, usepfilt, nora_rgbe; | 
| 885 | 
  | 
        int     frseq[2]; | 
| 886 | 
  | 
                                                /* check what is needed */ | 
| 887 | 
< | 
        usepinterp = atoi(vval(MBLUR)); | 
| 887 | 
> | 
        usepinterp = (nblur > 1); | 
| 888 | 
  | 
        usepfilt = pfiltalways | ep==NULL; | 
| 889 | 
  | 
        if (ep != NULL && !strcmp(ep, "1")) | 
| 890 | 
  | 
                ep = "+0"; | 
| 893 | 
  | 
                                                /* compute rendered views */ | 
| 894 | 
  | 
        frseq[0] = frame - ((frame-1) % (vint(INTERP)+1)); | 
| 895 | 
  | 
        frseq[1] = frseq[0] + vint(INTERP) + 1; | 
| 896 | 
+ | 
        fbase = dirfile(NULL, vval(BASENAME)); | 
| 897 | 
  | 
        if (frseq[1] > vint(END)) | 
| 898 | 
  | 
                frseq[1] = vint(END); | 
| 899 | 
  | 
        if (frseq[1] == frame) {                        /* pfilt only */ | 
| 903 | 
  | 
        } else if (frseq[0] == frame) {         /* no interpolation needed */ | 
| 904 | 
  | 
                if (!rvr && frame > 1+vint(INTERP)) {   /* archive previous */ | 
| 905 | 
  | 
                        *arcnext++ = ' '; | 
| 906 | 
< | 
                        sprintf(arcnext, vval(BASENAME), frame-vint(INTERP)-1); | 
| 906 | 
> | 
                        sprintf(arcnext, fbase, frame-vint(INTERP)-1); | 
| 907 | 
  | 
                        while (*arcnext) arcnext++; | 
| 908 | 
  | 
                        strcpy(arcnext, ".unf"); | 
| 909 | 
  | 
                        arcnext += 4; | 
| 910 | 
< | 
                        if (usepinterp || vint(INTERP)) {       /* and z-buf */ | 
| 910 | 
> | 
                        if (usepinterp || vint(INTERP)) {       /* and Z-buf */ | 
| 911 | 
  | 
                                *arcnext++ = ' '; | 
| 912 | 
< | 
                                sprintf(arcnext, vval(BASENAME), | 
| 847 | 
< | 
                                                frame-vint(INTERP)-1); | 
| 912 | 
> | 
                                sprintf(arcnext, fbase, frame-vint(INTERP)-1); | 
| 913 | 
  | 
                                while (*arcnext) arcnext++; | 
| 914 | 
  | 
                                strcpy(arcnext, ".zbf"); | 
| 915 | 
  | 
                                arcnext += 4; | 
| 929 | 
  | 
        if (usepinterp) {                       /* using pinterp */ | 
| 930 | 
  | 
                if (rvr == 2 && recover(frseq[1]))      /* recover after? */ | 
| 931 | 
  | 
                        return(1); | 
| 932 | 
< | 
                if (atoi(vval(MBLUR))) { | 
| 868 | 
< | 
                        FILE    *fp;            /* motion blurring */ | 
| 932 | 
> | 
                if (nblur > 1) {                /* with pmblur */ | 
| 933 | 
  | 
                        sprintf(fname0, "%s/vw0%c", vval(DIRECTORY), | 
| 934 | 
  | 
                                        'a'+(iter%26)); | 
| 871 | 
– | 
                        if ((fp = fopen(fname0, "w")) == NULL) { | 
| 872 | 
– | 
                                perror(fname0); quit(1); | 
| 873 | 
– | 
                        } | 
| 874 | 
– | 
                        fputs(VIEWSTR, fp); | 
| 875 | 
– | 
                        fprintview(vp, fp); | 
| 876 | 
– | 
                        putc('\n', fp); fclose(fp); | 
| 877 | 
– | 
                        if ((vp = getview(frame+1)) == NULL) { | 
| 878 | 
– | 
                                fprintf(stderr, | 
| 879 | 
– | 
                        "%s: unexpected error reading view for frame %d\n", | 
| 880 | 
– | 
                                                progname, frame+1); | 
| 881 | 
– | 
                                quit(1); | 
| 882 | 
– | 
                        } | 
| 935 | 
  | 
                        sprintf(fname1, "%s/vw1%c", vval(DIRECTORY), | 
| 936 | 
  | 
                                        'a'+(iter%26)); | 
| 937 | 
< | 
                        if ((fp = fopen(fname1, "w")) == NULL) { | 
| 938 | 
< | 
                                perror(fname1); quit(1); | 
| 937 | 
> | 
                        if (!noaction) { | 
| 938 | 
> | 
                                FILE    *fp;            /* motion blurring */ | 
| 939 | 
> | 
                                if ((fp = fopen(fname0, "w")) == NULL) { | 
| 940 | 
> | 
                                        perror(fname0); quit(1); | 
| 941 | 
> | 
                                } | 
| 942 | 
> | 
                                fputs(VIEWSTR, fp); | 
| 943 | 
> | 
                                fprintview(vp, fp); | 
| 944 | 
> | 
                                putc('\n', fp); fclose(fp); | 
| 945 | 
> | 
                                if ((vp = getview(frame+1)) == NULL) { | 
| 946 | 
> | 
                                        fprintf(stderr, | 
| 947 | 
> | 
                        "%s: unexpected error reading view for frame %d\n", | 
| 948 | 
> | 
                                                        progname, frame+1); | 
| 949 | 
> | 
                                        quit(1); | 
| 950 | 
> | 
                                } | 
| 951 | 
> | 
                                if ((fp = fopen(fname1, "w")) == NULL) { | 
| 952 | 
> | 
                                        perror(fname1); quit(1); | 
| 953 | 
> | 
                                } | 
| 954 | 
> | 
                                fputs(VIEWSTR, fp); | 
| 955 | 
> | 
                                fprintview(vp, fp); | 
| 956 | 
> | 
                                putc('\n', fp); fclose(fp); | 
| 957 | 
  | 
                        } | 
| 888 | 
– | 
                        fputs(VIEWSTR, fp); | 
| 889 | 
– | 
                        fprintview(vp, fp); | 
| 890 | 
– | 
                        putc('\n', fp); fclose(fp); | 
| 958 | 
  | 
                        sprintf(combuf, | 
| 959 | 
< | 
                        "(pmblur %s %d %s %s; rm -f %s %s) | pinterp -B", | 
| 960 | 
< | 
                        *sskip(vval(MBLUR)) ? sskip2(vval(MBLUR),1) : "1", | 
| 894 | 
< | 
                                        atoi(vval(MBLUR)), | 
| 959 | 
> | 
                        "(pmblur %.3f %d %s %s; rm -f %s %s) | pinterp -B -a", | 
| 960 | 
> | 
                                        blurf, nblur, | 
| 961 | 
  | 
                                        fname0, fname1, fname0, fname1); | 
| 962 | 
  | 
                        iter++; | 
| 963 | 
  | 
                } else                          /* no blurring */ | 
| 965 | 
  | 
                strcat(combuf, viewopt(vp)); | 
| 966 | 
  | 
                if (vbool(RTRACE)) | 
| 967 | 
  | 
                        sprintf(combuf+strlen(combuf), " -ff -fr '%s -w0 %s'", | 
| 968 | 
< | 
                                        rendopt, vval(OCTREE)); | 
| 968 | 
> | 
                                        rendopt+1, vval(OCTREE)); | 
| 969 | 
  | 
                if (vdef(PINTERP)) | 
| 970 | 
  | 
                        sprintf(combuf+strlen(combuf), " %s", vval(PINTERP)); | 
| 971 | 
  | 
                if (usepfilt) | 
| 972 | 
  | 
                        sprintf(combuf+strlen(combuf), " %s", rresopt); | 
| 973 | 
  | 
                else | 
| 974 | 
< | 
                        sprintf(combuf+strlen(combuf), " %s -e %s", | 
| 974 | 
> | 
                        sprintf(combuf+strlen(combuf), " -a %s -e %s", | 
| 975 | 
  | 
                                        fresopt, ep); | 
| 976 | 
  | 
                sprintf(combuf+strlen(combuf), " %s.unf %s.zbf", | 
| 977 | 
  | 
                                fnbefore, fnbefore); | 
| 1036 | 
  | 
                } | 
| 1037 | 
  | 
                return(NULL); | 
| 1038 | 
  | 
        } | 
| 1039 | 
< | 
        if (viewfp == NULL) {           /* open file */ | 
| 1039 | 
> | 
        if (viewfp == NULL) {                   /* open file */ | 
| 1040 | 
  | 
                if ((viewfp = fopen(vval(VIEWFILE), "r")) == NULL) { | 
| 1041 | 
  | 
                        perror(vval(VIEWFILE)); | 
| 1042 | 
  | 
                        quit(1); | 
| 1043 | 
  | 
                } | 
| 1044 | 
< | 
        } else if (n < viewnum) {       /* rewind file */ | 
| 1044 | 
> | 
        } else if (n > 0 && n < viewnum) {      /* rewind file */ | 
| 1045 | 
  | 
                if (viewnum == 1 && feof(viewfp)) | 
| 1046 | 
  | 
                        return(&curview);               /* just one view */ | 
| 1047 | 
  | 
                if (fseek(viewfp, 0L, 0) == EOF) { | 
| 1051 | 
  | 
                copystruct(&curview, &stdview); | 
| 1052 | 
  | 
                viewnum = 0; | 
| 1053 | 
  | 
        } | 
| 1054 | 
+ | 
        if (n < 0) {                            /* get next view */ | 
| 1055 | 
+ | 
                register int    c = getc(viewfp); | 
| 1056 | 
+ | 
                if (c == EOF) | 
| 1057 | 
+ | 
                        return((VIEW *)NULL);           /* that's it */ | 
| 1058 | 
+ | 
                ungetc(c, viewfp); | 
| 1059 | 
+ | 
                n = viewnum + 1; | 
| 1060 | 
+ | 
        } | 
| 1061 | 
  | 
        while (n > viewnum) {           /* scan to desired view */ | 
| 1062 | 
  | 
                if (fgets(linebuf, sizeof(linebuf), viewfp) == NULL) | 
| 1063 | 
< | 
                        return(viewnum==1 ? &curview : NULL); | 
| 1063 | 
> | 
                        return(viewnum==1 ? &curview : (VIEW *)NULL); | 
| 1064 | 
  | 
                if (isview(linebuf) && sscanview(&curview, linebuf) > 0) | 
| 1065 | 
  | 
                        viewnum++; | 
| 1066 | 
  | 
        } | 
| 1071 | 
  | 
int | 
| 1072 | 
  | 
countviews()                    /* count views in view file */ | 
| 1073 | 
  | 
{ | 
| 1074 | 
< | 
        register int    n = 0; | 
| 1074 | 
> | 
        int     n; | 
| 1075 | 
  | 
 | 
| 1076 | 
< | 
        while (getview(n+1) != NULL) | 
| 1076 | 
> | 
        if (getview(n=1) == NULL) | 
| 1077 | 
> | 
                return(0); | 
| 1078 | 
> | 
        while (getview(-1) != NULL) | 
| 1079 | 
  | 
                n++; | 
| 1080 | 
  | 
        return(n); | 
| 1081 | 
  | 
} | 
| 1095 | 
  | 
        if (n == 0) {                           /* signal to close file */ | 
| 1096 | 
  | 
                if (expfp != NULL) { | 
| 1097 | 
  | 
                        fclose(expfp); | 
| 1098 | 
+ | 
                        free((void *)exppos); | 
| 1099 | 
  | 
                        expfp = NULL; | 
| 1100 | 
  | 
                } | 
| 1101 | 
  | 
                return(NULL); | 
| 1102 | 
< | 
        } | 
| 1102 | 
> | 
        } else if (n > vint(END))               /* request past end (error?) */ | 
| 1103 | 
> | 
                return(NULL); | 
| 1104 | 
  | 
        if (!vdef(EXPOSURE))                    /* no setting (auto) */ | 
| 1105 | 
  | 
                return(NULL); | 
| 1106 | 
  | 
        if (isflt(vval(EXPOSURE)))              /* always the same */ | 
| 1138 | 
  | 
                } | 
| 1139 | 
  | 
                curfrm++; | 
| 1140 | 
  | 
                cp = fskip(expval);                     /* check format */ | 
| 1141 | 
< | 
                if (cp == NULL || *cp != '\n') { | 
| 1141 | 
> | 
                if (cp != NULL) | 
| 1142 | 
> | 
                        while (isspace(*cp)) | 
| 1143 | 
> | 
                                *cp++ = '\0'; | 
| 1144 | 
> | 
                if (cp == NULL || *cp) { | 
| 1145 | 
  | 
                        fprintf(stderr, | 
| 1146 | 
  | 
                                "%s: exposure format error on line %d\n", | 
| 1147 | 
  | 
                                        vval(EXPOSURE), curfrm); | 
| 1148 | 
  | 
                        quit(1); | 
| 1149 | 
  | 
                } | 
| 1070 | 
– | 
                *cp = '\0'; | 
| 1150 | 
  | 
        } | 
| 1151 | 
  | 
        return(expval);                         /* return value */ | 
| 1152 | 
  | 
} | 
| 1176 | 
  | 
int     status; | 
| 1177 | 
  | 
{ | 
| 1178 | 
  | 
        register PROC   *pp; | 
| 1179 | 
+ | 
        register struct pslot   *psl; | 
| 1180 | 
  | 
 | 
| 1181 | 
  | 
        pp = ps->proc + pn; | 
| 1182 | 
  | 
        if (pp->elen) {                 /* pass errors */ | 
| 1188 | 
  | 
                if (ps->hostname[0]) | 
| 1189 | 
  | 
                        status = 1;     /* because rsh doesn't return status */ | 
| 1190 | 
  | 
        } | 
| 1191 | 
+ | 
        lastpserver = NULL; | 
| 1192 | 
+ | 
        psl = findpslot(pp->pid);       /* check for bruncom() slot */ | 
| 1193 | 
+ | 
        if (psl->pid) { | 
| 1194 | 
+ | 
                if (status) { | 
| 1195 | 
+ | 
                        if (psl->rcvf != NULL)  /* attempt recovery */ | 
| 1196 | 
+ | 
                                status = (*psl->rcvf)(psl->fout); | 
| 1197 | 
+ | 
                        if (status) { | 
| 1198 | 
+ | 
                                fprintf(stderr, | 
| 1199 | 
+ | 
                                        "%s: error rendering frame %d\n", | 
| 1200 | 
+ | 
                                                progname, psl->fout); | 
| 1201 | 
+ | 
                                quit(1); | 
| 1202 | 
+ | 
                        } | 
| 1203 | 
+ | 
                        lastpserver = ps; | 
| 1204 | 
+ | 
                } | 
| 1205 | 
+ | 
                psl->pid = 0;                   /* free process slot */ | 
| 1206 | 
+ | 
        } else if (status) | 
| 1207 | 
+ | 
                lastpserver = ps; | 
| 1208 | 
  | 
        freestr(pp->com);               /* free command string */ | 
| 1112 | 
– | 
        lastpid = pp->pid;              /* record PID for bwait() */ | 
| 1113 | 
– | 
        lastpserver = ps;               /* record server for serverdown() */ | 
| 1209 | 
  | 
        return(status); | 
| 1210 | 
  | 
} | 
| 1211 | 
  | 
 | 
| 1213 | 
  | 
int | 
| 1214 | 
  | 
serverdown()                    /* check status of last process server */ | 
| 1215 | 
  | 
{ | 
| 1216 | 
+ | 
        if (lastpserver == NULL || !lastpserver->hostname[0]) | 
| 1217 | 
+ | 
                return(0); | 
| 1218 | 
  | 
        if (pserverOK(lastpserver))     /* server still up? */ | 
| 1219 | 
  | 
                return(0); | 
| 1220 | 
  | 
        delpserver(lastpserver);        /* else delete it */ | 
| 1241 | 
  | 
                        printf("\t%s\n", com);  /* echo command */ | 
| 1242 | 
  | 
                return(0); | 
| 1243 | 
  | 
        } | 
| 1244 | 
< | 
                                        /* else start it when we can */ | 
| 1245 | 
< | 
        while ((pid = startjob(NULL, savestr(com), donecom)) == -1) | 
| 1244 | 
> | 
        com = savestr(com);             /* else start it when we can */ | 
| 1245 | 
> | 
        while ((pid = startjob(NULL, com, donecom)) == -1) | 
| 1246 | 
  | 
                bwait(1); | 
| 1247 | 
  | 
        if (!silent) {                          /* echo command */ | 
| 1248 | 
  | 
                PSERVER *ps; | 
| 1264 | 
  | 
int     ncoms; | 
| 1265 | 
  | 
{ | 
| 1266 | 
  | 
        int     status; | 
| 1170 | 
– | 
        register struct pslot   *psl; | 
| 1267 | 
  | 
 | 
| 1268 | 
  | 
        if (noaction) | 
| 1269 | 
  | 
                return; | 
| 1270 | 
  | 
        while ((status = wait4job(NULL, -1)) != -1) { | 
| 1271 | 
< | 
                psl = findpslot(lastpid); | 
| 1272 | 
< | 
                if (status) {           /* attempt recovery */ | 
| 1273 | 
< | 
                        serverdown();   /* check server */ | 
| 1178 | 
< | 
                        if (psl->rcvf == NULL || (*psl->rcvf)(psl->fout)) { | 
| 1179 | 
< | 
                                fprintf(stderr, | 
| 1180 | 
< | 
                                        "%s: error rendering frame %d\n", | 
| 1181 | 
< | 
                                                progname, psl->fout); | 
| 1182 | 
< | 
                                quit(1); | 
| 1183 | 
< | 
                        } | 
| 1184 | 
< | 
                } | 
| 1185 | 
< | 
                psl->pid = 0;           /* free process slot */ | 
| 1186 | 
< | 
                if (!--ncoms) | 
| 1187 | 
< | 
                        return;         /* done enough */ | 
| 1271 | 
> | 
                serverdown();           /* update server status */ | 
| 1272 | 
> | 
                if (--ncoms == 0) | 
| 1273 | 
> | 
                        break;          /* done enough */ | 
| 1274 | 
  | 
        } | 
| 1275 | 
  | 
} | 
| 1276 | 
  | 
 | 
| 1282 | 
  | 
{ | 
| 1283 | 
  | 
        int     retstatus = 0; | 
| 1284 | 
  | 
        int     hostcopies; | 
| 1285 | 
< | 
        char    com1buf[10240], *com1, *endcom1; | 
| 1285 | 
> | 
        char    buf[10240], *com1, *s; | 
| 1286 | 
  | 
        int     status; | 
| 1287 | 
+ | 
        int     pfd; | 
| 1288 | 
+ | 
        register int    n; | 
| 1289 | 
  | 
        register PSERVER        *ps; | 
| 1290 | 
  | 
 | 
| 1291 | 
  | 
        if (!silent) | 
| 1297 | 
  | 
        for (ps = pslist; ps != NULL; ps = ps->next) { | 
| 1298 | 
  | 
                hostcopies = 0; | 
| 1299 | 
  | 
                if (maxcopies > 1 && ps->nprocs > 1 && ppins != NULL) { | 
| 1300 | 
< | 
                        strcpy(com1=com1buf, com);      /* build -PP command */ | 
| 1300 | 
> | 
                        strcpy(com1=buf, com);  /* build -PP command */ | 
| 1301 | 
  | 
                        sprintf(com1+(ppins-com), " -PP %s/%s.persist", | 
| 1302 | 
  | 
                                        vval(DIRECTORY), phostname(ps)); | 
| 1303 | 
  | 
                        strcat(com1, ppins); | 
| 1304 | 
< | 
                        endcom1 = com1 + strlen(com1); | 
| 1217 | 
< | 
                        sprintf(endcom1, "; kill `sed -n '1s/^[^ ]* //p' %s/%s.persist`", | 
| 1218 | 
< | 
                                        vval(DIRECTORY), phostname(ps)); | 
| 1219 | 
< | 
                } else { | 
| 1304 | 
> | 
                } else | 
| 1305 | 
  | 
                        com1 = com; | 
| 1306 | 
< | 
                        endcom1 = NULL; | 
| 1306 | 
> | 
                while (maxcopies > 0) { | 
| 1307 | 
> | 
                        s = savestr(com1); | 
| 1308 | 
> | 
                        if (startjob(ps, s, donecom) != -1) { | 
| 1309 | 
> | 
                                sleep(20); | 
| 1310 | 
> | 
                                hostcopies++; | 
| 1311 | 
> | 
                                maxcopies--; | 
| 1312 | 
> | 
                        } else { | 
| 1313 | 
> | 
                                freestr(s); | 
| 1314 | 
> | 
                                break; | 
| 1315 | 
> | 
                        } | 
| 1316 | 
  | 
                } | 
| 1223 | 
– | 
                while (maxcopies > 0 && | 
| 1224 | 
– | 
                                startjob(ps, savestr(com1), donecom) != -1) { | 
| 1225 | 
– | 
                        sleep(10); | 
| 1226 | 
– | 
                        hostcopies++; | 
| 1227 | 
– | 
                        maxcopies--; | 
| 1228 | 
– | 
                        if (endcom1 != NULL) | 
| 1229 | 
– | 
                                *endcom1 = '\0'; | 
| 1230 | 
– | 
                } | 
| 1317 | 
  | 
                if (!silent && hostcopies) { | 
| 1318 | 
  | 
                        if (hostcopies > 1) | 
| 1319 | 
  | 
                                printf("\t%d duplicate processes", hostcopies); | 
| 1325 | 
  | 
        } | 
| 1326 | 
  | 
                                        /* wait for jobs to finish */ | 
| 1327 | 
  | 
        while ((status = wait4job(NULL, -1)) != -1) | 
| 1328 | 
< | 
                if (status) | 
| 1329 | 
< | 
                        retstatus += !serverdown();     /* check server */ | 
| 1328 | 
> | 
                retstatus += status && !serverdown(); | 
| 1329 | 
> | 
                                        /* terminate parallel rpict's */ | 
| 1330 | 
> | 
        for (ps = pslist; ps != NULL; ps = ps->next) { | 
| 1331 | 
> | 
                sprintf(buf, "%s/%s.persist", vval(DIRECTORY), phostname(ps)); | 
| 1332 | 
> | 
                if ((pfd = open(buf, O_RDONLY)) >= 0) { | 
| 1333 | 
> | 
                        n = read(pfd, buf, sizeof(buf)-1);      /* get PID */ | 
| 1334 | 
> | 
                        buf[n] = '\0'; | 
| 1335 | 
> | 
                        close(pfd); | 
| 1336 | 
> | 
                        for (n = 0; buf[n] && !isspace(buf[n]); n++) | 
| 1337 | 
> | 
                                ; | 
| 1338 | 
> | 
                                                                /* terminate */ | 
| 1339 | 
> | 
                        sprintf(buf, "kill -ALRM %d", atoi(buf+n)); | 
| 1340 | 
> | 
                        wait4job(ps, startjob(ps, buf, NULL)); | 
| 1341 | 
> | 
                } | 
| 1342 | 
> | 
        } | 
| 1343 | 
  | 
        return(retstatus); | 
| 1344 | 
  | 
} | 
| 1345 | 
  | 
 | 
| 1377 | 
  | 
        fprintf(stderr, "%s: bad value for variable '%s'\n", | 
| 1378 | 
  | 
                        progname, vnam(vc)); | 
| 1379 | 
  | 
        quit(1); | 
| 1380 | 
+ | 
} | 
| 1381 | 
+ | 
 | 
| 1382 | 
+ | 
 | 
| 1383 | 
+ | 
char * | 
| 1384 | 
+ | 
dirfile(df, path)               /* separate path into directory and file */ | 
| 1385 | 
+ | 
char    *df; | 
| 1386 | 
+ | 
register char   *path; | 
| 1387 | 
+ | 
{ | 
| 1388 | 
+ | 
        register int    i; | 
| 1389 | 
+ | 
        int     psep; | 
| 1390 | 
+ | 
 | 
| 1391 | 
+ | 
        for (i = 0, psep = -1; path[i]; i++) | 
| 1392 | 
+ | 
                if (path[i] == '/') | 
| 1393 | 
+ | 
                        psep = i; | 
| 1394 | 
+ | 
        if (df != NULL) | 
| 1395 | 
+ | 
                if (psep == 0) { | 
| 1396 | 
+ | 
                        df[0] = '/'; | 
| 1397 | 
+ | 
                        df[1] = '\0'; | 
| 1398 | 
+ | 
                } else if (psep > 0) { | 
| 1399 | 
+ | 
                        strncpy(df, path, psep); | 
| 1400 | 
+ | 
                        df[psep] = '\0'; | 
| 1401 | 
+ | 
                } else | 
| 1402 | 
+ | 
                        df[0] = '\0'; | 
| 1403 | 
+ | 
        return(path+psep+1); | 
| 1404 | 
+ | 
} | 
| 1405 | 
+ | 
 | 
| 1406 | 
+ | 
 | 
| 1407 | 
+ | 
int | 
| 1408 | 
+ | 
getblur(double *bf)             /* get # blur samples (and fraction) */ | 
| 1409 | 
+ | 
{ | 
| 1410 | 
+ | 
        double  blurf; | 
| 1411 | 
+ | 
        int     nblur; | 
| 1412 | 
+ | 
        char    *s; | 
| 1413 | 
+ | 
 | 
| 1414 | 
+ | 
        if (!vdef(MBLUR)) { | 
| 1415 | 
+ | 
                if (bf != NULL) | 
| 1416 | 
+ | 
                        *bf = 0.0; | 
| 1417 | 
+ | 
                return(0); | 
| 1418 | 
+ | 
        } | 
| 1419 | 
+ | 
        blurf = atof(vval(MBLUR)); | 
| 1420 | 
+ | 
        if (blurf < 0.0) | 
| 1421 | 
+ | 
                blurf = 0.0; | 
| 1422 | 
+ | 
        if (bf != NULL) | 
| 1423 | 
+ | 
                *bf = blurf; | 
| 1424 | 
+ | 
        if (blurf <= FTINY) | 
| 1425 | 
+ | 
                return(0); | 
| 1426 | 
+ | 
        s = sskip(vval(MBLUR)); | 
| 1427 | 
+ | 
        if (!*s) | 
| 1428 | 
+ | 
                return(DEF_NBLUR); | 
| 1429 | 
+ | 
        nblur = atoi(s); | 
| 1430 | 
+ | 
        if (nblur <= 0) | 
| 1431 | 
+ | 
                return(1); | 
| 1432 | 
+ | 
        return(nblur); | 
| 1433 | 
  | 
} |