summaryrefslogtreecommitdiff
path: root/xserver/dix/extension.c
diff options
context:
space:
mode:
authorMatthieu Herrb <matthieu@cvs.openbsd.org>2008-11-02 15:26:35 +0000
committerMatthieu Herrb <matthieu@cvs.openbsd.org>2008-11-02 15:26:35 +0000
commitdbca69c8a4f3e2d1ccb4f89152213b2861b33af6 (patch)
treef8963ef73903a7b4374adc2354dffbaa905112ac /xserver/dix/extension.c
parent33b2029f322f3c238b7ba528083195ad8dde33e1 (diff)
xserver 1.5.2. tested by ckuethe@, oga@, and others.
Diffstat (limited to 'xserver/dix/extension.c')
-rw-r--r--xserver/dix/extension.c80
1 files changed, 15 insertions, 65 deletions
diff --git a/xserver/dix/extension.c b/xserver/dix/extension.c
index 7b405a493..d486161c8 100644
--- a/xserver/dix/extension.c
+++ b/xserver/dix/extension.c
@@ -59,6 +59,8 @@ SOFTWARE.
#include "gcstruct.h"
#include "scrnintstr.h"
#include "dispatch.h"
+#include "privates.h"
+#include "registry.h"
#include "xace.h"
#define EXTENSION_BASE 128
@@ -72,39 +74,6 @@ int lastEvent = EXTENSION_EVENT_BASE;
static int lastError = FirstExtensionError;
static unsigned int NumExtensions = 0;
-extern int extensionPrivateLen;
-extern unsigned *extensionPrivateSizes;
-extern unsigned totalExtensionSize;
-
-static void
-InitExtensionPrivates(ExtensionEntry *ext)
-{
- char *ptr;
- DevUnion *ppriv;
- unsigned *sizes;
- unsigned size;
- int i;
-
- if (totalExtensionSize == sizeof(ExtensionEntry))
- ppriv = (DevUnion *)NULL;
- else
- ppriv = (DevUnion *)(ext + 1);
-
- ext->devPrivates = ppriv;
- sizes = extensionPrivateSizes;
- ptr = (char *)(ppriv + extensionPrivateLen);
- for (i = extensionPrivateLen; --i >= 0; ppriv++, sizes++)
- {
- if ( (size = *sizes) )
- {
- ppriv->ptr = (pointer)ptr;
- ptr += size;
- }
- else
- ppriv->ptr = (pointer)NULL;
- }
-}
-
_X_EXPORT ExtensionEntry *
AddExtension(char *name, int NumEvents, int NumErrors,
int (*MainProc)(ClientPtr c1),
@@ -122,15 +91,14 @@ AddExtension(char *name, int NumEvents, int NumErrors,
(unsigned)(lastError + NumErrors > LAST_ERROR))
return((ExtensionEntry *) NULL);
- ext = (ExtensionEntry *) xalloc(totalExtensionSize);
+ ext = (ExtensionEntry *) xalloc(sizeof(ExtensionEntry));
if (!ext)
return((ExtensionEntry *) NULL);
- bzero(ext, totalExtensionSize);
- InitExtensionPrivates(ext);
- buflen = strlen(name) + 1;
- ext->name = (char *)xalloc(buflen);
ext->num_aliases = 0;
ext->aliases = (char **)NULL;
+ ext->devPrivates = NULL;
+ buflen = strlen(name) + 1;
+ ext->name = (char *)xalloc(buflen);
if (!ext->name)
{
xfree(ext);
@@ -178,6 +146,7 @@ AddExtension(char *name, int NumEvents, int NumErrors,
ext->errorLast = 0;
}
+ RegisterExtensionNames(ext);
return(ext);
}
@@ -187,6 +156,8 @@ _X_EXPORT Bool AddExtensionAlias(char *alias, ExtensionEntry *ext)
char **aliases;
size_t buflen;
+ if (!ext)
+ return FALSE ;
aliases = (char **)xrealloc(ext->aliases,
(ext->num_aliases + 1) * sizeof(char *));
if (!aliases)
@@ -253,14 +224,6 @@ GetExtensionEntry(int major)
return extensions[major];
}
-_X_EXPORT void
-DeclareExtensionSecurity(char *extname, Bool secure)
-{
- int i = FindExtension(extname, strlen(extname));
- if (i >= 0)
- XaceHook(XACE_DECLARE_EXT_SECURE, extensions[i], secure);
-}
-
_X_EXPORT unsigned short
StandardMinorOpcode(ClientPtr client)
{
@@ -294,6 +257,7 @@ CloseDownExtensions(void)
for (j = extensions[i]->num_aliases; --j >= 0;)
xfree(extensions[i]->aliases[j]);
xfree(extensions[i]->aliases);
+ dixFreePrivates(extensions[i]->devPrivates);
xfree(extensions[i]);
}
xfree(extensions);
@@ -321,7 +285,7 @@ ProcQueryExtension(ClientPtr client)
else
{
i = FindExtension((char *)&stuff[1], stuff->nbytes);
- if (i < 0 || !XaceHook(XACE_EXT_ACCESS, client, extensions[i]))
+ if (i < 0 || XaceHook(XACE_EXT_ACCESS, client, extensions[i]))
reply.present = xFalse;
else
{
@@ -357,7 +321,7 @@ ProcListExtensions(ClientPtr client)
for (i=0; i<NumExtensions; i++)
{
/* call callbacks to find out whether to show extension */
- if (!XaceHook(XACE_EXT_ACCESS, client, extensions[i]))
+ if (XaceHook(XACE_EXT_ACCESS, client, extensions[i]) != Success)
continue;
total_length += strlen(extensions[i]->name) + 1;
@@ -366,13 +330,13 @@ ProcListExtensions(ClientPtr client)
total_length += strlen(extensions[i]->aliases[j]) + 1;
}
reply.length = (total_length + 3) >> 2;
- buffer = bufptr = (char *)ALLOCATE_LOCAL(total_length);
+ buffer = bufptr = (char *)xalloc(total_length);
if (!buffer)
return(BadAlloc);
for (i=0; i<NumExtensions; i++)
{
int len;
- if (!XaceHook(XACE_EXT_ACCESS, client, extensions[i]))
+ if (XaceHook(XACE_EXT_ACCESS, client, extensions[i]) != Success)
continue;
*bufptr++ = len = strlen(extensions[i]->name);
@@ -390,21 +354,7 @@ ProcListExtensions(ClientPtr client)
if (reply.length)
{
WriteToClient(client, total_length, buffer);
- DEALLOCATE_LOCAL(buffer);
+ xfree(buffer);
}
return(client->noClientException);
}
-
-#ifdef XSERVER_DTRACE
-void LoadExtensionNames(char **RequestNames) {
- int i;
-
- for (i=0; i<NumExtensions; i++) {
- int r = extensions[i]->base;
-
- if (RequestNames[r] == NULL) {
- RequestNames[r] = strdup(extensions[i]->name);
- }
- }
-}
-#endif