summaryrefslogtreecommitdiff
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
parentd690556d496c7331bd112903a0c9e6553c7d3342 (diff)
Add "Extensions" section support to configuration parser
-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
-rw-r--r--include/globals.h6
-rw-r--r--mi/miinitext.c21
-rw-r--r--os/utils.c21
9 files changed, 211 insertions, 11 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;
diff --git a/include/globals.h b/include/globals.h
index 1a22bb6f9..c9e6fd245 100644
--- a/include/globals.h
+++ b/include/globals.h
@@ -1,4 +1,4 @@
-/* $XdotOrg: xc/programs/Xserver/include/globals.h,v 1.2 2004/04/23 19:54:23 eich Exp $ */
+/* $XdotOrg: xc/programs/Xserver/include/globals.h,v 1.3 2004/07/31 04:23:21 kem Exp $ */
/* $XFree86: xc/programs/Xserver/include/globals.h,v 1.3 1999/09/25 14:38:21 dawes Exp $ */
#ifndef _XSERV_GLOBAL_H_
@@ -57,4 +57,8 @@ extern Bool noRenderExtension;
extern Bool noXevieExtension;
#endif
+#ifdef COMPOSITE
+extern Bool noCompositeExtension;
+#endif
+
#endif /* _XSERV_GLOBAL_H_ */
diff --git a/mi/miinitext.c b/mi/miinitext.c
index ec4ae1aa4..be4856fec 100644
--- a/mi/miinitext.c
+++ b/mi/miinitext.c
@@ -1,4 +1,4 @@
-/* $XdotOrg: xc/programs/Xserver/mi/miinitext.c,v 1.7 2004/07/31 04:23:21 kem Exp $ */
+/* $XdotOrg: xc/programs/Xserver/mi/miinitext.c,v 1.8 2004/07/31 08:24:14 anholt Exp $ */
/* $XFree86: xc/programs/Xserver/mi/miinitext.c,v 3.67 2003/01/12 02:44:27 dawes Exp $ */
/***********************************************************
@@ -101,6 +101,9 @@ extern Bool noRenderExtension;
#ifdef XEVIE
extern Bool noXevieExtension;
#endif
+#ifdef COMPOSITE
+extern Bool noCompositeExtension;
+#endif
#ifndef XFree86LOADER
#define INITARGS void
@@ -309,6 +312,9 @@ static ExtensionToggle ExtensionToggleList[] =
#ifdef XEVIE
{ "XEVIE", &noXevieExtension },
#endif
+#ifdef COMPOSITE
+ { "COMPOSITE", &noCompositeExtension },
+#endif
{ NULL, NULL }
};
@@ -323,13 +329,18 @@ Bool EnableDisableExtension(char *name, Bool enable)
}
}
+ return FALSE;
+}
+
+void EnableDisableExtensionError(char *name, Bool enable)
+{
+ ExtensionToggle *ext = &ExtensionToggleList[0];
+
ErrorF("Extension \"%s\" is not recognized\n", name);
ErrorF("Only the following extensions can be run-time %s:\n",
enable ? "enabled" : "disabled");
for (ext = &ExtensionToggleList[0]; ext->name != NULL; ext++)
ErrorF(" %s\n", ext->name);
-
- return FALSE;
}
#ifndef XFree86LOADER
@@ -482,7 +493,7 @@ InitExtensions(argc, argv)
DamageExtensionInit();
#endif
#ifdef COMPOSITE
- CompositeExtensionInit ();
+ if (!noCompositeExtension) CompositeExtensionInit();
#endif
}
@@ -614,7 +625,7 @@ static ExtensionModule staticExtensions[] = {
{ DamageExtensionInit, "DAMAGE", NULL, NULL },
#endif
#ifdef COMPOSITE
- { CompositeExtensionInit, "COMPOSITE", NULL, NULL },
+ { CompositeExtensionInit, "COMPOSITE", &noCompositeExtension, NULL },
#endif
#ifdef XEVIE
{ XevieExtensionInit, "XEVIE", &noXevieExtension, NULL },
diff --git a/os/utils.c b/os/utils.c
index eccb2b37a..e232165a0 100644
--- a/os/utils.c
+++ b/os/utils.c
@@ -1,4 +1,4 @@
-/* $XdotOrg: xc/programs/Xserver/os/utils.c,v 1.3 2004/06/19 21:56:01 gisburn Exp $ */
+/* $XdotOrg: xc/programs/Xserver/os/utils.c,v 1.4 2004/07/31 04:23:21 kem Exp $ */
/* $Xorg: utils.c,v 1.5 2001/02/09 02:05:24 xorgcvs Exp $ */
/*
@@ -142,6 +142,10 @@ Bool PanoramiXOneExposeRequest = FALSE;
Bool noXevieExtension = TRUE;
#endif
+#ifdef COMPOSITE
+Bool noCompositeExtension = TRUE;
+#endif
+
int auditTrailLevel = 1;
Bool Must_have_memory = FALSE;
@@ -177,6 +181,7 @@ extern char dispatchExceptionAtReset;
/* Extension enable/disable in miinitext.c */
extern Bool EnableDisableExtension(char *name, Bool enable);
+extern void EnableDisableExtensionError(char *name, Bool enable);
OsSigHandlerPtr
OsSignal(sig, handler)
@@ -1011,12 +1016,22 @@ ProcessCommandLine(int argc, char *argv[])
#endif
else if ( strcmp( argv[i], "+extension") == 0)
{
- if (++i >= argc || !EnableDisableExtension(argv[i], TRUE))
+ if (++i < argc)
+ {
+ if (!EnableDisableExtension(argv[i], TRUE))
+ EnableDisableExtensionError(argv[i], TRUE);
+ }
+ else
UseMsg();
}
else if ( strcmp( argv[i], "-extension") == 0)
{
- if (++i >= argc || !EnableDisableExtension(argv[i], FALSE))
+ if (++i < argc)
+ {
+ if (!EnableDisableExtension(argv[i], FALSE))
+ EnableDisableExtensionError(argv[i], FALSE);
+ }
+ else
UseMsg();
}
else