[PATCH 42/42] Remove separate ExtensionToggle list from miinitext [WIP]

Daniel Stone daniel at fooishbar.org
Fri Dec 2 03:27:50 PST 2011


miinitext.c had two duplicate extension + disable pointer lists, one of
which was used for extension init, the other of which was used to toggle
extensions on and off via the command line or xorg.conf.  Merge these
into one.

WIP: This only works for static extensions, those added later (GLX,
     DGA, VidMode) or added by the DDX can't be enabled/disabled.

Signed-off-by: Daniel Stone <daniel at fooishbar.org>
---
 mi/miinitext.c |  159 +++++++++++++++-----------------------------------------
 1 files changed, 43 insertions(+), 116 deletions(-)

diff --git a/mi/miinitext.c b/mi/miinitext.c
index 07d47e7..d5cf262 100644
--- a/mi/miinitext.c
+++ b/mi/miinitext.c
@@ -112,122 +112,6 @@ SOFTWARE.
 #include "micmap.h"
 #include "globals.h"
 
-/* The following is only a small first step towards run-time
- * configurable extensions.
- */
-typedef struct {
-    const char *name;
-    Bool *disablePtr;
-} ExtensionToggle;
-
-static ExtensionToggle ExtensionToggleList[] =
-{
-    /* sort order is extension name string as shown in xdpyinfo */
-    { "Generic Events", &noGEExtension },
-#ifdef COMPOSITE
-    { "Composite", &noCompositeExtension },
-#endif
-#ifdef DAMAGE
-    { "DAMAGE", &noDamageExtension },
-#endif
-#ifdef DBE
-    { "DOUBLE-BUFFER", &noDbeExtension },
-#endif
-#ifdef DPMSExtension
-    { "DPMS", &noDPMSExtension },
-#endif
-#ifdef GLXEXT
-    { "GLX", &noGlxExtension },
-#endif
-#ifdef SCREENSAVER
-    { "MIT-SCREEN-SAVER", &noScreenSaverExtension },
-#endif
-#ifdef MITSHM
-    { SHMNAME, &noMITShmExtension },
-#endif
-#ifdef RANDR
-    { "RANDR", &noRRExtension },
-#endif
-    { "RENDER", &noRenderExtension },
-#ifdef XCSECURITY
-    { "SECURITY", &noSecurityExtension },
-#endif
-#ifdef RES
-    { "X-Resource", &noResExtension },
-#endif
-#ifdef XF86BIGFONT
-    { "XFree86-Bigfont", &noXFree86BigfontExtension },
-#endif
-#ifdef XFreeXDGA
-    { "XFree86-DGA", &noXFree86DGAExtension },
-#endif
-#ifdef XF86DRI
-    { "XFree86-DRI", &noXFree86DRIExtension },
-#endif
-#ifdef XF86VIDMODE
-    { "XFree86-VidModeExtension", &noXFree86VidModeExtension },
-#endif
-#ifdef XFIXES
-    { "XFIXES", &noXFixesExtension },
-#endif
-#ifdef PANORAMIX
-    { "XINERAMA", &noPanoramiXExtension },
-#endif
-    { "XInputExtension", NULL },
-    { "XKEYBOARD", NULL },
-#ifdef XSELINUX
-    { "SELinux", &noSELinuxExtension },
-#endif
-    { "XTEST", &noTestExtensions },
-#ifdef XV
-    { "XVideo", &noXvExtension },
-#endif
-    { NULL, NULL }
-};
-
-Bool EnableDisableExtension(const char *name, Bool enable)
-{
-    ExtensionToggle *ext = &ExtensionToggleList[0];
-
-    for (ext = &ExtensionToggleList[0]; ext->name != NULL; ext++) {
-	if (strcmp(name, ext->name) == 0) {
-	    if (ext->disablePtr != NULL) {
-		*ext->disablePtr = !enable;
-		return TRUE;
-	    } else {
-		/* Extension is always on, impossible to disable */
-		return enable; /* okay if they wanted to enable,
-				  fail if they tried to disable */
-	    }
-	}
-    }
-
-    return FALSE;
-}
-
-void EnableDisableExtensionError(const char *name, Bool enable)
-{
-    ExtensionToggle *ext = &ExtensionToggleList[0];
-    Bool found = FALSE;
-
-    for (ext = &ExtensionToggleList[0]; ext->name != NULL; ext++) {
-	if ((strcmp(name, ext->name) == 0) && (ext->disablePtr == NULL)) {
-	    ErrorF("[mi] Extension \"%s\" can not be disabled\n", name);
-	    found = TRUE;
-	    break;
-	}
-    }
-    if (found == FALSE)
-	ErrorF("[mi] Extension \"%s\" is not recognized\n", name);
-    ErrorF("[mi] Only the following extensions can be run-time %s:\n",
-	   enable ? "enabled" : "disabled");
-    for (ext = &ExtensionToggleList[0]; ext->name != NULL; ext++) {
-	if (ext->disablePtr != NULL) {
-	    ErrorF("[mi]    %s\n", ext->name);
-	}
-    }
-}
-
 /* List of built-in (statically linked) extensions */
 static ExtensionModule staticExtensions[] = {
     { GEExtensionInit, "Generic Event Extension", &noGEExtension },
@@ -291,6 +175,49 @@ static ExtensionModule staticExtensions[] = {
     { NULL, NULL, NULL }
 };
 
+Bool EnableDisableExtension(const char *name, Bool enable)
+{
+    ExtensionModule *ext;
+
+    for (ext = &staticExtensions[0]; ext->name != NULL; ext++) {
+	if (strcmp(name, ext->name) == 0) {
+	    if (ext->disablePtr != NULL) {
+		*ext->disablePtr = !enable;
+		return TRUE;
+	    } else {
+		/* Extension is always on, impossible to disable */
+		return enable; /* okay if they wanted to enable,
+				  fail if they tried to disable */
+	    }
+	}
+    }
+
+    return FALSE;
+}
+
+void EnableDisableExtensionError(const char *name, Bool enable)
+{
+    ExtensionModule *ext;
+    Bool found = FALSE;
+
+    for (ext = &staticExtensions[0]; ext->name != NULL; ext++) {
+	if ((strcmp(name, ext->name) == 0) && (ext->disablePtr == NULL)) {
+	    ErrorF("[mi] Extension \"%s\" can not be disabled\n", name);
+	    found = TRUE;
+	    break;
+	}
+    }
+    if (found == FALSE)
+	ErrorF("[mi] Extension \"%s\" is not recognized\n", name);
+    ErrorF("[mi] Only the following extensions can be run-time %s:\n",
+	   enable ? "enabled" : "disabled");
+    for (ext = &staticExtensions[0]; ext->name != NULL; ext++) {
+	if (ext->disablePtr != NULL) {
+	    ErrorF("[mi]    %s\n", ext->name);
+	}
+    }
+}
+
 static ExtensionModule *ExtensionModuleList = NULL;
 static int numExtensionModules = 0;
 
-- 
1.7.7.3



More information about the xorg-devel mailing list