Back to index

radiance  4R0+20100331
Defines | Functions | Variables
readfargs.c File Reference
#include "copyright.h"
#include "standard.h"
#include "object.h"

Go to the source code of this file.

Defines

#define getstr(s)   (fgetword(s,sizeof(s),fp)!=NULL)
#define getint(s)   (getstr(s) && isint(s))
#define getflt(s)   (getstr(s) && isflt(s))

Functions

int readfargs (FUNARGS *fa, FILE *fp)
void freefargs (FUNARGS *fa)

Variables

static const char RCSid [] = "$Id: readfargs.c,v 2.10 2003/07/27 22:12:01 schorsch Exp $"

Define Documentation

#define getflt (   s)    (getstr(s) && isflt(s))
#define getint (   s)    (getstr(s) && isint(s))
#define getstr (   s)    (fgetword(s,sizeof(s),fp)!=NULL)

Function Documentation

void freefargs ( FUNARGS fa)

Definition at line 79 of file readfargs.c.

{
       register int  i;

       if (fa->nsargs) {
              for (i = 0; i < fa->nsargs; i++)
                     freestr(fa->sarg[i]);
              free((void *)fa->sarg);
              fa->sarg = NULL;
              fa->nsargs = 0;
       }
#ifdef  IARGS
       if (fa->niargs) {
              free((void *)fa->iarg);
              fa->iarg = NULL;
              fa->niargs = 0;
       }
#endif
       if (fa->nfargs) {
              free((void *)fa->farg);
              fa->farg = NULL;
              fa->nfargs = 0;
       }
}

Here is the call graph for this function:

Here is the caller graph for this function:

int readfargs ( FUNARGS fa,
FILE *  fp 
)

Definition at line 17 of file readfargs.c.

{
#define getstr(s)    (fgetword(s,sizeof(s),fp)!=NULL)
#define getint(s)    (getstr(s) && isint(s))
#define getflt(s)    (getstr(s) && isflt(s))
       char  sbuf[MAXSTR];
       register int  n, i;

       if (!getint(sbuf) || (n = atoi(sbuf)) < 0)
              return(0);
       if ( (fa->nsargs = n) ) {
              fa->sarg = (char **)malloc(n*sizeof(char *));
              if (fa->sarg == NULL)
                     return(-1);
              for (i = 0; i < fa->nsargs; i++) {
                     if (!getstr(sbuf))
                            return(0);
                     fa->sarg[i] = savestr(sbuf);
              }
       } else
              fa->sarg = NULL;
       if (!getint(sbuf) || (n = atoi(sbuf)) < 0)
              return(0);
#ifdef  IARGS
       if (fa->niargs = n) {
              fa->iarg = (long *)malloc(n*sizeof(long));
              if (fa->iarg == NULL)
                     return(-1);
              for (i = 0; i < n; i++) {
                     if (!getint(sbuf))
                            return(0);
                     fa->iarg[i] = atol(sbuf);
              }
       } else
              fa->iarg = NULL;
#else
       if (n != 0)
              return(0);
#endif
       if (!getint(sbuf) || (n = atoi(sbuf)) < 0)
              return(0);
       if ( (fa->nfargs = n) ) {
              fa->farg = (RREAL *)malloc(n*sizeof(RREAL));
              if (fa->farg == NULL)
                     return(-1);
              for (i = 0; i < n; i++) {
                     if (!getflt(sbuf))
                            return(0);
                     fa->farg[i] = atof(sbuf);
              }
       } else
              fa->farg = NULL;
       return(1);
#undef getflt
#undef getint
#undef getstr
}

Here is the call graph for this function:

Here is the caller graph for this function:


Variable Documentation

const char RCSid[] = "$Id: readfargs.c,v 2.10 2003/07/27 22:12:01 schorsch Exp $" [static]

Definition at line 2 of file readfargs.c.