3 * Copyright (c) 1997 Metro Link Incorporated
5 * Permission is hereby granted, free of charge, to any person obtaining a
6 * copy of this software and associated documentation files (the "Software"),
7 * to deal in the Software without restriction, including without limitation
8 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
9 * and/or sell copies of the Software, and to permit persons to whom the
10 * Software is furnished to do so, subject to the following conditions:
12 * The above copyright notice and this permission notice shall be included in
13 * all copies or substantial portions of the Software.
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
19 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
20 * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23 * Except as contained in this notice, the name of the Metro Link shall not be
24 * used in advertising or otherwise to promote the sale, use or other dealings
25 * in this Software without prior written authorization from Metro Link.
29 * Copyright (c) 1997-2003 by The XFree86 Project, Inc.
31 * Permission is hereby granted, free of charge, to any person obtaining a
32 * copy of this software and associated documentation files (the "Software"),
33 * to deal in the Software without restriction, including without limitation
34 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
35 * and/or sell copies of the Software, and to permit persons to whom the
36 * Software is furnished to do so, subject to the following conditions:
38 * The above copyright notice and this permission notice shall be included in
39 * all copies or substantial portions of the Software.
41 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
42 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
43 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
44 * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
45 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
46 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
47 * OTHER DEALINGS IN THE SOFTWARE.
49 * Except as contained in this notice, the name of the copyright holder(s)
50 * and author(s) shall not be used in advertising or otherwise to promote
51 * the sale, use or other dealings in this Software without prior written
52 * authorization from the copyright holder(s) and author(s).
56 /* View/edit this file with tab stops set to 4 */
58 #ifdef HAVE_XORG_CONFIG_H
59 #include <xorg-config.h>
62 #include "xf86Parser.h"
63 #include "xf86tokens.h"
64 #include "Configint.h"
68 static xf86ConfigSymTabRec TopLevelTab
[] =
74 #define CLEANUP xf86freeConfig
77 * This function resolves name references and reports errors if the named
78 * objects cannot be found.
81 xf86validateConfig (XF86ConfigPtr p
)
83 if (!xf86validateDevice (p
))
85 if (!xf86validateScreen (p
))
87 if (!xf86validateInput (p
))
89 if (!xf86validateLayout (p
))
96 xf86readConfigFile (void)
99 XF86ConfigPtr ptr
= NULL
;
101 if ((ptr
= xf86confcalloc (1, sizeof (XF86ConfigRec
))) == NULL
)
105 memset (ptr
, 0, sizeof (XF86ConfigRec
));
107 while ((token
= xf86getToken (TopLevelTab
)) != EOF_TOKEN
)
112 ptr
->conf_comment
= xf86addComment(ptr
->conf_comment
, val
.str
);
115 if (xf86getSubToken (&(ptr
->conf_comment
)) != STRING
)
117 xf86parseError (QUOTE_MSG
, "Section");
121 xf86setSection (val
.str
);
122 if (xf86nameCompare (val
.str
, "files") == 0)
124 xf86conffree(val
.str
);
126 HANDLE_RETURN (conf_files
, xf86parseFilesSection ());
128 else if (xf86nameCompare (val
.str
, "serverflags") == 0)
130 xf86conffree(val
.str
);
132 HANDLE_RETURN (conf_flags
, xf86parseFlagsSection ());
134 else if (xf86nameCompare (val
.str
, "pointer") == 0)
136 xf86conffree(val
.str
);
138 HANDLE_LIST (conf_input_lst
, xf86parsePointerSection
,
141 else if (xf86nameCompare (val
.str
, "videoadaptor") == 0)
143 xf86conffree(val
.str
);
145 HANDLE_LIST (conf_videoadaptor_lst
, xf86parseVideoAdaptorSection
,
146 XF86ConfVideoAdaptorPtr
);
148 else if (xf86nameCompare (val
.str
, "device") == 0)
150 xf86conffree(val
.str
);
152 HANDLE_LIST (conf_device_lst
, xf86parseDeviceSection
,
155 else if (xf86nameCompare (val
.str
, "monitor") == 0)
157 xf86conffree(val
.str
);
159 HANDLE_LIST (conf_monitor_lst
, xf86parseMonitorSection
,
162 else if (xf86nameCompare (val
.str
, "modes") == 0)
164 xf86conffree(val
.str
);
166 HANDLE_LIST (conf_modes_lst
, xf86parseModesSection
,
169 else if (xf86nameCompare (val
.str
, "screen") == 0)
171 xf86conffree(val
.str
);
173 HANDLE_LIST (conf_screen_lst
, xf86parseScreenSection
,
176 else if (xf86nameCompare(val
.str
, "inputdevice") == 0)
178 xf86conffree(val
.str
);
180 HANDLE_LIST (conf_input_lst
, xf86parseInputSection
,
183 else if (xf86nameCompare (val
.str
, "module") == 0)
185 xf86conffree(val
.str
);
187 HANDLE_RETURN (conf_modules
, xf86parseModuleSection ());
189 else if (xf86nameCompare (val
.str
, "serverlayout") == 0)
191 xf86conffree(val
.str
);
193 HANDLE_LIST (conf_layout_lst
, xf86parseLayoutSection
,
196 else if (xf86nameCompare (val
.str
, "vendor") == 0)
198 xf86conffree(val
.str
);
200 HANDLE_LIST (conf_vendor_lst
, xf86parseVendorSection
,
203 else if (xf86nameCompare (val
.str
, "dri") == 0)
205 xf86conffree(val
.str
);
207 HANDLE_RETURN (conf_dri
, xf86parseDRISection ());
209 else if (xf86nameCompare (val
.str
, "extensions") == 0)
211 xf86conffree(val
.str
);
213 HANDLE_RETURN (conf_extensions
, xf86parseExtensionsSection ());
217 Error (INVALID_SECTION_MSG
, xf86tokenString ());
218 xf86conffree(val
.str
);
223 Error (INVALID_KEYWORD_MSG
, xf86tokenString ());
224 xf86conffree(val
.str
);
229 if (xf86validateConfig (ptr
))
241 * adds an item to the end of the linked list. Any record whose first field
242 * is a GenericListRec can be cast to this type and used with this function.
243 * A pointer to the head of the list is returned to handle the addition of
247 xf86addListItem (GenericListPtr head
, GenericListPtr
new)
249 GenericListPtr p
= head
;
250 GenericListPtr last
= NULL
;
268 * Test if one chained list contains the other.
269 * In this case both list have the same endpoint (provided they don't loop)
272 xf86itemNotSublist(GenericListPtr list_1
, GenericListPtr list_2
)
274 GenericListPtr p
= list_1
;
275 GenericListPtr last_1
= NULL
, last_2
= NULL
;
288 return (!(last_1
== last_2
));
292 xf86freeConfig (XF86ConfigPtr p
)
297 xf86freeFiles (p
->conf_files
);
298 xf86freeModules (p
->conf_modules
);
299 xf86freeFlags (p
->conf_flags
);
300 xf86freeMonitorList (p
->conf_monitor_lst
);
301 xf86freeModesList (p
->conf_modes_lst
);
302 xf86freeVideoAdaptorList (p
->conf_videoadaptor_lst
);
303 xf86freeDeviceList (p
->conf_device_lst
);
304 xf86freeScreenList (p
->conf_screen_lst
);
305 xf86freeLayoutList (p
->conf_layout_lst
);
306 xf86freeInputList (p
->conf_input_lst
);
307 xf86freeVendorList (p
->conf_vendor_lst
);
308 xf86freeDRI (p
->conf_dri
);
309 xf86freeExtensions (p
->conf_extensions
);
310 TestFree(p
->conf_comment
);