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).
55 #ifdef HAVE_XORG_CONFIG_H
56 #include <xorg-config.h>
59 #include "xf86Parser.h"
60 #include "xf86tokens.h"
61 #include "Configint.h"
65 static xf86ConfigSymTabRec TopLevelTab
[] = {
70 #define CLEANUP xf86freeConfig
73 * This function resolves name references and reports errors if the named
74 * objects cannot be found.
77 xf86validateConfig(XF86ConfigPtr p
)
79 if (!xf86validateScreen(p
))
81 if (!xf86validateInput(p
))
83 if (!xf86validateLayout(p
))
90 xf86readConfigFile(void)
93 XF86ConfigPtr ptr
= NULL
;
95 if ((ptr
= calloc(1, sizeof(XF86ConfigRec
))) == NULL
) {
99 while ((token
= xf86getToken(TopLevelTab
)) != EOF_TOKEN
) {
102 ptr
->conf_comment
= xf86addComment(ptr
->conf_comment
, val
.str
);
105 if (xf86getSubToken(&(ptr
->conf_comment
)) != STRING
) {
106 xf86parseError(QUOTE_MSG
, "Section");
110 xf86setSection(val
.str
);
111 if (xf86nameCompare(val
.str
, "files") == 0) {
114 HANDLE_RETURN(conf_files
, xf86parseFilesSection());
116 else if (xf86nameCompare(val
.str
, "serverflags") == 0) {
119 HANDLE_RETURN(conf_flags
, xf86parseFlagsSection());
121 else if (xf86nameCompare(val
.str
, "pointer") == 0) {
124 HANDLE_LIST(conf_input_lst
, xf86parsePointerSection
,
127 else if (xf86nameCompare(val
.str
, "videoadaptor") == 0) {
130 HANDLE_LIST(conf_videoadaptor_lst
, xf86parseVideoAdaptorSection
,
131 XF86ConfVideoAdaptorPtr
);
133 else if (xf86nameCompare(val
.str
, "device") == 0) {
136 HANDLE_LIST(conf_device_lst
, xf86parseDeviceSection
,
139 else if (xf86nameCompare(val
.str
, "monitor") == 0) {
142 HANDLE_LIST(conf_monitor_lst
, xf86parseMonitorSection
,
145 else if (xf86nameCompare(val
.str
, "modes") == 0) {
148 HANDLE_LIST(conf_modes_lst
, xf86parseModesSection
,
151 else if (xf86nameCompare(val
.str
, "screen") == 0) {
154 HANDLE_LIST(conf_screen_lst
, xf86parseScreenSection
,
157 else if (xf86nameCompare(val
.str
, "inputdevice") == 0) {
160 HANDLE_LIST(conf_input_lst
, xf86parseInputSection
,
163 else if (xf86nameCompare(val
.str
, "inputclass") == 0) {
166 HANDLE_LIST(conf_inputclass_lst
,
167 xf86parseInputClassSection
, XF86ConfInputClassPtr
);
169 else if (xf86nameCompare(val
.str
, "module") == 0) {
172 HANDLE_RETURN(conf_modules
, xf86parseModuleSection());
174 else if (xf86nameCompare(val
.str
, "serverlayout") == 0) {
177 HANDLE_LIST(conf_layout_lst
, xf86parseLayoutSection
,
180 else if (xf86nameCompare(val
.str
, "vendor") == 0) {
183 HANDLE_LIST(conf_vendor_lst
, xf86parseVendorSection
,
186 else if (xf86nameCompare(val
.str
, "dri") == 0) {
189 HANDLE_RETURN(conf_dri
, xf86parseDRISection());
191 else if (xf86nameCompare(val
.str
, "extensions") == 0) {
194 HANDLE_RETURN(conf_extensions
, xf86parseExtensionsSection());
199 Error(INVALID_SECTION_MSG
, xf86tokenString());
205 Error(INVALID_KEYWORD_MSG
, xf86tokenString());
209 if (xf86validateConfig(ptr
))
220 * adds an item to the end of the linked list. Any record whose first field
221 * is a GenericListRec can be cast to this type and used with this function.
222 * A pointer to the head of the list is returned to handle the addition of
226 xf86addListItem(GenericListPtr head
, GenericListPtr
new)
228 GenericListPtr p
= head
;
229 GenericListPtr last
= NULL
;
245 * Test if one chained list contains the other.
246 * In this case both list have the same endpoint (provided they don't loop)
249 xf86itemNotSublist(GenericListPtr list_1
, GenericListPtr list_2
)
251 GenericListPtr p
= list_1
;
252 GenericListPtr last_1
= NULL
, last_2
= NULL
;
265 return (!(last_1
== last_2
));
269 xf86freeConfig(XF86ConfigPtr p
)
274 xf86freeFiles(p
->conf_files
);
275 xf86freeModules(p
->conf_modules
);
276 xf86freeFlags(p
->conf_flags
);
277 xf86freeMonitorList(p
->conf_monitor_lst
);
278 xf86freeModesList(p
->conf_modes_lst
);
279 xf86freeVideoAdaptorList(p
->conf_videoadaptor_lst
);
280 xf86freeDeviceList(p
->conf_device_lst
);
281 xf86freeScreenList(p
->conf_screen_lst
);
282 xf86freeLayoutList(p
->conf_layout_lst
);
283 xf86freeInputList(p
->conf_input_lst
);
284 xf86freeVendorList(p
->conf_vendor_lst
);
285 xf86freeDRI(p
->conf_dri
);
286 xf86freeExtensions(p
->conf_extensions
);
287 TestFree(p
->conf_comment
);