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.12 by schorsch, Sun Mar 28 20:33:12 2004 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>
15   #include  <ctype.h>
16  
17   #include  "platform.h"
17 #include  "calcomp.h"
18   #include  "rterror.h"
19 + #include  "rtmisc.h"
20 + #include  "rtio.h"
21 + #include  "calcomp.h"
22  
23   #define  isnum(c)       (isdigit(c) || (c)=='-' || (c)=='.' \
24                                  || (c)=='+' || (c)=='e' || (c)=='E')
# Line 54 | Line 57 | struct field {                  /* record format struc
57   #define  savqstr(s)     strcpy(emalloc(strlen(s)+1),s)
58   #define  freqstr(s)     efree(s)
59  
60 + static int getinputrec(FILE *fp);
61   static void scaninp(void), advinp(void), resetinp(void);
62   static void putrec(void), putout(void), nbsynch(void);
63   static int getrec(void);
# Line 66 | Line 70 | static int getfield(struct field *f);
70   static void chanset(int n, double v);
71   static void bchanset(int n, double v);
72   static struct strvar* getsvar(char *svname);
73 + static double l_in(char *);
74  
75   struct field  *inpfmt = NULL;   /* input record format */
76   struct field  *outfmt = NULL;   /* output record structure */
# Line 109 | Line 114 | char  *argv[]
114          biggerlib();
115   #endif
116          varset("PI", ':', 3.14159265358979323846);
117 +        funset("in", 1, '=', &l_in);
118  
119          for (i = 1; i < argc && argv[i][0] == '-'; i++)
120                  switch (argv[i][1]) {
# Line 215 | Line 221 | eputs(" [-b][-l][-n][-w][-u][-tS][-s svar=sval][-e exp
221                          execute(argv[i]);
222          
223          quit(0);
224 +        return 0; /* pro forma return */
225   }
226  
227  
# Line 230 | Line 237 | nbsynch(void)               /* non-blank starting sync
237   }
238  
239  
240 < int
240 > static int
241   getinputrec(            /* get next input record */
242   FILE  *fp
243   )
# Line 297 | Line 304 | putout(void)                /* produce an output recor
304                  fflush(stdout);
305   }
306  
307 +
308 + static double
309 + l_in(char *funame)      /* function call for $channel */
310 + {
311 +        int  n;
312 +        register char  *cp;
313 +                        /* get argument as integer */
314 +        n = (int)(argument(1) + .5);
315 +        if (n != 0)     /* return channel value */
316 +                return(chanvalue(n));
317 +                        /* determine number of channels */
318 +        if (noinput || inpfmt != NULL)
319 +                return(0);
320 +        if (nbicols > 0)
321 +                return(nbicols);
322 +        if (nbicols < 0)
323 +                return(-nbicols);
324 +        cp = inpbuf;    /* need to count */
325 +        for (n = 0; *cp; )
326 +                if (blnkeq && isspace(sepchar)) {
327 +                        while (isspace(*cp))
328 +                                cp++;
329 +                        n += *cp != '\0';
330 +                        while (*cp && !isspace(*cp))
331 +                                cp++;
332 +                } else {
333 +                        n += *cp != '\n';
334 +                        while (*cp && *cp++ != sepchar)
335 +                                ;
336 +                }
337 +        return(n);
338 + }
339  
340   double
341   chanvalue(            /* return value for column n */

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines