summaryrefslogtreecommitdiff
path: root/xserver/dix/extension.c
diff options
context:
space:
mode:
Diffstat (limited to 'xserver/dix/extension.c')
-rw-r--r--xserver/dix/extension.c63
1 files changed, 17 insertions, 46 deletions
diff --git a/xserver/dix/extension.c b/xserver/dix/extension.c
index e81f673b2..9c158ba93 100644
--- a/xserver/dix/extension.c
+++ b/xserver/dix/extension.c
@@ -95,8 +95,6 @@ AddExtension(const char *name, int NumEvents, int NumErrors,
return NULL;
}
ext->name = strdup(name);
- ext->num_aliases = 0;
- ext->aliases = (const char **) NULL;
if (!ext->name) {
dixFreePrivates(ext->devPrivates, PRIVATE_EXTENSION);
free(ext);
@@ -144,42 +142,15 @@ AddExtension(const char *name, int NumEvents, int NumErrors,
return ext;
}
-Bool
-AddExtensionAlias(const char *alias, ExtensionEntry * ext)
-{
- char *name;
- const char **aliases;
-
- if (!ext)
- return FALSE;
- aliases = reallocarray(ext->aliases, ext->num_aliases + 1, sizeof(char *));
- if (!aliases)
- return FALSE;
- ext->aliases = aliases;
- name = strdup(alias);
- if (!name)
- return FALSE;
- ext->aliases[ext->num_aliases] = name;
- ext->num_aliases++;
- return TRUE;
-}
-
static int
FindExtension(const char *extname, int len)
{
- int i, j;
+ int i;
for (i = 0; i < NumExtensions; i++) {
if ((strlen(extensions[i]->name) == len) &&
!strncmp(extname, extensions[i]->name, len))
break;
- for (j = extensions[i]->num_aliases; --j >= 0;) {
- if ((strlen(extensions[i]->aliases[j]) == len) &&
- !strncmp(extname, extensions[i]->aliases[j], len))
- break;
- }
- if (j >= 0)
- break;
}
return ((i == NumExtensions) ? -1 : i);
}
@@ -223,16 +194,13 @@ StandardMinorOpcode(ClientPtr client)
void
CloseDownExtensions(void)
{
- int i, j;
+ int i;
for (i = NumExtensions - 1; i >= 0; i--) {
if (extensions[i]->CloseDown)
extensions[i]->CloseDown(extensions[i]);
NumExtensions = i;
free((void *) extensions[i]->name);
- for (j = extensions[i]->num_aliases; --j >= 0;)
- free((void *) extensions[i]->aliases[j]);
- free(extensions[i]->aliases);
dixFreePrivates(extensions[i]->devPrivates, PRIVATE_EXTENSION);
free(extensions[i]);
}
@@ -242,6 +210,16 @@ CloseDownExtensions(void)
lastError = FirstExtensionError;
}
+static Bool
+ExtensionAvailable(ClientPtr client, ExtensionEntry *ext)
+{
+ if (XaceHook(XACE_EXT_ACCESS, client, ext) != Success)
+ return FALSE;
+ if (!ext->base)
+ return FALSE;
+ return TRUE;
+}
+
int
ProcQueryExtension(ClientPtr client)
{
@@ -263,7 +241,7 @@ ProcQueryExtension(ClientPtr client)
reply.present = xFalse;
else {
i = FindExtension((char *) &stuff[1], stuff->nbytes);
- if (i < 0 || XaceHook(XACE_EXT_ACCESS, client, extensions[i]))
+ if (i < 0 || !ExtensionAvailable(client, extensions[i]))
reply.present = xFalse;
else {
reply.present = xTrue;
@@ -294,17 +272,15 @@ ProcListExtensions(ClientPtr client)
buffer = NULL;
if (NumExtensions) {
- int i, j;
+ int i;
for (i = 0; i < NumExtensions; i++) {
/* call callbacks to find out whether to show extension */
- if (XaceHook(XACE_EXT_ACCESS, client, extensions[i]) != Success)
+ if (!ExtensionAvailable(client, extensions[i]))
continue;
total_length += strlen(extensions[i]->name) + 1;
- reply.nExtensions += 1 + extensions[i]->num_aliases;
- for (j = extensions[i]->num_aliases; --j >= 0;)
- total_length += strlen(extensions[i]->aliases[j]) + 1;
+ reply.nExtensions += 1;
}
reply.length = bytes_to_int32(total_length);
buffer = bufptr = malloc(total_length);
@@ -313,17 +289,12 @@ ProcListExtensions(ClientPtr client)
for (i = 0; i < NumExtensions; i++) {
int len;
- if (XaceHook(XACE_EXT_ACCESS, client, extensions[i]) != Success)
+ if (!ExtensionAvailable(client, extensions[i]))
continue;
*bufptr++ = len = strlen(extensions[i]->name);
memmove(bufptr, extensions[i]->name, len);
bufptr += len;
- for (j = extensions[i]->num_aliases; --j >= 0;) {
- *bufptr++ = len = strlen(extensions[i]->aliases[j]);
- memmove(bufptr, extensions[i]->aliases[j], len);
- bufptr += len;
- }
}
}
WriteReplyToClient(client, sizeof(xListExtensionsReply), &reply);