Imported Upstream version 1.15.1
[deb_xorg-server.git] / hw / dmx / config / dmxparse.h
CommitLineData
a09e091a
JB
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 <faith@redhat.com>
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 ;) */
43typedef struct _DMXConfigToken {
44 int token;
45 int line;
46 const char *comment;
47} DMXConfigToken, *DMXConfigTokenPtr;
48
49/** Stores parsed strings. */
50typedef 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. */
59typedef 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) */
67typedef 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. */
78typedef struct _DMXConfigComment {
79 int token;
80 int line;
81 const char *comment;
82} DMXConfigComment, *DMXConfigCommentPtr;
83
84typedef enum {
85 dmxConfigComment,
86 dmxConfigVirtual,
87 dmxConfigDisplay,
88 dmxConfigWall,
89 dmxConfigOption,
90 dmxConfigParam
91} DMXConfigType;
92
93/** Stores a geometry specification. */
94typedef struct _DMXConfigPartDim {
95 DMXConfigPairPtr dim;
96 DMXConfigPairPtr offset;
97} DMXConfigPartDim, *DMXConfigPartDimPtr;
98
99/** Stores a pair of geometry specifications. */
100typedef struct _DMXConfigFullDim {
101 DMXConfigPartDimPtr scrn;
102 DMXConfigPartDimPtr root;
103} DMXConfigFullDim, *DMXConfigFullDimPtr;
104
105/** Stores parsed display information. */
106typedef 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. */
129typedef struct _DMXConfigWall {
130 /* Summary information */
131 int width, height; /* dimensions of displays */
132 int xwall, ywall; /* dimensions of wall, in tiles */
133
134 /* Raw configuration informaiton */
135 DMXConfigTokenPtr start;
136 DMXConfigPairPtr wallDim;
137 DMXConfigPairPtr displayDim;
138 DMXConfigStringPtr nameList;
139 DMXConfigTokenPtr end;
140} DMXConfigWall, *DMXConfigWallPtr;
141
142/** Stores parsed option information. */
143typedef struct _DMXConfigOption {
144 /* Summary information */
145 char *string;
146
147 /* Raw configuration informaiton */
148 DMXConfigTokenPtr start;
149 DMXConfigStringPtr option;
150 DMXConfigTokenPtr end;
151} DMXConfigOption, *DMXConfigOptionPtr;
152
153/** Stores parsed param information. */
154typedef struct _DMXConfigParam {
155 int argc;
156 const char **argv;
157
158 DMXConfigTokenPtr start;
159 DMXConfigTokenPtr open;
160 DMXConfigStringPtr param;
161 DMXConfigTokenPtr close;
162 DMXConfigTokenPtr end; /* Either open/close OR end */
163 struct _DMXConfigParam *next;
164} DMXConfigParam, *DMXConfigParamPtr;
165
166/** Stores options under an entry (subentry). */
167typedef struct _DMXConfigSub {
168 DMXConfigType type;
169 DMXConfigCommentPtr comment;
170 DMXConfigDisplayPtr display;
171 DMXConfigWallPtr wall;
172 DMXConfigOptionPtr option;
173 DMXConfigParamPtr param;
174 struct _DMXConfigSub *next;
175} DMXConfigSub, *DMXConfigSubPtr;
176
177/** Stores parsed virtual information. */
178typedef struct _DMXConfigVirtual {
179 /* Summary information */
180 const char *name;
181 int width, height;
182
183 /* Raw configuration information */
184 DMXConfigTokenPtr start;
185 DMXConfigStringPtr vname;
186 DMXConfigPairPtr dim;
187 DMXConfigTokenPtr open;
188 DMXConfigSubPtr subentry;
189 DMXConfigTokenPtr close;
190} DMXConfigVirtual, *DMXConfigVirtualPtr;
191
192/** Heads entry storage. */
193typedef struct _DMXConfigEntry {
194 DMXConfigType type;
195 DMXConfigCommentPtr comment;
196 DMXConfigVirtualPtr virtual;
197 struct _DMXConfigEntry *next;
198} DMXConfigEntry, *DMXConfigEntryPtr;
199
200extern DMXConfigEntryPtr dmxConfigEntry;
201
202extern int yylex(void);
203extern int yydebug;
204extern void yyerror(const char *message);
205
206extern void dmxConfigLog(const char *format, ...);
207extern void *dmxConfigAlloc(unsigned long bytes);
208extern void *dmxConfigRealloc(void *orig,
209 unsigned long orig_bytes, unsigned long bytes);
210extern const char *dmxConfigCopyString(const char *string, int length);
211extern void dmxConfigFree(void *area);
212extern DMXConfigTokenPtr dmxConfigCreateToken(int token, int line,
213 const char *comment);
214extern void dmxConfigFreeToken(DMXConfigTokenPtr p);
215extern DMXConfigStringPtr dmxConfigCreateString(int token, int line,
216 const char *comment,
217 const char *string);
218extern void dmxConfigFreeString(DMXConfigStringPtr p);
219extern DMXConfigNumberPtr dmxConfigCreateNumber(int token, int line,
220 const char *comment,
221 int number);
222extern void dmxConfigFreeNumber(DMXConfigNumberPtr p);
223extern DMXConfigPairPtr dmxConfigCreatePair(int token, int line,
224 const char *comment,
225 int x, int y, int xsign, int ysign);
226extern void dmxConfigFreePair(DMXConfigPairPtr p);
227extern DMXConfigCommentPtr dmxConfigCreateComment(int token, int line,
228 const char *comment);
229extern void dmxConfigFreeComment(DMXConfigCommentPtr p);
230extern DMXConfigPartDimPtr dmxConfigCreatePartDim(DMXConfigPairPtr pDim,
231 DMXConfigPairPtr pOffset);
232extern void dmxConfigFreePartDim(DMXConfigPartDimPtr p);
233extern DMXConfigFullDimPtr dmxConfigCreateFullDim(DMXConfigPartDimPtr pScrn,
234 DMXConfigPartDimPtr pRoot);
235extern void dmxConfigFreeFullDim(DMXConfigFullDimPtr p);
236extern DMXConfigDisplayPtr dmxConfigCreateDisplay(DMXConfigTokenPtr pStart,
237 DMXConfigStringPtr pName,
238 DMXConfigFullDimPtr pDim,
239 DMXConfigPairPtr pOrigin,
240 DMXConfigTokenPtr pEnd);
241extern void dmxConfigFreeDisplay(DMXConfigDisplayPtr p);
242extern DMXConfigWallPtr dmxConfigCreateWall(DMXConfigTokenPtr pStart,
243 DMXConfigPairPtr pWallDim,
244 DMXConfigPairPtr pDisplayDim,
245 DMXConfigStringPtr pNameList,
246 DMXConfigTokenPtr pEnd);
247extern void dmxConfigFreeWall(DMXConfigWallPtr p);
248extern DMXConfigOptionPtr dmxConfigCreateOption(DMXConfigTokenPtr pStart,
249 DMXConfigStringPtr pOption,
250 DMXConfigTokenPtr pEnd);
251extern void dmxConfigFreeOption(DMXConfigOptionPtr p);
252extern DMXConfigParamPtr dmxConfigCreateParam(DMXConfigTokenPtr pStart,
253 DMXConfigTokenPtr pOpen,
254 DMXConfigStringPtr pParam,
255 DMXConfigTokenPtr pClose,
256 DMXConfigTokenPtr pEnd);
257extern void dmxConfigFreeParam(DMXConfigParamPtr p);
258extern const char **dmxConfigLookupParam(DMXConfigParamPtr p,
259 const char *key, int *argc);
260extern DMXConfigSubPtr dmxConfigCreateSub(DMXConfigType type,
261 DMXConfigCommentPtr comment,
262 DMXConfigDisplayPtr display,
263 DMXConfigWallPtr wall,
264 DMXConfigOptionPtr option,
265 DMXConfigParamPtr param);
266extern void dmxConfigFreeSub(DMXConfigSubPtr sub);
267extern DMXConfigSubPtr dmxConfigSubComment(DMXConfigCommentPtr comment);
268extern DMXConfigSubPtr dmxConfigSubDisplay(DMXConfigDisplayPtr display);
269extern DMXConfigSubPtr dmxConfigSubWall(DMXConfigWallPtr wall);
270extern DMXConfigSubPtr dmxConfigSubOption(DMXConfigOptionPtr option);
271extern DMXConfigSubPtr dmxConfigSubParam(DMXConfigParamPtr param);
272extern DMXConfigSubPtr dmxConfigAddSub(DMXConfigSubPtr head,
273 DMXConfigSubPtr sub);
274extern DMXConfigVirtualPtr dmxConfigCreateVirtual(DMXConfigTokenPtr pStart,
275 DMXConfigStringPtr pName,
276 DMXConfigPairPtr pDim,
277 DMXConfigTokenPtr pOpen,
278 DMXConfigSubPtr pSubentry,
279 DMXConfigTokenPtr pClose);
280extern void dmxConfigFreeVirtual(DMXConfigVirtualPtr virtual);
281extern DMXConfigEntryPtr dmxConfigCreateEntry(DMXConfigType type,
282 DMXConfigCommentPtr comment,
283 DMXConfigVirtualPtr virtual);
284extern void dmxConfigFreeEntry(DMXConfigEntryPtr entry);
285extern DMXConfigEntryPtr dmxConfigAddEntry(DMXConfigEntryPtr head,
286 DMXConfigType type,
287 DMXConfigCommentPtr comment,
288 DMXConfigVirtualPtr virtual);
289extern DMXConfigEntryPtr dmxConfigEntryComment(DMXConfigCommentPtr comment);
290extern DMXConfigEntryPtr dmxConfigEntryVirtual(DMXConfigVirtualPtr virtual);
291
292#endif