diff options
author | Matthieu Herrb <matthieu@cvs.openbsd.org> | 2008-06-13 21:00:37 +0000 |
---|---|---|
committer | Matthieu Herrb <matthieu@cvs.openbsd.org> | 2008-06-13 21:00:37 +0000 |
commit | 4d24003fedd96a6d1e7801d9dd99e48ade5ba410 (patch) | |
tree | 826d02765d6b23f62efc3d5cfd3785629f0a55f7 /app/xfs/os/config.c | |
parent | 1d806dfb5f48abe149074e7e3df7b6a7b76f68ba (diff) |
update to xfs 1.0.8.
(The multiple defined symbol problem is not fixed yet)
Diffstat (limited to 'app/xfs/os/config.c')
-rw-r--r-- | app/xfs/os/config.c | 44 |
1 files changed, 40 insertions, 4 deletions
diff --git a/app/xfs/os/config.c b/app/xfs/os/config.c index e5dbc4801..1abf2afff 100644 --- a/app/xfs/os/config.c +++ b/app/xfs/os/config.c @@ -49,6 +49,8 @@ in this Software without prior written authorization from The Open Group. */ /* $XFree86: xc/programs/xfs/os/config.c,v 3.15 2002/05/31 18:46:12 dawes Exp $ */ +#include <xfs-config.h> + #include <stdio.h> #include <stdlib.h> #include <ctype.h> @@ -66,6 +68,15 @@ in this Software without prior written authorization from The Open Group. #include <X11/fonts/fontutil.h> #include "difs.h" +static const char * const default_config_files[] = { +#ifdef DEFAULT_CONFIG_FILE + DEFAULT_CONFIG_FILE, +#else + "/usr/lib/X11/fs/config", +#endif + NULL +}; + extern int portFromCmdline; static char *font_catalogue = NULL; @@ -285,6 +296,10 @@ SetConfigValues(void) int err, num; + if (font_catalogue == NULL) { + FatalError("font catalogue is missing/empty\n"); + } + err = SetFontCatalogue(font_catalogue, &num); if (err != FSSuccess) { FatalError("element #%d (starting at 0) of font path is bad or has a bad font:\n\"%s\"\n", @@ -315,12 +330,14 @@ char *__XFSRedirRoot(char *fname) } #endif +/* If argument is NULL, uses first file found from default_config_files */ int -ReadConfigFile(char *filename) +ReadConfigFile(const char *filename) { FILE *fp; int ret; int len; + int i; char *data; data = (char *) fsalloc(CONFIG_MAX_FILESIZE); @@ -328,12 +345,31 @@ ReadConfigFile(char *filename) ErrorF(ConfigErrors[CONFIG_ERR_MEMORY], filename); return FSBadAlloc; } + if (filename != NULL) { #ifdef __UNIXOS2__ - filename = __XFSRedirRoot(filename); + filename = __XFSRedirRoot(filename); #endif - if ((fp = fopen(filename, "r")) == NULL) { + fp = fopen(filename, "r"); + if (fp == NULL) { + ErrorF(ConfigErrors[CONFIG_ERR_OPEN], filename); + } + } else { + for (i = 0; default_config_files[i] != NULL; i++) { + filename = default_config_files[i]; +#ifdef __UNIXOS2__ + filename = __XFSRedirRoot(filename); +#endif + if ((fp = fopen(filename, "r")) != NULL) + break; + } + if (fp == NULL) { + for (i = 0; default_config_files[i] != NULL; i++) { + ErrorF(ConfigErrors[CONFIG_ERR_OPEN], default_config_files[i]); + } + } + } + if (fp == NULL) { fsfree(data); - ErrorF(ConfigErrors[CONFIG_ERR_OPEN], filename); return FSBadName; } ret = fread(data, sizeof(char), CONFIG_MAX_FILESIZE, fp); |