First import
[xorg_rtime.git] / xorg-server-1.4 / hw / xfree86 / parser / cpconfig.c
blob46a5a8b562393d8d798159a2f1e11e14be45f6ec
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:
12 * The above copyright notice and this permission notice shall be included in
13 * all copies or substantial portions of the Software.
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.
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.
29 /* View/edit this file with tab stops set to 4 */
31 #ifdef HAVE_XORG_CONFIG_H
32 #include <xorg-config.h>
33 #endif
35 #include <stdio.h>
36 #include <stdlib.h>
37 #include <stdarg.h>
38 #include <ctype.h>
39 #include "xf86Parser.h"
40 #include "configProcs.h"
42 #ifdef MALLOC_FUNCTIONS
43 void
44 xfree (void *p)
46 free (p);
47 return;
50 void *
51 xalloc (int size)
53 return malloc (size);
56 void *
57 xrealloc (void *p, int size)
59 return realloc (p, size);
62 #endif
64 #define CONFPATH "%A,%R,/etc/X11/%R,%P/etc/X11/%R,%E,%F,/etc/X11/%F," \
65 "%P/etc/X11/%F,%D/%X,/etc/X11/%X,/etc/%X,%P/etc/X11/%X.%H," \
66 "%P/etc/X11/%X,%P/lib/X11/%X.%H,%P/lib/X11/%X"
68 int
69 main (int argc, char *argv[])
71 const char *filename;
72 char *cmdline = NULL;
73 XF86ConfigPtr conf;
75 if (argc > 1)
77 cmdline = argv[1];
79 if ((filename = xf86openConfigFile (CONFPATH, cmdline, NULL)))
81 fprintf (stderr, "Opened %s for the config file\n", filename);
83 else
85 fprintf (stderr, "Unable to open config file\n");
86 exit (1);
89 if ((conf = xf86readConfigFile ()) == NULL)
91 fprintf (stderr, "Problem when parsing config file\n");
93 else
95 fprintf (stderr, "Config file parsed OK\n");
97 xf86closeConfigFile ();
99 if (argc > 2) {
100 fprintf(stderr, "Writing config file to `%s'\n", argv[2]);
101 xf86writeConfigFile (argv[2], conf);
103 exit(0);
106 /* Functions that the parser requires */
108 _X_EXPORT void
109 VErrorF(const char *f, va_list args)
111 vfprintf(stderr, f, args);
114 _X_EXPORT void
115 ErrorF(const char *f, ...)
117 va_list args;
119 va_start(args, f);
120 vfprintf(stderr, f, args);
121 va_end(args);