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