105b261ecSmrg/*
235c4bbdfSmrg *
305b261ecSmrg * Copyright (c) 1997  Metro Link Incorporated
435c4bbdfSmrg *
505b261ecSmrg * Permission is hereby granted, free of charge, to any person obtaining a
635c4bbdfSmrg * copy of this software and associated documentation files (the "Software"),
705b261ecSmrg * to deal in the Software without restriction, including without limitation
805b261ecSmrg * the rights to use, copy, modify, merge, publish, distribute, sublicense,
905b261ecSmrg * and/or sell copies of the Software, and to permit persons to whom the
1005b261ecSmrg * Software is furnished to do so, subject to the following conditions:
1135c4bbdfSmrg *
1205b261ecSmrg * The above copyright notice and this permission notice shall be included in
1305b261ecSmrg * all copies or substantial portions of the Software.
1435c4bbdfSmrg *
1505b261ecSmrg * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
1605b261ecSmrg * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
1705b261ecSmrg * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
1805b261ecSmrg * THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
1905b261ecSmrg * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
2005b261ecSmrg * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
2105b261ecSmrg * SOFTWARE.
2235c4bbdfSmrg *
2305b261ecSmrg * Except as contained in this notice, the name of the Metro Link shall not be
2405b261ecSmrg * used in advertising or otherwise to promote the sale, use or other dealings
2505b261ecSmrg * in this Software without prior written authorization from Metro Link.
2635c4bbdfSmrg *
2705b261ecSmrg */
2805b261ecSmrg/*
2905b261ecSmrg * Copyright (c) 1997-2002 by The XFree86 Project, Inc.
3005b261ecSmrg *
3105b261ecSmrg * Permission is hereby granted, free of charge, to any person obtaining a
3205b261ecSmrg * copy of this software and associated documentation files (the "Software"),
3305b261ecSmrg * to deal in the Software without restriction, including without limitation
3405b261ecSmrg * the rights to use, copy, modify, merge, publish, distribute, sublicense,
3505b261ecSmrg * and/or sell copies of the Software, and to permit persons to whom the
3605b261ecSmrg * Software is furnished to do so, subject to the following conditions:
3705b261ecSmrg *
3805b261ecSmrg * The above copyright notice and this permission notice shall be included in
3905b261ecSmrg * all copies or substantial portions of the Software.
4005b261ecSmrg *
4105b261ecSmrg * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
4205b261ecSmrg * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
4305b261ecSmrg * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
4405b261ecSmrg * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
4505b261ecSmrg * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
4605b261ecSmrg * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
4705b261ecSmrg * OTHER DEALINGS IN THE SOFTWARE.
4805b261ecSmrg *
4905b261ecSmrg * Except as contained in this notice, the name of the copyright holder(s)
5005b261ecSmrg * and author(s) shall not be used in advertising or otherwise to promote
5105b261ecSmrg * the sale, use or other dealings in this Software without prior written
5205b261ecSmrg * authorization from the copyright holder(s) and author(s).
5305b261ecSmrg */
5405b261ecSmrg
5535c4bbdfSmrg/*
5605b261ecSmrg * These definitions are used through out the configuration file parser, but
5705b261ecSmrg * they should not be visible outside of the parser.
5805b261ecSmrg */
5905b261ecSmrg
6005b261ecSmrg#ifdef HAVE_XORG_CONFIG_H
6105b261ecSmrg#include <xorg-config.h>
6205b261ecSmrg#endif
6305b261ecSmrg
6405b261ecSmrg#ifndef _Configint_h_
6505b261ecSmrg#define _Configint_h_
6605b261ecSmrg
6705b261ecSmrg#include <stdio.h>
6805b261ecSmrg#include <string.h>
6905b261ecSmrg#include <stdarg.h>
7005b261ecSmrg#include <stddef.h>
7105b261ecSmrg#include "xf86Parser.h"
7205b261ecSmrg
734642e01fSmrgtypedef enum { PARSE_DECIMAL, PARSE_OCTAL, PARSE_HEX } ParserNumType;
744642e01fSmrg
7535c4bbdfSmrgtypedef struct {
7635c4bbdfSmrg    int num;                    /* returned number */
7735c4bbdfSmrg    char *str;                  /* private copy of the return-string */
7835c4bbdfSmrg    double realnum;             /* returned number as a real */
7935c4bbdfSmrg    ParserNumType numType;      /* used to enforce correct number formatting */
8035c4bbdfSmrg} LexRec, *LexPtr;
8135c4bbdfSmrg
8235c4bbdfSmrgextern LexRec xf86_lex_val;
8305b261ecSmrg
8405b261ecSmrg#ifndef TRUE
8505b261ecSmrg#define TRUE 1
8605b261ecSmrg#endif
8705b261ecSmrg
8805b261ecSmrg#ifndef FALSE
8905b261ecSmrg#define FALSE 0
9005b261ecSmrg#endif
9105b261ecSmrg
9205b261ecSmrg#include "configProcs.h"
9305b261ecSmrg#include <stdlib.h>
9405b261ecSmrg
9535c4bbdfSmrg#define TestFree(a) if (a) { free ((void *) a); a = NULL; }
9605b261ecSmrg
9705b261ecSmrg#define parsePrologue(typeptr,typerec) typeptr ptr; \
986747b715Smrgif( (ptr=calloc(1,sizeof(typerec))) == NULL ) { return NULL; }
9905b261ecSmrg
10005b261ecSmrg#define HANDLE_RETURN(f,func)\
10105b261ecSmrgif ((ptr->f=func) == NULL)\
10205b261ecSmrg{\
10305b261ecSmrg	CLEANUP (ptr);\
1046747b715Smrg	return NULL;\
10505b261ecSmrg}
10605b261ecSmrg
10705b261ecSmrg#define HANDLE_LIST(field,func,type)\
10805b261ecSmrg{\
10905b261ecSmrgtype p = func ();\
11005b261ecSmrgif (p == NULL)\
11105b261ecSmrg{\
11205b261ecSmrg	CLEANUP (ptr);\
1136747b715Smrg	return NULL;\
11405b261ecSmrg}\
11505b261ecSmrgelse\
11605b261ecSmrg{\
11705b261ecSmrg	ptr->field = (type) xf86addListItem ((glp) ptr->field, (glp) p);\
11805b261ecSmrg}\
11905b261ecSmrg}
12005b261ecSmrg
12135c4bbdfSmrg#define Error(...) do { \
12235c4bbdfSmrg		xf86parseError (__VA_ARGS__); CLEANUP (ptr); return NULL; \
12305b261ecSmrg		   } while (0)
12405b261ecSmrg
12535c4bbdfSmrg/*
12605b261ecSmrg * These are defines for error messages to promote consistency.
127ed6184dfSmrg * Error messages are preceded by the line number, section and file name,
12805b261ecSmrg * so these messages should be about the specific keyword and syntax in error.
129ed6184dfSmrg * To help limit namespace pollution, end each with _MSG.
130ed6184dfSmrg * Limit messages to 70 characters if possible.
13105b261ecSmrg */
13205b261ecSmrg
13305b261ecSmrg#define BAD_OPTION_MSG \
13405b261ecSmrg"The Option keyword requires 1 or 2 quoted strings to follow it."
13505b261ecSmrg#define INVALID_KEYWORD_MSG \
13605b261ecSmrg"\"%s\" is not a valid keyword in this section."
13705b261ecSmrg#define INVALID_SECTION_MSG \
13805b261ecSmrg"\"%s\" is not a valid section name."
13905b261ecSmrg#define UNEXPECTED_EOF_MSG \
14005b261ecSmrg"Unexpected EOF. Missing EndSection keyword?"
14105b261ecSmrg#define QUOTE_MSG \
14205b261ecSmrg"The %s keyword requires a quoted string to follow it."
14305b261ecSmrg#define NUMBER_MSG \
14405b261ecSmrg"The %s keyword requires a number to follow it."
14505b261ecSmrg#define POSITIVE_INT_MSG \
14605b261ecSmrg"The %s keyword requires a positive integer to follow it."
1476747b715Smrg#define BOOL_MSG \
1486747b715Smrg"The %s keyword requires a boolean to follow it."
14905b261ecSmrg#define ZAXISMAPPING_MSG \
15005b261ecSmrg"The ZAxisMapping keyword requires 2 positive numbers or X or Y to follow it."
15105b261ecSmrg#define DACSPEED_MSG \
15205b261ecSmrg"The DacSpeed keyword must be followed by a list of up to %d numbers."
15305b261ecSmrg#define DISPLAYSIZE_MSG \
15405b261ecSmrg"The DisplaySize keyword must be followed by the width and height in mm."
15505b261ecSmrg#define HORIZSYNC_MSG \
15605b261ecSmrg"The HorizSync keyword must be followed by a list of numbers or ranges."
15705b261ecSmrg#define VERTREFRESH_MSG \
15805b261ecSmrg"The VertRefresh keyword must be followed by a list of numbers or ranges."
15905b261ecSmrg#define VIEWPORT_MSG \
16005b261ecSmrg"The Viewport keyword must be followed by an X and Y value."
16105b261ecSmrg#define VIRTUAL_MSG \
16205b261ecSmrg"The Virtual keyword must be followed by a width and height value."
16305b261ecSmrg#define WEIGHT_MSG \
16405b261ecSmrg"The Weight keyword must be followed by red, green and blue values."
16505b261ecSmrg#define BLACK_MSG \
16605b261ecSmrg"The Black keyword must be followed by red, green and blue values."
16705b261ecSmrg#define WHITE_MSG \
16805b261ecSmrg"The White keyword must be followed by red, green and blue values."
16905b261ecSmrg#define SCREEN_MSG \
17005b261ecSmrg"The Screen keyword must be followed by an optional number, a screen name\n" \
17105b261ecSmrg"\tin quotes, and optional position/layout information."
17205b261ecSmrg#define INVALID_SCR_MSG \
17305b261ecSmrg"Invalid Screen line."
17405b261ecSmrg#define INPUTDEV_MSG \
17505b261ecSmrg"The InputDevice keyword must be followed by an input device name in quotes."
17605b261ecSmrg#define INACTIVE_MSG \
17705b261ecSmrg"The Inactive keyword must be followed by a Device name in quotes."
17805b261ecSmrg#define UNDEFINED_SCREEN_MSG \
17905b261ecSmrg"Undefined Screen \"%s\" referenced by ServerLayout \"%s\"."
18005b261ecSmrg#define UNDEFINED_MODES_MSG \
18105b261ecSmrg"Undefined Modes Section \"%s\" referenced by Monitor \"%s\"."
18205b261ecSmrg#define UNDEFINED_DEVICE_MSG \
18305b261ecSmrg"Undefined Device \"%s\" referenced by Screen \"%s\"."
18405b261ecSmrg#define UNDEFINED_ADAPTOR_MSG \
18505b261ecSmrg"Undefined VideoAdaptor \"%s\" referenced by Screen \"%s\"."
18605b261ecSmrg#define ADAPTOR_REF_TWICE_MSG \
18705b261ecSmrg"VideoAdaptor \"%s\" already referenced by Screen \"%s\"."
18805b261ecSmrg#define UNDEFINED_DEVICE_LAY_MSG \
18905b261ecSmrg"Undefined Device \"%s\" referenced by ServerLayout \"%s\"."
19005b261ecSmrg#define UNDEFINED_INPUT_MSG \
19105b261ecSmrg"Undefined InputDevice \"%s\" referenced by ServerLayout \"%s\"."
19205b261ecSmrg#define NO_IDENT_MSG \
19305b261ecSmrg"This section must have an Identifier line."
19405b261ecSmrg#define ONLY_ONE_MSG \
19505b261ecSmrg"This section must have only one of either %s line."
19605b261ecSmrg#define UNDEFINED_INPUTDRIVER_MSG \
19705b261ecSmrg"InputDevice section \"%s\" must have a Driver line."
19805b261ecSmrg#define INVALID_GAMMA_MSG \
19905b261ecSmrg"gamma correction value(s) expected\n either one value or three r/g/b values."
20005b261ecSmrg#define GROUP_MSG \
20105b261ecSmrg"The Group keyword must be followed by either a group name in quotes or\n" \
20205b261ecSmrg"\ta numerical group id."
20305b261ecSmrg#define MULTIPLE_MSG \
20405b261ecSmrg"Multiple \"%s\" lines."
2054642e01fSmrg#define MUST_BE_OCTAL_MSG \
2064642e01fSmrg"The number \"%d\" given in this section must be in octal (0xxx) format."
20735c4bbdfSmrg#define GPU_DEVICE_TOO_MANY \
20835c4bbdfSmrg"More than %d GPU devices defined."
20905b261ecSmrg
21005b261ecSmrg/* Warning messages */
21105b261ecSmrg#define OBSOLETE_MSG \
21205b261ecSmrg"Ignoring obsolete keyword \"%s\"."
21305b261ecSmrg
21435c4bbdfSmrg#endif                          /* _Configint_h_ */
215