home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Fresh Fish 10
/
Fresh_Fish_10_2352.bin
/
new
/
dev
/
lang
/
sgmls
/
src
/
sgmlxtrn.c
< prev
next >
Wrap
C/C++ Source or Header
|
1994-07-10
|
12KB
|
226 lines
/* Standard Generalized Markup Language Users' Group (SGMLUG)
SGML Parser Materials (ARCSGML 1.0)
(C) 1983-1988 Charles F. Goldfarb (assigned to IBM Corporation)
(C) 1988-1991 IBM Corporation
Licensed to the SGML Users' Group for distribution under the terms of
the following license: */
char license[] =
"SGMLUG hereby grants to any user: (1) an irrevocable royalty-free,\n\
worldwide, non-exclusive license to use, execute, reproduce, display,\n\
perform and distribute copies of, and to prepare derivative works\n\
based upon these materials; and (2) the right to authorize others to\n\
do any of the foregoing.\n";
#include "sgmlincl.h"
/* SGMLXTRN: Storage allocation and initialization for all public variables.
Exceptions: Constants lex????? and del????? are defined in
LEX?????.C modules; constants pcb????? are defined in PCB?????.c.
*/
int badresw = 0; /* 1=REF_ out of context; 0=valid. */
int charmode = 0; /* >0=in #CHARS; 0=not. */
int conactsw = 0; /* 1=return saved content action 0=get new one.*/
int conrefsw = 0; /* 1=content reference att specified; 0=no. */
int contersv = 0; /* Save contersw while processing pending REF. */
int contersw = 0; /* 1=element or #CHARS out of context; 0=valid. */
int datarc = 0; /* Return code for data: DAF_ or REF_. */
int delmscsw = 0; /* 1=DELMSC must be read on return to es==0. */
int didreq = 0; /* 1=required implied tag processed; 0=no. */
int docelsw = 0; /* 1=had document element; 0=no */
int dostag = 0; /* 1=retry newetd instead of parsing; 0=parse. */
int dtdsw = 0; /* DOCTYPE declaration found: 1=yes; 0=no. */
int entdatsw = 0; /* 2=CDATA entity; 4=SDATA; 8=NDATA; 0=none. */
int entpisw = 0; /* 4=PI entity occurred; 0=not. */
int eodsw = 0; /* 1=eod found in error; 0=not yet. */
int eofsw = 0; /* 1=eof found in body of document; 0=not yet. */
int es = -1; /* Index of current source in stack. */
int etagimct = 0; /* Implicitly ended elements left on stack. */
int etagimsw = 0; /* 1=end-tag implied by other end-tag; 0=not. */
int etagmin = MINNONE; /* Minim: NONE NULL NET DATA; implied by S/ETAG*/
int etictr = 0; /* Number of "NET enabled" tags on stack. */
int etisw = 0; /* 1=tag ended with eti; 0=did not. */
int indtdsw = 0; /* Are we in the DTD? 1=yes; 0=no. */
int mslevel = 0; /* Nesting level of marked sections. */
int msplevel = 0; /* Nested MS levels subject to special parse. */
int prologsw = 1; /* 1=in prolog; 0=not. */
int pss = 0; /* SGMLACT: scbsgml stack level. */
int sgmlsw = 0; /* SGML declaration found: 1=yes; 0=no. */
int stagmin = MINNONE; /* Minimization: NONE, NULL tag, implied by STAG*/
int tagctr = 0; /* Tag source chars read. */
int tages = -1; /* ES level at start of tag. */
int ts = -1; /* Index of current tag in stack. */
struct parse *propcb = &pcbpro; /* Current PCB for prolog parse. */
int aentctr = 0; /* Number of ENTITY tokens in this att list. */
int conact = 0; /* Return code from content parse. */
int conrefsv = 0; /* Save conrefsw when doing implied start-tag.*/
int dtdrefsw = 0; /* External DTD? 1=yes; 0=no. */
int etiswsv = 0; /* Save etisw when processing implied start-tag.*/
int grplvl = 0; /* Current level of nested grps in model. */
int idrctr = 0; /* Number of IDREF tokens in this att list. */
int mdessv = 0; /* ES level at start of markup declaration. */
int notadn = 0; /* Position of NOTATION attribute in list. */
int parmno = 0; /* Current markup declaration parameter number. */
int pexsw = 0; /* 1=tag valid solely because of plus exception.*/
int rcessv = 0; /* ES level at start of RCDATA content. */
int tagdelsw = 0; /* 1=tag ended with delimiter; 0=no delimiter. */
int tokencnt = 0; /* Number of tokens found in attribute value. */
struct entity *ecbdeflt = 0; /* #DEFAULT ecb (NULL if no default entity). */
struct etd *docetd = 0; /* The etd for the document as a whole. */
struct etd *etagreal = 0; /* Actual or dummy etd that implied this tag. */
struct etd *newetd = 0; /* The etd for a start- or end-tag recognized. */
struct etd *nextetd = 0; /* ETD that must come next (only one choice). */
struct etd *lastetd = 0; /* most recently ended ETD. */
struct etd *stagreal = 0; /* Actual or dummy etd that implied this tag. */
struct parse *conpcb = 0; /* Current PCB for content parse. */
UNCH *data = 0; /* Pointer to returned data in buffer. */
UNCH *mdname = 0; /* Name of current markup declaration. */
UNCH *ptcon = 0; /* Current pointer into tbuf. */
UNCH *ptpro = 0; /* Current pointer into tbuf. */
UNCH *rbufs = 0; /* DOS file read area: start position for read. */
UNCH *subdcl = 0; /* Subject of markup declaration (e.g., GI). */
UNS conradn = 0; /* 1=CONREF attribute in list (0=no). */
UNS datalen = 0; /* Length of returned data in buffer. */
UNS entlen = 0; /* Length of TAG or EXTERNAL entity text. */
UNS idadn = 0; /* Number of ID attribute (0 if none). */
UNS noteadn = 0; /* Number of NOTATION attribute (0 if none). */
UNS reqadn = 0; /* Num of atts with REQUIRED default (0=none). */
int grplongs; /* Number of longs for GRPCNT bitvector. */
/* Variable arrays and structures.
*/
struct ad *al = 0; /* Current attribute list work area. */
struct dcncb *dcntab[1]; /* List of data content notation names. */
struct entity *etab[ENTHASH]; /* Entity hash table. */
struct etd *etdtab[ETDHASH]; /* Element type definition hash table. */
struct fpi fpidf; /* Fpi for #DEFAULT entity. */
struct id *itab[IDHASH]; /* Unique identifier hash table. */
struct etd **nmgrp = 0; /* Element name group */
PDCB *nnmgrp = 0; /* Notation name group */
struct restate *scbsgml = 0; /* SGMLACT: return action state stack. */
struct source *scbs = 0; /* Stack of open sources ("SCB stack"). */
struct srh *srhtab[1]; /* List of SHORTREF table headers. */
struct sgmlstat ds; /* Document statistics. */
struct switches sw; /* Parser control switches set by text proc. */
struct tag *tags = 0; /* Stack of open elements ("tag stack"). */
struct thdr *gbuf = 0; /* Buffer for creating group. */
struct thdr prcon[3]; /* 0-2: Model for *DOC content. */
struct thdr undechdr; /* 0:Default model hdr for undeclared content.*/
UNCH *dtype = 0; /* Document type name. */
UNCH *entbuf = 0; /* Buffer for entity reference name. */
UNCH fce[2]; /* String form of FCE char.
(fce[1] must be EOS).*/
/* Buffer for non-SGML character reference.*/
UNCH nonchbuf[2] = { DELNONCH };
UNCH *tbuf; /* Work area for tokenization. */
UNCH *lbuf = 0; /* In tbuf: Literal parse area.*/
UNCH *sysibuf = 0; /* Buffer for system identifiers. */
UNCH *pubibuf = 0; /* Buffer for public identifiers. */
UNCH *nmbuf = 0; /* Name buffer used by mdentity. */
struct mpos *savedpos;
/* Constants.
*/
struct map dctab[] = { /* Keywords for declared content parameter.*/
{ key[KRCDATA], MRCDATA+MPHRASE },
{ key[KCDATA], MCDATA+MPHRASE },
{ key[KANY], MANY+MCHARS+MGI },
{ key[KEMPTY], MNONE+MPHRASE },
{ NULL, 0 }
};
struct map deftab[] = { /* Default value keywords. */
{ key[KIMPLIED], DNULL },
{ key[KREQUIRED], DREQ },
{ key[KCURRENT], DCURR },
{ key[KCONREF],