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).
54 #ifdef HAVE_XORG_CONFIG_H
55 #include <xorg-config.h>
59 #include "xf86Parser.h"
60 #include "xf86tokens.h"
61 #include "Configint.h"
65 static xf86ConfigSymTabRec FilesTab
[] = {
66 {ENDSECTION
, "endsection"},
67 {FONTPATH
, "fontpath"},
68 {MODULEPATH
, "modulepath"},
69 {LOGFILEPATH
, "logfile"},
71 /* Obsolete keywords that aren't used but shouldn't cause errors: */
72 {OBSOLETE_TOKEN
, "rgbpath"},
73 {OBSOLETE_TOKEN
, "inputdevices"},
77 #define CLEANUP xf86freeFiles
80 xf86parseFilesSection(void)
87 parsePrologue(XF86ConfFilesPtr
, XF86ConfFilesRec
)
89 while ((token
= xf86getToken(FilesTab
)) != ENDSECTION
) {
92 ptr
->file_comment
= xf86addComment(ptr
->file_comment
, val
.str
);
95 if (xf86getSubToken(&(ptr
->file_comment
)) != STRING
)
96 Error(QUOTE_MSG
, "FontPath");
99 if (ptr
->file_fontpath
== NULL
) {
100 ptr
->file_fontpath
= malloc(1);
101 ptr
->file_fontpath
[0] = '\0';
105 i
= strlen(ptr
->file_fontpath
) + strlen(str
) + 1;
106 if (ptr
->file_fontpath
[strlen(ptr
->file_fontpath
) - 1] != ',') {
111 ptr
->file_fontpath
= realloc(ptr
->file_fontpath
, i
);
113 strcat(ptr
->file_fontpath
, ",");
115 strcat(ptr
->file_fontpath
, str
);
119 if (xf86getSubToken(&(ptr
->file_comment
)) != STRING
)
120 Error(QUOTE_MSG
, "ModulePath");
123 if (ptr
->file_modulepath
== NULL
) {
124 ptr
->file_modulepath
= malloc(1);
125 ptr
->file_modulepath
[0] = '\0';
129 k
= strlen(ptr
->file_modulepath
) + strlen(str
) + 1;
130 if (ptr
->file_modulepath
[strlen(ptr
->file_modulepath
) - 1] !=
136 ptr
->file_modulepath
= realloc(ptr
->file_modulepath
, k
);
138 strcat(ptr
->file_modulepath
, ",");
140 strcat(ptr
->file_modulepath
, str
);
144 if (xf86getSubToken(&(ptr
->file_comment
)) != STRING
)
145 Error(QUOTE_MSG
, "LogFile");
146 ptr
->file_logfile
= val
.str
;
149 if (xf86getSubToken(&(ptr
->file_xkbdir
)) != STRING
)
150 Error(QUOTE_MSG
, "XkbDir");
151 ptr
->file_xkbdir
= val
.str
;
154 Error(UNEXPECTED_EOF_MSG
);
157 xf86parseError(OBSOLETE_MSG
, xf86tokenString());
158 xf86getSubToken(&(ptr
->file_comment
));
161 Error(INVALID_KEYWORD_MSG
, xf86tokenString());
167 printf("File section parsed\n");
176 xf86printFileSection(FILE * cf
, XF86ConfFilesPtr ptr
)
183 if (ptr
->file_comment
)
184 fprintf(cf
, "%s", ptr
->file_comment
);
185 if (ptr
->file_logfile
)
186 fprintf(cf
, "\tLogFile \"%s\"\n", ptr
->file_logfile
);
187 if (ptr
->file_modulepath
) {
188 s
= ptr
->file_modulepath
;
192 fprintf(cf
, "\tModulePath \"%s\"\n", s
);
198 fprintf(cf
, "\tModulePath \"%s\"\n", s
);
200 if (ptr
->file_fontpath
) {
201 s
= ptr
->file_fontpath
;
205 fprintf(cf
, "\tFontPath \"%s\"\n", s
);
211 fprintf(cf
, "\tFontPath \"%s\"\n", s
);
213 if (ptr
->file_xkbdir
)
214 fprintf(cf
, "\tXkbDir \"%s\"\n", ptr
->file_xkbdir
);
218 xf86freeFiles(XF86ConfFilesPtr p
)
223 TestFree(p
->file_logfile
);
224 TestFree(p
->file_modulepath
);
225 TestFree(p
->file_fontpath
);
226 TestFree(p
->file_comment
);
227 TestFree(p
->file_xkbdir
);