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"
64
static xf86ConfigSymTabRec TopLevelTab[] = {
69
#define CLEANUP xf86freeConfig
72
* This function resolves name references and reports errors if the named
73
* objects cannot be found.
76
xf86validateConfig(XF86ConfigPtr p)
78
if (!xf86validateScreen(p))
80
if (!xf86validateInput(p))
82
if (!xf86validateLayout(p))
89
xf86readConfigFile(void)
92
XF86ConfigPtr ptr = NULL;
94
if ((ptr = calloc(1, sizeof(XF86ConfigRec))) == NULL) {
98
while ((token = xf86getToken(TopLevelTab)) != EOF_TOKEN) {
101
ptr->conf_comment = xf86addComment(ptr->conf_comment, xf86_lex_val.str);
104
if (xf86getSubToken(&(ptr->conf_comment)) != STRING) {
105
xf86parseError(QUOTE_MSG, "Section");
109
xf86setSection(xf86_lex_val.str);
110
if (xf86nameCompare(xf86_lex_val.str, "files") == 0) {
111
free(xf86_lex_val.str);
112
xf86_lex_val.str = NULL;
113
HANDLE_RETURN(conf_files, xf86parseFilesSection());
115
else if (xf86nameCompare(xf86_lex_val.str, "serverflags") == 0) {
116
free(xf86_lex_val.str);
117
xf86_lex_val.str = NULL;
118
HANDLE_RETURN(conf_flags, xf86parseFlagsSection());
120
else if (xf86nameCompare(xf86_lex_val.str, "pointer") == 0) {
121
free(xf86_lex_val.str);
122
xf86_lex_val.str = NULL;
123
HANDLE_LIST(conf_input_lst, xf86parsePointerSection,
126
else if (xf86nameCompare(xf86_lex_val.str, "videoadaptor") == 0) {
127
free(xf86_lex_val.str);
128
xf86_lex_val.str = NULL;
129
HANDLE_LIST(conf_videoadaptor_lst, xf86parseVideoAdaptorSection,
130
XF86ConfVideoAdaptorPtr);
132
else if (xf86nameCompare(xf86_lex_val.str, "device") == 0) {
133
free(xf86_lex_val.str);
134
xf86_lex_val.str = NULL;
135
HANDLE_LIST(conf_device_lst, xf86parseDeviceSection,
138
else if (xf86nameCompare(xf86_lex_val.str, "monitor") == 0) {
139
free(xf86_lex_val.str);
140
xf86_lex_val.str = NULL;
141
HANDLE_LIST(conf_monitor_lst, xf86parseMonitorSection,
144
else if (xf86nameCompare(xf86_lex_val.str, "modes") == 0) {
145
free(xf86_lex_val.str);
146
xf86_lex_val.str = NULL;
147
HANDLE_LIST(conf_modes_lst, xf86parseModesSection,
150
else if (xf86nameCompare(xf86_lex_val.str, "screen") == 0) {
151
free(xf86_lex_val.str);
152
xf86_lex_val.str = NULL;
153
HANDLE_LIST(conf_screen_lst, xf86parseScreenSection,
156
else if (xf86nameCompare(xf86_lex_val.str, "inputdevice") == 0) {
157
free(xf86_lex_val.str);
158
xf86_lex_val.str = NULL;
159
HANDLE_LIST(conf_input_lst, xf86parseInputSection,
162
else if (xf86nameCompare(xf86_lex_val.str, "inputclass") == 0) {
163
free(xf86_lex_val.str);
164
xf86_lex_val.str = NULL;
165
HANDLE_LIST(conf_inputclass_lst,
166
xf86parseInputClassSection, XF86ConfInputClassPtr);
168
else if (xf86nameCompare(xf86_lex_val.str, "module") == 0) {
169
free(xf86_lex_val.str);
170
xf86_lex_val.str = NULL;
171
HANDLE_RETURN(conf_modules, xf86parseModuleSection());
173
else if (xf86nameCompare(xf86_lex_val.str, "serverlayout") == 0) {
174
free(xf86_lex_val.str);
175
xf86_lex_val.str = NULL;
176
HANDLE_LIST(conf_layout_lst, xf86parseLayoutSection,
179
else if (xf86nameCompare(xf86_lex_val.str, "vendor") == 0) {
180
free(xf86_lex_val.str);
181
xf86_lex_val.str = NULL;
182
HANDLE_LIST(conf_vendor_lst, xf86parseVendorSection,
185
else if (xf86nameCompare(xf86_lex_val.str, "dri") == 0) {
186
free(xf86_lex_val.str);
187
xf86_lex_val.str = NULL;
188
HANDLE_RETURN(conf_dri, xf86parseDRISection());
190
else if (xf86nameCompare(xf86_lex_val.str, "extensions") == 0) {
191
free(xf86_lex_val.str);
192
xf86_lex_val.str = NULL;
193
HANDLE_RETURN(conf_extensions, xf86parseExtensionsSection());
196
free(xf86_lex_val.str);
197
xf86_lex_val.str = NULL;
198
Error(INVALID_SECTION_MSG, xf86tokenString());
202
free(xf86_lex_val.str);
203
xf86_lex_val.str = NULL;
204
Error(INVALID_KEYWORD_MSG, xf86tokenString());
208
if (xf86validateConfig(ptr))
219
* adds an item to the end of the linked list. Any record whose first field
220
* is a GenericListRec can be cast to this type and used with this function.
221
* A pointer to the head of the list is returned to handle the addition of
225
xf86addListItem(GenericListPtr head, GenericListPtr new)
227
GenericListPtr p = head;
228
GenericListPtr last = NULL;
244
* Test if one chained list contains the other.
245
* In this case both list have the same endpoint (provided they don't loop)
248
xf86itemNotSublist(GenericListPtr list_1, GenericListPtr list_2)
250
GenericListPtr p = list_1;
251
GenericListPtr last_1 = NULL, last_2 = NULL;
264
return (!(last_1 == last_2));
268
xf86freeConfig(XF86ConfigPtr p)
273
xf86freeFiles(p->conf_files);
274
xf86freeModules(p->conf_modules);
275
xf86freeFlags(p->conf_flags);
276
xf86freeMonitorList(p->conf_monitor_lst);
277
xf86freeModesList(p->conf_modes_lst);
278
xf86freeVideoAdaptorList(p->conf_videoadaptor_lst);
279
xf86freeDeviceList(p->conf_device_lst);
280
xf86freeScreenList(p->conf_screen_lst);
281
xf86freeLayoutList(p->conf_layout_lst);
282
xf86freeInputList(p->conf_input_lst);
283
xf86freeVendorList(p->conf_vendor_lst);
284
xf86freeDRI(p->conf_dri);
285
xf86freeExtensions(p->conf_extensions);
286
TestFree(p->conf_comment);