2003-11-14 16:54:54 +01:00
|
|
|
/***********************************************************
|
|
|
|
|
|
|
|
Copyright 1987, 1998 The Open Group
|
|
|
|
|
|
|
|
Permission to use, copy, modify, distribute, and sell this software and its
|
|
|
|
documentation for any purpose is hereby granted without fee, provided that
|
|
|
|
the above copyright notice appear in all copies and that both that
|
|
|
|
copyright notice and this permission notice appear in supporting
|
|
|
|
documentation.
|
|
|
|
|
|
|
|
The above copyright notice and this permission notice 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 NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
OPEN GROUP 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.
|
|
|
|
|
|
|
|
Except as contained in this notice, the name of The Open Group shall not be
|
|
|
|
used in advertising or otherwise to promote the sale, use or other dealings
|
|
|
|
in this Software without prior written authorization from The Open Group.
|
|
|
|
|
|
|
|
|
|
|
|
Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
|
|
|
|
|
|
|
|
All Rights Reserved
|
|
|
|
|
|
|
|
Permission to use, copy, modify, and distribute this software and its
|
|
|
|
documentation for any purpose and without fee is hereby granted,
|
|
|
|
provided that the above copyright notice appear in all copies and that
|
|
|
|
both that copyright notice and this permission notice appear in
|
|
|
|
supporting documentation, and that the name of Digital not be
|
|
|
|
used in advertising or publicity pertaining to distribution of the
|
|
|
|
software without specific, written prior permission.
|
|
|
|
|
|
|
|
DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
|
|
|
|
ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
|
|
|
|
DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
|
|
|
|
ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
|
|
|
|
WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
|
|
|
|
ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
|
|
|
|
SOFTWARE.
|
|
|
|
|
|
|
|
******************************************************************/
|
|
|
|
|
2005-07-03 09:02:09 +02:00
|
|
|
#ifdef HAVE_DIX_CONFIG_H
|
|
|
|
#include <dix-config.h>
|
|
|
|
#endif
|
|
|
|
|
2005-04-20 14:25:48 +02:00
|
|
|
#include <X11/X.h>
|
|
|
|
#include <X11/Xproto.h>
|
2005-07-03 10:53:54 +02:00
|
|
|
#include "misc.h"
|
2003-11-14 16:54:54 +01:00
|
|
|
#include "dixstruct.h"
|
|
|
|
#include "extnsionst.h"
|
|
|
|
#include "gcstruct.h"
|
|
|
|
#include "scrnintstr.h"
|
2003-11-14 17:49:22 +01:00
|
|
|
#include "dispatch.h"
|
2007-04-04 21:59:51 +02:00
|
|
|
#include "privates.h"
|
2007-11-26 21:26:49 +01:00
|
|
|
#include "registry.h"
|
2004-05-05 22:04:52 +02:00
|
|
|
#include "xace.h"
|
2003-11-14 16:54:54 +01:00
|
|
|
|
|
|
|
#define LAST_EVENT 128
|
|
|
|
#define LAST_ERROR 255
|
|
|
|
|
|
|
|
static ExtensionEntry **extensions = (ExtensionEntry **)NULL;
|
|
|
|
|
|
|
|
int lastEvent = EXTENSION_EVENT_BASE;
|
|
|
|
static int lastError = FirstExtensionError;
|
|
|
|
static unsigned int NumExtensions = 0;
|
|
|
|
|
Rework symbol visibility for easier maintenance
Save in a few special cases, _X_EXPORT should not be used in C source
files. Instead, it should be used in headers, and the proper C source
include that header. Some special cases are symbols that need to be
shared between modules, but not expected to be used by external drivers,
and symbols that are accessible via LoaderSymbol/dlopen.
This patch also adds conditionally some new sdk header files, depending
on extensions enabled. These files were added to match pattern for
other extensions/modules, that is, have the headers "deciding" symbol
visibility in the sdk. These headers are:
o Xext/panoramiXsrv.h, Xext/panoramiX.h
o fbpict.h (unconditionally)
o vidmodeproc.h
o mioverlay.h (unconditionally, used only by xaa)
o xfixes.h (unconditionally, symbols required by dri2)
LoaderSymbol and similar functions now don't have different prototypes,
in loaderProcs.h and xf86Module.h, so that both headers can be included,
without the need of defining IN_LOADER.
xf86NewInputDevice() device prototype readded to xf86Xinput.h, but
not exported (and with a comment about it).
2008-12-03 08:43:34 +01:00
|
|
|
ExtensionEntry *
|
2003-11-14 17:49:22 +01:00
|
|
|
AddExtension(char *name, int NumEvents, int NumErrors,
|
|
|
|
int (*MainProc)(ClientPtr c1),
|
|
|
|
int (*SwappedMainProc)(ClientPtr c2),
|
|
|
|
void (*CloseDownProc)(ExtensionEntry *e),
|
|
|
|
unsigned short (*MinorOpcodeProc)(ClientPtr c3))
|
2003-11-14 16:54:54 +01:00
|
|
|
{
|
|
|
|
int i;
|
2007-03-08 08:20:19 +01:00
|
|
|
ExtensionEntry *ext, **newexts;
|
2003-11-14 16:54:54 +01:00
|
|
|
|
2008-07-25 16:05:30 +02:00
|
|
|
if (!MainProc || !SwappedMainProc || !MinorOpcodeProc)
|
2003-11-14 16:54:54 +01:00
|
|
|
return((ExtensionEntry *) NULL);
|
|
|
|
if ((lastEvent + NumEvents > LAST_EVENT) ||
|
2010-03-11 18:28:18 +01:00
|
|
|
(unsigned)(lastError + NumErrors > LAST_ERROR)) {
|
|
|
|
LogMessage(X_ERROR, "Not enabling extension %s: maximum number of "
|
|
|
|
"events or errors exceeded.\n", name);
|
2003-11-14 16:54:54 +01:00
|
|
|
return((ExtensionEntry *) NULL);
|
2010-03-11 18:28:18 +01:00
|
|
|
}
|
2003-11-14 16:54:54 +01:00
|
|
|
|
2010-04-27 02:22:21 +02:00
|
|
|
ext = calloc(sizeof (ExtensionEntry), 1);
|
2006-09-08 21:25:17 +02:00
|
|
|
if (!ext)
|
2010-06-06 16:18:40 +02:00
|
|
|
return NULL;
|
2010-04-27 02:22:21 +02:00
|
|
|
if (!dixAllocatePrivates(&ext->devPrivates, PRIVATE_EXTENSION)) {
|
|
|
|
free(ext);
|
2010-06-06 16:18:40 +02:00
|
|
|
return NULL;
|
2010-04-27 02:22:21 +02:00
|
|
|
}
|
2010-08-28 00:34:49 +02:00
|
|
|
ext->name = strdup(name);
|
2003-11-14 16:54:54 +01:00
|
|
|
ext->num_aliases = 0;
|
|
|
|
ext->aliases = (char **)NULL;
|
|
|
|
if (!ext->name)
|
|
|
|
{
|
2010-04-27 02:22:21 +02:00
|
|
|
dixFreePrivates(ext->devPrivates, PRIVATE_EXTENSION);
|
2010-05-05 20:44:06 +02:00
|
|
|
free(ext);
|
2003-11-14 16:54:54 +01:00
|
|
|
return((ExtensionEntry *) NULL);
|
|
|
|
}
|
|
|
|
i = NumExtensions;
|
2010-05-05 20:44:06 +02:00
|
|
|
newexts = (ExtensionEntry **) realloc(extensions,
|
2003-11-14 16:54:54 +01:00
|
|
|
(i + 1) * sizeof(ExtensionEntry *));
|
|
|
|
if (!newexts)
|
|
|
|
{
|
2010-05-05 20:44:06 +02:00
|
|
|
free(ext->name);
|
2010-04-27 02:22:21 +02:00
|
|
|
dixFreePrivates(ext->devPrivates, PRIVATE_EXTENSION);
|
2010-05-05 20:44:06 +02:00
|
|
|
free(ext);
|
2003-11-14 16:54:54 +01:00
|
|
|
return((ExtensionEntry *) NULL);
|
|
|
|
}
|
|
|
|
NumExtensions++;
|
|
|
|
extensions = newexts;
|
|
|
|
extensions[i] = ext;
|
|
|
|
ext->index = i;
|
|
|
|
ext->base = i + EXTENSION_BASE;
|
|
|
|
ext->CloseDown = CloseDownProc;
|
|
|
|
ext->MinorOpcode = MinorOpcodeProc;
|
|
|
|
ProcVector[i + EXTENSION_BASE] = MainProc;
|
|
|
|
SwappedProcVector[i + EXTENSION_BASE] = SwappedMainProc;
|
|
|
|
if (NumEvents)
|
|
|
|
{
|
|
|
|
ext->eventBase = lastEvent;
|
|
|
|
ext->eventLast = lastEvent + NumEvents;
|
|
|
|
lastEvent += NumEvents;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ext->eventBase = 0;
|
|
|
|
ext->eventLast = 0;
|
|
|
|
}
|
|
|
|
if (NumErrors)
|
|
|
|
{
|
|
|
|
ext->errorBase = lastError;
|
|
|
|
ext->errorLast = lastError + NumErrors;
|
|
|
|
lastError += NumErrors;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ext->errorBase = 0;
|
|
|
|
ext->errorLast = 0;
|
|
|
|
}
|
|
|
|
|
2007-11-26 21:26:49 +01:00
|
|
|
RegisterExtensionNames(ext);
|
2010-06-06 16:18:40 +02:00
|
|
|
return ext;
|
2003-11-14 16:54:54 +01:00
|
|
|
}
|
|
|
|
|
Rework symbol visibility for easier maintenance
Save in a few special cases, _X_EXPORT should not be used in C source
files. Instead, it should be used in headers, and the proper C source
include that header. Some special cases are symbols that need to be
shared between modules, but not expected to be used by external drivers,
and symbols that are accessible via LoaderSymbol/dlopen.
This patch also adds conditionally some new sdk header files, depending
on extensions enabled. These files were added to match pattern for
other extensions/modules, that is, have the headers "deciding" symbol
visibility in the sdk. These headers are:
o Xext/panoramiXsrv.h, Xext/panoramiX.h
o fbpict.h (unconditionally)
o vidmodeproc.h
o mioverlay.h (unconditionally, used only by xaa)
o xfixes.h (unconditionally, symbols required by dri2)
LoaderSymbol and similar functions now don't have different prototypes,
in loaderProcs.h and xf86Module.h, so that both headers can be included,
without the need of defining IN_LOADER.
xf86NewInputDevice() device prototype readded to xf86Xinput.h, but
not exported (and with a comment about it).
2008-12-03 08:43:34 +01:00
|
|
|
Bool AddExtensionAlias(char *alias, ExtensionEntry *ext)
|
2003-11-14 16:54:54 +01:00
|
|
|
{
|
|
|
|
char *name;
|
|
|
|
char **aliases;
|
|
|
|
|
2007-08-30 22:31:47 +02:00
|
|
|
if (!ext)
|
|
|
|
return FALSE ;
|
2010-05-05 20:44:06 +02:00
|
|
|
aliases = (char **)realloc(ext->aliases,
|
2003-11-14 16:54:54 +01:00
|
|
|
(ext->num_aliases + 1) * sizeof(char *));
|
|
|
|
if (!aliases)
|
|
|
|
return FALSE;
|
|
|
|
ext->aliases = aliases;
|
2010-08-28 00:34:49 +02:00
|
|
|
name = strdup(alias);
|
2003-11-14 16:54:54 +01:00
|
|
|
if (!name)
|
|
|
|
return FALSE;
|
|
|
|
ext->aliases[ext->num_aliases] = name;
|
|
|
|
ext->num_aliases++;
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2003-11-14 17:49:22 +01:00
|
|
|
FindExtension(char *extname, int len)
|
2003-11-14 16:54:54 +01:00
|
|
|
{
|
|
|
|
int i, j;
|
|
|
|
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2003-11-14 17:49:22 +01:00
|
|
|
/*
|
|
|
|
* CheckExtension returns the extensions[] entry for the requested
|
|
|
|
* extension name. Maybe this could just return a Bool instead?
|
|
|
|
*/
|
Rework symbol visibility for easier maintenance
Save in a few special cases, _X_EXPORT should not be used in C source
files. Instead, it should be used in headers, and the proper C source
include that header. Some special cases are symbols that need to be
shared between modules, but not expected to be used by external drivers,
and symbols that are accessible via LoaderSymbol/dlopen.
This patch also adds conditionally some new sdk header files, depending
on extensions enabled. These files were added to match pattern for
other extensions/modules, that is, have the headers "deciding" symbol
visibility in the sdk. These headers are:
o Xext/panoramiXsrv.h, Xext/panoramiX.h
o fbpict.h (unconditionally)
o vidmodeproc.h
o mioverlay.h (unconditionally, used only by xaa)
o xfixes.h (unconditionally, symbols required by dri2)
LoaderSymbol and similar functions now don't have different prototypes,
in loaderProcs.h and xf86Module.h, so that both headers can be included,
without the need of defining IN_LOADER.
xf86NewInputDevice() device prototype readded to xf86Xinput.h, but
not exported (and with a comment about it).
2008-12-03 08:43:34 +01:00
|
|
|
ExtensionEntry *
|
2003-11-14 17:49:22 +01:00
|
|
|
CheckExtension(const char *extname)
|
|
|
|
{
|
|
|
|
int n;
|
|
|
|
|
|
|
|
n = FindExtension((char*)extname, strlen(extname));
|
|
|
|
if (n != -1)
|
|
|
|
return extensions[n];
|
|
|
|
else
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2004-05-05 22:04:52 +02:00
|
|
|
/*
|
|
|
|
* Added as part of Xace.
|
|
|
|
*/
|
Rework symbol visibility for easier maintenance
Save in a few special cases, _X_EXPORT should not be used in C source
files. Instead, it should be used in headers, and the proper C source
include that header. Some special cases are symbols that need to be
shared between modules, but not expected to be used by external drivers,
and symbols that are accessible via LoaderSymbol/dlopen.
This patch also adds conditionally some new sdk header files, depending
on extensions enabled. These files were added to match pattern for
other extensions/modules, that is, have the headers "deciding" symbol
visibility in the sdk. These headers are:
o Xext/panoramiXsrv.h, Xext/panoramiX.h
o fbpict.h (unconditionally)
o vidmodeproc.h
o mioverlay.h (unconditionally, used only by xaa)
o xfixes.h (unconditionally, symbols required by dri2)
LoaderSymbol and similar functions now don't have different prototypes,
in loaderProcs.h and xf86Module.h, so that both headers can be included,
without the need of defining IN_LOADER.
xf86NewInputDevice() device prototype readded to xf86Xinput.h, but
not exported (and with a comment about it).
2008-12-03 08:43:34 +01:00
|
|
|
ExtensionEntry *
|
2004-05-05 22:04:52 +02:00
|
|
|
GetExtensionEntry(int major)
|
|
|
|
{
|
|
|
|
if (major < EXTENSION_BASE)
|
|
|
|
return NULL;
|
|
|
|
major -= EXTENSION_BASE;
|
|
|
|
if (major >= NumExtensions)
|
|
|
|
return NULL;
|
|
|
|
return extensions[major];
|
|
|
|
}
|
|
|
|
|
Rework symbol visibility for easier maintenance
Save in a few special cases, _X_EXPORT should not be used in C source
files. Instead, it should be used in headers, and the proper C source
include that header. Some special cases are symbols that need to be
shared between modules, but not expected to be used by external drivers,
and symbols that are accessible via LoaderSymbol/dlopen.
This patch also adds conditionally some new sdk header files, depending
on extensions enabled. These files were added to match pattern for
other extensions/modules, that is, have the headers "deciding" symbol
visibility in the sdk. These headers are:
o Xext/panoramiXsrv.h, Xext/panoramiX.h
o fbpict.h (unconditionally)
o vidmodeproc.h
o mioverlay.h (unconditionally, used only by xaa)
o xfixes.h (unconditionally, symbols required by dri2)
LoaderSymbol and similar functions now don't have different prototypes,
in loaderProcs.h and xf86Module.h, so that both headers can be included,
without the need of defining IN_LOADER.
xf86NewInputDevice() device prototype readded to xf86Xinput.h, but
not exported (and with a comment about it).
2008-12-03 08:43:34 +01:00
|
|
|
unsigned short
|
2005-03-08 00:02:59 +01:00
|
|
|
StandardMinorOpcode(ClientPtr client)
|
2003-11-14 16:54:54 +01:00
|
|
|
{
|
|
|
|
return ((xReq *)client->requestBuffer)->data;
|
|
|
|
}
|
|
|
|
|
Rework symbol visibility for easier maintenance
Save in a few special cases, _X_EXPORT should not be used in C source
files. Instead, it should be used in headers, and the proper C source
include that header. Some special cases are symbols that need to be
shared between modules, but not expected to be used by external drivers,
and symbols that are accessible via LoaderSymbol/dlopen.
This patch also adds conditionally some new sdk header files, depending
on extensions enabled. These files were added to match pattern for
other extensions/modules, that is, have the headers "deciding" symbol
visibility in the sdk. These headers are:
o Xext/panoramiXsrv.h, Xext/panoramiX.h
o fbpict.h (unconditionally)
o vidmodeproc.h
o mioverlay.h (unconditionally, used only by xaa)
o xfixes.h (unconditionally, symbols required by dri2)
LoaderSymbol and similar functions now don't have different prototypes,
in loaderProcs.h and xf86Module.h, so that both headers can be included,
without the need of defining IN_LOADER.
xf86NewInputDevice() device prototype readded to xf86Xinput.h, but
not exported (and with a comment about it).
2008-12-03 08:43:34 +01:00
|
|
|
unsigned short
|
2005-03-08 00:02:59 +01:00
|
|
|
MinorOpcodeOfRequest(ClientPtr client)
|
2003-11-14 16:54:54 +01:00
|
|
|
{
|
|
|
|
unsigned char major;
|
|
|
|
|
|
|
|
major = ((xReq *)client->requestBuffer)->reqType;
|
|
|
|
if (major < EXTENSION_BASE)
|
|
|
|
return 0;
|
|
|
|
major -= EXTENSION_BASE;
|
|
|
|
if (major >= NumExtensions)
|
|
|
|
return 0;
|
|
|
|
return (*extensions[major]->MinorOpcode)(client);
|
|
|
|
}
|
|
|
|
|
Rework symbol visibility for easier maintenance
Save in a few special cases, _X_EXPORT should not be used in C source
files. Instead, it should be used in headers, and the proper C source
include that header. Some special cases are symbols that need to be
shared between modules, but not expected to be used by external drivers,
and symbols that are accessible via LoaderSymbol/dlopen.
This patch also adds conditionally some new sdk header files, depending
on extensions enabled. These files were added to match pattern for
other extensions/modules, that is, have the headers "deciding" symbol
visibility in the sdk. These headers are:
o Xext/panoramiXsrv.h, Xext/panoramiX.h
o fbpict.h (unconditionally)
o vidmodeproc.h
o mioverlay.h (unconditionally, used only by xaa)
o xfixes.h (unconditionally, symbols required by dri2)
LoaderSymbol and similar functions now don't have different prototypes,
in loaderProcs.h and xf86Module.h, so that both headers can be included,
without the need of defining IN_LOADER.
xf86NewInputDevice() device prototype readded to xf86Xinput.h, but
not exported (and with a comment about it).
2008-12-03 08:43:34 +01:00
|
|
|
void
|
2007-04-09 23:33:15 +02:00
|
|
|
CloseDownExtensions(void)
|
2003-11-14 16:54:54 +01:00
|
|
|
{
|
2007-03-08 08:20:19 +01:00
|
|
|
int i,j;
|
2003-11-14 16:54:54 +01:00
|
|
|
|
|
|
|
for (i = NumExtensions - 1; i >= 0; i--)
|
|
|
|
{
|
2008-07-24 15:13:26 +02:00
|
|
|
if (extensions[i]->CloseDown)
|
|
|
|
extensions[i]->CloseDown(extensions[i]);
|
2003-11-14 16:54:54 +01:00
|
|
|
NumExtensions = i;
|
2010-05-05 20:44:06 +02:00
|
|
|
free(extensions[i]->name);
|
2003-11-14 16:54:54 +01:00
|
|
|
for (j = extensions[i]->num_aliases; --j >= 0;)
|
2010-05-05 20:44:06 +02:00
|
|
|
free(extensions[i]->aliases[j]);
|
|
|
|
free(extensions[i]->aliases);
|
2010-04-27 02:22:21 +02:00
|
|
|
dixFreePrivates(extensions[i]->devPrivates, PRIVATE_EXTENSION);
|
2010-05-05 20:44:06 +02:00
|
|
|
free(extensions[i]);
|
2003-11-14 16:54:54 +01:00
|
|
|
}
|
2010-05-05 20:44:06 +02:00
|
|
|
free(extensions);
|
2003-11-14 16:54:54 +01:00
|
|
|
extensions = (ExtensionEntry **)NULL;
|
|
|
|
lastEvent = EXTENSION_EVENT_BASE;
|
|
|
|
lastError = FirstExtensionError;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2005-03-08 00:02:59 +01:00
|
|
|
ProcQueryExtension(ClientPtr client)
|
2003-11-14 16:54:54 +01:00
|
|
|
{
|
|
|
|
xQueryExtensionReply reply;
|
|
|
|
int i;
|
|
|
|
REQUEST(xQueryExtensionReq);
|
|
|
|
|
|
|
|
REQUEST_FIXED_SIZE(xQueryExtensionReq, stuff->nbytes);
|
2009-02-13 10:23:28 +01:00
|
|
|
|
|
|
|
memset(&reply, 0, sizeof(xQueryExtensionReply));
|
2003-11-14 16:54:54 +01:00
|
|
|
reply.type = X_Reply;
|
|
|
|
reply.length = 0;
|
|
|
|
reply.major_opcode = 0;
|
|
|
|
reply.sequenceNumber = client->sequence;
|
|
|
|
|
|
|
|
if ( ! NumExtensions )
|
|
|
|
reply.present = xFalse;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
i = FindExtension((char *)&stuff[1], stuff->nbytes);
|
2007-04-17 22:01:56 +02:00
|
|
|
if (i < 0 || XaceHook(XACE_EXT_ACCESS, client, extensions[i]))
|
2003-11-14 16:54:54 +01:00
|
|
|
reply.present = xFalse;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
reply.present = xTrue;
|
|
|
|
reply.major_opcode = extensions[i]->base;
|
|
|
|
reply.first_event = extensions[i]->eventBase;
|
|
|
|
reply.first_error = extensions[i]->errorBase;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
WriteReplyToClient(client, sizeof(xQueryExtensionReply), &reply);
|
2010-05-11 05:22:05 +02:00
|
|
|
return Success;
|
2003-11-14 16:54:54 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2005-03-08 00:02:59 +01:00
|
|
|
ProcListExtensions(ClientPtr client)
|
2003-11-14 16:54:54 +01:00
|
|
|
{
|
|
|
|
xListExtensionsReply reply;
|
|
|
|
char *bufptr, *buffer;
|
|
|
|
int total_length = 0;
|
|
|
|
|
|
|
|
REQUEST_SIZE_MATCH(xReq);
|
|
|
|
|
2009-02-13 10:23:28 +01:00
|
|
|
memset(&reply, 0, sizeof(xListExtensionsReply));
|
2003-11-14 16:54:54 +01:00
|
|
|
reply.type = X_Reply;
|
|
|
|
reply.nExtensions = 0;
|
|
|
|
reply.length = 0;
|
|
|
|
reply.sequenceNumber = client->sequence;
|
|
|
|
buffer = NULL;
|
|
|
|
|
|
|
|
if ( NumExtensions )
|
|
|
|
{
|
2007-03-08 08:20:19 +01:00
|
|
|
int i, j;
|
2003-11-14 16:54:54 +01:00
|
|
|
|
|
|
|
for (i=0; i<NumExtensions; i++)
|
|
|
|
{
|
2004-05-05 22:04:52 +02:00
|
|
|
/* call callbacks to find out whether to show extension */
|
2007-04-17 22:01:56 +02:00
|
|
|
if (XaceHook(XACE_EXT_ACCESS, client, extensions[i]) != Success)
|
2003-11-14 16:54:54 +01:00
|
|
|
continue;
|
2006-12-02 02:48:15 +01:00
|
|
|
|
2003-11-14 16:54:54 +01:00
|
|
|
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;
|
|
|
|
}
|
2009-07-03 08:50:03 +02:00
|
|
|
reply.length = bytes_to_int32(total_length);
|
2010-05-05 20:44:06 +02:00
|
|
|
buffer = bufptr = malloc(total_length);
|
2003-11-14 16:54:54 +01:00
|
|
|
if (!buffer)
|
2010-06-06 16:18:40 +02:00
|
|
|
return BadAlloc;
|
2003-11-14 16:54:54 +01:00
|
|
|
for (i=0; i<NumExtensions; i++)
|
|
|
|
{
|
|
|
|
int len;
|
2007-04-17 22:01:56 +02:00
|
|
|
if (XaceHook(XACE_EXT_ACCESS, client, extensions[i]) != Success)
|
2003-11-14 16:54:54 +01:00
|
|
|
continue;
|
2006-12-02 02:48:15 +01:00
|
|
|
|
2003-11-14 16:54:54 +01:00
|
|
|
*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);
|
|
|
|
if (reply.length)
|
|
|
|
{
|
|
|
|
WriteToClient(client, total_length, buffer);
|
2010-05-05 20:44:06 +02:00
|
|
|
free(buffer);
|
2003-11-14 16:54:54 +01:00
|
|
|
}
|
2010-05-11 05:22:05 +02:00
|
|
|
return Success;
|
2003-11-14 16:54:54 +01:00
|
|
|
}
|