Add GNU LGPL headers to all .c .C and .h files
[oweals/cde.git] / cde / programs / dtdocbook / sgmls / sgmlmain.h
1 /*
2  * CDE - Common Desktop Environment
3  *
4  * Copyright (c) 1993-2012, The Open Group. All rights reserved.
5  *
6  * These libraries and programs are free software; you can
7  * redistribute them and/or modify them under the terms of the GNU
8  * Lesser General Public License as published by the Free Software
9  * Foundation; either version 2 of the License, or (at your option)
10  * any later version.
11  *
12  * These libraries and programs are distributed in the hope that
13  * they will be useful, but WITHOUT ANY WARRANTY; without even the
14  * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15  * PURPOSE. See the GNU Lesser General Public License for more
16  * details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with these librararies and programs; if not, write
20  * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
21  * Floor, Boston, MA 02110-1301 USA
22  */
23 /* $XConsortium: sgmlmain.h /main/3 1996/06/19 17:17:52 drk $ */
24 /* SGMLMAIN: Main interface to SGML services.
25
26 Preprocessor variable names are the only supported interface
27 to data maintained by SGML.  They are defined in this file or in adl.h.
28 */
29 /* Return control block types (RCBTYPE) from calls to parser (SGML):
30    Names and strings follow the convention for the IPBs.
31 */
32 enum sgmlevent {
33      SGMLEOD,                   /* End of document. */
34      SGMLDAF,                   /* Data found. */
35      SGMLSTG,                   /* Start-tag found. */
36      SGMLETG,                   /* End-tag found. */
37      SGMLREF,                   /* Record end found. */
38      SGMLPIS,                   /* Processing instruction (string). */
39      SGMLAPP                    /* APPINFO (string) */
40 };
41
42 struct rcbdata {              /* Return control block: DAF EOD REF PIS APP. */
43      UNS contersw;            /* 1=context error; 2,4,8=data type; 0=not. */
44      UNS datalen;             /* Length of data or PI (0=single nonchar). */
45      UNCH *data;              /* Data, PI, single nonSGML, or NDATA ecb ptr. */
46 };
47
48 struct rcbtag {               /* Return control block for STG and ETG. */
49      UNS contersw;            /* 1=context error; 2=NET enabled; 0/0=not. */
50      UNS tagmin;              /* Minim: NONE NULL NET DATA; implied by S/ETAG */
51      UNCH *curgi;             /* Start-tag (or end-tag) GI. */
52      union {
53           struct ad *al;      /* Start-tag: attribute list. */
54           UNCH *oldgi;        /* End-tag: resumed GI. */
55      } ru;
56      struct ad *lal;          /* Start-tag: link attribute list (UNUSED). */
57      UNS format;              /* Format class for default processing. */
58      struct etd *tagreal;     /* Dummy etd or ptr to GI that implied this tag.*/
59      int etictr;              /* Number of elements on stack with NET enabled.*/
60      UNCH *srmnm;             /* Current SHORTREF map name (NULL=#EMPTY). */
61 };
62
63 /* Accessors for rcbdata and rcbtag. */
64 /* Datatype abbreviations: C=unsigned char  S=string  U=unsigned int L=4 bytes
65                            A=array  P=ptr to structure N=name (see sgmlcb.h)
66 */
67 /* Data control block fields: processing instructions (SGMLPIS).
68 */
69 #define PDATA(d) ((d).data)            /*S  PI string. */
70 #define PDATALEN(d) ((d).datalen)      /*U  Length of PI string. */
71 #define PIESW(d) (((d).contersw & 4))  /*U  1=PIDATA entity returned. */
72 /* Data control block fields: other data types.
73 */
74 #define CDATA(d) ((d).data)            /*S  CDATA content string. */
75 #define CDATALEN(d) ((d).datalen)      /*U  Length of CDATA content string. */
76 #define CONTERSW(d) (((d).contersw &1))/*U  1=CDATA or TAG out of context. */
77 #define CDESW(d) (((d).contersw & 2))  /*U  1=CDATA entity returned. */
78 #define SDESW(d) (((d).contersw & 4))  /*U  1=SDATA entity returned. */
79 #define NDESW(d) (((d).contersw & 8))  /*U  1=NDATA entity returned. */
80 #define NEPTR(d) ((PNE)(d).data)       /*P  Ptr to NDATA control block. */
81 #define MARKUP(d) ((d).data)           /*A  Markup delimiter strings. */
82 #define DTYPELEN(d) ((d).datalen)      /*U  Length of doc type name +len+EOS. */
83 #define DOCTYPE(d) ((d).data)          /*S  Document type name (with len+EOS). */
84 #define ADATA(d) ((d).data)            /*S  APPINFO */
85 #define ADATALEN(d) ((d).datalen)      /*U  Length of APPINFO string.  */
86 /* Tag control block fields.
87 */
88 #define ALPTR(t) ((t).ru.al)           /*P  Ptr to SGML attribute list. */
89 #define CURGI(t) ((t).curgi+1)         /*N  GI of started or ended element. */
90 #define OLDGI(t) ((t).ru.oldgi)        /*S  GI of resumed element. */
91 #define TAGMIN(t) (t).tagmin          /*U  Minimization for current tag. */
92 #define TAGREAL(t) ((t).tagreal)      /*P  Dummy etd that implied this tag. */
93 #define TAGRLNM(t) ((UNCH *)(t).tagreal)  /*P GI of tag that implied this tag.*/
94 #define ETISW(t) (((t).contersw & 2))  /*U  1=NET delimiter enabled by ETI. */
95 #define PEXSW(t) (((t).contersw & 4))  /*U  1=Element was plus exception. */
96 #define MTYSW(t) (((t).contersw & 8))  /*U  1=Element is empty. */
97 #define ETICTR(t) ((t).etictr)         /*U  Number of active NET delimiters. */
98 #define SRMNM(t) ((t).srmnm)           /*S  Name of current SHORTREF map. */
99 #define SRMCNT(t) ((t).contersw)       /*U  Number of SHORTREF maps defined. */
100 #define FORMAT(t) ((t).format)         /*U  Format class.*/
101
102 /* These function names are chosen so as to be distinct in the first 6
103 letters. */
104
105 /* Initialize. */
106 struct markup *sgmlset P((struct switches *));
107 /* Cleanup and return capacity usage statistics. */
108 VOID sgmlend P((struct sgmlcap *));
109 /* Set document entity. */
110 int sgmlsdoc P((UNIV));
111 /* Get entity. */
112 int sgmlgent P((UNCH *, PNE *, UNCH **));
113 /* Mark an entity.  Return is non-zero if already marked.*/
114 int sgmlment P((UNCH *));
115 /* Get the next sgml event. */
116 enum sgmlevent sgmlnext P((struct rcbdata *, struct rcbtag *));
117 /* Get the error count. */
118 int sgmlgcnterr P((void));
119 /* Get the current location. */
120 int sgmlloc P((unsigned long *, char **));
121 /* Write out the SGML declaration. */
122 VOID sgmlwrsd P((FILE *));
123 /* Note subdocument capacity usage. */
124 VOID sgmlsubcap P((long *));