swaprep.c 36 KB

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