Xext: xcmisc: use REQUEST_HEAD_STRUCT and REQUEST_FIELD_* macros
Use the new macros to make request struct parsing / field swapping much easier. Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
This commit is contained in:
parent
0bf0da7b90
commit
6f360d77bb
|
@ -33,6 +33,7 @@ from The Open Group.
|
||||||
#include <X11/Xproto.h>
|
#include <X11/Xproto.h>
|
||||||
#include <X11/extensions/xcmiscproto.h>
|
#include <X11/extensions/xcmiscproto.h>
|
||||||
|
|
||||||
|
#include "dix/request_priv.h"
|
||||||
#include "dix/resource_priv.h"
|
#include "dix/resource_priv.h"
|
||||||
|
|
||||||
#include "misc.h"
|
#include "misc.h"
|
||||||
|
@ -45,6 +46,11 @@ from The Open Group.
|
||||||
static int
|
static int
|
||||||
ProcXCMiscGetVersion(ClientPtr client)
|
ProcXCMiscGetVersion(ClientPtr client)
|
||||||
{
|
{
|
||||||
|
REQUEST_HEAD_STRUCT(xXCMiscGetVersionReq);
|
||||||
|
REQUEST_SIZE_MATCH(xXCMiscGetVersionReq);
|
||||||
|
REQUEST_FIELD_CARD16(majorVersion);
|
||||||
|
REQUEST_FIELD_CARD16(minorVersion);
|
||||||
|
|
||||||
xXCMiscGetVersionReply rep = {
|
xXCMiscGetVersionReply rep = {
|
||||||
.type = X_Reply,
|
.type = X_Reply,
|
||||||
.sequenceNumber = client->sequence,
|
.sequenceNumber = client->sequence,
|
||||||
|
@ -53,8 +59,6 @@ ProcXCMiscGetVersion(ClientPtr client)
|
||||||
.minorVersion = XCMiscMinorVersion
|
.minorVersion = XCMiscMinorVersion
|
||||||
};
|
};
|
||||||
|
|
||||||
REQUEST_SIZE_MATCH(xXCMiscGetVersionReq);
|
|
||||||
|
|
||||||
if (client->swapped) {
|
if (client->swapped) {
|
||||||
swaps(&rep.sequenceNumber);
|
swaps(&rep.sequenceNumber);
|
||||||
swaps(&rep.majorVersion);
|
swaps(&rep.majorVersion);
|
||||||
|
@ -67,10 +71,10 @@ ProcXCMiscGetVersion(ClientPtr client)
|
||||||
static int
|
static int
|
||||||
ProcXCMiscGetXIDRange(ClientPtr client)
|
ProcXCMiscGetXIDRange(ClientPtr client)
|
||||||
{
|
{
|
||||||
|
REQUEST_HEAD_STRUCT(xXCMiscGetXIDRangeReq);
|
||||||
|
|
||||||
xXCMiscGetXIDRangeReply rep;
|
xXCMiscGetXIDRangeReply rep;
|
||||||
XID min_id, max_id;
|
XID min_id, max_id;
|
||||||
|
|
||||||
REQUEST_SIZE_MATCH(xXCMiscGetXIDRangeReq);
|
|
||||||
GetXIDRange(client->index, FALSE, &min_id, &max_id);
|
GetXIDRange(client->index, FALSE, &min_id, &max_id);
|
||||||
rep = (xXCMiscGetXIDRangeReply) {
|
rep = (xXCMiscGetXIDRangeReply) {
|
||||||
.type = X_Reply,
|
.type = X_Reply,
|
||||||
|
@ -91,13 +95,14 @@ ProcXCMiscGetXIDRange(ClientPtr client)
|
||||||
static int
|
static int
|
||||||
ProcXCMiscGetXIDList(ClientPtr client)
|
ProcXCMiscGetXIDList(ClientPtr client)
|
||||||
{
|
{
|
||||||
REQUEST(xXCMiscGetXIDListReq);
|
REQUEST_HEAD_STRUCT(xXCMiscGetXIDListReq);
|
||||||
|
REQUEST_FIELD_CARD16(length);
|
||||||
|
REQUEST_FIELD_CARD32(count);
|
||||||
|
|
||||||
xXCMiscGetXIDListReply rep;
|
xXCMiscGetXIDListReply rep;
|
||||||
XID *pids;
|
XID *pids;
|
||||||
unsigned int count;
|
unsigned int count;
|
||||||
|
|
||||||
REQUEST_SIZE_MATCH(xXCMiscGetXIDListReq);
|
|
||||||
|
|
||||||
if (stuff->count > UINT32_MAX / sizeof(XID))
|
if (stuff->count > UINT32_MAX / sizeof(XID))
|
||||||
return BadAlloc;
|
return BadAlloc;
|
||||||
|
|
||||||
|
@ -142,46 +147,10 @@ ProcXCMiscDispatch(ClientPtr client)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int _X_COLD
|
|
||||||
SProcXCMiscGetVersion(ClientPtr client)
|
|
||||||
{
|
|
||||||
REQUEST(xXCMiscGetVersionReq);
|
|
||||||
REQUEST_SIZE_MATCH(xXCMiscGetVersionReq);
|
|
||||||
swaps(&stuff->majorVersion);
|
|
||||||
swaps(&stuff->minorVersion);
|
|
||||||
return ProcXCMiscGetVersion(client);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int _X_COLD
|
|
||||||
SProcXCMiscGetXIDList(ClientPtr client)
|
|
||||||
{
|
|
||||||
REQUEST(xXCMiscGetXIDListReq);
|
|
||||||
REQUEST_SIZE_MATCH(xXCMiscGetXIDListReq);
|
|
||||||
|
|
||||||
swapl(&stuff->count);
|
|
||||||
return ProcXCMiscGetXIDList(client);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int _X_COLD
|
|
||||||
SProcXCMiscDispatch(ClientPtr client)
|
|
||||||
{
|
|
||||||
REQUEST(xReq);
|
|
||||||
switch (stuff->data) {
|
|
||||||
case X_XCMiscGetVersion:
|
|
||||||
return SProcXCMiscGetVersion(client);
|
|
||||||
case X_XCMiscGetXIDRange:
|
|
||||||
return ProcXCMiscGetXIDRange(client);
|
|
||||||
case X_XCMiscGetXIDList:
|
|
||||||
return SProcXCMiscGetXIDList(client);
|
|
||||||
default:
|
|
||||||
return BadRequest;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
XCMiscExtensionInit(void)
|
XCMiscExtensionInit(void)
|
||||||
{
|
{
|
||||||
AddExtension(XCMiscExtensionName, 0, 0,
|
AddExtension(XCMiscExtensionName, 0, 0,
|
||||||
ProcXCMiscDispatch, SProcXCMiscDispatch,
|
ProcXCMiscDispatch, ProcXCMiscDispatch,
|
||||||
NULL, StandardMinorOpcode);
|
NULL, StandardMinorOpcode);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue