| 15 |  |  | 
| 16 |  | #include "copyright.h" | 
| 17 |  |  | 
| 18 | < | #include "standard.h" | 
| 18 | > | #include <stdio.h> | 
| 19 |  | #include <ctype.h> | 
| 20 |  | #include <sys/stat.h> | 
| 21 | + | #include <time.h> | 
| 22 | + |  | 
| 23 | + | /*#include "standard.h"*/ | 
| 24 | + | #include "platform.h" | 
| 25 | + | #include "paths.h" | 
| 26 | + | #include "rtio.h" | 
| 27 | + | #include "rterror.h" | 
| 28 |  | #include "view.h" | 
| 29 |  | #include "vars.h" | 
| 30 |  | #include "netproc.h" | 
| 33 |  | #define DEF_NBLUR       5 | 
| 34 |  | #endif | 
| 35 |  | /* default remote shell */ | 
| 29 | – | #ifdef _AUX_SOURCE | 
| 30 | – | #define REMSH           "remsh" | 
| 31 | – | #else | 
| 36 |  | #define REMSH           "rsh" | 
| 33 | – | #endif | 
| 37 |  | /* input variables (alphabetical by name) */ | 
| 38 |  | #define ANIMATE         0               /* animation command */ | 
| 39 |  | #define ARCHIVE         1               /* archiving command */ | 
| 122 |  | int     npslots;                /* number of process slots */ | 
| 123 |  |  | 
| 124 |  | #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(), *dirfile(); | 
| 129 | < | int     getblur(); | 
| 127 | > | static struct pslot * findpslot(int pid); | 
| 128 | > | static void checkdir(void); | 
| 129 | > | static VIEW * getview(int n); | 
| 130 |  |  | 
| 131 | < | extern time_t   time(); | 
| 131 | > | static char * dirfile(char *df, register char *path); | 
| 132 | > | static char * getexp(int n); | 
| 133 | > | static int getblur(double *bf); | 
| 134 | > | static int getastat(void); | 
| 135 | > | static void getradfile(char *rfargs); | 
| 136 | > | static void badvalue(int vc); | 
| 137 | > | static int rmfile(char *fn); | 
| 138 | > | static int runcom(char *cs); | 
| 139 | > | static int pruncom(char *com, char *ppins, int maxcopies); | 
| 140 | > | static void bwait(int ncoms); | 
| 141 | > | static int bruncom(char *com, int fout, int (*rf)()); | 
| 142 | > | static int serverdown(void); | 
| 143 | > | static int donecom(PSERVER *ps, int pn, int status); | 
| 144 | > | static int countviews(void); | 
| 145 | > | static int dofilt(int frame, int rvr); | 
| 146 | > | static void archive(void); | 
| 147 | > | static int frecover(int frame); | 
| 148 | > | static int recover(int frame); | 
| 149 | > | static void sethosts(void); | 
| 150 | > | static void walkwait(int first, int last, char *vfn); | 
| 151 | > | static void animrend(int frame, VIEW *vp); | 
| 152 | > | static void transferframes(void); | 
| 153 | > | static void filterframes(void); | 
| 154 | > | static void renderframes(int nframes); | 
| 155 | > | static void animate(void); | 
| 156 | > | static void setdefaults(void); | 
| 157 | > | static void putastat(void); | 
| 158 |  |  | 
| 159 |  |  | 
| 160 |  | main(argc, argv) | 
| 228 |  | } | 
| 229 |  |  | 
| 230 |  |  | 
| 231 | < | getastat()                      /* check/set animation status */ | 
| 231 | > | static int | 
| 232 | > | getastat(void)                  /* check/set animation status */ | 
| 233 |  | { | 
| 234 |  | char    sfname[256]; | 
| 235 |  | FILE    *fp; | 
| 293 |  | } | 
| 294 |  |  | 
| 295 |  |  | 
| 296 | < | putastat()                      /* put out current status */ | 
| 296 | > | static void | 
| 297 | > | putastat(void)                  /* put out current status */ | 
| 298 |  | { | 
| 299 |  | char    buf[256]; | 
| 300 |  | FILE    *fp; | 
| 316 |  | } | 
| 317 |  |  | 
| 318 |  |  | 
| 319 | < | checkdir()                      /* make sure we have our directory */ | 
| 319 | > | static void | 
| 320 | > | checkdir(void)                  /* make sure we have our directory */ | 
| 321 |  | { | 
| 322 |  | struct stat     stb; | 
| 323 |  |  | 
| 339 |  | } | 
| 340 |  |  | 
| 341 |  |  | 
| 342 | < | setdefaults()                   /* set default values */ | 
| 342 | > | static void | 
| 343 | > | setdefaults(void)                       /* set default values */ | 
| 344 |  | { | 
| 345 |  | extern char     *atos(); | 
| 346 |  | int     decades; | 
| 428 |  | } | 
| 429 |  |  | 
| 430 |  |  | 
| 431 | < | sethosts()                      /* set up process servers */ | 
| 431 | > | static void | 
| 432 | > | sethosts(void)                  /* set up process servers */ | 
| 433 |  | { | 
| 434 |  | extern char     *iskip(); | 
| 435 |  | char    buf[256], *dir, *uname; | 
| 484 |  | } | 
| 485 |  | } | 
| 486 |  |  | 
| 487 | < |  | 
| 488 | < | getradfile(rfargs)              /* run rad and get needed variables */ | 
| 458 | < | char    *rfargs; | 
| 487 | > | static void | 
| 488 | > | getradfile(char *rfargs)                /* run rad and get needed variables */ | 
| 489 |  | { | 
| 490 |  | static short    mvar[] = {OCTREE,PFILT,RESOLUTION,EXPOSURE,-1}; | 
| 491 |  | char    combuf[256]; | 
| 510 |  | pippt = NULL; | 
| 511 |  | } | 
| 512 |  | if (pippt != NULL) | 
| 513 | < | strcpy(pippt, "> /dev/null");   /* nothing to match */ | 
| 513 | > | strcpy(pippt, "> " NULL_DEVICE);        /* nothing to match */ | 
| 514 |  | else { | 
| 515 |  | sprintf(cp, ")[ \t]*=' > %s/radset.var", vval(DIRECTORY)); | 
| 516 |  | cp += 11;               /* point to file name */ | 
| 523 |  | } | 
| 524 |  |  | 
| 525 |  |  | 
| 526 | < | animate()                       /* run animation */ | 
| 526 | > | static void | 
| 527 | > | animate(void)                   /* run animation */ | 
| 528 |  | { | 
| 529 |  | int     xres, yres; | 
| 530 |  | float   pa, mult; | 
| 595 |  | } | 
| 596 |  |  | 
| 597 |  |  | 
| 598 | < | renderframes(nframes)           /* render next nframes frames */ | 
| 599 | < | int     nframes; | 
| 598 | > | static void | 
| 599 | > | renderframes(int nframes)               /* render next nframes frames */ | 
| 600 |  | { | 
| 601 |  | static char     vendbuf[16]; | 
| 602 |  | VIEW    *vp; | 
| 652 |  | } | 
| 653 |  |  | 
| 654 |  |  | 
| 655 | < | filterframes()                          /* catch up with filtering */ | 
| 655 | > | static void | 
| 656 | > | filterframes(void)                              /* catch up with filtering */ | 
| 657 |  | { | 
| 658 |  | VIEW    *vp; | 
| 659 |  | register int    i; | 
| 661 |  | if (astat.tnext < astat.fnext)  /* other work to do first */ | 
| 662 |  | return; | 
| 663 |  | /* filter each view */ | 
| 664 | < | for (i = astat.fnext; i < astat.rnext; i++) { | 
| 665 | < | if ((vp = getview(i)) == NULL) {        /* get view i */ | 
| 666 | < | fprintf(stderr, | 
| 635 | < | "%s: unexpected error reading view for frame %d\n", | 
| 636 | < | progname, i); | 
| 637 | < | quit(1); | 
| 638 | < | } | 
| 639 | < | dofilt(i, vp, getexp(i), 0);            /* filter frame */ | 
| 640 | < | } | 
| 664 | > | for (i = astat.fnext; i < astat.rnext; i++) | 
| 665 | > | dofilt(i, 0); | 
| 666 | > |  | 
| 667 |  | bwait(0);                       /* wait for filter processes */ | 
| 668 |  | archive();                      /* archive originals */ | 
| 669 |  | astat.fnext = i;                /* update status */ | 
| 671 |  | } | 
| 672 |  |  | 
| 673 |  |  | 
| 674 | < | transferframes()                        /* catch up with picture transfers */ | 
| 674 | > | static void | 
| 675 | > | transferframes(void)                    /* catch up with picture transfers */ | 
| 676 |  | { | 
| 677 |  | char    combuf[10240], *fbase; | 
| 678 |  | register char   *cp; | 
| 712 |  | } | 
| 713 |  |  | 
| 714 |  |  | 
| 715 | < | animrend(frame, vp)                     /* start animation frame */ | 
| 716 | < | int     frame; | 
| 717 | < | VIEW    *vp; | 
| 715 | > | static void | 
| 716 | > | animrend(                       /* start animation frame */ | 
| 717 | > | int     frame, | 
| 718 | > | VIEW    *vp | 
| 719 | > | ) | 
| 720 |  | { | 
| 692 | – | extern int      recover(); | 
| 721 |  | char    combuf[2048]; | 
| 722 |  | char    fname[128]; | 
| 723 |  |  | 
| 731 |  | } | 
| 732 |  |  | 
| 733 |  |  | 
| 734 | < | walkwait(first, last, vfn)              /* walk-through frames */ | 
| 735 | < | int     first, last; | 
| 736 | < | char    *vfn; | 
| 734 | > | static void | 
| 735 | > | walkwait(               /* walk-through frames */ | 
| 736 | > | int     first, | 
| 737 | > | int last, | 
| 738 | > | char    *vfn | 
| 739 | > | ) | 
| 740 |  | { | 
| 741 |  | double  blurf; | 
| 742 |  | int     nblur = getblur(&blurf); | 
| 786 |  | } | 
| 787 |  |  | 
| 788 |  |  | 
| 789 | < | int | 
| 790 | < | recover(frame)                          /* recover the specified frame */ | 
| 760 | < | int     frame; | 
| 789 | > | static int | 
| 790 | > | recover(int frame)                      /* recover the specified frame */ | 
| 791 |  | { | 
| 792 |  | static int      *rfrm;          /* list of recovered frames */ | 
| 793 |  | static int      nrfrms = 0; | 
| 840 |  | } | 
| 841 |  |  | 
| 842 |  |  | 
| 843 | < | int | 
| 844 | < | frecover(frame)                         /* recover filtered frame */ | 
| 815 | < | int     frame; | 
| 843 | > | static int | 
| 844 | > | frecover(int frame)                             /* recover filtered frame */ | 
| 845 |  | { | 
| 846 | < | VIEW    *vp; | 
| 818 | < | char    *ex; | 
| 819 | < |  | 
| 820 | < | vp = getview(frame); | 
| 821 | < | ex = getexp(frame); | 
| 822 | < | if (dofilt(frame, vp, ex, 2) && dofilt(frame, vp, ex, 1)) | 
| 846 | > | if (dofilt(frame, 2) && dofilt(frame, 1)) | 
| 847 |  | return(1); | 
| 848 |  | return(0); | 
| 849 |  | } | 
| 850 |  |  | 
| 851 |  |  | 
| 852 | < | archive()                       /* archive and remove renderings */ | 
| 852 | > | static void | 
| 853 | > | archive(void)                   /* archive and remove renderings */ | 
| 854 |  | { | 
| 855 |  | #define RMCOML  (sizeof(rmcom)-1) | 
| 856 |  | static char     rmcom[] = "rm -f"; | 
| 893 |  | } | 
| 894 |  |  | 
| 895 |  |  | 
| 896 | < | int | 
| 897 | < | dofilt(frame, vp, ep, rvr)                      /* filter frame */ | 
| 898 | < | int     frame; | 
| 899 | < | VIEW    *vp; | 
| 900 | < | char    *ep; | 
| 876 | < | int     rvr; | 
| 896 | > | static int | 
| 897 | > | dofilt(                         /* filter frame */ | 
| 898 | > | int     frame, | 
| 899 | > | int     rvr | 
| 900 | > | ) | 
| 901 |  | { | 
| 878 | – | extern int      frecover(); | 
| 902 |  | static int      iter = 0; | 
| 903 |  | double  blurf; | 
| 904 |  | int     nblur = getblur(&blurf); | 
| 905 | + | VIEW    *vp = getview(frame); | 
| 906 | + | char    *ep = getexp(frame); | 
| 907 |  | char    fnbefore[128], fnafter[128], *fbase; | 
| 908 |  | char    combuf[1024], fname0[128], fname1[128]; | 
| 909 |  | int     usepinterp, usepfilt, nora_rgbe; | 
| 910 |  | int     frseq[2]; | 
| 911 |  | /* check what is needed */ | 
| 912 | + | if (vp == NULL) { | 
| 913 | + | fprintf(stderr, | 
| 914 | + | "%s: unexpected error reading view for frame %d\n", | 
| 915 | + | progname, frame); | 
| 916 | + | quit(1); | 
| 917 | + | } | 
| 918 |  | usepinterp = (nblur > 1); | 
| 919 | < | usepfilt = pfiltalways | ep==NULL; | 
| 919 | > | usepfilt = pfiltalways | (ep==NULL); | 
| 920 |  | if (ep != NULL && !strcmp(ep, "1")) | 
| 921 |  | ep = "+0"; | 
| 922 |  | nora_rgbe = strcmp(vval(OVERSAMP),"1") || ep==NULL || | 
| 1049 |  | } | 
| 1050 |  |  | 
| 1051 |  |  | 
| 1052 | < | VIEW * | 
| 1053 | < | getview(n)                      /* get view number n */ | 
| 1023 | < | int     n; | 
| 1052 | > | static VIEW * | 
| 1053 | > | getview(int n)                  /* get view number n */ | 
| 1054 |  | { | 
| 1055 |  | static FILE     *viewfp = NULL;         /* view file pointer */ | 
| 1056 |  | static int      viewnum = 0;            /* current view number */ | 
| 1062 |  | fclose(viewfp); | 
| 1063 |  | viewfp = NULL; | 
| 1064 |  | viewnum = 0; | 
| 1065 | < | copystruct(&curview, &stdview); | 
| 1065 | > | curview = stdview; | 
| 1066 |  | } | 
| 1067 |  | return(NULL); | 
| 1068 |  | } | 
| 1078 |  | perror(vval(VIEWFILE)); | 
| 1079 |  | quit(1); | 
| 1080 |  | } | 
| 1081 | < | copystruct(&curview, &stdview); | 
| 1081 | > | curview = stdview; | 
| 1082 |  | viewnum = 0; | 
| 1083 |  | } | 
| 1084 |  | if (n < 0) {                            /* get next view */ | 
| 1098 |  | } | 
| 1099 |  |  | 
| 1100 |  |  | 
| 1101 | < | int | 
| 1102 | < | countviews()                    /* count views in view file */ | 
| 1101 | > | static int | 
| 1102 | > | countviews(void)                        /* count views in view file */ | 
| 1103 |  | { | 
| 1104 |  | int     n; | 
| 1105 |  |  | 
| 1111 |  | } | 
| 1112 |  |  | 
| 1113 |  |  | 
| 1114 | < | char * | 
| 1115 | < | getexp(n)                       /* get exposure for nth frame */ | 
| 1086 | < | int     n; | 
| 1114 | > | static char * | 
| 1115 | > | getexp(int n)                   /* get exposure for nth frame */ | 
| 1116 |  | { | 
| 1117 |  | extern char     *fskip(); | 
| 1118 |  | static char     expval[32]; | 
| 1181 |  | } | 
| 1182 |  |  | 
| 1183 |  |  | 
| 1184 | < | struct pslot * | 
| 1185 | < | findpslot(pid)                  /* find or allocate a process slot */ | 
| 1157 | < | int     pid; | 
| 1184 | > | static struct pslot * | 
| 1185 | > | findpslot(int pid)                      /* find or allocate a process slot */ | 
| 1186 |  | { | 
| 1187 |  | register struct pslot   *psempty = NULL; | 
| 1188 |  | register int    i; | 
| 1197 |  | } | 
| 1198 |  |  | 
| 1199 |  |  | 
| 1200 | < | int | 
| 1201 | < | donecom(ps, pn, status)         /* clean up after finished process */ | 
| 1202 | < | PSERVER *ps; | 
| 1203 | < | int     pn; | 
| 1204 | < | int     status; | 
| 1200 | > | static int | 
| 1201 | > | donecom(                /* clean up after finished process */ | 
| 1202 | > | PSERVER *ps, | 
| 1203 | > | int     pn, | 
| 1204 | > | int     status | 
| 1205 | > | ) | 
| 1206 |  | { | 
| 1207 | < | register PROC   *pp; | 
| 1207 | > | register NETPROC        *pp; | 
| 1208 |  | register struct pslot   *psl; | 
| 1209 |  |  | 
| 1210 |  | pp = ps->proc + pn; | 
| 1239 |  | } | 
| 1240 |  |  | 
| 1241 |  |  | 
| 1242 | < | int | 
| 1243 | < | serverdown()                    /* check status of last process server */ | 
| 1242 | > | static int | 
| 1243 | > | serverdown(void)                        /* check status of last process server */ | 
| 1244 |  | { | 
| 1245 |  | if (lastpserver == NULL || !lastpserver->hostname[0]) | 
| 1246 |  | return(0); | 
| 1256 |  | } | 
| 1257 |  |  | 
| 1258 |  |  | 
| 1259 | < | int | 
| 1260 | < | bruncom(com, fout, rf)          /* run a command in the background */ | 
| 1261 | < | char    *com; | 
| 1262 | < | int     fout; | 
| 1263 | < | int     (*rf)(); | 
| 1259 | > | static int | 
| 1260 | > | bruncom(                /* run a command in the background */ | 
| 1261 | > | char    *com, | 
| 1262 | > | int     fout, | 
| 1263 | > | int     (*rf)() | 
| 1264 | > | ) | 
| 1265 |  | { | 
| 1266 |  | int     pid; | 
| 1267 |  | register struct pslot   *psl; | 
| 1290 |  | } | 
| 1291 |  |  | 
| 1292 |  |  | 
| 1293 | < | bwait(ncoms)                            /* wait for batch job(s) to finish */ | 
| 1294 | < | int     ncoms; | 
| 1293 | > | static void | 
| 1294 | > | bwait(int ncoms)                                /* wait for batch job(s) to finish */ | 
| 1295 |  | { | 
| 1296 |  | int     status; | 
| 1297 |  |  | 
| 1305 |  | } | 
| 1306 |  |  | 
| 1307 |  |  | 
| 1308 | < | int | 
| 1309 | < | pruncom(com, ppins, maxcopies)  /* run a command in parallel over network */ | 
| 1310 | < | char    *com, *ppins; | 
| 1311 | < | int     maxcopies; | 
| 1308 | > | static int | 
| 1309 | > | pruncom(        /* run a command in parallel over network */ | 
| 1310 | > | char    *com, | 
| 1311 | > | char    *ppins, | 
| 1312 | > | int     maxcopies | 
| 1313 | > | ) | 
| 1314 |  | { | 
| 1315 |  | int     retstatus = 0; | 
| 1316 |  | int     hostcopies; | 
| 1377 |  | } | 
| 1378 |  |  | 
| 1379 |  |  | 
| 1380 | < | runcom(cs)                      /* run a command locally and wait for it */ | 
| 1381 | < | char    *cs; | 
| 1380 | > | static int | 
| 1381 | > | runcom(char *cs)                        /* run a command locally and wait for it */ | 
| 1382 |  | { | 
| 1383 |  | if (!silent)            /* echo it */ | 
| 1384 |  | printf("\t%s\n", cs); | 
| 1389 |  | } | 
| 1390 |  |  | 
| 1391 |  |  | 
| 1392 | < | rmfile(fn)                      /* remove a file */ | 
| 1393 | < | char    *fn; | 
| 1392 | > | static int | 
| 1393 | > | rmfile(char *fn)                        /* remove a file */ | 
| 1394 |  | { | 
| 1395 |  | if (!silent) | 
| 1396 |  | #ifdef _WIN32 | 
| 1404 |  | } | 
| 1405 |  |  | 
| 1406 |  |  | 
| 1407 | < | badvalue(vc)                    /* report bad variable value and exit */ | 
| 1408 | < | int     vc; | 
| 1407 | > | static void | 
| 1408 | > | badvalue(int vc)                        /* report bad variable value and exit */ | 
| 1409 |  | { | 
| 1410 |  | fprintf(stderr, "%s: bad value for variable '%s'\n", | 
| 1411 |  | progname, vnam(vc)); | 
| 1413 |  | } | 
| 1414 |  |  | 
| 1415 |  |  | 
| 1416 | < | char * | 
| 1417 | < | dirfile(df, path)               /* separate path into directory and file */ | 
| 1418 | < | char    *df; | 
| 1419 | < | register char   *path; | 
| 1416 | > | static char * | 
| 1417 | > | dirfile(                /* separate path into directory and file */ | 
| 1418 | > | char    *df, | 
| 1419 | > | register char   *path | 
| 1420 | > | ) | 
| 1421 |  | { | 
| 1422 |  | register int    i; | 
| 1423 |  | int     psep; | 
| 1425 |  | for (i = 0, psep = -1; path[i]; i++) | 
| 1426 |  | if (path[i] == '/') | 
| 1427 |  | psep = i; | 
| 1428 | < | if (df != NULL) | 
| 1428 | > | if (df != NULL) { | 
| 1429 |  | if (psep == 0) { | 
| 1430 |  | df[0] = '/'; | 
| 1431 |  | df[1] = '\0'; | 
| 1434 |  | df[psep] = '\0'; | 
| 1435 |  | } else | 
| 1436 |  | df[0] = '\0'; | 
| 1437 | + | } | 
| 1438 |  | return(path+psep+1); | 
| 1439 |  | } | 
| 1440 |  |  | 
| 1441 |  |  | 
| 1442 | < | int | 
| 1442 | > | static int | 
| 1443 |  | getblur(double *bf)             /* get # blur samples (and fraction) */ | 
| 1444 |  | { | 
| 1445 |  | double  blurf; |