ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/util/rad.c
(Generate patch)

Comparing ray/src/util/rad.c (file contents):
Revision 2.105 by greg, Fri Feb 25 06:51:51 2011 UTC vs.
Revision 2.117 by greg, Wed May 27 14:26:04 2015 UTC

# Line 24 | Line 24 | static const char      RCSid[] = "$Id$";
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) */
# Line 35 | Line 36 | static const char      RCSid[] = "$Id$";
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 RPICT           20              /* rpict parameters */
52 < #define RVU             21              /* rvu parameters */
53 < #define SCENE           22              /* scene files */
54 < #define UP              23              /* view up (X, Y or Z) */
55 < #define VARIABILITY     24              /* level of light variability */
56 < #define VIEWS           25              /* view(s) for picture(s) */
57 < #define ZFILE           26              /* distance file root name */
58 < #define ZONE            27              /* 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 = 28;
63 > int NVARS = 31;
64  
65   VARIABLE        vv[] = {                /* variable-value pairs */
66          {"AMBFILE",     3,      0,      NULL,   onevalue},
# Line 67 | Line 71 | VARIABLE       vv[] = {                /* variable-value pairs */
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},
# Line 107 | Line 114 | time_t oct0date;               /* date of pre-mkillum octree */
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 */
# Line 121 | Line 133 | char   *viewselect = NULL;     /* specific view only */
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";
# Line 144 | Line 157 | static void checkfiles(void);
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);
# Line 243 | Line 258 | main(
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 */
# Line 264 | Line 281 | userr:
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;
# Line 282 | Line 299 | rootname(              /* remove tail from end of fn */
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];
# Line 312 | Line 329 | newfname(              /* create modified file name */
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 */
# Line 335 | Line 352 | newfname(              /* create modified file name */
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)) {
# Line 364 | Line 382 | checkfiles(void)                       /* check for existence and modified
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  
# Line 378 | Line 416 | getoctcube(            /* get octree bounding cube */
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) <
# Line 558 | Line 596 | oconv(void)                            /* run oconv and mkillum if necessary *
596                          unlink(illumtmp);
597                          quit(1);
598                  }
599 +                rmfile(oct0name);
600                                                  /* make octree1 (frozen) */
601                  if (octreedate)
602                          sprintf(combuf, "%s%s -f -i %s %s > %s", c_oconv,
# Line 584 | Line 623 | oconv(void)                            /* run oconv and mkillum if necessary *
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 +                        if (pgmapdate)
661 +                                rmfile(pgmapname);
662 +                        cp = addarg(cp, "-apg");
663 +                        addarg(cp, vval(PGMAP));
664 +                        cp = sskip(sskip(cp));  /* remove any bandwidth */
665 +                        *cp = '\0';
666 +                }
667 +                if (pcmapname != NULL && pcmapdate < oct1date) {
668 +                        if (pcmapdate)
669 +                                rmfile(pcmapname);
670 +                        cp = addarg(cp, "-apc");
671 +                        addarg(cp, vval(PCMAP));
672 +                        cp = sskip(sskip(cp));  /* remove any bandwidth */
673 +                        *cp = '\0';
674 +                }
675 +                cp = addarg(cp, oct1name);
676 +                if (runcom(combuf)) {
677 +                        fprintf(stderr, "%s: error running %s\n",
678 +                                        progname, c_mkpmap);
679 +                        if (pgmapname != NULL && pgmapdate < oct1date)
680 +                                unlink(pgmapname);
681 +                        if (pcmapname != NULL && pcmapdate < oct1date)
682 +                                unlink(pcmapname);
683 +                        quit(1);
684 +                }
685 +        }
686 +        tnow = time((time_t *)NULL);
687 +        if (pgmapname != NULL)
688 +                pgmapdate = tnow;
689 +        if (pcmapname != NULL)
690 +                pcmapdate = tnow;
691 +        oct1date = tnow;        /* trigger ambient file removal if needed */
692 + }
693 +
694 +
695   static char *
696   addarg(                         /* append argument and advance pointer */
697 < register char   *op,
698 < register char   *arg
697 > char    *op,
698 > char    *arg
699   )
700   {
701          while (*op)
# Line 601 | Line 709 | register char  *arg
709  
710   static void
711   oconvopts(                              /* get oconv options */
712 <        register char   *oo
712 >        char    *oo
713   )
714   {
715          /* BEWARE:  This may be called via setdefaults(), so no assumptions */
716  
717          *oo = '\0';
718 <        if (vdef(OCONV))
719 <                if (vval(OCONV)[0] != '-') {
720 <                        atos(c_oconv, sizeof(c_oconv), vval(OCONV));
721 <                        oo = addarg(oo, sskip2(vval(OCONV), 1));
722 <                } else
723 <                        oo = addarg(oo, vval(OCONV));
718 >        if (!vdef(OCONV))
719 >                return;
720 >        if (vval(OCONV)[0] != '-') {
721 >                atos(c_oconv, sizeof(c_oconv), vval(OCONV));
722 >                oo = addarg(oo, sskip2(vval(OCONV), 1));
723 >        } else
724 >                oo = addarg(oo, vval(OCONV));
725   }
726  
727  
# Line 627 | Line 736 | mkillumopts(                           /* get mkillum options */
736                  sprintf(mo, " -n %d", nprocs);
737          else
738                  *mo = '\0';
739 <        if (vdef(MKILLUM))
740 <                if (vval(MKILLUM)[0] != '-') {
741 <                        atos(c_mkillum, sizeof(c_mkillum), vval(MKILLUM));
742 <                        mo = addarg(mo, sskip2(vval(MKILLUM), 1));
743 <                } else
744 <                        mo = addarg(mo, vval(MKILLUM));
739 >        if (!vdef(MKILLUM))
740 >                return;
741 >        if (vval(MKILLUM)[0] != '-') {
742 >                atos(c_mkillum, sizeof(c_mkillum), vval(MKILLUM));
743 >                mo = addarg(mo, sskip2(vval(MKILLUM), 1));
744 >        } else
745 >                mo = addarg(mo, vval(MKILLUM));
746   }
747  
748  
749   static void
750 + mkpmapopts(                             /* get mkpmap options */
751 +        char    *mo
752 + )
753 + {
754 +        /* BEWARE:  This may be called via setdefaults(), so no assumptions */
755 +
756 +        *mo = '\0';
757 +        if (!vdef(MKPMAP))
758 +                return;
759 +        if (vval(MKPMAP)[0] != '-') {
760 +                atos(c_mkpmap, sizeof(c_mkpmap), vval(MKPMAP));
761 +                mo = addarg(mo, sskip2(vval(MKPMAP), 1));
762 +        } else
763 +                mo = addarg(mo, vval(MKPMAP));
764 + }
765 +
766 +
767 + static void
768   checkambfile(void)                      /* check date on ambient file */
769   {
770          time_t  afdate;
# Line 677 | Line 805 | renderopts(                    /* set rendering options */
805          char    *po
806   )
807   {
808 +        char    pmapf[256], *bw;
809 +
810          switch(vscale(QUALITY)) {
811          case LOW:
812                  lowqopts(op, po);
# Line 688 | Line 818 | renderopts(                    /* set rendering options */
818                  hiqopts(op, po);
819                  break;
820          }
821 +        if (vdef(PGMAP)) {
822 +                bw = sskip2(vval(PGMAP), 2);
823 +                atos(pmapf, sizeof(pmapf), vval(PGMAP));
824 +                op = addarg(addarg(op, "-ap"), pmapf);
825 +                if (atoi(bw) > 0) op = addarg(op, bw);
826 +        }
827 +        if (vdef(PCMAP)) {
828 +                bw = sskip2(vval(PCMAP), 2);
829 +                atos(pmapf, sizeof(pmapf), vval(PCMAP));
830 +                op = addarg(addarg(op, "-ap"), pmapf);
831 +                if (atoi(bw) > 0) op = addarg(op, bw);
832 +        }
833          if (vdef(RENDER))
834                  op = addarg(op, vval(RENDER));
835          if (rvdevice != NULL) {
# Line 710 | Line 852 | renderopts(                    /* set rendering options */
852  
853   static void
854   lowqopts(                       /* low quality rendering options */
855 <        register char   *op,
855 >        char    *op,
856          char    *po
857   )
858   {
# Line 778 | Line 920 | lowqopts(                      /* low quality rendering options */
920  
921   static void
922   medqopts(                       /* medium quality rendering options */
923 <        register char   *op,
923 >        char    *op,
924          char    *po
925   )
926   {
# Line 856 | Line 998 | medqopts(                      /* medium quality rendering options */
998  
999   static void
1000   hiqopts(                                /* high quality rendering options */
1001 <        register char   *op,
1001 >        char    *op,
1002          char    *po
1003   )
1004   {
# Line 930 | Line 1072 | hiqopts(                               /* high quality rendering options */
1072   }
1073  
1074  
1075 + #ifdef _WIN32
1076   static void
1077 + setenv(                 /* set an environment variable */
1078 +        char    *vname,
1079 +        char    *value
1080 + )
1081 + {
1082 +        char    *evp;
1083 +
1084 +        evp = bmalloc(strlen(vname)+strlen(value)+2);
1085 +        if (evp == NULL)
1086 +                syserr(progname);
1087 +        sprintf(evp, "%s=%s", vname, value);
1088 +        if (putenv(evp) != 0) {
1089 +                fprintf(stderr, "%s: out of environment space\n", progname);
1090 +                quit(1);
1091 +        }
1092 +        if (!silent)
1093 +                printf("set %s\n", evp);
1094 + }
1095 + #endif
1096 +
1097 +
1098 + static void
1099   xferopts(                               /* transfer options if indicated */
1100          char    *ro
1101   )
1102   {
1103          int     fd, n;
1104 <        register char   *cp;
1104 >        char    *cp;
1105          
1106          n = strlen(ro);
1107          if (n < 2)
# Line 965 | Line 1130 | xferopts(                              /* transfer options if indicated */
1130  
1131   static void
1132   pfiltopts(                              /* get pfilt options */
1133 <        register char   *po
1133 >        char    *po
1134   )
1135   {
1136          *po = '\0';
# Line 992 | Line 1157 | pfiltopts(                             /* get pfilt options */
1157  
1158   static int
1159   matchword(                      /* match white-delimited words */
1160 <        register char   *s1,
1161 <        register char   *s2
1160 >        char    *s1,
1161 >        char    *s2
1162   )
1163   {
1164          while (isspace(*s1)) s1++;
# Line 1007 | Line 1172 | matchword(                     /* match white-delimited words */
1172  
1173   static char *
1174   specview(                               /* get proper view spec from vs */
1175 <        register char   *vs
1175 >        char    *vs
1176   )
1177   {
1178          static char     vup[7][12] = {"-vu 0 0 -1","-vu 0 -1 0","-vu -1 0 0",
1179                          "-vu 0 0 1", "-vu 1 0 0","-vu 0 1 0","-vu 0 0 1"};
1180          static char     viewopts[128];
1181 <        register char   *cp;
1181 >        char    *cp;
1182          int     xpos, ypos, zpos, viewtype, upax;
1183 <        register int    i;
1183 >        int     i;
1184          double  cent[3], dim[3], mult, d;
1185  
1186          if (vs == NULL || *vs == '-')
# Line 1075 | Line 1240 | specview(                              /* get proper view spec from vs */
1240                          cent[i] += .5*dim[i];
1241                  }
1242                  mult = vlet(ZONE)=='E' ? 2. : .45 ;
1243 <                sprintf(cp, " -vp %.2g %.2g %.2g -vd %.2g %.2g %.2g",
1243 >                sprintf(cp, " -vp %.3g %.3g %.3g -vd %.3g %.3g %.3g",
1244                                  cent[0]+xpos*mult*dim[0],
1245                                  cent[1]+ypos*mult*dim[1],
1246                                  cent[2]+zpos*mult*dim[2],
# Line 1107 | Line 1272 | specview(                              /* get proper view spec from vs */
1272                          break;
1273                  case VT_PAR:
1274                          d = sqrt(dim[0]*dim[0]+dim[1]*dim[1]+dim[2]*dim[2]);
1275 <                        sprintf(cp, " -vh %.2g -vv %.2g", d, d);
1275 >                        sprintf(cp, " -vh %.3g -vv %.3g", d, d);
1276                          cp += strlen(cp);
1277                          break;
1278                  case VT_ANG:
# Line 1147 | Line 1312 | getview(                               /* get view n, or NULL if none */
1312          char    *vn             /* returned view name */
1313   )
1314   {
1315 <        register char   *mv;
1315 >        char    *mv;
1316  
1317          if (viewselect != NULL) {               /* command-line selected */
1318                  if (n)                          /* only do one */
# Line 1179 | Line 1344 | numview:
1344          mv = nvalue(VIEWS, n);          /* use view n */
1345          if ((vn != NULL) & (mv != NULL))
1346                  if (*mv != '-') {
1347 <                        register char   *mv2 = mv;
1347 >                        char    *mv2 = mv;
1348                          while (*mv2 && !isspace(*mv2))
1349                                  *vn++ = *mv2++;
1350                          *vn = '\0';
# Line 1192 | Line 1357 | numview:
1357  
1358   static int
1359   myprintview(                    /* print out selected view */
1360 <        register char   *vopts,
1360 >        char    *vopts,
1361          FILE    *fp
1362   )
1363   {
1364          VIEW    vwr;
1365          char    buf[128];
1366 <        register char   *cp;
1366 >        char    *cp;
1367   #ifdef _WIN32
1368   /* XXX Should we allow something like this for all platforms? */
1369   /* XXX Or is it still required at all? */
# Line 1254 | Line 1419 | rvu(                           /* run rvu with first view */
1419   }
1420  
1421  
1422 + static int
1423 + syncf_done(                     /* check if an rpiece sync file is complete */
1424 +        char *sfname
1425 + )
1426 + {
1427 +        FILE    *fp = fopen(sfname, "r");
1428 +        int     todo = 1;
1429 +        int     x, y;
1430 +
1431 +        if (fp == NULL)
1432 +                return(0);
1433 +        if (fscanf(fp, "%d %d", &x, &y) != 2)
1434 +                goto checked;
1435 +        todo = x*y;             /* total number of tiles */
1436 +        if (fscanf(fp, "%d %d", &x, &y) != 2 || (x != 0) | (y != 0))
1437 +                goto checked;
1438 +                                /* XXX assume no redundant tiles */
1439 +        while (fscanf(fp, "%d %d", &x, &y) == 2)
1440 +                if (!--todo)
1441 +                        break;
1442 + checked:
1443 +        fclose(fp);
1444 +        return(!todo);
1445 + }
1446 +
1447 +
1448   static void
1449   rpict(                          /* run rpict and pfilt for each view */
1450          char    *opts,
# Line 1361 | Line 1552 | rpict(                         /* run rpict and pfilt for each view */
1552                                  int     xdiv = 8+nprocs/3, ydiv = 8+nprocs/3;
1553                                  if (rfdt >= oct1date) {
1554                                          fprintf(stderr,
1555 <                "%s: partial output not created with rpiece\n", rawfile);
1555 >                "%s: partial output not created with %s\n", rawfile, c_rpiece);
1556                                          quit(1);
1557                                  }
1558                                  if (rfdt) {     /* start fresh */
# Line 1450 | Line 1641 | rpict(                         /* run rpict and pfilt for each view */
1641                  if (do_rpiece) {                /* need to finish raw, first */
1642                          finish_process();
1643                          wait_process(1);
1644 <                        /* XXX should check sync file to see if really done? */
1644 >                        if (!syncf_done(sfile)) {
1645 >                                fprintf(stderr,
1646 >                        "%s: %s did not complete rendering of view %s\n",
1647 >                                                progname, c_rpiece, vs);
1648 >                                quit(1);
1649 >                        }
1650                  }
1651                  if (!vdef(RAWFILE) || strcmp(vval(RAWFILE),vval(PICTURE))) {
1652                                                  /* build pfilt command */
# Line 1647 | Line 1843 | finish_process(void)                   /* exit a child process */
1843                  return;                 /* in parent -- noop */
1844          exit(0);
1845   }
1650
1651 #ifdef _WIN32
1652 setenv(vname, value)            /* set an environment variable */
1653 char    *vname, *value;
1654 {
1655        register char   *evp;
1656
1657        evp = bmalloc(strlen(vname)+strlen(value)+2);
1658        if (evp == NULL)
1659                syserr(progname);
1660        sprintf(evp, "%s=%s", vname, value);
1661        if (putenv(evp) != 0) {
1662                fprintf(stderr, "%s: out of environment space\n", progname);
1663                quit(1);
1664        }
1665        if (!silent)
1666                printf("set %s\n", evp);
1667 }
1668 #endif
1846  
1847  
1848   static void

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines