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

Comparing ray/src/cv/ies2rad.c (file contents):
Revision 2.12 by greg, Tue Apr 25 21:37:14 1995 UTC vs.
Revision 2.13 by greg, Wed Jun 12 19:13:42 1996 UTC

# Line 1 | Line 1
1 < /* Copyright (c) 1992 Regents of the University of California */
1 > /* Copyright (c) 1996 Regents of the University of California */
2  
3   #ifndef lint
4   static char SCCSid[] = "$SunId$ LBL";
# Line 108 | Line 108 | float  defcolor[3] = {1.,1.,1.};       /* default lamp color
108   float   *lampcolor = defcolor;          /* pointer to current lamp color */
109   double  multiplier = 1.0;               /* multiplier for all light sources */
110   char    units[64] = "meters";           /* output units */
111 + int     out2stdout = 0;                 /* put out to stdout r.t. file */
112   int     instantiate = 0;                /* instantiate geometry */
113   double  illumrad = 0.0;                 /* radius for illum sphere */
114  
# Line 203 | Line 204 | char   *argv[];
204                  case 'f':               /* lamp data file */
205                          lampdat = argv[++i];
206                          break;
207 <                case 'o':               /* output file name */
207 >                case 'o':               /* output file root name */
208                          outfile = argv[++i];
209                          break;
210 +                case 's':               /* output to stdout */
211 +                        out2stdout = !out2stdout;
212 +                        break;
213                  case 'i':               /* illum */
214                          illumrad = atof(argv[++i]);
215                          break;
# Line 241 | Line 245 | char   *argv[];
245                          exit(ies2rad(NULL, outfile) == 0 ? 0 : 1);
246                  else if (i == argc-1)
247                          exit(ies2rad(argv[i], outfile) == 0 ? 0 : 1);
248 <                else {
249 <                        fprintf(stderr, "%s: single input file required\n",
246 <                                        argv[0]);
247 <                        exit(1);
248 <                }
248 >                else
249 >                        goto needsingle;
250          } else if (i >= argc) {
251                  fprintf(stderr, "%s: missing output file specification\n",
252                                  argv[0]);
253                  exit(1);
254          }
255 +        if (out2stdout && i != argc-1)
256 +                goto needsingle;
257          status = 0;
258          for ( ; i < argc; i++) {
259                  tailtrunc(strcpy(outname,filename(argv[i])));
# Line 258 | Line 261 | char   *argv[];
261                          status = 1;
262          }
263          exit(status);
264 + needsingle:
265 +        fprintf(stderr, "%s: single input file required\n", argv[0]);
266 +        exit(1);
267   }
268  
269  
# Line 464 | Line 470 | char   *inpname, *outname;
470                  perror(inpname);
471                  return(-1);
472          }
473 <        if ((outfp = fopen(fullname(buf,outname,T_RAD), "w")) == NULL) {
473 >        if (out2stdout)
474 >                outfp = stdout;
475 >        else if ((outfp = fopen(fullname(buf,outname,T_RAD), "w")) == NULL) {
476                  perror(buf);
477                  fclose(inpfp);
478                  return(-1);
# Line 1054 | Line 1062 | FILE   *outfp;                 /* close output file upon return */
1062                  fprintf(outfp, "0\n0\n");
1063                  fclose(outfp);
1064          } else {                        /* else append to luminaire file */
1057                fclose(outfp);
1065                  if (!FEQ(meters2out, 1.0)) {    /* apply scalefactor */
1066                          sprintf(cp, "| xform -s %f ", meters2out);
1067                          cp += strlen(cp);
1068                  }
1069 <                strcpy(cp, ">> ");              /* append works for DOS? */
1070 <                cp += 3;
1071 <                fullname(cp,outname,T_RAD);
1069 >                if (!out2stdout) {
1070 >                        fclose(outfp);
1071 >                        strcpy(cp, ">> ");      /* append works for DOS? */
1072 >                        cp += 3;
1073 >                        fullname(cp,outname,T_RAD);
1074 >                }
1075                  if (system(buf))
1076                          return(-1);
1077          }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines