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>
60 #include "xf86Parser.h"
61 #include "xf86tokens.h"
62 #include "Configint.h"
67 xf86ConfigSymTabRec InputTab
[] = {
68 {ENDSECTION
, "endsection"},
69 {IDENTIFIER
, "identifier"},
75 #define CLEANUP xf86freeInputList
78 xf86parseInputSection(void)
80 int has_ident
= FALSE
;
83 parsePrologue(XF86ConfInputPtr
, XF86ConfInputRec
)
85 while ((token
= xf86getToken(InputTab
)) != ENDSECTION
) {
88 ptr
->inp_comment
= xf86addComment(ptr
->inp_comment
, val
.str
);
91 if (xf86getSubToken(&(ptr
->inp_comment
)) != STRING
)
92 Error(QUOTE_MSG
, "Identifier");
93 if (has_ident
== TRUE
)
94 Error(MULTIPLE_MSG
, "Identifier");
95 ptr
->inp_identifier
= val
.str
;
99 if (xf86getSubToken(&(ptr
->inp_comment
)) != STRING
)
100 Error(QUOTE_MSG
, "Driver");
101 if (strcmp(val
.str
, "keyboard") == 0) {
102 ptr
->inp_driver
= strdup("kbd");
106 ptr
->inp_driver
= val
.str
;
109 ptr
->inp_option_lst
= xf86parseOption(ptr
->inp_option_lst
);
112 Error(UNEXPECTED_EOF_MSG
);
115 Error(INVALID_KEYWORD_MSG
, xf86tokenString());
124 printf("InputDevice section parsed\n");
133 xf86printInputSection(FILE * cf
, XF86ConfInputPtr ptr
)
136 fprintf(cf
, "Section \"InputDevice\"\n");
137 if (ptr
->inp_comment
)
138 fprintf(cf
, "%s", ptr
->inp_comment
);
139 if (ptr
->inp_identifier
)
140 fprintf(cf
, "\tIdentifier \"%s\"\n", ptr
->inp_identifier
);
142 fprintf(cf
, "\tDriver \"%s\"\n", ptr
->inp_driver
);
143 xf86printOptionList(cf
, ptr
->inp_option_lst
, 1);
144 fprintf(cf
, "EndSection\n\n");
145 ptr
= ptr
->list
.next
;
150 xf86freeInputList(XF86ConfInputPtr ptr
)
152 XF86ConfInputPtr prev
;
155 TestFree(ptr
->inp_identifier
);
156 TestFree(ptr
->inp_driver
);
157 TestFree(ptr
->inp_comment
);
158 xf86optionListFree(ptr
->inp_option_lst
);
161 ptr
= ptr
->list
.next
;
167 xf86validateInput(XF86ConfigPtr p
)
169 XF86ConfInputPtr input
= p
->conf_input_lst
;
172 if (!input
->inp_driver
) {
173 xf86validationError(UNDEFINED_INPUTDRIVER_MSG
,
174 input
->inp_identifier
);
177 input
= input
->list
.next
;
183 xf86findInput(const char *ident
, XF86ConfInputPtr p
)
186 if (xf86nameCompare(ident
, p
->inp_identifier
) == 0)
195 xf86findInputByDriver(const char *driver
, XF86ConfInputPtr p
)
198 if (xf86nameCompare(driver
, p
->inp_driver
) == 0)