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 /* View/edit this file with tab stops set to 4 */
57 #ifdef HAVE_XORG_CONFIG_H
58 #include <xorg-config.h>
61 #include "xf86Parser.h"
62 #include "xf86tokens.h"
63 #include "Configint.h"
67 static xf86ConfigSymTabRec VideoPortTab
[] =
69 {ENDSUBSECTION
, "endsubsection"},
70 {IDENTIFIER
, "identifier"},
75 #define CLEANUP xf86freeVideoPortList
78 xf86freeVideoPortList (XF86ConfVideoPortPtr ptr
)
80 XF86ConfVideoPortPtr prev
;
84 TestFree (ptr
->vp_identifier
);
85 TestFree (ptr
->vp_comment
);
86 xf86optionListFree (ptr
->vp_option_lst
);
93 static XF86ConfVideoPortPtr
94 xf86parseVideoPortSubSection (void)
96 int has_ident
= FALSE
;
98 parsePrologue (XF86ConfVideoPortPtr
, XF86ConfVideoPortRec
)
100 while ((token
= xf86getToken (VideoPortTab
)) != ENDSUBSECTION
)
105 ptr
->vp_comment
= xf86addComment(ptr
->vp_comment
, val
.str
);
108 if (xf86getSubToken (&(ptr
->vp_comment
)) != STRING
)
109 Error (QUOTE_MSG
, "Identifier");
110 if (has_ident
== TRUE
)
111 Error (MULTIPLE_MSG
, "Identifier");
112 ptr
->vp_identifier
= val
.str
;
116 ptr
->vp_option_lst
= xf86parseOption(ptr
->vp_option_lst
);
120 Error (UNEXPECTED_EOF_MSG
, NULL
);
123 Error (INVALID_KEYWORD_MSG
, xf86tokenString ());
129 printf ("VideoPort subsection parsed\n");
137 static xf86ConfigSymTabRec VideoAdaptorTab
[] =
139 {ENDSECTION
, "endsection"},
140 {IDENTIFIER
, "identifier"},
141 {VENDOR
, "vendorname"},
142 {BOARD
, "boardname"},
146 {SUBSECTION
, "subsection"},
150 #define CLEANUP xf86freeVideoAdaptorList
152 XF86ConfVideoAdaptorPtr
153 xf86parseVideoAdaptorSection (void)
155 int has_ident
= FALSE
;
158 parsePrologue (XF86ConfVideoAdaptorPtr
, XF86ConfVideoAdaptorRec
)
160 while ((token
= xf86getToken (VideoAdaptorTab
)) != ENDSECTION
)
165 ptr
->va_comment
= xf86addComment(ptr
->va_comment
, val
.str
);
168 if (xf86getSubToken (&(ptr
->va_comment
)) != STRING
)
169 Error (QUOTE_MSG
, "Identifier");
170 ptr
->va_identifier
= val
.str
;
171 if (has_ident
== TRUE
)
172 Error (MULTIPLE_MSG
, "Identifier");
176 if (xf86getSubToken (&(ptr
->va_comment
)) != STRING
)
177 Error (QUOTE_MSG
, "Vendor");
178 ptr
->va_vendor
= val
.str
;
181 if (xf86getSubToken (&(ptr
->va_comment
)) != STRING
)
182 Error (QUOTE_MSG
, "Board");
183 ptr
->va_board
= val
.str
;
186 if (xf86getSubToken (&(ptr
->va_comment
)) != STRING
)
187 Error (QUOTE_MSG
, "BusID");
188 ptr
->va_busid
= val
.str
;
191 if (xf86getSubToken (&(ptr
->va_comment
)) != STRING
)
192 Error (QUOTE_MSG
, "Driver");
193 ptr
->va_driver
= val
.str
;
196 ptr
->va_option_lst
= xf86parseOption(ptr
->va_option_lst
);
199 if (xf86getSubToken (&(ptr
->va_comment
)) != STRING
)
200 Error (QUOTE_MSG
, "SubSection");
202 HANDLE_LIST (va_port_lst
, xf86parseVideoPortSubSection
,
203 XF86ConfVideoPortPtr
);
208 Error (UNEXPECTED_EOF_MSG
, NULL
);
211 Error (INVALID_KEYWORD_MSG
, xf86tokenString ());
217 Error (NO_IDENT_MSG
, NULL
);
220 printf ("VideoAdaptor section parsed\n");
227 xf86printVideoAdaptorSection (FILE * cf
, XF86ConfVideoAdaptorPtr ptr
)
229 XF86ConfVideoPortPtr pptr
;
233 fprintf (cf
, "Section \"VideoAdaptor\"\n");
235 fprintf (cf
, "%s", ptr
->va_comment
);
236 if (ptr
->va_identifier
)
237 fprintf (cf
, "\tIdentifier \"%s\"\n", ptr
->va_identifier
);
239 fprintf (cf
, "\tVendorName \"%s\"\n", ptr
->va_vendor
);
241 fprintf (cf
, "\tBoardName \"%s\"\n", ptr
->va_board
);
243 fprintf (cf
, "\tBusID \"%s\"\n", ptr
->va_busid
);
245 fprintf (cf
, "\tDriver \"%s\"\n", ptr
->va_driver
);
246 xf86printOptionList(cf
, ptr
->va_option_lst
, 1);
247 for (pptr
= ptr
->va_port_lst
; pptr
; pptr
= pptr
->list
.next
)
249 fprintf (cf
, "\tSubSection \"VideoPort\"\n");
250 if (pptr
->vp_comment
)
251 fprintf (cf
, "%s", pptr
->vp_comment
);
252 if (pptr
->vp_identifier
)
253 fprintf (cf
, "\t\tIdentifier \"%s\"\n", pptr
->vp_identifier
);
254 xf86printOptionList(cf
, pptr
->vp_option_lst
, 2);
255 fprintf (cf
, "\tEndSubSection\n");
257 fprintf (cf
, "EndSection\n\n");
258 ptr
= ptr
->list
.next
;
264 xf86freeVideoAdaptorList (XF86ConfVideoAdaptorPtr ptr
)
266 XF86ConfVideoAdaptorPtr prev
;
270 TestFree (ptr
->va_identifier
);
271 TestFree (ptr
->va_vendor
);
272 TestFree (ptr
->va_board
);
273 TestFree (ptr
->va_busid
);
274 TestFree (ptr
->va_driver
);
275 TestFree (ptr
->va_fwdref
);
276 TestFree (ptr
->va_comment
);
277 xf86freeVideoPortList (ptr
->va_port_lst
);
278 xf86optionListFree (ptr
->va_option_lst
);
280 ptr
= ptr
->list
.next
;
285 XF86ConfVideoAdaptorPtr
286 xf86findVideoAdaptor (const char *ident
, XF86ConfVideoAdaptorPtr p
)
290 if (xf86nameCompare (ident
, p
->va_identifier
) == 0)