2 * Copyright (c) 1997 Metro Link Incorporated
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17 * THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
18 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
19 * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 * Except as contained in this notice, the name of the Metro Link shall not be
23 * used in advertising or otherwise to promote the sale, use or other dealings
24 * in this Software without prior written authorization from Metro Link.
28 * Copyright (c) 1997-2003 by The XFree86 Project, Inc.
30 * Permission is hereby granted, free of charge, to any person obtaining a
31 * copy of this software and associated documentation files (the "Software"),
32 * to deal in the Software without restriction, including without limitation
33 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
34 * and/or sell copies of the Software, and to permit persons to whom the
35 * Software is furnished to do so, subject to the following conditions:
37 * The above copyright notice and this permission notice shall be included in
38 * all copies or substantial portions of the Software.
40 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
41 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
42 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
43 * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
44 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
45 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
46 * OTHER DEALINGS IN THE SOFTWARE.
48 * Except as contained in this notice, the name of the copyright holder(s)
49 * and author(s) shall not be used in advertising or otherwise to promote
50 * the sale, use or other dealings in this Software without prior written
51 * authorization from the copyright holder(s) and author(s).
55 /* View/edit this file with tab stops set to 4 */
57 #ifdef HAVE_XORG_CONFIG_H
58 #include <xorg-config.h>
62 #include "xf86Parser.h"
63 #include "xf86tokens.h"
64 #include "Configint.h"
68 static xf86ConfigSymTabRec FilesTab
[] =
70 {ENDSECTION
, "endsection"},
71 {FONTPATH
, "fontpath"},
73 {MODULEPATH
, "modulepath"},
74 {INPUTDEVICES
, "inputdevices"},
75 {LOGFILEPATH
, "logfile"},
79 #define CLEANUP xf86freeFiles
82 xf86parseFilesSection (void)
88 parsePrologue (XF86ConfFilesPtr
, XF86ConfFilesRec
)
90 while ((token
= xf86getToken (FilesTab
)) != ENDSECTION
)
95 ptr
->file_comment
= xf86addComment(ptr
->file_comment
, val
.str
);
98 if (xf86getSubToken (&(ptr
->file_comment
)) != STRING
)
99 Error (QUOTE_MSG
, "FontPath");
102 if (ptr
->file_fontpath
== NULL
)
104 ptr
->file_fontpath
= xf86confmalloc (1);
105 ptr
->file_fontpath
[0] = '\0';
106 i
= strlen (str
) + 1;
110 i
= strlen (ptr
->file_fontpath
) + strlen (str
) + 1;
111 if (ptr
->file_fontpath
[strlen (ptr
->file_fontpath
) - 1] != ',')
118 xf86confrealloc (ptr
->file_fontpath
, i
);
120 strcat (ptr
->file_fontpath
, ",");
122 strcat (ptr
->file_fontpath
, str
);
123 xf86conffree (val
.str
);
126 if (xf86getSubToken (&(ptr
->file_comment
)) != STRING
)
127 Error (QUOTE_MSG
, "RGBPath");
128 ptr
->file_rgbpath
= val
.str
;
131 if (xf86getSubToken (&(ptr
->file_comment
)) != STRING
)
132 Error (QUOTE_MSG
, "ModulePath");
135 if (ptr
->file_modulepath
== NULL
)
137 ptr
->file_modulepath
= xf86confmalloc (1);
138 ptr
->file_modulepath
[0] = '\0';
139 k
= strlen (str
) + 1;
143 k
= strlen (ptr
->file_modulepath
) + strlen (str
) + 1;
144 if (ptr
->file_modulepath
[strlen (ptr
->file_modulepath
) - 1] != ',')
150 ptr
->file_modulepath
= xf86confrealloc (ptr
->file_modulepath
, k
);
152 strcat (ptr
->file_modulepath
, ",");
154 strcat (ptr
->file_modulepath
, str
);
155 xf86conffree (val
.str
);
158 if (xf86getSubToken (&(ptr
->file_comment
)) != STRING
)
159 Error (QUOTE_MSG
, "InputDevices");
162 if (ptr
->file_inputdevs
== NULL
)
164 ptr
->file_inputdevs
= xf86confmalloc (1);
165 ptr
->file_inputdevs
[0] = '\0';
166 k
= strlen (str
) + 1;
170 k
= strlen (ptr
->file_inputdevs
) + strlen (str
) + 1;
171 if (ptr
->file_inputdevs
[strlen (ptr
->file_inputdevs
) - 1] != ',')
177 ptr
->file_inputdevs
= xf86confrealloc (ptr
->file_inputdevs
, k
);
179 strcat (ptr
->file_inputdevs
, ",");
181 strcat (ptr
->file_inputdevs
, str
);
182 xf86conffree (val
.str
);
185 if (xf86getSubToken (&(ptr
->file_comment
)) != STRING
)
186 Error (QUOTE_MSG
, "LogFile");
187 ptr
->file_logfile
= val
.str
;
190 Error (UNEXPECTED_EOF_MSG
, NULL
);
193 Error (INVALID_KEYWORD_MSG
, xf86tokenString ());
199 printf ("File section parsed\n");
208 xf86printFileSection (FILE * cf
, XF86ConfFilesPtr ptr
)
215 if (ptr
->file_comment
)
216 fprintf (cf
, "%s", ptr
->file_comment
);
217 if (ptr
->file_logfile
)
218 fprintf (cf
, "\tLogFile \"%s\"\n", ptr
->file_logfile
);
219 if (ptr
->file_rgbpath
)
220 fprintf (cf
, "\tRgbPath \"%s\"\n", ptr
->file_rgbpath
);
221 if (ptr
->file_modulepath
)
223 s
= ptr
->file_modulepath
;
228 fprintf (cf
, "\tModulePath \"%s\"\n", s
);
234 fprintf (cf
, "\tModulePath \"%s\"\n", s
);
236 if (ptr
->file_inputdevs
)
238 s
= ptr
->file_inputdevs
;
243 fprintf (cf
, "\tInputDevices \"%s\"\n", s
);
249 fprintf (cf
, "\tInputDevices \"%s\"\n", s
);
251 if (ptr
->file_fontpath
)
253 s
= ptr
->file_fontpath
;
258 fprintf (cf
, "\tFontPath \"%s\"\n", s
);
264 fprintf (cf
, "\tFontPath \"%s\"\n", s
);
269 xf86freeFiles (XF86ConfFilesPtr p
)
274 TestFree (p
->file_logfile
);
275 TestFree (p
->file_rgbpath
);
276 TestFree (p
->file_modulepath
);
277 TestFree (p
->file_inputdevs
);
278 TestFree (p
->file_fontpath
);
279 TestFree (p
->file_comment
);