Back to index

radiance  4R0+20100331
Functions | Variables
readobj2.c File Reference
#include <ctype.h>
#include <stdio.h>
#include "platform.h"
#include "rtprocess.h"
#include "rtmath.h"
#include "rtio.h"
#include "rterror.h"
#include "object.h"
#include "otypes.h"
#include "oconv.h"

Go to the source code of this file.

Functions

static void getobject2 (char *name, FILE *fp, ro_cbfunc f)
void readobj2 (char *input, ro_cbfunc callback)

Variables

static const char RCSid [] = "$Id: readobj2.c,v 2.10 2004/09/28 23:55:02 greg Exp $"

Function Documentation

static void getobject2 ( char *  name,
FILE *  fp,
ro_cbfunc  f 
) [static]

Definition at line 69 of file readobj2.c.

{
       char  sbuf[MAXSTR];
       OBJREC  thisobj;
                                   /* get modifier */
       fgetword(sbuf, MAXSTR, fp);
       thisobj.omod = OVOID;
                                   /* get type */
       fgetword(sbuf, MAXSTR, fp);
       if ((thisobj.otype = otype(sbuf)) < 0) {
              sprintf(errmsg, "(%s): unknown type \"%s\"", name, sbuf);
              error(USER, errmsg);
       }
                                   /* get identifier */
       fgetword(sbuf, MAXSTR, fp);
       thisobj.oname = sbuf;
                                   /* get arguments */
       if (thisobj.otype == MOD_ALIAS) {
              fscanf(fp, "%*s");
              return;
       }
       if (readfargs(&thisobj.oargs, fp) <= 0) {
              sprintf(errmsg, "(%s): bad arguments", name);
              objerror(&thisobj, USER, errmsg);
       }
       thisobj.os = NULL;
                                   /* call function */
       (*f)(&thisobj);
                                   /* free memory */
       freefargs(&thisobj.oargs);
       free_os(&thisobj);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void readobj2 ( char *  input,
ro_cbfunc  callback 
)

Definition at line 25 of file readobj2.c.

{
       char  *fgetline();
       FILE  *infp;
       char  buf[2048];
       register int  c;

       if (input == NULL) {
              infp = stdin;
              input = "standard input";
       } else if (input[0] == '!') {
              if ((infp = popen(input+1, "r")) == NULL) {
                     sprintf(errmsg, "cannot execute \"%s\"", input);
                     error(SYSTEM, errmsg);
              }
       } else if ((infp = fopen(input, "r")) == NULL) {
              sprintf(errmsg, "cannot open scene file \"%s\"", input);
              error(SYSTEM, errmsg);
       }
       while ((c = getc(infp)) != EOF) {
              if (isspace(c))
                     continue;
              if (c == '#') {                           /* comment */
                     fgets(buf, sizeof(buf), infp);
              } else if (c == '!') {                    /* command */
                     ungetc(c, infp);
                     fgetline(buf, sizeof(buf), infp);
                     readobj2(buf, callback);
              } else {                           /* object */
                     ungetc(c, infp);
                     getobject2(input, infp, callback);
              }
       }
       if (input[0] == '!')
              pclose(infp);
       else
              fclose(infp);
}

Here is the call graph for this function:

Here is the caller graph for this function:


Variable Documentation

const char RCSid[] = "$Id: readobj2.c,v 2.10 2004/09/28 23:55:02 greg Exp $" [static]

Definition at line 2 of file readobj2.c.