void mg_init( void )
int mg_defuhand( int argc, char **argv )
extern int (*mg_ehand[MG_NENTITIES])( int argc, char **argv )
extern int (*mg_uhand)( int argc, char **argv )
extern unsigned mg_nunknown
#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 */ #define MG_NENTITIES 28 /* total # entities */
Once the mg_ehand array has been set by the program, the mg_init routine must be called to complete the initialization process. This should be done once and only once per invocation, before any other parser routines are called.
The mg_uhand variable points to the current handler for unknown entities encountered on the input. Its default value points to the mg_defuhand function, which simply increments the global variable mg_nunknown, printing a warning message on the standard error on the first offense. (This message may be avoided by incrementing mg_nunknown before processing begins.) If mg_uhand is assigned a value of NULL, then an unknown entity will return an MG_EUNK error, which will cause the parser to abort. (See the mg_load page for a list of errors.) If the mg_uhand pointer is assigned to another function, that function will receive any unknown entities and their arguments, and the parsing will abort if the new function returns a non-zero error value. This offers a convenient way to customize the language by adding non-standard entities.