1706f2543Smrg/* 2706f2543Smrg * 3706f2543Smrg * Copyright (c) 1997 Metro Link Incorporated 4706f2543Smrg * 5706f2543Smrg * Permission is hereby granted, free of charge, to any person obtaining a 6706f2543Smrg * copy of this software and associated documentation files (the "Software"), 7706f2543Smrg * to deal in the Software without restriction, including without limitation 8706f2543Smrg * the rights to use, copy, modify, merge, publish, distribute, sublicense, 9706f2543Smrg * and/or sell copies of the Software, and to permit persons to whom the 10706f2543Smrg * Software is furnished to do so, subject to the following conditions: 11706f2543Smrg * 12706f2543Smrg * The above copyright notice and this permission notice shall be included in 13706f2543Smrg * all copies or substantial portions of the Software. 14706f2543Smrg * 15706f2543Smrg * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16706f2543Smrg * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17706f2543Smrg * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 18706f2543Smrg * THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 19706f2543Smrg * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF 20706f2543Smrg * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21706f2543Smrg * SOFTWARE. 22706f2543Smrg * 23706f2543Smrg * Except as contained in this notice, the name of the Metro Link shall not be 24706f2543Smrg * used in advertising or otherwise to promote the sale, use or other dealings 25706f2543Smrg * in this Software without prior written authorization from Metro Link. 26706f2543Smrg * 27706f2543Smrg */ 28706f2543Smrg/* 29706f2543Smrg * Copyright (c) 1997-2002 by The XFree86 Project, Inc. 30706f2543Smrg * 31706f2543Smrg * Permission is hereby granted, free of charge, to any person obtaining a 32706f2543Smrg * copy of this software and associated documentation files (the "Software"), 33706f2543Smrg * to deal in the Software without restriction, including without limitation 34706f2543Smrg * the rights to use, copy, modify, merge, publish, distribute, sublicense, 35706f2543Smrg * and/or sell copies of the Software, and to permit persons to whom the 36706f2543Smrg * Software is furnished to do so, subject to the following conditions: 37706f2543Smrg * 38706f2543Smrg * The above copyright notice and this permission notice shall be included in 39706f2543Smrg * all copies or substantial portions of the Software. 40706f2543Smrg * 41706f2543Smrg * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 42706f2543Smrg * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 43706f2543Smrg * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 44706f2543Smrg * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR 45706f2543Smrg * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 46706f2543Smrg * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 47706f2543Smrg * OTHER DEALINGS IN THE SOFTWARE. 48706f2543Smrg * 49706f2543Smrg * Except as contained in this notice, the name of the copyright holder(s) 50706f2543Smrg * and author(s) shall not be used in advertising or otherwise to promote 51706f2543Smrg * the sale, use or other dealings in this Software without prior written 52706f2543Smrg * authorization from the copyright holder(s) and author(s). 53706f2543Smrg */ 54706f2543Smrg 55706f2543Smrg 56706f2543Smrg/* 57706f2543Smrg * These definitions are used through out the configuration file parser, but 58706f2543Smrg * they should not be visible outside of the parser. 59706f2543Smrg */ 60706f2543Smrg 61706f2543Smrg#ifdef HAVE_XORG_CONFIG_H 62706f2543Smrg#include <xorg-config.h> 63706f2543Smrg#endif 64706f2543Smrg 65706f2543Smrg#ifndef _Configint_h_ 66706f2543Smrg#define _Configint_h_ 67706f2543Smrg 68706f2543Smrg#include <stdio.h> 69706f2543Smrg#include <string.h> 70706f2543Smrg#include <stdarg.h> 71706f2543Smrg#include <stddef.h> 72706f2543Smrg#include "xf86Parser.h" 73706f2543Smrg 74706f2543Smrgtypedef enum { PARSE_DECIMAL, PARSE_OCTAL, PARSE_HEX } ParserNumType; 75706f2543Smrg 76706f2543Smrgtypedef struct 77706f2543Smrg{ 78706f2543Smrg int num; /* returned number */ 79706f2543Smrg char *str; /* private copy of the return-string */ 80706f2543Smrg double realnum; /* returned number as a real */ 81706f2543Smrg ParserNumType numType; /* used to enforce correct number formatting */ 82706f2543Smrg} 83706f2543SmrgLexRec, *LexPtr; 84706f2543Smrg 85706f2543Smrg#ifndef TRUE 86706f2543Smrg#define TRUE 1 87706f2543Smrg#endif 88706f2543Smrg 89706f2543Smrg#ifndef FALSE 90706f2543Smrg#define FALSE 0 91706f2543Smrg#endif 92706f2543Smrg 93706f2543Smrg#include "configProcs.h" 94706f2543Smrg#include <stdlib.h> 95706f2543Smrg 96706f2543Smrg#define TestFree(a) if (a) { free (a); a = NULL; } 97706f2543Smrg 98706f2543Smrg#define parsePrologue(typeptr,typerec) typeptr ptr; \ 99706f2543Smrgif( (ptr=calloc(1,sizeof(typerec))) == NULL ) { return NULL; } 100706f2543Smrg 101706f2543Smrg#define HANDLE_RETURN(f,func)\ 102706f2543Smrgif ((ptr->f=func) == NULL)\ 103706f2543Smrg{\ 104706f2543Smrg CLEANUP (ptr);\ 105706f2543Smrg return NULL;\ 106706f2543Smrg} 107706f2543Smrg 108706f2543Smrg#define HANDLE_LIST(field,func,type)\ 109706f2543Smrg{\ 110706f2543Smrgtype p = func ();\ 111706f2543Smrgif (p == NULL)\ 112706f2543Smrg{\ 113706f2543Smrg CLEANUP (ptr);\ 114706f2543Smrg return NULL;\ 115706f2543Smrg}\ 116706f2543Smrgelse\ 117706f2543Smrg{\ 118706f2543Smrg ptr->field = (type) xf86addListItem ((glp) ptr->field, (glp) p);\ 119706f2543Smrg}\ 120706f2543Smrg} 121706f2543Smrg 122706f2543Smrg#define Error(a,b) do { \ 123706f2543Smrg xf86parseError (a, b); CLEANUP (ptr); return NULL; \ 124706f2543Smrg } while (0) 125706f2543Smrg 126706f2543Smrg/* 127706f2543Smrg * These are defines for error messages to promote consistency. 128706f2543Smrg * error messages are preceded by the line number, section and file name, 129706f2543Smrg * so these messages should be about the specific keyword and syntax in error. 130706f2543Smrg * To help limit namespace polution, end each with _MSG. 131706f2543Smrg * limit messages to 70 characters if possible. 132706f2543Smrg */ 133706f2543Smrg 134706f2543Smrg#define BAD_OPTION_MSG \ 135706f2543Smrg"The Option keyword requires 1 or 2 quoted strings to follow it." 136706f2543Smrg#define INVALID_KEYWORD_MSG \ 137706f2543Smrg"\"%s\" is not a valid keyword in this section." 138706f2543Smrg#define INVALID_SECTION_MSG \ 139706f2543Smrg"\"%s\" is not a valid section name." 140706f2543Smrg#define UNEXPECTED_EOF_MSG \ 141706f2543Smrg"Unexpected EOF. Missing EndSection keyword?" 142706f2543Smrg#define QUOTE_MSG \ 143706f2543Smrg"The %s keyword requires a quoted string to follow it." 144706f2543Smrg#define NUMBER_MSG \ 145706f2543Smrg"The %s keyword requires a number to follow it." 146706f2543Smrg#define POSITIVE_INT_MSG \ 147706f2543Smrg"The %s keyword requires a positive integer to follow it." 148706f2543Smrg#define BOOL_MSG \ 149706f2543Smrg"The %s keyword requires a boolean to follow it." 150706f2543Smrg#define ZAXISMAPPING_MSG \ 151706f2543Smrg"The ZAxisMapping keyword requires 2 positive numbers or X or Y to follow it." 152706f2543Smrg#define DACSPEED_MSG \ 153706f2543Smrg"The DacSpeed keyword must be followed by a list of up to %d numbers." 154706f2543Smrg#define DISPLAYSIZE_MSG \ 155706f2543Smrg"The DisplaySize keyword must be followed by the width and height in mm." 156706f2543Smrg#define HORIZSYNC_MSG \ 157706f2543Smrg"The HorizSync keyword must be followed by a list of numbers or ranges." 158706f2543Smrg#define VERTREFRESH_MSG \ 159706f2543Smrg"The VertRefresh keyword must be followed by a list of numbers or ranges." 160706f2543Smrg#define VIEWPORT_MSG \ 161706f2543Smrg"The Viewport keyword must be followed by an X and Y value." 162706f2543Smrg#define VIRTUAL_MSG \ 163706f2543Smrg"The Virtual keyword must be followed by a width and height value." 164706f2543Smrg#define WEIGHT_MSG \ 165706f2543Smrg"The Weight keyword must be followed by red, green and blue values." 166706f2543Smrg#define BLACK_MSG \ 167706f2543Smrg"The Black keyword must be followed by red, green and blue values." 168706f2543Smrg#define WHITE_MSG \ 169706f2543Smrg"The White keyword must be followed by red, green and blue values." 170706f2543Smrg#define SCREEN_MSG \ 171706f2543Smrg"The Screen keyword must be followed by an optional number, a screen name\n" \ 172706f2543Smrg"\tin quotes, and optional position/layout information." 173706f2543Smrg#define INVALID_SCR_MSG \ 174706f2543Smrg"Invalid Screen line." 175706f2543Smrg#define INPUTDEV_MSG \ 176706f2543Smrg"The InputDevice keyword must be followed by an input device name in quotes." 177706f2543Smrg#define INACTIVE_MSG \ 178706f2543Smrg"The Inactive keyword must be followed by a Device name in quotes." 179706f2543Smrg#define UNDEFINED_SCREEN_MSG \ 180706f2543Smrg"Undefined Screen \"%s\" referenced by ServerLayout \"%s\"." 181706f2543Smrg#define UNDEFINED_MODES_MSG \ 182706f2543Smrg"Undefined Modes Section \"%s\" referenced by Monitor \"%s\"." 183706f2543Smrg#define UNDEFINED_DEVICE_MSG \ 184706f2543Smrg"Undefined Device \"%s\" referenced by Screen \"%s\"." 185706f2543Smrg#define UNDEFINED_ADAPTOR_MSG \ 186706f2543Smrg"Undefined VideoAdaptor \"%s\" referenced by Screen \"%s\"." 187706f2543Smrg#define ADAPTOR_REF_TWICE_MSG \ 188706f2543Smrg"VideoAdaptor \"%s\" already referenced by Screen \"%s\"." 189706f2543Smrg#define UNDEFINED_DEVICE_LAY_MSG \ 190706f2543Smrg"Undefined Device \"%s\" referenced by ServerLayout \"%s\"." 191706f2543Smrg#define UNDEFINED_INPUT_MSG \ 192706f2543Smrg"Undefined InputDevice \"%s\" referenced by ServerLayout \"%s\"." 193706f2543Smrg#define NO_IDENT_MSG \ 194706f2543Smrg"This section must have an Identifier line." 195706f2543Smrg#define ONLY_ONE_MSG \ 196706f2543Smrg"This section must have only one of either %s line." 197706f2543Smrg#define UNDEFINED_INPUTDRIVER_MSG \ 198706f2543Smrg"InputDevice section \"%s\" must have a Driver line." 199706f2543Smrg#define INVALID_GAMMA_MSG \ 200706f2543Smrg"gamma correction value(s) expected\n either one value or three r/g/b values." 201706f2543Smrg#define GROUP_MSG \ 202706f2543Smrg"The Group keyword must be followed by either a group name in quotes or\n" \ 203706f2543Smrg"\ta numerical group id." 204706f2543Smrg#define MULTIPLE_MSG \ 205706f2543Smrg"Multiple \"%s\" lines." 206706f2543Smrg#define MUST_BE_OCTAL_MSG \ 207706f2543Smrg"The number \"%d\" given in this section must be in octal (0xxx) format." 208706f2543Smrg 209706f2543Smrg/* Warning messages */ 210706f2543Smrg#define OBSOLETE_MSG \ 211706f2543Smrg"Ignoring obsolete keyword \"%s\"." 212706f2543Smrg 213706f2543Smrg#endif /* _Configint_h_ */ 214