Xext: panoramiX: 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:
Enrico Weigelt, metux IT consult 2024-07-11 19:54:43 +02:00
parent 587e00e167
commit a5f44e4c59
3 changed files with 19 additions and 117 deletions

View File

@ -32,6 +32,7 @@ Equipment Corporation.
#include <X11/extensions/panoramiXproto.h>
#include "dix/dix_priv.h"
#include "dix/request_priv.h"
#include "dix/resource_priv.h"
#include "dix/screen_hooks_priv.h"
#include "Xext/panoramiX.h"
@ -457,7 +458,8 @@ PanoramiXExtensionInit(void)
while (panoramiXGeneration != serverGeneration) {
extEntry = AddExtension(PANORAMIX_PROTOCOL_NAME, 0, 0,
ProcPanoramiXDispatch,
SProcPanoramiXDispatch, PanoramiXResetProc,
ProcPanoramiXDispatch,
PanoramiXResetProc,
StandardMinorOpcode);
if (!extEntry)
break;
@ -898,7 +900,8 @@ PanoramiXResetProc(ExtensionEntry * extEntry)
int
ProcPanoramiXQueryVersion(ClientPtr client)
{
/* REQUEST(xPanoramiXQueryVersionReq); */
REQUEST_HEAD_STRUCT(xPanoramiXQueryVersionReq);
xPanoramiXQueryVersionReply rep = {
.type = X_Reply,
.sequenceNumber = client->sequence,
@ -907,7 +910,6 @@ ProcPanoramiXQueryVersion(ClientPtr client)
.minorVersion = SERVER_PANORAMIX_MINOR_VERSION
};
REQUEST_SIZE_MATCH(xPanoramiXQueryVersionReq);
if (client->swapped) {
swaps(&rep.sequenceNumber);
swapl(&rep.length);
@ -921,12 +923,13 @@ ProcPanoramiXQueryVersion(ClientPtr client)
int
ProcPanoramiXGetState(ClientPtr client)
{
REQUEST(xPanoramiXGetStateReq);
REQUEST_HEAD_STRUCT(xPanoramiXGetStateReq);
REQUEST_FIELD_CARD32(window);
WindowPtr pWin;
xPanoramiXGetStateReply rep;
int rc;
REQUEST_SIZE_MATCH(xPanoramiXGetStateReq);
rc = dixLookupWindow(&pWin, stuff->window, client, DixGetAttrAccess);
if (rc != Success)
return rc;
@ -951,12 +954,13 @@ ProcPanoramiXGetState(ClientPtr client)
int
ProcPanoramiXGetScreenCount(ClientPtr client)
{
REQUEST(xPanoramiXGetScreenCountReq);
REQUEST_HEAD_STRUCT(xPanoramiXGetScreenCountReq);
REQUEST_FIELD_CARD32(window);
WindowPtr pWin;
xPanoramiXGetScreenCountReply rep;
int rc;
REQUEST_SIZE_MATCH(xPanoramiXGetScreenCountReq);
rc = dixLookupWindow(&pWin, stuff->window, client, DixGetAttrAccess);
if (rc != Success)
return rc;
@ -980,13 +984,14 @@ ProcPanoramiXGetScreenCount(ClientPtr client)
int
ProcPanoramiXGetScreenSize(ClientPtr client)
{
REQUEST(xPanoramiXGetScreenSizeReq);
REQUEST_HEAD_STRUCT(xPanoramiXGetScreenSizeReq);
REQUEST_FIELD_CARD32(window);
REQUEST_FIELD_CARD32(screen);
WindowPtr pWin;
xPanoramiXGetScreenSizeReply rep;
int rc;
REQUEST_SIZE_MATCH(xPanoramiXGetScreenSizeReq);
if (stuff->screen >= PanoramiXNumScreens)
return BadMatch;
@ -1019,12 +1024,9 @@ ProcPanoramiXGetScreenSize(ClientPtr client)
int
ProcXineramaIsActive(ClientPtr client)
{
/* REQUEST(xXineramaIsActiveReq); */
xXineramaIsActiveReply rep;
REQUEST_HEAD_STRUCT(xXineramaIsActiveReq);
REQUEST_SIZE_MATCH(xXineramaIsActiveReq);
rep = (xXineramaIsActiveReply) {
xXineramaIsActiveReply rep = {
.type = X_Reply,
.sequenceNumber = client->sequence,
.length = 0,
@ -1048,7 +1050,8 @@ ProcXineramaIsActive(ClientPtr client)
int
ProcXineramaQueryScreens(ClientPtr client)
{
/* REQUEST(xXineramaQueryScreensReq); */
REQUEST_HEAD_STRUCT(xXineramaQueryScreensReq);
CARD32 number = (noPanoramiXExtension) ? 0 : PanoramiXNumScreens;
xXineramaQueryScreensReply rep = {
.type = X_Reply,
@ -1057,8 +1060,6 @@ ProcXineramaQueryScreens(ClientPtr client)
.number = number
};
REQUEST_SIZE_MATCH(xXineramaQueryScreensReq);
if (client->swapped) {
swaps(&rep.sequenceNumber);
swapl(&rep.length);

View File

@ -1,97 +0,0 @@
/*****************************************************************
Copyright (c) 1991, 1997 Digital Equipment Corporation, Maynard, Massachusetts.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software.
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
DIGITAL EQUIPMENT CORPORATION BE LIABLE FOR ANY CLAIM, DAMAGES, INCLUDING,
BUT NOT LIMITED TO CONSEQUENTIAL OR INCIDENTAL 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 Digital Equipment Corporation
shall not be used in advertising or otherwise to promote the sale, use or other
dealings in this Software without prior written authorization from Digital
Equipment Corporation.
******************************************************************/
#include <dix-config.h>
#include <stdio.h>
#include <X11/X.h>
#include <X11/Xproto.h>
#include <X11/extensions/panoramiXproto.h>
#include "Xext/panoramiX.h"
#include "Xext/panoramiXsrv.h"
#include "misc.h"
#include "cursor.h"
#include "cursorstr.h"
#include "extnsionst.h"
#include "dixstruct.h"
#include "gc.h"
#include "gcstruct.h"
#include "scrnintstr.h"
#include "window.h"
#include "windowstr.h"
#include "pixmapstr.h"
#include "globals.h"
#include "panoramiXh.h"
static int _X_COLD
SProcPanoramiXGetState(ClientPtr client)
{
REQUEST(xPanoramiXGetStateReq);
REQUEST_SIZE_MATCH(xPanoramiXGetStateReq);
swapl(&stuff->window);
return ProcPanoramiXGetState(client);
}
static int _X_COLD
SProcPanoramiXGetScreenCount(ClientPtr client)
{
REQUEST(xPanoramiXGetScreenCountReq);
REQUEST_SIZE_MATCH(xPanoramiXGetScreenCountReq);
swapl(&stuff->window);
return ProcPanoramiXGetScreenCount(client);
}
static int _X_COLD
SProcPanoramiXGetScreenSize(ClientPtr client)
{
REQUEST(xPanoramiXGetScreenSizeReq);
REQUEST_SIZE_MATCH(xPanoramiXGetScreenSizeReq);
swapl(&stuff->window);
swapl(&stuff->screen);
return ProcPanoramiXGetScreenSize(client);
}
int _X_COLD
SProcPanoramiXDispatch(ClientPtr client)
{
REQUEST(xReq);
switch (stuff->data) {
case X_PanoramiXQueryVersion:
return ProcPanoramiXQueryVersion(client);
case X_PanoramiXGetState:
return SProcPanoramiXGetState(client);
case X_PanoramiXGetScreenCount:
return SProcPanoramiXGetScreenCount(client);
case X_PanoramiXGetScreenSize:
return SProcPanoramiXGetScreenSize(client);
case X_XineramaIsActive:
return ProcXineramaIsActive(client);
case X_XineramaQueryScreens:
return ProcXineramaQueryScreens(client);
}
return BadRequest;
}

View File

@ -65,8 +65,6 @@ PROC_EXTERN(ProcPanoramiXGetScreenSize);
PROC_EXTERN(ProcXineramaQueryScreens);
PROC_EXTERN(ProcXineramaIsActive);
extern int SProcPanoramiXDispatch(ClientPtr client);
extern int connBlockScreenStart;
extern xConnSetupPrefix connSetupPrefix;