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).
56 /* View/edit this file with tab stops set to 4 */
58 #ifdef HAVE_XORG_CONFIG_H
59 #include <xorg-config.h>
62 #include "xf86Parser.h"
63 #include "xf86tokens.h"
64 #include "Configint.h"
68 static xf86ConfigSymTabRec VendorSubTab
[] =
70 {ENDSUBSECTION
, "endsubsection"},
71 {IDENTIFIER
, "identifier"},
76 #define CLEANUP xf86freeVendorSubList
78 static XF86ConfVendSubPtr
79 xf86parseVendorSubSection (void)
81 int has_ident
= FALSE
;
83 parsePrologue (XF86ConfVendSubPtr
, XF86ConfVendSubRec
)
85 while ((token
= xf86getToken (VendorSubTab
)) != ENDSUBSECTION
)
90 ptr
->vs_comment
= xf86addComment(ptr
->vs_comment
, val
.str
);
93 if (xf86getSubToken (&(ptr
->vs_comment
)))
94 Error (QUOTE_MSG
, "Identifier");
95 if (has_ident
== TRUE
)
96 Error (MULTIPLE_MSG
, "Identifier");
97 ptr
->vs_identifier
= val
.str
;
101 ptr
->vs_option_lst
= xf86parseOption(ptr
->vs_option_lst
);
105 Error (UNEXPECTED_EOF_MSG
, NULL
);
108 Error (INVALID_KEYWORD_MSG
, xf86tokenString ());
114 printf ("Vendor subsection parsed\n");
122 static xf86ConfigSymTabRec VendorTab
[] =
124 {ENDSECTION
, "endsection"},
125 {IDENTIFIER
, "identifier"},
127 {SUBSECTION
, "subsection"},
131 #define CLEANUP xf86freeVendorList
134 xf86parseVendorSection (void)
136 int has_ident
= FALSE
;
138 parsePrologue (XF86ConfVendorPtr
, XF86ConfVendorRec
)
140 while ((token
= xf86getToken (VendorTab
)) != ENDSECTION
)
145 ptr
->vnd_comment
= xf86addComment(ptr
->vnd_comment
, val
.str
);
148 if (xf86getSubToken (&(ptr
->vnd_comment
)) != STRING
)
149 Error (QUOTE_MSG
, "Identifier");
150 if (has_ident
== TRUE
)
151 Error (MULTIPLE_MSG
, "Identifier");
152 ptr
->vnd_identifier
= val
.str
;
156 ptr
->vnd_option_lst
= xf86parseOption(ptr
->vnd_option_lst
);
159 if (xf86getSubToken (&(ptr
->vnd_comment
)) != STRING
)
160 Error (QUOTE_MSG
, "SubSection");
162 HANDLE_LIST (vnd_sub_lst
, xf86parseVendorSubSection
,
167 Error (UNEXPECTED_EOF_MSG
, NULL
);
170 Error (INVALID_KEYWORD_MSG
, xf86tokenString ());
177 Error (NO_IDENT_MSG
, NULL
);
180 printf ("Vendor section parsed\n");
189 xf86printVendorSection (FILE * cf
, XF86ConfVendorPtr ptr
)
191 XF86ConfVendSubPtr pptr
;
195 fprintf (cf
, "Section \"Vendor\"\n");
196 if (ptr
->vnd_comment
)
197 fprintf (cf
, "%s", ptr
->vnd_comment
);
198 if (ptr
->vnd_identifier
)
199 fprintf (cf
, "\tIdentifier \"%s\"\n", ptr
->vnd_identifier
);
201 xf86printOptionList(cf
, ptr
->vnd_option_lst
, 1);
202 for (pptr
= ptr
->vnd_sub_lst
; pptr
; pptr
= pptr
->list
.next
)
204 fprintf (cf
, "\tSubSection \"Vendor\"\n");
205 if (pptr
->vs_comment
)
206 fprintf (cf
, "%s", pptr
->vs_comment
);
207 if (pptr
->vs_identifier
)
208 fprintf (cf
, "\t\tIdentifier \"%s\"\n", pptr
->vs_identifier
);
209 xf86printOptionList(cf
, pptr
->vs_option_lst
, 2);
210 fprintf (cf
, "\tEndSubSection\n");
212 fprintf (cf
, "EndSection\n\n");
213 ptr
= ptr
->list
.next
;
218 xf86freeVendorList (XF86ConfVendorPtr p
)
222 xf86freeVendorSubList (p
->vnd_sub_lst
);
223 TestFree (p
->vnd_identifier
);
224 TestFree (p
->vnd_comment
);
225 xf86optionListFree (p
->vnd_option_lst
);
230 xf86freeVendorSubList (XF86ConfVendSubPtr ptr
)
232 XF86ConfVendSubPtr prev
;
236 TestFree (ptr
->vs_identifier
);
237 TestFree (ptr
->vs_name
);
238 TestFree (ptr
->vs_comment
);
239 xf86optionListFree (ptr
->vs_option_lst
);
241 ptr
= ptr
->list
.next
;