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 SubModuleTab
[] = {
66 {ENDSUBSECTION
, "endsubsection"},
71 static xf86ConfigSymTabRec ModuleTab
[] = {
72 {ENDSECTION
, "endsection"},
75 {LOAD_DRIVER
, "loaddriver"},
76 {SUBSECTION
, "subsection"},
80 #define CLEANUP xf86freeModules
83 xf86parseModuleSubSection(XF86LoadPtr head
, char *name
)
87 parsePrologue(XF86LoadPtr
, XF86LoadRec
)
89 ptr
->load_name
= name
;
90 ptr
->load_type
= XF86_LOAD_MODULE
;
93 ptr
->list
.next
= NULL
;
95 while ((token
= xf86getToken(SubModuleTab
)) != ENDSUBSECTION
) {
98 ptr
->load_comment
= xf86addComment(ptr
->load_comment
, val
.str
);
101 ptr
->load_opt
= xf86parseOption(ptr
->load_opt
);
104 xf86parseError(UNEXPECTED_EOF_MSG
);
108 xf86parseError(INVALID_KEYWORD_MSG
, xf86tokenString());
116 return ((XF86LoadPtr
) xf86addListItem((glp
) head
, (glp
) ptr
));
120 xf86parseModuleSection(void)
124 parsePrologue(XF86ConfModulePtr
, XF86ConfModuleRec
)
126 while ((token
= xf86getToken(ModuleTab
)) != ENDSECTION
) {
129 ptr
->mod_comment
= xf86addComment(ptr
->mod_comment
, val
.str
);
132 if (xf86getSubToken(&(ptr
->mod_comment
)) != STRING
)
133 Error(QUOTE_MSG
, "Load");
135 xf86addNewLoadDirective(ptr
->mod_load_lst
, val
.str
,
136 XF86_LOAD_MODULE
, NULL
);
139 if (xf86getSubToken(&(ptr
->mod_comment
)) != STRING
)
140 Error(QUOTE_MSG
, "Disable");
141 ptr
->mod_disable_lst
=
142 xf86addNewLoadDirective(ptr
->mod_disable_lst
, val
.str
,
143 XF86_DISABLE_MODULE
, NULL
);
146 if (xf86getSubToken(&(ptr
->mod_comment
)) != STRING
)
147 Error(QUOTE_MSG
, "LoadDriver");
149 xf86addNewLoadDirective(ptr
->mod_load_lst
, val
.str
,
150 XF86_LOAD_DRIVER
, NULL
);
153 if (xf86getSubToken(&(ptr
->mod_comment
)) != STRING
)
154 Error(QUOTE_MSG
, "SubSection");
156 xf86parseModuleSubSection(ptr
->mod_load_lst
, val
.str
);
159 Error(UNEXPECTED_EOF_MSG
);
162 Error(INVALID_KEYWORD_MSG
, xf86tokenString());
168 printf("Module section parsed\n");
177 xf86printModuleSection(FILE * cf
, XF86ConfModulePtr ptr
)
184 if (ptr
->mod_comment
)
185 fprintf(cf
, "%s", ptr
->mod_comment
);
186 for (lptr
= ptr
->mod_load_lst
; lptr
; lptr
= lptr
->list
.next
) {
187 switch (lptr
->load_type
) {
188 case XF86_LOAD_MODULE
:
189 if (lptr
->load_opt
== NULL
) {
190 fprintf(cf
, "\tLoad \"%s\"", lptr
->load_name
);
191 if (lptr
->load_comment
)
192 fprintf(cf
, "%s", lptr
->load_comment
);
197 fprintf(cf
, "\tSubSection \"%s\"\n", lptr
->load_name
);
198 if (lptr
->load_comment
)
199 fprintf(cf
, "%s", lptr
->load_comment
);
200 xf86printOptionList(cf
, lptr
->load_opt
, 2);
201 fprintf(cf
, "\tEndSubSection\n");
204 case XF86_LOAD_DRIVER
:
205 fprintf(cf
, "\tLoadDriver \"%s\"", lptr
->load_name
);
206 if (lptr
->load_comment
)
207 fprintf(cf
, "%s", lptr
->load_comment
);
213 fprintf(cf
, "#\tUnknown type \"%s\"\n", lptr
->load_name
);
221 xf86addNewLoadDirective(XF86LoadPtr head
, char *name
, int type
,
227 new = calloc(1, sizeof(XF86LoadRec
));
228 new->load_name
= name
;
229 new->load_type
= type
;
230 new->load_opt
= opts
;
232 new->list
.next
= NULL
;
234 if ((token
= xf86getToken(NULL
)) == COMMENT
)
235 new->load_comment
= xf86addComment(new->load_comment
, val
.str
);
237 xf86unGetToken(token
);
239 return ((XF86LoadPtr
) xf86addListItem((glp
) head
, (glp
) new));
243 xf86freeModules(XF86ConfModulePtr ptr
)
250 lptr
= ptr
->mod_load_lst
;
252 TestFree(lptr
->load_name
);
253 TestFree(lptr
->load_comment
);
255 lptr
= lptr
->list
.next
;
258 lptr
= ptr
->mod_disable_lst
;
260 TestFree(lptr
->load_name
);
261 TestFree(lptr
->load_comment
);
263 lptr
= lptr
->list
.next
;
266 TestFree(ptr
->mod_comment
);