2006-11-26 11:13:41 -07:00
|
|
|
/*
|
|
|
|
|
|
|
|
Copyright 1993, 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.
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef HAVE_DIX_CONFIG_H
|
|
|
|
#include <dix-config.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <X11/X.h>
|
|
|
|
#include <X11/Xproto.h>
|
|
|
|
#include "misc.h"
|
|
|
|
#include "os.h"
|
|
|
|
#include "dixstruct.h"
|
|
|
|
#include "extnsionst.h"
|
|
|
|
#include "swaprep.h"
|
2010-07-27 13:02:24 -06:00
|
|
|
#include <X11/extensions/xcmiscproto.h>
|
2013-06-07 11:28:45 -06:00
|
|
|
#include "extinit.h"
|
2006-11-26 11:13:41 -07:00
|
|
|
|
2007-04-03 20:50:29 -06:00
|
|
|
#include <stdint.h>
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
static int
|
2010-07-27 13:02:24 -06:00
|
|
|
ProcXCMiscGetVersion(ClientPtr client)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
2013-06-07 11:28:45 -06:00
|
|
|
xXCMiscGetVersionReply rep = {
|
|
|
|
.type = X_Reply,
|
|
|
|
.sequenceNumber = client->sequence,
|
|
|
|
.length = 0,
|
|
|
|
.majorVersion = XCMiscMajorVersion,
|
|
|
|
.minorVersion = XCMiscMinorVersion
|
|
|
|
};
|
2006-11-26 11:13:41 -07:00
|
|
|
|
|
|
|
REQUEST_SIZE_MATCH(xXCMiscGetVersionReq);
|
2013-06-07 11:28:45 -06:00
|
|
|
|
2006-11-26 11:13:41 -07:00
|
|
|
if (client->swapped) {
|
2012-06-10 07:21:05 -06:00
|
|
|
swaps(&rep.sequenceNumber);
|
|
|
|
swaps(&rep.majorVersion);
|
|
|
|
swaps(&rep.minorVersion);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
2013-06-07 11:28:45 -06:00
|
|
|
WriteToClient(client, sizeof(xXCMiscGetVersionReply), &rep);
|
2010-12-05 08:36:02 -07:00
|
|
|
return Success;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2010-07-27 13:02:24 -06:00
|
|
|
ProcXCMiscGetXIDRange(ClientPtr client)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
xXCMiscGetXIDRangeReply rep;
|
|
|
|
XID min_id, max_id;
|
|
|
|
|
|
|
|
REQUEST_SIZE_MATCH(xXCMiscGetXIDRangeReq);
|
|
|
|
GetXIDRange(client->index, FALSE, &min_id, &max_id);
|
2013-06-07 11:28:45 -06:00
|
|
|
rep = (xXCMiscGetXIDRangeReply) {
|
|
|
|
.type = X_Reply,
|
|
|
|
.sequenceNumber = client->sequence,
|
|
|
|
.length = 0,
|
|
|
|
.start_id = min_id,
|
|
|
|
.count = max_id - min_id + 1
|
|
|
|
};
|
2006-11-26 11:13:41 -07:00
|
|
|
if (client->swapped) {
|
2012-06-10 07:21:05 -06:00
|
|
|
swaps(&rep.sequenceNumber);
|
|
|
|
swapl(&rep.start_id);
|
|
|
|
swapl(&rep.count);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
2013-06-07 11:28:45 -06:00
|
|
|
WriteToClient(client, sizeof(xXCMiscGetXIDRangeReply), &rep);
|
2010-12-05 08:36:02 -07:00
|
|
|
return Success;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2010-07-27 13:02:24 -06:00
|
|
|
ProcXCMiscGetXIDList(ClientPtr client)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
REQUEST(xXCMiscGetXIDListReq);
|
|
|
|
xXCMiscGetXIDListReply rep;
|
|
|
|
XID *pids;
|
|
|
|
unsigned int count;
|
|
|
|
|
|
|
|
REQUEST_SIZE_MATCH(xXCMiscGetXIDListReq);
|
|
|
|
|
2007-04-03 20:50:29 -06:00
|
|
|
if (stuff->count > UINT32_MAX / sizeof(XID))
|
2012-06-10 07:21:05 -06:00
|
|
|
return BadAlloc;
|
2007-04-03 20:50:29 -06:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
pids = (XID *) malloc(stuff->count * sizeof(XID));
|
|
|
|
if (!pids) {
|
|
|
|
return BadAlloc;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
count = GetXIDList(client, stuff->count, pids);
|
2013-06-07 11:28:45 -06:00
|
|
|
rep = (xXCMiscGetXIDListReply) {
|
|
|
|
.type = X_Reply,
|
|
|
|
.sequenceNumber = client->sequence,
|
|
|
|
.length = count,
|
|
|
|
.count = count
|
|
|
|
};
|
2006-11-26 11:13:41 -07:00
|
|
|
if (client->swapped) {
|
2012-06-10 07:21:05 -06:00
|
|
|
swaps(&rep.sequenceNumber);
|
|
|
|
swapl(&rep.length);
|
|
|
|
swapl(&rep.count);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
2013-06-07 11:28:45 -06:00
|
|
|
WriteToClient(client, sizeof(xXCMiscGetXIDListReply), &rep);
|
2012-06-10 07:21:05 -06:00
|
|
|
if (count) {
|
|
|
|
client->pSwapReplyFunc = (ReplySwapPtr) Swap32Write;
|
|
|
|
WriteSwappedDataToClient(client, count * sizeof(XID), pids);
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
2010-12-05 08:36:02 -07:00
|
|
|
free(pids);
|
|
|
|
return Success;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2012-06-10 07:21:05 -06:00
|
|
|
ProcXCMiscDispatch(ClientPtr client)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
REQUEST(xReq);
|
2012-06-10 07:21:05 -06:00
|
|
|
switch (stuff->data) {
|
2006-11-26 11:13:41 -07:00
|
|
|
case X_XCMiscGetVersion:
|
2012-06-10 07:21:05 -06:00
|
|
|
return ProcXCMiscGetVersion(client);
|
2006-11-26 11:13:41 -07:00
|
|
|
case X_XCMiscGetXIDRange:
|
2012-06-10 07:21:05 -06:00
|
|
|
return ProcXCMiscGetXIDRange(client);
|
2006-11-26 11:13:41 -07:00
|
|
|
case X_XCMiscGetXIDList:
|
2012-06-10 07:21:05 -06:00
|
|
|
return ProcXCMiscGetXIDList(client);
|
2006-11-26 11:13:41 -07:00
|
|
|
default:
|
2012-06-10 07:21:05 -06:00
|
|
|
return BadRequest;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2010-07-27 13:02:24 -06:00
|
|
|
SProcXCMiscGetVersion(ClientPtr client)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
REQUEST(xXCMiscGetVersionReq);
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
swaps(&stuff->length);
|
2006-11-26 11:13:41 -07:00
|
|
|
REQUEST_SIZE_MATCH(xXCMiscGetVersionReq);
|
2012-06-10 07:21:05 -06:00
|
|
|
swaps(&stuff->majorVersion);
|
|
|
|
swaps(&stuff->minorVersion);
|
2006-11-26 11:13:41 -07:00
|
|
|
return ProcXCMiscGetVersion(client);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2010-07-27 13:02:24 -06:00
|
|
|
SProcXCMiscGetXIDRange(ClientPtr client)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
REQUEST(xReq);
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
swaps(&stuff->length);
|
2006-11-26 11:13:41 -07:00
|
|
|
return ProcXCMiscGetXIDRange(client);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2010-07-27 13:02:24 -06:00
|
|
|
SProcXCMiscGetXIDList(ClientPtr client)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
REQUEST(xXCMiscGetXIDListReq);
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
swaps(&stuff->length);
|
|
|
|
swapl(&stuff->count);
|
2006-11-26 11:13:41 -07:00
|
|
|
return ProcXCMiscGetXIDList(client);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2012-06-10 07:21:05 -06:00
|
|
|
SProcXCMiscDispatch(ClientPtr client)
|
2006-11-26 11:13:41 -07:00
|
|
|
{
|
|
|
|
REQUEST(xReq);
|
2012-06-10 07:21:05 -06:00
|
|
|
switch (stuff->data) {
|
2006-11-26 11:13:41 -07:00
|
|
|
case X_XCMiscGetVersion:
|
2012-06-10 07:21:05 -06:00
|
|
|
return SProcXCMiscGetVersion(client);
|
2006-11-26 11:13:41 -07:00
|
|
|
case X_XCMiscGetXIDRange:
|
2012-06-10 07:21:05 -06:00
|
|
|
return SProcXCMiscGetXIDRange(client);
|
2006-11-26 11:13:41 -07:00
|
|
|
case X_XCMiscGetXIDList:
|
2012-06-10 07:21:05 -06:00
|
|
|
return SProcXCMiscGetXIDList(client);
|
2006-11-26 11:13:41 -07:00
|
|
|
default:
|
2012-06-10 07:21:05 -06:00
|
|
|
return BadRequest;
|
2006-11-26 11:13:41 -07:00
|
|
|
}
|
|
|
|
}
|
2011-11-05 07:32:40 -06:00
|
|
|
|
|
|
|
void
|
2013-06-07 11:28:45 -06:00
|
|
|
XCMiscExtensionInit(void)
|
2011-11-05 07:32:40 -06:00
|
|
|
{
|
|
|
|
AddExtension(XCMiscExtensionName, 0, 0,
|
2012-06-10 07:21:05 -06:00
|
|
|
ProcXCMiscDispatch, SProcXCMiscDispatch,
|
|
|
|
NULL, StandardMinorOpcode);
|
2011-11-05 07:32:40 -06:00
|
|
|
}
|