summaryrefslogtreecommitdiff
path: root/hw
diff options
context:
space:
mode:
authorKevin E Martin <kem@kem.org>2004-07-31 09:14:06 +0000
committerKevin E Martin <kem@kem.org>2004-07-31 09:14:06 +0000
commit383b6b59864098b03d991628ff5933d997793ea1 (patch)
tree8c09ab41d2a62542369fb50bc2ac440429d7e54d /hw
parentd690556d496c7331bd112903a0c9e6553c7d3342 (diff)
Add "Extensions" section support to configuration parser
Diffstat (limited to 'hw')
-rw-r--r--hw/xfree86/common/xf86Config.c46
-rw-r--r--hw/xfree86/parser/Extensions.c107
-rw-r--r--hw/xfree86/parser/configProcs.h4
-rw-r--r--hw/xfree86/parser/read.c7
-rw-r--r--hw/xfree86/parser/write.c2
-rw-r--r--hw/xfree86/parser/xf86Parser.h8
6 files changed, 172 insertions, 2 deletions
diff --git a/hw/xfree86/common/xf86Config.c b/hw/xfree86/common/xf86Config.c
index fd5de965a..cf3ea927b 100644
--- a/hw/xfree86/common/xf86Config.c
+++ b/hw/xfree86/common/xf86Config.c
@@ -1,4 +1,4 @@
-/* $XdotOrg$ */
+/* $XdotOrg: xc/programs/Xserver/hw/xfree86/common/xf86Config.c,v 1.2 2004/04/23 19:20:32 eich Exp $ */
/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86Config.c,v 3.276 2003/10/08 14:58:26 dawes Exp $ */
@@ -128,6 +128,7 @@ static Bool addDefaultModes(MonPtr monitorp);
#ifdef XF86DRI
static Bool configDRI(XF86ConfDRIPtr drip);
#endif
+static Bool configExtensions(XF86ConfExtensionsPtr conf_ext);
/*
* xf86GetPathElem --
@@ -2396,6 +2397,46 @@ configDRI(XF86ConfDRIPtr drip)
#endif
static Bool
+configExtensions(XF86ConfExtensionsPtr conf_ext)
+{
+ XF86OptionPtr o;
+
+ /* Extension enable/disable in miinitext.c */
+ extern Bool EnableDisableExtension(char *name, Bool enable);
+
+ if (conf_ext && conf_ext->ext_option_lst) {
+ for (o = conf_ext->ext_option_lst; o; o = xf86NextOption(o)) {
+ char *name = xf86OptionName(o);
+ char *val = xf86OptionValue(o);
+ if (xf86NameCmp(val, "enable") == 0) {
+ if (EnableDisableExtension(name, TRUE)) {
+ xf86Msg(X_CONFIG, "Extension \"%s\" is enabled\n", name);
+ } else {
+ xf86Msg(X_ERROR,
+ "Extension \"%s\" is unrecognized\n", name);
+ return FALSE;
+ }
+ } else if (xf86NameCmp(val, "disable") == 0) {
+ if (EnableDisableExtension(name, FALSE)) {
+ xf86Msg(X_CONFIG, "Extension \"%s\" is disabled\n", name);
+ } else {
+ xf86Msg(X_ERROR,
+ "Extension \"%s\" is unrecognized\n", name);
+ return FALSE;
+ }
+ } else {
+ xf86Msg(X_ERROR,
+ "%s is not a valid value for the Extension option\n",
+ val);
+ return FALSE;
+ }
+ }
+ }
+
+ return TRUE;
+}
+
+static Bool
configInput(IDevPtr inputp, XF86ConfInputPtr conf_input, MessageType from)
{
xf86Msg(from, "|-->Input Device \"%s\"\n", conf_input->inp_identifier);
@@ -2551,7 +2592,8 @@ xf86HandleConfigFile(Bool autoconfig)
if (!configFiles(xf86configptr->conf_files) ||
!configServerFlags(xf86configptr->conf_flags,
- xf86ConfigLayout.options)
+ xf86ConfigLayout.options) ||
+ !configExtensions(xf86configptr->conf_extensions)
#ifdef XF86DRI
|| !configDRI(xf86configptr->conf_dri)
#endif
diff --git a/hw/xfree86/parser/Extensions.c b/hw/xfree86/parser/Extensions.c
new file mode 100644
index 000000000..0c51a6e33
--- /dev/null
+++ b/hw/xfree86/parser/Extensions.c
@@ -0,0 +1,107 @@
+/*
+ * Copyright 2004 Red Hat Inc., Raleigh, North Carolina.
+ *
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation on the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial
+ * portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NON-INFRINGEMENT. IN NO EVENT SHALL RED HAT AND/OR THEIR SUPPLIERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+/*
+ * Authors:
+ * Kevin E. Martin <kem@redhat.com>
+ *
+ */
+
+#include "xf86Parser.h"
+#include "xf86tokens.h"
+#include "Configint.h"
+
+extern LexRec val;
+
+static xf86ConfigSymTabRec ExtensionsTab[] =
+{
+ {ENDSECTION, "endsection"},
+ {OPTION, "option"},
+ {-1, ""},
+};
+
+#define CLEANUP xf86freeExtensions
+
+XF86ConfExtensionsPtr
+xf86parseExtensionsSection (void)
+{
+ int token;
+ parsePrologue (XF86ConfExtensionsPtr, XF86ConfExtensionsRec);
+
+ while ((token = xf86getToken (ExtensionsTab)) != ENDSECTION) {
+ switch (token) {
+ case OPTION:
+ ptr->ext_option_lst = xf86parseOption(ptr->ext_option_lst);
+ break;
+ case EOF_TOKEN:
+ Error (UNEXPECTED_EOF_MSG, NULL);
+ break;
+ case COMMENT:
+ ptr->extensions_comment =
+ xf86addComment(ptr->extensions_comment, val.str);
+ break;
+ default:
+ Error (INVALID_KEYWORD_MSG, xf86tokenString ());
+ break;
+ }
+ }
+
+#ifdef DEBUG
+ ErrorF("Extensions section parsed\n");
+#endif
+
+ return ptr;
+}
+
+#undef CLEANUP
+
+void
+xf86printExtensionsSection (FILE * cf, XF86ConfExtensionsPtr ptr)
+{
+ XF86OptionPtr p;
+
+ if (ptr == NULL || ptr->ext_option_lst == NULL)
+ return;
+
+ p = ptr->ext_option_lst;
+ fprintf (cf, "Section \"Extensions\"\n");
+ if (ptr->extensions_comment)
+ fprintf (cf, "%s", ptr->extensions_comment);
+ xf86printOptionList(cf, p, 1);
+ fprintf (cf, "EndSection\n\n");
+}
+
+void
+xf86freeExtensions (XF86ConfExtensionsPtr ptr)
+{
+ if (ptr == NULL)
+ return;
+
+ xf86optionListFree (ptr->ext_option_lst);
+ TestFree (ptr->extensions_comment);
+ xf86conffree (ptr);
+}
diff --git a/hw/xfree86/parser/configProcs.h b/hw/xfree86/parser/configProcs.h
index 522cf5c2f..cc694666f 100644
--- a/hw/xfree86/parser/configProcs.h
+++ b/hw/xfree86/parser/configProcs.h
@@ -116,6 +116,10 @@ void xf86freeBuffersList (XF86ConfBuffersPtr ptr);
XF86ConfDRIPtr xf86parseDRISection (void);
void xf86printDRISection (FILE * cf, XF86ConfDRIPtr ptr);
void xf86freeDRI (XF86ConfDRIPtr ptr);
+/* Extensions.c */
+XF86ConfExtensionsPtr xf86parseExtensionsSection (void);
+void xf86printExtensionsSection (FILE * cf, XF86ConfExtensionsPtr ptr);
+void xf86freeExtensions (XF86ConfExtensionsPtr ptr);
#ifndef IN_XSERVER
/* Externally provided functions */
diff --git a/hw/xfree86/parser/read.c b/hw/xfree86/parser/read.c
index 2a5afeb27..2946dc8b1 100644
--- a/hw/xfree86/parser/read.c
+++ b/hw/xfree86/parser/read.c
@@ -191,6 +191,12 @@ xf86readConfigFile (void)
val.str = NULL;
HANDLE_RETURN (conf_dri, xf86parseDRISection ());
}
+ else if (xf86nameCompare (val.str, "extensions") == 0)
+ {
+ xf86conffree(val.str);
+ val.str = NULL;
+ HANDLE_RETURN (conf_extensions, xf86parseExtensionsSection ());
+ }
else
{
Error (INVALID_SECTION_MSG, xf86tokenString ());
@@ -304,6 +310,7 @@ xf86freeConfig (XF86ConfigPtr p)
xf86freeInputList (p->conf_input_lst);
xf86freeVendorList (p->conf_vendor_lst);
xf86freeDRI (p->conf_dri);
+ xf86freeExtensions (p->conf_extensions);
TestFree(p->conf_comment);
xf86conffree (p);
diff --git a/hw/xfree86/parser/write.c b/hw/xfree86/parser/write.c
index e096c6247..499b6a11e 100644
--- a/hw/xfree86/parser/write.c
+++ b/hw/xfree86/parser/write.c
@@ -130,6 +130,8 @@ doWriteConfigFile (const char *filename, XF86ConfigPtr cptr)
xf86printDRISection (cf, cptr->conf_dri);
+ xf86printExtensionsSection (cf, cptr->conf_extensions);
+
fclose(cf);
return 1;
}
diff --git a/hw/xfree86/parser/xf86Parser.h b/hw/xfree86/parser/xf86Parser.h
index 1a30d17a8..b6a974d3c 100644
--- a/hw/xfree86/parser/xf86Parser.h
+++ b/hw/xfree86/parser/xf86Parser.h
@@ -416,6 +416,13 @@ XF86ConfDRIRec, *XF86ConfDRIPtr;
typedef struct
{
+ XF86OptionPtr ext_option_lst;
+ char *extensions_comment;
+}
+XF86ConfExtensionsRec, *XF86ConfExtensionsPtr;
+
+typedef struct
+{
XF86ConfFilesPtr conf_files;
XF86ConfModulePtr conf_modules;
XF86ConfFlagsPtr conf_flags;
@@ -428,6 +435,7 @@ typedef struct
XF86ConfLayoutPtr conf_layout_lst;
XF86ConfVendorPtr conf_vendor_lst;
XF86ConfDRIPtr conf_dri;
+ XF86ConfExtensionsPtr conf_extensions;
char *conf_comment;
}
XF86ConfigRec, *XF86ConfigPtr;