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