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