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