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