1 /************************************************************
3 Copyright (c) 1987 X Consortium
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:
12 The above copyright notice and this permission notice shall be included in
13 all copies or substantial portions of the Software.
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.
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.
27 Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
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.
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
47 ********************************************************/
49 /* $XConsortium: swaprep.c /main/25 1995/12/08 13:39:45 dpw $ */
50 /* $XFree86: xc/programs/Xserver/dix/swaprep.c,v 3.2 1996/04/15 11:19:58 dawes Exp $ */
57 #include "dixstruct.h"
58 #include "fontstruct.h"
59 #include "scrnintstr.h"
62 static void SwapFontInfo(
63 #if NeedFunctionPrototypes
64 xQueryFontReply * /* pr */
69 static void SwapCharInfo(
70 #if NeedFunctionPrototypes
71 xCharInfo * /* pInfo */
76 #if NeedFunctionPrototypes
77 xQueryFontReply * /* pr */,
83 /* Thanks to Jack Palevich for testing and subsequently rewriting all this */
85 Swap32Write(pClient, size, pbuf)
87 int size; /* in bytes */
88 register CARD32 *pbuf;
94 for(i = 0; i < size; i++)
95 /* brackets are mandatory here, because "swapl" macro expands
96 to several statements */
100 (void)WriteToClient(pClient, size << 2, (char *) pbuf);
104 CopySwap32Write(pClient, size, pbuf)
106 int size; /* in bytes */
111 register CARD32 *from, *to, *fromLast, *toLast;
114 /* Allocate as big a buffer as we can... */
115 while (!(pbufT = (CARD32 *) ALLOCATE_LOCAL(bufsize)))
125 /* convert lengths from # of bytes to # of longs */
130 fromLast = from + size;
131 while (from < fromLast) {
134 toLast = to + min (bufsize, fromLast - from);
135 nbytes = (toLast - to) << 2;
136 while (to < toLast) {
137 /* can't write "cpswapl(*from++, *to++)" because cpswapl is a macro
138 that evaulates its args more than once */
143 (void)WriteToClient (pClient, nbytes, (char *) pbufT);
147 DEALLOCATE_LOCAL ((char *) pbufT);
151 CopySwap16Write(pClient, size, pbuf)
153 int size; /* in bytes */
158 register short *from, *to, *fromLast, *toLast;
161 /* Allocate as big a buffer as we can... */
162 while (!(pbufT = (short *) ALLOCATE_LOCAL(bufsize)))
172 /* convert lengths from # of bytes to # of shorts */
177 fromLast = from + size;
178 while (from < fromLast) {
181 toLast = to + min (bufsize, fromLast - from);
182 nbytes = (toLast - to) << 1;
183 while (to < toLast) {
184 /* can't write "cpswaps(*from++, *to++)" because cpswaps is a macro
185 that evaulates its args more than once */
190 (void)WriteToClient (pClient, nbytes, (char *) pbufT);
194 DEALLOCATE_LOCAL ((char *) pbufT);
198 /* Extra-small reply */
200 SGenericReply(pClient, size, pRep)
207 swaps(&pRep->sequenceNumber, n);
208 (void)WriteToClient(pClient, size, (char *) pRep);
211 /* Extra-large reply */
213 SGetWindowAttributesReply(pClient, size, pRep)
216 xGetWindowAttributesReply *pRep;
220 swaps(&pRep->sequenceNumber, n);
221 swapl(&pRep->length, n);
222 swapl(&pRep->visualID, n);
223 swaps(&pRep->class, n);
224 swapl(&pRep->backingBitPlanes, n);
225 swapl(&pRep->backingPixel, n);
226 swapl(&pRep->colormap, n);
227 swapl(&pRep->allEventMasks, n);
228 swapl(&pRep->yourEventMask, n);
229 swaps(&pRep->doNotPropagateMask, n);
230 (void)WriteToClient(pClient, size, (char *) pRep);
234 SGetGeometryReply(pClient, size, pRep)
237 xGetGeometryReply *pRep;
241 swaps(&pRep->sequenceNumber, n);
242 swapl(&pRep->root, n);
245 swaps(&pRep->width, n);
246 swaps(&pRep->height, n);
247 swaps(&pRep->borderWidth, n);
248 (void)WriteToClient(pClient, size, (char *) pRep);
252 SQueryTreeReply(pClient, size, pRep)
255 xQueryTreeReply *pRep;
259 swaps(&pRep->sequenceNumber, n);
260 swapl(&pRep->length, n);
261 swapl(&pRep->root, n);
262 swapl(&pRep->parent, n);
263 swaps(&pRep->nChildren, n);
264 (void)WriteToClient(pClient, size, (char *) pRep);
268 SInternAtomReply(pClient, size, pRep)
271 xInternAtomReply *pRep;
275 swaps(&pRep->sequenceNumber, n);
276 swapl(&pRep->atom, n);
277 (void)WriteToClient(pClient, size, (char *) pRep);
281 SGetAtomNameReply(pClient, size, pRep)
284 xGetAtomNameReply *pRep;
288 swaps(&pRep->sequenceNumber, n);
289 swapl(&pRep->length, n);
290 swaps(&pRep->nameLength, n);
291 (void)WriteToClient(pClient, size, (char *) pRep);
296 SGetPropertyReply(pClient, size, pRep)
299 xGetPropertyReply *pRep;
303 swaps(&pRep->sequenceNumber, n);
304 swapl(&pRep->length, n);
305 swapl(&pRep->propertyType, n);
306 swapl(&pRep->bytesAfter, n);
307 swapl(&pRep->nItems, n);
308 (void)WriteToClient(pClient, size, (char *) pRep);
312 SListPropertiesReply(pClient, size, pRep)
315 xListPropertiesReply *pRep;
319 swaps(&pRep->sequenceNumber, n);
320 swapl(&pRep->length, n);
321 swaps(&pRep->nProperties, n);
322 (void)WriteToClient(pClient, size, (char *) pRep);
326 SGetSelectionOwnerReply(pClient, size, pRep)
329 xGetSelectionOwnerReply *pRep;
333 swaps(&pRep->sequenceNumber, n);
334 swapl(&pRep->owner, n);
335 (void)WriteToClient(pClient, size, (char *) pRep);
340 SQueryPointerReply(pClient, size, pRep)
343 xQueryPointerReply *pRep;
347 swaps(&pRep->sequenceNumber, n);
348 swapl(&pRep->root, n);
349 swapl(&pRep->child, n);
350 swaps(&pRep->rootX, n);
351 swaps(&pRep->rootY, n);
352 swaps(&pRep->winX, n);
353 swaps(&pRep->winY, n);
354 swaps(&pRep->mask, n);
355 (void)WriteToClient(pClient, size, (char *) pRep);
359 SwapTimecoord(pCoord)
364 swapl(&pCoord->time, n);
365 swaps(&pCoord->x, n);
366 swaps(&pCoord->y, n);
370 SwapTimeCoordWrite(pClient, size, pRep)
378 n = size / sizeof(xTimecoord);
380 for(i = 0; i < n; i++)
382 SwapTimecoord(pRepT);
385 (void)WriteToClient(pClient, size, (char *) pRep);
389 SGetMotionEventsReply(pClient, size, pRep)
392 xGetMotionEventsReply *pRep;
396 swaps(&pRep->sequenceNumber, n);
397 swapl(&pRep->length, n);
398 swapl(&pRep->nEvents, n);
399 (void)WriteToClient(pClient, size, (char *) pRep);
403 STranslateCoordsReply(pClient, size, pRep)
406 xTranslateCoordsReply *pRep;
410 swaps(&pRep->sequenceNumber, n);
411 swapl(&pRep->child, n);
412 swaps(&pRep->dstX, n);
413 swaps(&pRep->dstY, n);
414 (void)WriteToClient(pClient, size, (char *) pRep);
418 SGetInputFocusReply(pClient, size, pRep)
421 xGetInputFocusReply *pRep;
425 swaps(&pRep->sequenceNumber, n);
426 swapl(&pRep->focus, n);
427 (void)WriteToClient(pClient, size, (char *) pRep);
430 /* extra long reply */
432 SQueryKeymapReply(pClient, size, pRep)
435 xQueryKeymapReply *pRep;
439 swaps(&pRep->sequenceNumber, n);
440 swapl(&pRep->length, n);
441 (void)WriteToClient(pClient, size, (char *) pRep);
453 swaps(&pInfo->leftSideBearing, n);
454 swaps(&pInfo->rightSideBearing, n);
455 swaps(&pInfo->characterWidth, n);
456 swaps(&pInfo->ascent, n);
457 swaps(&pInfo->descent, n);
458 swaps(&pInfo->attributes, n);
467 swaps(&pr->minCharOrByte2, n);
468 swaps(&pr->maxCharOrByte2, n);
469 swaps(&pr->defaultChar, n);
470 swaps(&pr->nFontProps, n);
471 swaps(&pr->fontAscent, n);
472 swaps(&pr->fontDescent, n);
473 SwapCharInfo( &pr->minBounds);
474 SwapCharInfo( &pr->maxBounds);
475 swapl(&pr->nCharInfos, n);
482 SwapFont( pr, hasGlyphs)
483 xQueryFontReply * pr;
488 unsigned nchars, nprops;
492 swaps(&pr->sequenceNumber, n);
493 swapl(&pr->length, n);
494 nchars = pr->nCharInfos;
495 nprops = pr->nFontProps;
497 pby = (char *) &pr[1];
498 /* Font properties are an atom and either an int32 or a CARD32, so
499 * they are always 2 4 byte values */
500 for(i = 0; i < nprops; i++)
509 pxci = (xCharInfo *)pby;
510 for(i = 0; i< nchars; i++, pxci++)
516 SQueryFontReply(pClient, size, pRep)
519 xQueryFontReply *pRep;
521 SwapFont(pRep, TRUE);
522 (void)WriteToClient(pClient, size, (char *) pRep);
526 SQueryTextExtentsReply(pClient, size, pRep)
529 xQueryTextExtentsReply *pRep;
533 swaps(&pRep->sequenceNumber, n);
534 swaps(&pRep->fontAscent, n);
535 swaps(&pRep->fontDescent, n);
536 swaps(&pRep->overallAscent, n);
537 swaps(&pRep->overallDescent, n);
538 swapl(&pRep->overallWidth, n);
539 swapl(&pRep->overallLeft, n);
540 swapl(&pRep->overallRight, n);
541 (void)WriteToClient(pClient, size, (char *) pRep);
545 SListFontsReply(pClient, size, pRep)
548 xListFontsReply *pRep;
552 swaps(&pRep->sequenceNumber, n);
553 swapl(&pRep->length, n);
554 swaps(&pRep->nFonts, n);
555 (void)WriteToClient(pClient, size, (char *) pRep);
559 SListFontsWithInfoReply(pClient, size, pRep)
562 xListFontsWithInfoReply *pRep;
564 SwapFont((xQueryFontReply *)pRep, FALSE);
565 (void)WriteToClient(pClient, size, (char *) pRep);
569 SGetFontPathReply(pClient, size, pRep)
572 xGetFontPathReply *pRep;
576 swaps(&pRep->sequenceNumber, n);
577 swapl(&pRep->length, n);
578 swaps(&pRep->nPaths, n);
579 (void)WriteToClient(pClient, size, (char *) pRep);
583 SGetImageReply(pClient, size, pRep)
586 xGetImageReply *pRep;
590 swaps(&pRep->sequenceNumber, n);
591 swapl(&pRep->length, n);
592 swapl(&pRep->visual, n);
593 (void)WriteToClient(pClient, size, (char *) pRep);
594 /* Fortunately, image doesn't need swapping */
598 SListInstalledColormapsReply(pClient, size, pRep)
601 xListInstalledColormapsReply *pRep;
605 swaps(&pRep->sequenceNumber, n);
606 swapl(&pRep->length, n);
607 swaps(&pRep->nColormaps, n);
608 (void)WriteToClient(pClient, size, (char *) pRep);
612 SAllocColorReply(pClient, size, pRep)
615 xAllocColorReply *pRep;
619 swaps(&pRep->sequenceNumber, n);
620 swaps(&pRep->red, n);
621 swaps(&pRep->green, n);
622 swaps(&pRep->blue, n);
623 swapl(&pRep->pixel, n);
624 (void)WriteToClient(pClient, size, (char *) pRep);
628 SAllocNamedColorReply(pClient, size, pRep)
631 xAllocNamedColorReply *pRep;
635 swaps(&pRep->sequenceNumber, n);
636 swapl(&pRep->pixel, n);
637 swaps(&pRep->exactRed, n);
638 swaps(&pRep->exactGreen, n);
639 swaps(&pRep->exactBlue, n);
640 swaps(&pRep->screenRed, n);
641 swaps(&pRep->screenGreen, n);
642 swaps(&pRep->screenBlue, n);
643 (void)WriteToClient(pClient, size, (char *) pRep);
647 SAllocColorCellsReply(pClient, size, pRep)
650 xAllocColorCellsReply *pRep;
654 swaps(&pRep->sequenceNumber, n);
655 swapl(&pRep->length, n);
656 swaps(&pRep->nPixels, n);
657 swaps(&pRep->nMasks, n);
658 (void)WriteToClient(pClient, size, (char *) pRep);
663 SAllocColorPlanesReply(pClient, size, pRep)
666 xAllocColorPlanesReply *pRep;
670 swaps(&pRep->sequenceNumber, n);
671 swapl(&pRep->length, n);
672 swaps(&pRep->nPixels, n);
673 swapl(&pRep->redMask, n);
674 swapl(&pRep->greenMask, n);
675 swapl(&pRep->blueMask, n);
676 (void)WriteToClient(pClient, size, (char *) pRep);
685 swaps(&prgb->red, n);
686 swaps(&prgb->green, n);
687 swaps(&prgb->blue, n);
691 SQColorsExtend(pClient, size, prgb)
699 n = size / sizeof(xrgb);
701 for(i = 0; i < n; i++)
706 (void)WriteToClient(pClient, size, (char *) prgb);
710 SQueryColorsReply(pClient, size, pRep)
713 xQueryColorsReply *pRep;
717 swaps(&pRep->sequenceNumber, n);
718 swapl(&pRep->length, n);
719 swaps(&pRep->nColors, n);
720 (void)WriteToClient(pClient, size, (char *) pRep);
724 SLookupColorReply(pClient, size, pRep)
727 xLookupColorReply *pRep;
731 swaps(&pRep->sequenceNumber, n);
732 swaps(&pRep->exactRed, n);
733 swaps(&pRep->exactGreen, n);
734 swaps(&pRep->exactBlue, n);
735 swaps(&pRep->screenRed, n);
736 swaps(&pRep->screenGreen, n);
737 swaps(&pRep->screenBlue, n);
738 (void)WriteToClient(pClient, size, (char *) pRep);
742 SQueryBestSizeReply(pClient, size, pRep)
745 xQueryBestSizeReply *pRep;
749 swaps(&pRep->sequenceNumber, n);
750 swaps(&pRep->width, n);
751 swaps(&pRep->height, n);
752 (void)WriteToClient(pClient, size, (char *) pRep);
756 SListExtensionsReply(pClient, size, pRep)
759 xListExtensionsReply *pRep;
763 swaps(&pRep->sequenceNumber, n);
764 swapl(&pRep->length, n);
765 (void)WriteToClient(pClient, size, (char *) pRep);
769 SGetKeyboardMappingReply(pClient, size, pRep)
772 xGetKeyboardMappingReply *pRep;
776 swaps(&pRep->sequenceNumber, n);
777 swapl(&pRep->length, n);
778 (void)WriteToClient(pClient, size, (char *) pRep);
782 SGetPointerMappingReply(pClient, size, pRep)
785 xGetPointerMappingReply *pRep;
789 swaps(&pRep->sequenceNumber, n);
790 swapl(&pRep->length, n);
791 (void)WriteToClient(pClient, size, (char *) pRep);
795 SGetModifierMappingReply(pClient, size, pRep)
798 xGetModifierMappingReply *pRep;
802 swaps(&pRep->sequenceNumber, n);
803 swapl(&pRep->length, n);
804 (void)WriteToClient(pClient, size, (char *) pRep);
808 SGetKeyboardControlReply(pClient, size, pRep)
811 xGetKeyboardControlReply *pRep;
815 swaps(&pRep->sequenceNumber, n);
816 swapl(&pRep->length, n);
817 swapl(&pRep->ledMask, n);
818 swaps(&pRep->bellPitch, n);
819 swaps(&pRep->bellDuration, n);
820 (void)WriteToClient(pClient, size, (char *) pRep);
824 SGetPointerControlReply(pClient, size, pRep)
827 xGetPointerControlReply *pRep;
831 swaps(&pRep->sequenceNumber, n);
832 swaps(&pRep->accelNumerator, n);
833 swaps(&pRep->accelDenominator, n);
834 swaps(&pRep->threshold, n);
835 (void)WriteToClient(pClient, size, (char *) pRep);
839 SGetScreenSaverReply(pClient, size, pRep)
842 xGetScreenSaverReply *pRep;
846 swaps(&pRep->sequenceNumber, n);
847 swaps(&pRep->timeout, n);
848 swaps(&pRep->interval, n);
849 (void)WriteToClient(pClient, size, (char *) pRep);
853 SLHostsExtend(pClient, size, buf)
859 char *endbuf = buf + size;
860 while (bufT < endbuf) {
861 xHostEntry *host = (xHostEntry *) bufT;
862 int len = host->length;
864 swaps (&host->length, n);
865 bufT += sizeof (xHostEntry) + (((len + 3) >> 2) << 2);
867 (void)WriteToClient (pClient, size, buf);
871 SListHostsReply(pClient, size, pRep)
874 xListHostsReply *pRep;
878 swaps(&pRep->sequenceNumber, n);
879 swapl(&pRep->length, n);
880 swaps(&pRep->nHosts, n);
881 (void)WriteToClient(pClient, size, (char *) pRep);
887 SErrorEvent(from, to)
891 to->errorCode = from->errorCode;
892 cpswaps(from->sequenceNumber, to->sequenceNumber);
893 cpswapl(from->resourceID, to->resourceID);
894 cpswaps(from->minorCode, to->minorCode);
895 to->majorCode = from->majorCode;
899 SKeyButtonPtrEvent(from, to)
902 to->u.u.type = from->u.u.type;
903 to->u.u.detail = from->u.u.detail;
904 cpswaps(from->u.u.sequenceNumber, to->u.u.sequenceNumber);
905 cpswapl(from->u.keyButtonPointer.time,
906 to->u.keyButtonPointer.time);
907 cpswapl(from->u.keyButtonPointer.root,
908 to->u.keyButtonPointer.root);
909 cpswapl(from->u.keyButtonPointer.event,
910 to->u.keyButtonPointer.event);
911 cpswapl(from->u.keyButtonPointer.child,
912 to->u.keyButtonPointer.child);
913 cpswaps(from->u.keyButtonPointer.rootX,
914 to->u.keyButtonPointer.rootX);
915 cpswaps(from->u.keyButtonPointer.rootY,
916 to->u.keyButtonPointer.rootY);
917 cpswaps(from->u.keyButtonPointer.eventX,
918 to->u.keyButtonPointer.eventX);
919 cpswaps(from->u.keyButtonPointer.eventY,
920 to->u.keyButtonPointer.eventY);
921 cpswaps(from->u.keyButtonPointer.state,
922 to->u.keyButtonPointer.state);
923 to->u.keyButtonPointer.sameScreen =
924 from->u.keyButtonPointer.sameScreen;
928 SEnterLeaveEvent(from, to)
931 to->u.u.type = from->u.u.type;
932 to->u.u.detail = from->u.u.detail;
933 cpswaps(from->u.u.sequenceNumber, to->u.u.sequenceNumber);
934 cpswapl(from->u.enterLeave.time, to->u.enterLeave.time);
935 cpswapl(from->u.enterLeave.root, to->u.enterLeave.root);
936 cpswapl(from->u.enterLeave.event, to->u.enterLeave.event);
937 cpswapl(from->u.enterLeave.child, to->u.enterLeave.child);
938 cpswaps(from->u.enterLeave.rootX, to->u.enterLeave.rootX);
939 cpswaps(from->u.enterLeave.rootY, to->u.enterLeave.rootY);
940 cpswaps(from->u.enterLeave.eventX, to->u.enterLeave.eventX);
941 cpswaps(from->u.enterLeave.eventY, to->u.enterLeave.eventY);
942 cpswaps(from->u.enterLeave.state, to->u.enterLeave.state);
943 to->u.enterLeave.mode = from->u.enterLeave.mode;
944 to->u.enterLeave.flags = from->u.enterLeave.flags;
948 SFocusEvent(from, to)
951 to->u.u.type = from->u.u.type;
952 to->u.u.detail = from->u.u.detail;
953 cpswaps(from->u.u.sequenceNumber, to->u.u.sequenceNumber);
954 cpswapl(from->u.focus.window, to->u.focus.window);
955 to->u.focus.mode = from->u.focus.mode;
959 SExposeEvent(from, to)
962 to->u.u.type = from->u.u.type;
963 cpswaps(from->u.u.sequenceNumber, to->u.u.sequenceNumber);
964 cpswapl(from->u.expose.window, to->u.expose.window);
965 cpswaps(from->u.expose.x, to->u.expose.x);
966 cpswaps(from->u.expose.y, to->u.expose.y);
967 cpswaps(from->u.expose.width, to->u.expose.width);
968 cpswaps(from->u.expose.height, to->u.expose.height);
969 cpswaps(from->u.expose.count, to->u.expose.count);
973 SGraphicsExposureEvent(from, to)
976 to->u.u.type = from->u.u.type;
977 cpswaps(from->u.u.sequenceNumber, to->u.u.sequenceNumber);
978 cpswapl(from->u.graphicsExposure.drawable,
979 to->u.graphicsExposure.drawable);
980 cpswaps(from->u.graphicsExposure.x,
981 to->u.graphicsExposure.x);
982 cpswaps(from->u.graphicsExposure.y,
983 to->u.graphicsExposure.y);
984 cpswaps(from->u.graphicsExposure.width,
985 to->u.graphicsExposure.width);
986 cpswaps(from->u.graphicsExposure.height,
987 to->u.graphicsExposure.height);
988 cpswaps(from->u.graphicsExposure.minorEvent,
989 to->u.graphicsExposure.minorEvent);
990 cpswaps(from->u.graphicsExposure.count,
991 to->u.graphicsExposure.count);
992 to->u.graphicsExposure.majorEvent =
993 from->u.graphicsExposure.majorEvent;
997 SNoExposureEvent(from, to)
1000 to->u.u.type = from->u.u.type;
1001 cpswaps(from->u.u.sequenceNumber, to->u.u.sequenceNumber);
1002 cpswapl(from->u.noExposure.drawable, to->u.noExposure.drawable);
1003 cpswaps(from->u.noExposure.minorEvent, to->u.noExposure.minorEvent);
1004 to->u.noExposure.majorEvent = from->u.noExposure.majorEvent;
1008 SVisibilityEvent(from, to)
1011 to->u.u.type = from->u.u.type;
1012 cpswaps(from->u.u.sequenceNumber, to->u.u.sequenceNumber);
1013 cpswapl(from->u.visibility.window, to->u.visibility.window);
1014 to->u.visibility.state = from->u.visibility.state;
1018 SCreateNotifyEvent(from, to)
1021 to->u.u.type = from->u.u.type;
1022 cpswaps(from->u.u.sequenceNumber, to->u.u.sequenceNumber);
1023 cpswapl(from->u.createNotify.window, to->u.createNotify.window);
1024 cpswapl(from->u.createNotify.parent, to->u.createNotify.parent);
1025 cpswaps(from->u.createNotify.x, to->u.createNotify.x);
1026 cpswaps(from->u.createNotify.y, to->u.createNotify.y);
1027 cpswaps(from->u.createNotify.width, to->u.createNotify.width);
1028 cpswaps(from->u.createNotify.height, to->u.createNotify.height);
1029 cpswaps(from->u.createNotify.borderWidth,
1030 to->u.createNotify.borderWidth);
1031 to->u.createNotify.override = from->u.createNotify.override;
1035 SDestroyNotifyEvent(from, to)
1038 to->u.u.type = from->u.u.type;
1039 cpswaps(from->u.u.sequenceNumber, to->u.u.sequenceNumber);
1040 cpswapl(from->u.destroyNotify.event, to->u.destroyNotify.event);
1041 cpswapl(from->u.destroyNotify.window, to->u.destroyNotify.window);
1045 SUnmapNotifyEvent(from, to)
1048 to->u.u.type = from->u.u.type;
1049 cpswaps(from->u.u.sequenceNumber, to->u.u.sequenceNumber);
1050 cpswapl(from->u.unmapNotify.event, to->u.unmapNotify.event);
1051 cpswapl(from->u.unmapNotify.window, to->u.unmapNotify.window);
1052 to->u.unmapNotify.fromConfigure = from->u.unmapNotify.fromConfigure;
1056 SMapNotifyEvent(from, to)
1059 to->u.u.type = from->u.u.type;
1060 cpswaps(from->u.u.sequenceNumber, to->u.u.sequenceNumber);
1061 cpswapl(from->u.mapNotify.event, to->u.mapNotify.event);
1062 cpswapl(from->u.mapNotify.window, to->u.mapNotify.window);
1063 to->u.mapNotify.override = from->u.mapNotify.override;
1067 SMapRequestEvent(from, to)
1070 to->u.u.type = from->u.u.type;
1071 cpswaps(from->u.u.sequenceNumber, to->u.u.sequenceNumber);
1072 cpswapl(from->u.mapRequest.parent, to->u.mapRequest.parent);
1073 cpswapl(from->u.mapRequest.window, to->u.mapRequest.window);
1077 SReparentEvent(from, to)
1080 to->u.u.type = from->u.u.type;
1081 cpswaps(from->u.u.sequenceNumber, to->u.u.sequenceNumber);
1082 cpswapl(from->u.reparent.event, to->u.reparent.event);
1083 cpswapl(from->u.reparent.window, to->u.reparent.window);
1084 cpswapl(from->u.reparent.parent, to->u.reparent.parent);
1085 cpswaps(from->u.reparent.x, to->u.reparent.x);
1086 cpswaps(from->u.reparent.y, to->u.reparent.y);
1087 to->u.reparent.override = from->u.reparent.override;
1091 SConfigureNotifyEvent(from, to)
1094 to->u.u.type = from->u.u.type;
1095 cpswaps(from->u.u.sequenceNumber, to->u.u.sequenceNumber);
1096 cpswapl(from->u.configureNotify.event,
1097 to->u.configureNotify.event);
1098 cpswapl(from->u.configureNotify.window,
1099 to->u.configureNotify.window);
1100 cpswapl(from->u.configureNotify.aboveSibling,
1101 to->u.configureNotify.aboveSibling);
1102 cpswaps(from->u.configureNotify.x, to->u.configureNotify.x);
1103 cpswaps(from->u.configureNotify.y, to->u.configureNotify.y);
1104 cpswaps(from->u.configureNotify.width, to->u.configureNotify.width);
1105 cpswaps(from->u.configureNotify.height,
1106 to->u.configureNotify.height);
1107 cpswaps(from->u.configureNotify.borderWidth,
1108 to->u.configureNotify.borderWidth);
1109 to->u.configureNotify.override = from->u.configureNotify.override;
1113 SConfigureRequestEvent(from, to)
1116 to->u.u.type = from->u.u.type;
1117 to->u.u.detail = from->u.u.detail; /* actually stack-mode */
1118 cpswaps(from->u.u.sequenceNumber, to->u.u.sequenceNumber);
1119 cpswapl(from->u.configureRequest.parent,
1120 to->u.configureRequest.parent);
1121 cpswapl(from->u.configureRequest.window,
1122 to->u.configureRequest.window);
1123 cpswapl(from->u.configureRequest.sibling,
1124 to->u.configureRequest.sibling);
1125 cpswaps(from->u.configureRequest.x, to->u.configureRequest.x);
1126 cpswaps(from->u.configureRequest.y, to->u.configureRequest.y);
1127 cpswaps(from->u.configureRequest.width,
1128 to->u.configureRequest.width);
1129 cpswaps(from->u.configureRequest.height,
1130 to->u.configureRequest.height);
1131 cpswaps(from->u.configureRequest.borderWidth,
1132 to->u.configureRequest.borderWidth);
1133 cpswaps(from->u.configureRequest.valueMask,
1134 to->u.configureRequest.valueMask);
1139 SGravityEvent(from, to)
1142 to->u.u.type = from->u.u.type;
1143 cpswaps(from->u.u.sequenceNumber, to->u.u.sequenceNumber);
1144 cpswapl(from->u.gravity.event, to->u.gravity.event);
1145 cpswapl(from->u.gravity.window, to->u.gravity.window);
1146 cpswaps(from->u.gravity.x, to->u.gravity.x);
1147 cpswaps(from->u.gravity.y, to->u.gravity.y);
1151 SResizeRequestEvent(from, to)
1154 to->u.u.type = from->u.u.type;
1155 cpswaps(from->u.u.sequenceNumber, to->u.u.sequenceNumber);
1156 cpswapl(from->u.resizeRequest.window, to->u.resizeRequest.window);
1157 cpswaps(from->u.resizeRequest.width, to->u.resizeRequest.width);
1158 cpswaps(from->u.resizeRequest.height, to->u.resizeRequest.height);
1162 SCirculateEvent(from, to)
1165 to->u.u.type = from->u.u.type;
1166 to->u.u.detail = from->u.u.detail;
1167 cpswaps(from->u.u.sequenceNumber, to->u.u.sequenceNumber);
1168 cpswapl(from->u.circulate.event, to->u.circulate.event);
1169 cpswapl(from->u.circulate.window, to->u.circulate.window);
1170 cpswapl(from->u.circulate.parent, to->u.circulate.parent);
1171 to->u.circulate.place = from->u.circulate.place;
1175 SPropertyEvent(from, to)
1178 to->u.u.type = from->u.u.type;
1179 cpswaps(from->u.u.sequenceNumber, to->u.u.sequenceNumber);
1180 cpswapl(from->u.property.window, to->u.property.window);
1181 cpswapl(from->u.property.atom, to->u.property.atom);
1182 cpswapl(from->u.property.time, to->u.property.time);
1183 to->u.property.state = from->u.property.state;
1187 SSelectionClearEvent(from, to)
1190 to->u.u.type = from->u.u.type;
1191 cpswaps(from->u.u.sequenceNumber, to->u.u.sequenceNumber);
1192 cpswapl(from->u.selectionClear.time, to->u.selectionClear.time);
1193 cpswapl(from->u.selectionClear.window, to->u.selectionClear.window);
1194 cpswapl(from->u.selectionClear.atom, to->u.selectionClear.atom);
1198 SSelectionRequestEvent(from, to)
1201 to->u.u.type = from->u.u.type;
1202 cpswaps(from->u.u.sequenceNumber, to->u.u.sequenceNumber);
1203 cpswapl(from->u.selectionRequest.time, to->u.selectionRequest.time);
1204 cpswapl(from->u.selectionRequest.owner,
1205 to->u.selectionRequest.owner);
1206 cpswapl(from->u.selectionRequest.requestor,
1207 to->u.selectionRequest.requestor);
1208 cpswapl(from->u.selectionRequest.selection,
1209 to->u.selectionRequest.selection);
1210 cpswapl(from->u.selectionRequest.target,
1211 to->u.selectionRequest.target);
1212 cpswapl(from->u.selectionRequest.property,
1213 to->u.selectionRequest.property);
1217 SSelectionNotifyEvent(from, to)
1220 to->u.u.type = from->u.u.type;
1221 cpswaps(from->u.u.sequenceNumber, to->u.u.sequenceNumber);
1222 cpswapl(from->u.selectionNotify.time, to->u.selectionNotify.time);
1223 cpswapl(from->u.selectionNotify.requestor,
1224 to->u.selectionNotify.requestor);
1225 cpswapl(from->u.selectionNotify.selection,
1226 to->u.selectionNotify.selection);
1227 cpswapl(from->u.selectionNotify.target,
1228 to->u.selectionNotify.target);
1229 cpswapl(from->u.selectionNotify.property,
1230 to->u.selectionNotify.property);
1234 SColormapEvent(from, to)
1237 to->u.u.type = from->u.u.type;
1238 cpswaps(from->u.u.sequenceNumber, to->u.u.sequenceNumber);
1239 cpswapl(from->u.colormap.window, to->u.colormap.window);
1240 cpswapl(from->u.colormap.colormap, to->u.colormap.colormap);
1241 to->u.colormap.new = from->u.colormap.new;
1242 to->u.colormap.state = from->u.colormap.state;
1246 SMappingEvent(from, to)
1249 to->u.u.type = from->u.u.type;
1250 cpswaps(from->u.u.sequenceNumber, to->u.u.sequenceNumber);
1251 to->u.mappingNotify.request = from->u.mappingNotify.request;
1252 to->u.mappingNotify.firstKeyCode =
1253 from->u.mappingNotify.firstKeyCode;
1254 to->u.mappingNotify.count = from->u.mappingNotify.count;
1258 SClientMessageEvent(from, to)
1261 to->u.u.type = from->u.u.type;
1262 to->u.u.detail = from->u.u.detail; /* actually format */
1263 cpswaps(from->u.u.sequenceNumber, to->u.u.sequenceNumber);
1264 cpswapl(from->u.clientMessage.window, to->u.clientMessage.window);
1265 cpswapl(from->u.clientMessage.u.l.type,
1266 to->u.clientMessage.u.l.type);
1267 switch (from->u.u.detail) {
1269 memmove(to->u.clientMessage.u.b.bytes,
1270 from->u.clientMessage.u.b.bytes,20);
1273 cpswaps(from->u.clientMessage.u.s.shorts0,
1274 to->u.clientMessage.u.s.shorts0);
1275 cpswaps(from->u.clientMessage.u.s.shorts1,
1276 to->u.clientMessage.u.s.shorts1);
1277 cpswaps(from->u.clientMessage.u.s.shorts2,
1278 to->u.clientMessage.u.s.shorts2);
1279 cpswaps(from->u.clientMessage.u.s.shorts3,
1280 to->u.clientMessage.u.s.shorts3);
1281 cpswaps(from->u.clientMessage.u.s.shorts4,
1282 to->u.clientMessage.u.s.shorts4);
1283 cpswaps(from->u.clientMessage.u.s.shorts5,
1284 to->u.clientMessage.u.s.shorts5);
1285 cpswaps(from->u.clientMessage.u.s.shorts6,
1286 to->u.clientMessage.u.s.shorts6);
1287 cpswaps(from->u.clientMessage.u.s.shorts7,
1288 to->u.clientMessage.u.s.shorts7);
1289 cpswaps(from->u.clientMessage.u.s.shorts8,
1290 to->u.clientMessage.u.s.shorts8);
1291 cpswaps(from->u.clientMessage.u.s.shorts9,
1292 to->u.clientMessage.u.s.shorts9);
1295 cpswapl(from->u.clientMessage.u.l.longs0,
1296 to->u.clientMessage.u.l.longs0);
1297 cpswapl(from->u.clientMessage.u.l.longs1,
1298 to->u.clientMessage.u.l.longs1);
1299 cpswapl(from->u.clientMessage.u.l.longs2,
1300 to->u.clientMessage.u.l.longs2);
1301 cpswapl(from->u.clientMessage.u.l.longs3,
1302 to->u.clientMessage.u.l.longs3);
1303 cpswapl(from->u.clientMessage.u.l.longs4,
1304 to->u.clientMessage.u.l.longs4);
1310 SKeymapNotifyEvent(from, to)
1313 /* Keymap notify events are special; they have no
1314 sequence number field, and contain entirely 8-bit data */
1319 SwapConnSetupInfo(pInfo, pInfoTBase)
1327 xConnSetup *pConnSetup = (xConnSetup *)pInfo;
1329 pInfoT = pInfoTBase;
1330 SwapConnSetup(pConnSetup, (xConnSetup *)pInfoT);
1331 pInfo += sizeof(xConnSetup);
1332 pInfoT += sizeof(xConnSetup);
1334 /* Copy the vendor string */
1335 i = (pConnSetup->nbytesVendor + 3) & ~3;
1336 memmove(pInfoT, pInfo, i);
1340 /* The Pixmap formats don't need to be swapped, just copied. */
1341 i = sizeof(xPixmapFormat) * screenInfo.numPixmapFormats;
1342 memmove(pInfoT, pInfo, i);
1346 for(i = 0; i < screenInfo.numScreens; i++)
1348 pScreen = screenInfo.screens[i];
1349 SwapWinRoot((xWindowRoot *)pInfo, (xWindowRoot *)pInfoT);
1350 pInfo += sizeof(xWindowRoot);
1351 pInfoT += sizeof(xWindowRoot);
1352 pDepth = pScreen->allowedDepths;
1353 for(j = 0; j < pScreen->numDepths; j++, pDepth++)
1355 ((xDepth *)pInfoT)->depth = ((xDepth *)pInfo)->depth;
1356 cpswaps(((xDepth *)pInfo)->nVisuals, ((xDepth *)pInfoT)->nVisuals);
1357 pInfo += sizeof(xDepth);
1358 pInfoT += sizeof(xDepth);
1359 for(k = 0; k < pDepth->numVids; k++)
1361 SwapVisual((xVisualType *)pInfo, (xVisualType *)pInfoT);
1362 pInfo += sizeof(xVisualType);
1363 pInfoT += sizeof(xVisualType);
1371 WriteSConnectionInfo(pClient, size, pInfo)
1378 pInfoTBase = (char *) ALLOCATE_LOCAL(size);
1381 pClient->noClientException = -1;
1384 SwapConnSetupInfo(pInfo, pInfoTBase);
1385 (void)WriteToClient(pClient, (int)size, (char *) pInfoTBase);
1386 DEALLOCATE_LOCAL(pInfoTBase);
1390 SwapConnSetup(pConnSetup, pConnSetupT)
1391 xConnSetup *pConnSetup, *pConnSetupT;
1393 cpswapl(pConnSetup->release, pConnSetupT->release);
1394 cpswapl(pConnSetup->ridBase, pConnSetupT->ridBase);
1395 cpswapl(pConnSetup->ridMask, pConnSetupT->ridMask);
1396 cpswapl(pConnSetup->motionBufferSize, pConnSetupT->motionBufferSize);
1397 cpswaps(pConnSetup->nbytesVendor, pConnSetupT->nbytesVendor);
1398 cpswaps(pConnSetup->maxRequestSize, pConnSetupT->maxRequestSize);
1399 pConnSetupT->minKeyCode = pConnSetup->minKeyCode;
1400 pConnSetupT->maxKeyCode = pConnSetup->maxKeyCode;
1401 pConnSetupT->numRoots = pConnSetup->numRoots;
1402 pConnSetupT->numFormats = pConnSetup->numFormats;
1403 pConnSetupT->imageByteOrder = pConnSetup->imageByteOrder;
1404 pConnSetupT->bitmapBitOrder = pConnSetup->bitmapBitOrder;
1405 pConnSetupT->bitmapScanlineUnit = pConnSetup->bitmapScanlineUnit;
1406 pConnSetupT->bitmapScanlinePad = pConnSetup->bitmapScanlinePad;
1410 SwapWinRoot(pRoot, pRootT)
1411 xWindowRoot *pRoot, *pRootT;
1413 cpswapl(pRoot->windowId, pRootT->windowId);
1414 cpswapl(pRoot->defaultColormap, pRootT->defaultColormap);
1415 cpswapl(pRoot->whitePixel, pRootT->whitePixel);
1416 cpswapl(pRoot->blackPixel, pRootT->blackPixel);
1417 cpswapl(pRoot->currentInputMask, pRootT->currentInputMask);
1418 cpswaps(pRoot->pixWidth, pRootT->pixWidth);
1419 cpswaps(pRoot->pixHeight, pRootT->pixHeight);
1420 cpswaps(pRoot->mmWidth, pRootT->mmWidth);
1421 cpswaps(pRoot->mmHeight, pRootT->mmHeight);
1422 cpswaps(pRoot->minInstalledMaps, pRootT->minInstalledMaps);
1423 cpswaps(pRoot->maxInstalledMaps, pRootT->maxInstalledMaps);
1424 cpswapl(pRoot->rootVisualID, pRootT->rootVisualID);
1425 pRootT->backingStore = pRoot->backingStore;
1426 pRootT->saveUnders = pRoot->saveUnders;
1427 pRootT->rootDepth = pRoot->rootDepth;
1428 pRootT->nDepths = pRoot->nDepths;
1432 SwapVisual(pVis, pVisT)
1433 xVisualType *pVis, *pVisT;
1435 cpswapl(pVis->visualID, pVisT->visualID);
1436 pVisT->class = pVis->class;
1437 pVisT->bitsPerRGB = pVis->bitsPerRGB;
1438 cpswaps(pVis->colormapEntries, pVisT->colormapEntries);
1439 cpswapl(pVis->redMask, pVisT->redMask);
1440 cpswapl(pVis->greenMask, pVisT->greenMask);
1441 cpswapl(pVis->blueMask, pVisT->blueMask);
1445 SwapConnSetupPrefix(pcspFrom, pcspTo)
1446 xConnSetupPrefix *pcspFrom;
1447 xConnSetupPrefix *pcspTo;
1449 pcspTo->success = pcspFrom->success;
1450 pcspTo->lengthReason = pcspFrom->lengthReason;
1451 cpswaps(pcspFrom->majorVersion, pcspTo->majorVersion);
1452 cpswaps(pcspFrom->minorVersion, pcspTo->minorVersion);
1453 cpswaps(pcspFrom->length, pcspTo->length);
1457 WriteSConnSetupPrefix(pClient, pcsp)
1459 xConnSetupPrefix *pcsp;
1461 xConnSetupPrefix cspT;
1463 SwapConnSetupPrefix(pcsp, &cspT);
1464 (void)WriteToClient(pClient, sizeof(cspT), (char *) &cspT);