xref: /OK3568_Linux_fs/external/xserver/hw/xfree86/parser/Configint.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun /*
2*4882a593Smuzhiyun  *
3*4882a593Smuzhiyun  * Copyright (c) 1997  Metro Link Incorporated
4*4882a593Smuzhiyun  *
5*4882a593Smuzhiyun  * Permission is hereby granted, free of charge, to any person obtaining a
6*4882a593Smuzhiyun  * copy of this software and associated documentation files (the "Software"),
7*4882a593Smuzhiyun  * to deal in the Software without restriction, including without limitation
8*4882a593Smuzhiyun  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
9*4882a593Smuzhiyun  * and/or sell copies of the Software, and to permit persons to whom the
10*4882a593Smuzhiyun  * Software is furnished to do so, subject to the following conditions:
11*4882a593Smuzhiyun  *
12*4882a593Smuzhiyun  * The above copyright notice and this permission notice shall be included in
13*4882a593Smuzhiyun  * all copies or substantial portions of the Software.
14*4882a593Smuzhiyun  *
15*4882a593Smuzhiyun  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16*4882a593Smuzhiyun  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17*4882a593Smuzhiyun  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
18*4882a593Smuzhiyun  * THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
19*4882a593Smuzhiyun  * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
20*4882a593Smuzhiyun  * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21*4882a593Smuzhiyun  * SOFTWARE.
22*4882a593Smuzhiyun  *
23*4882a593Smuzhiyun  * Except as contained in this notice, the name of the Metro Link shall not be
24*4882a593Smuzhiyun  * used in advertising or otherwise to promote the sale, use or other dealings
25*4882a593Smuzhiyun  * in this Software without prior written authorization from Metro Link.
26*4882a593Smuzhiyun  *
27*4882a593Smuzhiyun  */
28*4882a593Smuzhiyun /*
29*4882a593Smuzhiyun  * Copyright (c) 1997-2002 by The XFree86 Project, Inc.
30*4882a593Smuzhiyun  *
31*4882a593Smuzhiyun  * Permission is hereby granted, free of charge, to any person obtaining a
32*4882a593Smuzhiyun  * copy of this software and associated documentation files (the "Software"),
33*4882a593Smuzhiyun  * to deal in the Software without restriction, including without limitation
34*4882a593Smuzhiyun  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
35*4882a593Smuzhiyun  * and/or sell copies of the Software, and to permit persons to whom the
36*4882a593Smuzhiyun  * Software is furnished to do so, subject to the following conditions:
37*4882a593Smuzhiyun  *
38*4882a593Smuzhiyun  * The above copyright notice and this permission notice shall be included in
39*4882a593Smuzhiyun  * all copies or substantial portions of the Software.
40*4882a593Smuzhiyun  *
41*4882a593Smuzhiyun  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
42*4882a593Smuzhiyun  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
43*4882a593Smuzhiyun  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
44*4882a593Smuzhiyun  * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
45*4882a593Smuzhiyun  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
46*4882a593Smuzhiyun  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
47*4882a593Smuzhiyun  * OTHER DEALINGS IN THE SOFTWARE.
48*4882a593Smuzhiyun  *
49*4882a593Smuzhiyun  * Except as contained in this notice, the name of the copyright holder(s)
50*4882a593Smuzhiyun  * and author(s) shall not be used in advertising or otherwise to promote
51*4882a593Smuzhiyun  * the sale, use or other dealings in this Software without prior written
52*4882a593Smuzhiyun  * authorization from the copyright holder(s) and author(s).
53*4882a593Smuzhiyun  */
54*4882a593Smuzhiyun 
55*4882a593Smuzhiyun /*
56*4882a593Smuzhiyun  * These definitions are used through out the configuration file parser, but
57*4882a593Smuzhiyun  * they should not be visible outside of the parser.
58*4882a593Smuzhiyun  */
59*4882a593Smuzhiyun 
60*4882a593Smuzhiyun #ifdef HAVE_XORG_CONFIG_H
61*4882a593Smuzhiyun #include <xorg-config.h>
62*4882a593Smuzhiyun #endif
63*4882a593Smuzhiyun 
64*4882a593Smuzhiyun #ifndef _Configint_h_
65*4882a593Smuzhiyun #define _Configint_h_
66*4882a593Smuzhiyun 
67*4882a593Smuzhiyun #include <stdio.h>
68*4882a593Smuzhiyun #include <string.h>
69*4882a593Smuzhiyun #include <stdarg.h>
70*4882a593Smuzhiyun #include <stddef.h>
71*4882a593Smuzhiyun #include "xf86Parser.h"
72*4882a593Smuzhiyun 
73*4882a593Smuzhiyun typedef enum { PARSE_DECIMAL, PARSE_OCTAL, PARSE_HEX } ParserNumType;
74*4882a593Smuzhiyun 
75*4882a593Smuzhiyun typedef struct {
76*4882a593Smuzhiyun     int num;                    /* returned number */
77*4882a593Smuzhiyun     char *str;                  /* private copy of the return-string */
78*4882a593Smuzhiyun     double realnum;             /* returned number as a real */
79*4882a593Smuzhiyun     ParserNumType numType;      /* used to enforce correct number formatting */
80*4882a593Smuzhiyun } LexRec, *LexPtr;
81*4882a593Smuzhiyun 
82*4882a593Smuzhiyun extern LexRec xf86_lex_val;
83*4882a593Smuzhiyun 
84*4882a593Smuzhiyun #ifndef TRUE
85*4882a593Smuzhiyun #define TRUE 1
86*4882a593Smuzhiyun #endif
87*4882a593Smuzhiyun 
88*4882a593Smuzhiyun #ifndef FALSE
89*4882a593Smuzhiyun #define FALSE 0
90*4882a593Smuzhiyun #endif
91*4882a593Smuzhiyun 
92*4882a593Smuzhiyun #include "configProcs.h"
93*4882a593Smuzhiyun #include <stdlib.h>
94*4882a593Smuzhiyun 
95*4882a593Smuzhiyun #define TestFree(a) if (a) { free ((void *) a); a = NULL; }
96*4882a593Smuzhiyun 
97*4882a593Smuzhiyun #define parsePrologue(typeptr,typerec) typeptr ptr; \
98*4882a593Smuzhiyun if( (ptr=calloc(1,sizeof(typerec))) == NULL ) { return NULL; }
99*4882a593Smuzhiyun 
100*4882a593Smuzhiyun #define HANDLE_RETURN(f,func)\
101*4882a593Smuzhiyun if ((ptr->f=func) == NULL)\
102*4882a593Smuzhiyun {\
103*4882a593Smuzhiyun 	CLEANUP (ptr);\
104*4882a593Smuzhiyun 	return NULL;\
105*4882a593Smuzhiyun }
106*4882a593Smuzhiyun 
107*4882a593Smuzhiyun #define HANDLE_LIST(field,func,type)\
108*4882a593Smuzhiyun {\
109*4882a593Smuzhiyun type p = func ();\
110*4882a593Smuzhiyun if (p == NULL)\
111*4882a593Smuzhiyun {\
112*4882a593Smuzhiyun 	CLEANUP (ptr);\
113*4882a593Smuzhiyun 	return NULL;\
114*4882a593Smuzhiyun }\
115*4882a593Smuzhiyun else\
116*4882a593Smuzhiyun {\
117*4882a593Smuzhiyun 	ptr->field = (type) xf86addListItem ((glp) ptr->field, (glp) p);\
118*4882a593Smuzhiyun }\
119*4882a593Smuzhiyun }
120*4882a593Smuzhiyun 
121*4882a593Smuzhiyun #define Error(...) do { \
122*4882a593Smuzhiyun 		xf86parseError (__VA_ARGS__); CLEANUP (ptr); return NULL; \
123*4882a593Smuzhiyun 		   } while (0)
124*4882a593Smuzhiyun 
125*4882a593Smuzhiyun /*
126*4882a593Smuzhiyun  * These are defines for error messages to promote consistency.
127*4882a593Smuzhiyun  * error messages are preceded by the line number, section and file name,
128*4882a593Smuzhiyun  * so these messages should be about the specific keyword and syntax in error.
129*4882a593Smuzhiyun  * To help limit namespace polution, end each with _MSG.
130*4882a593Smuzhiyun  * limit messages to 70 characters if possible.
131*4882a593Smuzhiyun  */
132*4882a593Smuzhiyun 
133*4882a593Smuzhiyun #define BAD_OPTION_MSG \
134*4882a593Smuzhiyun "The Option keyword requires 1 or 2 quoted strings to follow it."
135*4882a593Smuzhiyun #define INVALID_KEYWORD_MSG \
136*4882a593Smuzhiyun "\"%s\" is not a valid keyword in this section."
137*4882a593Smuzhiyun #define INVALID_SECTION_MSG \
138*4882a593Smuzhiyun "\"%s\" is not a valid section name."
139*4882a593Smuzhiyun #define UNEXPECTED_EOF_MSG \
140*4882a593Smuzhiyun "Unexpected EOF. Missing EndSection keyword?"
141*4882a593Smuzhiyun #define QUOTE_MSG \
142*4882a593Smuzhiyun "The %s keyword requires a quoted string to follow it."
143*4882a593Smuzhiyun #define NUMBER_MSG \
144*4882a593Smuzhiyun "The %s keyword requires a number to follow it."
145*4882a593Smuzhiyun #define POSITIVE_INT_MSG \
146*4882a593Smuzhiyun "The %s keyword requires a positive integer to follow it."
147*4882a593Smuzhiyun #define BOOL_MSG \
148*4882a593Smuzhiyun "The %s keyword requires a boolean to follow it."
149*4882a593Smuzhiyun #define ZAXISMAPPING_MSG \
150*4882a593Smuzhiyun "The ZAxisMapping keyword requires 2 positive numbers or X or Y to follow it."
151*4882a593Smuzhiyun #define DACSPEED_MSG \
152*4882a593Smuzhiyun "The DacSpeed keyword must be followed by a list of up to %d numbers."
153*4882a593Smuzhiyun #define DISPLAYSIZE_MSG \
154*4882a593Smuzhiyun "The DisplaySize keyword must be followed by the width and height in mm."
155*4882a593Smuzhiyun #define HORIZSYNC_MSG \
156*4882a593Smuzhiyun "The HorizSync keyword must be followed by a list of numbers or ranges."
157*4882a593Smuzhiyun #define VERTREFRESH_MSG \
158*4882a593Smuzhiyun "The VertRefresh keyword must be followed by a list of numbers or ranges."
159*4882a593Smuzhiyun #define VIEWPORT_MSG \
160*4882a593Smuzhiyun "The Viewport keyword must be followed by an X and Y value."
161*4882a593Smuzhiyun #define VIRTUAL_MSG \
162*4882a593Smuzhiyun "The Virtual keyword must be followed by a width and height value."
163*4882a593Smuzhiyun #define WEIGHT_MSG \
164*4882a593Smuzhiyun "The Weight keyword must be followed by red, green and blue values."
165*4882a593Smuzhiyun #define BLACK_MSG \
166*4882a593Smuzhiyun "The Black keyword must be followed by red, green and blue values."
167*4882a593Smuzhiyun #define WHITE_MSG \
168*4882a593Smuzhiyun "The White keyword must be followed by red, green and blue values."
169*4882a593Smuzhiyun #define SCREEN_MSG \
170*4882a593Smuzhiyun "The Screen keyword must be followed by an optional number, a screen name\n" \
171*4882a593Smuzhiyun "\tin quotes, and optional position/layout information."
172*4882a593Smuzhiyun #define INVALID_SCR_MSG \
173*4882a593Smuzhiyun "Invalid Screen line."
174*4882a593Smuzhiyun #define INPUTDEV_MSG \
175*4882a593Smuzhiyun "The InputDevice keyword must be followed by an input device name in quotes."
176*4882a593Smuzhiyun #define INACTIVE_MSG \
177*4882a593Smuzhiyun "The Inactive keyword must be followed by a Device name in quotes."
178*4882a593Smuzhiyun #define UNDEFINED_SCREEN_MSG \
179*4882a593Smuzhiyun "Undefined Screen \"%s\" referenced by ServerLayout \"%s\"."
180*4882a593Smuzhiyun #define UNDEFINED_MODES_MSG \
181*4882a593Smuzhiyun "Undefined Modes Section \"%s\" referenced by Monitor \"%s\"."
182*4882a593Smuzhiyun #define UNDEFINED_DEVICE_MSG \
183*4882a593Smuzhiyun "Undefined Device \"%s\" referenced by Screen \"%s\"."
184*4882a593Smuzhiyun #define UNDEFINED_ADAPTOR_MSG \
185*4882a593Smuzhiyun "Undefined VideoAdaptor \"%s\" referenced by Screen \"%s\"."
186*4882a593Smuzhiyun #define ADAPTOR_REF_TWICE_MSG \
187*4882a593Smuzhiyun "VideoAdaptor \"%s\" already referenced by Screen \"%s\"."
188*4882a593Smuzhiyun #define UNDEFINED_DEVICE_LAY_MSG \
189*4882a593Smuzhiyun "Undefined Device \"%s\" referenced by ServerLayout \"%s\"."
190*4882a593Smuzhiyun #define UNDEFINED_INPUT_MSG \
191*4882a593Smuzhiyun "Undefined InputDevice \"%s\" referenced by ServerLayout \"%s\"."
192*4882a593Smuzhiyun #define NO_IDENT_MSG \
193*4882a593Smuzhiyun "This section must have an Identifier line."
194*4882a593Smuzhiyun #define ONLY_ONE_MSG \
195*4882a593Smuzhiyun "This section must have only one of either %s line."
196*4882a593Smuzhiyun #define UNDEFINED_INPUTDRIVER_MSG \
197*4882a593Smuzhiyun "InputDevice section \"%s\" must have a Driver line."
198*4882a593Smuzhiyun #define INVALID_GAMMA_MSG \
199*4882a593Smuzhiyun "gamma correction value(s) expected\n either one value or three r/g/b values."
200*4882a593Smuzhiyun #define GROUP_MSG \
201*4882a593Smuzhiyun "The Group keyword must be followed by either a group name in quotes or\n" \
202*4882a593Smuzhiyun "\ta numerical group id."
203*4882a593Smuzhiyun #define MULTIPLE_MSG \
204*4882a593Smuzhiyun "Multiple \"%s\" lines."
205*4882a593Smuzhiyun #define MUST_BE_OCTAL_MSG \
206*4882a593Smuzhiyun "The number \"%d\" given in this section must be in octal (0xxx) format."
207*4882a593Smuzhiyun #define GPU_DEVICE_TOO_MANY \
208*4882a593Smuzhiyun "More than %d GPU devices defined."
209*4882a593Smuzhiyun 
210*4882a593Smuzhiyun /* Warning messages */
211*4882a593Smuzhiyun #define OBSOLETE_MSG \
212*4882a593Smuzhiyun "Ignoring obsolete keyword \"%s\"."
213*4882a593Smuzhiyun 
214*4882a593Smuzhiyun #endif                          /* _Configint_h_ */
215