summaryrefslogtreecommitdiff
path: root/dix
diff options
context:
space:
mode:
authorKeith Packard <keithp@keithp.com>2014-09-10 15:21:32 -0700
committerKeith Packard <keithp@keithp.com>2014-09-18 15:29:29 -0700
commit69d8572ae4cd1bce17223ea8aff87916a974c861 (patch)
tree02012e94ccdaa25e9128e53b1581835da31863ac /dix
parenta11fc2493e85e4a532f4954805a7c6d1c601b08f (diff)
Build required portions of registry.c automatically [v2]
Instead of making the inclusion of the registry code a global conditional, split the registry into two pieces; the bits required by the X-Resource extension (the resource names) and the bits required by the XCSECURITY extension (the protocol names). Build each set of code if the related extension is being built. v2: Check for both XCSECURITY and XSELINUX. Signed-off-by: Keith Packard <keithp@keithp.com> Reviewed-by: Adam Jackson <ajax@redhat.com>
Diffstat (limited to 'dix')
-rw-r--r--dix/extension.c2
-rw-r--r--dix/registry.c90
-rw-r--r--dix/resource.c2
3 files changed, 59 insertions, 35 deletions
diff --git a/dix/extension.c b/dix/extension.c
index ede4bf5bd..e43291eec 100644
--- a/dix/extension.c
+++ b/dix/extension.c
@@ -139,7 +139,9 @@ AddExtension(const char *name, int NumEvents, int NumErrors,
ext->errorLast = 0;
}
+#ifdef X_REGISTRY_REQUEST
RegisterExtensionNames(ext);
+#endif
return ext;
}
diff --git a/dix/registry.c b/dix/registry.c
index 8b76d56ad..84d48b4e3 100644
--- a/dix/registry.c
+++ b/dix/registry.c
@@ -21,8 +21,6 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include <dix-config.h>
#endif
-#ifdef XREGISTRY
-
#include <stdlib.h>
#include <string.h>
#include <X11/X.h>
@@ -31,6 +29,8 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include "registry.h"
#define BASE_SIZE 16
+
+#ifdef X_REGISTRY_REQUEST
#define CORE "X11"
#define FILENAME SERVER_MISC_CONFIG_PATH "/protocol.txt"
@@ -42,9 +42,15 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
static FILE *fh;
static char ***requests, **events, **errors;
+static unsigned nmajor, *nminor, nevent, nerror;
+#endif
+
+#ifdef X_REGISTRY_RESOURCE
static const char **resources;
-static unsigned nmajor, *nminor, nevent, nerror, nresource;
+static unsigned nresource;
+#endif
+#if defined(X_REGISTRY_RESOURCE) || defined(X_REGISTRY_REQUEST)
/*
* File parsing routines
*/
@@ -72,7 +78,12 @@ double_size(void *p, unsigned n, unsigned size)
memset(*ptr + s, 0, f - s);
return TRUE;
}
+#endif
+#ifdef X_REGISTRY_REQUEST
+/*
+ * Request/event/error registry functions
+ */
static void
RegisterRequestName(unsigned major, unsigned minor, char *name)
{
@@ -197,28 +208,6 @@ RegisterExtensionNames(ExtensionEntry * extEntry)
}
}
-/*
- * Registration functions
- */
-
-void
-RegisterResourceName(RESTYPE resource, const char *name)
-{
- resource &= TypeMask;
-
- while (resource >= nresource) {
- if (!double_size(&resources, nresource, sizeof(char *)))
- return;
- nresource = nresource ? nresource * 2 : BASE_SIZE;
- }
-
- resources[resource] = name;
-}
-
-/*
- * Lookup functions
- */
-
const char *
LookupRequestName(int major, int minor)
{
@@ -269,6 +258,26 @@ LookupErrorName(int error)
return errors[error] ? errors[error] : XREGISTRY_UNKNOWN;
}
+#endif /* X_REGISTRY_REQUEST */
+
+#ifdef X_REGISTRY_RESOURCE
+/*
+ * Resource registry functions
+ */
+
+void
+RegisterResourceName(RESTYPE resource, const char *name)
+{
+ resource &= TypeMask;
+
+ while (resource >= nresource) {
+ if (!double_size(&resources, nresource, sizeof(char *)))
+ return;
+ nresource = nresource ? nresource * 2 : BASE_SIZE;
+ }
+
+ resources[resource] = name;
+}
const char *
LookupResourceName(RESTYPE resource)
@@ -279,10 +288,12 @@ LookupResourceName(RESTYPE resource)
return resources[resource] ? resources[resource] : XREGISTRY_UNKNOWN;
}
+#endif /* X_REGISTRY_RESOURCE */
void
dixFreeRegistry(void)
{
+#ifdef X_REGISTRY_REQUEST
/* Free all memory */
while (nmajor--) {
while (nminor[nmajor])
@@ -299,25 +310,30 @@ dixFreeRegistry(void)
while (nerror--)
free(errors[nerror]);
free(errors);
-
- free(resources);
-
requests = NULL;
nminor = NULL;
events = NULL;
errors = NULL;
- resources = NULL;
+ nmajor = nevent = nerror = 0;
+#endif
+
+#ifdef X_REGISTRY_RESOURCE
+ free(resources);
- nmajor = nevent = nerror = nresource = 0;
+ resources = NULL;
+ nresource = 0;
+#endif
}
void
dixCloseRegistry(void)
{
+#ifdef X_REGISTRY_REQUEST
if (fh) {
fclose(fh);
fh = NULL;
}
+#endif
}
/*
@@ -326,16 +342,24 @@ dixCloseRegistry(void)
void
dixResetRegistry(void)
{
+#ifdef X_REGISTRY_REQUEST
ExtensionEntry extEntry = { .name = CORE };
+#endif
dixFreeRegistry();
+#ifdef X_REGISTRY_REQUEST
/* Open the protocol file */
fh = fopen(FILENAME, "r");
if (!fh)
LogMessage(X_WARNING,
"Failed to open protocol names file " FILENAME "\n");
+ /* Add the core protocol */
+ RegisterExtensionNames(&extEntry);
+#endif
+
+#ifdef X_REGISTRY_RESOURCE
/* Add built-in resources */
RegisterResourceName(RT_NONE, "NONE");
RegisterResourceName(RT_WINDOW, "WINDOW");
@@ -347,9 +371,5 @@ dixResetRegistry(void)
RegisterResourceName(RT_CMAPENTRY, "COLORMAP ENTRY");
RegisterResourceName(RT_OTHERCLIENT, "OTHER CLIENT");
RegisterResourceName(RT_PASSIVEGRAB, "PASSIVE GRAB");
-
- /* Add the core protocol */
- RegisterExtensionNames(&extEntry);
+#endif
}
-
-#endif /* XREGISTRY */
diff --git a/dix/resource.c b/dix/resource.c
index 623d862d6..c254244a3 100644
--- a/dix/resource.c
+++ b/dix/resource.c
@@ -524,8 +524,10 @@ CreateNewResourceType(DeleteType deleteFunc, const char *name)
resourceTypes[next].findSubResFunc = DefaultFindSubRes;
resourceTypes[next].errorValue = BadValue;
+#if X_REGISTRY_RESOURCE
/* Called even if name is NULL, to remove any previous entry */
RegisterResourceName(next, name);
+#endif
return next;
}