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 VideoPortTab
[] = {
66 {ENDSUBSECTION
, "endsubsection"},
67 {IDENTIFIER
, "identifier"},
72 #define CLEANUP xf86freeVideoPortList
75 xf86freeVideoPortList(XF86ConfVideoPortPtr ptr
)
77 XF86ConfVideoPortPtr prev
;
80 TestFree(ptr
->vp_identifier
);
81 TestFree(ptr
->vp_comment
);
82 xf86optionListFree(ptr
->vp_option_lst
);
89 static XF86ConfVideoPortPtr
90 xf86parseVideoPortSubSection(void)
92 int has_ident
= FALSE
;
95 parsePrologue(XF86ConfVideoPortPtr
, XF86ConfVideoPortRec
)
97 while ((token
= xf86getToken(VideoPortTab
)) != ENDSUBSECTION
) {
100 ptr
->vp_comment
= xf86addComment(ptr
->vp_comment
, val
.str
);
103 if (xf86getSubToken(&(ptr
->vp_comment
)) != STRING
)
104 Error(QUOTE_MSG
, "Identifier");
105 if (has_ident
== TRUE
)
106 Error(MULTIPLE_MSG
, "Identifier");
107 ptr
->vp_identifier
= val
.str
;
111 ptr
->vp_option_lst
= xf86parseOption(ptr
->vp_option_lst
);
115 Error(UNEXPECTED_EOF_MSG
);
118 Error(INVALID_KEYWORD_MSG
, xf86tokenString());
124 printf("VideoPort subsection parsed\n");
132 static xf86ConfigSymTabRec VideoAdaptorTab
[] = {
133 {ENDSECTION
, "endsection"},
134 {IDENTIFIER
, "identifier"},
135 {VENDOR
, "vendorname"},
136 {BOARD
, "boardname"},
140 {SUBSECTION
, "subsection"},
144 #define CLEANUP xf86freeVideoAdaptorList
146 XF86ConfVideoAdaptorPtr
147 xf86parseVideoAdaptorSection(void)
149 int has_ident
= FALSE
;
152 parsePrologue(XF86ConfVideoAdaptorPtr
, XF86ConfVideoAdaptorRec
)
154 while ((token
= xf86getToken(VideoAdaptorTab
)) != ENDSECTION
) {
157 ptr
->va_comment
= xf86addComment(ptr
->va_comment
, val
.str
);
160 if (xf86getSubToken(&(ptr
->va_comment
)) != STRING
)
161 Error(QUOTE_MSG
, "Identifier");
162 ptr
->va_identifier
= val
.str
;
163 if (has_ident
== TRUE
)
164 Error(MULTIPLE_MSG
, "Identifier");
168 if (xf86getSubToken(&(ptr
->va_comment
)) != STRING
)
169 Error(QUOTE_MSG
, "Vendor");
170 ptr
->va_vendor
= val
.str
;
173 if (xf86getSubToken(&(ptr
->va_comment
)) != STRING
)
174 Error(QUOTE_MSG
, "Board");
175 ptr
->va_board
= val
.str
;
178 if (xf86getSubToken(&(ptr
->va_comment
)) != STRING
)
179 Error(QUOTE_MSG
, "BusID");
180 ptr
->va_busid
= val
.str
;
183 if (xf86getSubToken(&(ptr
->va_comment
)) != STRING
)
184 Error(QUOTE_MSG
, "Driver");
185 ptr
->va_driver
= val
.str
;
188 ptr
->va_option_lst
= xf86parseOption(ptr
->va_option_lst
);
191 if (xf86getSubToken(&(ptr
->va_comment
)) != STRING
)
192 Error(QUOTE_MSG
, "SubSection");
194 HANDLE_LIST(va_port_lst
, xf86parseVideoPortSubSection
,
195 XF86ConfVideoPortPtr
);
200 Error(UNEXPECTED_EOF_MSG
);
203 Error(INVALID_KEYWORD_MSG
, xf86tokenString());
212 printf("VideoAdaptor section parsed\n");
219 xf86printVideoAdaptorSection(FILE * cf
, XF86ConfVideoAdaptorPtr ptr
)
221 XF86ConfVideoPortPtr pptr
;
224 fprintf(cf
, "Section \"VideoAdaptor\"\n");
226 fprintf(cf
, "%s", ptr
->va_comment
);
227 if (ptr
->va_identifier
)
228 fprintf(cf
, "\tIdentifier \"%s\"\n", ptr
->va_identifier
);
230 fprintf(cf
, "\tVendorName \"%s\"\n", ptr
->va_vendor
);
232 fprintf(cf
, "\tBoardName \"%s\"\n", ptr
->va_board
);
234 fprintf(cf
, "\tBusID \"%s\"\n", ptr
->va_busid
);
236 fprintf(cf
, "\tDriver \"%s\"\n", ptr
->va_driver
);
237 xf86printOptionList(cf
, ptr
->va_option_lst
, 1);
238 for (pptr
= ptr
->va_port_lst
; pptr
; pptr
= pptr
->list
.next
) {
239 fprintf(cf
, "\tSubSection \"VideoPort\"\n");
240 if (pptr
->vp_comment
)
241 fprintf(cf
, "%s", pptr
->vp_comment
);
242 if (pptr
->vp_identifier
)
243 fprintf(cf
, "\t\tIdentifier \"%s\"\n", pptr
->vp_identifier
);
244 xf86printOptionList(cf
, pptr
->vp_option_lst
, 2);
245 fprintf(cf
, "\tEndSubSection\n");
247 fprintf(cf
, "EndSection\n\n");
248 ptr
= ptr
->list
.next
;
254 xf86freeVideoAdaptorList(XF86ConfVideoAdaptorPtr ptr
)
256 XF86ConfVideoAdaptorPtr prev
;
259 TestFree(ptr
->va_identifier
);
260 TestFree(ptr
->va_vendor
);
261 TestFree(ptr
->va_board
);
262 TestFree(ptr
->va_busid
);
263 TestFree(ptr
->va_driver
);
264 TestFree(ptr
->va_fwdref
);
265 TestFree(ptr
->va_comment
);
266 xf86freeVideoPortList(ptr
->va_port_lst
);
267 xf86optionListFree(ptr
->va_option_lst
);
269 ptr
= ptr
->list
.next
;
274 XF86ConfVideoAdaptorPtr
275 xf86findVideoAdaptor(const char *ident
, XF86ConfVideoAdaptorPtr p
)
278 if (xf86nameCompare(ident
, p
->va_identifier
) == 0)