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

Comparing ray/src/cal/rcalc.c (file contents):
Revision 1.9 by greg, Wed Nov 5 19:03:03 2003 UTC vs.
Revision 1.11 by schorsch, Fri Nov 14 17:31:24 2003 UTC

# Line 8 | Line 8 | static const char RCSid[] = "$Id$";
8   */
9  
10   #include  <stdlib.h>
11 + #include  <fcntl.h>
12   #include  <stdio.h>
13   #include  <string.h>
14   #include  <math.h>
# Line 54 | Line 55 | struct field {                  /* record format struc
55   #define  savqstr(s)     strcpy(emalloc(strlen(s)+1),s)
56   #define  freqstr(s)     efree(s)
57  
58 + static int getinputrec(FILE *fp);
59   static void scaninp(void), advinp(void), resetinp(void);
60   static void putrec(void), putout(void), nbsynch(void);
61   static int getrec(void);
# Line 66 | Line 68 | static int getfield(struct field *f);
68   static void chanset(int n, double v);
69   static void bchanset(int n, double v);
70   static struct strvar* getsvar(char *svname);
71 + static double l_in(char *);
72  
73   struct field  *inpfmt = NULL;   /* input record format */
74   struct field  *outfmt = NULL;   /* output record structure */
# Line 109 | Line 112 | char  *argv[]
112          biggerlib();
113   #endif
114          varset("PI", ':', 3.14159265358979323846);
115 +        funset("in", 1, '=', &l_in);
116  
117          for (i = 1; i < argc && argv[i][0] == '-'; i++)
118                  switch (argv[i][1]) {
# Line 215 | Line 219 | eputs(" [-b][-l][-n][-w][-u][-tS][-s svar=sval][-e exp
219                          execute(argv[i]);
220          
221          quit(0);
222 +        return 0; /* pro forma return */
223   }
224  
225  
# Line 230 | Line 235 | nbsynch(void)               /* non-blank starting sync
235   }
236  
237  
238 < int
238 > static int
239   getinputrec(            /* get next input record */
240   FILE  *fp
241   )
# Line 297 | Line 302 | putout(void)                /* produce an output recor
302                  fflush(stdout);
303   }
304  
305 +
306 + static double
307 + l_in(char *funame)      /* function call for $channel */
308 + {
309 +        int  n;
310 +        register char  *cp;
311 +                        /* get argument as integer */
312 +        n = (int)(argument(1) + .5);
313 +        if (n != 0)     /* return channel value */
314 +                return(chanvalue(n));
315 +                        /* determine number of channels */
316 +        if (noinput || inpfmt != NULL)
317 +                return(0);
318 +        if (nbicols > 0)
319 +                return(nbicols);
320 +        if (nbicols < 0)
321 +                return(-nbicols);
322 +        cp = inpbuf;    /* need to count */
323 +        for (n = 0; *cp; )
324 +                if (blnkeq && isspace(sepchar)) {
325 +                        while (isspace(*cp))
326 +                                cp++;
327 +                        n += *cp != '\0';
328 +                        while (*cp && !isspace(*cp))
329 +                                cp++;
330 +                } else {
331 +                        n += *cp != '\n';
332 +                        while (*cp && *cp++ != sepchar)
333 +                                ;
334 +                }
335 +        return(n);
336 + }
337  
338   double
339   chanvalue(            /* return value for column n */

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines