swaprep.c 35 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175
  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. void
  56. Swap32Write(ClientPtr pClient, int size, 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. WriteToClient(pClient, size << 2, pbuf);
  67. }
  68. /**
  69. *
  70. * \param size size in bytes
  71. */
  72. 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 = malloc(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. WriteToClient(pClient, nbytes, pbufT);
  105. }
  106. if (pbufT != tmpbuf)
  107. free(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 = malloc(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. WriteToClient(pClient, nbytes, pbufT);
  146. }
  147. if (pbufT != tmpbuf)
  148. free(pbufT);
  149. }
  150. /* Extra-small reply */
  151. void
  152. SGenericReply(ClientPtr pClient, int size, xGenericReply * pRep)
  153. {
  154. swaps(&pRep->sequenceNumber);
  155. WriteToClient(pClient, size, 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. WriteToClient(pClient, size, 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. WriteToClient(pClient, size, 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. WriteToClient(pClient, size, pRep);
  195. }
  196. void
  197. SInternAtomReply(ClientPtr pClient, int size, xInternAtomReply * pRep)
  198. {
  199. swaps(&pRep->sequenceNumber);
  200. swapl(&pRep->atom);
  201. WriteToClient(pClient, size, 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. WriteToClient(pClient, size, 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. WriteToClient(pClient, size, 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. WriteToClient(pClient, size, pRep);
  228. }
  229. void
  230. SGetSelectionOwnerReply(ClientPtr pClient, int size,
  231. xGetSelectionOwnerReply * pRep)
  232. {
  233. swaps(&pRep->sequenceNumber);
  234. swapl(&pRep->owner);
  235. WriteToClient(pClient, size, 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. WriteToClient(pClient, size, pRep);
  249. }
  250. static 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. WriteToClient(pClient, size, 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. WriteToClient(pClient, size, 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. WriteToClient(pClient, size, pRep);
  286. }
  287. void
  288. SGetInputFocusReply(ClientPtr pClient, int size, xGetInputFocusReply * pRep)
  289. {
  290. swaps(&pRep->sequenceNumber);
  291. swapl(&pRep->focus);
  292. WriteToClient(pClient, size, 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. WriteToClient(pClient, size, 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. WriteToClient(pClient, size, 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. WriteToClient(pClient, size, 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. WriteToClient(pClient, size, pRep);
  379. }
  380. void
  381. SListFontsWithInfoReply(ClientPtr pClient, int size,
  382. xListFontsWithInfoReply * pRep)
  383. {
  384. SwapFont((xQueryFontReply *) pRep, FALSE);
  385. WriteToClient(pClient, size, 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. WriteToClient(pClient, size, 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. WriteToClient(pClient, size, 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. WriteToClient(pClient, size, pRep);
  412. }
  413. void
  414. SAllocColorReply(ClientPtr pClient, int size, xAllocColorReply * pRep)
  415. {
  416. swaps(&pRep->sequenceNumber);
  417. swaps(&pRep->red);
  418. swaps(&pRep->green);
  419. swaps(&pRep->blue);
  420. swapl(&pRep->pixel);
  421. WriteToClient(pClient, size, pRep);
  422. }
  423. void
  424. SAllocNamedColorReply(ClientPtr pClient, int size, xAllocNamedColorReply * pRep)
  425. {
  426. swaps(&pRep->sequenceNumber);
  427. swapl(&pRep->pixel);
  428. swaps(&pRep->exactRed);
  429. swaps(&pRep->exactGreen);
  430. swaps(&pRep->exactBlue);
  431. swaps(&pRep->screenRed);
  432. swaps(&pRep->screenGreen);
  433. swaps(&pRep->screenBlue);
  434. WriteToClient(pClient, size, pRep);
  435. }
  436. void
  437. SAllocColorCellsReply(ClientPtr pClient, int size, xAllocColorCellsReply * pRep)
  438. {
  439. swaps(&pRep->sequenceNumber);
  440. swapl(&pRep->length);
  441. swaps(&pRep->nPixels);
  442. swaps(&pRep->nMasks);
  443. WriteToClient(pClient, size, pRep);
  444. }
  445. void
  446. SAllocColorPlanesReply(ClientPtr pClient, int size,
  447. xAllocColorPlanesReply * pRep)
  448. {
  449. swaps(&pRep->sequenceNumber);
  450. swapl(&pRep->length);
  451. swaps(&pRep->nPixels);
  452. swapl(&pRep->redMask);
  453. swapl(&pRep->greenMask);
  454. swapl(&pRep->blueMask);
  455. WriteToClient(pClient, size, pRep);
  456. }
  457. static void
  458. SwapRGB(xrgb * prgb)
  459. {
  460. swaps(&prgb->red);
  461. swaps(&prgb->green);
  462. swaps(&prgb->blue);
  463. }
  464. void
  465. SQColorsExtend(ClientPtr pClient, int size, xrgb * prgb)
  466. {
  467. int i, n;
  468. xrgb *prgbT;
  469. n = size / sizeof(xrgb);
  470. prgbT = prgb;
  471. for (i = 0; i < n; i++) {
  472. SwapRGB(prgbT);
  473. prgbT++;
  474. }
  475. WriteToClient(pClient, size, prgb);
  476. }
  477. void
  478. SQueryColorsReply(ClientPtr pClient, int size, xQueryColorsReply * pRep)
  479. {
  480. swaps(&pRep->sequenceNumber);
  481. swapl(&pRep->length);
  482. swaps(&pRep->nColors);
  483. WriteToClient(pClient, size, pRep);
  484. }
  485. void
  486. SLookupColorReply(ClientPtr pClient, int size, xLookupColorReply * pRep)
  487. {
  488. swaps(&pRep->sequenceNumber);
  489. swaps(&pRep->exactRed);
  490. swaps(&pRep->exactGreen);
  491. swaps(&pRep->exactBlue);
  492. swaps(&pRep->screenRed);
  493. swaps(&pRep->screenGreen);
  494. swaps(&pRep->screenBlue);
  495. WriteToClient(pClient, size, pRep);
  496. }
  497. void
  498. SQueryBestSizeReply(ClientPtr pClient, int size, xQueryBestSizeReply * pRep)
  499. {
  500. swaps(&pRep->sequenceNumber);
  501. swaps(&pRep->width);
  502. swaps(&pRep->height);
  503. WriteToClient(pClient, size, pRep);
  504. }
  505. void
  506. SListExtensionsReply(ClientPtr pClient, int size, xListExtensionsReply * pRep)
  507. {
  508. swaps(&pRep->sequenceNumber);
  509. swapl(&pRep->length);
  510. WriteToClient(pClient, size, pRep);
  511. }
  512. void
  513. SGetKeyboardMappingReply(ClientPtr pClient, int size,
  514. xGetKeyboardMappingReply * pRep)
  515. {
  516. swaps(&pRep->sequenceNumber);
  517. swapl(&pRep->length);
  518. WriteToClient(pClient, size, pRep);
  519. }
  520. void
  521. SGetPointerMappingReply(ClientPtr pClient, int size,
  522. xGetPointerMappingReply * pRep)
  523. {
  524. swaps(&pRep->sequenceNumber);
  525. swapl(&pRep->length);
  526. WriteToClient(pClient, size, pRep);
  527. }
  528. void
  529. SGetModifierMappingReply(ClientPtr pClient, int size,
  530. xGetModifierMappingReply * pRep)
  531. {
  532. swaps(&pRep->sequenceNumber);
  533. swapl(&pRep->length);
  534. WriteToClient(pClient, size, pRep);
  535. }
  536. void
  537. SGetKeyboardControlReply(ClientPtr pClient, int size,
  538. xGetKeyboardControlReply * pRep)
  539. {
  540. swaps(&pRep->sequenceNumber);
  541. swapl(&pRep->length);
  542. swapl(&pRep->ledMask);
  543. swaps(&pRep->bellPitch);
  544. swaps(&pRep->bellDuration);
  545. WriteToClient(pClient, size, pRep);
  546. }
  547. void
  548. SGetPointerControlReply(ClientPtr pClient, int size,
  549. xGetPointerControlReply * pRep)
  550. {
  551. swaps(&pRep->sequenceNumber);
  552. swaps(&pRep->accelNumerator);
  553. swaps(&pRep->accelDenominator);
  554. swaps(&pRep->threshold);
  555. WriteToClient(pClient, size, pRep);
  556. }
  557. void
  558. SGetScreenSaverReply(ClientPtr pClient, int size, xGetScreenSaverReply * pRep)
  559. {
  560. swaps(&pRep->sequenceNumber);
  561. swaps(&pRep->timeout);
  562. swaps(&pRep->interval);
  563. WriteToClient(pClient, size, pRep);
  564. }
  565. void
  566. SLHostsExtend(ClientPtr pClient, int size, char *buf)
  567. {
  568. char *bufT = buf;
  569. char *endbuf = buf + size;
  570. while (bufT < endbuf) {
  571. xHostEntry *host = (xHostEntry *) bufT;
  572. int len = host->length;
  573. swaps(&host->length);
  574. bufT += sizeof(xHostEntry) + pad_to_int32(len);
  575. }
  576. WriteToClient(pClient, size, buf);
  577. }
  578. void
  579. SListHostsReply(ClientPtr pClient, int size, xListHostsReply * pRep)
  580. {
  581. swaps(&pRep->sequenceNumber);
  582. swapl(&pRep->length);
  583. swaps(&pRep->nHosts);
  584. WriteToClient(pClient, size, pRep);
  585. }
  586. void
  587. SErrorEvent(xError * from, xError * to)
  588. {
  589. to->type = X_Error;
  590. to->errorCode = from->errorCode;
  591. cpswaps(from->sequenceNumber, to->sequenceNumber);
  592. cpswapl(from->resourceID, to->resourceID);
  593. cpswaps(from->minorCode, to->minorCode);
  594. to->majorCode = from->majorCode;
  595. }
  596. void
  597. SKeyButtonPtrEvent(xEvent *from, xEvent *to)
  598. {
  599. to->u.u.type = from->u.u.type;
  600. to->u.u.detail = from->u.u.detail;
  601. cpswaps(from->u.u.sequenceNumber, to->u.u.sequenceNumber);
  602. cpswapl(from->u.keyButtonPointer.time, to->u.keyButtonPointer.time);
  603. cpswapl(from->u.keyButtonPointer.root, to->u.keyButtonPointer.root);
  604. cpswapl(from->u.keyButtonPointer.event, to->u.keyButtonPointer.event);
  605. cpswapl(from->u.keyButtonPointer.child, to->u.keyButtonPointer.child);
  606. cpswaps(from->u.keyButtonPointer.rootX, to->u.keyButtonPointer.rootX);
  607. cpswaps(from->u.keyButtonPointer.rootY, to->u.keyButtonPointer.rootY);
  608. cpswaps(from->u.keyButtonPointer.eventX, to->u.keyButtonPointer.eventX);
  609. cpswaps(from->u.keyButtonPointer.eventY, to->u.keyButtonPointer.eventY);
  610. cpswaps(from->u.keyButtonPointer.state, to->u.keyButtonPointer.state);
  611. to->u.keyButtonPointer.sameScreen = from->u.keyButtonPointer.sameScreen;
  612. }
  613. void
  614. SEnterLeaveEvent(xEvent *from, xEvent *to)
  615. {
  616. to->u.u.type = from->u.u.type;
  617. to->u.u.detail = from->u.u.detail;
  618. cpswaps(from->u.u.sequenceNumber, to->u.u.sequenceNumber);
  619. cpswapl(from->u.enterLeave.time, to->u.enterLeave.time);
  620. cpswapl(from->u.enterLeave.root, to->u.enterLeave.root);
  621. cpswapl(from->u.enterLeave.event, to->u.enterLeave.event);
  622. cpswapl(from->u.enterLeave.child, to->u.enterLeave.child);
  623. cpswaps(from->u.enterLeave.rootX, to->u.enterLeave.rootX);
  624. cpswaps(from->u.enterLeave.rootY, to->u.enterLeave.rootY);
  625. cpswaps(from->u.enterLeave.eventX, to->u.enterLeave.eventX);
  626. cpswaps(from->u.enterLeave.eventY, to->u.enterLeave.eventY);
  627. cpswaps(from->u.enterLeave.state, to->u.enterLeave.state);
  628. to->u.enterLeave.mode = from->u.enterLeave.mode;
  629. to->u.enterLeave.flags = from->u.enterLeave.flags;
  630. }
  631. void
  632. SFocusEvent(xEvent *from, xEvent *to)
  633. {
  634. to->u.u.type = from->u.u.type;
  635. to->u.u.detail = from->u.u.detail;
  636. cpswaps(from->u.u.sequenceNumber, to->u.u.sequenceNumber);
  637. cpswapl(from->u.focus.window, to->u.focus.window);
  638. to->u.focus.mode = from->u.focus.mode;
  639. }
  640. void
  641. SExposeEvent(xEvent *from, xEvent *to)
  642. {
  643. to->u.u.type = from->u.u.type;
  644. cpswaps(from->u.u.sequenceNumber, to->u.u.sequenceNumber);
  645. cpswapl(from->u.expose.window, to->u.expose.window);
  646. cpswaps(from->u.expose.x, to->u.expose.x);
  647. cpswaps(from->u.expose.y, to->u.expose.y);
  648. cpswaps(from->u.expose.width, to->u.expose.width);
  649. cpswaps(from->u.expose.height, to->u.expose.height);
  650. cpswaps(from->u.expose.count, to->u.expose.count);
  651. }
  652. void
  653. SGraphicsExposureEvent(xEvent *from, xEvent *to)
  654. {
  655. to->u.u.type = from->u.u.type;
  656. cpswaps(from->u.u.sequenceNumber, to->u.u.sequenceNumber);
  657. cpswapl(from->u.graphicsExposure.drawable, to->u.graphicsExposure.drawable);
  658. cpswaps(from->u.graphicsExposure.x, to->u.graphicsExposure.x);
  659. cpswaps(from->u.graphicsExposure.y, to->u.graphicsExposure.y);
  660. cpswaps(from->u.graphicsExposure.width, to->u.graphicsExposure.width);
  661. cpswaps(from->u.graphicsExposure.height, to->u.graphicsExposure.height);
  662. cpswaps(from->u.graphicsExposure.minorEvent,
  663. to->u.graphicsExposure.minorEvent);
  664. cpswaps(from->u.graphicsExposure.count, to->u.graphicsExposure.count);
  665. to->u.graphicsExposure.majorEvent = from->u.graphicsExposure.majorEvent;
  666. }
  667. void
  668. SNoExposureEvent(xEvent *from, xEvent *to)
  669. {
  670. to->u.u.type = from->u.u.type;
  671. cpswaps(from->u.u.sequenceNumber, to->u.u.sequenceNumber);
  672. cpswapl(from->u.noExposure.drawable, to->u.noExposure.drawable);
  673. cpswaps(from->u.noExposure.minorEvent, to->u.noExposure.minorEvent);
  674. to->u.noExposure.majorEvent = from->u.noExposure.majorEvent;
  675. }
  676. void
  677. SVisibilityEvent(xEvent *from, xEvent *to)
  678. {
  679. to->u.u.type = from->u.u.type;
  680. cpswaps(from->u.u.sequenceNumber, to->u.u.sequenceNumber);
  681. cpswapl(from->u.visibility.window, to->u.visibility.window);
  682. to->u.visibility.state = from->u.visibility.state;
  683. }
  684. void
  685. SCreateNotifyEvent(xEvent *from, xEvent *to)
  686. {
  687. to->u.u.type = from->u.u.type;
  688. cpswaps(from->u.u.sequenceNumber, to->u.u.sequenceNumber);
  689. cpswapl(from->u.createNotify.window, to->u.createNotify.window);
  690. cpswapl(from->u.createNotify.parent, to->u.createNotify.parent);
  691. cpswaps(from->u.createNotify.x, to->u.createNotify.x);
  692. cpswaps(from->u.createNotify.y, to->u.createNotify.y);
  693. cpswaps(from->u.createNotify.width, to->u.createNotify.width);
  694. cpswaps(from->u.createNotify.height, to->u.createNotify.height);
  695. cpswaps(from->u.createNotify.borderWidth, to->u.createNotify.borderWidth);
  696. to->u.createNotify.override = from->u.createNotify.override;
  697. }
  698. void
  699. SDestroyNotifyEvent(xEvent *from, xEvent *to)
  700. {
  701. to->u.u.type = from->u.u.type;
  702. cpswaps(from->u.u.sequenceNumber, to->u.u.sequenceNumber);
  703. cpswapl(from->u.destroyNotify.event, to->u.destroyNotify.event);
  704. cpswapl(from->u.destroyNotify.window, to->u.destroyNotify.window);
  705. }
  706. void
  707. SUnmapNotifyEvent(xEvent *from, xEvent *to)
  708. {
  709. to->u.u.type = from->u.u.type;
  710. cpswaps(from->u.u.sequenceNumber, to->u.u.sequenceNumber);
  711. cpswapl(from->u.unmapNotify.event, to->u.unmapNotify.event);
  712. cpswapl(from->u.unmapNotify.window, to->u.unmapNotify.window);
  713. to->u.unmapNotify.fromConfigure = from->u.unmapNotify.fromConfigure;
  714. }
  715. void
  716. SMapNotifyEvent(xEvent *from, xEvent *to)
  717. {
  718. to->u.u.type = from->u.u.type;
  719. cpswaps(from->u.u.sequenceNumber, to->u.u.sequenceNumber);
  720. cpswapl(from->u.mapNotify.event, to->u.mapNotify.event);
  721. cpswapl(from->u.mapNotify.window, to->u.mapNotify.window);
  722. to->u.mapNotify.override = from->u.mapNotify.override;
  723. }
  724. void
  725. SMapRequestEvent(xEvent *from, xEvent *to)
  726. {
  727. to->u.u.type = from->u.u.type;
  728. cpswaps(from->u.u.sequenceNumber, to->u.u.sequenceNumber);
  729. cpswapl(from->u.mapRequest.parent, to->u.mapRequest.parent);
  730. cpswapl(from->u.mapRequest.window, to->u.mapRequest.window);
  731. }
  732. void
  733. SReparentEvent(xEvent *from, xEvent *to)
  734. {
  735. to->u.u.type = from->u.u.type;
  736. cpswaps(from->u.u.sequenceNumber, to->u.u.sequenceNumber);
  737. cpswapl(from->u.reparent.event, to->u.reparent.event);
  738. cpswapl(from->u.reparent.window, to->u.reparent.window);
  739. cpswapl(from->u.reparent.parent, to->u.reparent.parent);
  740. cpswaps(from->u.reparent.x, to->u.reparent.x);
  741. cpswaps(from->u.reparent.y, to->u.reparent.y);
  742. to->u.reparent.override = from->u.reparent.override;
  743. }
  744. void
  745. SConfigureNotifyEvent(xEvent *from, xEvent *to)
  746. {
  747. to->u.u.type = from->u.u.type;
  748. cpswaps(from->u.u.sequenceNumber, to->u.u.sequenceNumber);
  749. cpswapl(from->u.configureNotify.event, to->u.configureNotify.event);
  750. cpswapl(from->u.configureNotify.window, to->u.configureNotify.window);
  751. cpswapl(from->u.configureNotify.aboveSibling,
  752. to->u.configureNotify.aboveSibling);
  753. cpswaps(from->u.configureNotify.x, to->u.configureNotify.x);
  754. cpswaps(from->u.configureNotify.y, to->u.configureNotify.y);
  755. cpswaps(from->u.configureNotify.width, to->u.configureNotify.width);
  756. cpswaps(from->u.configureNotify.height, to->u.configureNotify.height);
  757. cpswaps(from->u.configureNotify.borderWidth,
  758. to->u.configureNotify.borderWidth);
  759. to->u.configureNotify.override = from->u.configureNotify.override;
  760. }
  761. void
  762. SConfigureRequestEvent(xEvent *from, xEvent *to)
  763. {
  764. to->u.u.type = from->u.u.type;
  765. to->u.u.detail = from->u.u.detail; /* actually stack-mode */
  766. cpswaps(from->u.u.sequenceNumber, to->u.u.sequenceNumber);
  767. cpswapl(from->u.configureRequest.parent, to->u.configureRequest.parent);
  768. cpswapl(from->u.configureRequest.window, to->u.configureRequest.window);
  769. cpswapl(from->u.configureRequest.sibling, to->u.configureRequest.sibling);
  770. cpswaps(from->u.configureRequest.x, to->u.configureRequest.x);
  771. cpswaps(from->u.configureRequest.y, to->u.configureRequest.y);
  772. cpswaps(from->u.configureRequest.width, to->u.configureRequest.width);
  773. cpswaps(from->u.configureRequest.height, to->u.configureRequest.height);
  774. cpswaps(from->u.configureRequest.borderWidth,
  775. to->u.configureRequest.borderWidth);
  776. cpswaps(from->u.configureRequest.valueMask,
  777. to->u.configureRequest.valueMask);
  778. }
  779. void
  780. SGravityEvent(xEvent *from, xEvent *to)
  781. {
  782. to->u.u.type = from->u.u.type;
  783. cpswaps(from->u.u.sequenceNumber, to->u.u.sequenceNumber);
  784. cpswapl(from->u.gravity.event, to->u.gravity.event);
  785. cpswapl(from->u.gravity.window, to->u.gravity.window);
  786. cpswaps(from->u.gravity.x, to->u.gravity.x);
  787. cpswaps(from->u.gravity.y, to->u.gravity.y);
  788. }
  789. void
  790. SResizeRequestEvent(xEvent *from, xEvent *to)
  791. {
  792. to->u.u.type = from->u.u.type;
  793. cpswaps(from->u.u.sequenceNumber, to->u.u.sequenceNumber);
  794. cpswapl(from->u.resizeRequest.window, to->u.resizeRequest.window);
  795. cpswaps(from->u.resizeRequest.width, to->u.resizeRequest.width);
  796. cpswaps(from->u.resizeRequest.height, to->u.resizeRequest.height);
  797. }
  798. void
  799. SCirculateEvent(xEvent *from, xEvent *to)
  800. {
  801. to->u.u.type = from->u.u.type;
  802. to->u.u.detail = from->u.u.detail;
  803. cpswaps(from->u.u.sequenceNumber, to->u.u.sequenceNumber);
  804. cpswapl(from->u.circulate.event, to->u.circulate.event);
  805. cpswapl(from->u.circulate.window, to->u.circulate.window);
  806. cpswapl(from->u.circulate.parent, to->u.circulate.parent);
  807. to->u.circulate.place = from->u.circulate.place;
  808. }
  809. void
  810. SPropertyEvent(xEvent *from, xEvent *to)
  811. {
  812. to->u.u.type = from->u.u.type;
  813. cpswaps(from->u.u.sequenceNumber, to->u.u.sequenceNumber);
  814. cpswapl(from->u.property.window, to->u.property.window);
  815. cpswapl(from->u.property.atom, to->u.property.atom);
  816. cpswapl(from->u.property.time, to->u.property.time);
  817. to->u.property.state = from->u.property.state;
  818. }
  819. void
  820. SSelectionClearEvent(xEvent *from, xEvent *to)
  821. {
  822. to->u.u.type = from->u.u.type;
  823. cpswaps(from->u.u.sequenceNumber, to->u.u.sequenceNumber);
  824. cpswapl(from->u.selectionClear.time, to->u.selectionClear.time);
  825. cpswapl(from->u.selectionClear.window, to->u.selectionClear.window);
  826. cpswapl(from->u.selectionClear.atom, to->u.selectionClear.atom);
  827. }
  828. void
  829. SSelectionRequestEvent(xEvent *from, xEvent *to)
  830. {
  831. to->u.u.type = from->u.u.type;
  832. cpswaps(from->u.u.sequenceNumber, to->u.u.sequenceNumber);
  833. cpswapl(from->u.selectionRequest.time, to->u.selectionRequest.time);
  834. cpswapl(from->u.selectionRequest.owner, to->u.selectionRequest.owner);
  835. cpswapl(from->u.selectionRequest.requestor,
  836. to->u.selectionRequest.requestor);
  837. cpswapl(from->u.selectionRequest.selection,
  838. to->u.selectionRequest.selection);
  839. cpswapl(from->u.selectionRequest.target, to->u.selectionRequest.target);
  840. cpswapl(from->u.selectionRequest.property, to->u.selectionRequest.property);
  841. }
  842. void
  843. SSelectionNotifyEvent(xEvent *from, xEvent *to)
  844. {
  845. to->u.u.type = from->u.u.type;
  846. cpswaps(from->u.u.sequenceNumber, to->u.u.sequenceNumber);
  847. cpswapl(from->u.selectionNotify.time, to->u.selectionNotify.time);
  848. cpswapl(from->u.selectionNotify.requestor, to->u.selectionNotify.requestor);
  849. cpswapl(from->u.selectionNotify.selection, to->u.selectionNotify.selection);
  850. cpswapl(from->u.selectionNotify.target, to->u.selectionNotify.target);
  851. cpswapl(from->u.selectionNotify.property, to->u.selectionNotify.property);
  852. }
  853. void
  854. SColormapEvent(xEvent *from, xEvent *to)
  855. {
  856. to->u.u.type = from->u.u.type;
  857. cpswaps(from->u.u.sequenceNumber, to->u.u.sequenceNumber);
  858. cpswapl(from->u.colormap.window, to->u.colormap.window);
  859. cpswapl(from->u.colormap.colormap, to->u.colormap.colormap);
  860. to->u.colormap.new = from->u.colormap.new;
  861. to->u.colormap.state = from->u.colormap.state;
  862. }
  863. void
  864. SMappingEvent(xEvent *from, xEvent *to)
  865. {
  866. to->u.u.type = from->u.u.type;
  867. cpswaps(from->u.u.sequenceNumber, to->u.u.sequenceNumber);
  868. to->u.mappingNotify.request = from->u.mappingNotify.request;
  869. to->u.mappingNotify.firstKeyCode = from->u.mappingNotify.firstKeyCode;
  870. to->u.mappingNotify.count = from->u.mappingNotify.count;
  871. }
  872. void
  873. SClientMessageEvent(xEvent *from, xEvent *to)
  874. {
  875. to->u.u.type = from->u.u.type;
  876. to->u.u.detail = from->u.u.detail; /* actually format */
  877. cpswaps(from->u.u.sequenceNumber, to->u.u.sequenceNumber);
  878. cpswapl(from->u.clientMessage.window, to->u.clientMessage.window);
  879. cpswapl(from->u.clientMessage.u.l.type, to->u.clientMessage.u.l.type);
  880. switch (from->u.u.detail) {
  881. case 8:
  882. memmove(to->u.clientMessage.u.b.bytes,
  883. from->u.clientMessage.u.b.bytes, 20);
  884. break;
  885. case 16:
  886. cpswaps(from->u.clientMessage.u.s.shorts0,
  887. to->u.clientMessage.u.s.shorts0);
  888. cpswaps(from->u.clientMessage.u.s.shorts1,
  889. to->u.clientMessage.u.s.shorts1);
  890. cpswaps(from->u.clientMessage.u.s.shorts2,
  891. to->u.clientMessage.u.s.shorts2);
  892. cpswaps(from->u.clientMessage.u.s.shorts3,
  893. to->u.clientMessage.u.s.shorts3);
  894. cpswaps(from->u.clientMessage.u.s.shorts4,
  895. to->u.clientMessage.u.s.shorts4);
  896. cpswaps(from->u.clientMessage.u.s.shorts5,
  897. to->u.clientMessage.u.s.shorts5);
  898. cpswaps(from->u.clientMessage.u.s.shorts6,
  899. to->u.clientMessage.u.s.shorts6);
  900. cpswaps(from->u.clientMessage.u.s.shorts7,
  901. to->u.clientMessage.u.s.shorts7);
  902. cpswaps(from->u.clientMessage.u.s.shorts8,
  903. to->u.clientMessage.u.s.shorts8);
  904. cpswaps(from->u.clientMessage.u.s.shorts9,
  905. to->u.clientMessage.u.s.shorts9);
  906. break;
  907. case 32:
  908. cpswapl(from->u.clientMessage.u.l.longs0,
  909. to->u.clientMessage.u.l.longs0);
  910. cpswapl(from->u.clientMessage.u.l.longs1,
  911. to->u.clientMessage.u.l.longs1);
  912. cpswapl(from->u.clientMessage.u.l.longs2,
  913. to->u.clientMessage.u.l.longs2);
  914. cpswapl(from->u.clientMessage.u.l.longs3,
  915. to->u.clientMessage.u.l.longs3);
  916. cpswapl(from->u.clientMessage.u.l.longs4,
  917. to->u.clientMessage.u.l.longs4);
  918. break;
  919. }
  920. }
  921. void
  922. SKeymapNotifyEvent(xEvent *from, xEvent *to)
  923. {
  924. /* Keymap notify events are special; they have no
  925. sequence number field, and contain entirely 8-bit data */
  926. *to = *from;
  927. }
  928. static void
  929. SwapConnSetup(xConnSetup * pConnSetup, xConnSetup * pConnSetupT)
  930. {
  931. cpswapl(pConnSetup->release, pConnSetupT->release);
  932. cpswapl(pConnSetup->ridBase, pConnSetupT->ridBase);
  933. cpswapl(pConnSetup->ridMask, pConnSetupT->ridMask);
  934. cpswapl(pConnSetup->motionBufferSize, pConnSetupT->motionBufferSize);
  935. cpswaps(pConnSetup->nbytesVendor, pConnSetupT->nbytesVendor);
  936. cpswaps(pConnSetup->maxRequestSize, pConnSetupT->maxRequestSize);
  937. pConnSetupT->minKeyCode = pConnSetup->minKeyCode;
  938. pConnSetupT->maxKeyCode = pConnSetup->maxKeyCode;
  939. pConnSetupT->numRoots = pConnSetup->numRoots;
  940. pConnSetupT->numFormats = pConnSetup->numFormats;
  941. pConnSetupT->imageByteOrder = pConnSetup->imageByteOrder;
  942. pConnSetupT->bitmapBitOrder = pConnSetup->bitmapBitOrder;
  943. pConnSetupT->bitmapScanlineUnit = pConnSetup->bitmapScanlineUnit;
  944. pConnSetupT->bitmapScanlinePad = pConnSetup->bitmapScanlinePad;
  945. }
  946. static void
  947. SwapWinRoot(xWindowRoot * pRoot, xWindowRoot * pRootT)
  948. {
  949. cpswapl(pRoot->windowId, pRootT->windowId);
  950. cpswapl(pRoot->defaultColormap, pRootT->defaultColormap);
  951. cpswapl(pRoot->whitePixel, pRootT->whitePixel);
  952. cpswapl(pRoot->blackPixel, pRootT->blackPixel);
  953. cpswapl(pRoot->currentInputMask, pRootT->currentInputMask);
  954. cpswaps(pRoot->pixWidth, pRootT->pixWidth);
  955. cpswaps(pRoot->pixHeight, pRootT->pixHeight);
  956. cpswaps(pRoot->mmWidth, pRootT->mmWidth);
  957. cpswaps(pRoot->mmHeight, pRootT->mmHeight);
  958. cpswaps(pRoot->minInstalledMaps, pRootT->minInstalledMaps);
  959. cpswaps(pRoot->maxInstalledMaps, pRootT->maxInstalledMaps);
  960. cpswapl(pRoot->rootVisualID, pRootT->rootVisualID);
  961. pRootT->backingStore = pRoot->backingStore;
  962. pRootT->saveUnders = pRoot->saveUnders;
  963. pRootT->rootDepth = pRoot->rootDepth;
  964. pRootT->nDepths = pRoot->nDepths;
  965. }
  966. static void
  967. SwapVisual(xVisualType * pVis, xVisualType * pVisT)
  968. {
  969. cpswapl(pVis->visualID, pVisT->visualID);
  970. pVisT->class = pVis->class;
  971. pVisT->bitsPerRGB = pVis->bitsPerRGB;
  972. cpswaps(pVis->colormapEntries, pVisT->colormapEntries);
  973. cpswapl(pVis->redMask, pVisT->redMask);
  974. cpswapl(pVis->greenMask, pVisT->greenMask);
  975. cpswapl(pVis->blueMask, pVisT->blueMask);
  976. }
  977. void
  978. SwapConnSetupInfo(char *pInfo, char *pInfoT)
  979. {
  980. int i, j, k;
  981. xConnSetup *pConnSetup = (xConnSetup *) pInfo;
  982. xDepth *depth;
  983. xWindowRoot *root;
  984. SwapConnSetup(pConnSetup, (xConnSetup *) pInfoT);
  985. pInfo += sizeof(xConnSetup);
  986. pInfoT += sizeof(xConnSetup);
  987. /* Copy the vendor string */
  988. i = pad_to_int32(pConnSetup->nbytesVendor);
  989. memcpy(pInfoT, pInfo, i);
  990. pInfo += i;
  991. pInfoT += i;
  992. /* The Pixmap formats don't need to be swapped, just copied. */
  993. i = sizeof(xPixmapFormat) * pConnSetup->numFormats;
  994. memcpy(pInfoT, pInfo, i);
  995. pInfo += i;
  996. pInfoT += i;
  997. for (i = 0; i < pConnSetup->numRoots; i++) {
  998. root = (xWindowRoot *) pInfo;
  999. SwapWinRoot(root, (xWindowRoot *) pInfoT);
  1000. pInfo += sizeof(xWindowRoot);
  1001. pInfoT += sizeof(xWindowRoot);
  1002. for (j = 0; j < root->nDepths; j++) {
  1003. depth = (xDepth *) pInfo;
  1004. ((xDepth *) pInfoT)->depth = depth->depth;
  1005. cpswaps(depth->nVisuals, ((xDepth *) pInfoT)->nVisuals);
  1006. pInfo += sizeof(xDepth);
  1007. pInfoT += sizeof(xDepth);
  1008. for (k = 0; k < depth->nVisuals; k++) {
  1009. SwapVisual((xVisualType *) pInfo, (xVisualType *) pInfoT);
  1010. pInfo += sizeof(xVisualType);
  1011. pInfoT += sizeof(xVisualType);
  1012. }
  1013. }
  1014. }
  1015. }
  1016. void
  1017. WriteSConnectionInfo(ClientPtr pClient, unsigned long size, char *pInfo)
  1018. {
  1019. char *pInfoTBase;
  1020. pInfoTBase = malloc(size);
  1021. if (!pInfoTBase) {
  1022. pClient->noClientException = -1;
  1023. return;
  1024. }
  1025. SwapConnSetupInfo(pInfo, pInfoTBase);
  1026. WriteToClient(pClient, (int) size, pInfoTBase);
  1027. free(pInfoTBase);
  1028. }
  1029. void
  1030. SwapConnSetupPrefix(xConnSetupPrefix * pcspFrom, xConnSetupPrefix * pcspTo)
  1031. {
  1032. pcspTo->success = pcspFrom->success;
  1033. pcspTo->lengthReason = pcspFrom->lengthReason;
  1034. cpswaps(pcspFrom->majorVersion, pcspTo->majorVersion);
  1035. cpswaps(pcspFrom->minorVersion, pcspTo->minorVersion);
  1036. cpswaps(pcspFrom->length, pcspTo->length);
  1037. }
  1038. void
  1039. WriteSConnSetupPrefix(ClientPtr pClient, xConnSetupPrefix * pcsp)
  1040. {
  1041. xConnSetupPrefix cspT;
  1042. SwapConnSetupPrefix(pcsp, &cspT);
  1043. WriteToClient(pClient, sizeof(cspT), &cspT);
  1044. }
  1045. /*
  1046. * Dummy entry for ReplySwapVector[]
  1047. */
  1048. void
  1049. ReplyNotSwappd(ClientPtr pClient, int size, void *pbuf)
  1050. {
  1051. FatalError("Not implemented");
  1052. }