xref: /OK3568_Linux_fs/external/xserver/dix/swaprep.c (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun /************************************************************
2*4882a593Smuzhiyun 
3*4882a593Smuzhiyun Copyright 1987, 1998  The Open Group
4*4882a593Smuzhiyun 
5*4882a593Smuzhiyun Permission to use, copy, modify, distribute, and sell this software and its
6*4882a593Smuzhiyun documentation for any purpose is hereby granted without fee, provided that
7*4882a593Smuzhiyun the above copyright notice appear in all copies and that both that
8*4882a593Smuzhiyun copyright notice and this permission notice appear in supporting
9*4882a593Smuzhiyun documentation.
10*4882a593Smuzhiyun 
11*4882a593Smuzhiyun The above copyright notice and this permission notice shall be included in
12*4882a593Smuzhiyun all copies or substantial portions of the Software.
13*4882a593Smuzhiyun 
14*4882a593Smuzhiyun THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15*4882a593Smuzhiyun IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16*4882a593Smuzhiyun FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
17*4882a593Smuzhiyun OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
18*4882a593Smuzhiyun AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
19*4882a593Smuzhiyun CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
20*4882a593Smuzhiyun 
21*4882a593Smuzhiyun Except as contained in this notice, the name of The Open Group shall not be
22*4882a593Smuzhiyun used in advertising or otherwise to promote the sale, use or other dealings
23*4882a593Smuzhiyun in this Software without prior written authorization from The Open Group.
24*4882a593Smuzhiyun 
25*4882a593Smuzhiyun Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
26*4882a593Smuzhiyun 
27*4882a593Smuzhiyun                         All Rights Reserved
28*4882a593Smuzhiyun 
29*4882a593Smuzhiyun Permission to use, copy, modify, and distribute this software and its
30*4882a593Smuzhiyun documentation for any purpose and without fee is hereby granted,
31*4882a593Smuzhiyun provided that the above copyright notice appear in all copies and that
32*4882a593Smuzhiyun both that copyright notice and this permission notice appear in
33*4882a593Smuzhiyun supporting documentation, and that the name of Digital not be
34*4882a593Smuzhiyun used in advertising or publicity pertaining to distribution of the
35*4882a593Smuzhiyun software without specific, written prior permission.
36*4882a593Smuzhiyun 
37*4882a593Smuzhiyun DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
38*4882a593Smuzhiyun ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
39*4882a593Smuzhiyun DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
40*4882a593Smuzhiyun ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
41*4882a593Smuzhiyun WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
42*4882a593Smuzhiyun ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
43*4882a593Smuzhiyun SOFTWARE.
44*4882a593Smuzhiyun 
45*4882a593Smuzhiyun ********************************************************/
46*4882a593Smuzhiyun 
47*4882a593Smuzhiyun #ifdef HAVE_DIX_CONFIG_H
48*4882a593Smuzhiyun #include <dix-config.h>
49*4882a593Smuzhiyun #endif
50*4882a593Smuzhiyun 
51*4882a593Smuzhiyun #include <X11/X.h>
52*4882a593Smuzhiyun #include <X11/Xproto.h>
53*4882a593Smuzhiyun #include "misc.h"
54*4882a593Smuzhiyun #include "dixstruct.h"
55*4882a593Smuzhiyun #include <X11/fonts/fontstruct.h>
56*4882a593Smuzhiyun #include "scrnintstr.h"
57*4882a593Smuzhiyun #include "swaprep.h"
58*4882a593Smuzhiyun #include "globals.h"
59*4882a593Smuzhiyun 
60*4882a593Smuzhiyun static void SwapFontInfo(xQueryFontReply * pr);
61*4882a593Smuzhiyun 
62*4882a593Smuzhiyun static void SwapCharInfo(xCharInfo * pInfo);
63*4882a593Smuzhiyun 
64*4882a593Smuzhiyun static void SwapFont(xQueryFontReply * pr, Bool hasGlyphs);
65*4882a593Smuzhiyun 
66*4882a593Smuzhiyun /**
67*4882a593Smuzhiyun  * Thanks to Jack Palevich for testing and subsequently rewriting all this
68*4882a593Smuzhiyun  *
69*4882a593Smuzhiyun  *  \param size size in bytes
70*4882a593Smuzhiyun  */
71*4882a593Smuzhiyun void _X_COLD
Swap32Write(ClientPtr pClient,int size,CARD32 * pbuf)72*4882a593Smuzhiyun Swap32Write(ClientPtr pClient, int size, CARD32 *pbuf)
73*4882a593Smuzhiyun {
74*4882a593Smuzhiyun     int i;
75*4882a593Smuzhiyun 
76*4882a593Smuzhiyun     size >>= 2;
77*4882a593Smuzhiyun     for (i = 0; i < size; i++)
78*4882a593Smuzhiyun         /* brackets are mandatory here, because "swapl" macro expands
79*4882a593Smuzhiyun            to several statements */
80*4882a593Smuzhiyun     {
81*4882a593Smuzhiyun         swapl(&pbuf[i]);
82*4882a593Smuzhiyun     }
83*4882a593Smuzhiyun     WriteToClient(pClient, size << 2, pbuf);
84*4882a593Smuzhiyun }
85*4882a593Smuzhiyun 
86*4882a593Smuzhiyun /**
87*4882a593Smuzhiyun  *
88*4882a593Smuzhiyun  * \param size size in bytes
89*4882a593Smuzhiyun  */
90*4882a593Smuzhiyun void _X_COLD
CopySwap32Write(ClientPtr pClient,int size,CARD32 * pbuf)91*4882a593Smuzhiyun CopySwap32Write(ClientPtr pClient, int size, CARD32 *pbuf)
92*4882a593Smuzhiyun {
93*4882a593Smuzhiyun     int bufsize = size;
94*4882a593Smuzhiyun     CARD32 *pbufT;
95*4882a593Smuzhiyun     CARD32 *from, *to, *fromLast, *toLast;
96*4882a593Smuzhiyun     CARD32 tmpbuf[1];
97*4882a593Smuzhiyun 
98*4882a593Smuzhiyun     /* Allocate as big a buffer as we can... */
99*4882a593Smuzhiyun     while (!(pbufT = malloc(bufsize))) {
100*4882a593Smuzhiyun         bufsize >>= 1;
101*4882a593Smuzhiyun         if (bufsize == 4) {
102*4882a593Smuzhiyun             pbufT = tmpbuf;
103*4882a593Smuzhiyun             break;
104*4882a593Smuzhiyun         }
105*4882a593Smuzhiyun     }
106*4882a593Smuzhiyun 
107*4882a593Smuzhiyun     /* convert lengths from # of bytes to # of longs */
108*4882a593Smuzhiyun     size >>= 2;
109*4882a593Smuzhiyun     bufsize >>= 2;
110*4882a593Smuzhiyun 
111*4882a593Smuzhiyun     from = pbuf;
112*4882a593Smuzhiyun     fromLast = from + size;
113*4882a593Smuzhiyun     while (from < fromLast) {
114*4882a593Smuzhiyun         int nbytes;
115*4882a593Smuzhiyun 
116*4882a593Smuzhiyun         to = pbufT;
117*4882a593Smuzhiyun         toLast = to + min(bufsize, fromLast - from);
118*4882a593Smuzhiyun         nbytes = (toLast - to) << 2;
119*4882a593Smuzhiyun         while (to < toLast) {
120*4882a593Smuzhiyun             /* can't write "cpswapl(*from++, *to++)" because cpswapl is a macro
121*4882a593Smuzhiyun                that evaulates its args more than once */
122*4882a593Smuzhiyun             cpswapl(*from, *to);
123*4882a593Smuzhiyun             from++;
124*4882a593Smuzhiyun             to++;
125*4882a593Smuzhiyun         }
126*4882a593Smuzhiyun         WriteToClient(pClient, nbytes, pbufT);
127*4882a593Smuzhiyun     }
128*4882a593Smuzhiyun 
129*4882a593Smuzhiyun     if (pbufT != tmpbuf)
130*4882a593Smuzhiyun         free(pbufT);
131*4882a593Smuzhiyun }
132*4882a593Smuzhiyun 
133*4882a593Smuzhiyun /**
134*4882a593Smuzhiyun  *
135*4882a593Smuzhiyun  * \param size size in bytes
136*4882a593Smuzhiyun  */
137*4882a593Smuzhiyun void _X_COLD
CopySwap16Write(ClientPtr pClient,int size,short * pbuf)138*4882a593Smuzhiyun CopySwap16Write(ClientPtr pClient, int size, short *pbuf)
139*4882a593Smuzhiyun {
140*4882a593Smuzhiyun     int bufsize = size;
141*4882a593Smuzhiyun     short *pbufT;
142*4882a593Smuzhiyun     short *from, *to, *fromLast, *toLast;
143*4882a593Smuzhiyun     short tmpbuf[2];
144*4882a593Smuzhiyun 
145*4882a593Smuzhiyun     /* Allocate as big a buffer as we can... */
146*4882a593Smuzhiyun     while (!(pbufT = malloc(bufsize))) {
147*4882a593Smuzhiyun         bufsize >>= 1;
148*4882a593Smuzhiyun         if (bufsize == 4) {
149*4882a593Smuzhiyun             pbufT = tmpbuf;
150*4882a593Smuzhiyun             break;
151*4882a593Smuzhiyun         }
152*4882a593Smuzhiyun     }
153*4882a593Smuzhiyun 
154*4882a593Smuzhiyun     /* convert lengths from # of bytes to # of shorts */
155*4882a593Smuzhiyun     size >>= 1;
156*4882a593Smuzhiyun     bufsize >>= 1;
157*4882a593Smuzhiyun 
158*4882a593Smuzhiyun     from = pbuf;
159*4882a593Smuzhiyun     fromLast = from + size;
160*4882a593Smuzhiyun     while (from < fromLast) {
161*4882a593Smuzhiyun         int nbytes;
162*4882a593Smuzhiyun 
163*4882a593Smuzhiyun         to = pbufT;
164*4882a593Smuzhiyun         toLast = to + min(bufsize, fromLast - from);
165*4882a593Smuzhiyun         nbytes = (toLast - to) << 1;
166*4882a593Smuzhiyun         while (to < toLast) {
167*4882a593Smuzhiyun             /* can't write "cpswaps(*from++, *to++)" because cpswaps is a macro
168*4882a593Smuzhiyun                that evaulates its args more than once */
169*4882a593Smuzhiyun             cpswaps(*from, *to);
170*4882a593Smuzhiyun             from++;
171*4882a593Smuzhiyun             to++;
172*4882a593Smuzhiyun         }
173*4882a593Smuzhiyun         WriteToClient(pClient, nbytes, pbufT);
174*4882a593Smuzhiyun     }
175*4882a593Smuzhiyun 
176*4882a593Smuzhiyun     if (pbufT != tmpbuf)
177*4882a593Smuzhiyun         free(pbufT);
178*4882a593Smuzhiyun }
179*4882a593Smuzhiyun 
180*4882a593Smuzhiyun /* Extra-small reply */
181*4882a593Smuzhiyun void _X_COLD
SGenericReply(ClientPtr pClient,int size,xGenericReply * pRep)182*4882a593Smuzhiyun SGenericReply(ClientPtr pClient, int size, xGenericReply * pRep)
183*4882a593Smuzhiyun {
184*4882a593Smuzhiyun     swaps(&pRep->sequenceNumber);
185*4882a593Smuzhiyun     WriteToClient(pClient, size, pRep);
186*4882a593Smuzhiyun }
187*4882a593Smuzhiyun 
188*4882a593Smuzhiyun /* Extra-large reply */
189*4882a593Smuzhiyun void _X_COLD
SGetWindowAttributesReply(ClientPtr pClient,int size,xGetWindowAttributesReply * pRep)190*4882a593Smuzhiyun SGetWindowAttributesReply(ClientPtr pClient, int size,
191*4882a593Smuzhiyun                           xGetWindowAttributesReply * pRep)
192*4882a593Smuzhiyun {
193*4882a593Smuzhiyun     swaps(&pRep->sequenceNumber);
194*4882a593Smuzhiyun     swapl(&pRep->length);
195*4882a593Smuzhiyun     swapl(&pRep->visualID);
196*4882a593Smuzhiyun     swaps(&pRep->class);
197*4882a593Smuzhiyun     swapl(&pRep->backingBitPlanes);
198*4882a593Smuzhiyun     swapl(&pRep->backingPixel);
199*4882a593Smuzhiyun     swapl(&pRep->colormap);
200*4882a593Smuzhiyun     swapl(&pRep->allEventMasks);
201*4882a593Smuzhiyun     swapl(&pRep->yourEventMask);
202*4882a593Smuzhiyun     swaps(&pRep->doNotPropagateMask);
203*4882a593Smuzhiyun     WriteToClient(pClient, size, pRep);
204*4882a593Smuzhiyun }
205*4882a593Smuzhiyun 
206*4882a593Smuzhiyun void _X_COLD
SGetGeometryReply(ClientPtr pClient,int size,xGetGeometryReply * pRep)207*4882a593Smuzhiyun SGetGeometryReply(ClientPtr pClient, int size, xGetGeometryReply * pRep)
208*4882a593Smuzhiyun {
209*4882a593Smuzhiyun     swaps(&pRep->sequenceNumber);
210*4882a593Smuzhiyun     swapl(&pRep->root);
211*4882a593Smuzhiyun     swaps(&pRep->x);
212*4882a593Smuzhiyun     swaps(&pRep->y);
213*4882a593Smuzhiyun     swaps(&pRep->width);
214*4882a593Smuzhiyun     swaps(&pRep->height);
215*4882a593Smuzhiyun     swaps(&pRep->borderWidth);
216*4882a593Smuzhiyun     WriteToClient(pClient, size, pRep);
217*4882a593Smuzhiyun }
218*4882a593Smuzhiyun 
219*4882a593Smuzhiyun void _X_COLD
SQueryTreeReply(ClientPtr pClient,int size,xQueryTreeReply * pRep)220*4882a593Smuzhiyun SQueryTreeReply(ClientPtr pClient, int size, xQueryTreeReply * pRep)
221*4882a593Smuzhiyun {
222*4882a593Smuzhiyun     swaps(&pRep->sequenceNumber);
223*4882a593Smuzhiyun     swapl(&pRep->length);
224*4882a593Smuzhiyun     swapl(&pRep->root);
225*4882a593Smuzhiyun     swapl(&pRep->parent);
226*4882a593Smuzhiyun     swaps(&pRep->nChildren);
227*4882a593Smuzhiyun     WriteToClient(pClient, size, pRep);
228*4882a593Smuzhiyun }
229*4882a593Smuzhiyun 
230*4882a593Smuzhiyun void _X_COLD
SInternAtomReply(ClientPtr pClient,int size,xInternAtomReply * pRep)231*4882a593Smuzhiyun SInternAtomReply(ClientPtr pClient, int size, xInternAtomReply * pRep)
232*4882a593Smuzhiyun {
233*4882a593Smuzhiyun     swaps(&pRep->sequenceNumber);
234*4882a593Smuzhiyun     swapl(&pRep->atom);
235*4882a593Smuzhiyun     WriteToClient(pClient, size, pRep);
236*4882a593Smuzhiyun }
237*4882a593Smuzhiyun 
238*4882a593Smuzhiyun void _X_COLD
SGetAtomNameReply(ClientPtr pClient,int size,xGetAtomNameReply * pRep)239*4882a593Smuzhiyun SGetAtomNameReply(ClientPtr pClient, int size, xGetAtomNameReply * pRep)
240*4882a593Smuzhiyun {
241*4882a593Smuzhiyun     swaps(&pRep->sequenceNumber);
242*4882a593Smuzhiyun     swapl(&pRep->length);
243*4882a593Smuzhiyun     swaps(&pRep->nameLength);
244*4882a593Smuzhiyun     WriteToClient(pClient, size, pRep);
245*4882a593Smuzhiyun }
246*4882a593Smuzhiyun 
247*4882a593Smuzhiyun void _X_COLD
SGetPropertyReply(ClientPtr pClient,int size,xGetPropertyReply * pRep)248*4882a593Smuzhiyun SGetPropertyReply(ClientPtr pClient, int size, xGetPropertyReply * pRep)
249*4882a593Smuzhiyun {
250*4882a593Smuzhiyun     swaps(&pRep->sequenceNumber);
251*4882a593Smuzhiyun     swapl(&pRep->length);
252*4882a593Smuzhiyun     swapl(&pRep->propertyType);
253*4882a593Smuzhiyun     swapl(&pRep->bytesAfter);
254*4882a593Smuzhiyun     swapl(&pRep->nItems);
255*4882a593Smuzhiyun     WriteToClient(pClient, size, pRep);
256*4882a593Smuzhiyun }
257*4882a593Smuzhiyun 
258*4882a593Smuzhiyun void _X_COLD
SListPropertiesReply(ClientPtr pClient,int size,xListPropertiesReply * pRep)259*4882a593Smuzhiyun SListPropertiesReply(ClientPtr pClient, int size, xListPropertiesReply * pRep)
260*4882a593Smuzhiyun {
261*4882a593Smuzhiyun     swaps(&pRep->sequenceNumber);
262*4882a593Smuzhiyun     swapl(&pRep->length);
263*4882a593Smuzhiyun     swaps(&pRep->nProperties);
264*4882a593Smuzhiyun     WriteToClient(pClient, size, pRep);
265*4882a593Smuzhiyun }
266*4882a593Smuzhiyun 
267*4882a593Smuzhiyun void _X_COLD
SGetSelectionOwnerReply(ClientPtr pClient,int size,xGetSelectionOwnerReply * pRep)268*4882a593Smuzhiyun SGetSelectionOwnerReply(ClientPtr pClient, int size,
269*4882a593Smuzhiyun                         xGetSelectionOwnerReply * pRep)
270*4882a593Smuzhiyun {
271*4882a593Smuzhiyun     swaps(&pRep->sequenceNumber);
272*4882a593Smuzhiyun     swapl(&pRep->owner);
273*4882a593Smuzhiyun     WriteToClient(pClient, size, pRep);
274*4882a593Smuzhiyun }
275*4882a593Smuzhiyun 
276*4882a593Smuzhiyun void _X_COLD
SQueryPointerReply(ClientPtr pClient,int size,xQueryPointerReply * pRep)277*4882a593Smuzhiyun SQueryPointerReply(ClientPtr pClient, int size, xQueryPointerReply * pRep)
278*4882a593Smuzhiyun {
279*4882a593Smuzhiyun     swaps(&pRep->sequenceNumber);
280*4882a593Smuzhiyun     swapl(&pRep->root);
281*4882a593Smuzhiyun     swapl(&pRep->child);
282*4882a593Smuzhiyun     swaps(&pRep->rootX);
283*4882a593Smuzhiyun     swaps(&pRep->rootY);
284*4882a593Smuzhiyun     swaps(&pRep->winX);
285*4882a593Smuzhiyun     swaps(&pRep->winY);
286*4882a593Smuzhiyun     swaps(&pRep->mask);
287*4882a593Smuzhiyun     WriteToClient(pClient, size, pRep);
288*4882a593Smuzhiyun }
289*4882a593Smuzhiyun 
290*4882a593Smuzhiyun static void _X_COLD
SwapTimecoord(xTimecoord * pCoord)291*4882a593Smuzhiyun SwapTimecoord(xTimecoord * pCoord)
292*4882a593Smuzhiyun {
293*4882a593Smuzhiyun     swapl(&pCoord->time);
294*4882a593Smuzhiyun     swaps(&pCoord->x);
295*4882a593Smuzhiyun     swaps(&pCoord->y);
296*4882a593Smuzhiyun }
297*4882a593Smuzhiyun 
298*4882a593Smuzhiyun void _X_COLD
SwapTimeCoordWrite(ClientPtr pClient,int size,xTimecoord * pRep)299*4882a593Smuzhiyun SwapTimeCoordWrite(ClientPtr pClient, int size, xTimecoord * pRep)
300*4882a593Smuzhiyun {
301*4882a593Smuzhiyun     int i, n;
302*4882a593Smuzhiyun     xTimecoord *pRepT;
303*4882a593Smuzhiyun 
304*4882a593Smuzhiyun     n = size / sizeof(xTimecoord);
305*4882a593Smuzhiyun     pRepT = pRep;
306*4882a593Smuzhiyun     for (i = 0; i < n; i++) {
307*4882a593Smuzhiyun         SwapTimecoord(pRepT);
308*4882a593Smuzhiyun         pRepT++;
309*4882a593Smuzhiyun     }
310*4882a593Smuzhiyun     WriteToClient(pClient, size, pRep);
311*4882a593Smuzhiyun 
312*4882a593Smuzhiyun }
313*4882a593Smuzhiyun 
314*4882a593Smuzhiyun void _X_COLD
SGetMotionEventsReply(ClientPtr pClient,int size,xGetMotionEventsReply * pRep)315*4882a593Smuzhiyun SGetMotionEventsReply(ClientPtr pClient, int size, xGetMotionEventsReply * pRep)
316*4882a593Smuzhiyun {
317*4882a593Smuzhiyun     swaps(&pRep->sequenceNumber);
318*4882a593Smuzhiyun     swapl(&pRep->length);
319*4882a593Smuzhiyun     swapl(&pRep->nEvents);
320*4882a593Smuzhiyun     WriteToClient(pClient, size, pRep);
321*4882a593Smuzhiyun }
322*4882a593Smuzhiyun 
323*4882a593Smuzhiyun void _X_COLD
STranslateCoordsReply(ClientPtr pClient,int size,xTranslateCoordsReply * pRep)324*4882a593Smuzhiyun STranslateCoordsReply(ClientPtr pClient, int size, xTranslateCoordsReply * pRep)
325*4882a593Smuzhiyun {
326*4882a593Smuzhiyun     swaps(&pRep->sequenceNumber);
327*4882a593Smuzhiyun     swapl(&pRep->child);
328*4882a593Smuzhiyun     swaps(&pRep->dstX);
329*4882a593Smuzhiyun     swaps(&pRep->dstY);
330*4882a593Smuzhiyun     WriteToClient(pClient, size, pRep);
331*4882a593Smuzhiyun }
332*4882a593Smuzhiyun 
333*4882a593Smuzhiyun void _X_COLD
SGetInputFocusReply(ClientPtr pClient,int size,xGetInputFocusReply * pRep)334*4882a593Smuzhiyun SGetInputFocusReply(ClientPtr pClient, int size, xGetInputFocusReply * pRep)
335*4882a593Smuzhiyun {
336*4882a593Smuzhiyun     swaps(&pRep->sequenceNumber);
337*4882a593Smuzhiyun     swapl(&pRep->focus);
338*4882a593Smuzhiyun     WriteToClient(pClient, size, pRep);
339*4882a593Smuzhiyun }
340*4882a593Smuzhiyun 
341*4882a593Smuzhiyun /* extra long reply */
342*4882a593Smuzhiyun void _X_COLD
SQueryKeymapReply(ClientPtr pClient,int size,xQueryKeymapReply * pRep)343*4882a593Smuzhiyun SQueryKeymapReply(ClientPtr pClient, int size, xQueryKeymapReply * pRep)
344*4882a593Smuzhiyun {
345*4882a593Smuzhiyun     swaps(&pRep->sequenceNumber);
346*4882a593Smuzhiyun     swapl(&pRep->length);
347*4882a593Smuzhiyun     WriteToClient(pClient, size, pRep);
348*4882a593Smuzhiyun }
349*4882a593Smuzhiyun 
350*4882a593Smuzhiyun static void _X_COLD
SwapCharInfo(xCharInfo * pInfo)351*4882a593Smuzhiyun SwapCharInfo(xCharInfo * pInfo)
352*4882a593Smuzhiyun {
353*4882a593Smuzhiyun     swaps(&pInfo->leftSideBearing);
354*4882a593Smuzhiyun     swaps(&pInfo->rightSideBearing);
355*4882a593Smuzhiyun     swaps(&pInfo->characterWidth);
356*4882a593Smuzhiyun     swaps(&pInfo->ascent);
357*4882a593Smuzhiyun     swaps(&pInfo->descent);
358*4882a593Smuzhiyun     swaps(&pInfo->attributes);
359*4882a593Smuzhiyun }
360*4882a593Smuzhiyun 
361*4882a593Smuzhiyun static void _X_COLD
SwapFontInfo(xQueryFontReply * pr)362*4882a593Smuzhiyun SwapFontInfo(xQueryFontReply * pr)
363*4882a593Smuzhiyun {
364*4882a593Smuzhiyun     swaps(&pr->minCharOrByte2);
365*4882a593Smuzhiyun     swaps(&pr->maxCharOrByte2);
366*4882a593Smuzhiyun     swaps(&pr->defaultChar);
367*4882a593Smuzhiyun     swaps(&pr->nFontProps);
368*4882a593Smuzhiyun     swaps(&pr->fontAscent);
369*4882a593Smuzhiyun     swaps(&pr->fontDescent);
370*4882a593Smuzhiyun     SwapCharInfo(&pr->minBounds);
371*4882a593Smuzhiyun     SwapCharInfo(&pr->maxBounds);
372*4882a593Smuzhiyun     swapl(&pr->nCharInfos);
373*4882a593Smuzhiyun }
374*4882a593Smuzhiyun 
375*4882a593Smuzhiyun static void _X_COLD
SwapFont(xQueryFontReply * pr,Bool hasGlyphs)376*4882a593Smuzhiyun SwapFont(xQueryFontReply * pr, Bool hasGlyphs)
377*4882a593Smuzhiyun {
378*4882a593Smuzhiyun     unsigned i;
379*4882a593Smuzhiyun     xCharInfo *pxci;
380*4882a593Smuzhiyun     unsigned nchars, nprops;
381*4882a593Smuzhiyun     char *pby;
382*4882a593Smuzhiyun 
383*4882a593Smuzhiyun     swaps(&pr->sequenceNumber);
384*4882a593Smuzhiyun     swapl(&pr->length);
385*4882a593Smuzhiyun     nchars = pr->nCharInfos;
386*4882a593Smuzhiyun     nprops = pr->nFontProps;
387*4882a593Smuzhiyun     SwapFontInfo(pr);
388*4882a593Smuzhiyun     pby = (char *) &pr[1];
389*4882a593Smuzhiyun     /* Font properties are an atom and either an int32 or a CARD32, so
390*4882a593Smuzhiyun      * they are always 2 4 byte values */
391*4882a593Smuzhiyun     for (i = 0; i < nprops; i++) {
392*4882a593Smuzhiyun         swapl((int *) pby);
393*4882a593Smuzhiyun         pby += 4;
394*4882a593Smuzhiyun         swapl((int *) pby);
395*4882a593Smuzhiyun         pby += 4;
396*4882a593Smuzhiyun     }
397*4882a593Smuzhiyun     if (hasGlyphs) {
398*4882a593Smuzhiyun         pxci = (xCharInfo *) pby;
399*4882a593Smuzhiyun         for (i = 0; i < nchars; i++, pxci++)
400*4882a593Smuzhiyun             SwapCharInfo(pxci);
401*4882a593Smuzhiyun     }
402*4882a593Smuzhiyun }
403*4882a593Smuzhiyun 
404*4882a593Smuzhiyun void _X_COLD
SQueryFontReply(ClientPtr pClient,int size,xQueryFontReply * pRep)405*4882a593Smuzhiyun SQueryFontReply(ClientPtr pClient, int size, xQueryFontReply * pRep)
406*4882a593Smuzhiyun {
407*4882a593Smuzhiyun     SwapFont(pRep, TRUE);
408*4882a593Smuzhiyun     WriteToClient(pClient, size, pRep);
409*4882a593Smuzhiyun }
410*4882a593Smuzhiyun 
411*4882a593Smuzhiyun void _X_COLD
SQueryTextExtentsReply(ClientPtr pClient,int size,xQueryTextExtentsReply * pRep)412*4882a593Smuzhiyun SQueryTextExtentsReply(ClientPtr pClient, int size,
413*4882a593Smuzhiyun                        xQueryTextExtentsReply * pRep)
414*4882a593Smuzhiyun {
415*4882a593Smuzhiyun     swaps(&pRep->sequenceNumber);
416*4882a593Smuzhiyun     swaps(&pRep->fontAscent);
417*4882a593Smuzhiyun     swaps(&pRep->fontDescent);
418*4882a593Smuzhiyun     swaps(&pRep->overallAscent);
419*4882a593Smuzhiyun     swaps(&pRep->overallDescent);
420*4882a593Smuzhiyun     swapl(&pRep->overallWidth);
421*4882a593Smuzhiyun     swapl(&pRep->overallLeft);
422*4882a593Smuzhiyun     swapl(&pRep->overallRight);
423*4882a593Smuzhiyun     WriteToClient(pClient, size, pRep);
424*4882a593Smuzhiyun }
425*4882a593Smuzhiyun 
426*4882a593Smuzhiyun void _X_COLD
SListFontsReply(ClientPtr pClient,int size,xListFontsReply * pRep)427*4882a593Smuzhiyun SListFontsReply(ClientPtr pClient, int size, xListFontsReply * pRep)
428*4882a593Smuzhiyun {
429*4882a593Smuzhiyun     swaps(&pRep->sequenceNumber);
430*4882a593Smuzhiyun     swapl(&pRep->length);
431*4882a593Smuzhiyun     swaps(&pRep->nFonts);
432*4882a593Smuzhiyun     WriteToClient(pClient, size, pRep);
433*4882a593Smuzhiyun }
434*4882a593Smuzhiyun 
435*4882a593Smuzhiyun void _X_COLD
SListFontsWithInfoReply(ClientPtr pClient,int size,xListFontsWithInfoReply * pRep)436*4882a593Smuzhiyun SListFontsWithInfoReply(ClientPtr pClient, int size,
437*4882a593Smuzhiyun                         xListFontsWithInfoReply * pRep)
438*4882a593Smuzhiyun {
439*4882a593Smuzhiyun     SwapFont((xQueryFontReply *) pRep, FALSE);
440*4882a593Smuzhiyun     WriteToClient(pClient, size, pRep);
441*4882a593Smuzhiyun }
442*4882a593Smuzhiyun 
443*4882a593Smuzhiyun void _X_COLD
SGetFontPathReply(ClientPtr pClient,int size,xGetFontPathReply * pRep)444*4882a593Smuzhiyun SGetFontPathReply(ClientPtr pClient, int size, xGetFontPathReply * pRep)
445*4882a593Smuzhiyun {
446*4882a593Smuzhiyun     swaps(&pRep->sequenceNumber);
447*4882a593Smuzhiyun     swapl(&pRep->length);
448*4882a593Smuzhiyun     swaps(&pRep->nPaths);
449*4882a593Smuzhiyun     WriteToClient(pClient, size, pRep);
450*4882a593Smuzhiyun }
451*4882a593Smuzhiyun 
452*4882a593Smuzhiyun void _X_COLD
SGetImageReply(ClientPtr pClient,int size,xGetImageReply * pRep)453*4882a593Smuzhiyun SGetImageReply(ClientPtr pClient, int size, xGetImageReply * pRep)
454*4882a593Smuzhiyun {
455*4882a593Smuzhiyun     swaps(&pRep->sequenceNumber);
456*4882a593Smuzhiyun     swapl(&pRep->length);
457*4882a593Smuzhiyun     swapl(&pRep->visual);
458*4882a593Smuzhiyun     WriteToClient(pClient, size, pRep);
459*4882a593Smuzhiyun     /* Fortunately, image doesn't need swapping */
460*4882a593Smuzhiyun }
461*4882a593Smuzhiyun 
462*4882a593Smuzhiyun void _X_COLD
SListInstalledColormapsReply(ClientPtr pClient,int size,xListInstalledColormapsReply * pRep)463*4882a593Smuzhiyun SListInstalledColormapsReply(ClientPtr pClient, int size,
464*4882a593Smuzhiyun                              xListInstalledColormapsReply * pRep)
465*4882a593Smuzhiyun {
466*4882a593Smuzhiyun     swaps(&pRep->sequenceNumber);
467*4882a593Smuzhiyun     swapl(&pRep->length);
468*4882a593Smuzhiyun     swaps(&pRep->nColormaps);
469*4882a593Smuzhiyun     WriteToClient(pClient, size, pRep);
470*4882a593Smuzhiyun }
471*4882a593Smuzhiyun 
472*4882a593Smuzhiyun void _X_COLD
SAllocColorReply(ClientPtr pClient,int size,xAllocColorReply * pRep)473*4882a593Smuzhiyun SAllocColorReply(ClientPtr pClient, int size, xAllocColorReply * pRep)
474*4882a593Smuzhiyun {
475*4882a593Smuzhiyun     swaps(&pRep->sequenceNumber);
476*4882a593Smuzhiyun     swaps(&pRep->red);
477*4882a593Smuzhiyun     swaps(&pRep->green);
478*4882a593Smuzhiyun     swaps(&pRep->blue);
479*4882a593Smuzhiyun     swapl(&pRep->pixel);
480*4882a593Smuzhiyun     WriteToClient(pClient, size, pRep);
481*4882a593Smuzhiyun }
482*4882a593Smuzhiyun 
483*4882a593Smuzhiyun void _X_COLD
SAllocNamedColorReply(ClientPtr pClient,int size,xAllocNamedColorReply * pRep)484*4882a593Smuzhiyun SAllocNamedColorReply(ClientPtr pClient, int size, xAllocNamedColorReply * pRep)
485*4882a593Smuzhiyun {
486*4882a593Smuzhiyun     swaps(&pRep->sequenceNumber);
487*4882a593Smuzhiyun     swapl(&pRep->pixel);
488*4882a593Smuzhiyun     swaps(&pRep->exactRed);
489*4882a593Smuzhiyun     swaps(&pRep->exactGreen);
490*4882a593Smuzhiyun     swaps(&pRep->exactBlue);
491*4882a593Smuzhiyun     swaps(&pRep->screenRed);
492*4882a593Smuzhiyun     swaps(&pRep->screenGreen);
493*4882a593Smuzhiyun     swaps(&pRep->screenBlue);
494*4882a593Smuzhiyun     WriteToClient(pClient, size, pRep);
495*4882a593Smuzhiyun }
496*4882a593Smuzhiyun 
497*4882a593Smuzhiyun void _X_COLD
SAllocColorCellsReply(ClientPtr pClient,int size,xAllocColorCellsReply * pRep)498*4882a593Smuzhiyun SAllocColorCellsReply(ClientPtr pClient, int size, xAllocColorCellsReply * pRep)
499*4882a593Smuzhiyun {
500*4882a593Smuzhiyun     swaps(&pRep->sequenceNumber);
501*4882a593Smuzhiyun     swapl(&pRep->length);
502*4882a593Smuzhiyun     swaps(&pRep->nPixels);
503*4882a593Smuzhiyun     swaps(&pRep->nMasks);
504*4882a593Smuzhiyun     WriteToClient(pClient, size, pRep);
505*4882a593Smuzhiyun }
506*4882a593Smuzhiyun 
507*4882a593Smuzhiyun void _X_COLD
SAllocColorPlanesReply(ClientPtr pClient,int size,xAllocColorPlanesReply * pRep)508*4882a593Smuzhiyun SAllocColorPlanesReply(ClientPtr pClient, int size,
509*4882a593Smuzhiyun                        xAllocColorPlanesReply * pRep)
510*4882a593Smuzhiyun {
511*4882a593Smuzhiyun     swaps(&pRep->sequenceNumber);
512*4882a593Smuzhiyun     swapl(&pRep->length);
513*4882a593Smuzhiyun     swaps(&pRep->nPixels);
514*4882a593Smuzhiyun     swapl(&pRep->redMask);
515*4882a593Smuzhiyun     swapl(&pRep->greenMask);
516*4882a593Smuzhiyun     swapl(&pRep->blueMask);
517*4882a593Smuzhiyun     WriteToClient(pClient, size, pRep);
518*4882a593Smuzhiyun }
519*4882a593Smuzhiyun 
520*4882a593Smuzhiyun static void _X_COLD
SwapRGB(xrgb * prgb)521*4882a593Smuzhiyun SwapRGB(xrgb * prgb)
522*4882a593Smuzhiyun {
523*4882a593Smuzhiyun     swaps(&prgb->red);
524*4882a593Smuzhiyun     swaps(&prgb->green);
525*4882a593Smuzhiyun     swaps(&prgb->blue);
526*4882a593Smuzhiyun }
527*4882a593Smuzhiyun 
528*4882a593Smuzhiyun void _X_COLD
SQColorsExtend(ClientPtr pClient,int size,xrgb * prgb)529*4882a593Smuzhiyun SQColorsExtend(ClientPtr pClient, int size, xrgb * prgb)
530*4882a593Smuzhiyun {
531*4882a593Smuzhiyun     int i, n;
532*4882a593Smuzhiyun     xrgb *prgbT;
533*4882a593Smuzhiyun 
534*4882a593Smuzhiyun     n = size / sizeof(xrgb);
535*4882a593Smuzhiyun     prgbT = prgb;
536*4882a593Smuzhiyun     for (i = 0; i < n; i++) {
537*4882a593Smuzhiyun         SwapRGB(prgbT);
538*4882a593Smuzhiyun         prgbT++;
539*4882a593Smuzhiyun     }
540*4882a593Smuzhiyun     WriteToClient(pClient, size, prgb);
541*4882a593Smuzhiyun }
542*4882a593Smuzhiyun 
543*4882a593Smuzhiyun void _X_COLD
SQueryColorsReply(ClientPtr pClient,int size,xQueryColorsReply * pRep)544*4882a593Smuzhiyun SQueryColorsReply(ClientPtr pClient, int size, xQueryColorsReply * pRep)
545*4882a593Smuzhiyun {
546*4882a593Smuzhiyun     swaps(&pRep->sequenceNumber);
547*4882a593Smuzhiyun     swapl(&pRep->length);
548*4882a593Smuzhiyun     swaps(&pRep->nColors);
549*4882a593Smuzhiyun     WriteToClient(pClient, size, pRep);
550*4882a593Smuzhiyun }
551*4882a593Smuzhiyun 
552*4882a593Smuzhiyun void _X_COLD
SLookupColorReply(ClientPtr pClient,int size,xLookupColorReply * pRep)553*4882a593Smuzhiyun SLookupColorReply(ClientPtr pClient, int size, xLookupColorReply * pRep)
554*4882a593Smuzhiyun {
555*4882a593Smuzhiyun     swaps(&pRep->sequenceNumber);
556*4882a593Smuzhiyun     swaps(&pRep->exactRed);
557*4882a593Smuzhiyun     swaps(&pRep->exactGreen);
558*4882a593Smuzhiyun     swaps(&pRep->exactBlue);
559*4882a593Smuzhiyun     swaps(&pRep->screenRed);
560*4882a593Smuzhiyun     swaps(&pRep->screenGreen);
561*4882a593Smuzhiyun     swaps(&pRep->screenBlue);
562*4882a593Smuzhiyun     WriteToClient(pClient, size, pRep);
563*4882a593Smuzhiyun }
564*4882a593Smuzhiyun 
565*4882a593Smuzhiyun void _X_COLD
SQueryBestSizeReply(ClientPtr pClient,int size,xQueryBestSizeReply * pRep)566*4882a593Smuzhiyun SQueryBestSizeReply(ClientPtr pClient, int size, xQueryBestSizeReply * pRep)
567*4882a593Smuzhiyun {
568*4882a593Smuzhiyun     swaps(&pRep->sequenceNumber);
569*4882a593Smuzhiyun     swaps(&pRep->width);
570*4882a593Smuzhiyun     swaps(&pRep->height);
571*4882a593Smuzhiyun     WriteToClient(pClient, size, pRep);
572*4882a593Smuzhiyun }
573*4882a593Smuzhiyun 
574*4882a593Smuzhiyun void _X_COLD
SListExtensionsReply(ClientPtr pClient,int size,xListExtensionsReply * pRep)575*4882a593Smuzhiyun SListExtensionsReply(ClientPtr pClient, int size, xListExtensionsReply * pRep)
576*4882a593Smuzhiyun {
577*4882a593Smuzhiyun     swaps(&pRep->sequenceNumber);
578*4882a593Smuzhiyun     swapl(&pRep->length);
579*4882a593Smuzhiyun     WriteToClient(pClient, size, pRep);
580*4882a593Smuzhiyun }
581*4882a593Smuzhiyun 
582*4882a593Smuzhiyun void _X_COLD
SGetKeyboardMappingReply(ClientPtr pClient,int size,xGetKeyboardMappingReply * pRep)583*4882a593Smuzhiyun SGetKeyboardMappingReply(ClientPtr pClient, int size,
584*4882a593Smuzhiyun                          xGetKeyboardMappingReply * pRep)
585*4882a593Smuzhiyun {
586*4882a593Smuzhiyun     swaps(&pRep->sequenceNumber);
587*4882a593Smuzhiyun     swapl(&pRep->length);
588*4882a593Smuzhiyun     WriteToClient(pClient, size, pRep);
589*4882a593Smuzhiyun }
590*4882a593Smuzhiyun 
591*4882a593Smuzhiyun void _X_COLD
SGetPointerMappingReply(ClientPtr pClient,int size,xGetPointerMappingReply * pRep)592*4882a593Smuzhiyun SGetPointerMappingReply(ClientPtr pClient, int size,
593*4882a593Smuzhiyun                         xGetPointerMappingReply * pRep)
594*4882a593Smuzhiyun {
595*4882a593Smuzhiyun     swaps(&pRep->sequenceNumber);
596*4882a593Smuzhiyun     swapl(&pRep->length);
597*4882a593Smuzhiyun     WriteToClient(pClient, size, pRep);
598*4882a593Smuzhiyun }
599*4882a593Smuzhiyun 
600*4882a593Smuzhiyun void _X_COLD
SGetModifierMappingReply(ClientPtr pClient,int size,xGetModifierMappingReply * pRep)601*4882a593Smuzhiyun SGetModifierMappingReply(ClientPtr pClient, int size,
602*4882a593Smuzhiyun                          xGetModifierMappingReply * pRep)
603*4882a593Smuzhiyun {
604*4882a593Smuzhiyun     swaps(&pRep->sequenceNumber);
605*4882a593Smuzhiyun     swapl(&pRep->length);
606*4882a593Smuzhiyun     WriteToClient(pClient, size, pRep);
607*4882a593Smuzhiyun }
608*4882a593Smuzhiyun 
609*4882a593Smuzhiyun void _X_COLD
SGetKeyboardControlReply(ClientPtr pClient,int size,xGetKeyboardControlReply * pRep)610*4882a593Smuzhiyun SGetKeyboardControlReply(ClientPtr pClient, int size,
611*4882a593Smuzhiyun                          xGetKeyboardControlReply * pRep)
612*4882a593Smuzhiyun {
613*4882a593Smuzhiyun     swaps(&pRep->sequenceNumber);
614*4882a593Smuzhiyun     swapl(&pRep->length);
615*4882a593Smuzhiyun     swapl(&pRep->ledMask);
616*4882a593Smuzhiyun     swaps(&pRep->bellPitch);
617*4882a593Smuzhiyun     swaps(&pRep->bellDuration);
618*4882a593Smuzhiyun     WriteToClient(pClient, size, pRep);
619*4882a593Smuzhiyun }
620*4882a593Smuzhiyun 
621*4882a593Smuzhiyun void _X_COLD
SGetPointerControlReply(ClientPtr pClient,int size,xGetPointerControlReply * pRep)622*4882a593Smuzhiyun SGetPointerControlReply(ClientPtr pClient, int size,
623*4882a593Smuzhiyun                         xGetPointerControlReply * pRep)
624*4882a593Smuzhiyun {
625*4882a593Smuzhiyun     swaps(&pRep->sequenceNumber);
626*4882a593Smuzhiyun     swaps(&pRep->accelNumerator);
627*4882a593Smuzhiyun     swaps(&pRep->accelDenominator);
628*4882a593Smuzhiyun     swaps(&pRep->threshold);
629*4882a593Smuzhiyun     WriteToClient(pClient, size, pRep);
630*4882a593Smuzhiyun }
631*4882a593Smuzhiyun 
632*4882a593Smuzhiyun void _X_COLD
SGetScreenSaverReply(ClientPtr pClient,int size,xGetScreenSaverReply * pRep)633*4882a593Smuzhiyun SGetScreenSaverReply(ClientPtr pClient, int size, xGetScreenSaverReply * pRep)
634*4882a593Smuzhiyun {
635*4882a593Smuzhiyun     swaps(&pRep->sequenceNumber);
636*4882a593Smuzhiyun     swaps(&pRep->timeout);
637*4882a593Smuzhiyun     swaps(&pRep->interval);
638*4882a593Smuzhiyun     WriteToClient(pClient, size, pRep);
639*4882a593Smuzhiyun }
640*4882a593Smuzhiyun 
641*4882a593Smuzhiyun void _X_COLD
SLHostsExtend(ClientPtr pClient,int size,char * buf)642*4882a593Smuzhiyun SLHostsExtend(ClientPtr pClient, int size, char *buf)
643*4882a593Smuzhiyun {
644*4882a593Smuzhiyun     char *bufT = buf;
645*4882a593Smuzhiyun     char *endbuf = buf + size;
646*4882a593Smuzhiyun 
647*4882a593Smuzhiyun     while (bufT < endbuf) {
648*4882a593Smuzhiyun         xHostEntry *host = (xHostEntry *) bufT;
649*4882a593Smuzhiyun         int len = host->length;
650*4882a593Smuzhiyun 
651*4882a593Smuzhiyun         swaps(&host->length);
652*4882a593Smuzhiyun         bufT += sizeof(xHostEntry) + pad_to_int32(len);
653*4882a593Smuzhiyun     }
654*4882a593Smuzhiyun     WriteToClient(pClient, size, buf);
655*4882a593Smuzhiyun }
656*4882a593Smuzhiyun 
657*4882a593Smuzhiyun void _X_COLD
SListHostsReply(ClientPtr pClient,int size,xListHostsReply * pRep)658*4882a593Smuzhiyun SListHostsReply(ClientPtr pClient, int size, xListHostsReply * pRep)
659*4882a593Smuzhiyun {
660*4882a593Smuzhiyun     swaps(&pRep->sequenceNumber);
661*4882a593Smuzhiyun     swapl(&pRep->length);
662*4882a593Smuzhiyun     swaps(&pRep->nHosts);
663*4882a593Smuzhiyun     WriteToClient(pClient, size, pRep);
664*4882a593Smuzhiyun }
665*4882a593Smuzhiyun 
666*4882a593Smuzhiyun void _X_COLD
SErrorEvent(xError * from,xError * to)667*4882a593Smuzhiyun SErrorEvent(xError * from, xError * to)
668*4882a593Smuzhiyun {
669*4882a593Smuzhiyun     to->type = X_Error;
670*4882a593Smuzhiyun     to->errorCode = from->errorCode;
671*4882a593Smuzhiyun     cpswaps(from->sequenceNumber, to->sequenceNumber);
672*4882a593Smuzhiyun     cpswapl(from->resourceID, to->resourceID);
673*4882a593Smuzhiyun     cpswaps(from->minorCode, to->minorCode);
674*4882a593Smuzhiyun     to->majorCode = from->majorCode;
675*4882a593Smuzhiyun }
676*4882a593Smuzhiyun 
677*4882a593Smuzhiyun void _X_COLD
SKeyButtonPtrEvent(xEvent * from,xEvent * to)678*4882a593Smuzhiyun SKeyButtonPtrEvent(xEvent *from, xEvent *to)
679*4882a593Smuzhiyun {
680*4882a593Smuzhiyun     to->u.u.type = from->u.u.type;
681*4882a593Smuzhiyun     to->u.u.detail = from->u.u.detail;
682*4882a593Smuzhiyun     cpswaps(from->u.u.sequenceNumber, to->u.u.sequenceNumber);
683*4882a593Smuzhiyun     cpswapl(from->u.keyButtonPointer.time, to->u.keyButtonPointer.time);
684*4882a593Smuzhiyun     cpswapl(from->u.keyButtonPointer.root, to->u.keyButtonPointer.root);
685*4882a593Smuzhiyun     cpswapl(from->u.keyButtonPointer.event, to->u.keyButtonPointer.event);
686*4882a593Smuzhiyun     cpswapl(from->u.keyButtonPointer.child, to->u.keyButtonPointer.child);
687*4882a593Smuzhiyun     cpswaps(from->u.keyButtonPointer.rootX, to->u.keyButtonPointer.rootX);
688*4882a593Smuzhiyun     cpswaps(from->u.keyButtonPointer.rootY, to->u.keyButtonPointer.rootY);
689*4882a593Smuzhiyun     cpswaps(from->u.keyButtonPointer.eventX, to->u.keyButtonPointer.eventX);
690*4882a593Smuzhiyun     cpswaps(from->u.keyButtonPointer.eventY, to->u.keyButtonPointer.eventY);
691*4882a593Smuzhiyun     cpswaps(from->u.keyButtonPointer.state, to->u.keyButtonPointer.state);
692*4882a593Smuzhiyun     to->u.keyButtonPointer.sameScreen = from->u.keyButtonPointer.sameScreen;
693*4882a593Smuzhiyun }
694*4882a593Smuzhiyun 
695*4882a593Smuzhiyun void _X_COLD
SEnterLeaveEvent(xEvent * from,xEvent * to)696*4882a593Smuzhiyun SEnterLeaveEvent(xEvent *from, xEvent *to)
697*4882a593Smuzhiyun {
698*4882a593Smuzhiyun     to->u.u.type = from->u.u.type;
699*4882a593Smuzhiyun     to->u.u.detail = from->u.u.detail;
700*4882a593Smuzhiyun     cpswaps(from->u.u.sequenceNumber, to->u.u.sequenceNumber);
701*4882a593Smuzhiyun     cpswapl(from->u.enterLeave.time, to->u.enterLeave.time);
702*4882a593Smuzhiyun     cpswapl(from->u.enterLeave.root, to->u.enterLeave.root);
703*4882a593Smuzhiyun     cpswapl(from->u.enterLeave.event, to->u.enterLeave.event);
704*4882a593Smuzhiyun     cpswapl(from->u.enterLeave.child, to->u.enterLeave.child);
705*4882a593Smuzhiyun     cpswaps(from->u.enterLeave.rootX, to->u.enterLeave.rootX);
706*4882a593Smuzhiyun     cpswaps(from->u.enterLeave.rootY, to->u.enterLeave.rootY);
707*4882a593Smuzhiyun     cpswaps(from->u.enterLeave.eventX, to->u.enterLeave.eventX);
708*4882a593Smuzhiyun     cpswaps(from->u.enterLeave.eventY, to->u.enterLeave.eventY);
709*4882a593Smuzhiyun     cpswaps(from->u.enterLeave.state, to->u.enterLeave.state);
710*4882a593Smuzhiyun     to->u.enterLeave.mode = from->u.enterLeave.mode;
711*4882a593Smuzhiyun     to->u.enterLeave.flags = from->u.enterLeave.flags;
712*4882a593Smuzhiyun }
713*4882a593Smuzhiyun 
714*4882a593Smuzhiyun void _X_COLD
SFocusEvent(xEvent * from,xEvent * to)715*4882a593Smuzhiyun SFocusEvent(xEvent *from, xEvent *to)
716*4882a593Smuzhiyun {
717*4882a593Smuzhiyun     to->u.u.type = from->u.u.type;
718*4882a593Smuzhiyun     to->u.u.detail = from->u.u.detail;
719*4882a593Smuzhiyun     cpswaps(from->u.u.sequenceNumber, to->u.u.sequenceNumber);
720*4882a593Smuzhiyun     cpswapl(from->u.focus.window, to->u.focus.window);
721*4882a593Smuzhiyun     to->u.focus.mode = from->u.focus.mode;
722*4882a593Smuzhiyun }
723*4882a593Smuzhiyun 
724*4882a593Smuzhiyun void _X_COLD
SExposeEvent(xEvent * from,xEvent * to)725*4882a593Smuzhiyun SExposeEvent(xEvent *from, xEvent *to)
726*4882a593Smuzhiyun {
727*4882a593Smuzhiyun     to->u.u.type = from->u.u.type;
728*4882a593Smuzhiyun     cpswaps(from->u.u.sequenceNumber, to->u.u.sequenceNumber);
729*4882a593Smuzhiyun     cpswapl(from->u.expose.window, to->u.expose.window);
730*4882a593Smuzhiyun     cpswaps(from->u.expose.x, to->u.expose.x);
731*4882a593Smuzhiyun     cpswaps(from->u.expose.y, to->u.expose.y);
732*4882a593Smuzhiyun     cpswaps(from->u.expose.width, to->u.expose.width);
733*4882a593Smuzhiyun     cpswaps(from->u.expose.height, to->u.expose.height);
734*4882a593Smuzhiyun     cpswaps(from->u.expose.count, to->u.expose.count);
735*4882a593Smuzhiyun }
736*4882a593Smuzhiyun 
737*4882a593Smuzhiyun void _X_COLD
SGraphicsExposureEvent(xEvent * from,xEvent * to)738*4882a593Smuzhiyun SGraphicsExposureEvent(xEvent *from, xEvent *to)
739*4882a593Smuzhiyun {
740*4882a593Smuzhiyun     to->u.u.type = from->u.u.type;
741*4882a593Smuzhiyun     cpswaps(from->u.u.sequenceNumber, to->u.u.sequenceNumber);
742*4882a593Smuzhiyun     cpswapl(from->u.graphicsExposure.drawable, to->u.graphicsExposure.drawable);
743*4882a593Smuzhiyun     cpswaps(from->u.graphicsExposure.x, to->u.graphicsExposure.x);
744*4882a593Smuzhiyun     cpswaps(from->u.graphicsExposure.y, to->u.graphicsExposure.y);
745*4882a593Smuzhiyun     cpswaps(from->u.graphicsExposure.width, to->u.graphicsExposure.width);
746*4882a593Smuzhiyun     cpswaps(from->u.graphicsExposure.height, to->u.graphicsExposure.height);
747*4882a593Smuzhiyun     cpswaps(from->u.graphicsExposure.minorEvent,
748*4882a593Smuzhiyun             to->u.graphicsExposure.minorEvent);
749*4882a593Smuzhiyun     cpswaps(from->u.graphicsExposure.count, to->u.graphicsExposure.count);
750*4882a593Smuzhiyun     to->u.graphicsExposure.majorEvent = from->u.graphicsExposure.majorEvent;
751*4882a593Smuzhiyun }
752*4882a593Smuzhiyun 
753*4882a593Smuzhiyun void _X_COLD
SNoExposureEvent(xEvent * from,xEvent * to)754*4882a593Smuzhiyun SNoExposureEvent(xEvent *from, xEvent *to)
755*4882a593Smuzhiyun {
756*4882a593Smuzhiyun     to->u.u.type = from->u.u.type;
757*4882a593Smuzhiyun     cpswaps(from->u.u.sequenceNumber, to->u.u.sequenceNumber);
758*4882a593Smuzhiyun     cpswapl(from->u.noExposure.drawable, to->u.noExposure.drawable);
759*4882a593Smuzhiyun     cpswaps(from->u.noExposure.minorEvent, to->u.noExposure.minorEvent);
760*4882a593Smuzhiyun     to->u.noExposure.majorEvent = from->u.noExposure.majorEvent;
761*4882a593Smuzhiyun }
762*4882a593Smuzhiyun 
763*4882a593Smuzhiyun void _X_COLD
SVisibilityEvent(xEvent * from,xEvent * to)764*4882a593Smuzhiyun SVisibilityEvent(xEvent *from, xEvent *to)
765*4882a593Smuzhiyun {
766*4882a593Smuzhiyun     to->u.u.type = from->u.u.type;
767*4882a593Smuzhiyun     cpswaps(from->u.u.sequenceNumber, to->u.u.sequenceNumber);
768*4882a593Smuzhiyun     cpswapl(from->u.visibility.window, to->u.visibility.window);
769*4882a593Smuzhiyun     to->u.visibility.state = from->u.visibility.state;
770*4882a593Smuzhiyun }
771*4882a593Smuzhiyun 
772*4882a593Smuzhiyun void _X_COLD
SCreateNotifyEvent(xEvent * from,xEvent * to)773*4882a593Smuzhiyun SCreateNotifyEvent(xEvent *from, xEvent *to)
774*4882a593Smuzhiyun {
775*4882a593Smuzhiyun     to->u.u.type = from->u.u.type;
776*4882a593Smuzhiyun     cpswaps(from->u.u.sequenceNumber, to->u.u.sequenceNumber);
777*4882a593Smuzhiyun     cpswapl(from->u.createNotify.window, to->u.createNotify.window);
778*4882a593Smuzhiyun     cpswapl(from->u.createNotify.parent, to->u.createNotify.parent);
779*4882a593Smuzhiyun     cpswaps(from->u.createNotify.x, to->u.createNotify.x);
780*4882a593Smuzhiyun     cpswaps(from->u.createNotify.y, to->u.createNotify.y);
781*4882a593Smuzhiyun     cpswaps(from->u.createNotify.width, to->u.createNotify.width);
782*4882a593Smuzhiyun     cpswaps(from->u.createNotify.height, to->u.createNotify.height);
783*4882a593Smuzhiyun     cpswaps(from->u.createNotify.borderWidth, to->u.createNotify.borderWidth);
784*4882a593Smuzhiyun     to->u.createNotify.override = from->u.createNotify.override;
785*4882a593Smuzhiyun }
786*4882a593Smuzhiyun 
787*4882a593Smuzhiyun void _X_COLD
SDestroyNotifyEvent(xEvent * from,xEvent * to)788*4882a593Smuzhiyun SDestroyNotifyEvent(xEvent *from, xEvent *to)
789*4882a593Smuzhiyun {
790*4882a593Smuzhiyun     to->u.u.type = from->u.u.type;
791*4882a593Smuzhiyun     cpswaps(from->u.u.sequenceNumber, to->u.u.sequenceNumber);
792*4882a593Smuzhiyun     cpswapl(from->u.destroyNotify.event, to->u.destroyNotify.event);
793*4882a593Smuzhiyun     cpswapl(from->u.destroyNotify.window, to->u.destroyNotify.window);
794*4882a593Smuzhiyun }
795*4882a593Smuzhiyun 
796*4882a593Smuzhiyun void _X_COLD
SUnmapNotifyEvent(xEvent * from,xEvent * to)797*4882a593Smuzhiyun SUnmapNotifyEvent(xEvent *from, xEvent *to)
798*4882a593Smuzhiyun {
799*4882a593Smuzhiyun     to->u.u.type = from->u.u.type;
800*4882a593Smuzhiyun     cpswaps(from->u.u.sequenceNumber, to->u.u.sequenceNumber);
801*4882a593Smuzhiyun     cpswapl(from->u.unmapNotify.event, to->u.unmapNotify.event);
802*4882a593Smuzhiyun     cpswapl(from->u.unmapNotify.window, to->u.unmapNotify.window);
803*4882a593Smuzhiyun     to->u.unmapNotify.fromConfigure = from->u.unmapNotify.fromConfigure;
804*4882a593Smuzhiyun }
805*4882a593Smuzhiyun 
806*4882a593Smuzhiyun void _X_COLD
SMapNotifyEvent(xEvent * from,xEvent * to)807*4882a593Smuzhiyun SMapNotifyEvent(xEvent *from, xEvent *to)
808*4882a593Smuzhiyun {
809*4882a593Smuzhiyun     to->u.u.type = from->u.u.type;
810*4882a593Smuzhiyun     cpswaps(from->u.u.sequenceNumber, to->u.u.sequenceNumber);
811*4882a593Smuzhiyun     cpswapl(from->u.mapNotify.event, to->u.mapNotify.event);
812*4882a593Smuzhiyun     cpswapl(from->u.mapNotify.window, to->u.mapNotify.window);
813*4882a593Smuzhiyun     to->u.mapNotify.override = from->u.mapNotify.override;
814*4882a593Smuzhiyun }
815*4882a593Smuzhiyun 
816*4882a593Smuzhiyun void _X_COLD
SMapRequestEvent(xEvent * from,xEvent * to)817*4882a593Smuzhiyun SMapRequestEvent(xEvent *from, xEvent *to)
818*4882a593Smuzhiyun {
819*4882a593Smuzhiyun     to->u.u.type = from->u.u.type;
820*4882a593Smuzhiyun     cpswaps(from->u.u.sequenceNumber, to->u.u.sequenceNumber);
821*4882a593Smuzhiyun     cpswapl(from->u.mapRequest.parent, to->u.mapRequest.parent);
822*4882a593Smuzhiyun     cpswapl(from->u.mapRequest.window, to->u.mapRequest.window);
823*4882a593Smuzhiyun }
824*4882a593Smuzhiyun 
825*4882a593Smuzhiyun void _X_COLD
SReparentEvent(xEvent * from,xEvent * to)826*4882a593Smuzhiyun SReparentEvent(xEvent *from, xEvent *to)
827*4882a593Smuzhiyun {
828*4882a593Smuzhiyun     to->u.u.type = from->u.u.type;
829*4882a593Smuzhiyun     cpswaps(from->u.u.sequenceNumber, to->u.u.sequenceNumber);
830*4882a593Smuzhiyun     cpswapl(from->u.reparent.event, to->u.reparent.event);
831*4882a593Smuzhiyun     cpswapl(from->u.reparent.window, to->u.reparent.window);
832*4882a593Smuzhiyun     cpswapl(from->u.reparent.parent, to->u.reparent.parent);
833*4882a593Smuzhiyun     cpswaps(from->u.reparent.x, to->u.reparent.x);
834*4882a593Smuzhiyun     cpswaps(from->u.reparent.y, to->u.reparent.y);
835*4882a593Smuzhiyun     to->u.reparent.override = from->u.reparent.override;
836*4882a593Smuzhiyun }
837*4882a593Smuzhiyun 
838*4882a593Smuzhiyun void _X_COLD
SConfigureNotifyEvent(xEvent * from,xEvent * to)839*4882a593Smuzhiyun SConfigureNotifyEvent(xEvent *from, xEvent *to)
840*4882a593Smuzhiyun {
841*4882a593Smuzhiyun     to->u.u.type = from->u.u.type;
842*4882a593Smuzhiyun     cpswaps(from->u.u.sequenceNumber, to->u.u.sequenceNumber);
843*4882a593Smuzhiyun     cpswapl(from->u.configureNotify.event, to->u.configureNotify.event);
844*4882a593Smuzhiyun     cpswapl(from->u.configureNotify.window, to->u.configureNotify.window);
845*4882a593Smuzhiyun     cpswapl(from->u.configureNotify.aboveSibling,
846*4882a593Smuzhiyun             to->u.configureNotify.aboveSibling);
847*4882a593Smuzhiyun     cpswaps(from->u.configureNotify.x, to->u.configureNotify.x);
848*4882a593Smuzhiyun     cpswaps(from->u.configureNotify.y, to->u.configureNotify.y);
849*4882a593Smuzhiyun     cpswaps(from->u.configureNotify.width, to->u.configureNotify.width);
850*4882a593Smuzhiyun     cpswaps(from->u.configureNotify.height, to->u.configureNotify.height);
851*4882a593Smuzhiyun     cpswaps(from->u.configureNotify.borderWidth,
852*4882a593Smuzhiyun             to->u.configureNotify.borderWidth);
853*4882a593Smuzhiyun     to->u.configureNotify.override = from->u.configureNotify.override;
854*4882a593Smuzhiyun }
855*4882a593Smuzhiyun 
856*4882a593Smuzhiyun void _X_COLD
SConfigureRequestEvent(xEvent * from,xEvent * to)857*4882a593Smuzhiyun SConfigureRequestEvent(xEvent *from, xEvent *to)
858*4882a593Smuzhiyun {
859*4882a593Smuzhiyun     to->u.u.type = from->u.u.type;
860*4882a593Smuzhiyun     to->u.u.detail = from->u.u.detail;  /* actually stack-mode */
861*4882a593Smuzhiyun     cpswaps(from->u.u.sequenceNumber, to->u.u.sequenceNumber);
862*4882a593Smuzhiyun     cpswapl(from->u.configureRequest.parent, to->u.configureRequest.parent);
863*4882a593Smuzhiyun     cpswapl(from->u.configureRequest.window, to->u.configureRequest.window);
864*4882a593Smuzhiyun     cpswapl(from->u.configureRequest.sibling, to->u.configureRequest.sibling);
865*4882a593Smuzhiyun     cpswaps(from->u.configureRequest.x, to->u.configureRequest.x);
866*4882a593Smuzhiyun     cpswaps(from->u.configureRequest.y, to->u.configureRequest.y);
867*4882a593Smuzhiyun     cpswaps(from->u.configureRequest.width, to->u.configureRequest.width);
868*4882a593Smuzhiyun     cpswaps(from->u.configureRequest.height, to->u.configureRequest.height);
869*4882a593Smuzhiyun     cpswaps(from->u.configureRequest.borderWidth,
870*4882a593Smuzhiyun             to->u.configureRequest.borderWidth);
871*4882a593Smuzhiyun     cpswaps(from->u.configureRequest.valueMask,
872*4882a593Smuzhiyun             to->u.configureRequest.valueMask);
873*4882a593Smuzhiyun }
874*4882a593Smuzhiyun 
875*4882a593Smuzhiyun void _X_COLD
SGravityEvent(xEvent * from,xEvent * to)876*4882a593Smuzhiyun SGravityEvent(xEvent *from, xEvent *to)
877*4882a593Smuzhiyun {
878*4882a593Smuzhiyun     to->u.u.type = from->u.u.type;
879*4882a593Smuzhiyun     cpswaps(from->u.u.sequenceNumber, to->u.u.sequenceNumber);
880*4882a593Smuzhiyun     cpswapl(from->u.gravity.event, to->u.gravity.event);
881*4882a593Smuzhiyun     cpswapl(from->u.gravity.window, to->u.gravity.window);
882*4882a593Smuzhiyun     cpswaps(from->u.gravity.x, to->u.gravity.x);
883*4882a593Smuzhiyun     cpswaps(from->u.gravity.y, to->u.gravity.y);
884*4882a593Smuzhiyun }
885*4882a593Smuzhiyun 
886*4882a593Smuzhiyun void _X_COLD
SResizeRequestEvent(xEvent * from,xEvent * to)887*4882a593Smuzhiyun SResizeRequestEvent(xEvent *from, xEvent *to)
888*4882a593Smuzhiyun {
889*4882a593Smuzhiyun     to->u.u.type = from->u.u.type;
890*4882a593Smuzhiyun     cpswaps(from->u.u.sequenceNumber, to->u.u.sequenceNumber);
891*4882a593Smuzhiyun     cpswapl(from->u.resizeRequest.window, to->u.resizeRequest.window);
892*4882a593Smuzhiyun     cpswaps(from->u.resizeRequest.width, to->u.resizeRequest.width);
893*4882a593Smuzhiyun     cpswaps(from->u.resizeRequest.height, to->u.resizeRequest.height);
894*4882a593Smuzhiyun }
895*4882a593Smuzhiyun 
896*4882a593Smuzhiyun void _X_COLD
SCirculateEvent(xEvent * from,xEvent * to)897*4882a593Smuzhiyun SCirculateEvent(xEvent *from, xEvent *to)
898*4882a593Smuzhiyun {
899*4882a593Smuzhiyun     to->u.u.type = from->u.u.type;
900*4882a593Smuzhiyun     to->u.u.detail = from->u.u.detail;
901*4882a593Smuzhiyun     cpswaps(from->u.u.sequenceNumber, to->u.u.sequenceNumber);
902*4882a593Smuzhiyun     cpswapl(from->u.circulate.event, to->u.circulate.event);
903*4882a593Smuzhiyun     cpswapl(from->u.circulate.window, to->u.circulate.window);
904*4882a593Smuzhiyun     cpswapl(from->u.circulate.parent, to->u.circulate.parent);
905*4882a593Smuzhiyun     to->u.circulate.place = from->u.circulate.place;
906*4882a593Smuzhiyun }
907*4882a593Smuzhiyun 
908*4882a593Smuzhiyun void _X_COLD
SPropertyEvent(xEvent * from,xEvent * to)909*4882a593Smuzhiyun SPropertyEvent(xEvent *from, xEvent *to)
910*4882a593Smuzhiyun {
911*4882a593Smuzhiyun     to->u.u.type = from->u.u.type;
912*4882a593Smuzhiyun     cpswaps(from->u.u.sequenceNumber, to->u.u.sequenceNumber);
913*4882a593Smuzhiyun     cpswapl(from->u.property.window, to->u.property.window);
914*4882a593Smuzhiyun     cpswapl(from->u.property.atom, to->u.property.atom);
915*4882a593Smuzhiyun     cpswapl(from->u.property.time, to->u.property.time);
916*4882a593Smuzhiyun     to->u.property.state = from->u.property.state;
917*4882a593Smuzhiyun }
918*4882a593Smuzhiyun 
919*4882a593Smuzhiyun void _X_COLD
SSelectionClearEvent(xEvent * from,xEvent * to)920*4882a593Smuzhiyun SSelectionClearEvent(xEvent *from, xEvent *to)
921*4882a593Smuzhiyun {
922*4882a593Smuzhiyun     to->u.u.type = from->u.u.type;
923*4882a593Smuzhiyun     cpswaps(from->u.u.sequenceNumber, to->u.u.sequenceNumber);
924*4882a593Smuzhiyun     cpswapl(from->u.selectionClear.time, to->u.selectionClear.time);
925*4882a593Smuzhiyun     cpswapl(from->u.selectionClear.window, to->u.selectionClear.window);
926*4882a593Smuzhiyun     cpswapl(from->u.selectionClear.atom, to->u.selectionClear.atom);
927*4882a593Smuzhiyun }
928*4882a593Smuzhiyun 
929*4882a593Smuzhiyun void _X_COLD
SSelectionRequestEvent(xEvent * from,xEvent * to)930*4882a593Smuzhiyun SSelectionRequestEvent(xEvent *from, xEvent *to)
931*4882a593Smuzhiyun {
932*4882a593Smuzhiyun     to->u.u.type = from->u.u.type;
933*4882a593Smuzhiyun     cpswaps(from->u.u.sequenceNumber, to->u.u.sequenceNumber);
934*4882a593Smuzhiyun     cpswapl(from->u.selectionRequest.time, to->u.selectionRequest.time);
935*4882a593Smuzhiyun     cpswapl(from->u.selectionRequest.owner, to->u.selectionRequest.owner);
936*4882a593Smuzhiyun     cpswapl(from->u.selectionRequest.requestor,
937*4882a593Smuzhiyun             to->u.selectionRequest.requestor);
938*4882a593Smuzhiyun     cpswapl(from->u.selectionRequest.selection,
939*4882a593Smuzhiyun             to->u.selectionRequest.selection);
940*4882a593Smuzhiyun     cpswapl(from->u.selectionRequest.target, to->u.selectionRequest.target);
941*4882a593Smuzhiyun     cpswapl(from->u.selectionRequest.property, to->u.selectionRequest.property);
942*4882a593Smuzhiyun }
943*4882a593Smuzhiyun 
944*4882a593Smuzhiyun void _X_COLD
SSelectionNotifyEvent(xEvent * from,xEvent * to)945*4882a593Smuzhiyun SSelectionNotifyEvent(xEvent *from, xEvent *to)
946*4882a593Smuzhiyun {
947*4882a593Smuzhiyun     to->u.u.type = from->u.u.type;
948*4882a593Smuzhiyun     cpswaps(from->u.u.sequenceNumber, to->u.u.sequenceNumber);
949*4882a593Smuzhiyun     cpswapl(from->u.selectionNotify.time, to->u.selectionNotify.time);
950*4882a593Smuzhiyun     cpswapl(from->u.selectionNotify.requestor, to->u.selectionNotify.requestor);
951*4882a593Smuzhiyun     cpswapl(from->u.selectionNotify.selection, to->u.selectionNotify.selection);
952*4882a593Smuzhiyun     cpswapl(from->u.selectionNotify.target, to->u.selectionNotify.target);
953*4882a593Smuzhiyun     cpswapl(from->u.selectionNotify.property, to->u.selectionNotify.property);
954*4882a593Smuzhiyun }
955*4882a593Smuzhiyun 
956*4882a593Smuzhiyun void _X_COLD
SColormapEvent(xEvent * from,xEvent * to)957*4882a593Smuzhiyun SColormapEvent(xEvent *from, xEvent *to)
958*4882a593Smuzhiyun {
959*4882a593Smuzhiyun     to->u.u.type = from->u.u.type;
960*4882a593Smuzhiyun     cpswaps(from->u.u.sequenceNumber, to->u.u.sequenceNumber);
961*4882a593Smuzhiyun     cpswapl(from->u.colormap.window, to->u.colormap.window);
962*4882a593Smuzhiyun     cpswapl(from->u.colormap.colormap, to->u.colormap.colormap);
963*4882a593Smuzhiyun     to->u.colormap.new = from->u.colormap.new;
964*4882a593Smuzhiyun     to->u.colormap.state = from->u.colormap.state;
965*4882a593Smuzhiyun }
966*4882a593Smuzhiyun 
967*4882a593Smuzhiyun void _X_COLD
SMappingEvent(xEvent * from,xEvent * to)968*4882a593Smuzhiyun SMappingEvent(xEvent *from, xEvent *to)
969*4882a593Smuzhiyun {
970*4882a593Smuzhiyun     to->u.u.type = from->u.u.type;
971*4882a593Smuzhiyun     cpswaps(from->u.u.sequenceNumber, to->u.u.sequenceNumber);
972*4882a593Smuzhiyun     to->u.mappingNotify.request = from->u.mappingNotify.request;
973*4882a593Smuzhiyun     to->u.mappingNotify.firstKeyCode = from->u.mappingNotify.firstKeyCode;
974*4882a593Smuzhiyun     to->u.mappingNotify.count = from->u.mappingNotify.count;
975*4882a593Smuzhiyun }
976*4882a593Smuzhiyun 
977*4882a593Smuzhiyun void _X_COLD
SClientMessageEvent(xEvent * from,xEvent * to)978*4882a593Smuzhiyun SClientMessageEvent(xEvent *from, xEvent *to)
979*4882a593Smuzhiyun {
980*4882a593Smuzhiyun     to->u.u.type = from->u.u.type;
981*4882a593Smuzhiyun     to->u.u.detail = from->u.u.detail;  /* actually format */
982*4882a593Smuzhiyun     cpswaps(from->u.u.sequenceNumber, to->u.u.sequenceNumber);
983*4882a593Smuzhiyun     cpswapl(from->u.clientMessage.window, to->u.clientMessage.window);
984*4882a593Smuzhiyun     cpswapl(from->u.clientMessage.u.l.type, to->u.clientMessage.u.l.type);
985*4882a593Smuzhiyun     switch (from->u.u.detail) {
986*4882a593Smuzhiyun     case 8:
987*4882a593Smuzhiyun         memmove(to->u.clientMessage.u.b.bytes,
988*4882a593Smuzhiyun                 from->u.clientMessage.u.b.bytes, 20);
989*4882a593Smuzhiyun         break;
990*4882a593Smuzhiyun     case 16:
991*4882a593Smuzhiyun         cpswaps(from->u.clientMessage.u.s.shorts0,
992*4882a593Smuzhiyun                 to->u.clientMessage.u.s.shorts0);
993*4882a593Smuzhiyun         cpswaps(from->u.clientMessage.u.s.shorts1,
994*4882a593Smuzhiyun                 to->u.clientMessage.u.s.shorts1);
995*4882a593Smuzhiyun         cpswaps(from->u.clientMessage.u.s.shorts2,
996*4882a593Smuzhiyun                 to->u.clientMessage.u.s.shorts2);
997*4882a593Smuzhiyun         cpswaps(from->u.clientMessage.u.s.shorts3,
998*4882a593Smuzhiyun                 to->u.clientMessage.u.s.shorts3);
999*4882a593Smuzhiyun         cpswaps(from->u.clientMessage.u.s.shorts4,
1000*4882a593Smuzhiyun                 to->u.clientMessage.u.s.shorts4);
1001*4882a593Smuzhiyun         cpswaps(from->u.clientMessage.u.s.shorts5,
1002*4882a593Smuzhiyun                 to->u.clientMessage.u.s.shorts5);
1003*4882a593Smuzhiyun         cpswaps(from->u.clientMessage.u.s.shorts6,
1004*4882a593Smuzhiyun                 to->u.clientMessage.u.s.shorts6);
1005*4882a593Smuzhiyun         cpswaps(from->u.clientMessage.u.s.shorts7,
1006*4882a593Smuzhiyun                 to->u.clientMessage.u.s.shorts7);
1007*4882a593Smuzhiyun         cpswaps(from->u.clientMessage.u.s.shorts8,
1008*4882a593Smuzhiyun                 to->u.clientMessage.u.s.shorts8);
1009*4882a593Smuzhiyun         cpswaps(from->u.clientMessage.u.s.shorts9,
1010*4882a593Smuzhiyun                 to->u.clientMessage.u.s.shorts9);
1011*4882a593Smuzhiyun         break;
1012*4882a593Smuzhiyun     case 32:
1013*4882a593Smuzhiyun         cpswapl(from->u.clientMessage.u.l.longs0,
1014*4882a593Smuzhiyun                 to->u.clientMessage.u.l.longs0);
1015*4882a593Smuzhiyun         cpswapl(from->u.clientMessage.u.l.longs1,
1016*4882a593Smuzhiyun                 to->u.clientMessage.u.l.longs1);
1017*4882a593Smuzhiyun         cpswapl(from->u.clientMessage.u.l.longs2,
1018*4882a593Smuzhiyun                 to->u.clientMessage.u.l.longs2);
1019*4882a593Smuzhiyun         cpswapl(from->u.clientMessage.u.l.longs3,
1020*4882a593Smuzhiyun                 to->u.clientMessage.u.l.longs3);
1021*4882a593Smuzhiyun         cpswapl(from->u.clientMessage.u.l.longs4,
1022*4882a593Smuzhiyun                 to->u.clientMessage.u.l.longs4);
1023*4882a593Smuzhiyun         break;
1024*4882a593Smuzhiyun     }
1025*4882a593Smuzhiyun }
1026*4882a593Smuzhiyun 
1027*4882a593Smuzhiyun void _X_COLD
SKeymapNotifyEvent(xEvent * from,xEvent * to)1028*4882a593Smuzhiyun SKeymapNotifyEvent(xEvent *from, xEvent *to)
1029*4882a593Smuzhiyun {
1030*4882a593Smuzhiyun     /* Keymap notify events are special; they have no
1031*4882a593Smuzhiyun        sequence number field, and contain entirely 8-bit data */
1032*4882a593Smuzhiyun     *to = *from;
1033*4882a593Smuzhiyun }
1034*4882a593Smuzhiyun 
1035*4882a593Smuzhiyun static void _X_COLD
SwapConnSetup(xConnSetup * pConnSetup,xConnSetup * pConnSetupT)1036*4882a593Smuzhiyun SwapConnSetup(xConnSetup * pConnSetup, xConnSetup * pConnSetupT)
1037*4882a593Smuzhiyun {
1038*4882a593Smuzhiyun     cpswapl(pConnSetup->release, pConnSetupT->release);
1039*4882a593Smuzhiyun     cpswapl(pConnSetup->ridBase, pConnSetupT->ridBase);
1040*4882a593Smuzhiyun     cpswapl(pConnSetup->ridMask, pConnSetupT->ridMask);
1041*4882a593Smuzhiyun     cpswapl(pConnSetup->motionBufferSize, pConnSetupT->motionBufferSize);
1042*4882a593Smuzhiyun     cpswaps(pConnSetup->nbytesVendor, pConnSetupT->nbytesVendor);
1043*4882a593Smuzhiyun     cpswaps(pConnSetup->maxRequestSize, pConnSetupT->maxRequestSize);
1044*4882a593Smuzhiyun     pConnSetupT->minKeyCode = pConnSetup->minKeyCode;
1045*4882a593Smuzhiyun     pConnSetupT->maxKeyCode = pConnSetup->maxKeyCode;
1046*4882a593Smuzhiyun     pConnSetupT->numRoots = pConnSetup->numRoots;
1047*4882a593Smuzhiyun     pConnSetupT->numFormats = pConnSetup->numFormats;
1048*4882a593Smuzhiyun     pConnSetupT->imageByteOrder = pConnSetup->imageByteOrder;
1049*4882a593Smuzhiyun     pConnSetupT->bitmapBitOrder = pConnSetup->bitmapBitOrder;
1050*4882a593Smuzhiyun     pConnSetupT->bitmapScanlineUnit = pConnSetup->bitmapScanlineUnit;
1051*4882a593Smuzhiyun     pConnSetupT->bitmapScanlinePad = pConnSetup->bitmapScanlinePad;
1052*4882a593Smuzhiyun }
1053*4882a593Smuzhiyun 
1054*4882a593Smuzhiyun static void _X_COLD
SwapWinRoot(xWindowRoot * pRoot,xWindowRoot * pRootT)1055*4882a593Smuzhiyun SwapWinRoot(xWindowRoot * pRoot, xWindowRoot * pRootT)
1056*4882a593Smuzhiyun {
1057*4882a593Smuzhiyun     cpswapl(pRoot->windowId, pRootT->windowId);
1058*4882a593Smuzhiyun     cpswapl(pRoot->defaultColormap, pRootT->defaultColormap);
1059*4882a593Smuzhiyun     cpswapl(pRoot->whitePixel, pRootT->whitePixel);
1060*4882a593Smuzhiyun     cpswapl(pRoot->blackPixel, pRootT->blackPixel);
1061*4882a593Smuzhiyun     cpswapl(pRoot->currentInputMask, pRootT->currentInputMask);
1062*4882a593Smuzhiyun     cpswaps(pRoot->pixWidth, pRootT->pixWidth);
1063*4882a593Smuzhiyun     cpswaps(pRoot->pixHeight, pRootT->pixHeight);
1064*4882a593Smuzhiyun     cpswaps(pRoot->mmWidth, pRootT->mmWidth);
1065*4882a593Smuzhiyun     cpswaps(pRoot->mmHeight, pRootT->mmHeight);
1066*4882a593Smuzhiyun     cpswaps(pRoot->minInstalledMaps, pRootT->minInstalledMaps);
1067*4882a593Smuzhiyun     cpswaps(pRoot->maxInstalledMaps, pRootT->maxInstalledMaps);
1068*4882a593Smuzhiyun     cpswapl(pRoot->rootVisualID, pRootT->rootVisualID);
1069*4882a593Smuzhiyun     pRootT->backingStore = pRoot->backingStore;
1070*4882a593Smuzhiyun     pRootT->saveUnders = pRoot->saveUnders;
1071*4882a593Smuzhiyun     pRootT->rootDepth = pRoot->rootDepth;
1072*4882a593Smuzhiyun     pRootT->nDepths = pRoot->nDepths;
1073*4882a593Smuzhiyun }
1074*4882a593Smuzhiyun 
1075*4882a593Smuzhiyun static void _X_COLD
SwapVisual(xVisualType * pVis,xVisualType * pVisT)1076*4882a593Smuzhiyun SwapVisual(xVisualType * pVis, xVisualType * pVisT)
1077*4882a593Smuzhiyun {
1078*4882a593Smuzhiyun     cpswapl(pVis->visualID, pVisT->visualID);
1079*4882a593Smuzhiyun     pVisT->class = pVis->class;
1080*4882a593Smuzhiyun     pVisT->bitsPerRGB = pVis->bitsPerRGB;
1081*4882a593Smuzhiyun     cpswaps(pVis->colormapEntries, pVisT->colormapEntries);
1082*4882a593Smuzhiyun     cpswapl(pVis->redMask, pVisT->redMask);
1083*4882a593Smuzhiyun     cpswapl(pVis->greenMask, pVisT->greenMask);
1084*4882a593Smuzhiyun     cpswapl(pVis->blueMask, pVisT->blueMask);
1085*4882a593Smuzhiyun }
1086*4882a593Smuzhiyun 
1087*4882a593Smuzhiyun void _X_COLD
SwapConnSetupInfo(char * pInfo,char * pInfoT)1088*4882a593Smuzhiyun SwapConnSetupInfo(char *pInfo, char *pInfoT)
1089*4882a593Smuzhiyun {
1090*4882a593Smuzhiyun     int i, j, k;
1091*4882a593Smuzhiyun     xConnSetup *pConnSetup = (xConnSetup *) pInfo;
1092*4882a593Smuzhiyun     xDepth *depth;
1093*4882a593Smuzhiyun     xWindowRoot *root;
1094*4882a593Smuzhiyun 
1095*4882a593Smuzhiyun     SwapConnSetup(pConnSetup, (xConnSetup *) pInfoT);
1096*4882a593Smuzhiyun     pInfo += sizeof(xConnSetup);
1097*4882a593Smuzhiyun     pInfoT += sizeof(xConnSetup);
1098*4882a593Smuzhiyun 
1099*4882a593Smuzhiyun     /* Copy the vendor string */
1100*4882a593Smuzhiyun     i = pad_to_int32(pConnSetup->nbytesVendor);
1101*4882a593Smuzhiyun     memcpy(pInfoT, pInfo, i);
1102*4882a593Smuzhiyun     pInfo += i;
1103*4882a593Smuzhiyun     pInfoT += i;
1104*4882a593Smuzhiyun 
1105*4882a593Smuzhiyun     /* The Pixmap formats don't need to be swapped, just copied. */
1106*4882a593Smuzhiyun     i = sizeof(xPixmapFormat) * pConnSetup->numFormats;
1107*4882a593Smuzhiyun     memcpy(pInfoT, pInfo, i);
1108*4882a593Smuzhiyun     pInfo += i;
1109*4882a593Smuzhiyun     pInfoT += i;
1110*4882a593Smuzhiyun 
1111*4882a593Smuzhiyun     for (i = 0; i < pConnSetup->numRoots; i++) {
1112*4882a593Smuzhiyun         root = (xWindowRoot *) pInfo;
1113*4882a593Smuzhiyun         SwapWinRoot(root, (xWindowRoot *) pInfoT);
1114*4882a593Smuzhiyun         pInfo += sizeof(xWindowRoot);
1115*4882a593Smuzhiyun         pInfoT += sizeof(xWindowRoot);
1116*4882a593Smuzhiyun 
1117*4882a593Smuzhiyun         for (j = 0; j < root->nDepths; j++) {
1118*4882a593Smuzhiyun             depth = (xDepth *) pInfo;
1119*4882a593Smuzhiyun             ((xDepth *) pInfoT)->depth = depth->depth;
1120*4882a593Smuzhiyun             cpswaps(depth->nVisuals, ((xDepth *) pInfoT)->nVisuals);
1121*4882a593Smuzhiyun             pInfo += sizeof(xDepth);
1122*4882a593Smuzhiyun             pInfoT += sizeof(xDepth);
1123*4882a593Smuzhiyun             for (k = 0; k < depth->nVisuals; k++) {
1124*4882a593Smuzhiyun                 SwapVisual((xVisualType *) pInfo, (xVisualType *) pInfoT);
1125*4882a593Smuzhiyun                 pInfo += sizeof(xVisualType);
1126*4882a593Smuzhiyun                 pInfoT += sizeof(xVisualType);
1127*4882a593Smuzhiyun             }
1128*4882a593Smuzhiyun         }
1129*4882a593Smuzhiyun     }
1130*4882a593Smuzhiyun }
1131*4882a593Smuzhiyun 
1132*4882a593Smuzhiyun void _X_COLD
WriteSConnectionInfo(ClientPtr pClient,unsigned long size,char * pInfo)1133*4882a593Smuzhiyun WriteSConnectionInfo(ClientPtr pClient, unsigned long size, char *pInfo)
1134*4882a593Smuzhiyun {
1135*4882a593Smuzhiyun     char *pInfoTBase;
1136*4882a593Smuzhiyun 
1137*4882a593Smuzhiyun     pInfoTBase = malloc(size);
1138*4882a593Smuzhiyun     if (!pInfoTBase) {
1139*4882a593Smuzhiyun         pClient->noClientException = -1;
1140*4882a593Smuzhiyun         return;
1141*4882a593Smuzhiyun     }
1142*4882a593Smuzhiyun     SwapConnSetupInfo(pInfo, pInfoTBase);
1143*4882a593Smuzhiyun     WriteToClient(pClient, (int) size, pInfoTBase);
1144*4882a593Smuzhiyun     free(pInfoTBase);
1145*4882a593Smuzhiyun }
1146*4882a593Smuzhiyun 
1147*4882a593Smuzhiyun void _X_COLD
SwapConnSetupPrefix(xConnSetupPrefix * pcspFrom,xConnSetupPrefix * pcspTo)1148*4882a593Smuzhiyun SwapConnSetupPrefix(xConnSetupPrefix * pcspFrom, xConnSetupPrefix * pcspTo)
1149*4882a593Smuzhiyun {
1150*4882a593Smuzhiyun     pcspTo->success = pcspFrom->success;
1151*4882a593Smuzhiyun     pcspTo->lengthReason = pcspFrom->lengthReason;
1152*4882a593Smuzhiyun     cpswaps(pcspFrom->majorVersion, pcspTo->majorVersion);
1153*4882a593Smuzhiyun     cpswaps(pcspFrom->minorVersion, pcspTo->minorVersion);
1154*4882a593Smuzhiyun     cpswaps(pcspFrom->length, pcspTo->length);
1155*4882a593Smuzhiyun }
1156*4882a593Smuzhiyun 
1157*4882a593Smuzhiyun void _X_COLD
WriteSConnSetupPrefix(ClientPtr pClient,xConnSetupPrefix * pcsp)1158*4882a593Smuzhiyun WriteSConnSetupPrefix(ClientPtr pClient, xConnSetupPrefix * pcsp)
1159*4882a593Smuzhiyun {
1160*4882a593Smuzhiyun     xConnSetupPrefix cspT;
1161*4882a593Smuzhiyun 
1162*4882a593Smuzhiyun     SwapConnSetupPrefix(pcsp, &cspT);
1163*4882a593Smuzhiyun     WriteToClient(pClient, sizeof(cspT), &cspT);
1164*4882a593Smuzhiyun }
1165*4882a593Smuzhiyun 
1166*4882a593Smuzhiyun /*
1167*4882a593Smuzhiyun  * Dummy entry for ReplySwapVector[]
1168*4882a593Smuzhiyun  */
1169*4882a593Smuzhiyun 
1170*4882a593Smuzhiyun void _X_COLD
ReplyNotSwappd(ClientPtr pClient,int size,void * pbuf)1171*4882a593Smuzhiyun ReplyNotSwappd(ClientPtr pClient, int size, void *pbuf)
1172*4882a593Smuzhiyun {
1173*4882a593Smuzhiyun     FatalError("Not implemented");
1174*4882a593Smuzhiyun }
1175