| 1 |
– |
/* Copyright (c) 1991 Regents of the University of California */ |
| 2 |
– |
|
| 1 |
|
#ifndef lint |
| 2 |
< |
static char SCCSid[] = "$SunId$ LBL"; |
| 2 |
> |
static const char RCSid[] = "$Id$"; |
| 3 |
|
#endif |
| 6 |
– |
|
| 4 |
|
/* |
| 5 |
|
* readobj2.c - routines for reading in object descriptions. |
| 6 |
|
*/ |
| 7 |
|
|
| 8 |
< |
#include "standard.h" |
| 8 |
> |
#include <ctype.h> |
| 9 |
> |
#include <stdio.h> |
| 10 |
|
|
| 11 |
+ |
#include "platform.h" |
| 12 |
+ |
#include "rtprocess.h" |
| 13 |
+ |
#include "rtmath.h" |
| 14 |
+ |
#include "rtio.h" |
| 15 |
+ |
#include "rterror.h" |
| 16 |
|
#include "object.h" |
| 14 |
– |
|
| 17 |
|
#include "otypes.h" |
| 18 |
|
|
| 17 |
– |
#include <ctype.h> |
| 19 |
|
|
| 20 |
< |
extern char *fgetword(); |
| 20 |
> |
static void getobject2(char *name, FILE *fp, int (*f)()); |
| 21 |
|
|
| 22 |
< |
OBJREC *objblock[MAXOBJBLK]; /* our objects */ |
| 22 |
< |
OBJECT nobjects = 0; /* # of objects */ |
| 23 |
< |
int newobject() {return(0);} |
| 24 |
< |
|
| 25 |
< |
|
| 26 |
< |
readobj(input, callback) /* read in an object file or stream */ |
| 22 |
> |
readobj2(input, callback) /* read in an object file or stream */ |
| 23 |
|
char *input; |
| 24 |
|
int (*callback)(); |
| 25 |
|
{ |
| 26 |
< |
FILE *popen(); |
| 31 |
< |
char *fgets(), *fgetline(); |
| 26 |
> |
char *fgetline(); |
| 27 |
|
FILE *infp; |
| 28 |
|
char buf[512]; |
| 29 |
|
register int c; |
| 48 |
|
} else if (c == '!') { /* command */ |
| 49 |
|
ungetc(c, infp); |
| 50 |
|
fgetline(buf, sizeof(buf), infp); |
| 51 |
< |
readobj(buf, callback); |
| 51 |
> |
readobj2(buf, callback); |
| 52 |
|
} else { /* object */ |
| 53 |
|
ungetc(c, infp); |
| 54 |
< |
getobject(input, infp, callback); |
| 54 |
> |
getobject2(input, infp, callback); |
| 55 |
|
} |
| 56 |
|
} |
| 57 |
|
if (input[0] == '!') |
| 61 |
|
} |
| 62 |
|
|
| 63 |
|
|
| 64 |
< |
getobject(name, fp, f) /* read the next object */ |
| 65 |
< |
char *name; |
| 66 |
< |
FILE *fp; |
| 67 |
< |
int (*f)(); |
| 64 |
> |
static void |
| 65 |
> |
getobject2( /* read the next object */ |
| 66 |
> |
char *name, |
| 67 |
> |
FILE *fp, |
| 68 |
> |
int (*f)() |
| 69 |
> |
) |
| 70 |
|
{ |
| 71 |
|
char sbuf[MAXSTR]; |
| 72 |
|
OBJREC thisobj; |
| 75 |
|
thisobj.omod = OVOID; |
| 76 |
|
/* get type */ |
| 77 |
|
fgetword(sbuf, MAXSTR, fp); |
| 78 |
< |
if (!strcmp(sbuf, ALIASID)) |
| 82 |
< |
thisobj.otype = -1; |
| 83 |
< |
else if ((thisobj.otype = otype(sbuf)) < 0) { |
| 78 |
> |
if ((thisobj.otype = otype(sbuf)) < 0) { |
| 79 |
|
sprintf(errmsg, "(%s): unknown type \"%s\"", name, sbuf); |
| 80 |
|
error(USER, errmsg); |
| 81 |
|
} |
| 83 |
|
fgetword(sbuf, MAXSTR, fp); |
| 84 |
|
thisobj.oname = sbuf; |
| 85 |
|
/* get arguments */ |
| 86 |
< |
if (thisobj.otype == -1) { |
| 86 |
> |
if (thisobj.otype == MOD_ALIAS) { |
| 87 |
|
fscanf(fp, "%*s"); |
| 88 |
|
return; |
| 89 |
|
} |
| 95 |
|
/* call function */ |
| 96 |
|
(*f)(&thisobj); |
| 97 |
|
/* free memory */ |
| 103 |
– |
if (thisobj.os != NULL) |
| 104 |
– |
switch (thisobj.otype) { |
| 105 |
– |
case OBJ_CONE: |
| 106 |
– |
case OBJ_CUP: |
| 107 |
– |
case OBJ_CYLINDER: |
| 108 |
– |
case OBJ_TUBE: |
| 109 |
– |
case OBJ_RING: |
| 110 |
– |
freecone(&thisobj); |
| 111 |
– |
break; |
| 112 |
– |
case OBJ_FACE: |
| 113 |
– |
freeface(&thisobj); |
| 114 |
– |
break; |
| 115 |
– |
case OBJ_INSTANCE: |
| 116 |
– |
freeinstance(&thisobj); |
| 117 |
– |
break; |
| 118 |
– |
} |
| 98 |
|
freefargs(&thisobj.oargs); |
| 99 |
+ |
free_os(&thisobj); |
| 100 |
|
} |