--- ray/src/cv/mgflib/parser.h 1995/04/13 12:54:23 1.20 +++ ray/src/cv/mgflib/parser.h 1995/05/11 21:48:42 1.25 @@ -1,4 +1,4 @@ -/* Copyright (c) 1994 Regents of the University of California */ +/* Copyright (c) 1995 Regents of the University of California */ /* SCCSid "$SunId$ LBL" */ @@ -8,38 +8,44 @@ /* must include stdio.h before us */ - /* Entities (order doesn't really matter) */ -#define MG_E_COMMENT 0 -#define MG_E_COLOR 1 -#define MG_E_CCT 2 -#define MG_E_CONE 3 -#define MG_E_CMIX 4 -#define MG_E_CSPEC 5 -#define MG_E_CXY 6 -#define MG_E_CYL 7 -#define MG_E_ED 8 -#define MG_E_FACE 9 -#define MG_E_INCLUDE 10 -#define MG_E_IES 11 -#define MG_E_IR 12 -#define MG_E_MATERIAL 13 -#define MG_E_NORMAL 14 -#define MG_E_OBJECT 15 -#define MG_E_POINT 16 -#define MG_E_PRISM 17 -#define MG_E_RD 18 -#define MG_E_RING 19 -#define MG_E_RS 20 -#define MG_E_SIDES 21 -#define MG_E_SPH 22 -#define MG_E_TD 23 -#define MG_E_TORUS 24 -#define MG_E_TS 25 -#define MG_E_VERTEX 26 -#define MG_E_XF 27 +#define MG_VMAJOR 1 /* major version number */ +#define MG_VMINOR 0 /* minor version number */ -#define MG_NENTITIES 28 + /* Entities (list is only appended, never modified) */ +#define MG_E_COMMENT 0 /* # */ +#define MG_E_COLOR 1 /* c */ +#define MG_E_CCT 2 /* cct */ +#define MG_E_CONE 3 /* cone */ +#define MG_E_CMIX 4 /* cmix */ +#define MG_E_CSPEC 5 /* cspec */ +#define MG_E_CXY 6 /* cxy */ +#define MG_E_CYL 7 /* cyl */ +#define MG_E_ED 8 /* ed */ +#define MG_E_FACE 9 /* f */ +#define MG_E_INCLUDE 10 /* i */ +#define MG_E_IES 11 /* ies */ +#define MG_E_IR 12 /* ir */ +#define MG_E_MATERIAL 13 /* m */ +#define MG_E_NORMAL 14 /* n */ +#define MG_E_OBJECT 15 /* o */ +#define MG_E_POINT 16 /* p */ +#define MG_E_PRISM 17 /* prism */ +#define MG_E_RD 18 /* rd */ +#define MG_E_RING 19 /* ring */ +#define MG_E_RS 20 /* rs */ +#define MG_E_SIDES 21 /* sides */ +#define MG_E_SPH 22 /* sph */ +#define MG_E_TD 23 /* td */ +#define MG_E_TORUS 24 /* torus */ +#define MG_E_TS 25 /* ts */ +#define MG_E_VERTEX 26 /* v */ +#define MG_E_XF 27 /* xf */ + /* end of Version 1 entities */ +#define MG_NENTITIES 28 /* total # entities */ + +#define MG_NELIST {28} /* entity count for version 1 and up */ + #define MG_NAMELIST {"#","c","cct","cone","cmix","cspec","cxy","cyl","ed",\ "f","i","ies","ir","m","n","o","p","prism","rd",\ "ring","rs","sides","sph","td","torus","ts","v","xf"} @@ -48,14 +54,19 @@ extern char mg_ename[MG_NENTITIES][MG_MAXELEN]; - /* Handler routines for each entity */ - + /* Handler routines for each entity and unknown ones */ #ifdef NOPROTO extern int (*mg_ehand[MG_NENTITIES])(); +extern int (*mg_uhand)(); +extern int mg_defuhand(); #else extern int (*mg_ehand[MG_NENTITIES])(int argc, char **argv); +extern int (*mg_uhand)(int argc, char **argv); +extern int mg_defuhand(int, char **); #endif +extern unsigned mg_nunknown; /* count of unknown entities */ + /* Error codes */ #define MG_OK 0 /* normal return value */ #define MG_EUNK 1 /* unknown entity */ @@ -71,7 +82,7 @@ extern int (*mg_ehand[MG_NENTITIES])(int argc, char ** #define MG_NERRS 11 -extern char *mg_err[MG_NERRS]; +extern char *mg_err[MG_NERRS]; /* list of error messages */ /* * The general process for running the parser is to fill in the mg_ehand @@ -87,7 +98,7 @@ extern char *mg_err[MG_NERRS]; * (The first argument to mg_handle is the entity #, or -1.) * To free any data structures and clear the parser, use mg_clear. * If there is an error, mg_load, mg_open, mg_parse, mg_handle and - * mg_rewind will return an error from the list above. In addition, + * mg_fgoto will return an error from the list above. In addition, * mg_load will report the error to stderr. The mg_read routine * returns 0 when the end of file has been reached. */ @@ -150,10 +161,12 @@ extern int mg_nqcdivs; /* divisions per quarter circl extern int mg_entity(); /* get entity number from its name */ extern int isint(); /* non-zero if integer format */ extern int isflt(); /* non-zero if floating point format */ +extern int isname(); /* non-zero if legal identifier name */ #else extern int mg_entity(char *); /* get entity number from its name */ extern int isint(char *); /* non-zero if integer format */ extern int isflt(char *); /* non-zero if floating point format */ +extern int isname(char *); /* non-zero if legal identifier name */ #endif /************************************************************************ @@ -339,17 +352,21 @@ struct xf_array { typedef struct xf_spec { long xid; /* unique transform id */ - short xav0; /* zeroeth argument in xf_argv array */ - short xac; /* transform argument count */ + short xac; /* context argument count */ short rev; /* boolean true if vertices reversed */ XF xf; /* cumulative transformation */ struct xf_array *xarr; /* transformation array pointer */ struct xf_spec *prev; /* previous transformation context */ } XF_SPEC; /* followed by argument buffer */ -extern int xf_argc; /* total # transform args. */ -extern char **xf_argv; /* transform arguments */ -extern XF_SPEC *xf_context; /* current context */ +extern XF_SPEC *xf_context; /* current transform context */ +extern char **xf_argend; /* last transform argument */ + +#define xf_ac(xf) ((xf)->xac) +#define xf_av(xf) (xf_argend - (xf)->xac) + +#define xf_argc (xf_context==NULL ? 0 : xf_ac(xf_context)) +#define xf_argv xf_av(xf_context) /* * The transformation handler should do most of the work that needs