ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/Development/ray/src/rt/rmain.c
(Generate patch)

Comparing ray/src/rt/rmain.c (file contents):
Revision 1.9 by greg, Fri Jun 2 08:23:05 1989 UTC vs.
Revision 1.10 by greg, Sat Jun 3 10:37:55 1989 UTC

# Line 88 | Line 88 | main(argc, argv)
88   int  argc;
89   char  *argv[];
90   {
91 + #define  check(c,n)     if (argv[i][c] || n >= argc-i) goto badopt
92          double  atof();
93          char  *getenv();
94          int  report();
# Line 104 | Line 105 | char  *argv[];
105                                          /* get library path */
106          if ((libpath = getenv(ULIBVAR)) == NULL)
107                  libpath = DEFPATH;
108 <                                                /* option city */
108 >                                        /* option city */
109          for (i = 1; i < argc && argv[i][0] == '-'; i++) {
110                  if (!strcmp(argv[i], "-defaults")) {
111                          printdefaults();
# Line 124 | Line 125 | char  *argv[];
125                                  ourview.type = argv[i][3];
126                                  break;
127                          case 'p':                               /* point */
128 +                                check(3,3);
129                                  ourview.vp[0] = atof(argv[++i]);
130                                  ourview.vp[1] = atof(argv[++i]);
131                                  ourview.vp[2] = atof(argv[++i]);
132                                  break;
133                          case 'd':                               /* direction */
134 +                                check(3,3);
135                                  ourview.vdir[0] = atof(argv[++i]);
136                                  ourview.vdir[1] = atof(argv[++i]);
137                                  ourview.vdir[2] = atof(argv[++i]);
138                                  break;
139                          case 'u':                               /* up */
140 +                                check(3,3);
141                                  ourview.vup[0] = atof(argv[++i]);
142                                  ourview.vup[1] = atof(argv[++i]);
143                                  ourview.vup[2] = atof(argv[++i]);
144                                  break;
145                          case 'h':                               /* horizontal */
146 +                                check(3,1);
147                                  ourview.horiz = atof(argv[++i]);
148                                  break;
149                          case 'v':                               /* vertical */
150 +                                check(3,1);
151                                  ourview.vert = atof(argv[++i]);
152                                  break;
153                          case 'f':                               /* file */
154 +                                check(3,1);
155                                  rval = viewfile(argv[++i], &ourview);
156                                  if (rval < 0) {
157                                          sprintf(errmsg,
# Line 160 | Line 167 | char  *argv[];
167                                          gotvfile += rval;
168                                  break;
169                          default:
170 <                                goto unkopt;
170 >                                goto badopt;
171                          }
172                          break;
173   #endif
# Line 168 | Line 175 | char  *argv[];
175                          switch (argv[i][2]) {
176   #if  RPICT
177                          case 'p':                               /* pixel */
178 +                                check(3,1);
179                                  dstrpix = atof(argv[++i]);
180                                  break;
181   #endif
182                          case 's':                               /* source */
183 +                                check(3,1);
184                                  dstrsrc = atof(argv[++i]);
185                                  break;
186                          default:
187 <                                goto unkopt;
187 >                                goto badopt;
188                          }
189                          break;
190   #if  RPICT|RVIEW
191                  case 's':                               /* sample */
192                          switch (argv[i][2]) {
193                          case 'p':                               /* pixel */
194 +                                check(3,1);
195                                  psample = atoi(argv[++i]);
196                                  break;
197                          case 'd':                               /* difference */
198 +                                check(3,1);
199                                  maxdiff = atof(argv[++i]);
200                                  break;
201                          default:
202 <                                goto unkopt;
202 >                                goto badopt;
203                          }
204                          break;
205                  case 'x':                               /* x resolution */
206 +                        check(2,1);
207                          ourview.hresolu = atoi(argv[++i]);
208                          break;
209                  case 'y':                               /* y resolution */
210 +                        check(2,1);
211                          ourview.vresolu = atoi(argv[++i]);
212                          break;
213   #endif
214   #if  RTRACE
215                  case 'x':                               /* x resolution */
216 +                        check(2,1);
217                          hresolu = atoi(argv[++i]);
218                          break;
219                  case 'y':                               /* y resolution */
220 +                        check(2,1);
221                          vresolu = atoi(argv[++i]);
222                          break;
223   #endif
224                  case 'w':                               /* warnings */
225 +                        check(2,0);
226                          wrnvec = wrnvec==NULL ? stderr_v : NULL;
227                          break;
228                  case 'e':                               /* error file */
229 +                        check(2,1);
230                          errfile = argv[++i];
231                          break;
232                  case 'l':                               /* limit */
233                          switch (argv[i][2]) {
234                          case 'r':                               /* recursion */
235 +                                check(3,1);
236                                  maxdepth = atoi(argv[++i]);
237                                  break;
238                          case 'w':                               /* weight */
239 +                                check(3,1);
240                                  minweight = atof(argv[++i]);
241                                  break;
242                          default:
243 <                                goto unkopt;
243 >                                goto badopt;
244                          }
245                          break;
246   #if  RPICT
247                  case 'r':                               /* recover file */
248 +                        check(2,1);
249                          recover = argv[++i];
250                          rval = viewfile(recover, &ourview);
251                          if (rval <= 0) {
# Line 236 | Line 256 | char  *argv[];
256                                  gotvfile += rval;
257                          break;
258                  case 't':                               /* timer */
259 +                        check(2,1);
260                          ralrm = atoi(argv[++i]);
261                          break;
262   #endif
263                  case 'a':                               /* ambient */
264                          switch (argv[i][2]) {
265                          case 'v':                               /* value */
266 +                                check(3,3);
267                                  setcolor(ambval, atof(argv[i+1]),
268                                                  atof(argv[i+2]),
269                                                  atof(argv[i+3]));
270                                  i += 3;
271                                  break;
272                          case 'a':                               /* accuracy */
273 +                                check(3,1);
274                                  ambacc = atof(argv[++i]);
275                                  break;
276                          case 'r':                               /* resolution */
277 +                                check(3,1);
278                                  ambres = atoi(argv[++i]);
279                                  break;
280                          case 'd':                               /* divisions */
281 +                                check(3,1);
282                                  ambdiv = atoi(argv[++i]);
283                                  break;
284                          case 's':                               /* super-samp */
285 +                                check(3,1);
286                                  ambssamp = atoi(argv[++i]);
287                                  break;
288                          case 'b':                               /* bounces */
289 +                                check(3,1);
290                                  ambounce = atoi(argv[++i]);
291                                  break;
292                          case 'i':                               /* include */
293 +                                check(3,1);
294                                  if (ambincl != 1) {
295                                          ambincl = 1;
296                                          amblp = amblist;
# Line 270 | Line 298 | char  *argv[];
298                                  *amblp++ = argv[++i];
299                                  break;
300                          case 'e':                               /* exclude */
301 +                                check(3,1);
302                                  if (ambincl != 0) {
303                                          ambincl = 0;
304                                          amblp = amblist;
# Line 277 | Line 306 | char  *argv[];
306                                  *amblp++ = argv[++i];
307                                  break;
308                          case 'f':                               /* file */
309 +                                check(3,1);
310                                  ambfile= argv[++i];
311                                  break;
312                          default:
313 <                                goto unkopt;
313 >                                goto badopt;
314                          }
315                          break;
316   #if  RTRACE
# Line 292 | Line 322 | char  *argv[];
322                                  inform = argv[i][2];
323                                  break;
324                          default:
325 <                                goto unkopt;
325 >                                goto badopt;
326                          }
327                          switch (argv[i][3]) {
328                          case '\0':
# Line 304 | Line 334 | char  *argv[];
334                                  outform = argv[i][3];
335                                  break;
336                          default:
337 <                                goto unkopt;
337 >                                goto badopt;
338                          }
339                          break;
340                  case 'o':                               /* output */
341                          outvals = argv[i]+2;
342                          break;
343                  case 'h':                               /* toggle header */
344 +                        check(2,0);
345                          loadflags ^= IO_INFO;
346                          break;
347   #endif
348   #if  RVIEW
349                  case 'b':                               /* black and white */
350 +                        check(2,0);
351                          greyscale = !greyscale;
352                          break;
353                  case 'o':                               /* output device */
354 +                        check(2,1);
355                          devname = argv[++i];
356                          break;
357   #endif
358                  default:
359 < unkopt:
360 <                        sprintf(errmsg, "unknown option: '%s'", argv[i]);
359 > badopt:
360 >                        sprintf(errmsg, "bad option: '%s'", argv[i]);
361                          error(USER, errmsg);
362                          break;
363                  }
# Line 403 | Line 436 | unkopt:
436          rview();                        /* go */
437   #endif
438          quit(0);
439 + #undef  check
440   }
441  
442  

Diff Legend

Removed lines
+ Added lines
< Changed lines (old)
> Changed lines (new)