45e9809aff7304721fddb95654901b32195c9c7avboxsync/*
45e9809aff7304721fddb95654901b32195c9c7avboxsync *
45e9809aff7304721fddb95654901b32195c9c7avboxsync * Copyright (c) 1997 Metro Link Incorporated
45e9809aff7304721fddb95654901b32195c9c7avboxsync *
45e9809aff7304721fddb95654901b32195c9c7avboxsync * Permission is hereby granted, free of charge, to any person obtaining a
45e9809aff7304721fddb95654901b32195c9c7avboxsync * copy of this software and associated documentation files (the "Software"),
45e9809aff7304721fddb95654901b32195c9c7avboxsync * to deal in the Software without restriction, including without limitation
45e9809aff7304721fddb95654901b32195c9c7avboxsync * the rights to use, copy, modify, merge, publish, distribute, sublicense,
45e9809aff7304721fddb95654901b32195c9c7avboxsync * and/or sell copies of the Software, and to permit persons to whom the
45e9809aff7304721fddb95654901b32195c9c7avboxsync * Software is furnished to do so, subject to the following conditions:
45e9809aff7304721fddb95654901b32195c9c7avboxsync *
45e9809aff7304721fddb95654901b32195c9c7avboxsync * The above copyright notice and this permission notice shall be included in
45e9809aff7304721fddb95654901b32195c9c7avboxsync * all copies or substantial portions of the Software.
45e9809aff7304721fddb95654901b32195c9c7avboxsync *
45e9809aff7304721fddb95654901b32195c9c7avboxsync * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
45e9809aff7304721fddb95654901b32195c9c7avboxsync * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
45e9809aff7304721fddb95654901b32195c9c7avboxsync * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
45e9809aff7304721fddb95654901b32195c9c7avboxsync * THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
45e9809aff7304721fddb95654901b32195c9c7avboxsync * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
45e9809aff7304721fddb95654901b32195c9c7avboxsync * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
45e9809aff7304721fddb95654901b32195c9c7avboxsync * SOFTWARE.
45e9809aff7304721fddb95654901b32195c9c7avboxsync *
45e9809aff7304721fddb95654901b32195c9c7avboxsync * Except as contained in this notice, the name of the Metro Link shall not be
45e9809aff7304721fddb95654901b32195c9c7avboxsync * used in advertising or otherwise to promote the sale, use or other dealings
45e9809aff7304721fddb95654901b32195c9c7avboxsync * in this Software without prior written authorization from Metro Link.
45e9809aff7304721fddb95654901b32195c9c7avboxsync *
45e9809aff7304721fddb95654901b32195c9c7avboxsync */
45e9809aff7304721fddb95654901b32195c9c7avboxsync/*
45e9809aff7304721fddb95654901b32195c9c7avboxsync * Copyright (c) 1997-2002 by The XFree86 Project, Inc.
45e9809aff7304721fddb95654901b32195c9c7avboxsync *
45e9809aff7304721fddb95654901b32195c9c7avboxsync * Permission is hereby granted, free of charge, to any person obtaining a
45e9809aff7304721fddb95654901b32195c9c7avboxsync * copy of this software and associated documentation files (the "Software"),
45e9809aff7304721fddb95654901b32195c9c7avboxsync * to deal in the Software without restriction, including without limitation
45e9809aff7304721fddb95654901b32195c9c7avboxsync * the rights to use, copy, modify, merge, publish, distribute, sublicense,
45e9809aff7304721fddb95654901b32195c9c7avboxsync * and/or sell copies of the Software, and to permit persons to whom the
45e9809aff7304721fddb95654901b32195c9c7avboxsync * Software is furnished to do so, subject to the following conditions:
45e9809aff7304721fddb95654901b32195c9c7avboxsync *
45e9809aff7304721fddb95654901b32195c9c7avboxsync * The above copyright notice and this permission notice shall be included in
45e9809aff7304721fddb95654901b32195c9c7avboxsync * all copies or substantial portions of the Software.
45e9809aff7304721fddb95654901b32195c9c7avboxsync *
45e9809aff7304721fddb95654901b32195c9c7avboxsync * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
45e9809aff7304721fddb95654901b32195c9c7avboxsync * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
45e9809aff7304721fddb95654901b32195c9c7avboxsync * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
45e9809aff7304721fddb95654901b32195c9c7avboxsync * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
45e9809aff7304721fddb95654901b32195c9c7avboxsync * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
45e9809aff7304721fddb95654901b32195c9c7avboxsync * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
45e9809aff7304721fddb95654901b32195c9c7avboxsync * OTHER DEALINGS IN THE SOFTWARE.
45e9809aff7304721fddb95654901b32195c9c7avboxsync *
45e9809aff7304721fddb95654901b32195c9c7avboxsync * Except as contained in this notice, the name of the copyright holder(s)
45e9809aff7304721fddb95654901b32195c9c7avboxsync * and author(s) shall not be used in advertising or otherwise to promote
45e9809aff7304721fddb95654901b32195c9c7avboxsync * the sale, use or other dealings in this Software without prior written
45e9809aff7304721fddb95654901b32195c9c7avboxsync * authorization from the copyright holder(s) and author(s).
45e9809aff7304721fddb95654901b32195c9c7avboxsync */
45e9809aff7304721fddb95654901b32195c9c7avboxsync
45e9809aff7304721fddb95654901b32195c9c7avboxsync
45e9809aff7304721fddb95654901b32195c9c7avboxsync/*
45e9809aff7304721fddb95654901b32195c9c7avboxsync * These definitions are used through out the configuration file parser, but
45e9809aff7304721fddb95654901b32195c9c7avboxsync * they should not be visible outside of the parser.
45e9809aff7304721fddb95654901b32195c9c7avboxsync */
45e9809aff7304721fddb95654901b32195c9c7avboxsync
45e9809aff7304721fddb95654901b32195c9c7avboxsync#ifdef HAVE_XORG_CONFIG_H
45e9809aff7304721fddb95654901b32195c9c7avboxsync#include <xorg-config.h>
45e9809aff7304721fddb95654901b32195c9c7avboxsync#endif
45e9809aff7304721fddb95654901b32195c9c7avboxsync
45e9809aff7304721fddb95654901b32195c9c7avboxsync#ifndef _Configint_h_
45e9809aff7304721fddb95654901b32195c9c7avboxsync#define _Configint_h_
45e9809aff7304721fddb95654901b32195c9c7avboxsync
45e9809aff7304721fddb95654901b32195c9c7avboxsync#include <stdio.h>
45e9809aff7304721fddb95654901b32195c9c7avboxsync#include <string.h>
45e9809aff7304721fddb95654901b32195c9c7avboxsync#include <stdarg.h>
45e9809aff7304721fddb95654901b32195c9c7avboxsync#include <stddef.h>
45e9809aff7304721fddb95654901b32195c9c7avboxsync#include "xf86Parser.h"
45e9809aff7304721fddb95654901b32195c9c7avboxsync
45e9809aff7304721fddb95654901b32195c9c7avboxsynctypedef enum { PARSE_DECIMAL, PARSE_OCTAL, PARSE_HEX } ParserNumType;
45e9809aff7304721fddb95654901b32195c9c7avboxsync
45e9809aff7304721fddb95654901b32195c9c7avboxsynctypedef struct
45e9809aff7304721fddb95654901b32195c9c7avboxsync{
45e9809aff7304721fddb95654901b32195c9c7avboxsync int num; /* returned number */
45e9809aff7304721fddb95654901b32195c9c7avboxsync char *str; /* private copy of the return-string */
45e9809aff7304721fddb95654901b32195c9c7avboxsync double realnum; /* returned number as a real */
45e9809aff7304721fddb95654901b32195c9c7avboxsync ParserNumType numType; /* used to enforce correct number formatting */
45e9809aff7304721fddb95654901b32195c9c7avboxsync}
45e9809aff7304721fddb95654901b32195c9c7avboxsyncLexRec, *LexPtr;
45e9809aff7304721fddb95654901b32195c9c7avboxsync
45e9809aff7304721fddb95654901b32195c9c7avboxsync#ifndef TRUE
45e9809aff7304721fddb95654901b32195c9c7avboxsync#define TRUE 1
45e9809aff7304721fddb95654901b32195c9c7avboxsync#endif
45e9809aff7304721fddb95654901b32195c9c7avboxsync
45e9809aff7304721fddb95654901b32195c9c7avboxsync#ifndef FALSE
45e9809aff7304721fddb95654901b32195c9c7avboxsync#define FALSE 0
45e9809aff7304721fddb95654901b32195c9c7avboxsync#endif
45e9809aff7304721fddb95654901b32195c9c7avboxsync
45e9809aff7304721fddb95654901b32195c9c7avboxsync#include "configProcs.h"
45e9809aff7304721fddb95654901b32195c9c7avboxsync#include <stdlib.h>
45e9809aff7304721fddb95654901b32195c9c7avboxsync
45e9809aff7304721fddb95654901b32195c9c7avboxsync#define TestFree(a) if (a) { free (a); a = NULL; }
45e9809aff7304721fddb95654901b32195c9c7avboxsync
45e9809aff7304721fddb95654901b32195c9c7avboxsync#define parsePrologue(typeptr,typerec) typeptr ptr; \
45e9809aff7304721fddb95654901b32195c9c7avboxsyncif( (ptr=calloc(1,sizeof(typerec))) == NULL ) { return NULL; }
45e9809aff7304721fddb95654901b32195c9c7avboxsync
45e9809aff7304721fddb95654901b32195c9c7avboxsync#define parsePrologueVoid(typeptr,typerec) int token; typeptr ptr; \
45e9809aff7304721fddb95654901b32195c9c7avboxsyncif( (ptr=calloc(1,sizeof(typerec))) == NULL ) { return; }
45e9809aff7304721fddb95654901b32195c9c7avboxsync
45e9809aff7304721fddb95654901b32195c9c7avboxsync#define HANDLE_RETURN(f,func)\
45e9809aff7304721fddb95654901b32195c9c7avboxsyncif ((ptr->f=func) == NULL)\
45e9809aff7304721fddb95654901b32195c9c7avboxsync{\
45e9809aff7304721fddb95654901b32195c9c7avboxsync CLEANUP (ptr);\
45e9809aff7304721fddb95654901b32195c9c7avboxsync return (NULL);\
45e9809aff7304721fddb95654901b32195c9c7avboxsync}
45e9809aff7304721fddb95654901b32195c9c7avboxsync
45e9809aff7304721fddb95654901b32195c9c7avboxsync#define HANDLE_LIST(field,func,type)\
45e9809aff7304721fddb95654901b32195c9c7avboxsync{\
45e9809aff7304721fddb95654901b32195c9c7avboxsynctype p = func ();\
45e9809aff7304721fddb95654901b32195c9c7avboxsyncif (p == NULL)\
45e9809aff7304721fddb95654901b32195c9c7avboxsync{\
45e9809aff7304721fddb95654901b32195c9c7avboxsync CLEANUP (ptr);\
45e9809aff7304721fddb95654901b32195c9c7avboxsync return (NULL);\
45e9809aff7304721fddb95654901b32195c9c7avboxsync}\
45e9809aff7304721fddb95654901b32195c9c7avboxsyncelse\
45e9809aff7304721fddb95654901b32195c9c7avboxsync{\
45e9809aff7304721fddb95654901b32195c9c7avboxsync ptr->field = (type) xf86addListItem ((glp) ptr->field, (glp) p);\
45e9809aff7304721fddb95654901b32195c9c7avboxsync}\
45e9809aff7304721fddb95654901b32195c9c7avboxsync}
45e9809aff7304721fddb95654901b32195c9c7avboxsync
45e9809aff7304721fddb95654901b32195c9c7avboxsync#define Error(a,b) do { \
45e9809aff7304721fddb95654901b32195c9c7avboxsync xf86parseError (a, b); CLEANUP (ptr); return NULL; \
45e9809aff7304721fddb95654901b32195c9c7avboxsync } while (0)
45e9809aff7304721fddb95654901b32195c9c7avboxsync
45e9809aff7304721fddb95654901b32195c9c7avboxsync/*
45e9809aff7304721fddb95654901b32195c9c7avboxsync * These are defines for error messages to promote consistency.
45e9809aff7304721fddb95654901b32195c9c7avboxsync * error messages are preceded by the line number, section and file name,
45e9809aff7304721fddb95654901b32195c9c7avboxsync * so these messages should be about the specific keyword and syntax in error.
45e9809aff7304721fddb95654901b32195c9c7avboxsync * To help limit namespace polution, end each with _MSG.
45e9809aff7304721fddb95654901b32195c9c7avboxsync * limit messages to 70 characters if possible.
45e9809aff7304721fddb95654901b32195c9c7avboxsync */
45e9809aff7304721fddb95654901b32195c9c7avboxsync
45e9809aff7304721fddb95654901b32195c9c7avboxsync#define BAD_OPTION_MSG \
45e9809aff7304721fddb95654901b32195c9c7avboxsync"The Option keyword requires 1 or 2 quoted strings to follow it."
45e9809aff7304721fddb95654901b32195c9c7avboxsync#define INVALID_KEYWORD_MSG \
45e9809aff7304721fddb95654901b32195c9c7avboxsync"\"%s\" is not a valid keyword in this section."
45e9809aff7304721fddb95654901b32195c9c7avboxsync#define INVALID_SECTION_MSG \
45e9809aff7304721fddb95654901b32195c9c7avboxsync"\"%s\" is not a valid section name."
45e9809aff7304721fddb95654901b32195c9c7avboxsync#define UNEXPECTED_EOF_MSG \
45e9809aff7304721fddb95654901b32195c9c7avboxsync"Unexpected EOF. Missing EndSection keyword?"
45e9809aff7304721fddb95654901b32195c9c7avboxsync#define QUOTE_MSG \
45e9809aff7304721fddb95654901b32195c9c7avboxsync"The %s keyword requires a quoted string to follow it."
45e9809aff7304721fddb95654901b32195c9c7avboxsync#define NUMBER_MSG \
45e9809aff7304721fddb95654901b32195c9c7avboxsync"The %s keyword requires a number to follow it."
45e9809aff7304721fddb95654901b32195c9c7avboxsync#define POSITIVE_INT_MSG \
45e9809aff7304721fddb95654901b32195c9c7avboxsync"The %s keyword requires a positive integer to follow it."
45e9809aff7304721fddb95654901b32195c9c7avboxsync#define ZAXISMAPPING_MSG \
45e9809aff7304721fddb95654901b32195c9c7avboxsync"The ZAxisMapping keyword requires 2 positive numbers or X or Y to follow it."
45e9809aff7304721fddb95654901b32195c9c7avboxsync#define AUTOREPEAT_MSG \
45e9809aff7304721fddb95654901b32195c9c7avboxsync"The AutoRepeat keyword requires 2 numbers (delay and rate) to follow it."
45e9809aff7304721fddb95654901b32195c9c7avboxsync#define XLEDS_MSG \
45e9809aff7304721fddb95654901b32195c9c7avboxsync"The XLeds keyword requries one or more numbers to follow it."
45e9809aff7304721fddb95654901b32195c9c7avboxsync#define DACSPEED_MSG \
45e9809aff7304721fddb95654901b32195c9c7avboxsync"The DacSpeed keyword must be followed by a list of up to %d numbers."
45e9809aff7304721fddb95654901b32195c9c7avboxsync#define DISPLAYSIZE_MSG \
45e9809aff7304721fddb95654901b32195c9c7avboxsync"The DisplaySize keyword must be followed by the width and height in mm."
45e9809aff7304721fddb95654901b32195c9c7avboxsync#define HORIZSYNC_MSG \
45e9809aff7304721fddb95654901b32195c9c7avboxsync"The HorizSync keyword must be followed by a list of numbers or ranges."
45e9809aff7304721fddb95654901b32195c9c7avboxsync#define VERTREFRESH_MSG \
45e9809aff7304721fddb95654901b32195c9c7avboxsync"The VertRefresh keyword must be followed by a list of numbers or ranges."
45e9809aff7304721fddb95654901b32195c9c7avboxsync#define VIEWPORT_MSG \
45e9809aff7304721fddb95654901b32195c9c7avboxsync"The Viewport keyword must be followed by an X and Y value."
45e9809aff7304721fddb95654901b32195c9c7avboxsync#define VIRTUAL_MSG \
45e9809aff7304721fddb95654901b32195c9c7avboxsync"The Virtual keyword must be followed by a width and height value."
45e9809aff7304721fddb95654901b32195c9c7avboxsync#define WEIGHT_MSG \
45e9809aff7304721fddb95654901b32195c9c7avboxsync"The Weight keyword must be followed by red, green and blue values."
45e9809aff7304721fddb95654901b32195c9c7avboxsync#define BLACK_MSG \
45e9809aff7304721fddb95654901b32195c9c7avboxsync"The Black keyword must be followed by red, green and blue values."
45e9809aff7304721fddb95654901b32195c9c7avboxsync#define WHITE_MSG \
45e9809aff7304721fddb95654901b32195c9c7avboxsync"The White keyword must be followed by red, green and blue values."
45e9809aff7304721fddb95654901b32195c9c7avboxsync#define SCREEN_MSG \
45e9809aff7304721fddb95654901b32195c9c7avboxsync"The Screen keyword must be followed by an optional number, a screen name\n" \
45e9809aff7304721fddb95654901b32195c9c7avboxsync"\tin quotes, and optional position/layout information."
45e9809aff7304721fddb95654901b32195c9c7avboxsync#define INVALID_SCR_MSG \
45e9809aff7304721fddb95654901b32195c9c7avboxsync"Invalid Screen line."
45e9809aff7304721fddb95654901b32195c9c7avboxsync#define INPUTDEV_MSG \
45e9809aff7304721fddb95654901b32195c9c7avboxsync"The InputDevice keyword must be followed by an input device name in quotes."
45e9809aff7304721fddb95654901b32195c9c7avboxsync#define INACTIVE_MSG \
45e9809aff7304721fddb95654901b32195c9c7avboxsync"The Inactive keyword must be followed by a Device name in quotes."
45e9809aff7304721fddb95654901b32195c9c7avboxsync#define UNDEFINED_SCREEN_MSG \
45e9809aff7304721fddb95654901b32195c9c7avboxsync"Undefined Screen \"%s\" referenced by ServerLayout \"%s\"."
45e9809aff7304721fddb95654901b32195c9c7avboxsync#define UNDEFINED_MODES_MSG \
45e9809aff7304721fddb95654901b32195c9c7avboxsync"Undefined Modes Section \"%s\" referenced by Monitor \"%s\"."
45e9809aff7304721fddb95654901b32195c9c7avboxsync#define UNDEFINED_DEVICE_MSG \
45e9809aff7304721fddb95654901b32195c9c7avboxsync"Undefined Device \"%s\" referenced by Screen \"%s\"."
45e9809aff7304721fddb95654901b32195c9c7avboxsync#define UNDEFINED_ADAPTOR_MSG \
45e9809aff7304721fddb95654901b32195c9c7avboxsync"Undefined VideoAdaptor \"%s\" referenced by Screen \"%s\"."
45e9809aff7304721fddb95654901b32195c9c7avboxsync#define ADAPTOR_REF_TWICE_MSG \
45e9809aff7304721fddb95654901b32195c9c7avboxsync"VideoAdaptor \"%s\" already referenced by Screen \"%s\"."
45e9809aff7304721fddb95654901b32195c9c7avboxsync#define UNDEFINED_DEVICE_LAY_MSG \
45e9809aff7304721fddb95654901b32195c9c7avboxsync"Undefined Device \"%s\" referenced by ServerLayout \"%s\"."
45e9809aff7304721fddb95654901b32195c9c7avboxsync#define UNDEFINED_INPUT_MSG \
45e9809aff7304721fddb95654901b32195c9c7avboxsync"Undefined InputDevice \"%s\" referenced by ServerLayout \"%s\"."
45e9809aff7304721fddb95654901b32195c9c7avboxsync#define NO_IDENT_MSG \
45e9809aff7304721fddb95654901b32195c9c7avboxsync"This section must have an Identifier line."
45e9809aff7304721fddb95654901b32195c9c7avboxsync#define ONLY_ONE_MSG \
45e9809aff7304721fddb95654901b32195c9c7avboxsync"This section must have only one of either %s line."
45e9809aff7304721fddb95654901b32195c9c7avboxsync#define UNDEFINED_INPUTDRIVER_MSG \
45e9809aff7304721fddb95654901b32195c9c7avboxsync"InputDevice section \"%s\" must have a Driver line."
45e9809aff7304721fddb95654901b32195c9c7avboxsync#define INVALID_GAMMA_MSG \
45e9809aff7304721fddb95654901b32195c9c7avboxsync"gamma correction value(s) expected\n either one value or three r/g/b values."
45e9809aff7304721fddb95654901b32195c9c7avboxsync#define GROUP_MSG \
45e9809aff7304721fddb95654901b32195c9c7avboxsync"The Group keyword must be followed by either a group name in quotes or\n" \
45e9809aff7304721fddb95654901b32195c9c7avboxsync"\ta numerical group id."
45e9809aff7304721fddb95654901b32195c9c7avboxsync#define MULTIPLE_MSG \
45e9809aff7304721fddb95654901b32195c9c7avboxsync"Multiple \"%s\" lines."
45e9809aff7304721fddb95654901b32195c9c7avboxsync#define MUST_BE_OCTAL_MSG \
45e9809aff7304721fddb95654901b32195c9c7avboxsync"The number \"%d\" given in this section must be in octal (0xxx) format."
45e9809aff7304721fddb95654901b32195c9c7avboxsync
45e9809aff7304721fddb95654901b32195c9c7avboxsync/* Warning messages */
45e9809aff7304721fddb95654901b32195c9c7avboxsync#define OBSOLETE_MSG \
45e9809aff7304721fddb95654901b32195c9c7avboxsync"Ignoring obsolete keyword \"%s\"."
45e9809aff7304721fddb95654901b32195c9c7avboxsync#define MOVED_TO_FLAGS_MSG \
45e9809aff7304721fddb95654901b32195c9c7avboxsync"Keyword \"%s\" is now an Option flag in the ServerFlags section."
45e9809aff7304721fddb95654901b32195c9c7avboxsync
45e9809aff7304721fddb95654901b32195c9c7avboxsync#endif /* _Configint_h_ */