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