1117N/A/*
1117N/A *
1117N/A * Copyright (c) 1997 Metro Link Incorporated
1117N/A *
1117N/A * Permission is hereby granted, free of charge, to any person obtaining a
1117N/A * copy of this software and associated documentation files (the "Software"),
1117N/A * to deal in the Software without restriction, including without limitation
1117N/A * the rights to use, copy, modify, merge, publish, distribute, sublicense,
1117N/A * and/or sell copies of the Software, and to permit persons to whom the
1117N/A * Software is furnished to do so, subject to the following conditions:
1117N/A *
1117N/A * The above copyright notice and this permission notice shall be included in
1117N/A * all copies or substantial portions of the Software.
1117N/A *
1117N/A * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
1117N/A * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
1117N/A * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
1117N/A * THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
1117N/A * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
1117N/A * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
1117N/A * SOFTWARE.
1117N/A *
1117N/A * Except as contained in this notice, the name of the Metro Link shall not be
1117N/A * used in advertising or otherwise to promote the sale, use or other dealings
1117N/A * in this Software without prior written authorization from Metro Link.
1117N/A *
1117N/A */
1117N/A/*
1117N/A * Copyright (c) 1997-2003 by The XFree86 Project, Inc.
1117N/A *
1117N/A * Permission is hereby granted, free of charge, to any person obtaining a
1117N/A * copy of this software and associated documentation files (the "Software"),
1117N/A * to deal in the Software without restriction, including without limitation
1117N/A * the rights to use, copy, modify, merge, publish, distribute, sublicense,
1117N/A * and/or sell copies of the Software, and to permit persons to whom the
1117N/A * Software is furnished to do so, subject to the following conditions:
1117N/A *
1117N/A * The above copyright notice and this permission notice shall be included in
1117N/A * all copies or substantial portions of the Software.
1117N/A *
1117N/A * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
1117N/A * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
1117N/A * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
1117N/A * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
1117N/A * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
1117N/A * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
1117N/A * OTHER DEALINGS IN THE SOFTWARE.
1117N/A *
1117N/A * Except as contained in this notice, the name of the copyright holder(s)
1117N/A * and author(s) shall not be used in advertising or otherwise to promote
1117N/A * the sale, use or other dealings in this Software without prior written
1117N/A * authorization from the copyright holder(s) and author(s).
1117N/A */
1117N/A
1117N/A
1117N/A/* View/edit this file with tab stops set to 4 */
1117N/A
1117N/A#ifdef HAVE_XORG_CONFIG_H
1117N/A#include <xorg-config.h>
1117N/A#endif
1117N/A
1117N/A#if (0)
1117N/A#include <X11/Xos.h>
1117N/A#endif
1117N/A#include "xf86Parser.h"
1117N/A#include "xf86tokens.h"
1117N/A#include "Configint.h"
1117N/A
1117N/Aextern LexRec val;
1117N/A
1117N/Astatic xf86ConfigSymTabRec FilesTab[] =
1117N/A{
1117N/A {ENDSECTION, "endsection"},
1117N/A {FONTPATH, "fontpath"},
1117N/A {RGBPATH, "rgbpath"},
1117N/A {MODULEPATH, "modulepath"},
1117N/A {INPUTDEVICES, "inputdevices"},
1117N/A {LOGFILEPATH, "logfile"},
1117N/A {-1, ""},
1117N/A};
1117N/A
1117N/Astatic char *
1117N/AprependRoot (char *pathname)
1117N/A{
1117N/A#ifndef __EMX__
1117N/A return pathname;
1117N/A#else
1117N/A /* XXXX caveat: multiple path components in line */
1117N/A return (char *) __XOS2RedirRoot (pathname);
1117N/A#endif
1117N/A}
1117N/A
1117N/A#define CLEANUP xf86freeFiles
1117N/A
1117N/AXF86ConfFilesPtr
1117N/Axf86parseFilesSection (void)
1117N/A{
1117N/A int i, j;
1117N/A int k, l;
1117N/A char *str;
1117N/A int token;
1117N/A parsePrologue (XF86ConfFilesPtr, XF86ConfFilesRec)
1117N/A
1117N/A while ((token = xf86getToken (FilesTab)) != ENDSECTION)
1117N/A {
1117N/A switch (token)
1117N/A {
1117N/A case COMMENT:
1117N/A ptr->file_comment = xf86addComment(ptr->file_comment, val.str);
1117N/A break;
1117N/A case FONTPATH:
1117N/A if (xf86getSubToken (&(ptr->file_comment)) != STRING)
1117N/A Error (QUOTE_MSG, "FontPath");
1117N/A j = FALSE;
1117N/A str = prependRoot (val.str);
1117N/A if (ptr->file_fontpath == NULL)
1117N/A {
1117N/A ptr->file_fontpath = xf86confmalloc (1);
1117N/A ptr->file_fontpath[0] = '\0';
1117N/A i = strlen (str) + 1;
1117N/A }
1117N/A else
1117N/A {
1117N/A i = strlen (ptr->file_fontpath) + strlen (str) + 1;
1117N/A if (ptr->file_fontpath[strlen (ptr->file_fontpath) - 1] != ',')
1117N/A {
1117N/A i++;
1117N/A j = TRUE;
1117N/A }
1117N/A }
1117N/A ptr->file_fontpath =
1117N/A xf86confrealloc (ptr->file_fontpath, i);
1117N/A if (j)
1117N/A strcat (ptr->file_fontpath, ",");
1117N/A
1117N/A strcat (ptr->file_fontpath, str);
1117N/A xf86conffree (val.str);
1117N/A break;
1117N/A case RGBPATH:
1117N/A if (xf86getSubToken (&(ptr->file_comment)) != STRING)
1117N/A Error (QUOTE_MSG, "RGBPath");
1117N/A ptr->file_rgbpath = val.str;
1117N/A break;
1117N/A case MODULEPATH:
1117N/A if (xf86getSubToken (&(ptr->file_comment)) != STRING)
1117N/A Error (QUOTE_MSG, "ModulePath");
1117N/A l = FALSE;
1117N/A str = prependRoot (val.str);
1117N/A if (ptr->file_modulepath == NULL)
1117N/A {
1117N/A ptr->file_modulepath = xf86confmalloc (1);
1117N/A ptr->file_modulepath[0] = '\0';
1117N/A k = strlen (str) + 1;
1117N/A }
1117N/A else
1117N/A {
1117N/A k = strlen (ptr->file_modulepath) + strlen (str) + 1;
1117N/A if (ptr->file_modulepath[strlen (ptr->file_modulepath) - 1] != ',')
1117N/A {
1117N/A k++;
1117N/A l = TRUE;
1117N/A }
1117N/A }
1117N/A ptr->file_modulepath = xf86confrealloc (ptr->file_modulepath, k);
1117N/A if (l)
1117N/A strcat (ptr->file_modulepath, ",");
1117N/A
1117N/A strcat (ptr->file_modulepath, str);
1117N/A xf86conffree (val.str);
1117N/A break;
1117N/A case INPUTDEVICES:
1117N/A if (xf86getSubToken (&(ptr->file_comment)) != STRING)
1117N/A Error (QUOTE_MSG, "InputDevices");
1117N/A l = FALSE;
1117N/A str = prependRoot (val.str);
1117N/A if (ptr->file_inputdevs == NULL)
1117N/A {
1117N/A ptr->file_inputdevs = xf86confmalloc (1);
1117N/A ptr->file_inputdevs[0] = '\0';
1117N/A k = strlen (str) + 1;
1117N/A }
1117N/A else
1117N/A {
1117N/A k = strlen (ptr->file_inputdevs) + strlen (str) + 1;
1117N/A if (ptr->file_inputdevs[strlen (ptr->file_inputdevs) - 1] != ',')
1117N/A {
1117N/A k++;
1117N/A l = TRUE;
1117N/A }
1117N/A }
1117N/A ptr->file_inputdevs = xf86confrealloc (ptr->file_inputdevs, k);
1117N/A if (l)
1117N/A strcat (ptr->file_inputdevs, ",");
1117N/A
1117N/A strcat (ptr->file_inputdevs, str);
1117N/A xf86conffree (val.str);
1117N/A break;
1117N/A case LOGFILEPATH:
1117N/A if (xf86getSubToken (&(ptr->file_comment)) != STRING)
1117N/A Error (QUOTE_MSG, "LogFile");
1117N/A ptr->file_logfile = val.str;
1117N/A break;
1117N/A case EOF_TOKEN:
1117N/A Error (UNEXPECTED_EOF_MSG, NULL);
1117N/A break;
1117N/A default:
1117N/A Error (INVALID_KEYWORD_MSG, xf86tokenString ());
1117N/A break;
1117N/A }
1117N/A }
1117N/A
1117N/A#ifdef DEBUG
1117N/A printf ("Files section parsed\n");
1117N/A#endif
1117N/A
1117N/A return ptr;
1117N/A}
1117N/A
1117N/A#undef CLEANUP
1117N/A
1117N/Avoid
1117N/Axf86printFileSection (FILE * cf, XF86ConfFilesPtr ptr)
1117N/A{
1117N/A char *p, *s;
1117N/A
1117N/A if (ptr == NULL)
1117N/A return;
1117N/A
1117N/A fprintf (cf, "Section \"Files\"\n");
1117N/A
1117N/A if (ptr->file_comment)
1117N/A fprintf (cf, "%s", ptr->file_comment);
1117N/A if (ptr->file_logfile)
1117N/A fprintf (cf, "\tLogFile \"%s\"\n", ptr->file_logfile);
1117N/A if (ptr->file_rgbpath)
1117N/A fprintf (cf, "\tRgbPath \"%s\"\n", ptr->file_rgbpath);
1117N/A if (ptr->file_modulepath)
1117N/A {
1117N/A s = ptr->file_modulepath;
1117N/A p = strchr (s, ',');
1117N/A while (p)
1117N/A {
1117N/A *p = '\000';
1117N/A fprintf (cf, "\tModulePath \"%s\"\n", s);
1117N/A *p = ',';
1117N/A s = p;
1117N/A s++;
1117N/A p = strchr (s, ',');
1117N/A }
1117N/A fprintf (cf, "\tModulePath \"%s\"\n", s);
1117N/A }
1117N/A if (ptr->file_inputdevs)
1117N/A {
1117N/A s = ptr->file_inputdevs;
1117N/A p = strchr (s, ',');
1117N/A while (p)
1117N/A {
1117N/A *p = '\000';
1117N/A fprintf (cf, "\tInputDevices \"%s\"\n", s);
1117N/A *p = ',';
1117N/A s = p;
1117N/A s++;
1117N/A p = strchr (s, ',');
1117N/A }
1117N/A fprintf (cf, "\tInputdevs \"%s\"\n", s);
1117N/A }
1117N/A if (ptr->file_fontpath)
1117N/A {
1117N/A s = ptr->file_fontpath;
1117N/A p = strchr (s, ',');
1117N/A while (p)
1117N/A {
1117N/A *p = '\000';
1117N/A fprintf (cf, "\tFontPath \"%s\"\n", s);
1117N/A *p = ',';
1117N/A s = p;
1117N/A s++;
1117N/A p = strchr (s, ',');
1117N/A }
1117N/A fprintf (cf, "\tFontPath \"%s\"\n", s);
1117N/A }
1117N/A fprintf (cf, "EndSection\n\n");
1117N/A}
1117N/A
1117N/Avoid
1117N/Axf86freeFiles (XF86ConfFilesPtr p)
1117N/A{
1117N/A if (p == NULL)
1117N/A return;
1117N/A
1117N/A TestFree (p->file_logfile);
1117N/A TestFree (p->file_rgbpath);
1117N/A TestFree (p->file_modulepath);
1117N/A TestFree (p->file_inputdevs);
1117N/A TestFree (p->file_fontpath);
1117N/A TestFree (p->file_comment);
1117N/A
1117N/A xf86conffree (p);
1117N/A}
1117N/A