home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Source Code 1993 July / THE_SOURCE_CODE_CD_ROM.iso / X / mit / server / dix / swaprep.c < prev    next >
Encoding:
C/C++ Source or Header  |  1991-05-09  |  36.4 KB  |  1,374 lines

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