/************************************************************
Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts,
and the Massachusetts Institute of Technology, Cambridge, 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 names of Digital or MIT 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.

********************************************************/

/* $Header: swapreq.c,v 1.18 87/06/11 23:10:16 sue Exp $ */

#include "X.h"
#define NEED←REPLIES
#define NEED←EVENTS
#include "Xproto.h"
#include "Xprotostr.h"
#include "windowstr.h"
#include "font.h"
#include "gc.h"
#include "os.h"
#include "resource.h"
#include "selection.h"
#include "colormap.h"
#include "dixstruct.h"
#include "extension.h"
#include "input.h"
#include "cursor.h"

extern WindowRec WindowTable[];
extern xConnSetupPrefix connSetupPrefix;
extern char *ConnectionInfo;
extern char *SwappedConnInfo;
extern int (* ProcVector[256]) ();

/* Thanks to Jack Palevich for testing and subsequently rewriting all this */

#define LengthRestB(stuff) \
    ((stuff->length << 2) - sizeof(*stuff))

#define LengthRestS(stuff) \
    ((stuff->length << 1)  - (sizeof(*stuff) >> 1))

#define LengthRestL(stuff) \
    (stuff->length  - (sizeof(*stuff) >> 2))

#define SwapRestS(stuff) \
    SwapShorts((short *)(stuff + 1), (int)LengthRestS(stuff))

#define SwapRestL(stuff) \
    SwapLongs((long *)(stuff + 1), (int)LengthRestL(stuff))


int
SProcCreateWindow(client)
    register ClientPtr client;
{
    register int n;

    REQUEST(xCreateWindowReq);
    swaps(&stuff->length, n);
    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(client)
    register ClientPtr client;
{
    register int n;

    REQUEST(xChangeWindowAttributesReq);
    swaps(&stuff->length, n);
    swapl(&stuff->window, n);
    swapl(&stuff->valueMask, n);
    SwapRestL(stuff);
    return((* ProcVector[X←ChangeWindowAttributes])(client));
}

int
SProcGetWindowAttributes(client)
    register ClientPtr client;
{
    register int n;

    REQUEST(xResourceReq);
    swaps(&stuff->length, n);
    swapl(&stuff->id, n);
    return((* ProcVector[X←GetWindowAttributes])(client));

}

int
SProcDestroyWindow(client)
    register ClientPtr client;
{
    register int n;

    REQUEST(xResourceReq);

    swaps(&stuff->length, n);
    swapl(&stuff->id, n);
    return((* ProcVector[X←DestroyWindow])(client));
}

int
SProcDestroySubwindows(client)
    register ClientPtr client;
{
    register int n;

    REQUEST(xResourceReq);

    swaps(&stuff->length, n);
    swapl(&stuff->id, n);
    return((* ProcVector[X←DestroySubwindows])(client));
}

int
SProcChangeSaveSet(client)
    register ClientPtr client;
{
    register int n;
    REQUEST(xChangeSaveSetReq);
		  
    swaps(&stuff->length, n);
    swapl(&stuff->window, n);
    return((* ProcVector[X←ChangeSaveSet])(client));
}

int
SProcReparentWindow(client)
    register ClientPtr client;
{
    register int n;
    REQUEST(xReparentWindowReq);
    swaps(&stuff->length, n);
    swapl(&stuff->window, n);
    swapl(&stuff->parent, n);
    swaps(&stuff->x, n);
    swaps(&stuff->y, n);
    return((* ProcVector[X←ReparentWindow])(client));
}

int
SProcMapWindow(client)
    register ClientPtr client;
{
    register int n;
    REQUEST(xResourceReq);
    swaps(&stuff->length, n);
    swapl(&stuff->id, n);
    return((* ProcVector[X←MapWindow])(client));

}

int
SProcMapSubwindows(client)
    register ClientPtr client;
{
    register int n;
    REQUEST(xResourceReq);
    swaps(&stuff->length, n);
    swapl(&stuff->id, n);
    return((* ProcVector[X←MapSubwindows])(client));

}

int
SProcUnmapWindow(client)
    register ClientPtr client;
{
    register int n;

    REQUEST(xResourceReq);
    swaps(&stuff->length, n);
    swapl(&stuff->id, n);
    return((* ProcVector[X←UnmapWindow])(client));
}

int
SProcUnmapSubwindows(client)
    register ClientPtr client;
{
    register int n;
    REQUEST(xResourceReq);
    swaps(&stuff->length, n);
    swapl(&stuff->id, n);
    return((* ProcVector[X←GetWindowAttributes])(client));
}

int
SProcConfigureWindow(client)
    register ClientPtr client;
{
    register int n;
    REQUEST(xConfigureWindowReq);
    swaps(&stuff->length, n);
    swapl(&stuff->window, n);
    swaps(&stuff->mask, n);
    SwapRestL(stuff);
    return((* ProcVector[X←ConfigureWindow])(client));

}

int
SProcCirculateWindow(client)
    register ClientPtr client;
{
    register int n;
    REQUEST(xCirculateWindowReq);
    swaps(&stuff->length, n);
    swapl(&stuff->window, n);
    return((* ProcVector[X←CirculateWindow])(client));

}

int
SProcGetGeometry(client)
    register ClientPtr client;
{
    register int n;
    REQUEST(xResourceReq);
    
    swaps(&stuff->length, n);
    swapl(&stuff->id, n);
    return((* ProcVector[X←GetGeometry])(client));
}
int
SProcQueryTree(client)
    register ClientPtr client;
{

    register int n;
    REQUEST(xResourceReq);
    swaps(&stuff->length, n);
    swapl(&stuff->id, n);
    return((* ProcVector[X←QueryTree])(client));
}

int
SProcInternAtom(client)
    register ClientPtr client;
{
    register int n;
    REQUEST(xInternAtomReq);
    swaps(&stuff->length, n);
    swaps(&stuff->onlyIfExists, n);
    swaps(&stuff->nbytes, n);
}

int
SProcGetAtomName(client)
    register ClientPtr client;
{
    register int n;
    REQUEST(xResourceReq);
    swaps(&stuff->length, n);
    swapl(&stuff->id, n);
    return((* ProcVector[X←GetAtomName])(client));
}
int
SProcChangeProperty(client)
    register ClientPtr client;
{
    register int n;
    REQUEST(xChangePropertyReq);
    swaps(&stuff->length, n);
    swapl(&stuff->window, n);
    swapl(&stuff->property, n);
    swapl(&stuff->type, n);
    swapl(&stuff->nUnits, n);
    switch ( stuff->format ) {
        case 8 : break;
        case 16:
            SwapShorts((short *)(stuff + 1), (int)(stuff->nUnits));
	    break;
	case 32:
	    SwapLongs((long *)(stuff + 1), (int)(stuff->nUnits));
	    break;
	}
    return((* ProcVector[X←ChangeProperty])(client));
}

int 
SProcDeleteProperty(client)
    register ClientPtr client;
{
    register int n;
    REQUEST(xDeletePropertyReq);
    swaps(&stuff->length, n);
    swapl(&stuff->window, n);
    swapl(&stuff->property, n);
    return((* ProcVector[X←DeleteProperty])(client));
              
}

int 
SProcGetProperty(client)
    register ClientPtr client;
{
    register int n;
    REQUEST(xGetPropertyReq);
    swaps(&stuff->length, n);
    swaps(&stuff->delete, n);
    swapl(&stuff->window, n);
    swapl(&stuff->property, n);
    swapl(&stuff->type, n);
    return((* ProcVector[X←GetProperty])(client));
}

int
SProcListProperties(client)
    register ClientPtr client;
{
    register int n;

    REQUEST(xResourceReq);
    swaps(&stuff->length, n);
    swapl(&stuff->id, n);
    return((* ProcVector[X←ListProperties])(client));

}

int
SProcSetSelectionOwner(client)
    register ClientPtr client;
{
    register int n;
    REQUEST(xSetSelectionOwnerReq);
    swaps(&stuff->length, n);
    swapl(&stuff->window, n);
    swapl(&stuff->selection, n);
    swapl(&stuff->time, n);
}

int
SProcGetSelectionOwner(client)
    register ClientPtr client;
{
    register int n;
    REQUEST(xResourceReq);
    swaps(&stuff->length, n);
    swapl(&stuff->id, n);
    return((* ProcVector[X←GetSelectionOwner])(client));
}

int
SProcConvertSelection(client)
    register ClientPtr client;
{
    register int n;
    REQUEST(xConvertSelectionReq);
    swaps(&stuff->length, n);
    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(client)
    register ClientPtr client;
{
    register int n;
    xEvent *event;
    REQUEST(xSendEventReq);
    swaps(&stuff->length, n);
    swapl(&stuff->destination, n);
    swapl(&stuff->eventMask, n);
    /* Swap event */
    event = &stuff->event;
    swaps(&event->u.u.sequenceNumber, n);
    switch ( event->u.u.type )
    {
	    /* type keyButtonPointer */
	case KeyPress:
	case KeyRelease:
	case ButtonPress:
	case ButtonRelease:
	case MotionNotify:
	/* and, by coincidence, the same code will work for enterLeave */
	case EnterNotify:
	case LeaveNotify:
	    swapl(&event->u.keyButtonPointer.time, n);
	    swapl(&event->u.keyButtonPointer.root, n);
	    swapl(&event->u.keyButtonPointer.event, n);
	    swapl(&event->u.keyButtonPointer.child, n);
	    swaps(&event->u.keyButtonPointer.rootX, n);
	    swaps(&event->u.keyButtonPointer.rootY, n);
	    swaps(&event->u.keyButtonPointer.eventX, n);
	    swaps(&event->u.keyButtonPointer.eventY, n);
	    swaps(&event->u.keyButtonPointer.state, n);
	    break;
	/* focus */
	case FocusIn:
	case FocusOut:
	    swapl(&event->u.focus.window, n);
	    break;
	case KeymapNotify:
	    break;
	case Expose:
	    swapl(&event->u.expose.window, n);
	    swaps(&event->u.expose.x, n);
	    swaps(&event->u.expose.y, n);
	    swaps(&event->u.expose.width, n);
	    swaps(&event->u.expose.height, n);
	    break;
	case GraphicsExpose:
	    swapl(&event->u.graphicsExposure.drawable, n);
	    swaps(&event->u.graphicsExposure.x, n);
	    swaps(&event->u.graphicsExposure.y, n);
	    swaps(&event->u.graphicsExposure.width, n);
	    swaps(&event->u.graphicsExposure.height, n);
	    swaps(&event->u.graphicsExposure.minorEvent, n);
	    break;	    
	case NoExpose:
	    swapl(&event->u.noExposure.drawable, n);
	    swaps(&event->u.noExposure.minorEvent, n);
	    break;
	case VisibilityNotify:
	    swapl(&event->u.visibility.window, n);
	    break;
	case CreateNotify:
	    swapl(&event->u.createNotify.parent, n);
	    swapl(&event->u.createNotify.window, n);
	    swaps(&event->u.createNotify.x, n);
	    swaps(&event->u.createNotify.y, n);
	    swaps(&event->u.createNotify.width, n);
	    swaps(&event->u.createNotify.height, n);
	    swaps(&event->u.createNotify.borderWidth, n);
	    break;
	/* All four of these events can be swapped in the same way. */
	case DestroyNotify:
	case UnmapNotify:
	case MapNotify:
	case MapRequest:
	    swapl(&event->u.destroyNotify.event, n);
	    swapl(&event->u.destroyNotify.window, n);
	    break;
	case ReparentNotify:
	    swapl(&event->u.reparent.event, n);
	    swapl(&event->u.reparent.window, n);
	    swapl(&event->u.reparent.parent, n);
	    swaps(&event->u.reparent.x, n);
	    swaps(&event->u.reparent.y, n);
	    break;
	/* the next two events have identical swapping requirements */
	case ConfigureNotify:
	case ConfigureRequest:
	    swapl(&event->u.configureNotify.event, n);
	    swapl(&event->u.configureNotify.window, n);
	    swapl(&event->u.configureNotify.aboveSibling, n);
	    swaps(&event->u.configureNotify.x, n);
	    swaps(&event->u.configureNotify.y, n);
	    swaps(&event->u.configureNotify.width, n);
	    swaps(&event->u.configureNotify.height, n);
	    swaps(&event->u.configureNotify.borderWidth, n);
	    break;
	case GravityNotify:
	    swapl(&event->u.gravity.event, n);
	    swapl(&event->u.gravity.window, n);
	    swaps(&event->u.gravity.x, n);
	    swaps(&event->u.gravity.y, n);
	    break;
	case ResizeRequest:
	    swapl(&event->u.resizeRequest.window, n);
	    swaps(&event->u.resizeRequest.width, n);
	    swaps(&event->u.resizeRequest.height, n);
	    break;
	/* the next two events have identical swapping requirements */
	case CirculateNotify:
	case CirculateRequest:
	case PropertyNotify:
	case SelectionClear:
	    swapl(&event->u.circulate.event, n);
	    swapl(&event->u.circulate.window, n);
	    swapl(&event->u.circulate.parent, n);
	    break;
	case SelectionRequest:
	    swapl(&event->u.selectionRequest.time, n);
	    swapl(&event->u.selectionRequest.owner, n);
	    swapl(&event->u.selectionRequest.requestor, n);
	    swapl(&event->u.selectionRequest.selection, n);
	    swapl(&event->u.selectionRequest.target, n);
	    swapl(&event->u.selectionRequest.property, n);
	    break;
	case SelectionNotify:
	    swapl(&event->u.selectionNotify.time, n);
	    swapl(&event->u.selectionNotify.requestor, n);
	    swapl(&event->u.selectionNotify.selection, n);
	    swapl(&event->u.selectionNotify.target, n);
	    swapl(&event->u.selectionNotify.property, n);
	    break;
	case ColormapNotify:
	    swapl(&event->u.colormap.window, n);
	    swapl(&event->u.colormap.colormap, n);
	    break;
	case ClientMessage:
	    swapl(&event->u.clientMessage.window, n);
	    swapl(&event->u.clientMessage.u.l.type, n);  /* XXX */
	    /* XXX So, what do we do about swapping client message data
	     * (Is there any client message data?
	     */
	    break;
    }
    return((* ProcVector[X←SendEvent])(client));
}

int
SProcGrabPointer(client)
    register ClientPtr client;
{
    register int n;
    REQUEST(xGrabPointerReq);
    swaps(&stuff->length, n);
    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
SProcUngrabPointer(client)
    register ClientPtr client;
{
    register int n;

    REQUEST(xResourceReq);
    swaps(&stuff->length, n);
    swapl(&stuff->id, n);
    return((* ProcVector[X←UngrabPointer])(client));

}

int
SProcGrabButton(client)
    register ClientPtr client;
{
    register int n;
    REQUEST(xGrabButtonReq);
    swaps(&stuff->length, n);
    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(client)
    register ClientPtr client;
{
    register int n;
    REQUEST(xUngrabButtonReq);
    swaps(&stuff->length, n);
    swapl(&stuff->grabWindow, n);
    swaps(&stuff->modifiers, n);
    return((* ProcVector[X←UngrabButton])(client));
}

int
SProcChangeActivePointerGrab(client)
    register ClientPtr client;
{
    register int n;
    REQUEST(xChangeActivePointerGrabReq);
    swaps(&stuff->length, n);
    swapl(&stuff->cursor, n);
    swapl(&stuff->time, n);
    swaps(&stuff->eventMask, n);
    return((* ProcVector[X←ChangeActivePointerGrab])(client));
}

int
SProcGrabKeyboard(client)
    register ClientPtr client;
{
    register int n;
    REQUEST(xGrabKeyboardReq);
    swaps(&stuff->length, n);
    swapl(&stuff->grabWindow, n);
    swapl(&stuff->time, n);
    return((* ProcVector[X←GrabKeyboard])(client));
}

int
SProcUngrabKeyboard(client)
    register ClientPtr client;
{
    register int n;

    REQUEST(xResourceReq);
    swaps(&stuff->length, n);
    swapl(&stuff->id, n);
    return((* ProcVector[X←UngrabKeyboard])(client));

}

int
SProcGrabKey(client)
    register ClientPtr client;
{
    register int n;
    REQUEST(xGrabKeyReq);
    swaps(&stuff->length, n);
    swapl(&stuff->grabWindow, n);
    swaps(&stuff->modifiers, n);
    return((* ProcVector[X←GrabKey])(client));
}

int
SProcUngrabKey(client)
    register ClientPtr client;
{
    register int n;
    REQUEST(xUngrabKeyReq);
    swaps(&stuff->length, n);
    swapl(&stuff->grabWindow, n);
    swaps(&stuff->modifiers, n);
    return((* ProcVector[X←UngrabKey])(client));
}

int
SProcAllowEvents(client)
    register ClientPtr client;
{
    register int n;
    REQUEST(xAllowEventsReq);
    swaps(&stuff->length, n);
    swapl(&stuff->time, n);
    return((* ProcVector[X←AllowEvents])(client));
}

int
SProcGrabServer(client)
    register ClientPtr client;
{
    register int n;

    REQUEST(xResourceReq);
    swaps(&stuff->length, n);
    swapl(&stuff->id, n);
    return((* ProcVector[X←ListProperties])(client));

}

int
SProcUngrabServer(client)
    register ClientPtr client;
{
    register int n;

    REQUEST(xResourceReq);
    swaps(&stuff->length, n);
    swapl(&stuff->id, n);
    return((* ProcVector[X←UngrabServer])(client));

}

int
SProcQueryPointer(client)
    register ClientPtr client;
{
    register int n;

    REQUEST(xResourceReq);
    swaps(&stuff->length, n);
    swapl(&stuff->id, n);
    return((* ProcVector[X←QueryPointer])(client));

}

int
SProcGetMotionEvents(client)
    register ClientPtr client;
{
    register int n;
    REQUEST(xGetMotionEventsReq);
    swaps(&stuff->length, n);
    swapl(&stuff->window, n);
    swapl(&stuff->start, n);
    swapl(&stuff->stop, n);
    return((* ProcVector[X←GetMotionEvents])(client));
}

int
SProcTranslateCoords(client)
    register ClientPtr client;
{
    register int n;
    REQUEST(xTranslateCoordsReq);
    swaps(&stuff->length, n);
    swapl(&stuff->srcWid, n);
    swapl(&stuff->dstWid, n);
    swaps(&stuff->srcX, n);
    swaps(&stuff->srcY, n);
}

int
SProcWarpPointer(client)
    register ClientPtr client;
{
    register int n;
    REQUEST(xWarpPointerReq);
    swaps(&stuff->length, n);
    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(client)
    register ClientPtr client;
{
    register int n;
    REQUEST(xSetInputFocusReq);
    swaps(&stuff->length, n);
    swapl(&stuff->focus, n);
    swapl(&stuff->time, n);
    return((* ProcVector[X←SetInputFocus])(client));
}

int
SProcGetInputFocus(client)
    register ClientPtr client;
{
    register int n;
    REQUEST(xReq);
    swaps(&stuff->length, n);
    return((* ProcVector[X←GetInputFocus])(client));

}

int
SProcQueryKeymap(client)
    register ClientPtr client;
{
    register int n;
    REQUEST(xReq);
    swaps(&stuff->length, n);
    return((* ProcVector[X←QueryKeymap])(client));
}

SProcOpenFont(client)
    register ClientPtr client;
{
    register int n;
    REQUEST(xOpenFontReq);
    swaps(&stuff->length, n);
    swapl(&stuff->fid, n);
    swaps(&stuff->nbytes, n);
    return((* ProcVector[X←OpenFont])(client));
}

int
SProcCloseFont(client)
    register ClientPtr client;
{
    register int n;
    REQUEST(xResourceReq);
    swaps(&stuff->length, n);
    swapl(&stuff->id, n);
    return((* ProcVector[X←CloseFont])(client));
}

int
SProcQueryFont(client)
    register ClientPtr client;
{
    register int n;
    REQUEST(xResourceReq);
    swaps(&stuff->length, n);
    swapl(&stuff->id, n);
    return((* ProcVector[X←QueryFont])(client));
}

int
SProcQueryTextExtents(client)
    register ClientPtr client;
{
    register int n;
    REQUEST(xQueryTextExtentsReq);
    swaps(&stuff->length, n);
    swapl(&stuff->fid, n);
    return((* ProcVector[X←QueryTextExtents])(client));
}

int
SProcListFonts(client)
    register ClientPtr client;
{
    register int n;
    REQUEST(xListFontsReq);
    swaps(&stuff->length, n);
    swaps(&stuff->maxNames, n);
    swaps(&stuff->nbytes, n);
    return((* ProcVector[X←ListFonts])(client));
}

int
SProcListFontsWithInfo(client)
    register ClientPtr client;
{
    register int n;
    REQUEST(xListFontsWithInfoReq);
    swaps(&stuff->length, n);
    swaps(&stuff->maxNames, n);
    swaps(&stuff->nbytes, n);
    return((* ProcVector[X←ListFontsWithInfo])(client));
}

int
SProcSetFontPath(client)
    register ClientPtr client;
{
    register int n;
    REQUEST(xSetFontPathReq);
    swaps(&stuff->length, n);
    swaps(&stuff->nFonts, n);
    return((* ProcVector[X←SetFontPath])(client));
}

int
SProcCreatePixmap(client)
    register ClientPtr client;
{
    register int n;
    REQUEST(xCreatePixmapReq);

    swaps(&stuff->length, n);
    swapl(&stuff->pid, n);
    swapl(&stuff->drawable, n);
    swaps(&stuff->width, n);
    swaps(&stuff->height, n);
    return((* ProcVector[X←CreatePixmap])(client));
}

int
SProcFreePixmap(client)
    register ClientPtr client;
{
    register int n;
    REQUEST(xResourceReq);
    swaps(&stuff->length, n);
    swapl(&stuff->id, n);
    return((* ProcVector[X←FreePixmap])(client));
}

int
SProcCreateGC(client)
    register ClientPtr client;
{
    register int n;
    REQUEST(xCreateGCReq);
    swaps(&stuff->length, n);
    swapl(&stuff->gc, n);
    swapl(&stuff->drawable, n);
    swapl(&stuff->mask, n);
    SwapRestL(stuff);
    return((* ProcVector[X←CreateGC])(client));
}

int
SProcChangeGC(client)
    register ClientPtr client;
{
    register int n;
    REQUEST(xChangeGCReq);
    swaps(&stuff->length, n);
    swapl(&stuff->gc, n);
    swapl(&stuff->mask, n);
    SwapRestL(stuff);
    return((* ProcVector[X←ChangeGC])(client));
}

int
SProcCopyGC(client)
    register ClientPtr client;
{
    register int n;
    REQUEST(xCopyGCReq);
    swaps(&stuff->length, n);
    swapl(&stuff->srcGC, n);
    swapl(&stuff->dstGC, n);
    swapl(&stuff->mask, n);
    return((* ProcVector[X←CopyGC])(client));
}

int
SProcSetDashes(client)
    register ClientPtr client;
{
    register int n;
    REQUEST(xSetDashesReq);
    swaps(&stuff->length, n);
    swapl(&stuff->gc, n);
    swaps(&stuff->dashOffset, n);
    swaps(&stuff->nDashes, n);
    return((* ProcVector[X←SetDashes])(client));

}

int
SProcSetClipRectangles(client)
    register ClientPtr client;
{
    register int n;
    REQUEST(xSetClipRectanglesReq);
    swaps(&stuff->length, n);
    swapl(&stuff->gc, n);
    swaps(&stuff->xOrigin, n);
    swaps(&stuff->yOrigin, n);
    SwapRestS(stuff);
    return((* ProcVector[X←SetClipRectangles])(client));
}

int
SProcFreeGC(client)
    register ClientPtr client;
{
    register int n;
    REQUEST(xResourceReq);
    swaps(&stuff->length, n);
    swapl(&stuff->id, n);
    return((* ProcVector[X←FreeGC])(client));
}

int
SProcClearToBackground(client)
    register ClientPtr client;
{
    register int n;
    REQUEST(xClearAreaReq);
    swaps(&stuff->length, n);
    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(client)
    register ClientPtr client;
{
    register int n;
    REQUEST(xCopyAreaReq);
    swaps(&stuff->length, n);
    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));

}