home *** CD-ROM | disk | FTP | other *** search
/ Fresh Fish 10 / Fresh_Fish_10_2352.bin / new / dev / lang / sgmls / src / sgmlxtrn.c < prev    next >
C/C++ Source or Header  |  1994-07-10  |  12KB  |  226 lines

  1. /*    Standard Generalized Markup Language Users' Group (SGMLUG)
  2.                  SGML Parser Materials (ARCSGML 1.0)
  3.  
  4. (C) 1983-1988 Charles F. Goldfarb (assigned to IBM Corporation)
  5. (C) 1988-1991 IBM Corporation
  6.  
  7. Licensed to the SGML Users' Group for distribution under the terms of
  8. the following license:                                                       */
  9.  
  10. char license[] =
  11. "SGMLUG hereby grants to any user: (1) an irrevocable royalty-free,\n\
  12. worldwide, non-exclusive license to use, execute, reproduce, display,\n\
  13. perform and distribute copies of, and to prepare derivative works\n\
  14. based upon these materials; and (2) the right to authorize others to\n\
  15. do any of the foregoing.\n";
  16.  
  17. #include "sgmlincl.h"
  18.  
  19. /* SGMLXTRN: Storage allocation and initialization for all public variables.
  20.              Exceptions: Constants lex????? and del????? are defined in
  21.              LEX?????.C modules; constants pcb????? are defined in PCB?????.c.
  22. */
  23. int badresw = 0;              /* 1=REF_ out of context; 0=valid. */
  24. int charmode = 0;             /* >0=in #CHARS; 0=not. */
  25. int conactsw = 0;             /* 1=return saved content action 0=get new one.*/
  26. int conrefsw = 0;             /* 1=content reference att specified; 0=no. */
  27. int contersv = 0;             /* Save contersw while processing pending REF. */
  28. int contersw = 0;             /* 1=element or #CHARS out of context; 0=valid. */
  29. int datarc = 0;               /* Return code for data: DAF_ or REF_. */
  30. int delmscsw = 0;             /* 1=DELMSC must be read on return to es==0. */
  31. int didreq = 0;               /* 1=required implied tag processed; 0=no. */
  32. int docelsw = 0;          /* 1=had document element; 0=no */
  33. int dostag = 0;               /* 1=retry newetd instead of parsing; 0=parse. */
  34. int dtdsw = 0;                /* DOCTYPE declaration found: 1=yes; 0=no. */
  35. int entdatsw = 0;             /* 2=CDATA entity; 4=SDATA; 8=NDATA; 0=none. */
  36. int entpisw = 0;              /* 4=PI entity occurred; 0=not. */
  37. int eodsw = 0;                /* 1=eod found in error; 0=not yet. */
  38. int eofsw = 0;                /* 1=eof found in body of document; 0=not yet. */
  39. int es = -1;                  /* Index of current source in stack. */
  40. int etagimct = 0;             /* Implicitly ended elements left on stack. */
  41. int etagimsw = 0;             /* 1=end-tag implied by other end-tag; 0=not. */
  42. int etagmin = MINNONE;        /* Minim: NONE NULL NET DATA; implied by S/ETAG*/
  43. int etictr = 0;               /* Number of "NET enabled" tags on stack. */
  44. int etisw = 0;                /* 1=tag ended with eti; 0=did not. */
  45. int indtdsw = 0;              /* Are we in the DTD? 1=yes; 0=no. */
  46. int mslevel = 0;              /* Nesting level of marked sections. */
  47. int msplevel = 0;             /* Nested MS levels subject to special parse. */
  48. int prologsw = 1;             /* 1=in prolog; 0=not. */
  49. int pss = 0;                  /* SGMLACT: scbsgml stack level. */
  50. int sgmlsw = 0;               /* SGML declaration found: 1=yes; 0=no. */
  51. int stagmin = MINNONE;        /* Minimization: NONE, NULL tag, implied by STAG*/
  52. int tagctr = 0;               /* Tag source chars read. */
  53. int tages = -1;              /* ES level at start of tag. */
  54. int ts = -1;                  /* Index of current tag in stack. */
  55. struct parse *propcb = &pcbpro; /* Current PCB for prolog parse. */
  56. int aentctr = 0;              /* Number of ENTITY tokens in this att list. */
  57. int conact = 0;               /* Return code from content parse. */
  58. int conrefsv = 0;             /* Save conrefsw when doing implied start-tag.*/
  59. int dtdrefsw = 0;             /* External DTD? 1=yes; 0=no. */
  60. int etiswsv = 0;              /* Save etisw when processing implied start-tag.*/
  61. int grplvl = 0;               /* Current level of nested grps in model. */
  62. int idrctr = 0;               /* Number of IDREF tokens in this att list. */
  63. int mdessv = 0;               /* ES level at start of markup declaration. */
  64. int notadn = 0;               /* Position of NOTATION attribute in list. */
  65. int parmno = 0;               /* Current markup declaration parameter number. */
  66. int pexsw = 0;                /* 1=tag valid solely because of plus exception.*/
  67. int rcessv = 0;               /* ES level at start of RCDATA content. */
  68. int tagdelsw = 0;             /* 1=tag ended with delimiter; 0=no delimiter. */
  69. int tokencnt = 0;             /* Number of tokens found in attribute value. */
  70. struct entity *ecbdeflt = 0;  /* #DEFAULT ecb (NULL if no default entity). */
  71. struct etd *docetd = 0;       /* The etd for the document as a whole. */
  72. struct etd *etagreal = 0;     /* Actual or dummy etd that implied this tag. */
  73. struct etd *newetd = 0;       /* The etd for a start- or end-tag recognized. */
  74. struct etd *nextetd = 0;      /* ETD that must come next (only one choice). */
  75. struct etd *lastetd = 0;      /* most recently ended ETD. */
  76. struct etd *stagreal = 0;     /* Actual or dummy etd that implied this tag. */
  77. struct parse *conpcb = 0;     /* Current PCB for content parse. */
  78. UNCH *data = 0;               /* Pointer to returned data in buffer. */
  79. UNCH *mdname = 0;             /* Name of current markup declaration. */
  80. UNCH *ptcon = 0;              /* Current pointer into tbuf. */
  81. UNCH *ptpro = 0;              /* Current pointer into tbuf. */
  82. UNCH *rbufs = 0;              /* DOS file read area: start position for read. */
  83. UNCH *subdcl = 0;             /* Subject of markup declaration (e.g., GI). */
  84. UNS conradn = 0;              /* 1=CONREF attribute in list (0=no). */
  85. UNS datalen = 0;              /* Length of returned data in buffer. */
  86. UNS entlen = 0;               /* Length of TAG or EXTERNAL entity text. */
  87. UNS idadn = 0;                /* Number of ID attribute (0 if none). */
  88. UNS noteadn = 0;              /* Number of NOTATION attribute (0 if none). */
  89. UNS reqadn = 0;               /* Num of atts with REQUIRED default (0=none). */
  90. int grplongs;              /* Number of longs for GRPCNT bitvector. */
  91.  
  92. /* Variable arrays and structures.
  93. */
  94. struct ad *al = 0;            /* Current attribute list work area. */
  95. struct dcncb *dcntab[1];      /* List of data content notation names. */
  96. struct entity *etab[ENTHASH]; /* Entity hash table. */
  97. struct etd *etdtab[ETDHASH];  /* Element type definition hash table. */
  98. struct fpi fpidf;             /* Fpi for #DEFAULT entity. */
  99. struct id *itab[IDHASH];      /* Unique identifier hash table. */
  100. struct etd **nmgrp = 0;          /* Element name group */
  101. PDCB *nnmgrp = 0;          /* Notation name group */
  102. struct restate *scbsgml = 0;  /* SGMLACT: return action state stack. */
  103. struct source *scbs = 0;      /* Stack of open sources ("SCB stack"). */
  104. struct srh *srhtab[1];        /* List of SHORTREF table headers. */
  105. struct sgmlstat ds;           /* Document statistics. */
  106. struct switches sw;           /* Parser control switches set by text proc. */
  107. struct tag *tags = 0;         /* Stack of open elements ("tag stack"). */
  108. struct thdr *gbuf = 0;        /* Buffer for creating group. */
  109. struct thdr prcon[3];         /* 0-2: Model for *DOC content. */
  110. struct thdr undechdr;         /* 0:Default model hdr for undeclared content.*/
  111. UNCH *dtype = 0;              /* Document type name. */
  112. UNCH *entbuf = 0;             /* Buffer for entity reference name. */
  113. UNCH fce[2];                  /* String form of FCE char.
  114.                                  (fce[1] must be EOS).*/
  115. /* Buffer for non-SGML character reference.*/
  116. UNCH nonchbuf[2] = { DELNONCH };
  117. UNCH *tbuf;              /* Work area for tokenization. */
  118. UNCH *lbuf = 0;              /* In tbuf: Literal parse area.*/
  119. UNCH *sysibuf = 0;          /* Buffer for system identifiers. */
  120. UNCH *pubibuf = 0;          /* Buffer for public identifiers. */
  121. UNCH *nmbuf = 0;          /* Name buffer used by mdentity. */
  122. struct mpos *savedpos;
  123.  
  124. /* Constants.
  125. */
  126. struct map dctab[] = {        /* Keywords for declared content parameter.*/
  127.      { key[KRCDATA],  MRCDATA+MPHRASE },
  128.      { key[KCDATA],   MCDATA+MPHRASE },
  129.      { key[KANY],     MANY+MCHARS+MGI },
  130.      { key[KEMPTY],   MNONE+MPHRASE },
  131.      { NULL,          0 }
  132. };
  133. struct map deftab[] = {       /* Default value keywords. */
  134.      { key[KIMPLIED],  DNULL },
  135.      { key[KREQUIRED], DREQ  },
  136.      { key[KCURRENT],  DCURR },
  137.      { key[KCONREF],