swaprep.c revision 706f2543
1706f2543Smrg/************************************************************ 2706f2543Smrg 3706f2543SmrgCopyright 1987, 1998 The Open Group 4706f2543Smrg 5706f2543SmrgPermission to use, copy, modify, distribute, and sell this software and its 6706f2543Smrgdocumentation for any purpose is hereby granted without fee, provided that 7706f2543Smrgthe above copyright notice appear in all copies and that both that 8706f2543Smrgcopyright notice and this permission notice appear in supporting 9706f2543Smrgdocumentation. 10706f2543Smrg 11706f2543SmrgThe above copyright notice and this permission notice shall be included in 12706f2543Smrgall copies or substantial portions of the Software. 13706f2543Smrg 14706f2543SmrgTHE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15706f2543SmrgIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16706f2543SmrgFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17706f2543SmrgOPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN 18706f2543SmrgAN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 19706f2543SmrgCONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 20706f2543Smrg 21706f2543SmrgExcept as contained in this notice, the name of The Open Group shall not be 22706f2543Smrgused in advertising or otherwise to promote the sale, use or other dealings 23706f2543Smrgin this Software without prior written authorization from The Open Group. 24706f2543Smrg 25706f2543Smrg 26706f2543SmrgCopyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts. 27706f2543Smrg 28706f2543Smrg All Rights Reserved 29706f2543Smrg 30706f2543SmrgPermission to use, copy, modify, and distribute this software and its 31706f2543Smrgdocumentation for any purpose and without fee is hereby granted, 32706f2543Smrgprovided that the above copyright notice appear in all copies and that 33706f2543Smrgboth that copyright notice and this permission notice appear in 34706f2543Smrgsupporting documentation, and that the name of Digital not be 35706f2543Smrgused in advertising or publicity pertaining to distribution of the 36706f2543Smrgsoftware without specific, written prior permission. 37706f2543Smrg 38706f2543SmrgDIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING 39706f2543SmrgALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL 40706f2543SmrgDIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR 41706f2543SmrgANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, 42706f2543SmrgWHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, 43706f2543SmrgARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS 44706f2543SmrgSOFTWARE. 45706f2543Smrg 46706f2543Smrg********************************************************/ 47706f2543Smrg 48706f2543Smrg 49706f2543Smrg#ifdef HAVE_DIX_CONFIG_H 50706f2543Smrg#include <dix-config.h> 51706f2543Smrg#endif 52706f2543Smrg 53706f2543Smrg#include <X11/X.h> 54706f2543Smrg#include <X11/Xproto.h> 55706f2543Smrg#include "misc.h" 56706f2543Smrg#include "dixstruct.h" 57706f2543Smrg#include <X11/fonts/fontstruct.h> 58706f2543Smrg#include "scrnintstr.h" 59706f2543Smrg#include "swaprep.h" 60706f2543Smrg#include "globals.h" 61706f2543Smrg 62706f2543Smrgstatic void SwapFontInfo(xQueryFontReply *pr); 63706f2543Smrg 64706f2543Smrgstatic void SwapCharInfo(xCharInfo *pInfo); 65706f2543Smrg 66706f2543Smrgstatic void SwapFont(xQueryFontReply *pr, Bool hasGlyphs); 67706f2543Smrg 68706f2543Smrg/** 69706f2543Smrg * Thanks to Jack Palevich for testing and subsequently rewriting all this 70706f2543Smrg * 71706f2543Smrg * \param size size in bytes 72706f2543Smrg */ 73706f2543Smrgvoid 74706f2543SmrgSwap32Write(ClientPtr pClient, int size, CARD32 *pbuf) 75706f2543Smrg{ 76706f2543Smrg int i; 77706f2543Smrg char n; 78706f2543Smrg 79706f2543Smrg size >>= 2; 80706f2543Smrg for(i = 0; i < size; i++) 81706f2543Smrg /* brackets are mandatory here, because "swapl" macro expands 82706f2543Smrg to several statements */ 83706f2543Smrg { 84706f2543Smrg swapl(&pbuf[i], n); 85706f2543Smrg } 86706f2543Smrg (void)WriteToClient(pClient, size << 2, (char *) pbuf); 87706f2543Smrg} 88706f2543Smrg 89706f2543Smrg/** 90706f2543Smrg * 91706f2543Smrg * \param size size in bytes 92706f2543Smrg */ 93706f2543Smrgvoid 94706f2543SmrgCopySwap32Write(ClientPtr pClient, int size, CARD32 *pbuf) 95706f2543Smrg{ 96706f2543Smrg int bufsize = size; 97706f2543Smrg CARD32 *pbufT; 98706f2543Smrg CARD32 *from, *to, *fromLast, *toLast; 99706f2543Smrg CARD32 tmpbuf[1]; 100706f2543Smrg 101706f2543Smrg /* Allocate as big a buffer as we can... */ 102706f2543Smrg while (!(pbufT = malloc(bufsize))) 103706f2543Smrg { 104706f2543Smrg bufsize >>= 1; 105706f2543Smrg if (bufsize == 4) 106706f2543Smrg { 107706f2543Smrg pbufT = tmpbuf; 108706f2543Smrg break; 109706f2543Smrg } 110706f2543Smrg } 111706f2543Smrg 112706f2543Smrg /* convert lengths from # of bytes to # of longs */ 113706f2543Smrg size >>= 2; 114706f2543Smrg bufsize >>= 2; 115706f2543Smrg 116706f2543Smrg from = pbuf; 117706f2543Smrg fromLast = from + size; 118706f2543Smrg while (from < fromLast) { 119706f2543Smrg int nbytes; 120706f2543Smrg to = pbufT; 121706f2543Smrg toLast = to + min (bufsize, fromLast - from); 122706f2543Smrg nbytes = (toLast - to) << 2; 123706f2543Smrg while (to < toLast) { 124706f2543Smrg /* can't write "cpswapl(*from++, *to++)" because cpswapl is a macro 125706f2543Smrg that evaulates its args more than once */ 126706f2543Smrg cpswapl(*from, *to); 127706f2543Smrg from++; 128706f2543Smrg to++; 129706f2543Smrg } 130706f2543Smrg (void)WriteToClient (pClient, nbytes, (char *) pbufT); 131706f2543Smrg } 132706f2543Smrg 133706f2543Smrg if (pbufT != tmpbuf) 134706f2543Smrg free(pbufT); 135706f2543Smrg} 136706f2543Smrg 137706f2543Smrg/** 138706f2543Smrg * 139706f2543Smrg * \param size size in bytes 140706f2543Smrg */ 141706f2543Smrgvoid 142706f2543SmrgCopySwap16Write(ClientPtr pClient, int size, short *pbuf) 143706f2543Smrg{ 144706f2543Smrg int bufsize = size; 145706f2543Smrg short *pbufT; 146706f2543Smrg short *from, *to, *fromLast, *toLast; 147706f2543Smrg short tmpbuf[2]; 148706f2543Smrg 149706f2543Smrg /* Allocate as big a buffer as we can... */ 150706f2543Smrg while (!(pbufT = malloc(bufsize))) 151706f2543Smrg { 152706f2543Smrg bufsize >>= 1; 153706f2543Smrg if (bufsize == 4) 154706f2543Smrg { 155706f2543Smrg pbufT = tmpbuf; 156706f2543Smrg break; 157706f2543Smrg } 158706f2543Smrg } 159706f2543Smrg 160706f2543Smrg /* convert lengths from # of bytes to # of shorts */ 161706f2543Smrg size >>= 1; 162706f2543Smrg bufsize >>= 1; 163706f2543Smrg 164706f2543Smrg from = pbuf; 165706f2543Smrg fromLast = from + size; 166706f2543Smrg while (from < fromLast) { 167706f2543Smrg int nbytes; 168706f2543Smrg to = pbufT; 169706f2543Smrg toLast = to + min (bufsize, fromLast - from); 170706f2543Smrg nbytes = (toLast - to) << 1; 171706f2543Smrg while (to < toLast) { 172706f2543Smrg /* can't write "cpswaps(*from++, *to++)" because cpswaps is a macro 173706f2543Smrg that evaulates its args more than once */ 174706f2543Smrg cpswaps(*from, *to); 175706f2543Smrg from++; 176706f2543Smrg to++; 177706f2543Smrg } 178706f2543Smrg (void)WriteToClient (pClient, nbytes, (char *) pbufT); 179706f2543Smrg } 180706f2543Smrg 181706f2543Smrg if (pbufT != tmpbuf) 182706f2543Smrg free(pbufT); 183706f2543Smrg} 184706f2543Smrg 185706f2543Smrg 186706f2543Smrg/* Extra-small reply */ 187706f2543Smrgvoid 188706f2543SmrgSGenericReply(ClientPtr pClient, int size, xGenericReply *pRep) 189706f2543Smrg{ 190706f2543Smrg char n; 191706f2543Smrg 192706f2543Smrg swaps(&pRep->sequenceNumber, n); 193706f2543Smrg (void)WriteToClient(pClient, size, (char *) pRep); 194706f2543Smrg} 195706f2543Smrg 196706f2543Smrg/* Extra-large reply */ 197706f2543Smrgvoid 198706f2543SmrgSGetWindowAttributesReply(ClientPtr pClient, int size, 199706f2543Smrg xGetWindowAttributesReply *pRep) 200706f2543Smrg{ 201706f2543Smrg char n; 202706f2543Smrg 203706f2543Smrg swaps(&pRep->sequenceNumber, n); 204706f2543Smrg swapl(&pRep->length, n); 205706f2543Smrg swapl(&pRep->visualID, n); 206706f2543Smrg swaps(&pRep->class, n); 207706f2543Smrg swapl(&pRep->backingBitPlanes, n); 208706f2543Smrg swapl(&pRep->backingPixel, n); 209706f2543Smrg swapl(&pRep->colormap, n); 210706f2543Smrg swapl(&pRep->allEventMasks, n); 211706f2543Smrg swapl(&pRep->yourEventMask, n); 212706f2543Smrg swaps(&pRep->doNotPropagateMask, n); 213706f2543Smrg (void)WriteToClient(pClient, size, (char *) pRep); 214706f2543Smrg} 215706f2543Smrg 216706f2543Smrgvoid 217706f2543SmrgSGetGeometryReply(ClientPtr pClient, int size, xGetGeometryReply *pRep) 218706f2543Smrg{ 219706f2543Smrg char n; 220706f2543Smrg 221706f2543Smrg swaps(&pRep->sequenceNumber, n); 222706f2543Smrg swapl(&pRep->root, n); 223706f2543Smrg swaps(&pRep->x, n); 224706f2543Smrg swaps(&pRep->y, n); 225706f2543Smrg swaps(&pRep->width, n); 226706f2543Smrg swaps(&pRep->height, n); 227706f2543Smrg swaps(&pRep->borderWidth, n); 228706f2543Smrg (void)WriteToClient(pClient, size, (char *) pRep); 229706f2543Smrg} 230706f2543Smrg 231706f2543Smrgvoid 232706f2543SmrgSQueryTreeReply(ClientPtr pClient, int size, xQueryTreeReply *pRep) 233706f2543Smrg{ 234706f2543Smrg char n; 235706f2543Smrg 236706f2543Smrg swaps(&pRep->sequenceNumber, n); 237706f2543Smrg swapl(&pRep->length, n); 238706f2543Smrg swapl(&pRep->root, n); 239706f2543Smrg swapl(&pRep->parent, n); 240706f2543Smrg swaps(&pRep->nChildren, n); 241706f2543Smrg (void)WriteToClient(pClient, size, (char *) pRep); 242706f2543Smrg} 243706f2543Smrg 244706f2543Smrgvoid 245706f2543SmrgSInternAtomReply(ClientPtr pClient, int size, xInternAtomReply *pRep) 246706f2543Smrg{ 247706f2543Smrg char n; 248706f2543Smrg 249706f2543Smrg swaps(&pRep->sequenceNumber, n); 250706f2543Smrg swapl(&pRep->atom, n); 251706f2543Smrg (void)WriteToClient(pClient, size, (char *) pRep); 252706f2543Smrg} 253706f2543Smrg 254706f2543Smrgvoid 255706f2543SmrgSGetAtomNameReply(ClientPtr pClient, int size, xGetAtomNameReply *pRep) 256706f2543Smrg{ 257706f2543Smrg char n; 258706f2543Smrg 259706f2543Smrg swaps(&pRep->sequenceNumber, n); 260706f2543Smrg swapl(&pRep->length, n); 261706f2543Smrg swaps(&pRep->nameLength, n); 262706f2543Smrg (void)WriteToClient(pClient, size, (char *) pRep); 263706f2543Smrg} 264706f2543Smrg 265706f2543Smrg 266706f2543Smrgvoid 267706f2543SmrgSGetPropertyReply(ClientPtr pClient, int size, xGetPropertyReply *pRep) 268706f2543Smrg{ 269706f2543Smrg char n; 270706f2543Smrg 271706f2543Smrg swaps(&pRep->sequenceNumber, n); 272706f2543Smrg swapl(&pRep->length, n); 273706f2543Smrg swapl(&pRep->propertyType, n); 274706f2543Smrg swapl(&pRep->bytesAfter, n); 275706f2543Smrg swapl(&pRep->nItems, n); 276706f2543Smrg (void)WriteToClient(pClient, size, (char *) pRep); 277706f2543Smrg} 278706f2543Smrg 279706f2543Smrgvoid 280706f2543SmrgSListPropertiesReply(ClientPtr pClient, int size, xListPropertiesReply *pRep) 281706f2543Smrg{ 282706f2543Smrg char n; 283706f2543Smrg 284706f2543Smrg swaps(&pRep->sequenceNumber, n); 285706f2543Smrg swapl(&pRep->length, n); 286706f2543Smrg swaps(&pRep->nProperties, n); 287706f2543Smrg (void)WriteToClient(pClient, size, (char *) pRep); 288706f2543Smrg} 289706f2543Smrg 290706f2543Smrgvoid 291706f2543SmrgSGetSelectionOwnerReply(ClientPtr pClient, int size, 292706f2543Smrg xGetSelectionOwnerReply *pRep) 293706f2543Smrg{ 294706f2543Smrg char n; 295706f2543Smrg 296706f2543Smrg swaps(&pRep->sequenceNumber, n); 297706f2543Smrg swapl(&pRep->owner, n); 298706f2543Smrg (void)WriteToClient(pClient, size, (char *) pRep); 299706f2543Smrg} 300706f2543Smrg 301706f2543Smrg 302706f2543Smrgvoid 303706f2543SmrgSQueryPointerReply(ClientPtr pClient, int size, xQueryPointerReply *pRep) 304706f2543Smrg{ 305706f2543Smrg char n; 306706f2543Smrg 307706f2543Smrg swaps(&pRep->sequenceNumber, n); 308706f2543Smrg swapl(&pRep->root, n); 309706f2543Smrg swapl(&pRep->child, n); 310706f2543Smrg swaps(&pRep->rootX, n); 311706f2543Smrg swaps(&pRep->rootY, n); 312706f2543Smrg swaps(&pRep->winX, n); 313706f2543Smrg swaps(&pRep->winY, n); 314706f2543Smrg swaps(&pRep->mask, n); 315706f2543Smrg (void)WriteToClient(pClient, size, (char *) pRep); 316706f2543Smrg} 317706f2543Smrg 318706f2543Smrgstatic void 319706f2543SmrgSwapTimecoord(xTimecoord* pCoord) 320706f2543Smrg{ 321706f2543Smrg char n; 322706f2543Smrg 323706f2543Smrg swapl(&pCoord->time, n); 324706f2543Smrg swaps(&pCoord->x, n); 325706f2543Smrg swaps(&pCoord->y, n); 326706f2543Smrg} 327706f2543Smrg 328706f2543Smrgvoid 329706f2543SmrgSwapTimeCoordWrite(ClientPtr pClient, int size, xTimecoord *pRep) 330706f2543Smrg{ 331706f2543Smrg int i, n; 332706f2543Smrg xTimecoord *pRepT; 333706f2543Smrg 334706f2543Smrg n = size / sizeof(xTimecoord); 335706f2543Smrg pRepT = pRep; 336706f2543Smrg for(i = 0; i < n; i++) 337706f2543Smrg { 338706f2543Smrg SwapTimecoord(pRepT); 339706f2543Smrg pRepT++; 340706f2543Smrg } 341706f2543Smrg (void)WriteToClient(pClient, size, (char *) pRep); 342706f2543Smrg 343706f2543Smrg} 344706f2543Smrgvoid 345706f2543SmrgSGetMotionEventsReply(ClientPtr pClient, int size, xGetMotionEventsReply *pRep) 346706f2543Smrg{ 347706f2543Smrg char n; 348706f2543Smrg 349706f2543Smrg swaps(&pRep->sequenceNumber, n); 350706f2543Smrg swapl(&pRep->length, n); 351706f2543Smrg swapl(&pRep->nEvents, n); 352706f2543Smrg (void)WriteToClient(pClient, size, (char *) pRep); 353706f2543Smrg} 354706f2543Smrg 355706f2543Smrgvoid 356706f2543SmrgSTranslateCoordsReply(ClientPtr pClient, int size, xTranslateCoordsReply *pRep) 357706f2543Smrg{ 358706f2543Smrg char n; 359706f2543Smrg 360706f2543Smrg swaps(&pRep->sequenceNumber, n); 361706f2543Smrg swapl(&pRep->child, n); 362706f2543Smrg swaps(&pRep->dstX, n); 363706f2543Smrg swaps(&pRep->dstY, n); 364706f2543Smrg (void)WriteToClient(pClient, size, (char *) pRep); 365706f2543Smrg} 366706f2543Smrg 367706f2543Smrgvoid 368706f2543SmrgSGetInputFocusReply(ClientPtr pClient, int size, xGetInputFocusReply *pRep) 369706f2543Smrg{ 370706f2543Smrg char n; 371706f2543Smrg 372706f2543Smrg swaps(&pRep->sequenceNumber, n); 373706f2543Smrg swapl(&pRep->focus, n); 374706f2543Smrg (void)WriteToClient(pClient, size, (char *) pRep); 375706f2543Smrg} 376706f2543Smrg 377706f2543Smrg/* extra long reply */ 378706f2543Smrgvoid 379706f2543SmrgSQueryKeymapReply(ClientPtr pClient, int size, xQueryKeymapReply *pRep) 380706f2543Smrg{ 381706f2543Smrg char n; 382706f2543Smrg 383706f2543Smrg swaps(&pRep->sequenceNumber, n); 384706f2543Smrg swapl(&pRep->length, n); 385706f2543Smrg (void)WriteToClient(pClient, size, (char *) pRep); 386706f2543Smrg} 387706f2543Smrg 388706f2543Smrgstatic void 389706f2543SmrgSwapCharInfo(xCharInfo *pInfo) 390706f2543Smrg{ 391706f2543Smrg char n; 392706f2543Smrg 393706f2543Smrg swaps(&pInfo->leftSideBearing, n); 394706f2543Smrg swaps(&pInfo->rightSideBearing, n); 395706f2543Smrg swaps(&pInfo->characterWidth, n); 396706f2543Smrg swaps(&pInfo->ascent, n); 397706f2543Smrg swaps(&pInfo->descent, n); 398706f2543Smrg swaps(&pInfo->attributes, n); 399706f2543Smrg} 400706f2543Smrg 401706f2543Smrgstatic void 402706f2543SmrgSwapFontInfo(xQueryFontReply *pr) 403706f2543Smrg{ 404706f2543Smrg char n; 405706f2543Smrg 406706f2543Smrg swaps(&pr->minCharOrByte2, n); 407706f2543Smrg swaps(&pr->maxCharOrByte2, n); 408706f2543Smrg swaps(&pr->defaultChar, n); 409706f2543Smrg swaps(&pr->nFontProps, n); 410706f2543Smrg swaps(&pr->fontAscent, n); 411706f2543Smrg swaps(&pr->fontDescent, n); 412706f2543Smrg SwapCharInfo( &pr->minBounds); 413706f2543Smrg SwapCharInfo( &pr->maxBounds); 414706f2543Smrg swapl(&pr->nCharInfos, n); 415706f2543Smrg} 416706f2543Smrg 417706f2543Smrgstatic void 418706f2543SmrgSwapFont(xQueryFontReply *pr, Bool hasGlyphs) 419706f2543Smrg{ 420706f2543Smrg unsigned i; 421706f2543Smrg xCharInfo * pxci; 422706f2543Smrg unsigned nchars, nprops; 423706f2543Smrg char *pby; 424706f2543Smrg char n; 425706f2543Smrg 426706f2543Smrg swaps(&pr->sequenceNumber, n); 427706f2543Smrg swapl(&pr->length, n); 428706f2543Smrg nchars = pr->nCharInfos; 429706f2543Smrg nprops = pr->nFontProps; 430706f2543Smrg SwapFontInfo(pr); 431706f2543Smrg pby = (char *) &pr[1]; 432706f2543Smrg /* Font properties are an atom and either an int32 or a CARD32, so 433706f2543Smrg * they are always 2 4 byte values */ 434706f2543Smrg for(i = 0; i < nprops; i++) 435706f2543Smrg { 436706f2543Smrg swapl(pby, n); 437706f2543Smrg pby += 4; 438706f2543Smrg swapl(pby, n); 439706f2543Smrg pby += 4; 440706f2543Smrg } 441706f2543Smrg if (hasGlyphs) 442706f2543Smrg { 443706f2543Smrg pxci = (xCharInfo *)pby; 444706f2543Smrg for(i = 0; i< nchars; i++, pxci++) 445706f2543Smrg SwapCharInfo(pxci); 446706f2543Smrg } 447706f2543Smrg} 448706f2543Smrg 449706f2543Smrgvoid 450706f2543SmrgSQueryFontReply(ClientPtr pClient, int size, xQueryFontReply *pRep) 451706f2543Smrg{ 452706f2543Smrg SwapFont(pRep, TRUE); 453706f2543Smrg (void)WriteToClient(pClient, size, (char *) pRep); 454706f2543Smrg} 455706f2543Smrg 456706f2543Smrgvoid 457706f2543SmrgSQueryTextExtentsReply(ClientPtr pClient, int size, xQueryTextExtentsReply *pRep) 458706f2543Smrg{ 459706f2543Smrg char n; 460706f2543Smrg 461706f2543Smrg swaps(&pRep->sequenceNumber, n); 462706f2543Smrg swaps(&pRep->fontAscent, n); 463706f2543Smrg swaps(&pRep->fontDescent, n); 464706f2543Smrg swaps(&pRep->overallAscent, n); 465706f2543Smrg swaps(&pRep->overallDescent, n); 466706f2543Smrg swapl(&pRep->overallWidth, n); 467706f2543Smrg swapl(&pRep->overallLeft, n); 468706f2543Smrg swapl(&pRep->overallRight, n); 469706f2543Smrg (void)WriteToClient(pClient, size, (char *) pRep); 470706f2543Smrg} 471706f2543Smrg 472706f2543Smrgvoid 473706f2543SmrgSListFontsReply(ClientPtr pClient, int size, xListFontsReply *pRep) 474706f2543Smrg{ 475706f2543Smrg char n; 476706f2543Smrg 477706f2543Smrg swaps(&pRep->sequenceNumber, n); 478706f2543Smrg swapl(&pRep->length, n); 479706f2543Smrg swaps(&pRep->nFonts, n); 480706f2543Smrg (void)WriteToClient(pClient, size, (char *) pRep); 481706f2543Smrg} 482706f2543Smrg 483706f2543Smrgvoid 484706f2543SmrgSListFontsWithInfoReply(ClientPtr pClient, int size, 485706f2543Smrg xListFontsWithInfoReply *pRep) 486706f2543Smrg{ 487706f2543Smrg SwapFont((xQueryFontReply *)pRep, FALSE); 488706f2543Smrg (void)WriteToClient(pClient, size, (char *) pRep); 489706f2543Smrg} 490706f2543Smrg 491706f2543Smrgvoid 492706f2543SmrgSGetFontPathReply(ClientPtr pClient, int size, xGetFontPathReply *pRep) 493706f2543Smrg{ 494706f2543Smrg char n; 495706f2543Smrg 496706f2543Smrg swaps(&pRep->sequenceNumber, n); 497706f2543Smrg swapl(&pRep->length, n); 498706f2543Smrg swaps(&pRep->nPaths, n); 499706f2543Smrg (void)WriteToClient(pClient, size, (char *) pRep); 500706f2543Smrg} 501706f2543Smrg 502706f2543Smrgvoid 503706f2543SmrgSGetImageReply(ClientPtr pClient, int size, xGetImageReply *pRep) 504706f2543Smrg{ 505706f2543Smrg char n; 506706f2543Smrg 507706f2543Smrg swaps(&pRep->sequenceNumber, n); 508706f2543Smrg swapl(&pRep->length, n); 509706f2543Smrg swapl(&pRep->visual, n); 510706f2543Smrg (void)WriteToClient(pClient, size, (char *) pRep); 511706f2543Smrg /* Fortunately, image doesn't need swapping */ 512706f2543Smrg} 513706f2543Smrg 514706f2543Smrgvoid 515706f2543SmrgSListInstalledColormapsReply(ClientPtr pClient, int size, 516706f2543Smrg xListInstalledColormapsReply *pRep) 517706f2543Smrg{ 518706f2543Smrg char n; 519706f2543Smrg 520706f2543Smrg swaps(&pRep->sequenceNumber, n); 521706f2543Smrg swapl(&pRep->length, n); 522706f2543Smrg swaps(&pRep->nColormaps, n); 523706f2543Smrg (void)WriteToClient(pClient, size, (char *) pRep); 524706f2543Smrg} 525706f2543Smrg 526706f2543Smrgvoid 527706f2543SmrgSAllocColorReply(ClientPtr pClient, int size, xAllocColorReply *pRep) 528706f2543Smrg{ 529706f2543Smrg char n; 530706f2543Smrg 531706f2543Smrg swaps(&pRep->sequenceNumber, n); 532706f2543Smrg swaps(&pRep->red, n); 533706f2543Smrg swaps(&pRep->green, n); 534706f2543Smrg swaps(&pRep->blue, n); 535706f2543Smrg swapl(&pRep->pixel, n); 536706f2543Smrg (void)WriteToClient(pClient, size, (char *) pRep); 537706f2543Smrg} 538706f2543Smrg 539706f2543Smrgvoid 540706f2543SmrgSAllocNamedColorReply(ClientPtr pClient, int size, xAllocNamedColorReply *pRep) 541706f2543Smrg{ 542706f2543Smrg char n; 543706f2543Smrg 544706f2543Smrg swaps(&pRep->sequenceNumber, n); 545706f2543Smrg swapl(&pRep->pixel, n); 546706f2543Smrg swaps(&pRep->exactRed, n); 547706f2543Smrg swaps(&pRep->exactGreen, n); 548706f2543Smrg swaps(&pRep->exactBlue, n); 549706f2543Smrg swaps(&pRep->screenRed, n); 550706f2543Smrg swaps(&pRep->screenGreen, n); 551706f2543Smrg swaps(&pRep->screenBlue, n); 552706f2543Smrg (void)WriteToClient(pClient, size, (char *) pRep); 553706f2543Smrg} 554706f2543Smrg 555706f2543Smrgvoid 556706f2543SmrgSAllocColorCellsReply(ClientPtr pClient, int size, xAllocColorCellsReply *pRep) 557706f2543Smrg{ 558706f2543Smrg char n; 559706f2543Smrg 560706f2543Smrg swaps(&pRep->sequenceNumber, n); 561706f2543Smrg swapl(&pRep->length, n); 562706f2543Smrg swaps(&pRep->nPixels, n); 563706f2543Smrg swaps(&pRep->nMasks, n); 564706f2543Smrg (void)WriteToClient(pClient, size, (char *) pRep); 565706f2543Smrg} 566706f2543Smrg 567706f2543Smrg 568706f2543Smrgvoid 569706f2543SmrgSAllocColorPlanesReply(ClientPtr pClient, int size, xAllocColorPlanesReply *pRep) 570706f2543Smrg{ 571706f2543Smrg char n; 572706f2543Smrg 573706f2543Smrg swaps(&pRep->sequenceNumber, n); 574706f2543Smrg swapl(&pRep->length, n); 575706f2543Smrg swaps(&pRep->nPixels, n); 576706f2543Smrg swapl(&pRep->redMask, n); 577706f2543Smrg swapl(&pRep->greenMask, n); 578706f2543Smrg swapl(&pRep->blueMask, n); 579706f2543Smrg (void)WriteToClient(pClient, size, (char *) pRep); 580706f2543Smrg} 581706f2543Smrg 582706f2543Smrgstatic void 583706f2543SmrgSwapRGB(xrgb *prgb) 584706f2543Smrg{ 585706f2543Smrg char n; 586706f2543Smrg 587706f2543Smrg swaps(&prgb->red, n); 588706f2543Smrg swaps(&prgb->green, n); 589706f2543Smrg swaps(&prgb->blue, n); 590706f2543Smrg} 591706f2543Smrg 592706f2543Smrgvoid 593706f2543SmrgSQColorsExtend(ClientPtr pClient, int size, xrgb *prgb) 594706f2543Smrg{ 595706f2543Smrg int i, n; 596706f2543Smrg xrgb *prgbT; 597706f2543Smrg 598706f2543Smrg n = size / sizeof(xrgb); 599706f2543Smrg prgbT = prgb; 600706f2543Smrg for(i = 0; i < n; i++) 601706f2543Smrg { 602706f2543Smrg SwapRGB(prgbT); 603706f2543Smrg prgbT++; 604706f2543Smrg } 605706f2543Smrg (void)WriteToClient(pClient, size, (char *) prgb); 606706f2543Smrg} 607706f2543Smrg 608706f2543Smrgvoid 609706f2543SmrgSQueryColorsReply(ClientPtr pClient, int size, xQueryColorsReply* pRep) 610706f2543Smrg{ 611706f2543Smrg char n; 612706f2543Smrg 613706f2543Smrg swaps(&pRep->sequenceNumber, n); 614706f2543Smrg swapl(&pRep->length, n); 615706f2543Smrg swaps(&pRep->nColors, n); 616706f2543Smrg (void)WriteToClient(pClient, size, (char *) pRep); 617706f2543Smrg} 618706f2543Smrg 619706f2543Smrgvoid 620706f2543SmrgSLookupColorReply(ClientPtr pClient, int size, xLookupColorReply *pRep) 621706f2543Smrg{ 622706f2543Smrg char n; 623706f2543Smrg 624706f2543Smrg swaps(&pRep->sequenceNumber, n); 625706f2543Smrg swaps(&pRep->exactRed, n); 626706f2543Smrg swaps(&pRep->exactGreen, n); 627706f2543Smrg swaps(&pRep->exactBlue, n); 628706f2543Smrg swaps(&pRep->screenRed, n); 629706f2543Smrg swaps(&pRep->screenGreen, n); 630706f2543Smrg swaps(&pRep->screenBlue, n); 631706f2543Smrg (void)WriteToClient(pClient, size, (char *) pRep); 632706f2543Smrg} 633706f2543Smrg 634706f2543Smrgvoid 635706f2543SmrgSQueryBestSizeReply(ClientPtr pClient, int size, xQueryBestSizeReply *pRep) 636706f2543Smrg{ 637706f2543Smrg char n; 638706f2543Smrg 639706f2543Smrg swaps(&pRep->sequenceNumber, n); 640706f2543Smrg swaps(&pRep->width, n); 641706f2543Smrg swaps(&pRep->height, n); 642706f2543Smrg (void)WriteToClient(pClient, size, (char *) pRep); 643706f2543Smrg} 644706f2543Smrg 645706f2543Smrgvoid 646706f2543SmrgSListExtensionsReply(ClientPtr pClient, int size, xListExtensionsReply *pRep) 647706f2543Smrg{ 648706f2543Smrg char n; 649706f2543Smrg 650706f2543Smrg swaps(&pRep->sequenceNumber, n); 651706f2543Smrg swapl(&pRep->length, n); 652706f2543Smrg (void)WriteToClient(pClient, size, (char *) pRep); 653706f2543Smrg} 654706f2543Smrg 655706f2543Smrgvoid 656706f2543SmrgSGetKeyboardMappingReply(ClientPtr pClient, int size, 657706f2543Smrg xGetKeyboardMappingReply *pRep) 658706f2543Smrg{ 659706f2543Smrg char n; 660706f2543Smrg 661706f2543Smrg swaps(&pRep->sequenceNumber, n); 662706f2543Smrg swapl(&pRep->length, n); 663706f2543Smrg (void)WriteToClient(pClient, size, (char *) pRep); 664706f2543Smrg} 665706f2543Smrg 666706f2543Smrgvoid 667706f2543SmrgSGetPointerMappingReply(ClientPtr pClient, int size, 668706f2543Smrg xGetPointerMappingReply *pRep) 669706f2543Smrg{ 670706f2543Smrg char n; 671706f2543Smrg 672706f2543Smrg swaps(&pRep->sequenceNumber, n); 673706f2543Smrg swapl(&pRep->length, n); 674706f2543Smrg (void)WriteToClient(pClient, size, (char *) pRep); 675706f2543Smrg} 676706f2543Smrg 677706f2543Smrgvoid 678706f2543SmrgSGetModifierMappingReply(ClientPtr pClient, int size, 679706f2543Smrg xGetModifierMappingReply *pRep) 680706f2543Smrg{ 681706f2543Smrg char n; 682706f2543Smrg 683706f2543Smrg swaps(&pRep->sequenceNumber, n); 684706f2543Smrg swapl(&pRep->length, n); 685706f2543Smrg (void)WriteToClient(pClient, size, (char *) pRep); 686706f2543Smrg} 687706f2543Smrg 688706f2543Smrgvoid 689706f2543SmrgSGetKeyboardControlReply(ClientPtr pClient, int size, xGetKeyboardControlReply *pRep) 690706f2543Smrg{ 691706f2543Smrg char n; 692706f2543Smrg 693706f2543Smrg swaps(&pRep->sequenceNumber, n); 694706f2543Smrg swapl(&pRep->length, n); 695706f2543Smrg swapl(&pRep->ledMask, n); 696706f2543Smrg swaps(&pRep->bellPitch, n); 697706f2543Smrg swaps(&pRep->bellDuration, n); 698706f2543Smrg (void)WriteToClient(pClient, size, (char *) pRep); 699706f2543Smrg} 700706f2543Smrg 701706f2543Smrgvoid 702706f2543SmrgSGetPointerControlReply(ClientPtr pClient, int size, xGetPointerControlReply *pRep) 703706f2543Smrg{ 704706f2543Smrg char n; 705706f2543Smrg 706706f2543Smrg swaps(&pRep->sequenceNumber, n); 707706f2543Smrg swaps(&pRep->accelNumerator, n); 708706f2543Smrg swaps(&pRep->accelDenominator, n); 709706f2543Smrg swaps(&pRep->threshold, n); 710706f2543Smrg (void)WriteToClient(pClient, size, (char *) pRep); 711706f2543Smrg} 712706f2543Smrg 713706f2543Smrgvoid 714706f2543SmrgSGetScreenSaverReply(ClientPtr pClient, int size, xGetScreenSaverReply *pRep) 715706f2543Smrg{ 716706f2543Smrg char n; 717706f2543Smrg 718706f2543Smrg swaps(&pRep->sequenceNumber, n); 719706f2543Smrg swaps(&pRep->timeout, n); 720706f2543Smrg swaps(&pRep->interval, n); 721706f2543Smrg (void)WriteToClient(pClient, size, (char *) pRep); 722706f2543Smrg} 723706f2543Smrg 724706f2543Smrgvoid 725706f2543SmrgSLHostsExtend(ClientPtr pClient, int size, char *buf) 726706f2543Smrg{ 727706f2543Smrg char *bufT = buf; 728706f2543Smrg char *endbuf = buf + size; 729706f2543Smrg while (bufT < endbuf) { 730706f2543Smrg xHostEntry *host = (xHostEntry *) bufT; 731706f2543Smrg int len = host->length; 732706f2543Smrg char n; 733706f2543Smrg swaps (&host->length, n); 734706f2543Smrg bufT += sizeof (xHostEntry) + pad_to_int32(len); 735706f2543Smrg } 736706f2543Smrg (void)WriteToClient (pClient, size, buf); 737706f2543Smrg} 738706f2543Smrg 739706f2543Smrgvoid 740706f2543SmrgSListHostsReply(ClientPtr pClient, int size, xListHostsReply *pRep) 741706f2543Smrg{ 742706f2543Smrg char n; 743706f2543Smrg 744706f2543Smrg swaps(&pRep->sequenceNumber, n); 745706f2543Smrg swapl(&pRep->length, n); 746706f2543Smrg swaps(&pRep->nHosts, n); 747706f2543Smrg (void)WriteToClient(pClient, size, (char *) pRep); 748706f2543Smrg} 749706f2543Smrg 750706f2543Smrg 751706f2543Smrg 752706f2543Smrgvoid 753706f2543SmrgSErrorEvent(xError *from, xError *to) 754706f2543Smrg{ 755706f2543Smrg to->type = X_Error; 756706f2543Smrg to->errorCode = from->errorCode; 757706f2543Smrg cpswaps(from->sequenceNumber, to->sequenceNumber); 758706f2543Smrg cpswapl(from->resourceID, to->resourceID); 759706f2543Smrg cpswaps(from->minorCode, to->minorCode); 760706f2543Smrg to->majorCode = from->majorCode; 761706f2543Smrg} 762706f2543Smrg 763706f2543Smrgvoid 764706f2543SmrgSKeyButtonPtrEvent(xEvent *from, xEvent *to) 765706f2543Smrg{ 766706f2543Smrg to->u.u.type = from->u.u.type; 767706f2543Smrg to->u.u.detail = from->u.u.detail; 768706f2543Smrg cpswaps(from->u.u.sequenceNumber, to->u.u.sequenceNumber); 769706f2543Smrg cpswapl(from->u.keyButtonPointer.time, 770706f2543Smrg to->u.keyButtonPointer.time); 771706f2543Smrg cpswapl(from->u.keyButtonPointer.root, 772706f2543Smrg to->u.keyButtonPointer.root); 773706f2543Smrg cpswapl(from->u.keyButtonPointer.event, 774706f2543Smrg to->u.keyButtonPointer.event); 775706f2543Smrg cpswapl(from->u.keyButtonPointer.child, 776706f2543Smrg to->u.keyButtonPointer.child); 777706f2543Smrg cpswaps(from->u.keyButtonPointer.rootX, 778706f2543Smrg to->u.keyButtonPointer.rootX); 779706f2543Smrg cpswaps(from->u.keyButtonPointer.rootY, 780706f2543Smrg to->u.keyButtonPointer.rootY); 781706f2543Smrg cpswaps(from->u.keyButtonPointer.eventX, 782706f2543Smrg to->u.keyButtonPointer.eventX); 783706f2543Smrg cpswaps(from->u.keyButtonPointer.eventY, 784706f2543Smrg to->u.keyButtonPointer.eventY); 785706f2543Smrg cpswaps(from->u.keyButtonPointer.state, 786706f2543Smrg to->u.keyButtonPointer.state); 787706f2543Smrg to->u.keyButtonPointer.sameScreen = 788706f2543Smrg from->u.keyButtonPointer.sameScreen; 789706f2543Smrg} 790706f2543Smrg 791706f2543Smrgvoid 792706f2543SmrgSEnterLeaveEvent(xEvent *from, xEvent *to) 793706f2543Smrg{ 794706f2543Smrg to->u.u.type = from->u.u.type; 795706f2543Smrg to->u.u.detail = from->u.u.detail; 796706f2543Smrg cpswaps(from->u.u.sequenceNumber, to->u.u.sequenceNumber); 797706f2543Smrg cpswapl(from->u.enterLeave.time, to->u.enterLeave.time); 798706f2543Smrg cpswapl(from->u.enterLeave.root, to->u.enterLeave.root); 799706f2543Smrg cpswapl(from->u.enterLeave.event, to->u.enterLeave.event); 800706f2543Smrg cpswapl(from->u.enterLeave.child, to->u.enterLeave.child); 801706f2543Smrg cpswaps(from->u.enterLeave.rootX, to->u.enterLeave.rootX); 802706f2543Smrg cpswaps(from->u.enterLeave.rootY, to->u.enterLeave.rootY); 803706f2543Smrg cpswaps(from->u.enterLeave.eventX, to->u.enterLeave.eventX); 804706f2543Smrg cpswaps(from->u.enterLeave.eventY, to->u.enterLeave.eventY); 805706f2543Smrg cpswaps(from->u.enterLeave.state, to->u.enterLeave.state); 806706f2543Smrg to->u.enterLeave.mode = from->u.enterLeave.mode; 807706f2543Smrg to->u.enterLeave.flags = from->u.enterLeave.flags; 808706f2543Smrg} 809706f2543Smrg 810706f2543Smrgvoid 811706f2543SmrgSFocusEvent(xEvent *from, xEvent *to) 812706f2543Smrg{ 813706f2543Smrg to->u.u.type = from->u.u.type; 814706f2543Smrg to->u.u.detail = from->u.u.detail; 815706f2543Smrg cpswaps(from->u.u.sequenceNumber, to->u.u.sequenceNumber); 816706f2543Smrg cpswapl(from->u.focus.window, to->u.focus.window); 817706f2543Smrg to->u.focus.mode = from->u.focus.mode; 818706f2543Smrg} 819706f2543Smrg 820706f2543Smrgvoid 821706f2543SmrgSExposeEvent(xEvent *from, xEvent *to) 822706f2543Smrg{ 823706f2543Smrg to->u.u.type = from->u.u.type; 824706f2543Smrg cpswaps(from->u.u.sequenceNumber, to->u.u.sequenceNumber); 825706f2543Smrg cpswapl(from->u.expose.window, to->u.expose.window); 826706f2543Smrg cpswaps(from->u.expose.x, to->u.expose.x); 827706f2543Smrg cpswaps(from->u.expose.y, to->u.expose.y); 828706f2543Smrg cpswaps(from->u.expose.width, to->u.expose.width); 829706f2543Smrg cpswaps(from->u.expose.height, to->u.expose.height); 830706f2543Smrg cpswaps(from->u.expose.count, to->u.expose.count); 831706f2543Smrg} 832706f2543Smrg 833706f2543Smrgvoid 834706f2543SmrgSGraphicsExposureEvent(xEvent *from, xEvent *to) 835706f2543Smrg{ 836706f2543Smrg to->u.u.type = from->u.u.type; 837706f2543Smrg cpswaps(from->u.u.sequenceNumber, to->u.u.sequenceNumber); 838706f2543Smrg cpswapl(from->u.graphicsExposure.drawable, 839706f2543Smrg to->u.graphicsExposure.drawable); 840706f2543Smrg cpswaps(from->u.graphicsExposure.x, 841706f2543Smrg to->u.graphicsExposure.x); 842706f2543Smrg cpswaps(from->u.graphicsExposure.y, 843706f2543Smrg to->u.graphicsExposure.y); 844706f2543Smrg cpswaps(from->u.graphicsExposure.width, 845706f2543Smrg to->u.graphicsExposure.width); 846706f2543Smrg cpswaps(from->u.graphicsExposure.height, 847706f2543Smrg to->u.graphicsExposure.height); 848706f2543Smrg cpswaps(from->u.graphicsExposure.minorEvent, 849706f2543Smrg to->u.graphicsExposure.minorEvent); 850706f2543Smrg cpswaps(from->u.graphicsExposure.count, 851706f2543Smrg to->u.graphicsExposure.count); 852706f2543Smrg to->u.graphicsExposure.majorEvent = 853706f2543Smrg from->u.graphicsExposure.majorEvent; 854706f2543Smrg} 855706f2543Smrg 856706f2543Smrgvoid 857706f2543SmrgSNoExposureEvent(xEvent *from, xEvent *to) 858706f2543Smrg{ 859706f2543Smrg to->u.u.type = from->u.u.type; 860706f2543Smrg cpswaps(from->u.u.sequenceNumber, to->u.u.sequenceNumber); 861706f2543Smrg cpswapl(from->u.noExposure.drawable, to->u.noExposure.drawable); 862706f2543Smrg cpswaps(from->u.noExposure.minorEvent, to->u.noExposure.minorEvent); 863706f2543Smrg to->u.noExposure.majorEvent = from->u.noExposure.majorEvent; 864706f2543Smrg} 865706f2543Smrg 866706f2543Smrgvoid 867706f2543SmrgSVisibilityEvent(xEvent *from, xEvent *to) 868706f2543Smrg{ 869706f2543Smrg to->u.u.type = from->u.u.type; 870706f2543Smrg cpswaps(from->u.u.sequenceNumber, to->u.u.sequenceNumber); 871706f2543Smrg cpswapl(from->u.visibility.window, to->u.visibility.window); 872706f2543Smrg to->u.visibility.state = from->u.visibility.state; 873706f2543Smrg} 874706f2543Smrg 875706f2543Smrgvoid 876706f2543SmrgSCreateNotifyEvent(xEvent *from, xEvent *to) 877706f2543Smrg{ 878706f2543Smrg to->u.u.type = from->u.u.type; 879706f2543Smrg cpswaps(from->u.u.sequenceNumber, to->u.u.sequenceNumber); 880706f2543Smrg cpswapl(from->u.createNotify.window, to->u.createNotify.window); 881706f2543Smrg cpswapl(from->u.createNotify.parent, to->u.createNotify.parent); 882706f2543Smrg cpswaps(from->u.createNotify.x, to->u.createNotify.x); 883706f2543Smrg cpswaps(from->u.createNotify.y, to->u.createNotify.y); 884706f2543Smrg cpswaps(from->u.createNotify.width, to->u.createNotify.width); 885706f2543Smrg cpswaps(from->u.createNotify.height, to->u.createNotify.height); 886706f2543Smrg cpswaps(from->u.createNotify.borderWidth, 887706f2543Smrg to->u.createNotify.borderWidth); 888706f2543Smrg to->u.createNotify.override = from->u.createNotify.override; 889706f2543Smrg} 890706f2543Smrg 891706f2543Smrgvoid 892706f2543SmrgSDestroyNotifyEvent(xEvent *from, xEvent *to) 893706f2543Smrg{ 894706f2543Smrg to->u.u.type = from->u.u.type; 895706f2543Smrg cpswaps(from->u.u.sequenceNumber, to->u.u.sequenceNumber); 896706f2543Smrg cpswapl(from->u.destroyNotify.event, to->u.destroyNotify.event); 897706f2543Smrg cpswapl(from->u.destroyNotify.window, to->u.destroyNotify.window); 898706f2543Smrg} 899706f2543Smrg 900706f2543Smrgvoid 901706f2543SmrgSUnmapNotifyEvent(xEvent *from, xEvent *to) 902706f2543Smrg{ 903706f2543Smrg to->u.u.type = from->u.u.type; 904706f2543Smrg cpswaps(from->u.u.sequenceNumber, to->u.u.sequenceNumber); 905706f2543Smrg cpswapl(from->u.unmapNotify.event, to->u.unmapNotify.event); 906706f2543Smrg cpswapl(from->u.unmapNotify.window, to->u.unmapNotify.window); 907706f2543Smrg to->u.unmapNotify.fromConfigure = from->u.unmapNotify.fromConfigure; 908706f2543Smrg} 909706f2543Smrg 910706f2543Smrgvoid 911706f2543SmrgSMapNotifyEvent(xEvent *from, xEvent *to) 912706f2543Smrg{ 913706f2543Smrg to->u.u.type = from->u.u.type; 914706f2543Smrg cpswaps(from->u.u.sequenceNumber, to->u.u.sequenceNumber); 915706f2543Smrg cpswapl(from->u.mapNotify.event, to->u.mapNotify.event); 916706f2543Smrg cpswapl(from->u.mapNotify.window, to->u.mapNotify.window); 917706f2543Smrg to->u.mapNotify.override = from->u.mapNotify.override; 918706f2543Smrg} 919706f2543Smrg 920706f2543Smrgvoid 921706f2543SmrgSMapRequestEvent(xEvent *from, xEvent *to) 922706f2543Smrg{ 923706f2543Smrg to->u.u.type = from->u.u.type; 924706f2543Smrg cpswaps(from->u.u.sequenceNumber, to->u.u.sequenceNumber); 925706f2543Smrg cpswapl(from->u.mapRequest.parent, to->u.mapRequest.parent); 926706f2543Smrg cpswapl(from->u.mapRequest.window, to->u.mapRequest.window); 927706f2543Smrg} 928706f2543Smrg 929706f2543Smrgvoid 930706f2543SmrgSReparentEvent(xEvent *from, xEvent *to) 931706f2543Smrg{ 932706f2543Smrg to->u.u.type = from->u.u.type; 933706f2543Smrg cpswaps(from->u.u.sequenceNumber, to->u.u.sequenceNumber); 934706f2543Smrg cpswapl(from->u.reparent.event, to->u.reparent.event); 935706f2543Smrg cpswapl(from->u.reparent.window, to->u.reparent.window); 936706f2543Smrg cpswapl(from->u.reparent.parent, to->u.reparent.parent); 937706f2543Smrg cpswaps(from->u.reparent.x, to->u.reparent.x); 938706f2543Smrg cpswaps(from->u.reparent.y, to->u.reparent.y); 939706f2543Smrg to->u.reparent.override = from->u.reparent.override; 940706f2543Smrg} 941706f2543Smrg 942706f2543Smrgvoid 943706f2543SmrgSConfigureNotifyEvent(xEvent *from, xEvent *to) 944706f2543Smrg{ 945706f2543Smrg to->u.u.type = from->u.u.type; 946706f2543Smrg cpswaps(from->u.u.sequenceNumber, to->u.u.sequenceNumber); 947706f2543Smrg cpswapl(from->u.configureNotify.event, 948706f2543Smrg to->u.configureNotify.event); 949706f2543Smrg cpswapl(from->u.configureNotify.window, 950706f2543Smrg to->u.configureNotify.window); 951706f2543Smrg cpswapl(from->u.configureNotify.aboveSibling, 952706f2543Smrg to->u.configureNotify.aboveSibling); 953706f2543Smrg cpswaps(from->u.configureNotify.x, to->u.configureNotify.x); 954706f2543Smrg cpswaps(from->u.configureNotify.y, to->u.configureNotify.y); 955706f2543Smrg cpswaps(from->u.configureNotify.width, to->u.configureNotify.width); 956706f2543Smrg cpswaps(from->u.configureNotify.height, 957706f2543Smrg to->u.configureNotify.height); 958706f2543Smrg cpswaps(from->u.configureNotify.borderWidth, 959706f2543Smrg to->u.configureNotify.borderWidth); 960706f2543Smrg to->u.configureNotify.override = from->u.configureNotify.override; 961706f2543Smrg} 962706f2543Smrg 963706f2543Smrgvoid 964706f2543SmrgSConfigureRequestEvent(xEvent *from, xEvent *to) 965706f2543Smrg{ 966706f2543Smrg to->u.u.type = from->u.u.type; 967706f2543Smrg to->u.u.detail = from->u.u.detail; /* actually stack-mode */ 968706f2543Smrg cpswaps(from->u.u.sequenceNumber, to->u.u.sequenceNumber); 969706f2543Smrg cpswapl(from->u.configureRequest.parent, 970706f2543Smrg to->u.configureRequest.parent); 971706f2543Smrg cpswapl(from->u.configureRequest.window, 972706f2543Smrg to->u.configureRequest.window); 973706f2543Smrg cpswapl(from->u.configureRequest.sibling, 974706f2543Smrg to->u.configureRequest.sibling); 975706f2543Smrg cpswaps(from->u.configureRequest.x, to->u.configureRequest.x); 976706f2543Smrg cpswaps(from->u.configureRequest.y, to->u.configureRequest.y); 977706f2543Smrg cpswaps(from->u.configureRequest.width, 978706f2543Smrg to->u.configureRequest.width); 979706f2543Smrg cpswaps(from->u.configureRequest.height, 980706f2543Smrg to->u.configureRequest.height); 981706f2543Smrg cpswaps(from->u.configureRequest.borderWidth, 982706f2543Smrg to->u.configureRequest.borderWidth); 983706f2543Smrg cpswaps(from->u.configureRequest.valueMask, 984706f2543Smrg to->u.configureRequest.valueMask); 985706f2543Smrg} 986706f2543Smrg 987706f2543Smrg 988706f2543Smrgvoid 989706f2543SmrgSGravityEvent(xEvent *from, xEvent *to) 990706f2543Smrg{ 991706f2543Smrg to->u.u.type = from->u.u.type; 992706f2543Smrg cpswaps(from->u.u.sequenceNumber, to->u.u.sequenceNumber); 993706f2543Smrg cpswapl(from->u.gravity.event, to->u.gravity.event); 994706f2543Smrg cpswapl(from->u.gravity.window, to->u.gravity.window); 995706f2543Smrg cpswaps(from->u.gravity.x, to->u.gravity.x); 996706f2543Smrg cpswaps(from->u.gravity.y, to->u.gravity.y); 997706f2543Smrg} 998706f2543Smrg 999706f2543Smrgvoid 1000706f2543SmrgSResizeRequestEvent(xEvent *from, xEvent *to) 1001706f2543Smrg{ 1002706f2543Smrg to->u.u.type = from->u.u.type; 1003706f2543Smrg cpswaps(from->u.u.sequenceNumber, to->u.u.sequenceNumber); 1004706f2543Smrg cpswapl(from->u.resizeRequest.window, to->u.resizeRequest.window); 1005706f2543Smrg cpswaps(from->u.resizeRequest.width, to->u.resizeRequest.width); 1006706f2543Smrg cpswaps(from->u.resizeRequest.height, to->u.resizeRequest.height); 1007706f2543Smrg} 1008706f2543Smrg 1009706f2543Smrgvoid 1010706f2543SmrgSCirculateEvent(xEvent *from, xEvent *to) 1011706f2543Smrg{ 1012706f2543Smrg to->u.u.type = from->u.u.type; 1013706f2543Smrg to->u.u.detail = from->u.u.detail; 1014706f2543Smrg cpswaps(from->u.u.sequenceNumber, to->u.u.sequenceNumber); 1015706f2543Smrg cpswapl(from->u.circulate.event, to->u.circulate.event); 1016706f2543Smrg cpswapl(from->u.circulate.window, to->u.circulate.window); 1017706f2543Smrg cpswapl(from->u.circulate.parent, to->u.circulate.parent); 1018706f2543Smrg to->u.circulate.place = from->u.circulate.place; 1019706f2543Smrg} 1020706f2543Smrg 1021706f2543Smrgvoid 1022706f2543SmrgSPropertyEvent(xEvent *from, xEvent *to) 1023706f2543Smrg{ 1024706f2543Smrg to->u.u.type = from->u.u.type; 1025706f2543Smrg cpswaps(from->u.u.sequenceNumber, to->u.u.sequenceNumber); 1026706f2543Smrg cpswapl(from->u.property.window, to->u.property.window); 1027706f2543Smrg cpswapl(from->u.property.atom, to->u.property.atom); 1028706f2543Smrg cpswapl(from->u.property.time, to->u.property.time); 1029706f2543Smrg to->u.property.state = from->u.property.state; 1030706f2543Smrg} 1031706f2543Smrg 1032706f2543Smrgvoid 1033706f2543SmrgSSelectionClearEvent(xEvent *from, xEvent *to) 1034706f2543Smrg{ 1035706f2543Smrg to->u.u.type = from->u.u.type; 1036706f2543Smrg cpswaps(from->u.u.sequenceNumber, to->u.u.sequenceNumber); 1037706f2543Smrg cpswapl(from->u.selectionClear.time, to->u.selectionClear.time); 1038706f2543Smrg cpswapl(from->u.selectionClear.window, to->u.selectionClear.window); 1039706f2543Smrg cpswapl(from->u.selectionClear.atom, to->u.selectionClear.atom); 1040706f2543Smrg} 1041706f2543Smrg 1042706f2543Smrgvoid 1043706f2543SmrgSSelectionRequestEvent(xEvent *from, xEvent *to) 1044706f2543Smrg{ 1045706f2543Smrg to->u.u.type = from->u.u.type; 1046706f2543Smrg cpswaps(from->u.u.sequenceNumber, to->u.u.sequenceNumber); 1047706f2543Smrg cpswapl(from->u.selectionRequest.time, to->u.selectionRequest.time); 1048706f2543Smrg cpswapl(from->u.selectionRequest.owner, 1049706f2543Smrg to->u.selectionRequest.owner); 1050706f2543Smrg cpswapl(from->u.selectionRequest.requestor, 1051706f2543Smrg to->u.selectionRequest.requestor); 1052706f2543Smrg cpswapl(from->u.selectionRequest.selection, 1053706f2543Smrg to->u.selectionRequest.selection); 1054706f2543Smrg cpswapl(from->u.selectionRequest.target, 1055706f2543Smrg to->u.selectionRequest.target); 1056706f2543Smrg cpswapl(from->u.selectionRequest.property, 1057706f2543Smrg to->u.selectionRequest.property); 1058706f2543Smrg} 1059706f2543Smrg 1060706f2543Smrgvoid 1061706f2543SmrgSSelectionNotifyEvent(xEvent *from, xEvent *to) 1062706f2543Smrg{ 1063706f2543Smrg to->u.u.type = from->u.u.type; 1064706f2543Smrg cpswaps(from->u.u.sequenceNumber, to->u.u.sequenceNumber); 1065706f2543Smrg cpswapl(from->u.selectionNotify.time, to->u.selectionNotify.time); 1066706f2543Smrg cpswapl(from->u.selectionNotify.requestor, 1067706f2543Smrg to->u.selectionNotify.requestor); 1068706f2543Smrg cpswapl(from->u.selectionNotify.selection, 1069706f2543Smrg to->u.selectionNotify.selection); 1070706f2543Smrg cpswapl(from->u.selectionNotify.target, 1071706f2543Smrg to->u.selectionNotify.target); 1072706f2543Smrg cpswapl(from->u.selectionNotify.property, 1073706f2543Smrg to->u.selectionNotify.property); 1074706f2543Smrg} 1075706f2543Smrg 1076706f2543Smrgvoid 1077706f2543SmrgSColormapEvent(xEvent *from, xEvent *to) 1078706f2543Smrg{ 1079706f2543Smrg to->u.u.type = from->u.u.type; 1080706f2543Smrg cpswaps(from->u.u.sequenceNumber, to->u.u.sequenceNumber); 1081706f2543Smrg cpswapl(from->u.colormap.window, to->u.colormap.window); 1082706f2543Smrg cpswapl(from->u.colormap.colormap, to->u.colormap.colormap); 1083706f2543Smrg to->u.colormap.new = from->u.colormap.new; 1084706f2543Smrg to->u.colormap.state = from->u.colormap.state; 1085706f2543Smrg} 1086706f2543Smrg 1087706f2543Smrgvoid 1088706f2543SmrgSMappingEvent(xEvent *from, xEvent *to) 1089706f2543Smrg{ 1090706f2543Smrg to->u.u.type = from->u.u.type; 1091706f2543Smrg cpswaps(from->u.u.sequenceNumber, to->u.u.sequenceNumber); 1092706f2543Smrg to->u.mappingNotify.request = from->u.mappingNotify.request; 1093706f2543Smrg to->u.mappingNotify.firstKeyCode = 1094706f2543Smrg from->u.mappingNotify.firstKeyCode; 1095706f2543Smrg to->u.mappingNotify.count = from->u.mappingNotify.count; 1096706f2543Smrg} 1097706f2543Smrg 1098706f2543Smrgvoid 1099706f2543SmrgSClientMessageEvent(xEvent *from, xEvent *to) 1100706f2543Smrg{ 1101706f2543Smrg to->u.u.type = from->u.u.type; 1102706f2543Smrg to->u.u.detail = from->u.u.detail; /* actually format */ 1103706f2543Smrg cpswaps(from->u.u.sequenceNumber, to->u.u.sequenceNumber); 1104706f2543Smrg cpswapl(from->u.clientMessage.window, to->u.clientMessage.window); 1105706f2543Smrg cpswapl(from->u.clientMessage.u.l.type, 1106706f2543Smrg to->u.clientMessage.u.l.type); 1107706f2543Smrg switch (from->u.u.detail) { 1108706f2543Smrg case 8: 1109706f2543Smrg memmove(to->u.clientMessage.u.b.bytes, 1110706f2543Smrg from->u.clientMessage.u.b.bytes,20); 1111706f2543Smrg break; 1112706f2543Smrg case 16: 1113706f2543Smrg cpswaps(from->u.clientMessage.u.s.shorts0, 1114706f2543Smrg to->u.clientMessage.u.s.shorts0); 1115706f2543Smrg cpswaps(from->u.clientMessage.u.s.shorts1, 1116706f2543Smrg to->u.clientMessage.u.s.shorts1); 1117706f2543Smrg cpswaps(from->u.clientMessage.u.s.shorts2, 1118706f2543Smrg to->u.clientMessage.u.s.shorts2); 1119706f2543Smrg cpswaps(from->u.clientMessage.u.s.shorts3, 1120706f2543Smrg to->u.clientMessage.u.s.shorts3); 1121706f2543Smrg cpswaps(from->u.clientMessage.u.s.shorts4, 1122706f2543Smrg to->u.clientMessage.u.s.shorts4); 1123706f2543Smrg cpswaps(from->u.clientMessage.u.s.shorts5, 1124706f2543Smrg to->u.clientMessage.u.s.shorts5); 1125706f2543Smrg cpswaps(from->u.clientMessage.u.s.shorts6, 1126706f2543Smrg to->u.clientMessage.u.s.shorts6); 1127706f2543Smrg cpswaps(from->u.clientMessage.u.s.shorts7, 1128706f2543Smrg to->u.clientMessage.u.s.shorts7); 1129706f2543Smrg cpswaps(from->u.clientMessage.u.s.shorts8, 1130706f2543Smrg to->u.clientMessage.u.s.shorts8); 1131706f2543Smrg cpswaps(from->u.clientMessage.u.s.shorts9, 1132706f2543Smrg to->u.clientMessage.u.s.shorts9); 1133706f2543Smrg break; 1134706f2543Smrg case 32: 1135706f2543Smrg cpswapl(from->u.clientMessage.u.l.longs0, 1136706f2543Smrg to->u.clientMessage.u.l.longs0); 1137706f2543Smrg cpswapl(from->u.clientMessage.u.l.longs1, 1138706f2543Smrg to->u.clientMessage.u.l.longs1); 1139706f2543Smrg cpswapl(from->u.clientMessage.u.l.longs2, 1140706f2543Smrg to->u.clientMessage.u.l.longs2); 1141706f2543Smrg cpswapl(from->u.clientMessage.u.l.longs3, 1142706f2543Smrg to->u.clientMessage.u.l.longs3); 1143706f2543Smrg cpswapl(from->u.clientMessage.u.l.longs4, 1144706f2543Smrg to->u.clientMessage.u.l.longs4); 1145706f2543Smrg break; 1146706f2543Smrg } 1147706f2543Smrg} 1148706f2543Smrg 1149706f2543Smrgvoid 1150706f2543SmrgSKeymapNotifyEvent(xEvent *from, xEvent *to) 1151706f2543Smrg{ 1152706f2543Smrg /* Keymap notify events are special; they have no 1153706f2543Smrg sequence number field, and contain entirely 8-bit data */ 1154706f2543Smrg *to = *from; 1155706f2543Smrg} 1156706f2543Smrg 1157706f2543Smrgstatic void 1158706f2543SmrgSwapConnSetup(xConnSetup *pConnSetup, xConnSetup *pConnSetupT) 1159706f2543Smrg{ 1160706f2543Smrg cpswapl(pConnSetup->release, pConnSetupT->release); 1161706f2543Smrg cpswapl(pConnSetup->ridBase, pConnSetupT->ridBase); 1162706f2543Smrg cpswapl(pConnSetup->ridMask, pConnSetupT->ridMask); 1163706f2543Smrg cpswapl(pConnSetup->motionBufferSize, pConnSetupT->motionBufferSize); 1164706f2543Smrg cpswaps(pConnSetup->nbytesVendor, pConnSetupT->nbytesVendor); 1165706f2543Smrg cpswaps(pConnSetup->maxRequestSize, pConnSetupT->maxRequestSize); 1166706f2543Smrg pConnSetupT->minKeyCode = pConnSetup->minKeyCode; 1167706f2543Smrg pConnSetupT->maxKeyCode = pConnSetup->maxKeyCode; 1168706f2543Smrg pConnSetupT->numRoots = pConnSetup->numRoots; 1169706f2543Smrg pConnSetupT->numFormats = pConnSetup->numFormats; 1170706f2543Smrg pConnSetupT->imageByteOrder = pConnSetup->imageByteOrder; 1171706f2543Smrg pConnSetupT->bitmapBitOrder = pConnSetup->bitmapBitOrder; 1172706f2543Smrg pConnSetupT->bitmapScanlineUnit = pConnSetup->bitmapScanlineUnit; 1173706f2543Smrg pConnSetupT->bitmapScanlinePad = pConnSetup->bitmapScanlinePad; 1174706f2543Smrg} 1175706f2543Smrg 1176706f2543Smrgstatic void 1177706f2543SmrgSwapWinRoot(xWindowRoot *pRoot, xWindowRoot *pRootT) 1178706f2543Smrg{ 1179706f2543Smrg cpswapl(pRoot->windowId, pRootT->windowId); 1180706f2543Smrg cpswapl(pRoot->defaultColormap, pRootT->defaultColormap); 1181706f2543Smrg cpswapl(pRoot->whitePixel, pRootT->whitePixel); 1182706f2543Smrg cpswapl(pRoot->blackPixel, pRootT->blackPixel); 1183706f2543Smrg cpswapl(pRoot->currentInputMask, pRootT->currentInputMask); 1184706f2543Smrg cpswaps(pRoot->pixWidth, pRootT->pixWidth); 1185706f2543Smrg cpswaps(pRoot->pixHeight, pRootT->pixHeight); 1186706f2543Smrg cpswaps(pRoot->mmWidth, pRootT->mmWidth); 1187706f2543Smrg cpswaps(pRoot->mmHeight, pRootT->mmHeight); 1188706f2543Smrg cpswaps(pRoot->minInstalledMaps, pRootT->minInstalledMaps); 1189706f2543Smrg cpswaps(pRoot->maxInstalledMaps, pRootT->maxInstalledMaps); 1190706f2543Smrg cpswapl(pRoot->rootVisualID, pRootT->rootVisualID); 1191706f2543Smrg pRootT->backingStore = pRoot->backingStore; 1192706f2543Smrg pRootT->saveUnders = pRoot->saveUnders; 1193706f2543Smrg pRootT->rootDepth = pRoot->rootDepth; 1194706f2543Smrg pRootT->nDepths = pRoot->nDepths; 1195706f2543Smrg} 1196706f2543Smrg 1197706f2543Smrgstatic void 1198706f2543SmrgSwapVisual(xVisualType *pVis, xVisualType *pVisT) 1199706f2543Smrg{ 1200706f2543Smrg cpswapl(pVis->visualID, pVisT->visualID); 1201706f2543Smrg pVisT->class = pVis->class; 1202706f2543Smrg pVisT->bitsPerRGB = pVis->bitsPerRGB; 1203706f2543Smrg cpswaps(pVis->colormapEntries, pVisT->colormapEntries); 1204706f2543Smrg cpswapl(pVis->redMask, pVisT->redMask); 1205706f2543Smrg cpswapl(pVis->greenMask, pVisT->greenMask); 1206706f2543Smrg cpswapl(pVis->blueMask, pVisT->blueMask); 1207706f2543Smrg} 1208706f2543Smrg 1209706f2543Smrgvoid 1210706f2543SmrgSwapConnSetupInfo( 1211706f2543Smrg char *pInfo, 1212706f2543Smrg char *pInfoT 1213706f2543Smrg) 1214706f2543Smrg{ 1215706f2543Smrg int i, j, k; 1216706f2543Smrg xConnSetup *pConnSetup = (xConnSetup *)pInfo; 1217706f2543Smrg xDepth *depth; 1218706f2543Smrg xWindowRoot *root; 1219706f2543Smrg 1220706f2543Smrg SwapConnSetup(pConnSetup, (xConnSetup *)pInfoT); 1221706f2543Smrg pInfo += sizeof(xConnSetup); 1222706f2543Smrg pInfoT += sizeof(xConnSetup); 1223706f2543Smrg 1224706f2543Smrg /* Copy the vendor string */ 1225706f2543Smrg i = pad_to_int32(pConnSetup->nbytesVendor); 1226706f2543Smrg memcpy(pInfoT, pInfo, i); 1227706f2543Smrg pInfo += i; 1228706f2543Smrg pInfoT += i; 1229706f2543Smrg 1230706f2543Smrg /* The Pixmap formats don't need to be swapped, just copied. */ 1231706f2543Smrg i = sizeof(xPixmapFormat) * pConnSetup->numFormats; 1232706f2543Smrg memcpy(pInfoT, pInfo, i); 1233706f2543Smrg pInfo += i; 1234706f2543Smrg pInfoT += i; 1235706f2543Smrg 1236706f2543Smrg for(i = 0; i < pConnSetup->numRoots; i++) 1237706f2543Smrg { 1238706f2543Smrg root = (xWindowRoot*)pInfo; 1239706f2543Smrg SwapWinRoot(root, (xWindowRoot *)pInfoT); 1240706f2543Smrg pInfo += sizeof(xWindowRoot); 1241706f2543Smrg pInfoT += sizeof(xWindowRoot); 1242706f2543Smrg 1243706f2543Smrg for(j = 0; j < root->nDepths; j++) 1244706f2543Smrg { 1245706f2543Smrg depth = (xDepth*)pInfo; 1246706f2543Smrg ((xDepth *)pInfoT)->depth = depth->depth; 1247706f2543Smrg cpswaps(depth->nVisuals, ((xDepth *)pInfoT)->nVisuals); 1248706f2543Smrg pInfo += sizeof(xDepth); 1249706f2543Smrg pInfoT += sizeof(xDepth); 1250706f2543Smrg for(k = 0; k < depth->nVisuals; k++) 1251706f2543Smrg { 1252706f2543Smrg SwapVisual((xVisualType *)pInfo, (xVisualType *)pInfoT); 1253706f2543Smrg pInfo += sizeof(xVisualType); 1254706f2543Smrg pInfoT += sizeof(xVisualType); 1255706f2543Smrg } 1256706f2543Smrg } 1257706f2543Smrg } 1258706f2543Smrg} 1259706f2543Smrg 1260706f2543Smrgvoid 1261706f2543SmrgWriteSConnectionInfo(ClientPtr pClient, unsigned long size, char *pInfo) 1262706f2543Smrg{ 1263706f2543Smrg char *pInfoTBase; 1264706f2543Smrg 1265706f2543Smrg pInfoTBase = malloc(size); 1266706f2543Smrg if (!pInfoTBase) 1267706f2543Smrg { 1268706f2543Smrg pClient->noClientException = -1; 1269706f2543Smrg return; 1270706f2543Smrg } 1271706f2543Smrg SwapConnSetupInfo(pInfo, pInfoTBase); 1272706f2543Smrg (void)WriteToClient(pClient, (int)size, (char *) pInfoTBase); 1273706f2543Smrg free(pInfoTBase); 1274706f2543Smrg} 1275706f2543Smrg 1276706f2543Smrgvoid 1277706f2543SmrgSwapConnSetupPrefix(xConnSetupPrefix *pcspFrom, xConnSetupPrefix *pcspTo) 1278706f2543Smrg{ 1279706f2543Smrg pcspTo->success = pcspFrom->success; 1280706f2543Smrg pcspTo->lengthReason = pcspFrom->lengthReason; 1281706f2543Smrg cpswaps(pcspFrom->majorVersion, pcspTo->majorVersion); 1282706f2543Smrg cpswaps(pcspFrom->minorVersion, pcspTo->minorVersion); 1283706f2543Smrg cpswaps(pcspFrom->length, pcspTo->length); 1284706f2543Smrg} 1285706f2543Smrg 1286706f2543Smrgvoid 1287706f2543SmrgWriteSConnSetupPrefix(ClientPtr pClient, xConnSetupPrefix *pcsp) 1288706f2543Smrg{ 1289706f2543Smrg xConnSetupPrefix cspT; 1290706f2543Smrg 1291706f2543Smrg SwapConnSetupPrefix(pcsp, &cspT); 1292706f2543Smrg (void)WriteToClient(pClient, sizeof(cspT), (char *) &cspT); 1293706f2543Smrg} 1294706f2543Smrg 1295706f2543Smrg/* 1296706f2543Smrg * Dummy entry for ReplySwapVector[] 1297706f2543Smrg */ 1298706f2543Smrg 1299706f2543Smrgvoid 1300706f2543SmrgReplyNotSwappd( 1301706f2543Smrg ClientPtr pClient , 1302706f2543Smrg int size , 1303706f2543Smrg void * pbuf 1304706f2543Smrg ) 1305706f2543Smrg{ 1306706f2543Smrg FatalError("Not implemented"); 1307706f2543Smrg} 1308706f2543Smrg 1309