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"
69 xf86ConfigSymTabRec InputTab
[] =
71 {ENDSECTION
, "endsection"},
72 {IDENTIFIER
, "identifier"},
78 #define CLEANUP xf86freeInputList
81 xf86parseInputSection (void)
83 int has_ident
= FALSE
;
85 parsePrologue (XF86ConfInputPtr
, XF86ConfInputRec
)
87 while ((token
= xf86getToken (InputTab
)) != ENDSECTION
)
92 ptr
->inp_comment
= xf86addComment(ptr
->inp_comment
, val
.str
);
95 if (xf86getSubToken (&(ptr
->inp_comment
)) != STRING
)
96 Error (QUOTE_MSG
, "Identifier");
97 if (has_ident
== TRUE
)
98 Error (MULTIPLE_MSG
, "Identifier");
99 ptr
->inp_identifier
= val
.str
;
103 if (xf86getSubToken (&(ptr
->inp_comment
)) != STRING
)
104 Error (QUOTE_MSG
, "Driver");
105 if (strcmp(val
.str
, "keyboard") == 0)
106 ptr
->inp_driver
= "kbd";
108 ptr
->inp_driver
= val
.str
;
111 ptr
->inp_option_lst
= xf86parseOption(ptr
->inp_option_lst
);
114 Error (UNEXPECTED_EOF_MSG
, NULL
);
117 Error (INVALID_KEYWORD_MSG
, xf86tokenString ());
123 Error (NO_IDENT_MSG
, NULL
);
126 printf ("InputDevice section parsed\n");
135 xf86printInputSection (FILE * cf
, XF86ConfInputPtr ptr
)
139 fprintf (cf
, "Section \"InputDevice\"\n");
140 if (ptr
->inp_comment
)
141 fprintf (cf
, "%s", ptr
->inp_comment
);
142 if (ptr
->inp_identifier
)
143 fprintf (cf
, "\tIdentifier \"%s\"\n", ptr
->inp_identifier
);
145 fprintf (cf
, "\tDriver \"%s\"\n", ptr
->inp_driver
);
146 xf86printOptionList(cf
, ptr
->inp_option_lst
, 1);
147 fprintf (cf
, "EndSection\n\n");
148 ptr
= ptr
->list
.next
;
153 xf86freeInputList (XF86ConfInputPtr ptr
)
155 XF86ConfInputPtr prev
;
159 TestFree (ptr
->inp_identifier
);
160 TestFree (ptr
->inp_driver
);
161 TestFree (ptr
->inp_comment
);
162 xf86optionListFree (ptr
->inp_option_lst
);
165 ptr
= ptr
->list
.next
;
171 xf86validateInput (XF86ConfigPtr p
)
173 XF86ConfInputPtr input
= p
->conf_input_lst
;
175 #if 0 /* Enable this later */
177 xf86validationError ("At least one InputDevice section is required.");
183 if (!input
->inp_driver
) {
184 xf86validationError (UNDEFINED_INPUTDRIVER_MSG
, input
->inp_identifier
);
187 input
= input
->list
.next
;
193 xf86findInput (const char *ident
, XF86ConfInputPtr p
)
197 if (xf86nameCompare (ident
, p
->inp_identifier
) == 0)
206 xf86findInputByDriver (const char *driver
, XF86ConfInputPtr p
)
210 if (xf86nameCompare (driver
, p
->inp_driver
) == 0)