1117N/A/*
1117N/A *
1117N/A * Copyright (c) 1997 Metro Link Incorporated
1117N/A *
1117N/A * Permission is hereby granted, free of charge, to any person obtaining a
1117N/A * copy of this software and associated documentation files (the "Software"),
1117N/A * to deal in the Software without restriction, including without limitation
1117N/A * the rights to use, copy, modify, merge, publish, distribute, sublicense,
1117N/A * and/or sell copies of the Software, and to permit persons to whom the
1117N/A * Software is furnished to do so, subject to the following conditions:
1117N/A *
1117N/A * The above copyright notice and this permission notice shall be included in
1117N/A * all copies or substantial portions of the Software.
1117N/A *
1117N/A * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
1117N/A * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
1117N/A * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
1117N/A * THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
1117N/A * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
1117N/A * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
1117N/A * SOFTWARE.
1117N/A *
1117N/A * Except as contained in this notice, the name of the Metro Link shall not be
1117N/A * used in advertising or otherwise to promote the sale, use or other dealings
1117N/A * in this Software without prior written authorization from Metro Link.
1117N/A *
1117N/A */
1117N/A/*
1117N/A * Copyright (c) 1997-2003 by The XFree86 Project, Inc.
1117N/A *
1117N/A * Permission is hereby granted, free of charge, to any person obtaining a
1117N/A * copy of this software and associated documentation files (the "Software"),
1117N/A * to deal in the Software without restriction, including without limitation
1117N/A * the rights to use, copy, modify, merge, publish, distribute, sublicense,
1117N/A * and/or sell copies of the Software, and to permit persons to whom the
1117N/A * Software is furnished to do so, subject to the following conditions:
1117N/A *
1117N/A * The above copyright notice and this permission notice shall be included in
1117N/A * all copies or substantial portions of the Software.
1117N/A *
1117N/A * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
1117N/A * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
1117N/A * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
1117N/A * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
1117N/A * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
1117N/A * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
1117N/A * OTHER DEALINGS IN THE SOFTWARE.
1117N/A *
1117N/A * Except as contained in this notice, the name of the copyright holder(s)
1117N/A * and author(s) shall not be used in advertising or otherwise to promote
1117N/A * the sale, use or other dealings in this Software without prior written
1117N/A * authorization from the copyright holder(s) and author(s).
1117N/A */
1117N/A
1117N/A
1117N/A/* View/edit this file with tab stops set to 4 */
1117N/A
1117N/A#ifdef HAVE_XORG_CONFIG_H
1117N/A#include <xorg-config.h>
1117N/A#endif
1117N/A
1117N/A#include "xf86Parser.h"
1117N/A#include "xf86tokens.h"
1117N/A#include "Configint.h"
1117N/A#include "fields.h" /* Config file output line fields */
1117N/A
1117N/Aextern LexRec val;
1117N/A
1117N/Astatic
1117N/Axf86ConfigSymTabRec InputTab[] =
1117N/A{
1117N/A {ENDSECTION, "endsection"},
1117N/A {IDENTIFIER, "identifier"},
1117N/A {OPTION, "option"},
1117N/A {DRIVER, "driver"},
1117N/A {-1, ""},
1117N/A};
1117N/A
1117N/A#define CLEANUP xf86freeInputList
1117N/A
1117N/AXF86ConfInputPtr
1117N/Axf86parseInputSection (void)
1117N/A{
1117N/A int has_ident = FALSE;
1117N/A int token;
1117N/A parsePrologue (XF86ConfInputPtr, XF86ConfInputRec)
1117N/A
1117N/A while ((token = xf86getToken (InputTab)) != ENDSECTION)
1117N/A {
1117N/A switch (token)
1117N/A {
1117N/A case COMMENT:
1117N/A ptr->inp_comment = xf86addComment(ptr->inp_comment, val.str);
1117N/A break;
1117N/A case IDENTIFIER:
1117N/A if (xf86getSubToken (&(ptr->inp_comment)) != STRING)
1117N/A Error (QUOTE_MSG, "Identifier");
1117N/A if (has_ident == TRUE)
1117N/A Error (MULTIPLE_MSG, "Identifier");
1117N/A ptr->inp_identifier = val.str;
1117N/A has_ident = TRUE;
1117N/A break;
1117N/A case DRIVER:
1117N/A if (xf86getSubToken (&(ptr->inp_comment)) != STRING)
1117N/A Error (QUOTE_MSG, "Driver");
1117N/A ptr->inp_driver = val.str;
1117N/A break;
1117N/A case OPTION:
1117N/A ptr->inp_option_lst = xf86parseOption(ptr->inp_option_lst);
1117N/A break;
1117N/A case EOF_TOKEN:
1117N/A Error (UNEXPECTED_EOF_MSG, NULL);
1117N/A break;
1117N/A default:
1117N/A Error (INVALID_KEYWORD_MSG, xf86tokenString ());
1117N/A break;
1117N/A }
1117N/A }
1117N/A
1117N/A if (!has_ident)
1117N/A Error (NO_IDENT_MSG, NULL);
1117N/A
1117N/A#ifdef DEBUG
1117N/A printf ("InputDevice section parsed\n");
1117N/A#endif
1117N/A
1117N/A return ptr;
1117N/A}
1117N/A
1117N/A#undef CLEANUP
1117N/A
1117N/Avoid
1117N/Axf86printInputSection (FILE * cf, XF86ConfInputPtr ptr)
1117N/A{
1117N/A while (ptr)
1117N/A {
1117N/A fprintf (cf, "Section \"InputDevice\"\n");
1117N/A if (ptr->inp_comment)
1117N/A fprintf (cf, "%s", ptr->inp_comment);
1117N/A if (ptr->inp_identifier)
1117N/A fprintf (cf, "\tIdentifier \"%s\"\n", ptr->inp_identifier);
1117N/A if (ptr->inp_driver)
1117N/A fprintf (cf, "\tDriver \"%s\"\n", ptr->inp_driver);
1117N/A xf86printOptionList(cf, ptr->inp_option_lst, xf86whitespace_1);
1117N/A fprintf (cf, "EndSection\n\n");
1117N/A ptr = ptr->list.next;
1117N/A }
1117N/A}
1117N/A
1117N/Avoid
1117N/Axf86freeInputList (XF86ConfInputPtr ptr)
1117N/A{
1117N/A XF86ConfInputPtr prev;
1117N/A
1117N/A while (ptr)
1117N/A {
1117N/A TestFree (ptr->inp_identifier);
1117N/A TestFree (ptr->inp_driver);
1117N/A TestFree (ptr->inp_comment);
1117N/A xf86optionListFree (ptr->inp_option_lst);
1117N/A
1117N/A prev = ptr;
1117N/A ptr = ptr->list.next;
1117N/A xf86conffree (prev);
1117N/A }
1117N/A}
1117N/A
1117N/Aint
1117N/Axf86validateInput (XF86ConfigPtr p)
1117N/A{
1117N/A XF86ConfInputPtr input = p->conf_input_lst;
1117N/A
1117N/A#if 0 /* Enable this later */
1117N/A if (!input) {
1117N/A xf86validationError ("At least one InputDevice section is required.");
1117N/A return (FALSE);
1117N/A }
1117N/A#endif
1117N/A
1117N/A while (input) {
1117N/A if (!input->inp_driver) {
1117N/A xf86validationError (UNDEFINED_INPUTDRIVER_MSG, input->inp_identifier);
1117N/A return (FALSE);
1117N/A }
1117N/A input = input->list.next;
1117N/A }
1117N/A return (TRUE);
1117N/A}
1117N/A
1117N/AXF86ConfInputPtr
1117N/Axf86findInput (const char *ident, XF86ConfInputPtr p)
1117N/A{
1117N/A while (p)
1117N/A {
1117N/A if (xf86nameCompare (ident, p->inp_identifier) == 0)
1117N/A return (p);
1117N/A
1117N/A p = p->list.next;
1117N/A }
1117N/A return (NULL);
1117N/A}
1117N/A
1117N/AXF86ConfInputPtr
1117N/Axf86findInputByDriver (const char *driver, XF86ConfInputPtr p)
1117N/A{
1117N/A while (p)
1117N/A {
1117N/A if (xf86nameCompare (driver, p->inp_driver) == 0)
1117N/A return (p);
1117N/A
1117N/A p = p->list.next;
1117N/A }
1117N/A return (NULL);
1117N/A}
1117N/A