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

Comparing ray/src/util/rfluxmtx.c (file contents):
Revision 2.10 by greg, Fri Jul 25 17:03:06 2014 UTC vs.
Revision 2.15 by greg, Fri Aug 15 19:59:56 2014 UTC

# Line 11 | Line 11 | static const char RCSid[] = "$Id$";
11   #include <stdlib.h>
12   #include "rtio.h"
13   #include "rtmath.h"
14 + #include "rtprocess.h"
15   #include "bsdf.h"
16   #include "bsdf_m.h"
17   #include "random.h"
# Line 144 | Line 145 | surf_type(const char *otype)
145   static char *
146   oconv_command(int ac, char *av[])
147   {
148 <        static char     oconvbuf[2048] = "!oconv -f";
149 <        char            *cp = oconvbuf + 9;
150 <
148 >        static char     oconvbuf[2048] = "!oconv -f ";
149 >        char            *cp = oconvbuf + 10;
150 >        char            *recv = *av++;
151 >        
152 >        if (ac-- <= 0)
153 >                return(NULL);
154          while (ac-- > 0) {
155 +                strcpy(cp, *av++);
156 +                while (*cp) cp++;
157 +                *cp++ = ' ';
158                  if (cp >= oconvbuf+(sizeof(oconvbuf)-32)) {
159                          fputs(progname, stderr);
160                          fputs(": too many file arguments!\n", stderr);
161                          exit(1);
162                  }
156                *cp++ = ' ';
157                strcpy(cp, *av++);
158                while (*cp) cp++;
163          }
164 <        *cp = '\0';
164 >        strcpy(cp, recv);       /* receiver goes last */
165          return(oconvbuf);
166   }
167  
# Line 315 | Line 319 | parse_params(PARAMS *p, char *pargs)
319          int     nparams = 0;
320          int     i;
321  
322 <        for ( ; ; )
322 >        for ( ; ; ) {
323                  switch (*cp++) {
324                  case 'h':
325                          if (*cp++ != '=')
# Line 338 | Line 342 | parse_params(PARAMS *p, char *pargs)
342                                  break;
343                          if (!get_direction(p->vup, cp))
344                                  break;
345 +                        while (*cp && !isspace(*cp++))
346 +                                ;
347                          ++nparams;
348                          continue;
349                  case 'o':
# Line 356 | Line 362 | parse_params(PARAMS *p, char *pargs)
362                  case ' ':
363                  case '\t':
364                  case '\r':
359                case '\n':
365                          continue;
366 +                case '\n':
367                  case '\0':
368                          return(nparams);
369                  default:
370                          break;
371                  }
372 <        fprintf(stderr, "%s: bad parameter string '%s'\n", progname, pargs);
372 >                break;
373 >        }
374 >        fprintf(stderr, "%s: bad parameter string: %s", progname, pargs);
375          exit(1);
376          return(-1);     /* pro forma return */
377   }
# Line 1174 | Line 1182 | main(int argc, char *argv[])
1182   {
1183          char    fmtopt[6] = "-faa";     /* default output is ASCII */
1184          char    *xrs=NULL, *yrs=NULL, *ldopt=NULL;
1185 <        int     wantIrradiance = 0;
1185 >        char    *iropt = NULL;
1186          char    *sendfn;
1187          char    sampcntbuf[32], nsbinbuf[32];
1188          FILE    *rcfp;
# Line 1182 | Line 1190 | main(int argc, char *argv[])
1190          int     a, i;
1191                                          /* screen rcontrib options */
1192          progname = argv[0];
1193 <        for (a = 1; a < argc-2 && argv[a][0] == '-'; a++) {
1194 <                int     na = 1;         /* !! Keep consistent !! */
1195 <                switch (argv[a][1]) {
1193 >        for (a = 1; a < argc-2; a++) {
1194 >                int     na;
1195 >                                        /* check for argument expansion */
1196 >                while ((na = expandarg(&argc, &argv, a)) > 0)
1197 >                        ;
1198 >                if (na < 0) {
1199 >                        fprintf(stderr, "%s: cannot expand '%s'\n",
1200 >                                        progname, argv[a]);
1201 >                        return(1);
1202 >                }
1203 >                if (argv[a][0] != '-' || !argv[a][1])
1204 >                        break;
1205 >                na = 1;
1206 >                switch (argv[a][1]) {   /* !! Keep consistent !! */
1207                  case 'v':               /* verbose mode */
1208                          verbose = !verbose;
1209                          na = 0;
# Line 1223 | Line 1242 | main(int argc, char *argv[])
1242                          na = 0;         /* we re-add this later */
1243                          continue;
1244                  case 'I':               /* only for pass-through mode */
1245 <                        wantIrradiance = 1;
1245 >                case 'i':
1246 >                        iropt = argv[a];
1247                          na = 0;
1248                          continue;
1249                  case 'V':               /* options without arguments */
1250                  case 'w':
1251                  case 'u':
1232                case 'i':
1252                  case 'h':
1253                  case 'r':
1254                          break;
# Line 1259 | Line 1278 | main(int argc, char *argv[])
1278                          if (!argv[a][2]) goto userr;
1279                          na = (argv[a][2] == 'e') | (argv[a][2] == 'a') ? 4 : 2;
1280                          break;
1262                case '\0':              /* pass-through mode */
1263                        goto done_opts;
1281                  default:                /* anything else is verbotten */
1282                          goto userr;
1283                  }
# Line 1270 | Line 1287 | main(int argc, char *argv[])
1287                  while (--na)            /* + arguments if any */
1288                          rcarg[nrcargs++] = argv[++a];
1289          }
1273 done_opts:
1290          if (a > argc-2)
1291                  goto userr;             /* check at end of options */
1292          sendfn = argv[a++];             /* assign sender & receiver inputs */
1293          if (sendfn[0] == '-') {         /* user wants pass-through mode? */
1294                  if (sendfn[1]) goto userr;
1295                  sendfn = NULL;
1296 <                if (wantIrradiance) {
1296 >                if (iropt) {
1297                          CHECKARGC(1);
1298 <                        rcarg[nrcargs++] = "-I";
1298 >                        rcarg[nrcargs++] = iropt;
1299                  }
1300                  if (xrs) {
1301                          CHECKARGC(2);
# Line 1297 | Line 1313 | done_opts:
1313                  }
1314                  if (sampcnt <= 0) sampcnt = 1;
1315          } else {                        /* else in sampling mode */
1316 <                if (wantIrradiance) {
1316 >                if (iropt) {
1317                          fputs(progname, stderr);
1318 <                        fputs(": -I supported for pass-through only\n", stderr);
1318 >                        fputs(": -i, -I supported for pass-through only\n", stderr);
1319                          return(1);
1320                  }
1321                  fmtopt[2] = (sizeof(RREAL)==sizeof(double)) ? 'd' : 'f';
# Line 1352 | Line 1368 | done_opts:
1368   userr:
1369          if (a < argc-2)
1370                  fprintf(stderr, "%s: unsupported option '%s'", progname, argv[a]);
1371 <        fprintf(stderr, "Usage: %s [-v][rcontrib options] sender.rad receiver.rad [system.rad ..]\n",
1371 >        fprintf(stderr, "Usage: %s [-v][rcontrib options] sender.rad receiver.rad [-i system.oct] [system.rad ..]\n",
1372                                  progname);
1373          return(1);
1374   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines