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 | #include <X11/Xfuncproto.h> /* For _X_ATTRIBUTE_PRINTF */
|
---|
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 | /* 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, ...) _X_ATTRIBUTE_PRINTF(1,0);
|
---|
208 | extern void *dmxConfigAlloc(unsigned long bytes);
|
---|
209 | extern void *dmxConfigRealloc(void *orig,
|
---|
210 | unsigned long orig_bytes, unsigned long bytes);
|
---|
211 | extern const char *dmxConfigCopyString(const char *string, int length);
|
---|
212 | extern void dmxConfigFree(void *area);
|
---|
213 | extern DMXConfigTokenPtr dmxConfigCreateToken(int token, int line,
|
---|
214 | const char *comment);
|
---|
215 | extern void dmxConfigFreeToken(DMXConfigTokenPtr p);
|
---|
216 | extern DMXConfigStringPtr dmxConfigCreateString(int token, int line,
|
---|
217 | const char *comment,
|
---|
218 | const char *string);
|
---|
219 | extern void dmxConfigFreeString(DMXConfigStringPtr p);
|
---|
220 | extern DMXConfigNumberPtr dmxConfigCreateNumber(int token, int line,
|
---|
221 | const char *comment,
|
---|
222 | int number);
|
---|
223 | extern void dmxConfigFreeNumber(DMXConfigNumberPtr p);
|
---|
224 | extern DMXConfigPairPtr dmxConfigCreatePair(int token, int line,
|
---|
225 | const char *comment,
|
---|
226 | int x, int y, int xsign, int ysign);
|
---|
227 | extern void dmxConfigFreePair(DMXConfigPairPtr p);
|
---|
228 | extern DMXConfigCommentPtr dmxConfigCreateComment(int token, int line,
|
---|
229 | const char *comment);
|
---|
230 | extern void dmxConfigFreeComment(DMXConfigCommentPtr p);
|
---|
231 | extern DMXConfigPartDimPtr dmxConfigCreatePartDim(DMXConfigPairPtr pDim,
|
---|
232 | DMXConfigPairPtr pOffset);
|
---|
233 | extern void dmxConfigFreePartDim(DMXConfigPartDimPtr p);
|
---|
234 | extern DMXConfigFullDimPtr dmxConfigCreateFullDim(DMXConfigPartDimPtr pScrn,
|
---|
235 | DMXConfigPartDimPtr pRoot);
|
---|
236 | extern void dmxConfigFreeFullDim(DMXConfigFullDimPtr p);
|
---|
237 | extern DMXConfigDisplayPtr dmxConfigCreateDisplay(DMXConfigTokenPtr pStart,
|
---|
238 | DMXConfigStringPtr pName,
|
---|
239 | DMXConfigFullDimPtr pDim,
|
---|
240 | DMXConfigPairPtr pOrigin,
|
---|
241 | DMXConfigTokenPtr pEnd);
|
---|
242 | extern void dmxConfigFreeDisplay(DMXConfigDisplayPtr p);
|
---|
243 | extern DMXConfigWallPtr dmxConfigCreateWall(DMXConfigTokenPtr pStart,
|
---|
244 | DMXConfigPairPtr pWallDim,
|
---|
245 | DMXConfigPairPtr pDisplayDim,
|
---|
246 | DMXConfigStringPtr pNameList,
|
---|
247 | DMXConfigTokenPtr pEnd);
|
---|
248 | extern void dmxConfigFreeWall(DMXConfigWallPtr p);
|
---|
249 | extern DMXConfigOptionPtr dmxConfigCreateOption(DMXConfigTokenPtr pStart,
|
---|
250 | DMXConfigStringPtr pOption,
|
---|
251 | DMXConfigTokenPtr pEnd);
|
---|
252 | extern void dmxConfigFreeOption(DMXConfigOptionPtr p);
|
---|
253 | extern DMXConfigParamPtr dmxConfigCreateParam(DMXConfigTokenPtr pStart,
|
---|
254 | DMXConfigTokenPtr pOpen,
|
---|
255 | DMXConfigStringPtr pParam,
|
---|
256 | DMXConfigTokenPtr pClose,
|
---|
257 | DMXConfigTokenPtr pEnd);
|
---|
258 | extern void dmxConfigFreeParam(DMXConfigParamPtr p);
|
---|
259 | extern const char **dmxConfigLookupParam(DMXConfigParamPtr p,
|
---|
260 | const char *key, int *argc);
|
---|
261 | extern DMXConfigSubPtr dmxConfigCreateSub(DMXConfigType type,
|
---|
262 | DMXConfigCommentPtr comment,
|
---|
263 | DMXConfigDisplayPtr display,
|
---|
264 | DMXConfigWallPtr wall,
|
---|
265 | DMXConfigOptionPtr option,
|
---|
266 | DMXConfigParamPtr param);
|
---|
267 | extern void dmxConfigFreeSub(DMXConfigSubPtr sub);
|
---|
268 | extern DMXConfigSubPtr dmxConfigSubComment(DMXConfigCommentPtr comment);
|
---|
269 | extern DMXConfigSubPtr dmxConfigSubDisplay(DMXConfigDisplayPtr display);
|
---|
270 | extern DMXConfigSubPtr dmxConfigSubWall(DMXConfigWallPtr wall);
|
---|
271 | extern DMXConfigSubPtr dmxConfigSubOption(DMXConfigOptionPtr option);
|
---|
272 | extern DMXConfigSubPtr dmxConfigSubParam(DMXConfigParamPtr param);
|
---|
273 | extern DMXConfigSubPtr dmxConfigAddSub(DMXConfigSubPtr head,
|
---|
274 | DMXConfigSubPtr sub);
|
---|
275 | extern DMXConfigVirtualPtr dmxConfigCreateVirtual(DMXConfigTokenPtr pStart,
|
---|
276 | DMXConfigStringPtr pName,
|
---|
277 | DMXConfigPairPtr pDim,
|
---|
278 | DMXConfigTokenPtr pOpen,
|
---|
279 | DMXConfigSubPtr pSubentry,
|
---|
280 | DMXConfigTokenPtr pClose);
|
---|
281 | extern void dmxConfigFreeVirtual(DMXConfigVirtualPtr virtual);
|
---|
282 | extern DMXConfigEntryPtr dmxConfigCreateEntry(DMXConfigType type,
|
---|
283 | DMXConfigCommentPtr comment,
|
---|
284 | DMXConfigVirtualPtr virtual);
|
---|
285 | extern void dmxConfigFreeEntry(DMXConfigEntryPtr entry);
|
---|
286 | extern DMXConfigEntryPtr dmxConfigAddEntry(DMXConfigEntryPtr head,
|
---|
287 | DMXConfigType type,
|
---|
288 | DMXConfigCommentPtr comment,
|
---|
289 | DMXConfigVirtualPtr virtual);
|
---|
290 | extern DMXConfigEntryPtr dmxConfigEntryComment(DMXConfigCommentPtr comment);
|
---|
291 | extern DMXConfigEntryPtr dmxConfigEntryVirtual(DMXConfigVirtualPtr virtual);
|
---|
292 |
|
---|
293 | #endif
|
---|