home *** CD-ROM | disk | FTP | other *** search
/ Internet Info 1994 March / Internet Info CD-ROM (Walnut Creek) (March 1994).iso / standards / sgml / nist / incs / dtd.h < prev    next >
Encoding:
C/C++ Source or Header  |  1990-09-13  |  13.2 KB  |  315 lines

  1. /* National Institute of Standards and Technology (NIST)
  2. /* National Computer System Laboratory (NCSL)
  3. /* Office Systems Engineering (OSE) Group
  4. /* ********************************************************************
  5. /*                            D I S C L A I M E R
  6. /*                              (March 8, 1989)
  7. /*  
  8. /* There is no warranty for the NIST NCSL OSE SGML parser and/or the NIST
  9. /* NCSL OSE SGML parser validation suite.  If the SGML parser and/or
  10. /* validation suite is modified by someone else and passed on, NIST wants
  11. /* the parser's recipients to know that what they have is not what NIST
  12. /* distributed, so that any problems introduced by others will not
  13. /* reflect on our reputation.
  14. /* 
  15. /* Policies
  16. /* 
  17. /* 1. Anyone may copy and distribute verbatim copies of the SGML source
  18. /* code as received in any medium.
  19. /* 
  20. /* 2. Anyone may modify your copy or copies of SGML parser source code or
  21. /* any portion of it, and copy and distribute such modifications provided
  22. /* that all modifications are clearly associated with the entity that
  23. /* performs the modifications.
  24. /* 
  25. /* NO WARRANTY
  26. /* ===========
  27. /* 
  28. /* NIST PROVIDES ABSOLUTELY NO WARRANTY.  THE SGML PARSER AND VALIDATION
  29. /* SUITE ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER
  30. /* EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  31. /* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  32. /* THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS
  33. /* WITH YOU.  SHOULD THE SGML PARSER OR VALIDATION SUITE PROVE DEFECTIVE,
  34. /* YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
  35. /* 
  36. /* IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW WILL NIST BE LIABLE FOR
  37. /* DAMAGES, INCLUDING ANY LOST PROFITS, LOST MONIES, OR OTHER SPECIAL,
  38. /* INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR
  39. /* INABILITY TO USE (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA
  40. /* BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY THIRD PARTIES OR A
  41. /* FAILURE OF THE PROGRAM TO OPERATE WITH PROGRAMS NOT DISTRIBUTED BY
  42. /* NIST) THE PROGRAM, EVEN IF YOU HAVE BEEN ADVISED OF THE POSSIBILITY OF
  43. /* SUCH DAMAGES, OR FOR ANY CLAIM BY ANY OTHER PARTY.
  44. */
  45.  
  46. /************************************************************************/
  47. /*   TITLE:          SGML PARSER                                        */
  48. /*   SYSTEM:         DTD PROCESSOR                                      */
  49. /*   SUBSYSTEM:                                                         */
  50. /*   SOURCE FILE:    DTD.H                                              */
  51. /*   AUTHOR:         Jim Heath                                          */
  52. /*                                                                      */
  53. /*   DATE CREATED:                                                      */
  54. /*   LAST MODIFIED:                                                     */
  55. /*                                                                      */
  56. /*                  REVISIONS                                           */
  57. /*   WHEN      WHO            WHY                                       */
  58. /************************************************************************/
  59. #define PERROR(x)    {perror(x); exit(1);}
  60. #define REGISTER register
  61. #define TREEFILE    (1 << 0) 
  62. #define SYMBFILE    (1 << 1)
  63. #define ATTRTEMP    (1 << 2)
  64. #define PREFFILE    (1 << 3)
  65. #define GREFFILE    (1 << 4)
  66. #define ATTRFILE    (1 << 5)
  67. #define DOCFILE        (1 << 6)
  68. #define XCPTFILE    (1 << 7)
  69. #define DTDFILE        (1 << 8)
  70. #define POSFILE     (1 << 9)
  71. #define INCLFILE    (1 << 10)
  72. #define EXCLFILE    (1 << 11)
  73. #define CMFILE      (1 << 12)
  74. #define ENTITYFILE  (1 << 13)
  75. /* ======================================================== */
  76. typedef char SGMLNAME [NAMELEN + 1];
  77. /* ======================================================== */
  78. #define NOTATIONFLAG     (1 << 0)
  79. #define CONREFFLAG      (1 << 1)
  80. /* ======================================================== */
  81. #define      IN_DECL            (1 << 0)
  82. #define      IN_ENTITY          (1 << 1)
  83. #define      DECL_IS_IN_ENTITY  (1 << 2)
  84.  
  85. #define      SETFLAG(x)         (specflag |= x)
  86. #define      TESTFLAG(x)        ((specflag & x) == x)
  87. #define      CLEARFLAG(x)       (specflag &= (~(x)))
  88. /* ======================================================== */
  89. #define      EOS                '\0'
  90. #define      DOCTYPELEN         9
  91. #define      FPRINTF(list)      fprintf list
  92. /* ======================================================== */
  93. #define INPNAME(ptr, len, xlat) inpitem (ptr, len, \
  94.                                          isnmstrt, isnmchar, xlat, NO)
  95. #define INPNBR(ptr, len, xlat) inpitem (ptr, len, \
  96.                                         ISDIGIT, ISDIGIT, xlat, NO)
  97. #define INPRNINAME(ptr, len, xlat) inpitem (ptr, len, \
  98.                                             isnmstrt, isnmchar, xlat, YES)
  99.  
  100. #define INPNMTOKEN(ptr, len, xlat) inpitem (ptr, len, \
  101.                                             isnmchar, isnmchar, xlat, NO)
  102. #define INPNUMTOKEN(ptr, len, xlat) inpitem (ptr, len, \
  103.                                             ISDIGIT, isnmchar, xlat, NO)
  104.  
  105. /* ======================================================== */
  106. /* defines representing the number of characters comprising */
  107. /* one pair of appropriate delimeters.                      */
  108. /* ======================================================== */
  109. #define STARTTAGSIZE   2   /* < > */
  110. #define ENDTAGSIZE     3   /* </ > */
  111. #define MSSIZE         6   /* <![ ]]> */
  112. #define MDSIZE         3   /* <! > */
  113. /* ======================================================== */
  114. /* defines to be used in inputing separator chracters.      */
  115. /* ======================================================== */
  116. #define PS             0
  117. #define TS             1    /* defines reprsenting separator types */
  118. #define DS             2
  119. #define INPPS() inpsep(PS) /* macro def for inputting PS's */
  120. #define INPDS() inpsep(DS) /* macro def for inputting DS's */
  121. /* ======================================================== */
  122.  
  123. #define CLRDECL()       dodecl(ON, NULL, (char *)NULL, (char **)NULL)
  124. #define ADDCHAR(c)      dodecl(OFF, c, (char *)NULL, (char **)NULL)
  125. #define ADDSTRING(ptr)  dodecl(OFF, NULL, ptr,(char **)NULL)
  126. #define GETDECLADDR(ptr) dodecl(OFF, NULL, (char *)NULL, ptr)
  127. /* ======================================================== */
  128. /* defines representing entity name types.                  */
  129. /* ======================================================== */
  130. #define PARM_ENT_NAME  0  /* parameter entity name type */
  131. #define GEN_ENT_NAME   1  /* general entity name type */
  132. /* ======================================================== */
  133. /* defines used in the processing of the document type      */
  134. /* definition.                                              */
  135. /* ======================================================== */
  136. typedef enum {KW_DOCTYPE = 200, KW_ELEMENT, KW_ENTITY, KW_RNIDEFAULT,
  137.               KW_ANY, KW_CDATA, KW_RCDATA, KW_SDATA, KW_PI, KW_EMPTY,
  138.               KW_STARTTAG, KW_ENDTAG, KW_MS, KW_MD, KW_ATTLIST,
  139.               KW_ID, KW_IDREF, KW_IDREFS, KW_NAME, KW_NAMES,
  140.               KW_NMTOKEN, KW_NMTOKENS, KW_NOTATION, KW_NUMBER,
  141.               KW_NUMBERS, KW_NUTOKEN, KW_NUTOKENS, KW_REQUIRED,
  142.               KW_CURRENT, KW_CONREF, KW_IMPLIED, KW_FIXED, KW_GROUP,
  143.               KW_LIT, KW_UNFIXED, KW_SYSTEM, KW_PUBLIC, KW_NDATA
  144.               } KEYWORDS;
  145. /* ======================================================== */
  146. /* define representing the largest length of a number used  */
  147. /* as a "character number" within a character reference.    */
  148. /* ======================================================== */
  149. #define MAX_CHAR_IN_DELIM_NUM  NAMELEN
  150. /* ======================================================== */
  151. #define      CMTRC              (1 << 1)
  152. #define      SIMPTRC            (1 << 2)
  153. #define      CONTEXTTRC         (1 << 3)
  154. #define      FILETRC            (1 << 4)
  155. #define      FUNCTRC            (1 << 5)
  156. #define      WAITFORCR          (1 << 6)
  157. #define      ALLOWSYNTXERRS     (1 << 7)
  158. /* ======================================================== */
  159.  
  160. #define      MAXELTS            256
  161. #define      ABORT(x)           syntxerr(x)
  162. #define      MAXDFLTLEN         512
  163. /* ======================================================== */
  164. #define     ERROR      -1
  165. #ifndef     NO
  166. #define     NO         0
  167. #endif
  168. #ifndef     YES
  169. #define     YES        1
  170. #endif
  171. #ifndef     FALSE
  172. #define     FALSE      0
  173. #endif
  174. #ifndef     TRUE
  175. #define     TRUE       1
  176. #endif
  177. #ifndef     NULL
  178. #define     NULL      '\0'
  179. #endif
  180.  
  181. #define     NONE       0
  182. #define     CTRLZ      0x1A
  183. #define     SPACE      ' '
  184. #define     RE         0x0D
  185. #define     RS         0x0A
  186. #define     TAB        0x09
  187. #define     OFF        0
  188. #define     ON         1
  189. #define     BAD        0
  190. #define     GOOD       1
  191. #define     MDC        '>'
  192. #define     GRPO       '('
  193. #define     GRPC       ')'
  194. #define     DSO        '['
  195. #define     DSC        ']'
  196. #define     PERO       '%'
  197. #define     ERO        '&'
  198. #define     LIT        '"'
  199. #define     LITA       0x27
  200. #define     REFC       ';'
  201. #define     CR         0x0D
  202. #define     LF         0x0A
  203. #define     ILLCHAR    (char) 0xFF
  204. #define     RNI        '#'
  205. #define     EE         (char) 0xFE
  206. /* ======================================================== */
  207. #ifndef     SEEK_STRT
  208. #define     SEEK_STRT     0
  209. #endif
  210. #ifndef     SEEK_CURRENT
  211. #define     SEEK_CURRENT   1
  212. #endif
  213. #ifndef     SEEK_END
  214. #define     SEEK_END       2
  215. #endif
  216. /* ======================================================== */
  217. /* ======================================================== */
  218.  
  219.  
  220. #define    GETC(a)       getc(a)
  221. #define    UNGETC(a,b)     ungetc(a,b)
  222. /* ======================================================== */
  223. /*
  224.    CONTEXT CODE (enum)
  225.                  - this field is used to indicate the contextual requiredness
  226.                    of a given token; its values are given by:
  227. */
  228.    typedef enum  CONTEXT  {C_NEVERO,      /* NEVER OMISSABLE 
  229.                                           ex. A in   (A?, B)            */
  230.                            C_ALWAYSO,     /* ALWAYS OMISSABLE 
  231.                                           ex. A in   (A, B)             */
  232.                            C_SOMETIMESO,  /* SOMETIMES OMISSABLE
  233.                                           ex. B in   (A?, B)*           */
  234.                            C_FTO,         /* OMISSABLE FIRST TIME ONLY
  235.                                           ex. A in (A+, B)              */
  236.                            C_FTOWR,       /* OMISSABLE FIRST TIME THEN RESET 
  237.                                           ex. B in (A, B+)+             */
  238.                            C_FTOTSO};     /* FIRST TIME OMISSABLE THEN 
  239.                                              SOMETIMES OMISSABLE 
  240.                                           ex. B in (A?, B+)+            */
  241. /* ======================================================== */
  242.  
  243. typedef    struct  TREEREC {
  244.    char    Tinfo[8];
  245.    int     Toi;
  246.    int     Tcontreq;
  247. } TREEREC;
  248.  
  249. typedef    struct  SYMBREC{
  250.    int    Smin;
  251.    char    Sname[NAMELEN];
  252.    int    Sid;
  253. } SYMBREC;
  254.  
  255. typedef    struct  {
  256.    int     Dtoken;
  257.    int     Doi;
  258.    enum CONTEXT     Dcontreq;
  259. } DTDREC;
  260.  
  261. /* ======================================================== */
  262. #define     SYMTBLREF           'x'
  263. /* ======================================================== */
  264. #define     COMMA               -21
  265. #define     AMPERSAND           -22
  266. #define     AND                 AMPERSAND
  267. #define     OR                  -23
  268. #define     ENDAND              -25
  269. /* ======================================================== */
  270. /* ======================================================== */
  271. /* ======================================================== */
  272.  
  273. /* the following documents the structure of the attribute file passed
  274.    from the DTD processor; the file will (until we decide what to do
  275.    with file options) be in D:DTDATTRIB.DAT.  The format is:
  276.  
  277.    TOKEN ID (int) 
  278.                  - this will associate the following attributes with
  279.                    an element name found in the symbol table.
  280.    NUMBER of ATTRIBS (int)
  281.                  - this is a count of the number of attributes associated
  282.                    with the current element.
  283.    ATTRIBUTE NAME (NAMELEN bytes, LJBF)
  284.                  - this field contains the name of the attribute.
  285.    DECLARED VALUE TOKEN (enum)
  286.                  - this field contains a token for the declared value of
  287.                    the attribute; it's values are given by:
  288. */
  289. typedef enum declval {GROUP, ENUM_CDATA, ENTITY, ID, IDREF, NAME, NMTOKEN, 
  290.                NUTOKEN, IDREFS, NAMES, NMTOKENS, NUTOKENS, NOTATION, 
  291.                NUMBER, NUMBERS} DECLVAL;
  292. /*
  293.    DEFAULT CODE (enum)
  294.                  - this field is used to indicate options for the default
  295.                    value; it's values are given by:
  296. */
  297.    typedef enum  adflt  {A_REQD, A_CURRENT, A_IMPLIED, A_UNFIXED,
  298.                     A_FIXED, A_CONREF} ADFLT;
  299.  
  300. /*
  301.    DEFAULT VALUE (ASCII Z-String)
  302.                  - this field contains the default value for this 
  303.                    attribute; this field is always present but may consist
  304.                    of only the End-of-String ('\0') byte.
  305.    NUMBER OF ITEMS IN GROUP (int)
  306.                  - this field contains the count of the number of items 
  307.                    in the group.
  308.    DECLARED VALUES (NAMELEN bytes LJBF)
  309.                  - this field contains the declared value(s) of the 
  310.                    attribute; each value is null terminated with no
  311.                    padding.
  312. */
  313.  
  314.  
  315.