1 | /*
|
---|
2 | * Copyright 2002 Red Hat Inc., Durham, North Carolina.
|
---|
3 | *
|
---|
4 | * All Rights Reserved.
|
---|
5 | *
|
---|
6 | * Permission is hereby granted, free of charge, to any person obtaining
|
---|
7 | * a copy of this software and associated documentation files (the
|
---|
8 | * "Software"), to deal in the Software without restriction, including
|
---|
9 | * without limitation on the rights to use, copy, modify, merge,
|
---|
10 | * publish, distribute, sublicense, and/or sell copies of the Software,
|
---|
11 | * and to permit persons to whom the Software is furnished to do so,
|
---|
12 | * subject to the following conditions:
|
---|
13 | *
|
---|
14 | * The above copyright notice and this permission notice (including the
|
---|
15 | * next paragraph) shall be included in all copies or substantial
|
---|
16 | * portions of the Software.
|
---|
17 | *
|
---|
18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
---|
19 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
---|
20 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
---|
21 | * NON-INFRINGEMENT. IN NO EVENT SHALL RED HAT AND/OR THEIR SUPPLIERS
|
---|
22 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
---|
23 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
---|
24 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
---|
25 | * SOFTWARE.
|
---|
26 | */
|
---|
27 |
|
---|
28 | /*
|
---|
29 | * Authors:
|
---|
30 | * Rickard E. (Rik) Faith <[email protected]>
|
---|
31 | *
|
---|
32 | */
|
---|
33 |
|
---|
34 | /** \file
|
---|
35 | * Interface to DMX configuration file parser. \see dmxparse.c */
|
---|
36 |
|
---|
37 | #ifndef _DMXPARSE_H_
|
---|
38 | #define _DMXPARSE_H_
|
---|
39 |
|
---|
40 | #include <stdio.h> /* For FILE */
|
---|
41 |
|
---|
42 | /** Stores tokens not stored in other structures (e.g., keywords and ;) */
|
---|
43 | typedef struct _DMXConfigToken {
|
---|
44 | int token;
|
---|
45 | int line;
|
---|
46 | const char *comment;
|
---|
47 | } DMXConfigToken, *DMXConfigTokenPtr;
|
---|
48 |
|
---|
49 | /** Stores parsed strings. */
|
---|
50 | typedef struct _DMXConfigString {
|
---|
51 | int token;
|
---|
52 | int line;
|
---|
53 | const char *comment;
|
---|
54 | const char *string;
|
---|
55 | struct _DMXConfigString *next;
|
---|
56 | } DMXConfigString, *DMXConfigStringPtr;
|
---|
57 |
|
---|
58 | /** Stores parsed numbers. */
|
---|
59 | typedef struct _DMXConfigNumber {
|
---|
60 | int token;
|
---|
61 | int line;
|
---|
62 | const char *comment;
|
---|
63 | int number;
|
---|
64 | } DMXConfigNumber, *DMXConfigNumberPtr;
|
---|
65 |
|
---|
66 | /** Stores parsed pairs (e.g., x y) */
|
---|
67 | typedef struct _DMXConfigPair {
|
---|
68 | int token;
|
---|
69 | int line;
|
---|
70 | const char *comment;
|
---|
71 | int x;
|
---|
72 | int y;
|
---|
73 | int xsign;
|
---|
74 | int ysign;
|
---|
75 | } DMXConfigPair, *DMXConfigPairPtr;
|
---|
76 |
|
---|
77 | /** Stores parsed comments not stored with a token. */
|
---|
78 | typedef struct _DMXConfigComment {
|
---|
79 | int token;
|
---|
80 | int line;
|
---|
81 | const char *comment;
|
---|
82 | } DMXConfigComment, *DMXConfigCommentPtr;
|
---|
83 |
|
---|
84 | typedef enum {
|
---|
85 | dmxConfigComment,
|
---|
86 | dmxConfigVirtual,
|
---|
87 | dmxConfigDisplay,
|
---|
88 | dmxConfigWall,
|
---|
89 | dmxConfigOption,
|
---|
90 | dmxConfigParam
|
---|
91 | } DMXConfigType;
|
---|
92 |
|
---|
93 | /** Stores a geometry specification. */
|
---|
94 | typedef struct _DMXConfigPartDim {
|
---|
95 | DMXConfigPairPtr dim;
|
---|
96 | DMXConfigPairPtr offset;
|
---|
97 | } DMXConfigPartDim, *DMXConfigPartDimPtr;
|
---|
98 |
|
---|
99 | /** Stores a pair of geometry specifications. */
|
---|
100 | typedef struct _DMXConfigFullDim {
|
---|
101 | DMXConfigPartDimPtr scrn;
|
---|
102 | DMXConfigPartDimPtr root;
|
---|
103 | } DMXConfigFullDim, *DMXConfigFullDimPtr;
|
---|
104 |
|
---|
105 | /** Stores parsed display information. */
|
---|
106 | typedef struct _DMXConfigDisplay {
|
---|
107 | /* Summary information */
|
---|
108 | const char *name;
|
---|
109 | /* Screen Window Geometry */
|
---|
110 | int scrnWidth, scrnHeight;
|
---|
111 | int scrnX, scrnY;
|
---|
112 | int scrnXSign, scrnYSign;
|
---|
113 | /* Root Window Geometry */
|
---|
114 | int rootWidth, rootHeight;
|
---|
115 | int rootX, rootY;
|
---|
116 | int rootXSign, rootYSign;
|
---|
117 | /* Origin in global space */
|
---|
118 | int rootXOrigin, rootYOrigin;
|
---|
119 |
|
---|
120 | /* Raw configuration information */
|
---|
121 | DMXConfigTokenPtr start;
|
---|
122 | DMXConfigStringPtr dname;
|
---|
123 | DMXConfigFullDimPtr dim;
|
---|
124 | DMXConfigPairPtr origin;
|
---|
125 | DMXConfigTokenPtr end;
|
---|
126 | } DMXConfigDisplay, *DMXConfigDisplayPtr;
|
---|
127 |
|
---|
128 | /** Stores parsed wall information. */
|
---|
129 | typedef struct _DMXConfigWall {
|
---|
130 | /* Summary information */
|
---|
131 | int width, height; /* dimensions of displays */
|
---|
132 | int xwall, ywall; /* dimensions of wall, in tiles */
|
---|
133 |
|
---|
134 |
|
---|
135 | /* Raw configuration informaiton */
|
---|
136 | DMXConfigTokenPtr start;
|
---|
137 | DMXConfigPairPtr wallDim;
|
---|
138 | DMXConfigPairPtr displayDim;
|
---|
139 | DMXConfigStringPtr nameList;
|
---|
140 | DMXConfigTokenPtr end;
|
---|
141 | } DMXConfigWall, *DMXConfigWallPtr;
|
---|
142 |
|
---|
143 | /** Stores parsed option information. */
|
---|
144 | typedef struct _DMXConfigOption {
|
---|
145 | /* Summary information */
|
---|
146 | char *string;
|
---|
147 |
|
---|
148 | /* Raw configuration informaiton */
|
---|
149 | DMXConfigTokenPtr start;
|
---|
150 | DMXConfigStringPtr option;
|
---|
151 | DMXConfigTokenPtr end;
|
---|
152 | } DMXConfigOption, *DMXConfigOptionPtr;
|
---|
153 |
|
---|
154 | /** Stores parsed param information. */
|
---|
155 | typedef struct _DMXConfigParam {
|
---|
156 | int argc;
|
---|
157 | const char **argv;
|
---|
158 |
|
---|
159 | DMXConfigTokenPtr start;
|
---|
160 | DMXConfigTokenPtr open;
|
---|
161 | DMXConfigStringPtr param;
|
---|
162 | DMXConfigTokenPtr close;
|
---|
163 | DMXConfigTokenPtr end; /* Either open/close OR end */
|
---|
164 | struct _DMXConfigParam *next;
|
---|
165 | } DMXConfigParam, *DMXConfigParamPtr;
|
---|
166 |
|
---|
167 | /** Stores options under an entry (subentry). */
|
---|
168 | typedef struct _DMXConfigSub {
|
---|
169 | DMXConfigType type;
|
---|
170 | DMXConfigCommentPtr comment;
|
---|
171 | DMXConfigDisplayPtr display;
|
---|
172 | DMXConfigWallPtr wall;
|
---|
173 | DMXConfigOptionPtr option;
|
---|
174 | DMXConfigParamPtr param;
|
---|
175 | struct _DMXConfigSub *next;
|
---|
176 | } DMXConfigSub, *DMXConfigSubPtr;
|
---|
177 |
|
---|
178 | /** Stores parsed virtual information. */
|
---|
179 | typedef struct _DMXConfigVirtual {
|
---|
180 | /* Summary information */
|
---|
181 | const char *name;
|
---|
182 | int width, height;
|
---|
183 |
|
---|
184 | /* Raw configuration information */
|
---|
185 | DMXConfigTokenPtr start;
|
---|
186 | DMXConfigStringPtr vname;
|
---|
187 | DMXConfigPairPtr dim;
|
---|
188 | DMXConfigTokenPtr open;
|
---|
189 | DMXConfigSubPtr subentry;
|
---|
190 | DMXConfigTokenPtr close;
|
---|
191 | } DMXConfigVirtual, *DMXConfigVirtualPtr;
|
---|
192 |
|
---|
193 | /** Heads entry storage. */
|
---|
194 | typedef struct _DMXConfigEntry {
|
---|
195 | DMXConfigType type;
|
---|
196 | DMXConfigCommentPtr comment;
|
---|
197 | DMXConfigVirtualPtr virtual;
|
---|
198 | struct _DMXConfigEntry *next;
|
---|
199 | } DMXConfigEntry, *DMXConfigEntryPtr;
|
---|
200 |
|
---|
201 | extern DMXConfigEntryPtr dmxConfigEntry;
|
---|
202 |
|
---|
203 | extern int yylex(void);
|
---|
204 | extern int yydebug;
|
---|
205 | extern void yyerror(const char *message);
|
---|
206 |
|
---|
207 | extern void dmxConfigLog(const char *format, ...);
|
---|
208 | extern void *dmxConfigAlloc(unsigned long bytes);
|
---|
209 | extern void *dmxConfigRealloc(void *orig,
|
---|
210 | unsigned long orig_bytes,
|
---|
211 | unsigned long bytes);
|
---|
212 | extern const char *dmxConfigCopyString(const char *string,
|
---|
213 | int length);
|
---|
214 | extern void dmxConfigFree(void *area);
|
---|
215 | extern DMXConfigTokenPtr dmxConfigCreateToken(int token, int line,
|
---|
216 | const char *comment);
|
---|
217 | extern void dmxConfigFreeToken(DMXConfigTokenPtr p);
|
---|
218 | extern DMXConfigStringPtr dmxConfigCreateString(int token, int line,
|
---|
219 | const char *comment,
|
---|
220 | const char *string);
|
---|
221 | extern void dmxConfigFreeString(DMXConfigStringPtr p);
|
---|
222 | extern DMXConfigNumberPtr dmxConfigCreateNumber(int token, int line,
|
---|
223 | const char *comment,
|
---|
224 | int number);
|
---|
225 | extern void dmxConfigFreeNumber(DMXConfigNumberPtr p);
|
---|
226 | extern DMXConfigPairPtr dmxConfigCreatePair(int token, int line,
|
---|
227 | const char *comment,
|
---|
228 | int x, int y,
|
---|
229 | int xsign, int ysign);
|
---|
230 | extern void dmxConfigFreePair(DMXConfigPairPtr p);
|
---|
231 | extern DMXConfigCommentPtr dmxConfigCreateComment(int token, int line,
|
---|
232 | const char *comment);
|
---|
233 | extern void dmxConfigFreeComment(DMXConfigCommentPtr p);
|
---|
234 | extern DMXConfigPartDimPtr dmxConfigCreatePartDim(DMXConfigPairPtr pDim,
|
---|
235 | DMXConfigPairPtr pOffset);
|
---|
236 | extern void dmxConfigFreePartDim(DMXConfigPartDimPtr p);
|
---|
237 | extern DMXConfigFullDimPtr dmxConfigCreateFullDim(DMXConfigPartDimPtr pScrn,
|
---|
238 | DMXConfigPartDimPtr pRoot);
|
---|
239 | extern void dmxConfigFreeFullDim(DMXConfigFullDimPtr p);
|
---|
240 | extern DMXConfigDisplayPtr dmxConfigCreateDisplay(DMXConfigTokenPtr pStart,
|
---|
241 | DMXConfigStringPtr pName,
|
---|
242 | DMXConfigFullDimPtr pDim,
|
---|
243 | DMXConfigPairPtr pOrigin,
|
---|
244 | DMXConfigTokenPtr pEnd);
|
---|
245 | extern void dmxConfigFreeDisplay(DMXConfigDisplayPtr p);
|
---|
246 | extern DMXConfigWallPtr dmxConfigCreateWall(DMXConfigTokenPtr pStart,
|
---|
247 | DMXConfigPairPtr pWallDim,
|
---|
248 | DMXConfigPairPtr pDisplayDim,
|
---|
249 | DMXConfigStringPtr pNameList,
|
---|
250 | DMXConfigTokenPtr pEnd);
|
---|
251 | extern void dmxConfigFreeWall(DMXConfigWallPtr p);
|
---|
252 | extern DMXConfigOptionPtr dmxConfigCreateOption(DMXConfigTokenPtr pStart,
|
---|
253 | DMXConfigStringPtr pOption,
|
---|
254 | DMXConfigTokenPtr pEnd);
|
---|
255 | extern void dmxConfigFreeOption(DMXConfigOptionPtr p);
|
---|
256 | extern DMXConfigParamPtr dmxConfigCreateParam(DMXConfigTokenPtr pStart,
|
---|
257 | DMXConfigTokenPtr pOpen,
|
---|
258 | DMXConfigStringPtr pParam,
|
---|
259 | DMXConfigTokenPtr pClose,
|
---|
260 | DMXConfigTokenPtr pEnd);
|
---|
261 | extern void dmxConfigFreeParam(DMXConfigParamPtr p);
|
---|
262 | extern const char **dmxConfigLookupParam(DMXConfigParamPtr p,
|
---|
263 | const char *key,
|
---|
264 | int *argc);
|
---|
265 | extern DMXConfigSubPtr dmxConfigCreateSub(DMXConfigType type,
|
---|
266 | DMXConfigCommentPtr comment,
|
---|
267 | DMXConfigDisplayPtr display,
|
---|
268 | DMXConfigWallPtr wall,
|
---|
269 | DMXConfigOptionPtr option,
|
---|
270 | DMXConfigParamPtr param);
|
---|
271 | extern void dmxConfigFreeSub(DMXConfigSubPtr sub);
|
---|
272 | extern DMXConfigSubPtr dmxConfigSubComment(DMXConfigCommentPtr comment);
|
---|
273 | extern DMXConfigSubPtr dmxConfigSubDisplay(DMXConfigDisplayPtr display);
|
---|
274 | extern DMXConfigSubPtr dmxConfigSubWall(DMXConfigWallPtr wall);
|
---|
275 | extern DMXConfigSubPtr dmxConfigSubOption(DMXConfigOptionPtr option);
|
---|
276 | extern DMXConfigSubPtr dmxConfigSubParam(DMXConfigParamPtr param);
|
---|
277 | extern DMXConfigSubPtr dmxConfigAddSub(DMXConfigSubPtr head,
|
---|
278 | DMXConfigSubPtr sub);
|
---|
279 | extern DMXConfigVirtualPtr dmxConfigCreateVirtual(DMXConfigTokenPtr pStart,
|
---|
280 | DMXConfigStringPtr pName,
|
---|
281 | DMXConfigPairPtr pDim,
|
---|
282 | DMXConfigTokenPtr pOpen,
|
---|
283 | DMXConfigSubPtr pSubentry,
|
---|
284 | DMXConfigTokenPtr pClose);
|
---|
285 | extern void dmxConfigFreeVirtual(DMXConfigVirtualPtr virtual);
|
---|
286 | extern DMXConfigEntryPtr dmxConfigCreateEntry(DMXConfigType type,
|
---|
287 | DMXConfigCommentPtr comment,
|
---|
288 | DMXConfigVirtualPtr virtual);
|
---|
289 | extern void dmxConfigFreeEntry(DMXConfigEntryPtr entry);
|
---|
290 | extern DMXConfigEntryPtr dmxConfigAddEntry(DMXConfigEntryPtr head,
|
---|
291 | DMXConfigType type,
|
---|
292 | DMXConfigCommentPtr comment,
|
---|
293 | DMXConfigVirtualPtr virtual);
|
---|
294 | extern DMXConfigEntryPtr dmxConfigEntryComment(DMXConfigCommentPtr comment);
|
---|
295 | extern DMXConfigEntryPtr dmxConfigEntryVirtual(DMXConfigVirtualPtr virtual);
|
---|
296 |
|
---|
297 | #endif
|
---|