xserver

xserver with xephyr scale patch
git clone https://git.neptards.moe/u3shit/xserver.git
Log | Files | Refs | README | LICENSE

swapreq.c (25727B)


      1 /************************************************************
      2 
      3 Copyright 1987, 1998  The Open Group
      4 
      5 Permission to use, copy, modify, distribute, and sell this software and its
      6 documentation for any purpose is hereby granted without fee, provided that
      7 the above copyright notice appear in all copies and that both that
      8 copyright notice and this permission notice appear in supporting
      9 documentation.
     10 
     11 The above copyright notice and this permission notice shall be included in
     12 all copies or substantial portions of the Software.
     13 
     14 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
     15 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
     16 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
     17 OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
     18 AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
     19 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
     20 
     21 Except as contained in this notice, the name of The Open Group shall not be
     22 used in advertising or otherwise to promote the sale, use or other dealings
     23 in this Software without prior written authorization from The Open Group.
     24 
     25 Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
     26 
     27                         All Rights Reserved
     28 
     29 Permission to use, copy, modify, and distribute this software and its
     30 documentation for any purpose and without fee is hereby granted,
     31 provided that the above copyright notice appear in all copies and that
     32 both that copyright notice and this permission notice appear in
     33 supporting documentation, and that the name of Digital not be
     34 used in advertising or publicity pertaining to distribution of the
     35 software without specific, written prior permission.
     36 
     37 DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
     38 ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
     39 DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
     40 ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
     41 WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
     42 ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
     43 SOFTWARE.
     44 
     45 ********************************************************/
     46 
     47 #ifdef HAVE_DIX_CONFIG_H
     48 #include <dix-config.h>
     49 #endif
     50 
     51 #include <X11/X.h>
     52 #include <X11/Xproto.h>
     53 #include <X11/Xprotostr.h>
     54 #include "misc.h"
     55 #include "dixstruct.h"
     56 #include "extnsionst.h"         /* for SendEvent */
     57 #include "swapreq.h"
     58 
     59 /* Thanks to Jack Palevich for testing and subsequently rewriting all this */
     60 
     61 /* Byte swap a list of longs */
     62 void
     63 SwapLongs(CARD32 *list, unsigned long count)
     64 {
     65     while (count >= 8) {
     66         swapl(list + 0);
     67         swapl(list + 1);
     68         swapl(list + 2);
     69         swapl(list + 3);
     70         swapl(list + 4);
     71         swapl(list + 5);
     72         swapl(list + 6);
     73         swapl(list + 7);
     74         list += 8;
     75         count -= 8;
     76     }
     77     if (count != 0) {
     78         do {
     79             swapl(list);
     80             list++;
     81         } while (--count != 0);
     82     }
     83 }
     84 
     85 /* Byte swap a list of shorts */
     86 void
     87 SwapShorts(short *list, unsigned long count)
     88 {
     89     while (count >= 16) {
     90         swaps(list + 0);
     91         swaps(list + 1);
     92         swaps(list + 2);
     93         swaps(list + 3);
     94         swaps(list + 4);
     95         swaps(list + 5);
     96         swaps(list + 6);
     97         swaps(list + 7);
     98         swaps(list + 8);
     99         swaps(list + 9);
    100         swaps(list + 10);
    101         swaps(list + 11);
    102         swaps(list + 12);
    103         swaps(list + 13);
    104         swaps(list + 14);
    105         swaps(list + 15);
    106         list += 16;
    107         count -= 16;
    108     }
    109     if (count != 0) {
    110         do {
    111             swaps(list);
    112             list++;
    113         } while (--count != 0);
    114     }
    115 }
    116 
    117 /* The following is used for all requests that have
    118    no fields to be swapped (except "length") */
    119 int _X_COLD
    120 SProcSimpleReq(ClientPtr client)
    121 {
    122     REQUEST(xReq);
    123     swaps(&stuff->length);
    124     return (*ProcVector[stuff->reqType]) (client);
    125 }
    126 
    127 /* The following is used for all requests that have
    128    only a single 32-bit field to be swapped, coming
    129    right after the "length" field */
    130 int _X_COLD
    131 SProcResourceReq(ClientPtr client)
    132 {
    133     REQUEST(xResourceReq);
    134     swaps(&stuff->length);
    135     REQUEST_AT_LEAST_SIZE(xResourceReq);        /* not EXACT */
    136     swapl(&stuff->id);
    137     return (*ProcVector[stuff->reqType]) (client);
    138 }
    139 
    140 int _X_COLD
    141 SProcCreateWindow(ClientPtr client)
    142 {
    143     REQUEST(xCreateWindowReq);
    144     swaps(&stuff->length);
    145     REQUEST_AT_LEAST_SIZE(xCreateWindowReq);
    146     swapl(&stuff->wid);
    147     swapl(&stuff->parent);
    148     swaps(&stuff->x);
    149     swaps(&stuff->y);
    150     swaps(&stuff->width);
    151     swaps(&stuff->height);
    152     swaps(&stuff->borderWidth);
    153     swaps(&stuff->class);
    154     swapl(&stuff->visual);
    155     swapl(&stuff->mask);
    156     SwapRestL(stuff);
    157     return ((*ProcVector[X_CreateWindow]) (client));
    158 }
    159 
    160 int _X_COLD
    161 SProcChangeWindowAttributes(ClientPtr client)
    162 {
    163     REQUEST(xChangeWindowAttributesReq);
    164     swaps(&stuff->length);
    165     REQUEST_AT_LEAST_SIZE(xChangeWindowAttributesReq);
    166     swapl(&stuff->window);
    167     swapl(&stuff->valueMask);
    168     SwapRestL(stuff);
    169     return ((*ProcVector[X_ChangeWindowAttributes]) (client));
    170 }
    171 
    172 int _X_COLD
    173 SProcReparentWindow(ClientPtr client)
    174 {
    175     REQUEST(xReparentWindowReq);
    176     swaps(&stuff->length);
    177     REQUEST_SIZE_MATCH(xReparentWindowReq);
    178     swapl(&stuff->window);
    179     swapl(&stuff->parent);
    180     swaps(&stuff->x);
    181     swaps(&stuff->y);
    182     return ((*ProcVector[X_ReparentWindow]) (client));
    183 }
    184 
    185 int _X_COLD
    186 SProcConfigureWindow(ClientPtr client)
    187 {
    188     REQUEST(xConfigureWindowReq);
    189     swaps(&stuff->length);
    190     REQUEST_AT_LEAST_SIZE(xConfigureWindowReq);
    191     swapl(&stuff->window);
    192     swaps(&stuff->mask);
    193     SwapRestL(stuff);
    194     return ((*ProcVector[X_ConfigureWindow]) (client));
    195 
    196 }
    197 
    198 int _X_COLD
    199 SProcInternAtom(ClientPtr client)
    200 {
    201     REQUEST(xInternAtomReq);
    202     swaps(&stuff->length);
    203     REQUEST_AT_LEAST_SIZE(xInternAtomReq);
    204     swaps(&stuff->nbytes);
    205     return ((*ProcVector[X_InternAtom]) (client));
    206 }
    207 
    208 int _X_COLD
    209 SProcChangeProperty(ClientPtr client)
    210 {
    211     REQUEST(xChangePropertyReq);
    212     swaps(&stuff->length);
    213     REQUEST_AT_LEAST_SIZE(xChangePropertyReq);
    214     swapl(&stuff->window);
    215     swapl(&stuff->property);
    216     swapl(&stuff->type);
    217     swapl(&stuff->nUnits);
    218     switch (stuff->format) {
    219     case 8:
    220         break;
    221     case 16:
    222         SwapRestS(stuff);
    223         break;
    224     case 32:
    225         SwapRestL(stuff);
    226         break;
    227     }
    228     return ((*ProcVector[X_ChangeProperty]) (client));
    229 }
    230 
    231 int _X_COLD
    232 SProcDeleteProperty(ClientPtr client)
    233 {
    234     REQUEST(xDeletePropertyReq);
    235     swaps(&stuff->length);
    236     REQUEST_SIZE_MATCH(xDeletePropertyReq);
    237     swapl(&stuff->window);
    238     swapl(&stuff->property);
    239     return ((*ProcVector[X_DeleteProperty]) (client));
    240 
    241 }
    242 
    243 int _X_COLD
    244 SProcGetProperty(ClientPtr client)
    245 {
    246     REQUEST(xGetPropertyReq);
    247     swaps(&stuff->length);
    248     REQUEST_SIZE_MATCH(xGetPropertyReq);
    249     swapl(&stuff->window);
    250     swapl(&stuff->property);
    251     swapl(&stuff->type);
    252     swapl(&stuff->longOffset);
    253     swapl(&stuff->longLength);
    254     return ((*ProcVector[X_GetProperty]) (client));
    255 }
    256 
    257 int _X_COLD
    258 SProcSetSelectionOwner(ClientPtr client)
    259 {
    260     REQUEST(xSetSelectionOwnerReq);
    261     swaps(&stuff->length);
    262     REQUEST_SIZE_MATCH(xSetSelectionOwnerReq);
    263     swapl(&stuff->window);
    264     swapl(&stuff->selection);
    265     swapl(&stuff->time);
    266     return ((*ProcVector[X_SetSelectionOwner]) (client));
    267 }
    268 
    269 int _X_COLD
    270 SProcConvertSelection(ClientPtr client)
    271 {
    272     REQUEST(xConvertSelectionReq);
    273     swaps(&stuff->length);
    274     REQUEST_SIZE_MATCH(xConvertSelectionReq);
    275     swapl(&stuff->requestor);
    276     swapl(&stuff->selection);
    277     swapl(&stuff->target);
    278     swapl(&stuff->property);
    279     swapl(&stuff->time);
    280     return ((*ProcVector[X_ConvertSelection]) (client));
    281 }
    282 
    283 int _X_COLD
    284 SProcSendEvent(ClientPtr client)
    285 {
    286     xEvent eventT = { .u.u.type = 0 };
    287     EventSwapPtr proc;
    288 
    289     REQUEST(xSendEventReq);
    290     swaps(&stuff->length);
    291     REQUEST_SIZE_MATCH(xSendEventReq);
    292     swapl(&stuff->destination);
    293     swapl(&stuff->eventMask);
    294 
    295     /* Generic events can have variable size, but SendEvent request holds
    296        exactly 32B of event data. */
    297     if (stuff->event.u.u.type == GenericEvent) {
    298         client->errorValue = stuff->event.u.u.type;
    299         return BadValue;
    300     }
    301 
    302     /* Swap event */
    303     proc = EventSwapVector[stuff->event.u.u.type & 0177];
    304     if (!proc || proc == NotImplemented)        /* no swapping proc; invalid event type? */
    305         return BadValue;
    306     (*proc) (&stuff->event, &eventT);
    307     stuff->event = eventT;
    308 
    309     return ((*ProcVector[X_SendEvent]) (client));
    310 }
    311 
    312 int _X_COLD
    313 SProcGrabPointer(ClientPtr client)
    314 {
    315     REQUEST(xGrabPointerReq);
    316     swaps(&stuff->length);
    317     REQUEST_SIZE_MATCH(xGrabPointerReq);
    318     swapl(&stuff->grabWindow);
    319     swaps(&stuff->eventMask);
    320     swapl(&stuff->confineTo);
    321     swapl(&stuff->cursor);
    322     swapl(&stuff->time);
    323     return ((*ProcVector[X_GrabPointer]) (client));
    324 }
    325 
    326 int _X_COLD
    327 SProcGrabButton(ClientPtr client)
    328 {
    329     REQUEST(xGrabButtonReq);
    330     swaps(&stuff->length);
    331     REQUEST_SIZE_MATCH(xGrabButtonReq);
    332     swapl(&stuff->grabWindow);
    333     swaps(&stuff->eventMask);
    334     swapl(&stuff->confineTo);
    335     swapl(&stuff->cursor);
    336     swaps(&stuff->modifiers);
    337     return ((*ProcVector[X_GrabButton]) (client));
    338 }
    339 
    340 int _X_COLD
    341 SProcUngrabButton(ClientPtr client)
    342 {
    343     REQUEST(xUngrabButtonReq);
    344     swaps(&stuff->length);
    345     REQUEST_SIZE_MATCH(xUngrabButtonReq);
    346     swapl(&stuff->grabWindow);
    347     swaps(&stuff->modifiers);
    348     return ((*ProcVector[X_UngrabButton]) (client));
    349 }
    350 
    351 int _X_COLD
    352 SProcChangeActivePointerGrab(ClientPtr client)
    353 {
    354     REQUEST(xChangeActivePointerGrabReq);
    355     swaps(&stuff->length);
    356     REQUEST_SIZE_MATCH(xChangeActivePointerGrabReq);
    357     swapl(&stuff->cursor);
    358     swapl(&stuff->time);
    359     swaps(&stuff->eventMask);
    360     return ((*ProcVector[X_ChangeActivePointerGrab]) (client));
    361 }
    362 
    363 int _X_COLD
    364 SProcGrabKeyboard(ClientPtr client)
    365 {
    366     REQUEST(xGrabKeyboardReq);
    367     swaps(&stuff->length);
    368     REQUEST_SIZE_MATCH(xGrabKeyboardReq);
    369     swapl(&stuff->grabWindow);
    370     swapl(&stuff->time);
    371     return ((*ProcVector[X_GrabKeyboard]) (client));
    372 }
    373 
    374 int _X_COLD
    375 SProcGrabKey(ClientPtr client)
    376 {
    377     REQUEST(xGrabKeyReq);
    378     swaps(&stuff->length);
    379     REQUEST_SIZE_MATCH(xGrabKeyReq);
    380     swapl(&stuff->grabWindow);
    381     swaps(&stuff->modifiers);
    382     return ((*ProcVector[X_GrabKey]) (client));
    383 }
    384 
    385 int _X_COLD
    386 SProcUngrabKey(ClientPtr client)
    387 {
    388     REQUEST(xUngrabKeyReq);
    389     swaps(&stuff->length);
    390     REQUEST_SIZE_MATCH(xUngrabKeyReq);
    391     swapl(&stuff->grabWindow);
    392     swaps(&stuff->modifiers);
    393     return ((*ProcVector[X_UngrabKey]) (client));
    394 }
    395 
    396 int _X_COLD
    397 SProcGetMotionEvents(ClientPtr client)
    398 {
    399     REQUEST(xGetMotionEventsReq);
    400     swaps(&stuff->length);
    401     REQUEST_SIZE_MATCH(xGetMotionEventsReq);
    402     swapl(&stuff->window);
    403     swapl(&stuff->start);
    404     swapl(&stuff->stop);
    405     return ((*ProcVector[X_GetMotionEvents]) (client));
    406 }
    407 
    408 int _X_COLD
    409 SProcTranslateCoords(ClientPtr client)
    410 {
    411     REQUEST(xTranslateCoordsReq);
    412     swaps(&stuff->length);
    413     REQUEST_SIZE_MATCH(xTranslateCoordsReq);
    414     swapl(&stuff->srcWid);
    415     swapl(&stuff->dstWid);
    416     swaps(&stuff->srcX);
    417     swaps(&stuff->srcY);
    418     return ((*ProcVector[X_TranslateCoords]) (client));
    419 }
    420 
    421 int _X_COLD
    422 SProcWarpPointer(ClientPtr client)
    423 {
    424     REQUEST(xWarpPointerReq);
    425     swaps(&stuff->length);
    426     REQUEST_SIZE_MATCH(xWarpPointerReq);
    427     swapl(&stuff->srcWid);
    428     swapl(&stuff->dstWid);
    429     swaps(&stuff->srcX);
    430     swaps(&stuff->srcY);
    431     swaps(&stuff->srcWidth);
    432     swaps(&stuff->srcHeight);
    433     swaps(&stuff->dstX);
    434     swaps(&stuff->dstY);
    435     return ((*ProcVector[X_WarpPointer]) (client));
    436 }
    437 
    438 int _X_COLD
    439 SProcSetInputFocus(ClientPtr client)
    440 {
    441     REQUEST(xSetInputFocusReq);
    442     swaps(&stuff->length);
    443     REQUEST_SIZE_MATCH(xSetInputFocusReq);
    444     swapl(&stuff->focus);
    445     swapl(&stuff->time);
    446     return ((*ProcVector[X_SetInputFocus]) (client));
    447 }
    448 
    449 int _X_COLD
    450 SProcOpenFont(ClientPtr client)
    451 {
    452     REQUEST(xOpenFontReq);
    453     swaps(&stuff->length);
    454     REQUEST_AT_LEAST_SIZE(xOpenFontReq);
    455     swapl(&stuff->fid);
    456     swaps(&stuff->nbytes);
    457     return ((*ProcVector[X_OpenFont]) (client));
    458 }
    459 
    460 int _X_COLD
    461 SProcListFonts(ClientPtr client)
    462 {
    463     REQUEST(xListFontsReq);
    464     swaps(&stuff->length);
    465     REQUEST_AT_LEAST_SIZE(xListFontsReq);
    466     swaps(&stuff->maxNames);
    467     swaps(&stuff->nbytes);
    468     return ((*ProcVector[X_ListFonts]) (client));
    469 }
    470 
    471 int _X_COLD
    472 SProcListFontsWithInfo(ClientPtr client)
    473 {
    474     REQUEST(xListFontsWithInfoReq);
    475     swaps(&stuff->length);
    476     REQUEST_AT_LEAST_SIZE(xListFontsWithInfoReq);
    477     swaps(&stuff->maxNames);
    478     swaps(&stuff->nbytes);
    479     return ((*ProcVector[X_ListFontsWithInfo]) (client));
    480 }
    481 
    482 int _X_COLD
    483 SProcSetFontPath(ClientPtr client)
    484 {
    485     REQUEST(xSetFontPathReq);
    486     swaps(&stuff->length);
    487     REQUEST_AT_LEAST_SIZE(xSetFontPathReq);
    488     swaps(&stuff->nFonts);
    489     return ((*ProcVector[X_SetFontPath]) (client));
    490 }
    491 
    492 int _X_COLD
    493 SProcCreatePixmap(ClientPtr client)
    494 {
    495     REQUEST(xCreatePixmapReq);
    496 
    497     swaps(&stuff->length);
    498     REQUEST_SIZE_MATCH(xCreatePixmapReq);
    499     swapl(&stuff->pid);
    500     swapl(&stuff->drawable);
    501     swaps(&stuff->width);
    502     swaps(&stuff->height);
    503     return ((*ProcVector[X_CreatePixmap]) (client));
    504 }
    505 
    506 int _X_COLD
    507 SProcCreateGC(ClientPtr client)
    508 {
    509     REQUEST(xCreateGCReq);
    510     swaps(&stuff->length);
    511     REQUEST_AT_LEAST_SIZE(xCreateGCReq);
    512     swapl(&stuff->gc);
    513     swapl(&stuff->drawable);
    514     swapl(&stuff->mask);
    515     SwapRestL(stuff);
    516     return ((*ProcVector[X_CreateGC]) (client));
    517 }
    518 
    519 int _X_COLD
    520 SProcChangeGC(ClientPtr client)
    521 {
    522     REQUEST(xChangeGCReq);
    523     swaps(&stuff->length);
    524     REQUEST_AT_LEAST_SIZE(xChangeGCReq);
    525     swapl(&stuff->gc);
    526     swapl(&stuff->mask);
    527     SwapRestL(stuff);
    528     return ((*ProcVector[X_ChangeGC]) (client));
    529 }
    530 
    531 int _X_COLD
    532 SProcCopyGC(ClientPtr client)
    533 {
    534     REQUEST(xCopyGCReq);
    535     swaps(&stuff->length);
    536     REQUEST_SIZE_MATCH(xCopyGCReq);
    537     swapl(&stuff->srcGC);
    538     swapl(&stuff->dstGC);
    539     swapl(&stuff->mask);
    540     return ((*ProcVector[X_CopyGC]) (client));
    541 }
    542 
    543 int _X_COLD
    544 SProcSetDashes(ClientPtr client)
    545 {
    546     REQUEST(xSetDashesReq);
    547     swaps(&stuff->length);
    548     REQUEST_AT_LEAST_SIZE(xSetDashesReq);
    549     swapl(&stuff->gc);
    550     swaps(&stuff->dashOffset);
    551     swaps(&stuff->nDashes);
    552     return ((*ProcVector[X_SetDashes]) (client));
    553 
    554 }
    555 
    556 int _X_COLD
    557 SProcSetClipRectangles(ClientPtr client)
    558 {
    559     REQUEST(xSetClipRectanglesReq);
    560     swaps(&stuff->length);
    561     REQUEST_AT_LEAST_SIZE(xSetClipRectanglesReq);
    562     swapl(&stuff->gc);
    563     swaps(&stuff->xOrigin);
    564     swaps(&stuff->yOrigin);
    565     SwapRestS(stuff);
    566     return ((*ProcVector[X_SetClipRectangles]) (client));
    567 }
    568 
    569 int _X_COLD
    570 SProcClearToBackground(ClientPtr client)
    571 {
    572     REQUEST(xClearAreaReq);
    573     swaps(&stuff->length);
    574     REQUEST_SIZE_MATCH(xClearAreaReq);
    575     swapl(&stuff->window);
    576     swaps(&stuff->x);
    577     swaps(&stuff->y);
    578     swaps(&stuff->width);
    579     swaps(&stuff->height);
    580     return ((*ProcVector[X_ClearArea]) (client));
    581 }
    582 
    583 int _X_COLD
    584 SProcCopyArea(ClientPtr client)
    585 {
    586     REQUEST(xCopyAreaReq);
    587     swaps(&stuff->length);
    588     REQUEST_SIZE_MATCH(xCopyAreaReq);
    589     swapl(&stuff->srcDrawable);
    590     swapl(&stuff->dstDrawable);
    591     swapl(&stuff->gc);
    592     swaps(&stuff->srcX);
    593     swaps(&stuff->srcY);
    594     swaps(&stuff->dstX);
    595     swaps(&stuff->dstY);
    596     swaps(&stuff->width);
    597     swaps(&stuff->height);
    598     return ((*ProcVector[X_CopyArea]) (client));
    599 }
    600 
    601 int _X_COLD
    602 SProcCopyPlane(ClientPtr client)
    603 {
    604     REQUEST(xCopyPlaneReq);
    605     swaps(&stuff->length);
    606     REQUEST_SIZE_MATCH(xCopyPlaneReq);
    607     swapl(&stuff->srcDrawable);
    608     swapl(&stuff->dstDrawable);
    609     swapl(&stuff->gc);
    610     swaps(&stuff->srcX);
    611     swaps(&stuff->srcY);
    612     swaps(&stuff->dstX);
    613     swaps(&stuff->dstY);
    614     swaps(&stuff->width);
    615     swaps(&stuff->height);
    616     swapl(&stuff->bitPlane);
    617     return ((*ProcVector[X_CopyPlane]) (client));
    618 }
    619 
    620 /* The following routine is used for all Poly drawing requests
    621    (except FillPoly, which uses a different request format) */
    622 int _X_COLD
    623 SProcPoly(ClientPtr client)
    624 {
    625     REQUEST(xPolyPointReq);
    626     swaps(&stuff->length);
    627     REQUEST_AT_LEAST_SIZE(xPolyPointReq);
    628     swapl(&stuff->drawable);
    629     swapl(&stuff->gc);
    630     SwapRestS(stuff);
    631     return ((*ProcVector[stuff->reqType]) (client));
    632 }
    633 
    634 /* cannot use SProcPoly for this one, because xFillPolyReq
    635    is longer than xPolyPointReq, and we don't want to swap
    636    the difference as shorts! */
    637 int _X_COLD
    638 SProcFillPoly(ClientPtr client)
    639 {
    640     REQUEST(xFillPolyReq);
    641     swaps(&stuff->length);
    642     REQUEST_AT_LEAST_SIZE(xFillPolyReq);
    643     swapl(&stuff->drawable);
    644     swapl(&stuff->gc);
    645     SwapRestS(stuff);
    646     return ((*ProcVector[X_FillPoly]) (client));
    647 }
    648 
    649 int _X_COLD
    650 SProcPutImage(ClientPtr client)
    651 {
    652     REQUEST(xPutImageReq);
    653     swaps(&stuff->length);
    654     REQUEST_AT_LEAST_SIZE(xPutImageReq);
    655     swapl(&stuff->drawable);
    656     swapl(&stuff->gc);
    657     swaps(&stuff->width);
    658     swaps(&stuff->height);
    659     swaps(&stuff->dstX);
    660     swaps(&stuff->dstY);
    661     /* Image should already be swapped */
    662     return ((*ProcVector[X_PutImage]) (client));
    663 
    664 }
    665 
    666 int _X_COLD
    667 SProcGetImage(ClientPtr client)
    668 {
    669     REQUEST(xGetImageReq);
    670     swaps(&stuff->length);
    671     REQUEST_SIZE_MATCH(xGetImageReq);
    672     swapl(&stuff->drawable);
    673     swaps(&stuff->x);
    674     swaps(&stuff->y);
    675     swaps(&stuff->width);
    676     swaps(&stuff->height);
    677     swapl(&stuff->planeMask);
    678     return ((*ProcVector[X_GetImage]) (client));
    679 }
    680 
    681 /* ProcPolyText used for both PolyText8 and PolyText16 */
    682 
    683 int _X_COLD
    684 SProcPolyText(ClientPtr client)
    685 {
    686     REQUEST(xPolyTextReq);
    687     swaps(&stuff->length);
    688     REQUEST_AT_LEAST_SIZE(xPolyTextReq);
    689     swapl(&stuff->drawable);
    690     swapl(&stuff->gc);
    691     swaps(&stuff->x);
    692     swaps(&stuff->y);
    693     return ((*ProcVector[stuff->reqType]) (client));
    694 }
    695 
    696 /* ProcImageText used for both ImageText8 and ImageText16 */
    697 
    698 int _X_COLD
    699 SProcImageText(ClientPtr client)
    700 {
    701     REQUEST(xImageTextReq);
    702     swaps(&stuff->length);
    703     REQUEST_AT_LEAST_SIZE(xImageTextReq);
    704     swapl(&stuff->drawable);
    705     swapl(&stuff->gc);
    706     swaps(&stuff->x);
    707     swaps(&stuff->y);
    708     return ((*ProcVector[stuff->reqType]) (client));
    709 }
    710 
    711 int _X_COLD
    712 SProcCreateColormap(ClientPtr client)
    713 {
    714     REQUEST(xCreateColormapReq);
    715     swaps(&stuff->length);
    716     REQUEST_SIZE_MATCH(xCreateColormapReq);
    717     swapl(&stuff->mid);
    718     swapl(&stuff->window);
    719     swapl(&stuff->visual);
    720     return ((*ProcVector[X_CreateColormap]) (client));
    721 }
    722 
    723 int _X_COLD
    724 SProcCopyColormapAndFree(ClientPtr client)
    725 {
    726     REQUEST(xCopyColormapAndFreeReq);
    727     swaps(&stuff->length);
    728     REQUEST_SIZE_MATCH(xCopyColormapAndFreeReq);
    729     swapl(&stuff->mid);
    730     swapl(&stuff->srcCmap);
    731     return ((*ProcVector[X_CopyColormapAndFree]) (client));
    732 
    733 }
    734 
    735 int _X_COLD
    736 SProcAllocColor(ClientPtr client)
    737 {
    738     REQUEST(xAllocColorReq);
    739     swaps(&stuff->length);
    740     REQUEST_SIZE_MATCH(xAllocColorReq);
    741     swapl(&stuff->cmap);
    742     swaps(&stuff->red);
    743     swaps(&stuff->green);
    744     swaps(&stuff->blue);
    745     return ((*ProcVector[X_AllocColor]) (client));
    746 }
    747 
    748 int _X_COLD
    749 SProcAllocNamedColor(ClientPtr client)
    750 {
    751     REQUEST(xAllocNamedColorReq);
    752     swaps(&stuff->length);
    753     REQUEST_AT_LEAST_SIZE(xAllocNamedColorReq);
    754     swapl(&stuff->cmap);
    755     swaps(&stuff->nbytes);
    756     return ((*ProcVector[X_AllocNamedColor]) (client));
    757 }
    758 
    759 int _X_COLD
    760 SProcAllocColorCells(ClientPtr client)
    761 {
    762     REQUEST(xAllocColorCellsReq);
    763     swaps(&stuff->length);
    764     REQUEST_SIZE_MATCH(xAllocColorCellsReq);
    765     swapl(&stuff->cmap);
    766     swaps(&stuff->colors);
    767     swaps(&stuff->planes);
    768     return ((*ProcVector[X_AllocColorCells]) (client));
    769 }
    770 
    771 int _X_COLD
    772 SProcAllocColorPlanes(ClientPtr client)
    773 {
    774     REQUEST(xAllocColorPlanesReq);
    775     swaps(&stuff->length);
    776     REQUEST_SIZE_MATCH(xAllocColorPlanesReq);
    777     swapl(&stuff->cmap);
    778     swaps(&stuff->colors);
    779     swaps(&stuff->red);
    780     swaps(&stuff->green);
    781     swaps(&stuff->blue);
    782     return ((*ProcVector[X_AllocColorPlanes]) (client));
    783 }
    784 
    785 int _X_COLD
    786 SProcFreeColors(ClientPtr client)
    787 {
    788     REQUEST(xFreeColorsReq);
    789     swaps(&stuff->length);
    790     REQUEST_AT_LEAST_SIZE(xFreeColorsReq);
    791     swapl(&stuff->cmap);
    792     swapl(&stuff->planeMask);
    793     SwapRestL(stuff);
    794     return ((*ProcVector[X_FreeColors]) (client));
    795 
    796 }
    797 
    798 void _X_COLD
    799 SwapColorItem(xColorItem * pItem)
    800 {
    801     swapl(&pItem->pixel);
    802     swaps(&pItem->red);
    803     swaps(&pItem->green);
    804     swaps(&pItem->blue);
    805 }
    806 
    807 int _X_COLD
    808 SProcStoreColors(ClientPtr client)
    809 {
    810     long count;
    811     xColorItem *pItem;
    812 
    813     REQUEST(xStoreColorsReq);
    814     swaps(&stuff->length);
    815     REQUEST_AT_LEAST_SIZE(xStoreColorsReq);
    816     swapl(&stuff->cmap);
    817     pItem = (xColorItem *) &stuff[1];
    818     for (count = LengthRestB(stuff) / sizeof(xColorItem); --count >= 0;)
    819         SwapColorItem(pItem++);
    820     return ((*ProcVector[X_StoreColors]) (client));
    821 }
    822 
    823 int _X_COLD
    824 SProcStoreNamedColor(ClientPtr client)
    825 {
    826     REQUEST(xStoreNamedColorReq);
    827     swaps(&stuff->length);
    828     REQUEST_AT_LEAST_SIZE(xStoreNamedColorReq);
    829     swapl(&stuff->cmap);
    830     swapl(&stuff->pixel);
    831     swaps(&stuff->nbytes);
    832     return ((*ProcVector[X_StoreNamedColor]) (client));
    833 }
    834 
    835 int _X_COLD
    836 SProcQueryColors(ClientPtr client)
    837 {
    838     REQUEST(xQueryColorsReq);
    839     swaps(&stuff->length);
    840     REQUEST_AT_LEAST_SIZE(xQueryColorsReq);
    841     swapl(&stuff->cmap);
    842     SwapRestL(stuff);
    843     return ((*ProcVector[X_QueryColors]) (client));
    844 }
    845 
    846 int _X_COLD
    847 SProcLookupColor(ClientPtr client)
    848 {
    849     REQUEST(xLookupColorReq);
    850     swaps(&stuff->length);
    851     REQUEST_AT_LEAST_SIZE(xLookupColorReq);
    852     swapl(&stuff->cmap);
    853     swaps(&stuff->nbytes);
    854     return ((*ProcVector[X_LookupColor]) (client));
    855 }
    856 
    857 int _X_COLD
    858 SProcCreateCursor(ClientPtr client)
    859 {
    860     REQUEST(xCreateCursorReq);
    861     swaps(&stuff->length);
    862     REQUEST_SIZE_MATCH(xCreateCursorReq);
    863     swapl(&stuff->cid);
    864     swapl(&stuff->source);
    865     swapl(&stuff->mask);
    866     swaps(&stuff->foreRed);
    867     swaps(&stuff->foreGreen);
    868     swaps(&stuff->foreBlue);
    869     swaps(&stuff->backRed);
    870     swaps(&stuff->backGreen);
    871     swaps(&stuff->backBlue);
    872     swaps(&stuff->x);
    873     swaps(&stuff->y);
    874     return ((*ProcVector[X_CreateCursor]) (client));
    875 }
    876 
    877 int _X_COLD
    878 SProcCreateGlyphCursor(ClientPtr client)
    879 {
    880     REQUEST(xCreateGlyphCursorReq);
    881     swaps(&stuff->length);
    882     REQUEST_SIZE_MATCH(xCreateGlyphCursorReq);
    883     swapl(&stuff->cid);
    884     swapl(&stuff->source);
    885     swapl(&stuff->mask);
    886     swaps(&stuff->sourceChar);
    887     swaps(&stuff->maskChar);
    888     swaps(&stuff->foreRed);
    889     swaps(&stuff->foreGreen);
    890     swaps(&stuff->foreBlue);
    891     swaps(&stuff->backRed);
    892     swaps(&stuff->backGreen);
    893     swaps(&stuff->backBlue);
    894     return ((*ProcVector[X_CreateGlyphCursor]) (client));
    895 }
    896 
    897 int _X_COLD
    898 SProcRecolorCursor(ClientPtr client)
    899 {
    900     REQUEST(xRecolorCursorReq);
    901     swaps(&stuff->length);
    902     REQUEST_SIZE_MATCH(xRecolorCursorReq);
    903     swapl(&stuff->cursor);
    904     swaps(&stuff->foreRed);
    905     swaps(&stuff->foreGreen);
    906     swaps(&stuff->foreBlue);
    907     swaps(&stuff->backRed);
    908     swaps(&stuff->backGreen);
    909     swaps(&stuff->backBlue);
    910     return ((*ProcVector[X_RecolorCursor]) (client));
    911 }
    912 
    913 int _X_COLD
    914 SProcQueryBestSize(ClientPtr client)
    915 {
    916     REQUEST(xQueryBestSizeReq);
    917     swaps(&stuff->length);
    918     REQUEST_SIZE_MATCH(xQueryBestSizeReq);
    919     swapl(&stuff->drawable);
    920     swaps(&stuff->width);
    921     swaps(&stuff->height);
    922     return ((*ProcVector[X_QueryBestSize]) (client));
    923 
    924 }
    925 
    926 int _X_COLD
    927 SProcQueryExtension(ClientPtr client)
    928 {
    929     REQUEST(xQueryExtensionReq);
    930     swaps(&stuff->length);
    931     REQUEST_AT_LEAST_SIZE(xQueryExtensionReq);
    932     swaps(&stuff->nbytes);
    933     return ((*ProcVector[X_QueryExtension]) (client));
    934 }
    935 
    936 int _X_COLD
    937 SProcChangeKeyboardMapping(ClientPtr client)
    938 {
    939     REQUEST(xChangeKeyboardMappingReq);
    940     swaps(&stuff->length);
    941     REQUEST_AT_LEAST_SIZE(xChangeKeyboardMappingReq);
    942     SwapRestL(stuff);
    943     return ((*ProcVector[X_ChangeKeyboardMapping]) (client));
    944 }
    945 
    946 int _X_COLD
    947 SProcChangeKeyboardControl(ClientPtr client)
    948 {
    949     REQUEST(xChangeKeyboardControlReq);
    950     swaps(&stuff->length);
    951     REQUEST_AT_LEAST_SIZE(xChangeKeyboardControlReq);
    952     swapl(&stuff->mask);
    953     SwapRestL(stuff);
    954     return ((*ProcVector[X_ChangeKeyboardControl]) (client));
    955 }
    956 
    957 int _X_COLD
    958 SProcChangePointerControl(ClientPtr client)
    959 {
    960     REQUEST(xChangePointerControlReq);
    961     swaps(&stuff->length);
    962     REQUEST_SIZE_MATCH(xChangePointerControlReq);
    963     swaps(&stuff->accelNum);
    964     swaps(&stuff->accelDenum);
    965     swaps(&stuff->threshold);
    966     return ((*ProcVector[X_ChangePointerControl]) (client));
    967 }
    968 
    969 int _X_COLD
    970 SProcSetScreenSaver(ClientPtr client)
    971 {
    972     REQUEST(xSetScreenSaverReq);
    973     swaps(&stuff->length);
    974     REQUEST_SIZE_MATCH(xSetScreenSaverReq);
    975     swaps(&stuff->timeout);
    976     swaps(&stuff->interval);
    977     return ((*ProcVector[X_SetScreenSaver]) (client));
    978 }
    979 
    980 int _X_COLD
    981 SProcChangeHosts(ClientPtr client)
    982 {
    983     REQUEST(xChangeHostsReq);
    984     swaps(&stuff->length);
    985     REQUEST_AT_LEAST_SIZE(xChangeHostsReq);
    986     swaps(&stuff->hostLength);
    987     return ((*ProcVector[X_ChangeHosts]) (client));
    988 
    989 }
    990 
    991 int _X_COLD
    992 SProcRotateProperties(ClientPtr client)
    993 {
    994     REQUEST(xRotatePropertiesReq);
    995     swaps(&stuff->length);
    996     REQUEST_AT_LEAST_SIZE(xRotatePropertiesReq);
    997     swapl(&stuff->window);
    998     swaps(&stuff->nAtoms);
    999     swaps(&stuff->nPositions);
   1000     SwapRestL(stuff);
   1001     return ((*ProcVector[X_RotateProperties]) (client));
   1002 }
   1003 
   1004 int _X_COLD
   1005 SProcNoOperation(ClientPtr client)
   1006 {
   1007     REQUEST(xReq);
   1008     swaps(&stuff->length);
   1009     return ((*ProcVector[X_NoOperation]) (client));
   1010 }
   1011 
   1012 void _X_COLD
   1013 SwapConnClientPrefix(xConnClientPrefix * pCCP)
   1014 {
   1015     swaps(&pCCP->majorVersion);
   1016     swaps(&pCCP->minorVersion);
   1017     swaps(&pCCP->nbytesAuthProto);
   1018     swaps(&pCCP->nbytesAuthString);
   1019 }