aboutsummaryrefslogtreecommitdiff
path: root/xorg-server/dix
diff options
context:
space:
mode:
Diffstat (limited to 'xorg-server/dix')
-rw-r--r--xorg-server/dix/colormap.c7
-rw-r--r--xorg-server/dix/cursor.c2
-rw-r--r--xorg-server/dix/dispatch.c23
-rw-r--r--xorg-server/dix/swaprep.c2537
-rw-r--r--xorg-server/dix/swapreq.c2116
5 files changed, 2252 insertions, 2433 deletions
diff --git a/xorg-server/dix/colormap.c b/xorg-server/dix/colormap.c
index 0e1feb6c4..038457d3d 100644
--- a/xorg-server/dix/colormap.c
+++ b/xorg-server/dix/colormap.c
@@ -287,13 +287,6 @@ CreateColormap (Colormap mid, ScreenPtr pScreen, VisualPtr pVisual,
if (!pmap)
return BadAlloc;
}
-#if defined(_XSERVER64)
- pmap->pad0 = 0;
- pmap->pad1 = 0;
-#if (X_BYTE_ORDER == X_LITTLE_ENDIAN)
- pmap->pad2 = 0;
-#endif
-#endif
pmap->red = (EntryPtr)((char *)pmap + sizeof(ColormapRec));
sizebytes = size * sizeof(Entry);
pmap->clientPixelsRed = (Pixel **)((char *)pmap->red + sizebytes);
diff --git a/xorg-server/dix/cursor.c b/xorg-server/dix/cursor.c
index c191c1e88..f29cb1125 100644
--- a/xorg-server/dix/cursor.c
+++ b/xorg-server/dix/cursor.c
@@ -72,7 +72,7 @@ typedef struct _GlyphShare {
static GlyphSharePtr sharedGlyphs = (GlyphSharePtr)NULL;
-DevPrivateKeyRec cursorScreenDevPriv[MAXSCREENS];
+DevScreenPrivateKeyRec cursorScreenDevPriv;
#ifdef XFIXES
static CARD32 cursorSerial;
diff --git a/xorg-server/dix/dispatch.c b/xorg-server/dix/dispatch.c
index 192c8c34e..43cb4d1d3 100644
--- a/xorg-server/dix/dispatch.c
+++ b/xorg-server/dix/dispatch.c
@@ -1419,7 +1419,6 @@ CreatePmap:
}
if (AddResource(stuff->pid, RT_PIXMAP, (pointer)pMap))
return Success;
- (*pDraw->pScreen->DestroyPixmap)(pMap);
}
return BadAlloc;
}
@@ -3443,8 +3442,7 @@ CloseDownClient(ClientPtr client)
* now. If it hasn't gotten to Running, nClients has *not*
* been incremented, so *don't* decrement it.
*/
- if (client->clientState != ClientStateInitial &&
- client->clientState != ClientStateAuthenticating )
+ if (client->clientState != ClientStateInitial)
{
--nClients;
}
@@ -3584,7 +3582,7 @@ ProcInitialConnection(ClientPtr client)
bytes_to_int32(prefix->nbytesAuthString);
if (client->swapped)
{
- swaps(&stuff->length, whichbyte);
+ swaps(&stuff->length);
}
ResetCurrentRequest(client);
return Success;
@@ -3706,19 +3704,8 @@ ProcEstablishConnection(ClientPtr client)
auth_proto,
(unsigned short)prefix->nbytesAuthString,
auth_string);
- /*
- * If Kerberos is being used for this client, the clientState
- * will be set to ClientStateAuthenticating at this point.
- * More messages need to be exchanged among the X server, Kerberos
- * server, and client to figure out if everyone is authorized.
- * So we don't want to send the connection setup info yet, since
- * the auth step isn't really done.
- */
- if (client->clientState == ClientStateCheckingSecurity)
- client->clientState = ClientStateCheckedSecurity;
- else if (client->clientState != ClientStateAuthenticating)
- return(SendConnSetup(client, reason));
- return Success;
+
+ return(SendConnSetup(client, reason));
}
void
@@ -3911,7 +3898,7 @@ AddScreen(
return -1;
}
- dixRegisterPrivateKey(&cursorScreenDevPriv[i], PRIVATE_CURSOR, 0);
+ dixRegisterScreenPrivateKey(&cursorScreenDevPriv, pScreen, PRIVATE_CURSOR, 0);
return i;
}
diff --git a/xorg-server/dix/swaprep.c b/xorg-server/dix/swaprep.c
index 936da6d1c..28c354cd9 100644
--- a/xorg-server/dix/swaprep.c
+++ b/xorg-server/dix/swaprep.c
@@ -1,1308 +1,1229 @@
-/************************************************************
-
-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.
-
-********************************************************/
-
-
-#ifdef HAVE_DIX_CONFIG_H
-#include <dix-config.h>
-#endif
-
-#include <X11/X.h>
-#include <X11/Xproto.h>
-#include "misc.h"
-#include "dixstruct.h"
-#include <X11/fonts/fontstruct.h>
-#include "scrnintstr.h"
-#include "swaprep.h"
-#include "globals.h"
-
-static void SwapFontInfo(xQueryFontReply *pr);
-
-static void SwapCharInfo(xCharInfo *pInfo);
-
-static void SwapFont(xQueryFontReply *pr, Bool hasGlyphs);
-
-/**
- * Thanks to Jack Palevich for testing and subsequently rewriting all this
- *
- * \param size size in bytes
- */
-void
-Swap32Write(ClientPtr pClient, int size, CARD32 *pbuf)
-{
- int i;
- char n;
-
- size >>= 2;
- for(i = 0; i < size; i++)
- /* brackets are mandatory here, because "swapl" macro expands
- to several statements */
- {
- swapl(&pbuf[i], n);
- }
- (void)WriteToClient(pClient, size << 2, (char *) pbuf);
-}
-
-/**
- *
- * \param size size in bytes
- */
-void
-CopySwap32Write(ClientPtr pClient, int size, CARD32 *pbuf)
-{
- int bufsize = size;
- CARD32 *pbufT;
- CARD32 *from, *to, *fromLast, *toLast;
- CARD32 tmpbuf[1];
-
- /* Allocate as big a buffer as we can... */
- while (!(pbufT = malloc(bufsize)))
- {
- bufsize >>= 1;
- if (bufsize == 4)
- {
- pbufT = tmpbuf;
- break;
- }
- }
-
- /* convert lengths from # of bytes to # of longs */
- size >>= 2;
- bufsize >>= 2;
-
- from = pbuf;
- fromLast = from + size;
- while (from < fromLast) {
- int nbytes;
- to = pbufT;
- toLast = to + min (bufsize, fromLast - from);
- nbytes = (toLast - to) << 2;
- while (to < toLast) {
- /* can't write "cpswapl(*from++, *to++)" because cpswapl is a macro
- that evaulates its args more than once */
- cpswapl(*from, *to);
- from++;
- to++;
- }
- (void)WriteToClient (pClient, nbytes, (char *) pbufT);
- }
-
- if (pbufT != tmpbuf)
- free(pbufT);
-}
-
-/**
- *
- * \param size size in bytes
- */
-void
-CopySwap16Write(ClientPtr pClient, int size, short *pbuf)
-{
- int bufsize = size;
- short *pbufT;
- short *from, *to, *fromLast, *toLast;
- short tmpbuf[2];
-
- /* Allocate as big a buffer as we can... */
- while (!(pbufT = malloc(bufsize)))
- {
- bufsize >>= 1;
- if (bufsize == 4)
- {
- pbufT = tmpbuf;
- break;
- }
- }
-
- /* convert lengths from # of bytes to # of shorts */
- size >>= 1;
- bufsize >>= 1;
-
- from = pbuf;
- fromLast = from + size;
- while (from < fromLast) {
- int nbytes;
- to = pbufT;
- toLast = to + min (bufsize, fromLast - from);
- nbytes = (toLast - to) << 1;
- while (to < toLast) {
- /* can't write "cpswaps(*from++, *to++)" because cpswaps is a macro
- that evaulates its args more than once */
- cpswaps(*from, *to);
- from++;
- to++;
- }
- (void)WriteToClient (pClient, nbytes, (char *) pbufT);
- }
-
- if (pbufT != tmpbuf)
- free(pbufT);
-}
-
-
-/* Extra-small reply */
-void
-SGenericReply(ClientPtr pClient, int size, xGenericReply *pRep)
-{
- char n;
-
- swaps(&pRep->sequenceNumber, n);
- (void)WriteToClient(pClient, size, (char *) pRep);
-}
-
-/* Extra-large reply */
-void
-SGetWindowAttributesReply(ClientPtr pClient, int size,
- xGetWindowAttributesReply *pRep)
-{
- char n;
-
- swaps(&pRep->sequenceNumber, n);
- swapl(&pRep->length, n);
- swapl(&pRep->visualID, n);
- swaps(&pRep->class, n);
- swapl(&pRep->backingBitPlanes, n);
- swapl(&pRep->backingPixel, n);
- swapl(&pRep->colormap, n);
- swapl(&pRep->allEventMasks, n);
- swapl(&pRep->yourEventMask, n);
- swaps(&pRep->doNotPropagateMask, n);
- (void)WriteToClient(pClient, size, (char *) pRep);
-}
-
-void
-SGetGeometryReply(ClientPtr pClient, int size, xGetGeometryReply *pRep)
-{
- char n;
-
- swaps(&pRep->sequenceNumber, n);
- swapl(&pRep->root, n);
- swaps(&pRep->x, n);
- swaps(&pRep->y, n);
- swaps(&pRep->width, n);
- swaps(&pRep->height, n);
- swaps(&pRep->borderWidth, n);
- (void)WriteToClient(pClient, size, (char *) pRep);
-}
-
-void
-SQueryTreeReply(ClientPtr pClient, int size, xQueryTreeReply *pRep)
-{
- char n;
-
- swaps(&pRep->sequenceNumber, n);
- swapl(&pRep->length, n);
- swapl(&pRep->root, n);
- swapl(&pRep->parent, n);
- swaps(&pRep->nChildren, n);
- (void)WriteToClient(pClient, size, (char *) pRep);
-}
-
-void
-SInternAtomReply(ClientPtr pClient, int size, xInternAtomReply *pRep)
-{
- char n;
-
- swaps(&pRep->sequenceNumber, n);
- swapl(&pRep->atom, n);
- (void)WriteToClient(pClient, size, (char *) pRep);
-}
-
-void
-SGetAtomNameReply(ClientPtr pClient, int size, xGetAtomNameReply *pRep)
-{
- char n;
-
- swaps(&pRep->sequenceNumber, n);
- swapl(&pRep->length, n);
- swaps(&pRep->nameLength, n);
- (void)WriteToClient(pClient, size, (char *) pRep);
-}
-
-
-void
-SGetPropertyReply(ClientPtr pClient, int size, xGetPropertyReply *pRep)
-{
- char n;
-
- swaps(&pRep->sequenceNumber, n);
- swapl(&pRep->length, n);
- swapl(&pRep->propertyType, n);
- swapl(&pRep->bytesAfter, n);
- swapl(&pRep->nItems, n);
- (void)WriteToClient(pClient, size, (char *) pRep);
-}
-
-void
-SListPropertiesReply(ClientPtr pClient, int size, xListPropertiesReply *pRep)
-{
- char n;
-
- swaps(&pRep->sequenceNumber, n);
- swapl(&pRep->length, n);
- swaps(&pRep->nProperties, n);
- (void)WriteToClient(pClient, size, (char *) pRep);
-}
-
-void
-SGetSelectionOwnerReply(ClientPtr pClient, int size,
- xGetSelectionOwnerReply *pRep)
-{
- char n;
-
- swaps(&pRep->sequenceNumber, n);
- swapl(&pRep->owner, n);
- (void)WriteToClient(pClient, size, (char *) pRep);
-}
-
-
-void
-SQueryPointerReply(ClientPtr pClient, int size, xQueryPointerReply *pRep)
-{
- char n;
-
- swaps(&pRep->sequenceNumber, n);
- swapl(&pRep->root, n);
- swapl(&pRep->child, n);
- swaps(&pRep->rootX, n);
- swaps(&pRep->rootY, n);
- swaps(&pRep->winX, n);
- swaps(&pRep->winY, n);
- swaps(&pRep->mask, n);
- (void)WriteToClient(pClient, size, (char *) pRep);
-}
-
-static void
-SwapTimecoord(xTimecoord* pCoord)
-{
- char n;
-
- swapl(&pCoord->time, n);
- swaps(&pCoord->x, n);
- swaps(&pCoord->y, n);
-}
-
-void
-SwapTimeCoordWrite(ClientPtr pClient, int size, xTimecoord *pRep)
-{
- int i, n;
- xTimecoord *pRepT;
-
- n = size / sizeof(xTimecoord);
- pRepT = pRep;
- for(i = 0; i < n; i++)
- {
- SwapTimecoord(pRepT);
- pRepT++;
- }
- (void)WriteToClient(pClient, size, (char *) pRep);
-
-}
-void
-SGetMotionEventsReply(ClientPtr pClient, int size, xGetMotionEventsReply *pRep)
-{
- char n;
-
- swaps(&pRep->sequenceNumber, n);
- swapl(&pRep->length, n);
- swapl(&pRep->nEvents, n);
- (void)WriteToClient(pClient, size, (char *) pRep);
-}
-
-void
-STranslateCoordsReply(ClientPtr pClient, int size, xTranslateCoordsReply *pRep)
-{
- char n;
-
- swaps(&pRep->sequenceNumber, n);
- swapl(&pRep->child, n);
- swaps(&pRep->dstX, n);
- swaps(&pRep->dstY, n);
- (void)WriteToClient(pClient, size, (char *) pRep);
-}
-
-void
-SGetInputFocusReply(ClientPtr pClient, int size, xGetInputFocusReply *pRep)
-{
- char n;
-
- swaps(&pRep->sequenceNumber, n);
- swapl(&pRep->focus, n);
- (void)WriteToClient(pClient, size, (char *) pRep);
-}
-
-/* extra long reply */
-void
-SQueryKeymapReply(ClientPtr pClient, int size, xQueryKeymapReply *pRep)
-{
- char n;
-
- swaps(&pRep->sequenceNumber, n);
- swapl(&pRep->length, n);
- (void)WriteToClient(pClient, size, (char *) pRep);
-}
-
-static void
-SwapCharInfo(xCharInfo *pInfo)
-{
- char n;
-
- swaps(&pInfo->leftSideBearing, n);
- swaps(&pInfo->rightSideBearing, n);
- swaps(&pInfo->characterWidth, n);
- swaps(&pInfo->ascent, n);
- swaps(&pInfo->descent, n);
- swaps(&pInfo->attributes, n);
-}
-
-static void
-SwapFontInfo(xQueryFontReply *pr)
-{
- char n;
-
- swaps(&pr->minCharOrByte2, n);
- swaps(&pr->maxCharOrByte2, n);
- swaps(&pr->defaultChar, n);
- swaps(&pr->nFontProps, n);
- swaps(&pr->fontAscent, n);
- swaps(&pr->fontDescent, n);
- SwapCharInfo( &pr->minBounds);
- SwapCharInfo( &pr->maxBounds);
- swapl(&pr->nCharInfos, n);
-}
-
-static void
-SwapFont(xQueryFontReply *pr, Bool hasGlyphs)
-{
- unsigned i;
- xCharInfo * pxci;
- unsigned nchars, nprops;
- char *pby;
- char n;
-
- swaps(&pr->sequenceNumber, n);
- swapl(&pr->length, n);
- nchars = pr->nCharInfos;
- nprops = pr->nFontProps;
- SwapFontInfo(pr);
- pby = (char *) &pr[1];
- /* Font properties are an atom and either an int32 or a CARD32, so
- * they are always 2 4 byte values */
- for(i = 0; i < nprops; i++)
- {
- swapl(pby, n);
- pby += 4;
- swapl(pby, n);
- pby += 4;
- }
- if (hasGlyphs)
- {
- pxci = (xCharInfo *)pby;
- for(i = 0; i< nchars; i++, pxci++)
- SwapCharInfo(pxci);
- }
-}
-
-void
-SQueryFontReply(ClientPtr pClient, int size, xQueryFontReply *pRep)
-{
- SwapFont(pRep, TRUE);
- (void)WriteToClient(pClient, size, (char *) pRep);
-}
-
-void
-SQueryTextExtentsReply(ClientPtr pClient, int size, xQueryTextExtentsReply *pRep)
-{
- char n;
-
- swaps(&pRep->sequenceNumber, n);
- swaps(&pRep->fontAscent, n);
- swaps(&pRep->fontDescent, n);
- swaps(&pRep->overallAscent, n);
- swaps(&pRep->overallDescent, n);
- swapl(&pRep->overallWidth, n);
- swapl(&pRep->overallLeft, n);
- swapl(&pRep->overallRight, n);
- (void)WriteToClient(pClient, size, (char *) pRep);
-}
-
-void
-SListFontsReply(ClientPtr pClient, int size, xListFontsReply *pRep)
-{
- char n;
-
- swaps(&pRep->sequenceNumber, n);
- swapl(&pRep->length, n);
- swaps(&pRep->nFonts, n);
- (void)WriteToClient(pClient, size, (char *) pRep);
-}
-
-void
-SListFontsWithInfoReply(ClientPtr pClient, int size,
- xListFontsWithInfoReply *pRep)
-{
- SwapFont((xQueryFontReply *)pRep, FALSE);
- (void)WriteToClient(pClient, size, (char *) pRep);
-}
-
-void
-SGetFontPathReply(ClientPtr pClient, int size, xGetFontPathReply *pRep)
-{
- char n;
-
- swaps(&pRep->sequenceNumber, n);
- swapl(&pRep->length, n);
- swaps(&pRep->nPaths, n);
- (void)WriteToClient(pClient, size, (char *) pRep);
-}
-
-void
-SGetImageReply(ClientPtr pClient, int size, xGetImageReply *pRep)
-{
- char n;
-
- swaps(&pRep->sequenceNumber, n);
- swapl(&pRep->length, n);
- swapl(&pRep->visual, n);
- (void)WriteToClient(pClient, size, (char *) pRep);
- /* Fortunately, image doesn't need swapping */
-}
-
-void
-SListInstalledColormapsReply(ClientPtr pClient, int size,
- xListInstalledColormapsReply *pRep)
-{
- char n;
-
- swaps(&pRep->sequenceNumber, n);
- swapl(&pRep->length, n);
- swaps(&pRep->nColormaps, n);
- (void)WriteToClient(pClient, size, (char *) pRep);
-}
-
-void
-SAllocColorReply(ClientPtr pClient, int size, xAllocColorReply *pRep)
-{
- char n;
-
- swaps(&pRep->sequenceNumber, n);
- swaps(&pRep->red, n);
- swaps(&pRep->green, n);
- swaps(&pRep->blue, n);
- swapl(&pRep->pixel, n);
- (void)WriteToClient(pClient, size, (char *) pRep);
-}
-
-void
-SAllocNamedColorReply(ClientPtr pClient, int size, xAllocNamedColorReply *pRep)
-{
- char n;
-
- swaps(&pRep->sequenceNumber, n);
- swapl(&pRep->pixel, n);
- swaps(&pRep->exactRed, n);
- swaps(&pRep->exactGreen, n);
- swaps(&pRep->exactBlue, n);
- swaps(&pRep->screenRed, n);
- swaps(&pRep->screenGreen, n);
- swaps(&pRep->screenBlue, n);
- (void)WriteToClient(pClient, size, (char *) pRep);
-}
-
-void
-SAllocColorCellsReply(ClientPtr pClient, int size, xAllocColorCellsReply *pRep)
-{
- char n;
-
- swaps(&pRep->sequenceNumber, n);
- swapl(&pRep->length, n);
- swaps(&pRep->nPixels, n);
- swaps(&pRep->nMasks, n);
- (void)WriteToClient(pClient, size, (char *) pRep);
-}
-
-
-void
-SAllocColorPlanesReply(ClientPtr pClient, int size, xAllocColorPlanesReply *pRep)
-{
- char n;
-
- swaps(&pRep->sequenceNumber, n);
- swapl(&pRep->length, n);
- swaps(&pRep->nPixels, n);
- swapl(&pRep->redMask, n);
- swapl(&pRep->greenMask, n);
- swapl(&pRep->blueMask, n);
- (void)WriteToClient(pClient, size, (char *) pRep);
-}
-
-static void
-SwapRGB(xrgb *prgb)
-{
- char n;
-
- swaps(&prgb->red, n);
- swaps(&prgb->green, n);
- swaps(&prgb->blue, n);
-}
-
-void
-SQColorsExtend(ClientPtr pClient, int size, xrgb *prgb)
-{
- int i, n;
- xrgb *prgbT;
-
- n = size / sizeof(xrgb);
- prgbT = prgb;
- for(i = 0; i < n; i++)
- {
- SwapRGB(prgbT);
- prgbT++;
- }
- (void)WriteToClient(pClient, size, (char *) prgb);
-}
-
-void
-SQueryColorsReply(ClientPtr pClient, int size, xQueryColorsReply* pRep)
-{
- char n;
-
- swaps(&pRep->sequenceNumber, n);
- swapl(&pRep->length, n);
- swaps(&pRep->nColors, n);
- (void)WriteToClient(pClient, size, (char *) pRep);
-}
-
-void
-SLookupColorReply(ClientPtr pClient, int size, xLookupColorReply *pRep)
-{
- char n;
-
- swaps(&pRep->sequenceNumber, n);
- swaps(&pRep->exactRed, n);
- swaps(&pRep->exactGreen, n);
- swaps(&pRep->exactBlue, n);
- swaps(&pRep->screenRed, n);
- swaps(&pRep->screenGreen, n);
- swaps(&pRep->screenBlue, n);
- (void)WriteToClient(pClient, size, (char *) pRep);
-}
-
-void
-SQueryBestSizeReply(ClientPtr pClient, int size, xQueryBestSizeReply *pRep)
-{
- char n;
-
- swaps(&pRep->sequenceNumber, n);
- swaps(&pRep->width, n);
- swaps(&pRep->height, n);
- (void)WriteToClient(pClient, size, (char *) pRep);
-}
-
-void
-SListExtensionsReply(ClientPtr pClient, int size, xListExtensionsReply *pRep)
-{
- char n;
-
- swaps(&pRep->sequenceNumber, n);
- swapl(&pRep->length, n);
- (void)WriteToClient(pClient, size, (char *) pRep);
-}
-
-void
-SGetKeyboardMappingReply(ClientPtr pClient, int size,
- xGetKeyboardMappingReply *pRep)
-{
- char n;
-
- swaps(&pRep->sequenceNumber, n);
- swapl(&pRep->length, n);
- (void)WriteToClient(pClient, size, (char *) pRep);
-}
-
-void
-SGetPointerMappingReply(ClientPtr pClient, int size,
- xGetPointerMappingReply *pRep)
-{
- char n;
-
- swaps(&pRep->sequenceNumber, n);
- swapl(&pRep->length, n);
- (void)WriteToClient(pClient, size, (char *) pRep);
-}
-
-void
-SGetModifierMappingReply(ClientPtr pClient, int size,
- xGetModifierMappingReply *pRep)
-{
- char n;
-
- swaps(&pRep->sequenceNumber, n);
- swapl(&pRep->length, n);
- (void)WriteToClient(pClient, size, (char *) pRep);
-}
-
-void
-SGetKeyboardControlReply(ClientPtr pClient, int size, xGetKeyboardControlReply *pRep)
-{
- char n;
-
- swaps(&pRep->sequenceNumber, n);
- swapl(&pRep->length, n);
- swapl(&pRep->ledMask, n);
- swaps(&pRep->bellPitch, n);
- swaps(&pRep->bellDuration, n);
- (void)WriteToClient(pClient, size, (char *) pRep);
-}
-
-void
-SGetPointerControlReply(ClientPtr pClient, int size, xGetPointerControlReply *pRep)
-{
- char n;
-
- swaps(&pRep->sequenceNumber, n);
- swaps(&pRep->accelNumerator, n);
- swaps(&pRep->accelDenominator, n);
- swaps(&pRep->threshold, n);
- (void)WriteToClient(pClient, size, (char *) pRep);
-}
-
-void
-SGetScreenSaverReply(ClientPtr pClient, int size, xGetScreenSaverReply *pRep)
-{
- char n;
-
- swaps(&pRep->sequenceNumber, n);
- swaps(&pRep->timeout, n);
- swaps(&pRep->interval, n);
- (void)WriteToClient(pClient, size, (char *) pRep);
-}
-
-void
-SLHostsExtend(ClientPtr pClient, int size, char *buf)
-{
- char *bufT = buf;
- char *endbuf = buf + size;
- while (bufT < endbuf) {
- xHostEntry *host = (xHostEntry *) bufT;
- int len = host->length;
- char n;
- swaps (&host->length, n);
- bufT += sizeof (xHostEntry) + pad_to_int32(len);
- }
- (void)WriteToClient (pClient, size, buf);
-}
-
-void
-SListHostsReply(ClientPtr pClient, int size, xListHostsReply *pRep)
-{
- char n;
-
- swaps(&pRep->sequenceNumber, n);
- swapl(&pRep->length, n);
- swaps(&pRep->nHosts, n);
- (void)WriteToClient(pClient, size, (char *) pRep);
-}
-
-
-
-void
-SErrorEvent(xError *from, xError *to)
-{
- to->type = X_Error;
- to->errorCode = from->errorCode;
- cpswaps(from->sequenceNumber, to->sequenceNumber);
- cpswapl(from->resourceID, to->resourceID);
- cpswaps(from->minorCode, to->minorCode);
- to->majorCode = from->majorCode;
-}
-
-void
-SKeyButtonPtrEvent(xEvent *from, xEvent *to)
-{
- to->u.u.type = from->u.u.type;
- to->u.u.detail = from->u.u.detail;
- cpswaps(from->u.u.sequenceNumber, to->u.u.sequenceNumber);
- cpswapl(from->u.keyButtonPointer.time,
- to->u.keyButtonPointer.time);
- cpswapl(from->u.keyButtonPointer.root,
- to->u.keyButtonPointer.root);
- cpswapl(from->u.keyButtonPointer.event,
- to->u.keyButtonPointer.event);
- cpswapl(from->u.keyButtonPointer.child,
- to->u.keyButtonPointer.child);
- cpswaps(from->u.keyButtonPointer.rootX,
- to->u.keyButtonPointer.rootX);
- cpswaps(from->u.keyButtonPointer.rootY,
- to->u.keyButtonPointer.rootY);
- cpswaps(from->u.keyButtonPointer.eventX,
- to->u.keyButtonPointer.eventX);
- cpswaps(from->u.keyButtonPointer.eventY,
- to->u.keyButtonPointer.eventY);
- cpswaps(from->u.keyButtonPointer.state,
- to->u.keyButtonPointer.state);
- to->u.keyButtonPointer.sameScreen =
- from->u.keyButtonPointer.sameScreen;
-}
-
-void
-SEnterLeaveEvent(xEvent *from, xEvent *to)
-{
- to->u.u.type = from->u.u.type;
- to->u.u.detail = from->u.u.detail;
- cpswaps(from->u.u.sequenceNumber, to->u.u.sequenceNumber);
- cpswapl(from->u.enterLeave.time, to->u.enterLeave.time);
- cpswapl(from->u.enterLeave.root, to->u.enterLeave.root);
- cpswapl(from->u.enterLeave.event, to->u.enterLeave.event);
- cpswapl(from->u.enterLeave.child, to->u.enterLeave.child);
- cpswaps(from->u.enterLeave.rootX, to->u.enterLeave.rootX);
- cpswaps(from->u.enterLeave.rootY, to->u.enterLeave.rootY);
- cpswaps(from->u.enterLeave.eventX, to->u.enterLeave.eventX);
- cpswaps(from->u.enterLeave.eventY, to->u.enterLeave.eventY);
- cpswaps(from->u.enterLeave.state, to->u.enterLeave.state);
- to->u.enterLeave.mode = from->u.enterLeave.mode;
- to->u.enterLeave.flags = from->u.enterLeave.flags;
-}
-
-void
-SFocusEvent(xEvent *from, xEvent *to)
-{
- to->u.u.type = from->u.u.type;
- to->u.u.detail = from->u.u.detail;
- cpswaps(from->u.u.sequenceNumber, to->u.u.sequenceNumber);
- cpswapl(from->u.focus.window, to->u.focus.window);
- to->u.focus.mode = from->u.focus.mode;
-}
-
-void
-SExposeEvent(xEvent *from, xEvent *to)
-{
- to->u.u.type = from->u.u.type;
- cpswaps(from->u.u.sequenceNumber, to->u.u.sequenceNumber);
- cpswapl(from->u.expose.window, to->u.expose.window);
- cpswaps(from->u.expose.x, to->u.expose.x);
- cpswaps(from->u.expose.y, to->u.expose.y);
- cpswaps(from->u.expose.width, to->u.expose.width);
- cpswaps(from->u.expose.height, to->u.expose.height);
- cpswaps(from->u.expose.count, to->u.expose.count);
-}
-
-void
-SGraphicsExposureEvent(xEvent *from, xEvent *to)
-{
- to->u.u.type = from->u.u.type;
- cpswaps(from->u.u.sequenceNumber, to->u.u.sequenceNumber);
- cpswapl(from->u.graphicsExposure.drawable,
- to->u.graphicsExposure.drawable);
- cpswaps(from->u.graphicsExposure.x,
- to->u.graphicsExposure.x);
- cpswaps(from->u.graphicsExposure.y,
- to->u.graphicsExposure.y);
- cpswaps(from->u.graphicsExposure.width,
- to->u.graphicsExposure.width);
- cpswaps(from->u.graphicsExposure.height,
- to->u.graphicsExposure.height);
- cpswaps(from->u.graphicsExposure.minorEvent,
- to->u.graphicsExposure.minorEvent);
- cpswaps(from->u.graphicsExposure.count,
- to->u.graphicsExposure.count);
- to->u.graphicsExposure.majorEvent =
- from->u.graphicsExposure.majorEvent;
-}
-
-void
-SNoExposureEvent(xEvent *from, xEvent *to)
-{
- to->u.u.type = from->u.u.type;
- cpswaps(from->u.u.sequenceNumber, to->u.u.sequenceNumber);
- cpswapl(from->u.noExposure.drawable, to->u.noExposure.drawable);
- cpswaps(from->u.noExposure.minorEvent, to->u.noExposure.minorEvent);
- to->u.noExposure.majorEvent = from->u.noExposure.majorEvent;
-}
-
-void
-SVisibilityEvent(xEvent *from, xEvent *to)
-{
- to->u.u.type = from->u.u.type;
- cpswaps(from->u.u.sequenceNumber, to->u.u.sequenceNumber);
- cpswapl(from->u.visibility.window, to->u.visibility.window);
- to->u.visibility.state = from->u.visibility.state;
-}
-
-void
-SCreateNotifyEvent(xEvent *from, xEvent *to)
-{
- to->u.u.type = from->u.u.type;
- cpswaps(from->u.u.sequenceNumber, to->u.u.sequenceNumber);
- cpswapl(from->u.createNotify.window, to->u.createNotify.window);
- cpswapl(from->u.createNotify.parent, to->u.createNotify.parent);
- cpswaps(from->u.createNotify.x, to->u.createNotify.x);
- cpswaps(from->u.createNotify.y, to->u.createNotify.y);
- cpswaps(from->u.createNotify.width, to->u.createNotify.width);
- cpswaps(from->u.createNotify.height, to->u.createNotify.height);
- cpswaps(from->u.createNotify.borderWidth,
- to->u.createNotify.borderWidth);
- to->u.createNotify.override = from->u.createNotify.override;
-}
-
-void
-SDestroyNotifyEvent(xEvent *from, xEvent *to)
-{
- to->u.u.type = from->u.u.type;
- cpswaps(from->u.u.sequenceNumber, to->u.u.sequenceNumber);
- cpswapl(from->u.destroyNotify.event, to->u.destroyNotify.event);
- cpswapl(from->u.destroyNotify.window, to->u.destroyNotify.window);
-}
-
-void
-SUnmapNotifyEvent(xEvent *from, xEvent *to)
-{
- to->u.u.type = from->u.u.type;
- cpswaps(from->u.u.sequenceNumber, to->u.u.sequenceNumber);
- cpswapl(from->u.unmapNotify.event, to->u.unmapNotify.event);
- cpswapl(from->u.unmapNotify.window, to->u.unmapNotify.window);
- to->u.unmapNotify.fromConfigure = from->u.unmapNotify.fromConfigure;
-}
-
-void
-SMapNotifyEvent(xEvent *from, xEvent *to)
-{
- to->u.u.type = from->u.u.type;
- cpswaps(from->u.u.sequenceNumber, to->u.u.sequenceNumber);
- cpswapl(from->u.mapNotify.event, to->u.mapNotify.event);
- cpswapl(from->u.mapNotify.window, to->u.mapNotify.window);
- to->u.mapNotify.override = from->u.mapNotify.override;
-}
-
-void
-SMapRequestEvent(xEvent *from, xEvent *to)
-{
- to->u.u.type = from->u.u.type;
- cpswaps(from->u.u.sequenceNumber, to->u.u.sequenceNumber);
- cpswapl(from->u.mapRequest.parent, to->u.mapRequest.parent);
- cpswapl(from->u.mapRequest.window, to->u.mapRequest.window);
-}
-
-void
-SReparentEvent(xEvent *from, xEvent *to)
-{
- to->u.u.type = from->u.u.type;
- cpswaps(from->u.u.sequenceNumber, to->u.u.sequenceNumber);
- cpswapl(from->u.reparent.event, to->u.reparent.event);
- cpswapl(from->u.reparent.window, to->u.reparent.window);
- cpswapl(from->u.reparent.parent, to->u.reparent.parent);
- cpswaps(from->u.reparent.x, to->u.reparent.x);
- cpswaps(from->u.reparent.y, to->u.reparent.y);
- to->u.reparent.override = from->u.reparent.override;
-}
-
-void
-SConfigureNotifyEvent(xEvent *from, xEvent *to)
-{
- to->u.u.type = from->u.u.type;
- cpswaps(from->u.u.sequenceNumber, to->u.u.sequenceNumber);
- cpswapl(from->u.configureNotify.event,
- to->u.configureNotify.event);
- cpswapl(from->u.configureNotify.window,
- to->u.configureNotify.window);
- cpswapl(from->u.configureNotify.aboveSibling,
- to->u.configureNotify.aboveSibling);
- cpswaps(from->u.configureNotify.x, to->u.configureNotify.x);
- cpswaps(from->u.configureNotify.y, to->u.configureNotify.y);
- cpswaps(from->u.configureNotify.width, to->u.configureNotify.width);
- cpswaps(from->u.configureNotify.height,
- to->u.configureNotify.height);
- cpswaps(from->u.configureNotify.borderWidth,
- to->u.configureNotify.borderWidth);
- to->u.configureNotify.override = from->u.configureNotify.override;
-}
-
-void
-SConfigureRequestEvent(xEvent *from, xEvent *to)
-{
- to->u.u.type = from->u.u.type;
- to->u.u.detail = from->u.u.detail; /* actually stack-mode */
- cpswaps(from->u.u.sequenceNumber, to->u.u.sequenceNumber);
- cpswapl(from->u.configureRequest.parent,
- to->u.configureRequest.parent);
- cpswapl(from->u.configureRequest.window,
- to->u.configureRequest.window);
- cpswapl(from->u.configureRequest.sibling,
- to->u.configureRequest.sibling);
- cpswaps(from->u.configureRequest.x, to->u.configureRequest.x);
- cpswaps(from->u.configureRequest.y, to->u.configureRequest.y);
- cpswaps(from->u.configureRequest.width,
- to->u.configureRequest.width);
- cpswaps(from->u.configureRequest.height,
- to->u.configureRequest.height);
- cpswaps(from->u.configureRequest.borderWidth,
- to->u.configureRequest.borderWidth);
- cpswaps(from->u.configureRequest.valueMask,
- to->u.configureRequest.valueMask);
-}
-
-
-void
-SGravityEvent(xEvent *from, xEvent *to)
-{
- to->u.u.type = from->u.u.type;
- cpswaps(from->u.u.sequenceNumber, to->u.u.sequenceNumber);
- cpswapl(from->u.gravity.event, to->u.gravity.event);
- cpswapl(from->u.gravity.window, to->u.gravity.window);
- cpswaps(from->u.gravity.x, to->u.gravity.x);
- cpswaps(from->u.gravity.y, to->u.gravity.y);
-}
-
-void
-SResizeRequestEvent(xEvent *from, xEvent *to)
-{
- to->u.u.type = from->u.u.type;
- cpswaps(from->u.u.sequenceNumber, to->u.u.sequenceNumber);
- cpswapl(from->u.resizeRequest.window, to->u.resizeRequest.window);
- cpswaps(from->u.resizeRequest.width, to->u.resizeRequest.width);
- cpswaps(from->u.resizeRequest.height, to->u.resizeRequest.height);
-}
-
-void
-SCirculateEvent(xEvent *from, xEvent *to)
-{
- to->u.u.type = from->u.u.type;
- to->u.u.detail = from->u.u.detail;
- cpswaps(from->u.u.sequenceNumber, to->u.u.sequenceNumber);
- cpswapl(from->u.circulate.event, to->u.circulate.event);
- cpswapl(from->u.circulate.window, to->u.circulate.window);
- cpswapl(from->u.circulate.parent, to->u.circulate.parent);
- to->u.circulate.place = from->u.circulate.place;
-}
-
-void
-SPropertyEvent(xEvent *from, xEvent *to)
-{
- to->u.u.type = from->u.u.type;
- cpswaps(from->u.u.sequenceNumber, to->u.u.sequenceNumber);
- cpswapl(from->u.property.window, to->u.property.window);
- cpswapl(from->u.property.atom, to->u.property.atom);
- cpswapl(from->u.property.time, to->u.property.time);
- to->u.property.state = from->u.property.state;
-}
-
-void
-SSelectionClearEvent(xEvent *from, xEvent *to)
-{
- to->u.u.type = from->u.u.type;
- cpswaps(from->u.u.sequenceNumber, to->u.u.sequenceNumber);
- cpswapl(from->u.selectionClear.time, to->u.selectionClear.time);
- cpswapl(from->u.selectionClear.window, to->u.selectionClear.window);
- cpswapl(from->u.selectionClear.atom, to->u.selectionClear.atom);
-}
-
-void
-SSelectionRequestEvent(xEvent *from, xEvent *to)
-{
- to->u.u.type = from->u.u.type;
- cpswaps(from->u.u.sequenceNumber, to->u.u.sequenceNumber);
- cpswapl(from->u.selectionRequest.time, to->u.selectionRequest.time);
- cpswapl(from->u.selectionRequest.owner,
- to->u.selectionRequest.owner);
- cpswapl(from->u.selectionRequest.requestor,
- to->u.selectionRequest.requestor);
- cpswapl(from->u.selectionRequest.selection,
- to->u.selectionRequest.selection);
- cpswapl(from->u.selectionRequest.target,
- to->u.selectionRequest.target);
- cpswapl(from->u.selectionRequest.property,
- to->u.selectionRequest.property);
-}
-
-void
-SSelectionNotifyEvent(xEvent *from, xEvent *to)
-{
- to->u.u.type = from->u.u.type;
- cpswaps(from->u.u.sequenceNumber, to->u.u.sequenceNumber);
- cpswapl(from->u.selectionNotify.time, to->u.selectionNotify.time);
- cpswapl(from->u.selectionNotify.requestor,
- to->u.selectionNotify.requestor);
- cpswapl(from->u.selectionNotify.selection,
- to->u.selectionNotify.selection);
- cpswapl(from->u.selectionNotify.target,
- to->u.selectionNotify.target);
- cpswapl(from->u.selectionNotify.property,
- to->u.selectionNotify.property);
-}
-
-void
-SColormapEvent(xEvent *from, xEvent *to)
-{
- to->u.u.type = from->u.u.type;
- cpswaps(from->u.u.sequenceNumber, to->u.u.sequenceNumber);
- cpswapl(from->u.colormap.window, to->u.colormap.window);
- cpswapl(from->u.colormap.colormap, to->u.colormap.colormap);
- to->u.colormap.new = from->u.colormap.new;
- to->u.colormap.state = from->u.colormap.state;
-}
-
-void
-SMappingEvent(xEvent *from, xEvent *to)
-{
- to->u.u.type = from->u.u.type;
- cpswaps(from->u.u.sequenceNumber, to->u.u.sequenceNumber);
- to->u.mappingNotify.request = from->u.mappingNotify.request;
- to->u.mappingNotify.firstKeyCode =
- from->u.mappingNotify.firstKeyCode;
- to->u.mappingNotify.count = from->u.mappingNotify.count;
-}
-
-void
-SClientMessageEvent(xEvent *from, xEvent *to)
-{
- to->u.u.type = from->u.u.type;
- to->u.u.detail = from->u.u.detail; /* actually format */
- cpswaps(from->u.u.sequenceNumber, to->u.u.sequenceNumber);
- cpswapl(from->u.clientMessage.window, to->u.clientMessage.window);
- cpswapl(from->u.clientMessage.u.l.type,
- to->u.clientMessage.u.l.type);
- switch (from->u.u.detail) {
- case 8:
- memmove(to->u.clientMessage.u.b.bytes,
- from->u.clientMessage.u.b.bytes,20);
- break;
- case 16:
- cpswaps(from->u.clientMessage.u.s.shorts0,
- to->u.clientMessage.u.s.shorts0);
- cpswaps(from->u.clientMessage.u.s.shorts1,
- to->u.clientMessage.u.s.shorts1);
- cpswaps(from->u.clientMessage.u.s.shorts2,
- to->u.clientMessage.u.s.shorts2);
- cpswaps(from->u.clientMessage.u.s.shorts3,
- to->u.clientMessage.u.s.shorts3);
- cpswaps(from->u.clientMessage.u.s.shorts4,
- to->u.clientMessage.u.s.shorts4);
- cpswaps(from->u.clientMessage.u.s.shorts5,
- to->u.clientMessage.u.s.shorts5);
- cpswaps(from->u.clientMessage.u.s.shorts6,
- to->u.clientMessage.u.s.shorts6);
- cpswaps(from->u.clientMessage.u.s.shorts7,
- to->u.clientMessage.u.s.shorts7);
- cpswaps(from->u.clientMessage.u.s.shorts8,
- to->u.clientMessage.u.s.shorts8);
- cpswaps(from->u.clientMessage.u.s.shorts9,
- to->u.clientMessage.u.s.shorts9);
- break;
- case 32:
- cpswapl(from->u.clientMessage.u.l.longs0,
- to->u.clientMessage.u.l.longs0);
- cpswapl(from->u.clientMessage.u.l.longs1,
- to->u.clientMessage.u.l.longs1);
- cpswapl(from->u.clientMessage.u.l.longs2,
- to->u.clientMessage.u.l.longs2);
- cpswapl(from->u.clientMessage.u.l.longs3,
- to->u.clientMessage.u.l.longs3);
- cpswapl(from->u.clientMessage.u.l.longs4,
- to->u.clientMessage.u.l.longs4);
- break;
- }
-}
-
-void
-SKeymapNotifyEvent(xEvent *from, xEvent *to)
-{
- /* Keymap notify events are special; they have no
- sequence number field, and contain entirely 8-bit data */
- *to = *from;
-}
-
-static void
-SwapConnSetup(xConnSetup *pConnSetup, xConnSetup *pConnSetupT)
-{
- cpswapl(pConnSetup->release, pConnSetupT->release);
- cpswapl(pConnSetup->ridBase, pConnSetupT->ridBase);
- cpswapl(pConnSetup->ridMask, pConnSetupT->ridMask);
- cpswapl(pConnSetup->motionBufferSize, pConnSetupT->motionBufferSize);
- cpswaps(pConnSetup->nbytesVendor, pConnSetupT->nbytesVendor);
- cpswaps(pConnSetup->maxRequestSize, pConnSetupT->maxRequestSize);
- pConnSetupT->minKeyCode = pConnSetup->minKeyCode;
- pConnSetupT->maxKeyCode = pConnSetup->maxKeyCode;
- pConnSetupT->numRoots = pConnSetup->numRoots;
- pConnSetupT->numFormats = pConnSetup->numFormats;
- pConnSetupT->imageByteOrder = pConnSetup->imageByteOrder;
- pConnSetupT->bitmapBitOrder = pConnSetup->bitmapBitOrder;
- pConnSetupT->bitmapScanlineUnit = pConnSetup->bitmapScanlineUnit;
- pConnSetupT->bitmapScanlinePad = pConnSetup->bitmapScanlinePad;
-}
-
-static void
-SwapWinRoot(xWindowRoot *pRoot, xWindowRoot *pRootT)
-{
- cpswapl(pRoot->windowId, pRootT->windowId);
- cpswapl(pRoot->defaultColormap, pRootT->defaultColormap);
- cpswapl(pRoot->whitePixel, pRootT->whitePixel);
- cpswapl(pRoot->blackPixel, pRootT->blackPixel);
- cpswapl(pRoot->currentInputMask, pRootT->currentInputMask);
- cpswaps(pRoot->pixWidth, pRootT->pixWidth);
- cpswaps(pRoot->pixHeight, pRootT->pixHeight);
- cpswaps(pRoot->mmWidth, pRootT->mmWidth);
- cpswaps(pRoot->mmHeight, pRootT->mmHeight);
- cpswaps(pRoot->minInstalledMaps, pRootT->minInstalledMaps);
- cpswaps(pRoot->maxInstalledMaps, pRootT->maxInstalledMaps);
- cpswapl(pRoot->rootVisualID, pRootT->rootVisualID);
- pRootT->backingStore = pRoot->backingStore;
- pRootT->saveUnders = pRoot->saveUnders;
- pRootT->rootDepth = pRoot->rootDepth;
- pRootT->nDepths = pRoot->nDepths;
-}
-
-static void
-SwapVisual(xVisualType *pVis, xVisualType *pVisT)
-{
- cpswapl(pVis->visualID, pVisT->visualID);
- pVisT->class = pVis->class;
- pVisT->bitsPerRGB = pVis->bitsPerRGB;
- cpswaps(pVis->colormapEntries, pVisT->colormapEntries);
- cpswapl(pVis->redMask, pVisT->redMask);
- cpswapl(pVis->greenMask, pVisT->greenMask);
- cpswapl(pVis->blueMask, pVisT->blueMask);
-}
-
-void
-SwapConnSetupInfo(
- char *pInfo,
- char *pInfoT
-)
-{
- int i, j, k;
- xConnSetup *pConnSetup = (xConnSetup *)pInfo;
- xDepth *depth;
- xWindowRoot *root;
-
- SwapConnSetup(pConnSetup, (xConnSetup *)pInfoT);
- pInfo += sizeof(xConnSetup);
- pInfoT += sizeof(xConnSetup);
-
- /* Copy the vendor string */
- i = pad_to_int32(pConnSetup->nbytesVendor);
- memcpy(pInfoT, pInfo, i);
- pInfo += i;
- pInfoT += i;
-
- /* The Pixmap formats don't need to be swapped, just copied. */
- i = sizeof(xPixmapFormat) * pConnSetup->numFormats;
- memcpy(pInfoT, pInfo, i);
- pInfo += i;
- pInfoT += i;
-
- for(i = 0; i < pConnSetup->numRoots; i++)
- {
- root = (xWindowRoot*)pInfo;
- SwapWinRoot(root, (xWindowRoot *)pInfoT);
- pInfo += sizeof(xWindowRoot);
- pInfoT += sizeof(xWindowRoot);
-
- for(j = 0; j < root->nDepths; j++)
- {
- depth = (xDepth*)pInfo;
- ((xDepth *)pInfoT)->depth = depth->depth;
- cpswaps(depth->nVisuals, ((xDepth *)pInfoT)->nVisuals);
- pInfo += sizeof(xDepth);
- pInfoT += sizeof(xDepth);
- for(k = 0; k < depth->nVisuals; k++)
- {
- SwapVisual((xVisualType *)pInfo, (xVisualType *)pInfoT);
- pInfo += sizeof(xVisualType);
- pInfoT += sizeof(xVisualType);
- }
- }
- }
-}
-
-void
-WriteSConnectionInfo(ClientPtr pClient, unsigned long size, char *pInfo)
-{
- char *pInfoTBase;
-
- pInfoTBase = malloc(size);
- if (!pInfoTBase)
- {
- pClient->noClientException = -1;
- return;
- }
- SwapConnSetupInfo(pInfo, pInfoTBase);
- (void)WriteToClient(pClient, (int)size, (char *) pInfoTBase);
- free(pInfoTBase);
-}
-
-void
-SwapConnSetupPrefix(xConnSetupPrefix *pcspFrom, xConnSetupPrefix *pcspTo)
-{
- pcspTo->success = pcspFrom->success;
- pcspTo->lengthReason = pcspFrom->lengthReason;
- cpswaps(pcspFrom->majorVersion, pcspTo->majorVersion);
- cpswaps(pcspFrom->minorVersion, pcspTo->minorVersion);
- cpswaps(pcspFrom->length, pcspTo->length);
-}
-
-void
-WriteSConnSetupPrefix(ClientPtr pClient, xConnSetupPrefix *pcsp)
-{
- xConnSetupPrefix cspT;
-
- SwapConnSetupPrefix(pcsp, &cspT);
- (void)WriteToClient(pClient, sizeof(cspT), (char *) &cspT);
-}
-
-/*
- * Dummy entry for ReplySwapVector[]
- */
-
-void
-ReplyNotSwappd(
- ClientPtr pClient ,
- int size ,
- void * pbuf
- )
-{
- FatalError("Not implemented");
-}
-
+/************************************************************
+
+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.
+
+********************************************************/
+
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h>
+#include <X11/Xproto.h>
+#include "misc.h"
+#include "dixstruct.h"
+#include <X11/fonts/fontstruct.h>
+#include "scrnintstr.h"
+#include "swaprep.h"
+#include "globals.h"
+
+static void SwapFontInfo(xQueryFontReply *pr);
+
+static void SwapCharInfo(xCharInfo *pInfo);
+
+static void SwapFont(xQueryFontReply *pr, Bool hasGlyphs);
+
+/**
+ * Thanks to Jack Palevich for testing and subsequently rewriting all this
+ *
+ * \param size size in bytes
+ */
+void
+Swap32Write(ClientPtr pClient, int size, CARD32 *pbuf)
+{
+ int i;
+
+ size >>= 2;
+ for(i = 0; i < size; i++)
+ /* brackets are mandatory here, because "swapl" macro expands
+ to several statements */
+ {
+ swapl(&pbuf[i]);
+ }
+ (void)WriteToClient(pClient, size << 2, (char *) pbuf);
+}
+
+/**
+ *
+ * \param size size in bytes
+ */
+void
+CopySwap32Write(ClientPtr pClient, int size, CARD32 *pbuf)
+{
+ int bufsize = size;
+ CARD32 *pbufT;
+ CARD32 *from, *to, *fromLast, *toLast;
+ CARD32 tmpbuf[1];
+
+ /* Allocate as big a buffer as we can... */
+ while (!(pbufT = malloc(bufsize)))
+ {
+ bufsize >>= 1;
+ if (bufsize == 4)
+ {
+ pbufT = tmpbuf;
+ break;
+ }
+ }
+
+ /* convert lengths from # of bytes to # of longs */
+ size >>= 2;
+ bufsize >>= 2;
+
+ from = pbuf;
+ fromLast = from + size;
+ while (from < fromLast) {
+ int nbytes;
+ to = pbufT;
+ toLast = to + min (bufsize, fromLast - from);
+ nbytes = (toLast - to) << 2;
+ while (to < toLast) {
+ /* can't write "cpswapl(*from++, *to++)" because cpswapl is a macro
+ that evaulates its args more than once */
+ cpswapl(*from, *to);
+ from++;
+ to++;
+ }
+ (void)WriteToClient (pClient, nbytes, (char *) pbufT);
+ }
+
+ if (pbufT != tmpbuf)
+ free(pbufT);
+}
+
+/**
+ *
+ * \param size size in bytes
+ */
+void
+CopySwap16Write(ClientPtr pClient, int size, short *pbuf)
+{
+ int bufsize = size;
+ short *pbufT;
+ short *from, *to, *fromLast, *toLast;
+ short tmpbuf[2];
+
+ /* Allocate as big a buffer as we can... */
+ while (!(pbufT = malloc(bufsize)))
+ {
+ bufsize >>= 1;
+ if (bufsize == 4)
+ {
+ pbufT = tmpbuf;
+ break;
+ }
+ }
+
+ /* convert lengths from # of bytes to # of shorts */
+ size >>= 1;
+ bufsize >>= 1;
+
+ from = pbuf;
+ fromLast = from + size;
+ while (from < fromLast) {
+ int nbytes;
+ to = pbufT;
+ toLast = to + min (bufsize, fromLast - from);
+ nbytes = (toLast - to) << 1;
+ while (to < toLast) {
+ /* can't write "cpswaps(*from++, *to++)" because cpswaps is a macro
+ that evaulates its args more than once */
+ cpswaps(*from, *to);
+ from++;
+ to++;
+ }
+ (void)WriteToClient (pClient, nbytes, (char *) pbufT);
+ }
+
+ if (pbufT != tmpbuf)
+ free(pbufT);
+}
+
+
+/* Extra-small reply */
+void
+SGenericReply(ClientPtr pClient, int size, xGenericReply *pRep)
+{
+ swaps(&pRep->sequenceNumber);
+ (void)WriteToClient(pClient, size, (char *) pRep);
+}
+
+/* Extra-large reply */
+void
+SGetWindowAttributesReply(ClientPtr pClient, int size,
+ xGetWindowAttributesReply *pRep)
+{
+ swaps(&pRep->sequenceNumber);
+ swapl(&pRep->length);
+ swapl(&pRep->visualID);
+ swaps(&pRep->class);
+ swapl(&pRep->backingBitPlanes);
+ swapl(&pRep->backingPixel);
+ swapl(&pRep->colormap);
+ swapl(&pRep->allEventMasks);
+ swapl(&pRep->yourEventMask);
+ swaps(&pRep->doNotPropagateMask);
+ (void)WriteToClient(pClient, size, (char *) pRep);
+}
+
+void
+SGetGeometryReply(ClientPtr pClient, int size, xGetGeometryReply *pRep)
+{
+ swaps(&pRep->sequenceNumber);
+ swapl(&pRep->root);
+ swaps(&pRep->x);
+ swaps(&pRep->y);
+ swaps(&pRep->width);
+ swaps(&pRep->height);
+ swaps(&pRep->borderWidth);
+ (void)WriteToClient(pClient, size, (char *) pRep);
+}
+
+void
+SQueryTreeReply(ClientPtr pClient, int size, xQueryTreeReply *pRep)
+{
+ swaps(&pRep->sequenceNumber);
+ swapl(&pRep->length);
+ swapl(&pRep->root);
+ swapl(&pRep->parent);
+ swaps(&pRep->nChildren);
+ (void)WriteToClient(pClient, size, (char *) pRep);
+}
+
+void
+SInternAtomReply(ClientPtr pClient, int size, xInternAtomReply *pRep)
+{
+ swaps(&pRep->sequenceNumber);
+ swapl(&pRep->atom);
+ (void)WriteToClient(pClient, size, (char *) pRep);
+}
+
+void
+SGetAtomNameReply(ClientPtr pClient, int size, xGetAtomNameReply *pRep)
+{
+ swaps(&pRep->sequenceNumber);
+ swapl(&pRep->length);
+ swaps(&pRep->nameLength);
+ (void)WriteToClient(pClient, size, (char *) pRep);
+}
+
+
+void
+SGetPropertyReply(ClientPtr pClient, int size, xGetPropertyReply *pRep)
+{
+ swaps(&pRep->sequenceNumber);
+ swapl(&pRep->length);
+ swapl(&pRep->propertyType);
+ swapl(&pRep->bytesAfter);
+ swapl(&pRep->nItems);
+ (void)WriteToClient(pClient, size, (char *) pRep);
+}
+
+void
+SListPropertiesReply(ClientPtr pClient, int size, xListPropertiesReply *pRep)
+{
+ swaps(&pRep->sequenceNumber);
+ swapl(&pRep->length);
+ swaps(&pRep->nProperties);
+ (void)WriteToClient(pClient, size, (char *) pRep);
+}
+
+void
+SGetSelectionOwnerReply(ClientPtr pClient, int size,
+ xGetSelectionOwnerReply *pRep)
+{
+ swaps(&pRep->sequenceNumber);
+ swapl(&pRep->owner);
+ (void)WriteToClient(pClient, size, (char *) pRep);
+}
+
+
+void
+SQueryPointerReply(ClientPtr pClient, int size, xQueryPointerReply *pRep)
+{
+ swaps(&pRep->sequenceNumber);
+ swapl(&pRep->root);
+ swapl(&pRep->child);
+ swaps(&pRep->rootX);
+ swaps(&pRep->rootY);
+ swaps(&pRep->winX);
+ swaps(&pRep->winY);
+ swaps(&pRep->mask);
+ (void)WriteToClient(pClient, size, (char *) pRep);
+}
+
+static void
+SwapTimecoord(xTimecoord* pCoord)
+{
+ swapl(&pCoord->time);
+ swaps(&pCoord->x);
+ swaps(&pCoord->y);
+}
+
+void
+SwapTimeCoordWrite(ClientPtr pClient, int size, xTimecoord *pRep)
+{
+ int i, n;
+ xTimecoord *pRepT;
+
+ n = size / sizeof(xTimecoord);
+ pRepT = pRep;
+ for(i = 0; i < n; i++)
+ {
+ SwapTimecoord(pRepT);
+ pRepT++;
+ }
+ (void)WriteToClient(pClient, size, (char *) pRep);
+
+}
+void
+SGetMotionEventsReply(ClientPtr pClient, int size, xGetMotionEventsReply *pRep)
+{
+ swaps(&pRep->sequenceNumber);
+ swapl(&pRep->length);
+ swapl(&pRep->nEvents);
+ (void)WriteToClient(pClient, size, (char *) pRep);
+}
+
+void
+STranslateCoordsReply(ClientPtr pClient, int size, xTranslateCoordsReply *pRep)
+{
+ swaps(&pRep->sequenceNumber);
+ swapl(&pRep->child);
+ swaps(&pRep->dstX);
+ swaps(&pRep->dstY);
+ (void)WriteToClient(pClient, size, (char *) pRep);
+}
+
+void
+SGetInputFocusReply(ClientPtr pClient, int size, xGetInputFocusReply *pRep)
+{
+ swaps(&pRep->sequenceNumber);
+ swapl(&pRep->focus);
+ (void)WriteToClient(pClient, size, (char *) pRep);
+}
+
+/* extra long reply */
+void
+SQueryKeymapReply(ClientPtr pClient, int size, xQueryKeymapReply *pRep)
+{
+ swaps(&pRep->sequenceNumber);
+ swapl(&pRep->length);
+ (void)WriteToClient(pClient, size, (char *) pRep);
+}
+
+static void
+SwapCharInfo(xCharInfo *pInfo)
+{
+ swaps(&pInfo->leftSideBearing);
+ swaps(&pInfo->rightSideBearing);
+ swaps(&pInfo->characterWidth);
+ swaps(&pInfo->ascent);
+ swaps(&pInfo->descent);
+ swaps(&pInfo->attributes);
+}
+
+static void
+SwapFontInfo(xQueryFontReply *pr)
+{
+ swaps(&pr->minCharOrByte2);
+ swaps(&pr->maxCharOrByte2);
+ swaps(&pr->defaultChar);
+ swaps(&pr->nFontProps);
+ swaps(&pr->fontAscent);
+ swaps(&pr->fontDescent);
+ SwapCharInfo( &pr->minBounds);
+ SwapCharInfo( &pr->maxBounds);
+ swapl(&pr->nCharInfos);
+}
+
+static void
+SwapFont(xQueryFontReply *pr, Bool hasGlyphs)
+{
+ unsigned i;
+ xCharInfo * pxci;
+ unsigned nchars, nprops;
+ char *pby;
+
+ swaps(&pr->sequenceNumber);
+ swapl(&pr->length);
+ nchars = pr->nCharInfos;
+ nprops = pr->nFontProps;
+ SwapFontInfo(pr);
+ pby = (char *) &pr[1];
+ /* Font properties are an atom and either an int32 or a CARD32, so
+ * they are always 2 4 byte values */
+ for(i = 0; i < nprops; i++)
+ {
+ swapl((int *)pby);
+ pby += 4;
+ swapl((int *)pby);
+ pby += 4;
+ }
+ if (hasGlyphs)
+ {
+ pxci = (xCharInfo *)pby;
+ for(i = 0; i< nchars; i++, pxci++)
+ SwapCharInfo(pxci);
+ }
+}
+
+void
+SQueryFontReply(ClientPtr pClient, int size, xQueryFontReply *pRep)
+{
+ SwapFont(pRep, TRUE);
+ (void)WriteToClient(pClient, size, (char *) pRep);
+}
+
+void
+SQueryTextExtentsReply(ClientPtr pClient, int size, xQueryTextExtentsReply *pRep)
+{
+ swaps(&pRep->sequenceNumber);
+ swaps(&pRep->fontAscent);
+ swaps(&pRep->fontDescent);
+ swaps(&pRep->overallAscent);
+ swaps(&pRep->overallDescent);
+ swapl(&pRep->overallWidth);
+ swapl(&pRep->overallLeft);
+ swapl(&pRep->overallRight);
+ (void)WriteToClient(pClient, size, (char *) pRep);
+}
+
+void
+SListFontsReply(ClientPtr pClient, int size, xListFontsReply *pRep)
+{
+ swaps(&pRep->sequenceNumber);
+ swapl(&pRep->length);
+ swaps(&pRep->nFonts);
+ (void)WriteToClient(pClient, size, (char *) pRep);
+}
+
+void
+SListFontsWithInfoReply(ClientPtr pClient, int size,
+ xListFontsWithInfoReply *pRep)
+{
+ SwapFont((xQueryFontReply *)pRep, FALSE);
+ (void)WriteToClient(pClient, size, (char *) pRep);
+}
+
+void
+SGetFontPathReply(ClientPtr pClient, int size, xGetFontPathReply *pRep)
+{
+ swaps(&pRep->sequenceNumber);
+ swapl(&pRep->length);
+ swaps(&pRep->nPaths);
+ (void)WriteToClient(pClient, size, (char *) pRep);
+}
+
+void
+SGetImageReply(ClientPtr pClient, int size, xGetImageReply *pRep)
+{
+ swaps(&pRep->sequenceNumber);
+ swapl(&pRep->length);
+ swapl(&pRep->visual);
+ (void)WriteToClient(pClient, size, (char *) pRep);
+ /* Fortunately, image doesn't need swapping */
+}
+
+void
+SListInstalledColormapsReply(ClientPtr pClient, int size,
+ xListInstalledColormapsReply *pRep)
+{
+ swaps(&pRep->sequenceNumber);
+ swapl(&pRep->length);
+ swaps(&pRep->nColormaps);
+ (void)WriteToClient(pClient, size, (char *) pRep);
+}
+
+void
+SAllocColorReply(ClientPtr pClient, int size, xAllocColorReply *pRep)
+{
+ swaps(&pRep->sequenceNumber);
+ swaps(&pRep->red);
+ swaps(&pRep->green);
+ swaps(&pRep->blue);
+ swapl(&pRep->pixel);
+ (void)WriteToClient(pClient, size, (char *) pRep);
+}
+
+void
+SAllocNamedColorReply(ClientPtr pClient, int size, xAllocNamedColorReply *pRep)
+{
+ swaps(&pRep->sequenceNumber);
+ swapl(&pRep->pixel);
+ swaps(&pRep->exactRed);
+ swaps(&pRep->exactGreen);
+ swaps(&pRep->exactBlue);
+ swaps(&pRep->screenRed);
+ swaps(&pRep->screenGreen);
+ swaps(&pRep->screenBlue);
+ (void)WriteToClient(pClient, size, (char *) pRep);
+}
+
+void
+SAllocColorCellsReply(ClientPtr pClient, int size, xAllocColorCellsReply *pRep)
+{
+ swaps(&pRep->sequenceNumber);
+ swapl(&pRep->length);
+ swaps(&pRep->nPixels);
+ swaps(&pRep->nMasks);
+ (void)WriteToClient(pClient, size, (char *) pRep);
+}
+
+
+void
+SAllocColorPlanesReply(ClientPtr pClient, int size, xAllocColorPlanesReply *pRep)
+{
+ swaps(&pRep->sequenceNumber);
+ swapl(&pRep->length);
+ swaps(&pRep->nPixels);
+ swapl(&pRep->redMask);
+ swapl(&pRep->greenMask);
+ swapl(&pRep->blueMask);
+ (void)WriteToClient(pClient, size, (char *) pRep);
+}
+
+static void
+SwapRGB(xrgb *prgb)
+{
+ swaps(&prgb->red);
+ swaps(&prgb->green);
+ swaps(&prgb->blue);
+}
+
+void
+SQColorsExtend(ClientPtr pClient, int size, xrgb *prgb)
+{
+ int i, n;
+ xrgb *prgbT;
+
+ n = size / sizeof(xrgb);
+ prgbT = prgb;
+ for(i = 0; i < n; i++)
+ {
+ SwapRGB(prgbT);
+ prgbT++;
+ }
+ (void)WriteToClient(pClient, size, (char *) prgb);
+}
+
+void
+SQueryColorsReply(ClientPtr pClient, int size, xQueryColorsReply* pRep)
+{
+ swaps(&pRep->sequenceNumber);
+ swapl(&pRep->length);
+ swaps(&pRep->nColors);
+ (void)WriteToClient(pClient, size, (char *) pRep);
+}
+
+void
+SLookupColorReply(ClientPtr pClient, int size, xLookupColorReply *pRep)
+{
+ swaps(&pRep->sequenceNumber);
+ swaps(&pRep->exactRed);
+ swaps(&pRep->exactGreen);
+ swaps(&pRep->exactBlue);
+ swaps(&pRep->screenRed);
+ swaps(&pRep->screenGreen);
+ swaps(&pRep->screenBlue);
+ (void)WriteToClient(pClient, size, (char *) pRep);
+}
+
+void
+SQueryBestSizeReply(ClientPtr pClient, int size, xQueryBestSizeReply *pRep)
+{
+ swaps(&pRep->sequenceNumber);
+ swaps(&pRep->width);
+ swaps(&pRep->height);
+ (void)WriteToClient(pClient, size, (char *) pRep);
+}
+
+void
+SListExtensionsReply(ClientPtr pClient, int size, xListExtensionsReply *pRep)
+{
+ swaps(&pRep->sequenceNumber);
+ swapl(&pRep->length);
+ (void)WriteToClient(pClient, size, (char *) pRep);
+}
+
+void
+SGetKeyboardMappingReply(ClientPtr pClient, int size,
+ xGetKeyboardMappingReply *pRep)
+{
+ swaps(&pRep->sequenceNumber);
+ swapl(&pRep->length);
+ (void)WriteToClient(pClient, size, (char *) pRep);
+}
+
+void
+SGetPointerMappingReply(ClientPtr pClient, int size,
+ xGetPointerMappingReply *pRep)
+{
+ swaps(&pRep->sequenceNumber);
+ swapl(&pRep->length);
+ (void)WriteToClient(pClient, size, (char *) pRep);
+}
+
+void
+SGetModifierMappingReply(ClientPtr pClient, int size,
+ xGetModifierMappingReply *pRep)
+{
+ swaps(&pRep->sequenceNumber);
+ swapl(&pRep->length);
+ (void)WriteToClient(pClient, size, (char *) pRep);
+}
+
+void
+SGetKeyboardControlReply(ClientPtr pClient, int size, xGetKeyboardControlReply *pRep)
+{
+ swaps(&pRep->sequenceNumber);
+ swapl(&pRep->length);
+ swapl(&pRep->ledMask);
+ swaps(&pRep->bellPitch);
+ swaps(&pRep->bellDuration);
+ (void)WriteToClient(pClient, size, (char *) pRep);
+}
+
+void
+SGetPointerControlReply(ClientPtr pClient, int size, xGetPointerControlReply *pRep)
+{
+ swaps(&pRep->sequenceNumber);
+ swaps(&pRep->accelNumerator);
+ swaps(&pRep->accelDenominator);
+ swaps(&pRep->threshold);
+ (void)WriteToClient(pClient, size, (char *) pRep);
+}
+
+void
+SGetScreenSaverReply(ClientPtr pClient, int size, xGetScreenSaverReply *pRep)
+{
+ swaps(&pRep->sequenceNumber);
+ swaps(&pRep->timeout);
+ swaps(&pRep->interval);
+ (void)WriteToClient(pClient, size, (char *) pRep);
+}
+
+void
+SLHostsExtend(ClientPtr pClient, int size, char *buf)
+{
+ char *bufT = buf;
+ char *endbuf = buf + size;
+ while (bufT < endbuf) {
+ xHostEntry *host = (xHostEntry *) bufT;
+ int len = host->length;
+ swaps(&host->length);
+ bufT += sizeof (xHostEntry) + pad_to_int32(len);
+ }
+ (void)WriteToClient (pClient, size, buf);
+}
+
+void
+SListHostsReply(ClientPtr pClient, int size, xListHostsReply *pRep)
+{
+ swaps(&pRep->sequenceNumber);
+ swapl(&pRep->length);
+ swaps(&pRep->nHosts);
+ (void)WriteToClient(pClient, size, (char *) pRep);
+}
+
+
+
+void
+SErrorEvent(xError *from, xError *to)
+{
+ to->type = X_Error;
+ to->errorCode = from->errorCode;
+ cpswaps(from->sequenceNumber, to->sequenceNumber);
+ cpswapl(from->resourceID, to->resourceID);
+ cpswaps(from->minorCode, to->minorCode);
+ to->majorCode = from->majorCode;
+}
+
+void
+SKeyButtonPtrEvent(xEvent *from, xEvent *to)
+{
+ to->u.u.type = from->u.u.type;
+ to->u.u.detail = from->u.u.detail;
+ cpswaps(from->u.u.sequenceNumber, to->u.u.sequenceNumber);
+ cpswapl(from->u.keyButtonPointer.time,
+ to->u.keyButtonPointer.time);
+ cpswapl(from->u.keyButtonPointer.root,
+ to->u.keyButtonPointer.root);
+ cpswapl(from->u.keyButtonPointer.event,
+ to->u.keyButtonPointer.event);
+ cpswapl(from->u.keyButtonPointer.child,
+ to->u.keyButtonPointer.child);
+ cpswaps(from->u.keyButtonPointer.rootX,
+ to->u.keyButtonPointer.rootX);
+ cpswaps(from->u.keyButtonPointer.rootY,
+ to->u.keyButtonPointer.rootY);
+ cpswaps(from->u.keyButtonPointer.eventX,
+ to->u.keyButtonPointer.eventX);
+ cpswaps(from->u.keyButtonPointer.eventY,
+ to->u.keyButtonPointer.eventY);
+ cpswaps(from->u.keyButtonPointer.state,
+ to->u.keyButtonPointer.state);
+ to->u.keyButtonPointer.sameScreen =
+ from->u.keyButtonPointer.sameScreen;
+}
+
+void
+SEnterLeaveEvent(xEvent *from, xEvent *to)
+{
+ to->u.u.type = from->u.u.type;
+ to->u.u.detail = from->u.u.detail;
+ cpswaps(from->u.u.sequenceNumber, to->u.u.sequenceNumber);
+ cpswapl(from->u.enterLeave.time, to->u.enterLeave.time);
+ cpswapl(from->u.enterLeave.root, to->u.enterLeave.root);
+ cpswapl(from->u.enterLeave.event, to->u.enterLeave.event);
+ cpswapl(from->u.enterLeave.child, to->u.enterLeave.child);
+ cpswaps(from->u.enterLeave.rootX, to->u.enterLeave.rootX);
+ cpswaps(from->u.enterLeave.rootY, to->u.enterLeave.rootY);
+ cpswaps(from->u.enterLeave.eventX, to->u.enterLeave.eventX);
+ cpswaps(from->u.enterLeave.eventY, to->u.enterLeave.eventY);
+ cpswaps(from->u.enterLeave.state, to->u.enterLeave.state);
+ to->u.enterLeave.mode = from->u.enterLeave.mode;
+ to->u.enterLeave.flags = from->u.enterLeave.flags;
+}
+
+void
+SFocusEvent(xEvent *from, xEvent *to)
+{
+ to->u.u.type = from->u.u.type;
+ to->u.u.detail = from->u.u.detail;
+ cpswaps(from->u.u.sequenceNumber, to->u.u.sequenceNumber);
+ cpswapl(from->u.focus.window, to->u.focus.window);
+ to->u.focus.mode = from->u.focus.mode;
+}
+
+void
+SExposeEvent(xEvent *from, xEvent *to)
+{
+ to->u.u.type = from->u.u.type;
+ cpswaps(from->u.u.sequenceNumber, to->u.u.sequenceNumber);
+ cpswapl(from->u.expose.window, to->u.expose.window);
+ cpswaps(from->u.expose.x, to->u.expose.x);
+ cpswaps(from->u.expose.y, to->u.expose.y);
+ cpswaps(from->u.expose.width, to->u.expose.width);
+ cpswaps(from->u.expose.height, to->u.expose.height);
+ cpswaps(from->u.expose.count, to->u.expose.count);
+}
+
+void
+SGraphicsExposureEvent(xEvent *from, xEvent *to)
+{
+ to->u.u.type = from->u.u.type;
+ cpswaps(from->u.u.sequenceNumber, to->u.u.sequenceNumber);
+ cpswapl(from->u.graphicsExposure.drawable,
+ to->u.graphicsExposure.drawable);
+ cpswaps(from->u.graphicsExposure.x,
+ to->u.graphicsExposure.x);
+ cpswaps(from->u.graphicsExposure.y,
+ to->u.graphicsExposure.y);
+ cpswaps(from->u.graphicsExposure.width,
+ to->u.graphicsExposure.width);
+ cpswaps(from->u.graphicsExposure.height,
+ to->u.graphicsExposure.height);
+ cpswaps(from->u.graphicsExposure.minorEvent,
+ to->u.graphicsExposure.minorEvent);
+ cpswaps(from->u.graphicsExposure.count,
+ to->u.graphicsExposure.count);
+ to->u.graphicsExposure.majorEvent =
+ from->u.graphicsExposure.majorEvent;
+}
+
+void
+SNoExposureEvent(xEvent *from, xEvent *to)
+{
+ to->u.u.type = from->u.u.type;
+ cpswaps(from->u.u.sequenceNumber, to->u.u.sequenceNumber);
+ cpswapl(from->u.noExposure.drawable, to->u.noExposure.drawable);
+ cpswaps(from->u.noExposure.minorEvent, to->u.noExposure.minorEvent);
+ to->u.noExposure.majorEvent = from->u.noExposure.majorEvent;
+}
+
+void
+SVisibilityEvent(xEvent *from, xEvent *to)
+{
+ to->u.u.type = from->u.u.type;
+ cpswaps(from->u.u.sequenceNumber, to->u.u.sequenceNumber);
+ cpswapl(from->u.visibility.window, to->u.visibility.window);
+ to->u.visibility.state = from->u.visibility.state;
+}
+
+void
+SCreateNotifyEvent(xEvent *from, xEvent *to)
+{
+ to->u.u.type = from->u.u.type;
+ cpswaps(from->u.u.sequenceNumber, to->u.u.sequenceNumber);
+ cpswapl(from->u.createNotify.window, to->u.createNotify.window);
+ cpswapl(from->u.createNotify.parent, to->u.createNotify.parent);
+ cpswaps(from->u.createNotify.x, to->u.createNotify.x);
+ cpswaps(from->u.createNotify.y, to->u.createNotify.y);
+ cpswaps(from->u.createNotify.width, to->u.createNotify.width);
+ cpswaps(from->u.createNotify.height, to->u.createNotify.height);
+ cpswaps(from->u.createNotify.borderWidth,
+ to->u.createNotify.borderWidth);
+ to->u.createNotify.override = from->u.createNotify.override;
+}
+
+void
+SDestroyNotifyEvent(xEvent *from, xEvent *to)
+{
+ to->u.u.type = from->u.u.type;
+ cpswaps(from->u.u.sequenceNumber, to->u.u.sequenceNumber);
+ cpswapl(from->u.destroyNotify.event, to->u.destroyNotify.event);
+ cpswapl(from->u.destroyNotify.window, to->u.destroyNotify.window);
+}
+
+void
+SUnmapNotifyEvent(xEvent *from, xEvent *to)
+{
+ to->u.u.type = from->u.u.type;
+ cpswaps(from->u.u.sequenceNumber, to->u.u.sequenceNumber);
+ cpswapl(from->u.unmapNotify.event, to->u.unmapNotify.event);
+ cpswapl(from->u.unmapNotify.window, to->u.unmapNotify.window);
+ to->u.unmapNotify.fromConfigure = from->u.unmapNotify.fromConfigure;
+}
+
+void
+SMapNotifyEvent(xEvent *from, xEvent *to)
+{
+ to->u.u.type = from->u.u.type;
+ cpswaps(from->u.u.sequenceNumber, to->u.u.sequenceNumber);
+ cpswapl(from->u.mapNotify.event, to->u.mapNotify.event);
+ cpswapl(from->u.mapNotify.window, to->u.mapNotify.window);
+ to->u.mapNotify.override = from->u.mapNotify.override;
+}
+
+void
+SMapRequestEvent(xEvent *from, xEvent *to)
+{
+ to->u.u.type = from->u.u.type;
+ cpswaps(from->u.u.sequenceNumber, to->u.u.sequenceNumber);
+ cpswapl(from->u.mapRequest.parent, to->u.mapRequest.parent);
+ cpswapl(from->u.mapRequest.window, to->u.mapRequest.window);
+}
+
+void
+SReparentEvent(xEvent *from, xEvent *to)
+{
+ to->u.u.type = from->u.u.type;
+ cpswaps(from->u.u.sequenceNumber, to->u.u.sequenceNumber);
+ cpswapl(from->u.reparent.event, to->u.reparent.event);
+ cpswapl(from->u.reparent.window, to->u.reparent.window);
+ cpswapl(from->u.reparent.parent, to->u.reparent.parent);
+ cpswaps(from->u.reparent.x, to->u.reparent.x);
+ cpswaps(from->u.reparent.y, to->u.reparent.y);
+ to->u.reparent.override = from->u.reparent.override;
+}
+
+void
+SConfigureNotifyEvent(xEvent *from, xEvent *to)
+{
+ to->u.u.type = from->u.u.type;
+ cpswaps(from->u.u.sequenceNumber, to->u.u.sequenceNumber);
+ cpswapl(from->u.configureNotify.event,
+ to->u.configureNotify.event);
+ cpswapl(from->u.configureNotify.window,
+ to->u.configureNotify.window);
+ cpswapl(from->u.configureNotify.aboveSibling,
+ to->u.configureNotify.aboveSibling);
+ cpswaps(from->u.configureNotify.x, to->u.configureNotify.x);
+ cpswaps(from->u.configureNotify.y, to->u.configureNotify.y);
+ cpswaps(from->u.configureNotify.width, to->u.configureNotify.width);
+ cpswaps(from->u.configureNotify.height,
+ to->u.configureNotify.height);
+ cpswaps(from->u.configureNotify.borderWidth,
+ to->u.configureNotify.borderWidth);
+ to->u.configureNotify.override = from->u.configureNotify.override;
+}
+
+void
+SConfigureRequestEvent(xEvent *from, xEvent *to)
+{
+ to->u.u.type = from->u.u.type;
+ to->u.u.detail = from->u.u.detail; /* actually stack-mode */
+ cpswaps(from->u.u.sequenceNumber, to->u.u.sequenceNumber);
+ cpswapl(from->u.configureRequest.parent,
+ to->u.configureRequest.parent);
+ cpswapl(from->u.configureRequest.window,
+ to->u.configureRequest.window);
+ cpswapl(from->u.configureRequest.sibling,
+ to->u.configureRequest.sibling);
+ cpswaps(from->u.configureRequest.x, to->u.configureRequest.x);
+ cpswaps(from->u.configureRequest.y, to->u.configureRequest.y);
+ cpswaps(from->u.configureRequest.width,
+ to->u.configureRequest.width);
+ cpswaps(from->u.configureRequest.height,
+ to->u.configureRequest.height);
+ cpswaps(from->u.configureRequest.borderWidth,
+ to->u.configureRequest.borderWidth);
+ cpswaps(from->u.configureRequest.valueMask,
+ to->u.configureRequest.valueMask);
+}
+
+
+void
+SGravityEvent(xEvent *from, xEvent *to)
+{
+ to->u.u.type = from->u.u.type;
+ cpswaps(from->u.u.sequenceNumber, to->u.u.sequenceNumber);
+ cpswapl(from->u.gravity.event, to->u.gravity.event);
+ cpswapl(from->u.gravity.window, to->u.gravity.window);
+ cpswaps(from->u.gravity.x, to->u.gravity.x);
+ cpswaps(from->u.gravity.y, to->u.gravity.y);
+}
+
+void
+SResizeRequestEvent(xEvent *from, xEvent *to)
+{
+ to->u.u.type = from->u.u.type;
+ cpswaps(from->u.u.sequenceNumber, to->u.u.sequenceNumber);
+ cpswapl(from->u.resizeRequest.window, to->u.resizeRequest.window);
+ cpswaps(from->u.resizeRequest.width, to->u.resizeRequest.width);
+ cpswaps(from->u.resizeRequest.height, to->u.resizeRequest.height);
+}
+
+void
+SCirculateEvent(xEvent *from, xEvent *to)
+{
+ to->u.u.type = from->u.u.type;
+ to->u.u.detail = from->u.u.detail;
+ cpswaps(from->u.u.sequenceNumber, to->u.u.sequenceNumber);
+ cpswapl(from->u.circulate.event, to->u.circulate.event);
+ cpswapl(from->u.circulate.window, to->u.circulate.window);
+ cpswapl(from->u.circulate.parent, to->u.circulate.parent);
+ to->u.circulate.place = from->u.circulate.place;
+}
+
+void
+SPropertyEvent(xEvent *from, xEvent *to)
+{
+ to->u.u.type = from->u.u.type;
+ cpswaps(from->u.u.sequenceNumber, to->u.u.sequenceNumber);
+ cpswapl(from->u.property.window, to->u.property.window);
+ cpswapl(from->u.property.atom, to->u.property.atom);
+ cpswapl(from->u.property.time, to->u.property.time);
+ to->u.property.state = from->u.property.state;
+}
+
+void
+SSelectionClearEvent(xEvent *from, xEvent *to)
+{
+ to->u.u.type = from->u.u.type;
+ cpswaps(from->u.u.sequenceNumber, to->u.u.sequenceNumber);
+ cpswapl(from->u.selectionClear.time, to->u.selectionClear.time);
+ cpswapl(from->u.selectionClear.window, to->u.selectionClear.window);
+ cpswapl(from->u.selectionClear.atom, to->u.selectionClear.atom);
+}
+
+void
+SSelectionRequestEvent(xEvent *from, xEvent *to)
+{
+ to->u.u.type = from->u.u.type;
+ cpswaps(from->u.u.sequenceNumber, to->u.u.sequenceNumber);
+ cpswapl(from->u.selectionRequest.time, to->u.selectionRequest.time);
+ cpswapl(from->u.selectionRequest.owner,
+ to->u.selectionRequest.owner);
+ cpswapl(from->u.selectionRequest.requestor,
+ to->u.selectionRequest.requestor);
+ cpswapl(from->u.selectionRequest.selection,
+ to->u.selectionRequest.selection);
+ cpswapl(from->u.selectionRequest.target,
+ to->u.selectionRequest.target);
+ cpswapl(from->u.selectionRequest.property,
+ to->u.selectionRequest.property);
+}
+
+void
+SSelectionNotifyEvent(xEvent *from, xEvent *to)
+{
+ to->u.u.type = from->u.u.type;
+ cpswaps(from->u.u.sequenceNumber, to->u.u.sequenceNumber);
+ cpswapl(from->u.selectionNotify.time, to->u.selectionNotify.time);
+ cpswapl(from->u.selectionNotify.requestor,
+ to->u.selectionNotify.requestor);
+ cpswapl(from->u.selectionNotify.selection,
+ to->u.selectionNotify.selection);
+ cpswapl(from->u.selectionNotify.target,
+ to->u.selectionNotify.target);
+ cpswapl(from->u.selectionNotify.property,
+ to->u.selectionNotify.property);
+}
+
+void
+SColormapEvent(xEvent *from, xEvent *to)
+{
+ to->u.u.type = from->u.u.type;
+ cpswaps(from->u.u.sequenceNumber, to->u.u.sequenceNumber);
+ cpswapl(from->u.colormap.window, to->u.colormap.window);
+ cpswapl(from->u.colormap.colormap, to->u.colormap.colormap);
+ to->u.colormap.new = from->u.colormap.new;
+ to->u.colormap.state = from->u.colormap.state;
+}
+
+void
+SMappingEvent(xEvent *from, xEvent *to)
+{
+ to->u.u.type = from->u.u.type;
+ cpswaps(from->u.u.sequenceNumber, to->u.u.sequenceNumber);
+ to->u.mappingNotify.request = from->u.mappingNotify.request;
+ to->u.mappingNotify.firstKeyCode =
+ from->u.mappingNotify.firstKeyCode;
+ to->u.mappingNotify.count = from->u.mappingNotify.count;
+}
+
+void
+SClientMessageEvent(xEvent *from, xEvent *to)
+{
+ to->u.u.type = from->u.u.type;
+ to->u.u.detail = from->u.u.detail; /* actually format */
+ cpswaps(from->u.u.sequenceNumber, to->u.u.sequenceNumber);
+ cpswapl(from->u.clientMessage.window, to->u.clientMessage.window);
+ cpswapl(from->u.clientMessage.u.l.type,
+ to->u.clientMessage.u.l.type);
+ switch (from->u.u.detail) {
+ case 8:
+ memmove(to->u.clientMessage.u.b.bytes,
+ from->u.clientMessage.u.b.bytes,20);
+ break;
+ case 16:
+ cpswaps(from->u.clientMessage.u.s.shorts0,
+ to->u.clientMessage.u.s.shorts0);
+ cpswaps(from->u.clientMessage.u.s.shorts1,
+ to->u.clientMessage.u.s.shorts1);
+ cpswaps(from->u.clientMessage.u.s.shorts2,
+ to->u.clientMessage.u.s.shorts2);
+ cpswaps(from->u.clientMessage.u.s.shorts3,
+ to->u.clientMessage.u.s.shorts3);
+ cpswaps(from->u.clientMessage.u.s.shorts4,
+ to->u.clientMessage.u.s.shorts4);
+ cpswaps(from->u.clientMessage.u.s.shorts5,
+ to->u.clientMessage.u.s.shorts5);
+ cpswaps(from->u.clientMessage.u.s.shorts6,
+ to->u.clientMessage.u.s.shorts6);
+ cpswaps(from->u.clientMessage.u.s.shorts7,
+ to->u.clientMessage.u.s.shorts7);
+ cpswaps(from->u.clientMessage.u.s.shorts8,
+ to->u.clientMessage.u.s.shorts8);
+ cpswaps(from->u.clientMessage.u.s.shorts9,
+ to->u.clientMessage.u.s.shorts9);
+ break;
+ case 32:
+ cpswapl(from->u.clientMessage.u.l.longs0,
+ to->u.clientMessage.u.l.longs0);
+ cpswapl(from->u.clientMessage.u.l.longs1,
+ to->u.clientMessage.u.l.longs1);
+ cpswapl(from->u.clientMessage.u.l.longs2,
+ to->u.clientMessage.u.l.longs2);
+ cpswapl(from->u.clientMessage.u.l.longs3,
+ to->u.clientMessage.u.l.longs3);
+ cpswapl(from->u.clientMessage.u.l.longs4,
+ to->u.clientMessage.u.l.longs4);
+ break;
+ }
+}
+
+void
+SKeymapNotifyEvent(xEvent *from, xEvent *to)
+{
+ /* Keymap notify events are special; they have no
+ sequence number field, and contain entirely 8-bit data */
+ *to = *from;
+}
+
+static void
+SwapConnSetup(xConnSetup *pConnSetup, xConnSetup *pConnSetupT)
+{
+ cpswapl(pConnSetup->release, pConnSetupT->release);
+ cpswapl(pConnSetup->ridBase, pConnSetupT->ridBase);
+ cpswapl(pConnSetup->ridMask, pConnSetupT->ridMask);
+ cpswapl(pConnSetup->motionBufferSize, pConnSetupT->motionBufferSize);
+ cpswaps(pConnSetup->nbytesVendor, pConnSetupT->nbytesVendor);
+ cpswaps(pConnSetup->maxRequestSize, pConnSetupT->maxRequestSize);
+ pConnSetupT->minKeyCode = pConnSetup->minKeyCode;
+ pConnSetupT->maxKeyCode = pConnSetup->maxKeyCode;
+ pConnSetupT->numRoots = pConnSetup->numRoots;
+ pConnSetupT->numFormats = pConnSetup->numFormats;
+ pConnSetupT->imageByteOrder = pConnSetup->imageByteOrder;
+ pConnSetupT->bitmapBitOrder = pConnSetup->bitmapBitOrder;
+ pConnSetupT->bitmapScanlineUnit = pConnSetup->bitmapScanlineUnit;
+ pConnSetupT->bitmapScanlinePad = pConnSetup->bitmapScanlinePad;
+}
+
+static void
+SwapWinRoot(xWindowRoot *pRoot, xWindowRoot *pRootT)
+{
+ cpswapl(pRoot->windowId, pRootT->windowId);
+ cpswapl(pRoot->defaultColormap, pRootT->defaultColormap);
+ cpswapl(pRoot->whitePixel, pRootT->whitePixel);
+ cpswapl(pRoot->blackPixel, pRootT->blackPixel);
+ cpswapl(pRoot->currentInputMask, pRootT->currentInputMask);
+ cpswaps(pRoot->pixWidth, pRootT->pixWidth);
+ cpswaps(pRoot->pixHeight, pRootT->pixHeight);
+ cpswaps(pRoot->mmWidth, pRootT->mmWidth);
+ cpswaps(pRoot->mmHeight, pRootT->mmHeight);
+ cpswaps(pRoot->minInstalledMaps, pRootT->minInstalledMaps);
+ cpswaps(pRoot->maxInstalledMaps, pRootT->maxInstalledMaps);
+ cpswapl(pRoot->rootVisualID, pRootT->rootVisualID);
+ pRootT->backingStore = pRoot->backingStore;
+ pRootT->saveUnders = pRoot->saveUnders;
+ pRootT->rootDepth = pRoot->rootDepth;
+ pRootT->nDepths = pRoot->nDepths;
+}
+
+static void
+SwapVisual(xVisualType *pVis, xVisualType *pVisT)
+{
+ cpswapl(pVis->visualID, pVisT->visualID);
+ pVisT->class = pVis->class;
+ pVisT->bitsPerRGB = pVis->bitsPerRGB;
+ cpswaps(pVis->colormapEntries, pVisT->colormapEntries);
+ cpswapl(pVis->redMask, pVisT->redMask);
+ cpswapl(pVis->greenMask, pVisT->greenMask);
+ cpswapl(pVis->blueMask, pVisT->blueMask);
+}
+
+void
+SwapConnSetupInfo(
+ char *pInfo,
+ char *pInfoT
+)
+{
+ int i, j, k;
+ xConnSetup *pConnSetup = (xConnSetup *)pInfo;
+ xDepth *depth;
+ xWindowRoot *root;
+
+ SwapConnSetup(pConnSetup, (xConnSetup *)pInfoT);
+ pInfo += sizeof(xConnSetup);
+ pInfoT += sizeof(xConnSetup);
+
+ /* Copy the vendor string */
+ i = pad_to_int32(pConnSetup->nbytesVendor);
+ memcpy(pInfoT, pInfo, i);
+ pInfo += i;
+ pInfoT += i;
+
+ /* The Pixmap formats don't need to be swapped, just copied. */
+ i = sizeof(xPixmapFormat) * pConnSetup->numFormats;
+ memcpy(pInfoT, pInfo, i);
+ pInfo += i;
+ pInfoT += i;
+
+ for(i = 0; i < pConnSetup->numRoots; i++)
+ {
+ root = (xWindowRoot*)pInfo;
+ SwapWinRoot(root, (xWindowRoot *)pInfoT);
+ pInfo += sizeof(xWindowRoot);
+ pInfoT += sizeof(xWindowRoot);
+
+ for(j = 0; j < root->nDepths; j++)
+ {
+ depth = (xDepth*)pInfo;
+ ((xDepth *)pInfoT)->depth = depth->depth;
+ cpswaps(depth->nVisuals, ((xDepth *)pInfoT)->nVisuals);
+ pInfo += sizeof(xDepth);
+ pInfoT += sizeof(xDepth);
+ for(k = 0; k < depth->nVisuals; k++)
+ {
+ SwapVisual((xVisualType *)pInfo, (xVisualType *)pInfoT);
+ pInfo += sizeof(xVisualType);
+ pInfoT += sizeof(xVisualType);
+ }
+ }
+ }
+}
+
+void
+WriteSConnectionInfo(ClientPtr pClient, unsigned long size, char *pInfo)
+{
+ char *pInfoTBase;
+
+ pInfoTBase = malloc(size);
+ if (!pInfoTBase)
+ {
+ pClient->noClientException = -1;
+ return;
+ }
+ SwapConnSetupInfo(pInfo, pInfoTBase);
+ (void)WriteToClient(pClient, (int)size, (char *) pInfoTBase);
+ free(pInfoTBase);
+}
+
+void
+SwapConnSetupPrefix(xConnSetupPrefix *pcspFrom, xConnSetupPrefix *pcspTo)
+{
+ pcspTo->success = pcspFrom->success;
+ pcspTo->lengthReason = pcspFrom->lengthReason;
+ cpswaps(pcspFrom->majorVersion, pcspTo->majorVersion);
+ cpswaps(pcspFrom->minorVersion, pcspTo->minorVersion);
+ cpswaps(pcspFrom->length, pcspTo->length);
+}
+
+void
+WriteSConnSetupPrefix(ClientPtr pClient, xConnSetupPrefix *pcsp)
+{
+ xConnSetupPrefix cspT;
+
+ SwapConnSetupPrefix(pcsp, &cspT);
+ (void)WriteToClient(pClient, sizeof(cspT), (char *) &cspT);
+}
+
+/*
+ * Dummy entry for ReplySwapVector[]
+ */
+
+void
+ReplyNotSwappd(
+ ClientPtr pClient ,
+ int size ,
+ void * pbuf
+ )
+{
+ FatalError("Not implemented");
+}
+
diff --git a/xorg-server/dix/swapreq.c b/xorg-server/dix/swapreq.c
index 4fbb6ebda..d07cd10d3 100644
--- a/xorg-server/dix/swapreq.c
+++ b/xorg-server/dix/swapreq.c
@@ -1,1099 +1,1017 @@
-/************************************************************
-
-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.
-
-********************************************************/
-
-
-#ifdef HAVE_DIX_CONFIG_H
-#include <dix-config.h>
-#endif
-
-#include <X11/X.h>
-#include <X11/Xproto.h>
-#include <X11/Xprotostr.h>
-#include "misc.h"
-#include "dixstruct.h"
-#include "extnsionst.h" /* for SendEvent */
-#include "swapreq.h"
-
-/* Thanks to Jack Palevich for testing and subsequently rewriting all this */
-
-/* Byte swap a list of longs */
-void
-SwapLongs (CARD32 *list, unsigned long count)
-{
- char n;
-
- while (count >= 8) {
- swapl(list+0, n);
- swapl(list+1, n);
- swapl(list+2, n);
- swapl(list+3, n);
- swapl(list+4, n);
- swapl(list+5, n);
- swapl(list+6, n);
- swapl(list+7, n);
- list += 8;
- count -= 8;
- }
- if (count != 0) {
- do {
- swapl(list, n);
- list++;
- } while (--count != 0);
- }
-}
-
-/* Byte swap a list of shorts */
-void
-SwapShorts (short *list, unsigned long count)
-{
- char n;
-
- while (count >= 16) {
- swaps(list+0, n);
- swaps(list+1, n);
- swaps(list+2, n);
- swaps(list+3, n);
- swaps(list+4, n);
- swaps(list+5, n);
- swaps(list+6, n);
- swaps(list+7, n);
- swaps(list+8, n);
- swaps(list+9, n);
- swaps(list+10, n);
- swaps(list+11, n);
- swaps(list+12, n);
- swaps(list+13, n);
- swaps(list+14, n);
- swaps(list+15, n);
- list += 16;
- count -= 16;
- }
- if (count != 0) {
- do {
- swaps(list, n);
- list++;
- } while (--count != 0);
- }
-}
-
-/* The following is used for all requests that have
- no fields to be swapped (except "length") */
-int
-SProcSimpleReq(ClientPtr client)
-{
- char n;
-
- REQUEST(xReq);
- swaps(&stuff->length, n);
- return(*ProcVector[stuff->reqType])(client);
-}
-
-/* The following is used for all requests that have
- only a single 32-bit field to be swapped, coming
- right after the "length" field */
-int
-SProcResourceReq(ClientPtr client)
-{
- char n;
-
- REQUEST(xResourceReq);
- swaps(&stuff->length, n);
- REQUEST_AT_LEAST_SIZE(xResourceReq); /* not EXACT */
- swapl(&stuff->id, n);
- return(*ProcVector[stuff->reqType])(client);
-}
-
-int
-SProcCreateWindow(ClientPtr client)
-{
- char n;
-
- REQUEST(xCreateWindowReq);
- swaps(&stuff->length, n);
- REQUEST_AT_LEAST_SIZE(xCreateWindowReq);
- swapl(&stuff->wid, n);
- swapl(&stuff->parent, n);
- swaps(&stuff->x, n);
- swaps(&stuff->y, n);
- swaps(&stuff->width, n);
- swaps(&stuff->height, n);
- swaps(&stuff->borderWidth, n);
- swaps(&stuff->class, n);
- swapl(&stuff->visual, n);
- swapl(&stuff->mask, n);
- SwapRestL(stuff);
- return((* ProcVector[X_CreateWindow])(client));
-}
-
-int
-SProcChangeWindowAttributes(ClientPtr client)
-{
- char n;
-
- REQUEST(xChangeWindowAttributesReq);
- swaps(&stuff->length, n);
- REQUEST_AT_LEAST_SIZE(xChangeWindowAttributesReq);
- swapl(&stuff->window, n);
- swapl(&stuff->valueMask, n);
- SwapRestL(stuff);
- return((* ProcVector[X_ChangeWindowAttributes])(client));
-}
-
-int
-SProcReparentWindow(ClientPtr client)
-{
- char n;
- REQUEST(xReparentWindowReq);
- swaps(&stuff->length, n);
- REQUEST_SIZE_MATCH(xReparentWindowReq);
- swapl(&stuff->window, n);
- swapl(&stuff->parent, n);
- swaps(&stuff->x, n);
- swaps(&stuff->y, n);
- return((* ProcVector[X_ReparentWindow])(client));
-}
-
-int
-SProcConfigureWindow(ClientPtr client)
-{
- char n;
- REQUEST(xConfigureWindowReq);
- swaps(&stuff->length, n);
- REQUEST_AT_LEAST_SIZE(xConfigureWindowReq);
- swapl(&stuff->window, n);
- swaps(&stuff->mask, n);
- SwapRestL(stuff);
- return((* ProcVector[X_ConfigureWindow])(client));
-
-}
-
-
-int
-SProcInternAtom(ClientPtr client)
-{
- char n;
- REQUEST(xInternAtomReq);
- swaps(&stuff->length, n);
- REQUEST_AT_LEAST_SIZE(xInternAtomReq);
- swaps(&stuff->nbytes, n);
- return((* ProcVector[X_InternAtom])(client));
-}
-
-int
-SProcChangeProperty(ClientPtr client)
-{
- char n;
- REQUEST(xChangePropertyReq);
- swaps(&stuff->length, n);
- REQUEST_AT_LEAST_SIZE(xChangePropertyReq);
- swapl(&stuff->window, n);
- swapl(&stuff->property, n);
- swapl(&stuff->type, n);
- swapl(&stuff->nUnits, n);
- switch ( stuff->format ) {
- case 8 :
- break;
- case 16:
- SwapRestS(stuff);
- break;
- case 32:
- SwapRestL(stuff);
- break;
- }
- return((* ProcVector[X_ChangeProperty])(client));
-}
-
-int
-SProcDeleteProperty(ClientPtr client)
-{
- char n;
- REQUEST(xDeletePropertyReq);
- swaps(&stuff->length, n);
- REQUEST_SIZE_MATCH(xDeletePropertyReq);
- swapl(&stuff->window, n);
- swapl(&stuff->property, n);
- return((* ProcVector[X_DeleteProperty])(client));
-
-}
-
-int
-SProcGetProperty(ClientPtr client)
-{
- char n;
- REQUEST(xGetPropertyReq);
- swaps(&stuff->length, n);
- REQUEST_SIZE_MATCH(xGetPropertyReq);
- swapl(&stuff->window, n);
- swapl(&stuff->property, n);
- swapl(&stuff->type, n);
- swapl(&stuff->longOffset, n);
- swapl(&stuff->longLength, n);
- return((* ProcVector[X_GetProperty])(client));
-}
-
-int
-SProcSetSelectionOwner(ClientPtr client)
-{
- char n;
- REQUEST(xSetSelectionOwnerReq);
- swaps(&stuff->length, n);
- REQUEST_SIZE_MATCH(xSetSelectionOwnerReq);
- swapl(&stuff->window, n);
- swapl(&stuff->selection, n);
- swapl(&stuff->time, n);
- return((* ProcVector[X_SetSelectionOwner])(client));
-}
-
-int
-SProcConvertSelection(ClientPtr client)
-{
- char n;
- REQUEST(xConvertSelectionReq);
- swaps(&stuff->length, n);
- REQUEST_SIZE_MATCH(xConvertSelectionReq);
- swapl(&stuff->requestor, n);
- swapl(&stuff->selection, n);
- swapl(&stuff->target, n);
- swapl(&stuff->property, n);
- swapl(&stuff->time, n);
- return((* ProcVector[X_ConvertSelection])(client));
-}
-
-int
-SProcSendEvent(ClientPtr client)
-{
- char n;
- xEvent eventT;
- EventSwapPtr proc;
- REQUEST(xSendEventReq);
- swaps(&stuff->length, n);
- REQUEST_SIZE_MATCH(xSendEventReq);
- swapl(&stuff->destination, n);
- swapl(&stuff->eventMask, n);
-
- /* Swap event */
- proc = EventSwapVector[stuff->event.u.u.type & 0177];
- if (!proc || proc == NotImplemented) /* no swapping proc; invalid event type? */
- return BadValue;
- (*proc)(&stuff->event, &eventT);
- stuff->event = eventT;
-
- return((* ProcVector[X_SendEvent])(client));
-}
-
-int
-SProcGrabPointer(ClientPtr client)
-{
- char n;
- REQUEST(xGrabPointerReq);
- swaps(&stuff->length, n);
- REQUEST_SIZE_MATCH(xGrabPointerReq);
- swapl(&stuff->grabWindow, n);
- swaps(&stuff->eventMask, n);
- swapl(&stuff->confineTo, n);
- swapl(&stuff->cursor, n);
- swapl(&stuff->time, n);
- return((* ProcVector[X_GrabPointer])(client));
-}
-
-int
-SProcGrabButton(ClientPtr client)
-{
- char n;
- REQUEST(xGrabButtonReq);
- swaps(&stuff->length, n);
- REQUEST_SIZE_MATCH(xGrabButtonReq);
- swapl(&stuff->grabWindow, n);
- swaps(&stuff->eventMask, n);
- swapl(&stuff->confineTo, n);
- swapl(&stuff->cursor, n);
- swaps(&stuff->modifiers, n);
- return((* ProcVector[X_GrabButton])(client));
-}
-
-int
-SProcUngrabButton(ClientPtr client)
-{
- char n;
- REQUEST(xUngrabButtonReq);
- swaps(&stuff->length, n);
- REQUEST_SIZE_MATCH(xUngrabButtonReq);
- swapl(&stuff->grabWindow, n);
- swaps(&stuff->modifiers, n);
- return((* ProcVector[X_UngrabButton])(client));
-}
-
-int
-SProcChangeActivePointerGrab(ClientPtr client)
-{
- char n;
- REQUEST(xChangeActivePointerGrabReq);
- swaps(&stuff->length, n);
- REQUEST_SIZE_MATCH(xChangeActivePointerGrabReq);
- swapl(&stuff->cursor, n);
- swapl(&stuff->time, n);
- swaps(&stuff->eventMask, n);
- return((* ProcVector[X_ChangeActivePointerGrab])(client));
-}
-
-int
-SProcGrabKeyboard(ClientPtr client)
-{
- char n;
- REQUEST(xGrabKeyboardReq);
- swaps(&stuff->length, n);
- REQUEST_SIZE_MATCH(xGrabKeyboardReq);
- swapl(&stuff->grabWindow, n);
- swapl(&stuff->time, n);
- return((* ProcVector[X_GrabKeyboard])(client));
-}
-
-int
-SProcGrabKey(ClientPtr client)
-{
- char n;
- REQUEST(xGrabKeyReq);
- swaps(&stuff->length, n);
- REQUEST_SIZE_MATCH(xGrabKeyReq);
- swapl(&stuff->grabWindow, n);
- swaps(&stuff->modifiers, n);
- return((* ProcVector[X_GrabKey])(client));
-}
-
-int
-SProcUngrabKey(ClientPtr client)
-{
- char n;
- REQUEST(xUngrabKeyReq);
- swaps(&stuff->length, n);
- REQUEST_SIZE_MATCH(xUngrabKeyReq);
- swapl(&stuff->grabWindow, n);
- swaps(&stuff->modifiers, n);
- return((* ProcVector[X_UngrabKey])(client));
-}
-
-int
-SProcGetMotionEvents(ClientPtr client)
-{
- char n;
- REQUEST(xGetMotionEventsReq);
- swaps(&stuff->length, n);
- REQUEST_SIZE_MATCH(xGetMotionEventsReq);
- swapl(&stuff->window, n);
- swapl(&stuff->start, n);
- swapl(&stuff->stop, n);
- return((* ProcVector[X_GetMotionEvents])(client));
-}
-
-int
-SProcTranslateCoords(ClientPtr client)
-{
- char n;
- REQUEST(xTranslateCoordsReq);
- swaps(&stuff->length, n);
- REQUEST_SIZE_MATCH(xTranslateCoordsReq);
- swapl(&stuff->srcWid, n);
- swapl(&stuff->dstWid, n);
- swaps(&stuff->srcX, n);
- swaps(&stuff->srcY, n);
- return((* ProcVector[X_TranslateCoords])(client));
-}
-
-int
-SProcWarpPointer(ClientPtr client)
-{
- char n;
- REQUEST(xWarpPointerReq);
- swaps(&stuff->length, n);
- REQUEST_SIZE_MATCH(xWarpPointerReq);
- swapl(&stuff->srcWid, n);
- swapl(&stuff->dstWid, n);
- swaps(&stuff->srcX, n);
- swaps(&stuff->srcY, n);
- swaps(&stuff->srcWidth, n);
- swaps(&stuff->srcHeight, n);
- swaps(&stuff->dstX, n);
- swaps(&stuff->dstY, n);
- return((* ProcVector[X_WarpPointer])(client));
-}
-
-int
-SProcSetInputFocus(ClientPtr client)
-{
- char n;
- REQUEST(xSetInputFocusReq);
- swaps(&stuff->length, n);
- REQUEST_SIZE_MATCH(xSetInputFocusReq);
- swapl(&stuff->focus, n);
- swapl(&stuff->time, n);
- return((* ProcVector[X_SetInputFocus])(client));
-}
-
-int
-SProcOpenFont(ClientPtr client)
-{
- char n;
- REQUEST(xOpenFontReq);
- swaps(&stuff->length, n);
- REQUEST_AT_LEAST_SIZE(xOpenFontReq);
- swapl(&stuff->fid, n);
- swaps(&stuff->nbytes, n);
- return((* ProcVector[X_OpenFont])(client));
-}
-
-int
-SProcListFonts(ClientPtr client)
-{
- char n;
- REQUEST(xListFontsReq);
- swaps(&stuff->length, n);
- REQUEST_AT_LEAST_SIZE(xListFontsReq);
- swaps(&stuff->maxNames, n);
- swaps(&stuff->nbytes, n);
- return((* ProcVector[X_ListFonts])(client));
-}
-
-int
-SProcListFontsWithInfo(ClientPtr client)
-{
- char n;
- REQUEST(xListFontsWithInfoReq);
- swaps(&stuff->length, n);
- REQUEST_AT_LEAST_SIZE(xListFontsWithInfoReq);
- swaps(&stuff->maxNames, n);
- swaps(&stuff->nbytes, n);
- return((* ProcVector[X_ListFontsWithInfo])(client));
-}
-
-int
-SProcSetFontPath(ClientPtr client)
-{
- char n;
- REQUEST(xSetFontPathReq);
- swaps(&stuff->length, n);
- REQUEST_AT_LEAST_SIZE(xSetFontPathReq);
- swaps(&stuff->nFonts, n);
- return((* ProcVector[X_SetFontPath])(client));
-}
-
-int
-SProcCreatePixmap(ClientPtr client)
-{
- char n;
- REQUEST(xCreatePixmapReq);
-
- swaps(&stuff->length, n);
- REQUEST_SIZE_MATCH(xCreatePixmapReq);
- swapl(&stuff->pid, n);
- swapl(&stuff->drawable, n);
- swaps(&stuff->width, n);
- swaps(&stuff->height, n);
- return((* ProcVector[X_CreatePixmap])(client));
-}
-
-int
-SProcCreateGC(ClientPtr client)
-{
- char n;
- REQUEST(xCreateGCReq);
- swaps(&stuff->length, n);
- REQUEST_AT_LEAST_SIZE(xCreateGCReq);
- swapl(&stuff->gc, n);
- swapl(&stuff->drawable, n);
- swapl(&stuff->mask, n);
- SwapRestL(stuff);
- return((* ProcVector[X_CreateGC])(client));
-}
-
-int
-SProcChangeGC(ClientPtr client)
-{
- char n;
- REQUEST(xChangeGCReq);
- swaps(&stuff->length, n);
- REQUEST_AT_LEAST_SIZE(xChangeGCReq);
- swapl(&stuff->gc, n);
- swapl(&stuff->mask, n);
- SwapRestL(stuff);
- return((* ProcVector[X_ChangeGC])(client));
-}
-
-int
-SProcCopyGC(ClientPtr client)
-{
- char n;
- REQUEST(xCopyGCReq);
- swaps(&stuff->length, n);
- REQUEST_SIZE_MATCH(xCopyGCReq);
- swapl(&stuff->srcGC, n);
- swapl(&stuff->dstGC, n);
- swapl(&stuff->mask, n);
- return((* ProcVector[X_CopyGC])(client));
-}
-
-int
-SProcSetDashes(ClientPtr client)
-{
- char n;
- REQUEST(xSetDashesReq);
- swaps(&stuff->length, n);
- REQUEST_AT_LEAST_SIZE(xSetDashesReq);
- swapl(&stuff->gc, n);
- swaps(&stuff->dashOffset, n);
- swaps(&stuff->nDashes, n);
- return((* ProcVector[X_SetDashes])(client));
-
-}
-
-int
-SProcSetClipRectangles(ClientPtr client)
-{
- char n;
- REQUEST(xSetClipRectanglesReq);
- swaps(&stuff->length, n);
- REQUEST_AT_LEAST_SIZE(xSetClipRectanglesReq);
- swapl(&stuff->gc, n);
- swaps(&stuff->xOrigin, n);
- swaps(&stuff->yOrigin, n);
- SwapRestS(stuff);
- return((* ProcVector[X_SetClipRectangles])(client));
-}
-
-int
-SProcClearToBackground(ClientPtr client)
-{
- char n;
- REQUEST(xClearAreaReq);
- swaps(&stuff->length, n);
- REQUEST_SIZE_MATCH(xClearAreaReq);
- swapl(&stuff->window, n);
- swaps(&stuff->x, n);
- swaps(&stuff->y, n);
- swaps(&stuff->width, n);
- swaps(&stuff->height, n);
- return((* ProcVector[X_ClearArea])(client));
-}
-
-int
-SProcCopyArea(ClientPtr client)
-{
- char n;
- REQUEST(xCopyAreaReq);
- swaps(&stuff->length, n);
- REQUEST_SIZE_MATCH(xCopyAreaReq);
- swapl(&stuff->srcDrawable, n);
- swapl(&stuff->dstDrawable, n);
- swapl(&stuff->gc, n);
- swaps(&stuff->srcX, n);
- swaps(&stuff->srcY, n);
- swaps(&stuff->dstX, n);
- swaps(&stuff->dstY, n);
- swaps(&stuff->width, n);
- swaps(&stuff->height, n);
- return((* ProcVector[X_CopyArea])(client));
-}
-
-int
-SProcCopyPlane(ClientPtr client)
-{
- char n;
- REQUEST(xCopyPlaneReq);
- swaps(&stuff->length, n);
- REQUEST_SIZE_MATCH(xCopyPlaneReq);
- swapl(&stuff->srcDrawable, n);
- swapl(&stuff->dstDrawable, n);
- swapl(&stuff->gc, n);
- swaps(&stuff->srcX, n);
- swaps(&stuff->srcY, n);
- swaps(&stuff->dstX, n);
- swaps(&stuff->dstY, n);
- swaps(&stuff->width, n);
- swaps(&stuff->height, n);
- swapl(&stuff->bitPlane, n);
- return((* ProcVector[X_CopyPlane])(client));
-}
-
-/* The following routine is used for all Poly drawing requests
- (except FillPoly, which uses a different request format) */
-int
-SProcPoly(ClientPtr client)
-{
- char n;
-
- REQUEST(xPolyPointReq);
- swaps(&stuff->length, n);
- REQUEST_AT_LEAST_SIZE(xPolyPointReq);
- swapl(&stuff->drawable, n);
- swapl(&stuff->gc, n);
- SwapRestS(stuff);
- return((* ProcVector[stuff->reqType])(client));
-}
-
-/* cannot use SProcPoly for this one, because xFillPolyReq
- is longer than xPolyPointReq, and we don't want to swap
- the difference as shorts! */
-int
-SProcFillPoly(ClientPtr client)
-{
- char n;
-
- REQUEST(xFillPolyReq);
- swaps(&stuff->length, n);
- REQUEST_AT_LEAST_SIZE(xFillPolyReq);
- swapl(&stuff->drawable, n);
- swapl(&stuff->gc, n);
- SwapRestS(stuff);
- return((* ProcVector[X_FillPoly])(client));
-}
-
-int
-SProcPutImage(ClientPtr client)
-{
- char n;
- REQUEST(xPutImageReq);
- swaps(&stuff->length, n);
- REQUEST_AT_LEAST_SIZE(xPutImageReq);
- swapl(&stuff->drawable, n);
- swapl(&stuff->gc, n);
- swaps(&stuff->width, n);
- swaps(&stuff->height, n);
- swaps(&stuff->dstX, n);
- swaps(&stuff->dstY, n);
- /* Image should already be swapped */
- return((* ProcVector[X_PutImage])(client));
-
-}
-
-int
-SProcGetImage(ClientPtr client)
-{
- char n;
- REQUEST(xGetImageReq);
- swaps(&stuff->length, n);
- REQUEST_SIZE_MATCH(xGetImageReq);
- swapl(&stuff->drawable, n);
- swaps(&stuff->x, n);
- swaps(&stuff->y, n);
- swaps(&stuff->width, n);
- swaps(&stuff->height, n);
- swapl(&stuff->planeMask, n);
- return((* ProcVector[X_GetImage])(client));
-}
-
-/* ProcPolyText used for both PolyText8 and PolyText16 */
-
-int
-SProcPolyText(ClientPtr client)
-{
- char n;
- REQUEST(xPolyTextReq);
- swaps(&stuff->length, n);
- REQUEST_AT_LEAST_SIZE(xPolyTextReq);
- swapl(&stuff->drawable, n);
- swapl(&stuff->gc, n);
- swaps(&stuff->x, n);
- swaps(&stuff->y, n);
- return((* ProcVector[stuff->reqType])(client));
-}
-
-/* ProcImageText used for both ImageText8 and ImageText16 */
-
-int
-SProcImageText(ClientPtr client)
-{
- char n;
- REQUEST(xImageTextReq);
- swaps(&stuff->length, n);
- REQUEST_AT_LEAST_SIZE(xImageTextReq);
- swapl(&stuff->drawable, n);
- swapl(&stuff->gc, n);
- swaps(&stuff->x, n);
- swaps(&stuff->y, n);
- return((* ProcVector[stuff->reqType])(client));
-}
-
-int
-SProcCreateColormap(ClientPtr client)
-{
- char n;
- REQUEST(xCreateColormapReq);
- swaps(&stuff->length, n);
- REQUEST_SIZE_MATCH(xCreateColormapReq);
- swapl(&stuff->mid, n);
- swapl(&stuff->window, n);
- swapl(&stuff->visual, n);
- return((* ProcVector[X_CreateColormap])(client));
-}
-
-
-int
-SProcCopyColormapAndFree(ClientPtr client)
-{
- char n;
- REQUEST(xCopyColormapAndFreeReq);
- swaps(&stuff->length, n);
- REQUEST_SIZE_MATCH(xCopyColormapAndFreeReq);
- swapl(&stuff->mid, n);
- swapl(&stuff->srcCmap, n);
- return((* ProcVector[X_CopyColormapAndFree])(client));
-
-}
-
-int
-SProcAllocColor(ClientPtr client)
-{
- char n;
- REQUEST(xAllocColorReq);
- swaps(&stuff->length, n);
- REQUEST_SIZE_MATCH(xAllocColorReq);
- swapl(&stuff->cmap, n);
- swaps(&stuff->red, n);
- swaps(&stuff->green, n);
- swaps(&stuff->blue, n);
- return((* ProcVector[X_AllocColor])(client));
-}
-
-int
-SProcAllocNamedColor(ClientPtr client)
-{
- char n;
-
- REQUEST(xAllocNamedColorReq);
- swaps(&stuff->length, n);
- REQUEST_AT_LEAST_SIZE(xAllocNamedColorReq);
- swapl(&stuff->cmap, n);
- swaps(&stuff->nbytes, n);
- return((* ProcVector[X_AllocNamedColor])(client));
-}
-
-int
-SProcAllocColorCells(ClientPtr client)
-{
- char n;
- REQUEST(xAllocColorCellsReq);
- swaps(&stuff->length, n);
- REQUEST_SIZE_MATCH(xAllocColorCellsReq);
- swapl(&stuff->cmap, n);
- swaps(&stuff->colors, n);
- swaps(&stuff->planes, n);
- return((* ProcVector[X_AllocColorCells])(client));
-}
-
-int
-SProcAllocColorPlanes(ClientPtr client)
-{
- char n;
- REQUEST(xAllocColorPlanesReq);
- swaps(&stuff->length, n);
- REQUEST_SIZE_MATCH(xAllocColorPlanesReq);
- swapl(&stuff->cmap, n);
- swaps(&stuff->colors, n);
- swaps(&stuff->red, n);
- swaps(&stuff->green, n);
- swaps(&stuff->blue, n);
- return((* ProcVector[X_AllocColorPlanes])(client));
-}
-
-int
-SProcFreeColors(ClientPtr client)
-{
- char n;
- REQUEST(xFreeColorsReq);
- swaps(&stuff->length, n);
- REQUEST_AT_LEAST_SIZE(xFreeColorsReq);
- swapl(&stuff->cmap, n);
- swapl(&stuff->planeMask, n);
- SwapRestL(stuff);
- return((* ProcVector[X_FreeColors])(client));
-
-}
-
-void
-SwapColorItem(xColorItem *pItem)
-{
- char n;
-
- swapl(&pItem->pixel, n);
- swaps(&pItem->red, n);
- swaps(&pItem->green, n);
- swaps(&pItem->blue, n);
-}
-
-int
-SProcStoreColors(ClientPtr client)
-{
- char n;
- long count;
- xColorItem *pItem;
-
- REQUEST(xStoreColorsReq);
- swaps(&stuff->length, n);
- REQUEST_AT_LEAST_SIZE(xStoreColorsReq);
- swapl(&stuff->cmap, n);
- pItem = (xColorItem *) &stuff[1];
- for(count = LengthRestB(stuff)/sizeof(xColorItem); --count >= 0; )
- SwapColorItem(pItem++);
- return((* ProcVector[X_StoreColors])(client));
-}
-
-int
-SProcStoreNamedColor (ClientPtr client)
-{
- char n;
- REQUEST(xStoreNamedColorReq);
- swaps(&stuff->length, n);
- REQUEST_AT_LEAST_SIZE(xStoreNamedColorReq);
- swapl(&stuff->cmap, n);
- swapl(&stuff->pixel, n);
- swaps(&stuff->nbytes, n);
- return((* ProcVector[X_StoreNamedColor])(client));
-}
-
-int
-SProcQueryColors (ClientPtr client)
-{
- char n;
- REQUEST(xQueryColorsReq);
- swaps(&stuff->length, n);
- REQUEST_AT_LEAST_SIZE(xQueryColorsReq);
- swapl(&stuff->cmap, n);
- SwapRestL(stuff);
- return((* ProcVector[X_QueryColors])(client));
-}
-
-int
-SProcLookupColor (ClientPtr client)
-{
- char n;
- REQUEST(xLookupColorReq);
- swaps(&stuff->length, n);
- REQUEST_AT_LEAST_SIZE(xLookupColorReq);
- swapl(&stuff->cmap, n);
- swaps(&stuff->nbytes, n);
- return((* ProcVector[X_LookupColor])(client));
-}
-
-int
-SProcCreateCursor (ClientPtr client)
-{
- char n;
- REQUEST(xCreateCursorReq);
- swaps(&stuff->length, n);
- REQUEST_SIZE_MATCH(xCreateCursorReq);
- swapl(&stuff->cid, n);
- swapl(&stuff->source, n);
- swapl(&stuff->mask, n);
- swaps(&stuff->foreRed, n);
- swaps(&stuff->foreGreen, n);
- swaps(&stuff->foreBlue, n);
- swaps(&stuff->backRed, n);
- swaps(&stuff->backGreen, n);
- swaps(&stuff->backBlue, n);
- swaps(&stuff->x, n);
- swaps(&stuff->y, n);
- return((* ProcVector[X_CreateCursor])(client));
-}
-
-int
-SProcCreateGlyphCursor (ClientPtr client)
-{
- char n;
- REQUEST(xCreateGlyphCursorReq);
- swaps(&stuff->length, n);
- REQUEST_SIZE_MATCH(xCreateGlyphCursorReq);
- swapl(&stuff->cid, n);
- swapl(&stuff->source, n);
- swapl(&stuff->mask, n);
- swaps(&stuff->sourceChar, n);
- swaps(&stuff->maskChar, n);
- swaps(&stuff->foreRed, n);
- swaps(&stuff->foreGreen, n);
- swaps(&stuff->foreBlue, n);
- swaps(&stuff->backRed, n);
- swaps(&stuff->backGreen, n);
- swaps(&stuff->backBlue, n);
- return((* ProcVector[X_CreateGlyphCursor])(client));
-}
-
-
-int
-SProcRecolorCursor (ClientPtr client)
-{
- char n;
- REQUEST(xRecolorCursorReq);
- swaps(&stuff->length, n);
- REQUEST_SIZE_MATCH(xRecolorCursorReq);
- swapl(&stuff->cursor, n);
- swaps(&stuff->foreRed, n);
- swaps(&stuff->foreGreen, n);
- swaps(&stuff->foreBlue, n);
- swaps(&stuff->backRed, n);
- swaps(&stuff->backGreen, n);
- swaps(&stuff->backBlue, n);
- return((* ProcVector[X_RecolorCursor])(client));
-}
-
-int
-SProcQueryBestSize (ClientPtr client)
-{
- char n;
- REQUEST(xQueryBestSizeReq);
- swaps(&stuff->length, n);
- REQUEST_SIZE_MATCH(xQueryBestSizeReq);
- swapl(&stuff->drawable, n);
- swaps(&stuff->width, n);
- swaps(&stuff->height, n);
- return((* ProcVector[X_QueryBestSize])(client));
-
-}
-
-int
-SProcQueryExtension (ClientPtr client)
-{
- char n;
- REQUEST(xQueryExtensionReq);
- swaps(&stuff->length, n);
- REQUEST_AT_LEAST_SIZE(xQueryExtensionReq);
- swaps(&stuff->nbytes, n);
- return((* ProcVector[X_QueryExtension])(client));
-}
-
-int
-SProcChangeKeyboardMapping (ClientPtr client)
-{
- char n;
- REQUEST(xChangeKeyboardMappingReq);
- swaps(&stuff->length, n);
- REQUEST_AT_LEAST_SIZE(xChangeKeyboardMappingReq);
- SwapRestL(stuff);
- return((* ProcVector[X_ChangeKeyboardMapping])(client));
-}
-
-
-int
-SProcChangeKeyboardControl (ClientPtr client)
-{
- char n;
- REQUEST(xChangeKeyboardControlReq);
- swaps(&stuff->length, n);
- REQUEST_AT_LEAST_SIZE(xChangeKeyboardControlReq);
- swapl(&stuff->mask, n);
- SwapRestL(stuff);
- return((* ProcVector[X_ChangeKeyboardControl])(client));
-}
-
-int
-SProcChangePointerControl (ClientPtr client)
-{
- char n;
- REQUEST(xChangePointerControlReq);
- swaps(&stuff->length, n);
- REQUEST_SIZE_MATCH(xChangePointerControlReq);
- swaps(&stuff->accelNum, n);
- swaps(&stuff->accelDenum, n);
- swaps(&stuff->threshold, n);
- return((* ProcVector[X_ChangePointerControl])(client));
-}
-
-
-int
-SProcSetScreenSaver (ClientPtr client)
-{
- char n;
- REQUEST(xSetScreenSaverReq);
- swaps(&stuff->length, n);
- REQUEST_SIZE_MATCH(xSetScreenSaverReq);
- swaps(&stuff->timeout, n);
- swaps(&stuff->interval, n);
- return((* ProcVector[X_SetScreenSaver])(client));
-}
-
-int
-SProcChangeHosts (ClientPtr client)
-{
- char n;
-
- REQUEST(xChangeHostsReq);
- swaps(&stuff->length, n);
- REQUEST_AT_LEAST_SIZE(xChangeHostsReq);
- swaps(&stuff->hostLength, n);
- return((* ProcVector[X_ChangeHosts])(client));
-
-}
-
-int SProcRotateProperties (ClientPtr client)
-{
- char n;
- REQUEST(xRotatePropertiesReq);
- swaps(&stuff->length, n);
- REQUEST_AT_LEAST_SIZE(xRotatePropertiesReq);
- swapl(&stuff->window, n);
- swaps(&stuff->nAtoms, n);
- swaps(&stuff->nPositions, n);
- SwapRestL(stuff);
- return ((* ProcVector[X_RotateProperties])(client));
-}
-
-int
-SProcNoOperation(ClientPtr client)
-{
- char n;
- REQUEST(xReq);
- swaps(&stuff->length, n);
- return ((* ProcVector[X_NoOperation])(client));
-}
-
-void
-SwapConnClientPrefix(xConnClientPrefix *pCCP)
-{
- char n;
-
- swaps(&pCCP->majorVersion, n);
- swaps(&pCCP->minorVersion, n);
- swaps(&pCCP->nbytesAuthProto, n);
- swaps(&pCCP->nbytesAuthString, n);
-}
+/************************************************************
+
+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.
+
+********************************************************/
+
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h>
+#include <X11/Xproto.h>
+#include <X11/Xprotostr.h>
+#include "misc.h"
+#include "dixstruct.h"
+#include "extnsionst.h" /* for SendEvent */
+#include "swapreq.h"
+
+/* Thanks to Jack Palevich for testing and subsequently rewriting all this */
+
+/* Byte swap a list of longs */
+void
+SwapLongs (CARD32 *list, unsigned long count)
+{
+ while (count >= 8) {
+ swapl(list + 0);
+ swapl(list + 1);
+ swapl(list + 2);
+ swapl(list + 3);
+ swapl(list + 4);
+ swapl(list + 5);
+ swapl(list + 6);
+ swapl(list + 7);
+ list += 8;
+ count -= 8;
+ }
+ if (count != 0) {
+ do {
+ swapl(list);
+ list++;
+ } while (--count != 0);
+ }
+}
+
+/* Byte swap a list of shorts */
+void
+SwapShorts (short *list, unsigned long count)
+{
+ while (count >= 16) {
+ swaps(list + 0);
+ swaps(list + 1);
+ swaps(list + 2);
+ swaps(list + 3);
+ swaps(list + 4);
+ swaps(list + 5);
+ swaps(list + 6);
+ swaps(list + 7);
+ swaps(list + 8);
+ swaps(list + 9);
+ swaps(list + 10);
+ swaps(list + 11);
+ swaps(list + 12);
+ swaps(list + 13);
+ swaps(list + 14);
+ swaps(list + 15);
+ list += 16;
+ count -= 16;
+ }
+ if (count != 0) {
+ do {
+ swaps(list);
+ list++;
+ } while (--count != 0);
+ }
+}
+
+/* The following is used for all requests that have
+ no fields to be swapped (except "length") */
+int
+SProcSimpleReq(ClientPtr client)
+{
+ REQUEST(xReq);
+ swaps(&stuff->length);
+ return(*ProcVector[stuff->reqType])(client);
+}
+
+/* The following is used for all requests that have
+ only a single 32-bit field to be swapped, coming
+ right after the "length" field */
+int
+SProcResourceReq(ClientPtr client)
+{
+ REQUEST(xResourceReq);
+ swaps(&stuff->length);
+ REQUEST_AT_LEAST_SIZE(xResourceReq); /* not EXACT */
+ swapl(&stuff->id);
+ return(*ProcVector[stuff->reqType])(client);
+}
+
+int
+SProcCreateWindow(ClientPtr client)
+{
+ REQUEST(xCreateWindowReq);
+ swaps(&stuff->length);
+ REQUEST_AT_LEAST_SIZE(xCreateWindowReq);
+ swapl(&stuff->wid);
+ swapl(&stuff->parent);
+ swaps(&stuff->x);
+ swaps(&stuff->y);
+ swaps(&stuff->width);
+ swaps(&stuff->height);
+ swaps(&stuff->borderWidth);
+ swaps(&stuff->class);
+ swapl(&stuff->visual);
+ swapl(&stuff->mask);
+ SwapRestL(stuff);
+ return((* ProcVector[X_CreateWindow])(client));
+}
+
+int
+SProcChangeWindowAttributes(ClientPtr client)
+{
+ REQUEST(xChangeWindowAttributesReq);
+ swaps(&stuff->length);
+ REQUEST_AT_LEAST_SIZE(xChangeWindowAttributesReq);
+ swapl(&stuff->window);
+ swapl(&stuff->valueMask);
+ SwapRestL(stuff);
+ return((* ProcVector[X_ChangeWindowAttributes])(client));
+}
+
+int
+SProcReparentWindow(ClientPtr client)
+{
+ REQUEST(xReparentWindowReq);
+ swaps(&stuff->length);
+ REQUEST_SIZE_MATCH(xReparentWindowReq);
+ swapl(&stuff->window);
+ swapl(&stuff->parent);
+ swaps(&stuff->x);
+ swaps(&stuff->y);
+ return((* ProcVector[X_ReparentWindow])(client));
+}
+
+int
+SProcConfigureWindow(ClientPtr client)
+{
+ REQUEST(xConfigureWindowReq);
+ swaps(&stuff->length);
+ REQUEST_AT_LEAST_SIZE(xConfigureWindowReq);
+ swapl(&stuff->window);
+ swaps(&stuff->mask);
+ SwapRestL(stuff);
+ return((* ProcVector[X_ConfigureWindow])(client));
+
+}
+
+
+int
+SProcInternAtom(ClientPtr client)
+{
+ REQUEST(xInternAtomReq);
+ swaps(&stuff->length);
+ REQUEST_AT_LEAST_SIZE(xInternAtomReq);
+ swaps(&stuff->nbytes);
+ return((* ProcVector[X_InternAtom])(client));
+}
+
+int
+SProcChangeProperty(ClientPtr client)
+{
+ REQUEST(xChangePropertyReq);
+ swaps(&stuff->length);
+ REQUEST_AT_LEAST_SIZE(xChangePropertyReq);
+ swapl(&stuff->window);
+ swapl(&stuff->property);
+ swapl(&stuff->type);
+ swapl(&stuff->nUnits);
+ switch ( stuff->format ) {
+ case 8 :
+ break;
+ case 16:
+ SwapRestS(stuff);
+ break;
+ case 32:
+ SwapRestL(stuff);
+ break;
+ }
+ return((* ProcVector[X_ChangeProperty])(client));
+}
+
+int
+SProcDeleteProperty(ClientPtr client)
+{
+ REQUEST(xDeletePropertyReq);
+ swaps(&stuff->length);
+ REQUEST_SIZE_MATCH(xDeletePropertyReq);
+ swapl(&stuff->window);
+ swapl(&stuff->property);
+ return((* ProcVector[X_DeleteProperty])(client));
+
+}
+
+int
+SProcGetProperty(ClientPtr client)
+{
+ REQUEST(xGetPropertyReq);
+ swaps(&stuff->length);
+ REQUEST_SIZE_MATCH(xGetPropertyReq);
+ swapl(&stuff->window);
+ swapl(&stuff->property);
+ swapl(&stuff->type);
+ swapl(&stuff->longOffset);
+ swapl(&stuff->longLength);
+ return((* ProcVector[X_GetProperty])(client));
+}
+
+int
+SProcSetSelectionOwner(ClientPtr client)
+{
+ REQUEST(xSetSelectionOwnerReq);
+ swaps(&stuff->length);
+ REQUEST_SIZE_MATCH(xSetSelectionOwnerReq);
+ swapl(&stuff->window);
+ swapl(&stuff->selection);
+ swapl(&stuff->time);
+ return((* ProcVector[X_SetSelectionOwner])(client));
+}
+
+int
+SProcConvertSelection(ClientPtr client)
+{
+ REQUEST(xConvertSelectionReq);
+ swaps(&stuff->length);
+ REQUEST_SIZE_MATCH(xConvertSelectionReq);
+ swapl(&stuff->requestor);
+ swapl(&stuff->selection);
+ swapl(&stuff->target);
+ swapl(&stuff->property);
+ swapl(&stuff->time);
+ return((* ProcVector[X_ConvertSelection])(client));
+}
+
+int
+SProcSendEvent(ClientPtr client)
+{
+ xEvent eventT;
+ EventSwapPtr proc;
+ REQUEST(xSendEventReq);
+ swaps(&stuff->length);
+ REQUEST_SIZE_MATCH(xSendEventReq);
+ swapl(&stuff->destination);
+ swapl(&stuff->eventMask);
+
+ /* Swap event */
+ proc = EventSwapVector[stuff->event.u.u.type & 0177];
+ if (!proc || proc == NotImplemented) /* no swapping proc; invalid event type? */
+ return BadValue;
+ (*proc)(&stuff->event, &eventT);
+ stuff->event = eventT;
+
+ return((* ProcVector[X_SendEvent])(client));
+}
+
+int
+SProcGrabPointer(ClientPtr client)
+{
+ REQUEST(xGrabPointerReq);
+ swaps(&stuff->length);
+ REQUEST_SIZE_MATCH(xGrabPointerReq);
+ swapl(&stuff->grabWindow);
+ swaps(&stuff->eventMask);
+ swapl(&stuff->confineTo);
+ swapl(&stuff->cursor);
+ swapl(&stuff->time);
+ return((* ProcVector[X_GrabPointer])(client));
+}
+
+int
+SProcGrabButton(ClientPtr client)
+{
+ REQUEST(xGrabButtonReq);
+ swaps(&stuff->length);
+ REQUEST_SIZE_MATCH(xGrabButtonReq);
+ swapl(&stuff->grabWindow);
+ swaps(&stuff->eventMask);
+ swapl(&stuff->confineTo);
+ swapl(&stuff->cursor);
+ swaps(&stuff->modifiers);
+ return((* ProcVector[X_GrabButton])(client));
+}
+
+int
+SProcUngrabButton(ClientPtr client)
+{
+ REQUEST(xUngrabButtonReq);
+ swaps(&stuff->length);
+ REQUEST_SIZE_MATCH(xUngrabButtonReq);
+ swapl(&stuff->grabWindow);
+ swaps(&stuff->modifiers);
+ return((* ProcVector[X_UngrabButton])(client));
+}
+
+int
+SProcChangeActivePointerGrab(ClientPtr client)
+{
+ REQUEST(xChangeActivePointerGrabReq);
+ swaps(&stuff->length);
+ REQUEST_SIZE_MATCH(xChangeActivePointerGrabReq);
+ swapl(&stuff->cursor);
+ swapl(&stuff->time);
+ swaps(&stuff->eventMask);
+ return((* ProcVector[X_ChangeActivePointerGrab])(client));
+}
+
+int
+SProcGrabKeyboard(ClientPtr client)
+{
+ REQUEST(xGrabKeyboardReq);
+ swaps(&stuff->length);
+ REQUEST_SIZE_MATCH(xGrabKeyboardReq);
+ swapl(&stuff->grabWindow);
+ swapl(&stuff->time);
+ return((* ProcVector[X_GrabKeyboard])(client));
+}
+
+int
+SProcGrabKey(ClientPtr client)
+{
+ REQUEST(xGrabKeyReq);
+ swaps(&stuff->length);
+ REQUEST_SIZE_MATCH(xGrabKeyReq);
+ swapl(&stuff->grabWindow);
+ swaps(&stuff->modifiers);
+ return((* ProcVector[X_GrabKey])(client));
+}
+
+int
+SProcUngrabKey(ClientPtr client)
+{
+ REQUEST(xUngrabKeyReq);
+ swaps(&stuff->length);
+ REQUEST_SIZE_MATCH(xUngrabKeyReq);
+ swapl(&stuff->grabWindow);
+ swaps(&stuff->modifiers);
+ return((* ProcVector[X_UngrabKey])(client));
+}
+
+int
+SProcGetMotionEvents(ClientPtr client)
+{
+ REQUEST(xGetMotionEventsReq);
+ swaps(&stuff->length);
+ REQUEST_SIZE_MATCH(xGetMotionEventsReq);
+ swapl(&stuff->window);
+ swapl(&stuff->start);
+ swapl(&stuff->stop);
+ return((* ProcVector[X_GetMotionEvents])(client));
+}
+
+int
+SProcTranslateCoords(ClientPtr client)
+{
+ REQUEST(xTranslateCoordsReq);
+ swaps(&stuff->length);
+ REQUEST_SIZE_MATCH(xTranslateCoordsReq);
+ swapl(&stuff->srcWid);
+ swapl(&stuff->dstWid);
+ swaps(&stuff->srcX);
+ swaps(&stuff->srcY);
+ return((* ProcVector[X_TranslateCoords])(client));
+}
+
+int
+SProcWarpPointer(ClientPtr client)
+{
+ REQUEST(xWarpPointerReq);
+ swaps(&stuff->length);
+ REQUEST_SIZE_MATCH(xWarpPointerReq);
+ swapl(&stuff->srcWid);
+ swapl(&stuff->dstWid);
+ swaps(&stuff->srcX);
+ swaps(&stuff->srcY);
+ swaps(&stuff->srcWidth);
+ swaps(&stuff->srcHeight);
+ swaps(&stuff->dstX);
+ swaps(&stuff->dstY);
+ return((* ProcVector[X_WarpPointer])(client));
+}
+
+int
+SProcSetInputFocus(ClientPtr client)
+{
+ REQUEST(xSetInputFocusReq);
+ swaps(&stuff->length);
+ REQUEST_SIZE_MATCH(xSetInputFocusReq);
+ swapl(&stuff->focus);
+ swapl(&stuff->time);
+ return((* ProcVector[X_SetInputFocus])(client));
+}
+
+int
+SProcOpenFont(ClientPtr client)
+{
+ REQUEST(xOpenFontReq);
+ swaps(&stuff->length);
+ REQUEST_AT_LEAST_SIZE(xOpenFontReq);
+ swapl(&stuff->fid);
+ swaps(&stuff->nbytes);
+ return((* ProcVector[X_OpenFont])(client));
+}
+
+int
+SProcListFonts(ClientPtr client)
+{
+ REQUEST(xListFontsReq);
+ swaps(&stuff->length);
+ REQUEST_AT_LEAST_SIZE(xListFontsReq);
+ swaps(&stuff->maxNames);
+ swaps(&stuff->nbytes);
+ return((* ProcVector[X_ListFonts])(client));
+}
+
+int
+SProcListFontsWithInfo(ClientPtr client)
+{
+ REQUEST(xListFontsWithInfoReq);
+ swaps(&stuff->length);
+ REQUEST_AT_LEAST_SIZE(xListFontsWithInfoReq);
+ swaps(&stuff->maxNames);
+ swaps(&stuff->nbytes);
+ return((* ProcVector[X_ListFontsWithInfo])(client));
+}
+
+int
+SProcSetFontPath(ClientPtr client)
+{
+ REQUEST(xSetFontPathReq);
+ swaps(&stuff->length);
+ REQUEST_AT_LEAST_SIZE(xSetFontPathReq);
+ swaps(&stuff->nFonts);
+ return((* ProcVector[X_SetFontPath])(client));
+}
+
+int
+SProcCreatePixmap(ClientPtr client)
+{
+ REQUEST(xCreatePixmapReq);
+
+ swaps(&stuff->length);
+ REQUEST_SIZE_MATCH(xCreatePixmapReq);
+ swapl(&stuff->pid);
+ swapl(&stuff->drawable);
+ swaps(&stuff->width);
+ swaps(&stuff->height);
+ return((* ProcVector[X_CreatePixmap])(client));
+}
+
+int
+SProcCreateGC(ClientPtr client)
+{
+ REQUEST(xCreateGCReq);
+ swaps(&stuff->length);
+ REQUEST_AT_LEAST_SIZE(xCreateGCReq);
+ swapl(&stuff->gc);
+ swapl(&stuff->drawable);
+ swapl(&stuff->mask);
+ SwapRestL(stuff);
+ return((* ProcVector[X_CreateGC])(client));
+}
+
+int
+SProcChangeGC(ClientPtr client)
+{
+ REQUEST(xChangeGCReq);
+ swaps(&stuff->length);
+ REQUEST_AT_LEAST_SIZE(xChangeGCReq);
+ swapl(&stuff->gc);
+ swapl(&stuff->mask);
+ SwapRestL(stuff);
+ return((* ProcVector[X_ChangeGC])(client));
+}
+
+int
+SProcCopyGC(ClientPtr client)
+{
+ REQUEST(xCopyGCReq);
+ swaps(&stuff->length);
+ REQUEST_SIZE_MATCH(xCopyGCReq);
+ swapl(&stuff->srcGC);
+ swapl(&stuff->dstGC);
+ swapl(&stuff->mask);
+ return((* ProcVector[X_CopyGC])(client));
+}
+
+int
+SProcSetDashes(ClientPtr client)
+{
+ REQUEST(xSetDashesReq);
+ swaps(&stuff->length);
+ REQUEST_AT_LEAST_SIZE(xSetDashesReq);
+ swapl(&stuff->gc);
+ swaps(&stuff->dashOffset);
+ swaps(&stuff->nDashes);
+ return((* ProcVector[X_SetDashes])(client));
+
+}
+
+int
+SProcSetClipRectangles(ClientPtr client)
+{
+ REQUEST(xSetClipRectanglesReq);
+ swaps(&stuff->length);
+ REQUEST_AT_LEAST_SIZE(xSetClipRectanglesReq);
+ swapl(&stuff->gc);
+ swaps(&stuff->xOrigin);
+ swaps(&stuff->yOrigin);
+ SwapRestS(stuff);
+ return((* ProcVector[X_SetClipRectangles])(client));
+}
+
+int
+SProcClearToBackground(ClientPtr client)
+{
+ REQUEST(xClearAreaReq);
+ swaps(&stuff->length);
+ REQUEST_SIZE_MATCH(xClearAreaReq);
+ swapl(&stuff->window);
+ swaps(&stuff->x);
+ swaps(&stuff->y);
+ swaps(&stuff->width);
+ swaps(&stuff->height);
+ return((* ProcVector[X_ClearArea])(client));
+}
+
+int
+SProcCopyArea(ClientPtr client)
+{
+ REQUEST(xCopyAreaReq);
+ swaps(&stuff->length);
+ REQUEST_SIZE_MATCH(xCopyAreaReq);
+ swapl(&stuff->srcDrawable);
+ swapl(&stuff->dstDrawable);
+ swapl(&stuff->gc);
+ swaps(&stuff->srcX);
+ swaps(&stuff->srcY);
+ swaps(&stuff->dstX);
+ swaps(&stuff->dstY);
+ swaps(&stuff->width);
+ swaps(&stuff->height);
+ return((* ProcVector[X_CopyArea])(client));
+}
+
+int
+SProcCopyPlane(ClientPtr client)
+{
+ REQUEST(xCopyPlaneReq);
+ swaps(&stuff->length);
+ REQUEST_SIZE_MATCH(xCopyPlaneReq);
+ swapl(&stuff->srcDrawable);
+ swapl(&stuff->dstDrawable);
+ swapl(&stuff->gc);
+ swaps(&stuff->srcX);
+ swaps(&stuff->srcY);
+ swaps(&stuff->dstX);
+ swaps(&stuff->dstY);
+ swaps(&stuff->width);
+ swaps(&stuff->height);
+ swapl(&stuff->bitPlane);
+ return((* ProcVector[X_CopyPlane])(client));
+}
+
+/* The following routine is used for all Poly drawing requests
+ (except FillPoly, which uses a different request format) */
+int
+SProcPoly(ClientPtr client)
+{
+ REQUEST(xPolyPointReq);
+ swaps(&stuff->length);
+ REQUEST_AT_LEAST_SIZE(xPolyPointReq);
+ swapl(&stuff->drawable);
+ swapl(&stuff->gc);
+ SwapRestS(stuff);
+ return((* ProcVector[stuff->reqType])(client));
+}
+
+/* cannot use SProcPoly for this one, because xFillPolyReq
+ is longer than xPolyPointReq, and we don't want to swap
+ the difference as shorts! */
+int
+SProcFillPoly(ClientPtr client)
+{
+ REQUEST(xFillPolyReq);
+ swaps(&stuff->length);
+ REQUEST_AT_LEAST_SIZE(xFillPolyReq);
+ swapl(&stuff->drawable);
+ swapl(&stuff->gc);
+ SwapRestS(stuff);
+ return((* ProcVector[X_FillPoly])(client));
+}
+
+int
+SProcPutImage(ClientPtr client)
+{
+ REQUEST(xPutImageReq);
+ swaps(&stuff->length);
+ REQUEST_AT_LEAST_SIZE(xPutImageReq);
+ swapl(&stuff->drawable);
+ swapl(&stuff->gc);
+ swaps(&stuff->width);
+ swaps(&stuff->height);
+ swaps(&stuff->dstX);
+ swaps(&stuff->dstY);
+ /* Image should already be swapped */
+ return((* ProcVector[X_PutImage])(client));
+
+}
+
+int
+SProcGetImage(ClientPtr client)
+{
+ REQUEST(xGetImageReq);
+ swaps(&stuff->length);
+ REQUEST_SIZE_MATCH(xGetImageReq);
+ swapl(&stuff->drawable);
+ swaps(&stuff->x);
+ swaps(&stuff->y);
+ swaps(&stuff->width);
+ swaps(&stuff->height);
+ swapl(&stuff->planeMask);
+ return((* ProcVector[X_GetImage])(client));
+}
+
+/* ProcPolyText used for both PolyText8 and PolyText16 */
+
+int
+SProcPolyText(ClientPtr client)
+{
+ REQUEST(xPolyTextReq);
+ swaps(&stuff->length);
+ REQUEST_AT_LEAST_SIZE(xPolyTextReq);
+ swapl(&stuff->drawable);
+ swapl(&stuff->gc);
+ swaps(&stuff->x);
+ swaps(&stuff->y);
+ return((* ProcVector[stuff->reqType])(client));
+}
+
+/* ProcImageText used for both ImageText8 and ImageText16 */
+
+int
+SProcImageText(ClientPtr client)
+{
+ REQUEST(xImageTextReq);
+ swaps(&stuff->length);
+ REQUEST_AT_LEAST_SIZE(xImageTextReq);
+ swapl(&stuff->drawable);
+ swapl(&stuff->gc);
+ swaps(&stuff->x);
+ swaps(&stuff->y);
+ return((* ProcVector[stuff->reqType])(client));
+}
+
+int
+SProcCreateColormap(ClientPtr client)
+{
+ REQUEST(xCreateColormapReq);
+ swaps(&stuff->length);
+ REQUEST_SIZE_MATCH(xCreateColormapReq);
+ swapl(&stuff->mid);
+ swapl(&stuff->window);
+ swapl(&stuff->visual);
+ return((* ProcVector[X_CreateColormap])(client));
+}
+
+
+int
+SProcCopyColormapAndFree(ClientPtr client)
+{
+ REQUEST(xCopyColormapAndFreeReq);
+ swaps(&stuff->length);
+ REQUEST_SIZE_MATCH(xCopyColormapAndFreeReq);
+ swapl(&stuff->mid);
+ swapl(&stuff->srcCmap);
+ return((* ProcVector[X_CopyColormapAndFree])(client));
+
+}
+
+int
+SProcAllocColor(ClientPtr client)
+{
+ REQUEST(xAllocColorReq);
+ swaps(&stuff->length);
+ REQUEST_SIZE_MATCH(xAllocColorReq);
+ swapl(&stuff->cmap);
+ swaps(&stuff->red);
+ swaps(&stuff->green);
+ swaps(&stuff->blue);
+ return((* ProcVector[X_AllocColor])(client));
+}
+
+int
+SProcAllocNamedColor(ClientPtr client)
+{
+ REQUEST(xAllocNamedColorReq);
+ swaps(&stuff->length);
+ REQUEST_AT_LEAST_SIZE(xAllocNamedColorReq);
+ swapl(&stuff->cmap);
+ swaps(&stuff->nbytes);
+ return((* ProcVector[X_AllocNamedColor])(client));
+}
+
+int
+SProcAllocColorCells(ClientPtr client)
+{
+ REQUEST(xAllocColorCellsReq);
+ swaps(&stuff->length);
+ REQUEST_SIZE_MATCH(xAllocColorCellsReq);
+ swapl(&stuff->cmap);
+ swaps(&stuff->colors);
+ swaps(&stuff->planes);
+ return((* ProcVector[X_AllocColorCells])(client));
+}
+
+int
+SProcAllocColorPlanes(ClientPtr client)
+{
+ REQUEST(xAllocColorPlanesReq);
+ swaps(&stuff->length);
+ REQUEST_SIZE_MATCH(xAllocColorPlanesReq);
+ swapl(&stuff->cmap);
+ swaps(&stuff->colors);
+ swaps(&stuff->red);
+ swaps(&stuff->green);
+ swaps(&stuff->blue);
+ return((* ProcVector[X_AllocColorPlanes])(client));
+}
+
+int
+SProcFreeColors(ClientPtr client)
+{
+ REQUEST(xFreeColorsReq);
+ swaps(&stuff->length);
+ REQUEST_AT_LEAST_SIZE(xFreeColorsReq);
+ swapl(&stuff->cmap);
+ swapl(&stuff->planeMask);
+ SwapRestL(stuff);
+ return((* ProcVector[X_FreeColors])(client));
+
+}
+
+void
+SwapColorItem(xColorItem *pItem)
+{
+ swapl(&pItem->pixel);
+ swaps(&pItem->red);
+ swaps(&pItem->green);
+ swaps(&pItem->blue);
+}
+
+int
+SProcStoreColors(ClientPtr client)
+{
+ long count;
+ xColorItem *pItem;
+
+ REQUEST(xStoreColorsReq);
+ swaps(&stuff->length);
+ REQUEST_AT_LEAST_SIZE(xStoreColorsReq);
+ swapl(&stuff->cmap);
+ pItem = (xColorItem *) &stuff[1];
+ for(count = LengthRestB(stuff)/sizeof(xColorItem); --count >= 0; )
+ SwapColorItem(pItem++);
+ return((* ProcVector[X_StoreColors])(client));
+}
+
+int
+SProcStoreNamedColor (ClientPtr client)
+{
+ REQUEST(xStoreNamedColorReq);
+ swaps(&stuff->length);
+ REQUEST_AT_LEAST_SIZE(xStoreNamedColorReq);
+ swapl(&stuff->cmap);
+ swapl(&stuff->pixel);
+ swaps(&stuff->nbytes);
+ return((* ProcVector[X_StoreNamedColor])(client));
+}
+
+int
+SProcQueryColors (ClientPtr client)
+{
+ REQUEST(xQueryColorsReq);
+ swaps(&stuff->length);
+ REQUEST_AT_LEAST_SIZE(xQueryColorsReq);
+ swapl(&stuff->cmap);
+ SwapRestL(stuff);
+ return((* ProcVector[X_QueryColors])(client));
+}
+
+int
+SProcLookupColor (ClientPtr client)
+{
+ REQUEST(xLookupColorReq);
+ swaps(&stuff->length);
+ REQUEST_AT_LEAST_SIZE(xLookupColorReq);
+ swapl(&stuff->cmap);
+ swaps(&stuff->nbytes);
+ return((* ProcVector[X_LookupColor])(client));
+}
+
+int
+SProcCreateCursor (ClientPtr client)
+{
+ REQUEST(xCreateCursorReq);
+ swaps(&stuff->length);
+ REQUEST_SIZE_MATCH(xCreateCursorReq);
+ swapl(&stuff->cid);
+ swapl(&stuff->source);
+ swapl(&stuff->mask);
+ swaps(&stuff->foreRed);
+ swaps(&stuff->foreGreen);
+ swaps(&stuff->foreBlue);
+ swaps(&stuff->backRed);
+ swaps(&stuff->backGreen);
+ swaps(&stuff->backBlue);
+ swaps(&stuff->x);
+ swaps(&stuff->y);
+ return((* ProcVector[X_CreateCursor])(client));
+}
+
+int
+SProcCreateGlyphCursor (ClientPtr client)
+{
+ REQUEST(xCreateGlyphCursorReq);
+ swaps(&stuff->length);
+ REQUEST_SIZE_MATCH(xCreateGlyphCursorReq);
+ swapl(&stuff->cid);
+ swapl(&stuff->source);
+ swapl(&stuff->mask);
+ swaps(&stuff->sourceChar);
+ swaps(&stuff->maskChar);
+ swaps(&stuff->foreRed);
+ swaps(&stuff->foreGreen);
+ swaps(&stuff->foreBlue);
+ swaps(&stuff->backRed);
+ swaps(&stuff->backGreen);
+ swaps(&stuff->backBlue);
+ return((* ProcVector[X_CreateGlyphCursor])(client));
+}
+
+
+int
+SProcRecolorCursor (ClientPtr client)
+{
+ REQUEST(xRecolorCursorReq);
+ swaps(&stuff->length);
+ REQUEST_SIZE_MATCH(xRecolorCursorReq);
+ swapl(&stuff->cursor);
+ swaps(&stuff->foreRed);
+ swaps(&stuff->foreGreen);
+ swaps(&stuff->foreBlue);
+ swaps(&stuff->backRed);
+ swaps(&stuff->backGreen);
+ swaps(&stuff->backBlue);
+ return((* ProcVector[X_RecolorCursor])(client));
+}
+
+int
+SProcQueryBestSize (ClientPtr client)
+{
+ REQUEST(xQueryBestSizeReq);
+ swaps(&stuff->length);
+ REQUEST_SIZE_MATCH(xQueryBestSizeReq);
+ swapl(&stuff->drawable);
+ swaps(&stuff->width);
+ swaps(&stuff->height);
+ return((* ProcVector[X_QueryBestSize])(client));
+
+}
+
+int
+SProcQueryExtension (ClientPtr client)
+{
+ REQUEST(xQueryExtensionReq);
+ swaps(&stuff->length);
+ REQUEST_AT_LEAST_SIZE(xQueryExtensionReq);
+ swaps(&stuff->nbytes);
+ return((* ProcVector[X_QueryExtension])(client));
+}
+
+int
+SProcChangeKeyboardMapping (ClientPtr client)
+{
+ REQUEST(xChangeKeyboardMappingReq);
+ swaps(&stuff->length);
+ REQUEST_AT_LEAST_SIZE(xChangeKeyboardMappingReq);
+ SwapRestL(stuff);
+ return((* ProcVector[X_ChangeKeyboardMapping])(client));
+}
+
+
+int
+SProcChangeKeyboardControl (ClientPtr client)
+{
+ REQUEST(xChangeKeyboardControlReq);
+ swaps(&stuff->length);
+ REQUEST_AT_LEAST_SIZE(xChangeKeyboardControlReq);
+ swapl(&stuff->mask);
+ SwapRestL(stuff);
+ return((* ProcVector[X_ChangeKeyboardControl])(client));
+}
+
+int
+SProcChangePointerControl (ClientPtr client)
+{
+ REQUEST(xChangePointerControlReq);
+ swaps(&stuff->length);
+ REQUEST_SIZE_MATCH(xChangePointerControlReq);
+ swaps(&stuff->accelNum);
+ swaps(&stuff->accelDenum);
+ swaps(&stuff->threshold);
+ return((* ProcVector[X_ChangePointerControl])(client));
+}
+
+
+int
+SProcSetScreenSaver (ClientPtr client)
+{
+ REQUEST(xSetScreenSaverReq);
+ swaps(&stuff->length);
+ REQUEST_SIZE_MATCH(xSetScreenSaverReq);
+ swaps(&stuff->timeout);
+ swaps(&stuff->interval);
+ return((* ProcVector[X_SetScreenSaver])(client));
+}
+
+int
+SProcChangeHosts (ClientPtr client)
+{
+ REQUEST(xChangeHostsReq);
+ swaps(&stuff->length);
+ REQUEST_AT_LEAST_SIZE(xChangeHostsReq);
+ swaps(&stuff->hostLength);
+ return((* ProcVector[X_ChangeHosts])(client));
+
+}
+
+int SProcRotateProperties (ClientPtr client)
+{
+ REQUEST(xRotatePropertiesReq);
+ swaps(&stuff->length);
+ REQUEST_AT_LEAST_SIZE(xRotatePropertiesReq);
+ swapl(&stuff->window);
+ swaps(&stuff->nAtoms);
+ swaps(&stuff->nPositions);
+ SwapRestL(stuff);
+ return ((* ProcVector[X_RotateProperties])(client));
+}
+
+int
+SProcNoOperation(ClientPtr client)
+{
+ REQUEST(xReq);
+ swaps(&stuff->length);
+ return ((* ProcVector[X_NoOperation])(client));
+}
+
+void
+SwapConnClientPrefix(xConnClientPrefix *pCCP)
+{
+ swaps(&pCCP->majorVersion);
+ swaps(&pCCP->minorVersion);
+ swaps(&pCCP->nbytesAuthProto);
+ swaps(&pCCP->nbytesAuthString);
+}