swaprep.c revision bbe1b32b
1bbe1b32bSmrg/* $Xorg: swaprep.c,v 1.4 2001/02/09 02:05:43 xorgcvs Exp $ */
2bbe1b32bSmrg/*
3bbe1b32bSmrg * font server reply swapping
4bbe1b32bSmrg */
5bbe1b32bSmrg/*
6bbe1b32bSmrg
7bbe1b32bSmrgCopyright 1990, 1991, 1998  The Open Group
8bbe1b32bSmrg
9bbe1b32bSmrgPermission to use, copy, modify, distribute, and sell this software and its
10bbe1b32bSmrgdocumentation for any purpose is hereby granted without fee, provided that
11bbe1b32bSmrgthe above copyright notice appear in all copies and that both that
12bbe1b32bSmrgcopyright notice and this permission notice appear in supporting
13bbe1b32bSmrgdocumentation.
14bbe1b32bSmrg
15bbe1b32bSmrgThe above copyright notice and this permission notice shall be included in
16bbe1b32bSmrgall copies or substantial portions of the Software.
17bbe1b32bSmrg
18bbe1b32bSmrgTHE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19bbe1b32bSmrgIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20bbe1b32bSmrgFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
21bbe1b32bSmrgOPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
22bbe1b32bSmrgAN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
23bbe1b32bSmrgCONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24bbe1b32bSmrg
25bbe1b32bSmrgExcept as contained in this notice, the name of The Open Group shall not be
26bbe1b32bSmrgused in advertising or otherwise to promote the sale, use or other dealings
27bbe1b32bSmrgin this Software without prior written authorization from The Open Group.
28bbe1b32bSmrg
29bbe1b32bSmrg * Copyright 1990, 1991 Network Computing Devices;
30bbe1b32bSmrg * Portions Copyright 1987 by Digital Equipment Corporation
31bbe1b32bSmrg *
32bbe1b32bSmrg * Permission to use, copy, modify, distribute, and sell this software and
33bbe1b32bSmrg * its documentation for any purpose is hereby granted without fee, provided
34bbe1b32bSmrg * that the above copyright notice appear in all copies and that both that
35bbe1b32bSmrg * copyright notice and this permission notice appear in supporting
36bbe1b32bSmrg * documentation, and that the names of Network Computing Devices, or Digital
37bbe1b32bSmrg * not be used in advertising or publicity pertaining to distribution
38bbe1b32bSmrg * of the software without specific, written prior permission.
39bbe1b32bSmrg *
40bbe1b32bSmrg * NETWORK COMPUTING DEVICES, AND DIGITAL DISCLAIM ALL WARRANTIES WITH
41bbe1b32bSmrg * REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF
42bbe1b32bSmrg * MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL NETWORK COMPUTING DEVICES,
43bbe1b32bSmrg * OR DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
44bbe1b32bSmrg * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
45bbe1b32bSmrg * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
46bbe1b32bSmrg * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
47bbe1b32bSmrg * THIS SOFTWARE.
48bbe1b32bSmrg */
49bbe1b32bSmrg/* $XFree86: xc/programs/xfs/difs/swaprep.c,v 1.4 2001/01/17 23:45:29 dawes Exp $ */
50bbe1b32bSmrg
51bbe1b32bSmrg#include	<swaprep.h>
52bbe1b32bSmrg#include	<swapreq.h>
53bbe1b32bSmrg
54bbe1b32bSmrg#include	<X11/fonts/FSproto.h>
55bbe1b32bSmrg#include	"clientstr.h"
56bbe1b32bSmrg
57bbe1b32bSmrgstatic void SwapConnSetupAccept(fsConnSetupAccept *pConnSetup, fsConnSetupAccept *pConnSetupT);
58bbe1b32bSmrg
59bbe1b32bSmrgvoid
60bbe1b32bSmrgSwap32Write(
61bbe1b32bSmrg    ClientPtr   client,
62bbe1b32bSmrg    int         size,
63bbe1b32bSmrg    long       *pbuf)
64bbe1b32bSmrg{
65bbe1b32bSmrg    int         n,
66bbe1b32bSmrg                i;
67bbe1b32bSmrg
68bbe1b32bSmrg    size >>= 2;
69bbe1b32bSmrg    for (i = 0; i < size; i++) {
70bbe1b32bSmrg	swapl(&pbuf[i], n);
71bbe1b32bSmrg    }
72bbe1b32bSmrg    (void) WriteToClient(client, size << 2, (char *) pbuf);
73bbe1b32bSmrg}
74bbe1b32bSmrg
75bbe1b32bSmrgvoid
76bbe1b32bSmrgSwap16Write(
77bbe1b32bSmrg    ClientPtr   client,
78bbe1b32bSmrg    int         size,
79bbe1b32bSmrg    short      *pbuf)
80bbe1b32bSmrg{
81bbe1b32bSmrg    int         n,
82bbe1b32bSmrg                i;
83bbe1b32bSmrg
84bbe1b32bSmrg    size >>= 1;
85bbe1b32bSmrg    for (i = 0; i < size; i++) {
86bbe1b32bSmrg	swaps(&pbuf[i], n);
87bbe1b32bSmrg    }
88bbe1b32bSmrg    (void) WriteToClient(client, size << 1, (char *) pbuf);
89bbe1b32bSmrg}
90bbe1b32bSmrg
91bbe1b32bSmrgvoid
92bbe1b32bSmrgCopySwap32Write(
93bbe1b32bSmrg    ClientPtr   client,
94bbe1b32bSmrg    int         size,
95bbe1b32bSmrg    long       *pbuf)
96bbe1b32bSmrg{
97bbe1b32bSmrg    int         bufsize = size;
98bbe1b32bSmrg    long       *pbufT;
99bbe1b32bSmrg    long       *from,
100bbe1b32bSmrg               *to,
101bbe1b32bSmrg               *fromLast,
102bbe1b32bSmrg               *toLast;
103bbe1b32bSmrg    long        tmpbuf[1];
104bbe1b32bSmrg
105bbe1b32bSmrg    while (!(pbufT = (long *) ALLOCATE_LOCAL(bufsize))) {
106bbe1b32bSmrg	bufsize >>= 1;
107bbe1b32bSmrg	if (bufsize == 4) {
108bbe1b32bSmrg	    pbufT = tmpbuf;
109bbe1b32bSmrg	    break;
110bbe1b32bSmrg	}
111bbe1b32bSmrg    }
112bbe1b32bSmrg    /* convert lengths from # of bytes to # of longs */
113bbe1b32bSmrg    size >>= 2;
114bbe1b32bSmrg    bufsize >>= 2;
115bbe1b32bSmrg
116bbe1b32bSmrg    from = pbuf;
117bbe1b32bSmrg    fromLast = from + size;
118bbe1b32bSmrg    while (from < fromLast) {
119bbe1b32bSmrg	int         nbytes;
120bbe1b32bSmrg
121bbe1b32bSmrg	to = pbufT;
122bbe1b32bSmrg	toLast = to + min(bufsize, fromLast - from);
123bbe1b32bSmrg	nbytes = (toLast - to) << 2;
124bbe1b32bSmrg	while (to < toLast) {
125bbe1b32bSmrg	    /*
126bbe1b32bSmrg	     * can't write "cpswapl(*from++, *to++)" because cpswapl is a
127bbe1b32bSmrg	     * macro that evaulates its args more than once
128bbe1b32bSmrg	     */
129bbe1b32bSmrg	    cpswapl(*from, *to);
130bbe1b32bSmrg	    from++;
131bbe1b32bSmrg	    to++;
132bbe1b32bSmrg	}
133bbe1b32bSmrg	(void) WriteToClient(client, nbytes, (char *) pbufT);
134bbe1b32bSmrg    }
135bbe1b32bSmrg
136bbe1b32bSmrg    if (pbufT != tmpbuf)
137bbe1b32bSmrg	DEALLOCATE_LOCAL((char *) pbufT);
138bbe1b32bSmrg}
139bbe1b32bSmrg
140bbe1b32bSmrgvoid
141bbe1b32bSmrgCopySwap16Write(
142bbe1b32bSmrg    ClientPtr   client,
143bbe1b32bSmrg    int         size,
144bbe1b32bSmrg    short      *pbuf)
145bbe1b32bSmrg{
146bbe1b32bSmrg    int         bufsize = size;
147bbe1b32bSmrg    short      *pbufT;
148bbe1b32bSmrg    register short *from,
149bbe1b32bSmrg               *to,
150bbe1b32bSmrg               *fromLast,
151bbe1b32bSmrg               *toLast;
152bbe1b32bSmrg    short       tmpbuf[2];
153bbe1b32bSmrg
154bbe1b32bSmrg    /* Allocate as big a buffer as we can... */
155bbe1b32bSmrg    while (!(pbufT = (short *) ALLOCATE_LOCAL(bufsize))) {
156bbe1b32bSmrg	bufsize >>= 1;
157bbe1b32bSmrg	if (bufsize == 4) {
158bbe1b32bSmrg	    pbufT = tmpbuf;
159bbe1b32bSmrg	    break;
160bbe1b32bSmrg	}
161bbe1b32bSmrg    }
162bbe1b32bSmrg
163bbe1b32bSmrg    /* convert lengths from # of bytes to # of shorts */
164bbe1b32bSmrg    size >>= 1;
165bbe1b32bSmrg    bufsize >>= 1;
166bbe1b32bSmrg
167bbe1b32bSmrg    from = pbuf;
168bbe1b32bSmrg    fromLast = from + size;
169bbe1b32bSmrg    while (from < fromLast) {
170bbe1b32bSmrg	int         nbytes;
171bbe1b32bSmrg
172bbe1b32bSmrg	to = pbufT;
173bbe1b32bSmrg	toLast = to + min(bufsize, fromLast - from);
174bbe1b32bSmrg	nbytes = (toLast - to) << 1;
175bbe1b32bSmrg	while (to < toLast) {
176bbe1b32bSmrg	    /*
177bbe1b32bSmrg	     * can't write "cpswaps(*from++, *to++)" because cpswaps is a
178bbe1b32bSmrg	     * macro that evaulates its args more than once
179bbe1b32bSmrg	     */
180bbe1b32bSmrg	    cpswaps(*from, *to);
181bbe1b32bSmrg	    from++;
182bbe1b32bSmrg	    to++;
183bbe1b32bSmrg	}
184bbe1b32bSmrg	(void) WriteToClient(client, nbytes, (char *) pbufT);
185bbe1b32bSmrg    }
186bbe1b32bSmrg
187bbe1b32bSmrg    if (pbufT != tmpbuf)
188bbe1b32bSmrg	DEALLOCATE_LOCAL((char *) pbufT);
189bbe1b32bSmrg}
190bbe1b32bSmrg
191bbe1b32bSmrg
192bbe1b32bSmrg#undef  pRep
193bbe1b32bSmrg#define pRep ((fsGenericReply *)data)
194bbe1b32bSmrg
195bbe1b32bSmrgvoid
196bbe1b32bSmrgSGenericReply(
197bbe1b32bSmrg    ClientPtr   client,
198bbe1b32bSmrg    int         size,
199bbe1b32bSmrg    void *	data)
200bbe1b32bSmrg{
201bbe1b32bSmrg    pRep->sequenceNumber = lswaps(pRep->sequenceNumber);
202bbe1b32bSmrg    pRep->length = lswapl(pRep->length);
203bbe1b32bSmrg    (void) WriteToClient(client, size, (char *) pRep);
204bbe1b32bSmrg}
205bbe1b32bSmrg
206bbe1b32bSmrg
207bbe1b32bSmrg#undef  pRep
208bbe1b32bSmrg#define pRep ((fsListExtensionsReply *)data)
209bbe1b32bSmrg
210bbe1b32bSmrgvoid
211bbe1b32bSmrgSListExtensionsReply(
212bbe1b32bSmrg    ClientPtr   client,
213bbe1b32bSmrg    int         size,
214bbe1b32bSmrg    void *	data)
215bbe1b32bSmrg{
216bbe1b32bSmrg    pRep->sequenceNumber = lswaps(pRep->sequenceNumber);
217bbe1b32bSmrg    pRep->length = lswapl(pRep->length);
218bbe1b32bSmrg    (void) WriteToClient(client, size, (char *) pRep);
219bbe1b32bSmrg}
220bbe1b32bSmrg
221bbe1b32bSmrg#undef  pRep
222bbe1b32bSmrg#define pRep ((fsQueryExtensionReply *)data)
223bbe1b32bSmrg
224bbe1b32bSmrgvoid
225bbe1b32bSmrgSQueryExtensionReply(
226bbe1b32bSmrg    ClientPtr   client,
227bbe1b32bSmrg    int         size,
228bbe1b32bSmrg    void *	data)
229bbe1b32bSmrg{
230bbe1b32bSmrg    pRep->sequenceNumber = lswaps(pRep->sequenceNumber);
231bbe1b32bSmrg    pRep->length = lswapl(pRep->length);
232bbe1b32bSmrg    pRep->major_version = lswaps(pRep->major_version);
233bbe1b32bSmrg    pRep->minor_version = lswaps(pRep->minor_version);
234bbe1b32bSmrg    (void) WriteToClient(client, size, (char *) pRep);
235bbe1b32bSmrg}
236bbe1b32bSmrg
237bbe1b32bSmrg#undef  pRep
238bbe1b32bSmrg#define pRep ((fsListCataloguesReply *)data)
239bbe1b32bSmrg
240bbe1b32bSmrgvoid
241bbe1b32bSmrgSListCataloguesReply(
242bbe1b32bSmrg    ClientPtr   client,
243bbe1b32bSmrg    int         size,
244bbe1b32bSmrg    void *	data)
245bbe1b32bSmrg{
246bbe1b32bSmrg    pRep->sequenceNumber = lswaps(pRep->sequenceNumber);
247bbe1b32bSmrg    pRep->length = lswapl(pRep->length);
248bbe1b32bSmrg    pRep->num_replies = lswapl(pRep->num_replies);
249bbe1b32bSmrg    pRep->num_catalogues = lswapl(pRep->num_catalogues);
250bbe1b32bSmrg    (void) WriteToClient(client, size, (char *) pRep);
251bbe1b32bSmrg}
252bbe1b32bSmrg
253bbe1b32bSmrg#undef  pRep
254bbe1b32bSmrg#define pRep ((fsCreateACReply *)data)
255bbe1b32bSmrg
256bbe1b32bSmrgvoid
257bbe1b32bSmrgSCreateACReply(
258bbe1b32bSmrg    ClientPtr   client,
259bbe1b32bSmrg    int         size,
260bbe1b32bSmrg    void *	data)
261bbe1b32bSmrg{
262bbe1b32bSmrg    pRep->sequenceNumber = lswaps(pRep->sequenceNumber);
263bbe1b32bSmrg    pRep->length = lswapl(pRep->length);
264bbe1b32bSmrg    pRep->status = lswaps(pRep->status);
265bbe1b32bSmrg    (void) WriteToClient(client, size, (char *) pRep);
266bbe1b32bSmrg}
267bbe1b32bSmrg
268bbe1b32bSmrg#undef  pRep
269bbe1b32bSmrg#define pRep ((fsGetEventMaskReply *)data)
270bbe1b32bSmrg
271bbe1b32bSmrgvoid
272bbe1b32bSmrgSGetEventMaskReply(
273bbe1b32bSmrg    ClientPtr   client,
274bbe1b32bSmrg    int         size,
275bbe1b32bSmrg    void *	data)
276bbe1b32bSmrg{
277bbe1b32bSmrg    pRep->sequenceNumber = lswaps(pRep->sequenceNumber);
278bbe1b32bSmrg    pRep->length = lswapl(pRep->length);
279bbe1b32bSmrg    pRep->event_mask = lswapl(pRep->event_mask);
280bbe1b32bSmrg    (void) WriteToClient(client, size, (char *) pRep);
281bbe1b32bSmrg}
282bbe1b32bSmrg
283bbe1b32bSmrg#undef  pRep
284bbe1b32bSmrg#define pRep ((fsGetResolutionReply *)data)
285bbe1b32bSmrg
286bbe1b32bSmrgvoid
287bbe1b32bSmrgSGetResolutionReply(
288bbe1b32bSmrg    ClientPtr   client,
289bbe1b32bSmrg    int         size,
290bbe1b32bSmrg    void *	data)
291bbe1b32bSmrg{
292bbe1b32bSmrg    pRep->sequenceNumber = lswaps(pRep->sequenceNumber);
293bbe1b32bSmrg    pRep->length = lswapl(pRep->length);
294bbe1b32bSmrg    (void) WriteToClient(client, size, (char *) pRep);
295bbe1b32bSmrg}
296bbe1b32bSmrg
297bbe1b32bSmrg#undef  pRep
298bbe1b32bSmrg#define pRep ((fsListFontsReply *)data)
299bbe1b32bSmrg
300bbe1b32bSmrgvoid
301bbe1b32bSmrgSListFontsReply(
302bbe1b32bSmrg    ClientPtr   client,
303bbe1b32bSmrg    int         size,
304bbe1b32bSmrg    void *	data)
305bbe1b32bSmrg{
306bbe1b32bSmrg    pRep->sequenceNumber = lswaps(pRep->sequenceNumber);
307bbe1b32bSmrg    pRep->length = lswapl(pRep->length);
308bbe1b32bSmrg    pRep->following = lswapl(pRep->following);
309bbe1b32bSmrg    pRep->nFonts = lswapl(pRep->nFonts);
310bbe1b32bSmrg    (void) WriteToClient(client, size, (char *) pRep);
311bbe1b32bSmrg}
312bbe1b32bSmrg
313bbe1b32bSmrg#define SwapXFontInfoHeader(reply) \
314bbe1b32bSmrg    reply->font_header_flags = lswapl(reply->font_header_flags); \
315bbe1b32bSmrg \
316bbe1b32bSmrg    reply->font_header_min_bounds_left = lswaps(reply->font_header_min_bounds_left); \
317bbe1b32bSmrg    reply->font_header_min_bounds_right = lswaps(reply->font_header_min_bounds_right); \
318bbe1b32bSmrg    reply->font_header_min_bounds_width = lswaps(reply->font_header_min_bounds_width); \
319bbe1b32bSmrg    reply->font_header_min_bounds_ascent = lswaps(reply->font_header_min_bounds_ascent); \
320bbe1b32bSmrg    reply->font_header_min_bounds_descent = lswaps(reply->font_header_min_bounds_descent); \
321bbe1b32bSmrg    reply->font_header_min_bounds_attributes = lswaps(reply->font_header_min_bounds_attributes); \
322bbe1b32bSmrg \
323bbe1b32bSmrg    reply->font_header_max_bounds_left = lswaps(reply->font_header_max_bounds_left); \
324bbe1b32bSmrg    reply->font_header_max_bounds_right = lswaps(reply->font_header_max_bounds_right); \
325bbe1b32bSmrg    reply->font_header_max_bounds_width = lswaps(reply->font_header_max_bounds_width); \
326bbe1b32bSmrg    reply->font_header_max_bounds_ascent = lswaps(reply->font_header_max_bounds_ascent); \
327bbe1b32bSmrg    reply->font_header_max_bounds_descent = lswaps(reply->font_header_max_bounds_descent); \
328bbe1b32bSmrg    reply->font_header_max_bounds_attributes = lswaps(reply->font_header_max_bounds_attributes); \
329bbe1b32bSmrg \
330bbe1b32bSmrg    reply->font_header_font_ascent = lswaps(reply->font_header_font_ascent); \
331bbe1b32bSmrg    reply->font_header_font_descent = lswaps(reply->font_header_font_descent)
332bbe1b32bSmrg
333bbe1b32bSmrg#undef  pRep
334bbe1b32bSmrg#define pRep ((fsListFontsWithXInfoReply *)data)
335bbe1b32bSmrg
336bbe1b32bSmrgvoid
337bbe1b32bSmrgSListFontsWithXInfoReply(
338bbe1b32bSmrg    ClientPtr   client,
339bbe1b32bSmrg    int         size,
340bbe1b32bSmrg    void *	data)
341bbe1b32bSmrg{
342bbe1b32bSmrg    pRep->sequenceNumber = lswaps(pRep->sequenceNumber);
343bbe1b32bSmrg    pRep->length = lswapl(pRep->length);
344bbe1b32bSmrg    if (size > SIZEOF(fsGenericReply)) { 	/* not last in series? */
345bbe1b32bSmrg	pRep->nReplies = lswapl(pRep->nReplies);
346bbe1b32bSmrg	SwapXFontInfoHeader(pRep);
347bbe1b32bSmrg    }
348bbe1b32bSmrg    (void) WriteToClient(client, size, (char *) pRep);
349bbe1b32bSmrg}
350bbe1b32bSmrg
351bbe1b32bSmrg#undef  pRep
352bbe1b32bSmrg#define pRep ((fsOpenBitmapFontReply *)data)
353bbe1b32bSmrg
354bbe1b32bSmrgvoid
355bbe1b32bSmrgSOpenBitmapFontReply(
356bbe1b32bSmrg    ClientPtr   client,
357bbe1b32bSmrg    int         size,
358bbe1b32bSmrg    void *	data)
359bbe1b32bSmrg{
360bbe1b32bSmrg    pRep->sequenceNumber = lswaps(pRep->sequenceNumber);
361bbe1b32bSmrg    pRep->length = lswapl(pRep->length);
362bbe1b32bSmrg    pRep->otherid = lswapl(pRep->otherid);
363bbe1b32bSmrg
364bbe1b32bSmrg    (void) WriteToClient(client, size, (char *) pRep);
365bbe1b32bSmrg}
366bbe1b32bSmrg
367bbe1b32bSmrg#undef  pRep
368bbe1b32bSmrg#define pRep ((fsQueryXInfoReply *)data)
369bbe1b32bSmrg
370bbe1b32bSmrgvoid
371bbe1b32bSmrgSQueryXInfoReply(
372bbe1b32bSmrg    ClientPtr   client,
373bbe1b32bSmrg    int         size,
374bbe1b32bSmrg    void *	data)
375bbe1b32bSmrg{
376bbe1b32bSmrg    pRep->sequenceNumber = lswaps(pRep->sequenceNumber);
377bbe1b32bSmrg    pRep->length = lswapl(pRep->length);
378bbe1b32bSmrg    SwapXFontInfoHeader(pRep);
379bbe1b32bSmrg    (void) WriteToClient(client, size, (char *) pRep);
380bbe1b32bSmrg}
381bbe1b32bSmrg
382bbe1b32bSmrg#undef  pRep
383bbe1b32bSmrg#define pRep ((fsQueryXExtents8Reply *)data)
384bbe1b32bSmrg
385bbe1b32bSmrgvoid
386bbe1b32bSmrgSQueryXExtentsReply(
387bbe1b32bSmrg    ClientPtr   client,
388bbe1b32bSmrg    int         size,
389bbe1b32bSmrg    void *	data) /* QueryXExtents16Reply is the same */
390bbe1b32bSmrg{
391bbe1b32bSmrg    pRep->sequenceNumber = lswaps(pRep->sequenceNumber);
392bbe1b32bSmrg    pRep->length = lswapl(pRep->length);
393bbe1b32bSmrg    pRep->num_extents = lswapl(pRep->num_extents);
394bbe1b32bSmrg    (void) WriteToClient(client, size, (char *) pRep);
395bbe1b32bSmrg}
396bbe1b32bSmrg
397bbe1b32bSmrg#undef  pRep
398bbe1b32bSmrg#define pRep ((fsQueryXBitmaps8Reply *)data)
399bbe1b32bSmrg
400bbe1b32bSmrgvoid
401bbe1b32bSmrgSQueryXBitmapsReply(
402bbe1b32bSmrg    ClientPtr   client,
403bbe1b32bSmrg    int         size,
404bbe1b32bSmrg    void *	data) /* QueryXBitmaps16Reply is the same */
405bbe1b32bSmrg{
406bbe1b32bSmrg    pRep->sequenceNumber = lswaps(pRep->sequenceNumber);
407bbe1b32bSmrg    pRep->length = lswapl(pRep->length);
408bbe1b32bSmrg    pRep->replies_hint = lswapl(pRep->replies_hint);
409bbe1b32bSmrg    pRep->num_chars = lswapl(pRep->num_chars);
410bbe1b32bSmrg    pRep->nbytes = lswapl(pRep->nbytes);
411bbe1b32bSmrg    (void) WriteToClient(client, size, (char *) pRep);
412bbe1b32bSmrg}
413bbe1b32bSmrg
414bbe1b32bSmrgvoid
415bbe1b32bSmrgSErrorEvent(fsError *error, fsError *perror)
416bbe1b32bSmrg{
417bbe1b32bSmrg    *perror = *error;
418bbe1b32bSmrg    perror->sequenceNumber = lswaps(perror->sequenceNumber);
419bbe1b32bSmrg    perror->length = lswapl(perror->length);
420bbe1b32bSmrg    perror->timestamp = lswapl(perror->timestamp);
421bbe1b32bSmrg}
422bbe1b32bSmrg
423bbe1b32bSmrgvoid
424bbe1b32bSmrgWriteSConnectionInfo(
425bbe1b32bSmrg    ClientPtr   client,
426bbe1b32bSmrg    unsigned long size,
427bbe1b32bSmrg    char       *pInfo)
428bbe1b32bSmrg{
429bbe1b32bSmrg    char       *pInfoT,
430bbe1b32bSmrg               *pInfoTBase;
431bbe1b32bSmrg    fsConnSetupAccept *pConnSetup = (fsConnSetupAccept *) pInfo;
432bbe1b32bSmrg    int         i;
433bbe1b32bSmrg
434bbe1b32bSmrg    pInfoT = pInfoTBase = (char *) ALLOCATE_LOCAL(size);
435bbe1b32bSmrg    if (!pInfoT) {
436bbe1b32bSmrg	client->noClientException = -2;
437bbe1b32bSmrg	return;
438bbe1b32bSmrg    }
439bbe1b32bSmrg    SwapConnSetupAccept(pConnSetup, (fsConnSetupAccept *) pInfoT);
440bbe1b32bSmrg    pInfoT += SIZEOF(fsConnSetup);
441bbe1b32bSmrg    pInfo += SIZEOF(fsConnSetup);
442bbe1b32bSmrg
443bbe1b32bSmrg    i = (pConnSetup->vendor_len + 3) & ~3;
444bbe1b32bSmrg    memmove( pInfoT, pInfo, i);
445bbe1b32bSmrg
446bbe1b32bSmrg    (void) WriteToClient(client, (int) size, (char *) pInfoTBase);
447bbe1b32bSmrg    DEALLOCATE_LOCAL(pInfoTBase);
448bbe1b32bSmrg}
449bbe1b32bSmrg
450bbe1b32bSmrgstatic void
451bbe1b32bSmrgSwapConnSetupAccept(fsConnSetupAccept *pConnSetup, fsConnSetupAccept *pConnSetupT)
452bbe1b32bSmrg{
453bbe1b32bSmrg    pConnSetupT->length = lswapl(pConnSetup->length);
454bbe1b32bSmrg    pConnSetupT->max_request_len = lswaps(pConnSetup->max_request_len);
455bbe1b32bSmrg    pConnSetupT->vendor_len = lswaps(pConnSetup->vendor_len);
456bbe1b32bSmrg    pConnSetupT->release_number = lswapl(pConnSetup->release_number);
457bbe1b32bSmrg}
458bbe1b32bSmrg
459bbe1b32bSmrgvoid
460bbe1b32bSmrgWriteSConnSetup(ClientPtr client, fsConnSetup *pcsp)
461bbe1b32bSmrg{
462bbe1b32bSmrg    fsConnSetup cspT;
463bbe1b32bSmrg
464bbe1b32bSmrg    cspT.status = lswaps(pcsp->status);
465bbe1b32bSmrg    cspT.major_version = lswaps(pcsp->major_version);
466bbe1b32bSmrg    cspT.minor_version = lswaps(pcsp->minor_version);
467bbe1b32bSmrg    cspT.num_alternates = pcsp->num_alternates;
468bbe1b32bSmrg    cspT.auth_index = pcsp->auth_index;
469bbe1b32bSmrg    cspT.alternate_len = lswaps(pcsp->alternate_len);
470bbe1b32bSmrg    cspT.auth_len = lswaps(pcsp->auth_len);
471bbe1b32bSmrg    (void) WriteToClient(client, SIZEOF(fsConnSetup), (char *) &cspT);
472bbe1b32bSmrg}
473bbe1b32bSmrg
474bbe1b32bSmrgstatic void
475bbe1b32bSmrgSwapPropOffset(char *po)
476bbe1b32bSmrg{
477bbe1b32bSmrg    int i, n;
478bbe1b32bSmrg
479bbe1b32bSmrg    for (i=0; i<4; i++)
480bbe1b32bSmrg    {
481bbe1b32bSmrg	swapl(po, n);
482bbe1b32bSmrg	po += 4;
483bbe1b32bSmrg    }
484bbe1b32bSmrg}
485bbe1b32bSmrg
486bbe1b32bSmrgvoid
487bbe1b32bSmrgSwapPropInfo(fsPropInfo *pi)
488bbe1b32bSmrg{
489bbe1b32bSmrg    int i;
490bbe1b32bSmrg    char *po;
491bbe1b32bSmrg
492bbe1b32bSmrg    po = (char *) pi + SIZEOF(fsPropInfo);
493bbe1b32bSmrg    for (i = 0; i < pi->num_offsets; i++)
494bbe1b32bSmrg    {
495bbe1b32bSmrg	SwapPropOffset(po);
496bbe1b32bSmrg	po += SIZEOF(fsPropOffset);
497bbe1b32bSmrg    }
498bbe1b32bSmrg
499bbe1b32bSmrg    pi->num_offsets = lswapl(pi->num_offsets);
500bbe1b32bSmrg    pi->data_len = lswapl(pi->data_len);
501bbe1b32bSmrg}
502bbe1b32bSmrg
503bbe1b32bSmrgvoid
504bbe1b32bSmrgSwapExtents(fsXCharInfo *extents, int num)
505bbe1b32bSmrg{
506bbe1b32bSmrg    SwapShorts((short *)extents, num * (SIZEOF(fsXCharInfo) / 2));
507bbe1b32bSmrg}
508