Require strdup and remove utils wrapper
[platform/upstream/libxkbcommon.git] / src / xkbcomp / xkbcomp.h
1 /************************************************************
2  Copyright (c) 1994 by Silicon Graphics Computer Systems, Inc.
3
4  Permission to use, copy, modify, and distribute this
5  software and its documentation for any purpose and without
6  fee is hereby granted, provided that the above copyright
7  notice appear in all copies and that both that copyright
8  notice and this permission notice appear in supporting
9  documentation, and that the name of Silicon Graphics not be
10  used in advertising or publicity pertaining to distribution
11  of the software without specific prior written permission.
12  Silicon Graphics makes no representation about the suitability
13  of this software for any purpose. It is provided "as is"
14  without any express or implied warranty.
15
16  SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
17  SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
18  AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
19  GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
20  DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
21  DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
22  OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION  WITH
23  THE USE OR PERFORMANCE OF THIS SOFTWARE.
24
25  ********************************************************/
26
27 #ifndef XKBCOMP_H
28 #define XKBCOMP_H 1
29
30 #ifndef DEBUG_VAR
31 #define DEBUG_VAR debugFlags
32 #endif
33
34 #include <X11/X.h>
35 #include <X11/Xdefs.h>
36
37 #include "utils.h"
38
39 #include <X11/extensions/XKM.h>
40 #include "X11/extensions/XKBcommon.h"
41 #include "XKBcommonint.h"
42
43 extern char *scanFile;
44
45 #define TypeUnknown     0
46 #define TypeBoolean     1
47 #define TypeInt         2
48 #define TypeFloat       3
49 #define TypeString      4
50 #define TypeAction      5
51 #define TypeKeyName     6
52 #define TypeSymbols     7
53
54 #define StmtUnknown             0
55 #define StmtInclude             1
56 #define StmtKeycodeDef          2
57 #define StmtKeyAliasDef         3
58 #define StmtExpr                4
59 #define StmtVarDef              5
60 #define StmtKeyTypeDef          6
61 #define StmtInterpDef           7
62 #define StmtVModDef             8
63 #define StmtSymbolsDef          9
64 #define StmtModMapDef           10
65 #define StmtGroupCompatDef      11
66 #define StmtIndicatorMapDef     12
67 #define StmtIndicatorNameDef    13
68 #define StmtOutlineDef          14
69 #define StmtShapeDef            15
70 #define StmtKeyDef              16
71 #define StmtRowDef              17
72 #define StmtSectionDef          18
73 #define StmtOverlayKeyDef       19
74 #define StmtOverlayDef          20
75 #define StmtDoodadDef           21
76
77 #define FileSymInterp   100
78
79 typedef struct _ParseCommon
80 {
81     unsigned stmtType;
82     struct _ParseCommon *next;
83 } ParseCommon;
84
85 #define ExprValue       0
86 #define ExprIdent       1
87 #define ExprActionDecl  2
88 #define ExprFieldRef    3
89 #define ExprArrayRef    4
90 #define ExprKeysymList  5
91 #define ExprActionList  6
92 #define ExprCoord       7
93
94 #define OpAdd           20
95 #define OpSubtract      21
96 #define OpMultiply      22
97 #define OpDivide        23
98 #define OpAssign        24
99 #define OpNot           25
100 #define OpNegate        26
101 #define OpInvert        27
102 #define OpUnaryPlus     28
103
104 #define MergeDefault    0
105 #define MergeAugment    1
106 #define MergeOverride   2
107 #define MergeReplace    3
108 #define MergeAltForm    4
109
110 #define AutoKeyNames    (1L <<  0)
111 #define CreateKeyNames(x)       ((x)->flags&AutoKeyNames)
112
113 extern unsigned warningLevel;
114 extern unsigned optionalParts;
115
116 typedef struct _IncludeStmt
117 {
118     ParseCommon common;
119     unsigned merge;
120     char *stmt;
121     char *file;
122     char *map;
123     char *modifier;
124     char *path;
125     struct _IncludeStmt *next;
126 } IncludeStmt;
127
128 typedef struct _Expr
129 {
130     ParseCommon common;
131     unsigned op;
132     unsigned type;
133     union
134     {
135         struct
136         {
137             struct _Expr *left;
138             struct _Expr *right;
139         } binary;
140         struct
141         {
142             Atom element;
143             Atom field;
144         } field;
145         struct
146         {
147             Atom element;
148             Atom field;
149             struct _Expr *entry;
150         } array;
151         struct
152         {
153             Atom name;
154             struct _Expr *args;
155         } action;
156         struct
157         {
158             int nSyms;
159             int szSyms;
160             KeySym *syms;
161         } list;
162         struct
163         {
164             int x;
165             int y;
166         } coord;
167         struct _Expr *child;
168         Atom str;
169         unsigned uval;
170         int ival;
171         char keyName[5];
172         Opaque ptr;
173     } value;
174 } ExprDef;
175
176 typedef struct _VarDef
177 {
178     ParseCommon common;
179     unsigned merge;
180     ExprDef *name;
181     ExprDef *value;
182 } VarDef;
183
184 typedef struct _VModDef
185 {
186     ParseCommon common;
187     unsigned merge;
188     Atom name;
189     ExprDef *value;
190 } VModDef;
191
192 typedef struct _KeycodeDef
193 {
194     ParseCommon common;
195     unsigned merge;
196     char name[5];
197     ExprDef *value;
198 } KeycodeDef;
199
200 typedef struct _KeyAliasDef
201 {
202     ParseCommon common;
203     unsigned merge;
204     char alias[5];
205     char real[5];
206 } KeyAliasDef;
207
208 typedef struct _KeyTypeDef
209 {
210     ParseCommon common;
211     unsigned merge;
212     Atom name;
213     VarDef *body;
214 } KeyTypeDef;
215
216 typedef struct _SymbolsDef
217 {
218     ParseCommon common;
219     unsigned merge;
220     char keyName[5];
221     ExprDef *symbols;
222 } SymbolsDef;
223
224 typedef struct _ModMapDef
225 {
226     ParseCommon common;
227     unsigned merge;
228     Atom modifier;
229     ExprDef *keys;
230 } ModMapDef;
231
232 typedef struct _GroupCompatDef
233 {
234     ParseCommon common;
235     unsigned merge;
236     int group;
237     ExprDef *def;
238 } GroupCompatDef;
239
240 typedef struct _InterpDef
241 {
242     ParseCommon common;
243     unsigned merge;
244     KeySym sym;
245     ExprDef *match;
246     VarDef *def;
247 } InterpDef;
248
249 typedef struct _IndicatorNameDef
250 {
251     ParseCommon common;
252     unsigned merge;
253     int ndx;
254     ExprDef *name;
255     Bool virtual;
256 } IndicatorNameDef;
257
258 typedef struct _OutlineDef
259 {
260     ParseCommon common;
261     Atom field;
262     int nPoints;
263     ExprDef *points;
264 } OutlineDef;
265
266 typedef struct _ShapeDef
267 {
268     ParseCommon common;
269     unsigned merge;
270     Atom name;
271     int nOutlines;
272     OutlineDef *outlines;
273 } ShapeDef;
274
275 typedef struct _KeyDef
276 {
277     ParseCommon common;
278     unsigned defined;
279     char *name;
280     ExprDef *expr;
281 } KeyDef;
282
283 typedef struct _RowDef
284 {
285     ParseCommon common;
286     int nKeys;
287     KeyDef *keys;
288 } RowDef;
289
290 typedef struct _SectionDef
291 {
292     ParseCommon common;
293     unsigned merge;
294     Atom name;
295     int nRows;
296     RowDef *rows;
297 } SectionDef;
298
299 typedef struct _OverlayKeyDef
300 {
301     ParseCommon common;
302     char over[5];
303     char under[5];
304 } OverlayKeyDef;
305
306 typedef struct _OverlayDef
307 {
308     ParseCommon common;
309     unsigned merge;
310     Atom name;
311     int nKeys;
312     OverlayKeyDef *keys;
313 } OverlayDef;
314
315 typedef struct _DoodadDef
316 {
317     ParseCommon common;
318     unsigned merge;
319     unsigned type;
320     Atom name;
321     VarDef *body;
322 } DoodadDef;
323
324 /* IndicatorMapDef doesn't use the type field, but the rest of the fields
325    need to be at the same offsets as in DoodadDef.  Use #define to avoid
326    any strict aliasing problems.  */
327 #define IndicatorMapDef DoodadDef
328
329 typedef struct _XkbFile
330 {
331     ParseCommon common;
332     int type;
333     char *topName;
334     char *name;
335     ParseCommon *defs;
336     int id;
337     unsigned flags;
338     Bool compiled;
339 } XkbFile;
340
341 extern Bool
342 CompileKeymap(XkbFile *file, XkbcDescPtr xkb, unsigned merge);
343
344 extern Bool
345 CompileKeycodes(XkbFile *file, XkbcDescPtr xkb, unsigned merge);
346
347 extern Bool
348 CompileGeometry(XkbFile *file, XkbcDescPtr xkb, unsigned merge);
349
350 extern Bool
351 CompileKeyTypes(XkbFile *file, XkbcDescPtr xkb, unsigned merge);
352
353 typedef struct _LEDInfo *LEDInfoPtr;
354
355 extern Bool
356 CompileCompatMap(XkbFile *file, XkbcDescPtr xkb, unsigned merge,
357                  LEDInfoPtr *unboundLEDs);
358
359 extern Bool
360 CompileSymbols(XkbFile *file, XkbcDescPtr xkb, unsigned merge);
361
362 #endif /* XKBCOMP_H */