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 VendorSubTab
[] = {
66 {ENDSUBSECTION
, "endsubsection"},
67 {IDENTIFIER
, "identifier"},
72 #define CLEANUP xf86freeVendorSubList
74 static XF86ConfVendSubPtr
75 xf86parseVendorSubSection(void)
77 int has_ident
= FALSE
;
80 parsePrologue(XF86ConfVendSubPtr
, XF86ConfVendSubRec
)
82 while ((token
= xf86getToken(VendorSubTab
)) != ENDSUBSECTION
) {
85 ptr
->vs_comment
= xf86addComment(ptr
->vs_comment
, val
.str
);
88 if (xf86getSubToken(&(ptr
->vs_comment
)))
89 Error(QUOTE_MSG
, "Identifier");
90 if (has_ident
== TRUE
)
91 Error(MULTIPLE_MSG
, "Identifier");
92 ptr
->vs_identifier
= val
.str
;
96 ptr
->vs_option_lst
= xf86parseOption(ptr
->vs_option_lst
);
100 Error(UNEXPECTED_EOF_MSG
);
103 Error(INVALID_KEYWORD_MSG
, xf86tokenString());
109 printf("Vendor subsection parsed\n");
117 static xf86ConfigSymTabRec VendorTab
[] = {
118 {ENDSECTION
, "endsection"},
119 {IDENTIFIER
, "identifier"},
121 {SUBSECTION
, "subsection"},
125 #define CLEANUP xf86freeVendorList
128 xf86parseVendorSection(void)
130 int has_ident
= FALSE
;
133 parsePrologue(XF86ConfVendorPtr
, XF86ConfVendorRec
)
135 while ((token
= xf86getToken(VendorTab
)) != ENDSECTION
) {
138 ptr
->vnd_comment
= xf86addComment(ptr
->vnd_comment
, val
.str
);
141 if (xf86getSubToken(&(ptr
->vnd_comment
)) != STRING
)
142 Error(QUOTE_MSG
, "Identifier");
143 if (has_ident
== TRUE
)
144 Error(MULTIPLE_MSG
, "Identifier");
145 ptr
->vnd_identifier
= val
.str
;
149 ptr
->vnd_option_lst
= xf86parseOption(ptr
->vnd_option_lst
);
152 if (xf86getSubToken(&(ptr
->vnd_comment
)) != STRING
)
153 Error(QUOTE_MSG
, "SubSection");
155 HANDLE_LIST(vnd_sub_lst
, xf86parseVendorSubSection
,
160 Error(UNEXPECTED_EOF_MSG
);
163 Error(INVALID_KEYWORD_MSG
, xf86tokenString());
173 printf("Vendor section parsed\n");
182 xf86printVendorSection(FILE * cf
, XF86ConfVendorPtr ptr
)
184 XF86ConfVendSubPtr pptr
;
187 fprintf(cf
, "Section \"Vendor\"\n");
188 if (ptr
->vnd_comment
)
189 fprintf(cf
, "%s", ptr
->vnd_comment
);
190 if (ptr
->vnd_identifier
)
191 fprintf(cf
, "\tIdentifier \"%s\"\n", ptr
->vnd_identifier
);
193 xf86printOptionList(cf
, ptr
->vnd_option_lst
, 1);
194 for (pptr
= ptr
->vnd_sub_lst
; pptr
; pptr
= pptr
->list
.next
) {
195 fprintf(cf
, "\tSubSection \"Vendor\"\n");
196 if (pptr
->vs_comment
)
197 fprintf(cf
, "%s", pptr
->vs_comment
);
198 if (pptr
->vs_identifier
)
199 fprintf(cf
, "\t\tIdentifier \"%s\"\n", pptr
->vs_identifier
);
200 xf86printOptionList(cf
, pptr
->vs_option_lst
, 2);
201 fprintf(cf
, "\tEndSubSection\n");
203 fprintf(cf
, "EndSection\n\n");
204 ptr
= ptr
->list
.next
;
209 xf86freeVendorList(XF86ConfVendorPtr p
)
213 xf86freeVendorSubList(p
->vnd_sub_lst
);
214 TestFree(p
->vnd_identifier
);
215 TestFree(p
->vnd_comment
);
216 xf86optionListFree(p
->vnd_option_lst
);
221 xf86freeVendorSubList(XF86ConfVendSubPtr ptr
)
223 XF86ConfVendSubPtr prev
;
226 TestFree(ptr
->vs_identifier
);
227 TestFree(ptr
->vs_name
);
228 TestFree(ptr
->vs_comment
);
229 xf86optionListFree(ptr
->vs_option_lst
);
231 ptr
= ptr
->list
.next
;