Add GNU LGPL headers to all .c .C and .h files
[oweals/cde.git] / cde / programs / dthelp / parser / pass2 / eltdef / eltdef.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: eltdef.h /main/3 1995/11/08 10:44:51 rswiston $ */
24 /*
25               Copyright 1986 Tandem Computers Incorporated.
26 This product and information is proprietary of Tandem Computers Incorporated.
27                    Copyright (c) 1986, 1987, 1988, 1989 Hewlett-Packard Co.
28 */
29
30 /* Eltdef.h is the include file for allocating global variables in ELTDEF */
31
32 #if defined(ELTDEF)
33 #define ELTEXTERN
34 #define ELTINIT(a) = a
35 #else
36 #define ELTEXTERN extern
37 #define ELTINIT(a)
38 #endif
39
40 #include "common.h"
41
42 /* Error recovery status */
43 #define RENTITY 0
44 #define RSIGNON 1
45 #define RGLOBDEC 2
46 #define RGLOBDEF 3
47 #define RELEMENT 4
48
49 /* State transition network generated by CONTEXT */
50 #include "sparse.h"
51
52 /* Indicates whether, and if so where, each character can appear in
53    a name */
54 #if defined(ELTDEF)
55 #include "chartype.h"
56 #else
57 extern M_CHARTYPE m_ctarray[M_CHARSETLEN] ;
58 #endif
59
60 /* Scanned name or literal */
61 ELTEXTERN M_WCHAR name[M_NAMELEN + 1] ;
62 ELTEXTERN M_WCHAR literal[M_LITLEN + 1] ;
63
64 /* Associates a C variable with a particular parameter */
65 typedef struct cvarstruct CVARSTRUCT ;
66 struct cvarstruct {
67   int param ;
68   M_WCHAR *cvarptr ;
69   CVARSTRUCT *next ;
70   } ;
71 ELTEXTERN CVARSTRUCT *cvarlist ;
72 /* Current and previous context (state) of transition system 
73    controlling ELTDEF */
74 ELTEXTERN int curcon ELTINIT(START) ;
75 ELTEXTERN int m_prevcon ;
76
77 /* Character read-ahead buffer */
78 ELTEXTERN int toundo ELTINIT(0) ;
79 ELTEXTERN int maxundo ELTINIT(0) ;
80 #define SAVECHAR 50
81 ELTEXTERN int savechar[SAVECHAR] ;
82
83 /* Chain of elements named in pseudo-tag */
84 typedef struct chain CHAIN ;
85 struct chain {
86   M_ELEMENT elt ;
87   CHAIN *next ;
88   } ;
89 ELTEXTERN CHAIN *firstchain ELTINIT(NULL) ;
90 ELTEXTERN CHAIN **nextchain ELTINIT(&firstchain) ;
91
92 /* Text character returned from scanner */
93 ELTEXTERN M_WCHAR textchar ;
94
95 /* Identifying index of element currently being processed */
96 ELTEXTERN M_ELEMENT openelt ELTINIT(M_NULLVAL) ;
97
98 /* Output files */
99 ELTEXTERN FILE *globdec, *globdef, *string,
100   *pfile, *tfile, *sfile, *efile, *entfile, *ifile, *stfile, *ifh, *pvalh ;
101
102 /* Flags indicating whether currently in the middle of processing 
103    an action */
104 ELTEXTERN LOGICAL intext ELTINIT(FALSE),
105                   inent ELTINIT(FALSE),
106                   inpc ELTINIT(FALSE),
107                   insc ELTINIT(FALSE),
108                   inec ELTINIT(FALSE),
109                   instc ELTINIT(FALSE),
110                   instring ELTINIT(FALSE) ;
111
112 /* Location of global start-string and end-string, if any */
113 ELTEXTERN int gss ELTINIT(0), 
114               ges ELTINIT(0) ;
115
116 /* Flags indicating whether default code setments are to be used */
117 ELTEXTERN LOGICAL finitext ELTINIT(TRUE), 
118                   finipi ELTINIT(TRUE),
119                   finistc ELTINIT(TRUE) ;
120
121 /* Whether have finished the sign-on message */
122 ELTEXTERN LOGICAL signonend ELTINIT(FALSE) ;
123         
124 /* Whether errors have occurred */
125 ELTEXTERN LOGICAL errexit ELTINIT(FALSE) ;
126
127 /* Number of characters currently written to stext.h and etext.h */
128 ELTEXTERN int stringcnt ELTINIT(1) ;
129
130 /* Number of actions so far written to code files */
131 ELTEXTERN int sactions ELTINIT(1), 
132               eactions ELTINIT(1), 
133               tactions ELTINIT(1), 
134               pactions ELTINIT(1),
135               stactions ELTINIT(1) ;
136
137 /* Pool of ponters for associating a chain of elements with an action string
138    or code */
139 typedef struct action ACTION ;
140 struct action {
141   int data ;
142   M_ELEMENT element ;
143   int count ;
144   ACTION *son ;
145   ACTION *next ;
146   ACTION *nextact ;
147   } ;
148 ELTEXTERN int actlen ELTINIT(0) ;
149 ELTEXTERN ACTION *firstact ELTINIT(NULL) ;
150 ELTEXTERN ACTION **nextact ELTINIT(&firstact) ;
151
152 /* Number of elements defined in the document type */
153 #if defined(M_DTDDEF)
154 #define ELCOUNT sizeof(m_element)/sizeof(m_element[0])
155 #else
156 #define ELCOUNT
157 #endif
158
159 /* Action arrays, indexed by the element in which they occur.  Each element
160    is a linked list for actions qualified by the context in which they
161    occur. */
162 ELTEXTERN ACTION *starray[ELCOUNT], 
163                  *etarray[ELCOUNT], 
164                  *scarray[ELCOUNT],
165                  *ecarray[ELCOUNT], 
166                  *tcarray[ELCOUNT], 
167                  *pcarray[ELCOUNT],
168                  *stcarray[ELCOUNT] ;
169
170 /* Store the sign-on message */
171 #define SOCHAR 512
172 ELTEXTERN char signonmsg[SOCHAR] ;
173 ELTEXTERN int sochar ELTINIT(0) ;
174
175 /* Indicates which elements have been processed at a particular time */
176 ELTEXTERN LOGICAL processed[ELCOUNT] ;
177
178 /* Flags to indicate whether data has yet been written to various files */
179 ELTEXTERN LOGICAL stringstart ELTINIT(TRUE) ;
180
181 /* Flag indicating whether a carriage return was the last character of
182    the signon message */
183 ELTEXTERN LOGICAL socr ELTINIT(FALSE) ;
184
185 /* Number of current input line */
186 ELTEXTERN int m_line ELTINIT(1) ;
187
188 /* Pointer to file error for error messages */
189 ELTEXTERN FILE *m_errfile ;
190
191 /* Name of interface file */
192 #define IFLEN 512
193 ELTEXTERN char iffile[IFLEN] ; 
194
195 /* Pointer to current entity */
196 ELTEXTERN M_ENTITY *entity ;
197
198 /* Count of code entities defined */
199 ELTEXTERN int codeent ELTINIT(0) ;
200
201 /* Content of entity being defined */
202 ELTEXTERN int entclen ;
203 ELTEXTERN M_WCHAR entcontent[M_LITLEN + 1] ;
204
205 /* Error recovery status */
206 ELTEXTERN int restart ELTINIT(RENTITY) ;
207
208 /* Strings to write to generated files */
209 #define pproto "M_WCHAR *m_pi, M_WCHAR *m_entname, int m_enttype"
210 #define pformal "m_pi, m_entname, m_enttype"
211 #define pftype "  M_WCHAR *m_pi ;\n  M_WCHAR *m_entname ;\n  int m_enttype ;"
212 #define tproto "M_WCHAR m_textchar"
213 #define tformal "m_textchar"
214 #define tftype "  M_WCHAR m_textchar ;\n"
215 #define stproto "M_WCHAR *m_string, LOGICAL M_START, LOGICAL M_END"
216 #define stformal "m_string, M_START, M_END"
217 #define stft "  M_WCHAR *m_string ;\n  LOGICAL M_START ;\n  LOGICAL M_END ;\n"
218 #define nopar "M_NOPAR"
219
220 /* Structures for generating defines for parameter values */
221 ELTEXTERN M_TRIE parval ;
222 typedef struct {
223   M_WCHAR *cname ;
224   M_WCHAR *value ;
225   int line ;
226   } PARVAL ;
227 ELTEXTERN PARVAL *pval ;
228
229 /* Function prototypes */
230 #include "proto.h"
231
232 /* Flag to open fewer files for convenience of debugging with
233    CodeView */
234 ELTEXTERN LOGICAL debug ELTINIT(FALSE) ;
235 /* Scanner trace for debugging */
236 ELTEXTERN LOGICAL scantrace ELTINIT(FALSE) ;
237 /* Test validity of heap in calls to malloc/free */
238 ELTEXTERN LOGICAL m_heapchk ELTINIT(FALSE) ;
239 /* Trace calls to malloc/free */
240 ELTEXTERN LOGICAL m_malftrace ELTINIT(FALSE) ;
241