Commit | Line | Data |
---|---|---|
a09e091a JB |
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 <X11/Xprotostr.h> | |
54 | #include "misc.h" | |
55 | #include "dixstruct.h" | |
56 | #include "extnsionst.h" /* for SendEvent */ | |
57 | #include "swapreq.h" | |
58 | ||
59 | /* Thanks to Jack Palevich for testing and subsequently rewriting all this */ | |
60 | ||
61 | /* Byte swap a list of longs */ | |
62 | void | |
63 | SwapLongs(CARD32 *list, unsigned long count) | |
64 | { | |
65 | while (count >= 8) { | |
66 | swapl(list + 0); | |
67 | swapl(list + 1); | |
68 | swapl(list + 2); | |
69 | swapl(list + 3); | |
70 | swapl(list + 4); | |
71 | swapl(list + 5); | |
72 | swapl(list + 6); | |
73 | swapl(list + 7); | |
74 | list += 8; | |
75 | count -= 8; | |
76 | } | |
77 | if (count != 0) { | |
78 | do { | |
79 | swapl(list); | |
80 | list++; | |
81 | } while (--count != 0); | |
82 | } | |
83 | } | |
84 | ||
85 | /* Byte swap a list of shorts */ | |
86 | void | |
87 | SwapShorts(short *list, unsigned long count) | |
88 | { | |
89 | while (count >= 16) { | |
90 | swaps(list + 0); | |
91 | swaps(list + 1); | |
92 | swaps(list + 2); | |
93 | swaps(list + 3); | |
94 | swaps(list + 4); | |
95 | swaps(list + 5); | |
96 | swaps(list + 6); | |
97 | swaps(list + 7); | |
98 | swaps(list + 8); | |
99 | swaps(list + 9); | |
100 | swaps(list + 10); | |
101 | swaps(list + 11); | |
102 | swaps(list + 12); | |
103 | swaps(list + 13); | |
104 | swaps(list + 14); | |
105 | swaps(list + 15); | |
106 | list += 16; | |
107 | count -= 16; | |
108 | } | |
109 | if (count != 0) { | |
110 | do { | |
111 | swaps(list); | |
112 | list++; | |
113 | } while (--count != 0); | |
114 | } | |
115 | } | |
116 | ||
117 | /* The following is used for all requests that have | |
118 | no fields to be swapped (except "length") */ | |
119 | int | |
120 | SProcSimpleReq(ClientPtr client) | |
121 | { | |
122 | REQUEST(xReq); | |
123 | swaps(&stuff->length); | |
124 | return (*ProcVector[stuff->reqType]) (client); | |
125 | } | |
126 | ||
127 | /* The following is used for all requests that have | |
128 | only a single 32-bit field to be swapped, coming | |
129 | right after the "length" field */ | |
130 | int | |
131 | SProcResourceReq(ClientPtr client) | |
132 | { | |
133 | REQUEST(xResourceReq); | |
134 | swaps(&stuff->length); | |
135 | REQUEST_AT_LEAST_SIZE(xResourceReq); /* not EXACT */ | |
136 | swapl(&stuff->id); | |
137 | return (*ProcVector[stuff->reqType]) (client); | |
138 | } | |
139 | ||
140 | int | |
141 | SProcCreateWindow(ClientPtr client) | |
142 | { | |
143 | REQUEST(xCreateWindowReq); | |
144 | swaps(&stuff->length); | |
145 | REQUEST_AT_LEAST_SIZE(xCreateWindowReq); | |
146 | swapl(&stuff->wid); | |
147 | swapl(&stuff->parent); | |
148 | swaps(&stuff->x); | |
149 | swaps(&stuff->y); | |
150 | swaps(&stuff->width); | |
151 | swaps(&stuff->height); | |
152 | swaps(&stuff->borderWidth); | |
153 | swaps(&stuff->class); | |
154 | swapl(&stuff->visual); | |
155 | swapl(&stuff->mask); | |
156 | SwapRestL(stuff); | |
157 | return ((*ProcVector[X_CreateWindow]) (client)); | |
158 | } | |
159 | ||
160 | int | |
161 | SProcChangeWindowAttributes(ClientPtr client) | |
162 | { | |
163 | REQUEST(xChangeWindowAttributesReq); | |
164 | swaps(&stuff->length); | |
165 | REQUEST_AT_LEAST_SIZE(xChangeWindowAttributesReq); | |
166 | swapl(&stuff->window); | |
167 | swapl(&stuff->valueMask); | |
168 | SwapRestL(stuff); | |
169 | return ((*ProcVector[X_ChangeWindowAttributes]) (client)); | |
170 | } | |
171 | ||
172 | int | |
173 | SProcReparentWindow(ClientPtr client) | |
174 | { | |
175 | REQUEST(xReparentWindowReq); | |
176 | swaps(&stuff->length); | |
177 | REQUEST_SIZE_MATCH(xReparentWindowReq); | |
178 | swapl(&stuff->window); | |
179 | swapl(&stuff->parent); | |
180 | swaps(&stuff->x); | |
181 | swaps(&stuff->y); | |
182 | return ((*ProcVector[X_ReparentWindow]) (client)); | |
183 | } | |
184 | ||
185 | int | |
186 | SProcConfigureWindow(ClientPtr client) | |
187 | { | |
188 | REQUEST(xConfigureWindowReq); | |
189 | swaps(&stuff->length); | |
190 | REQUEST_AT_LEAST_SIZE(xConfigureWindowReq); | |
191 | swapl(&stuff->window); | |
192 | swaps(&stuff->mask); | |
193 | SwapRestL(stuff); | |
194 | return ((*ProcVector[X_ConfigureWindow]) (client)); | |
195 | ||
196 | } | |
197 | ||
198 | int | |
199 | SProcInternAtom(ClientPtr client) | |
200 | { | |
201 | REQUEST(xInternAtomReq); | |
202 | swaps(&stuff->length); | |
203 | REQUEST_AT_LEAST_SIZE(xInternAtomReq); | |
204 | swaps(&stuff->nbytes); | |
205 | return ((*ProcVector[X_InternAtom]) (client)); | |
206 | } | |
207 | ||
208 | int | |
209 | SProcChangeProperty(ClientPtr client) | |
210 | { | |
211 | REQUEST(xChangePropertyReq); | |
212 | swaps(&stuff->length); | |
213 | REQUEST_AT_LEAST_SIZE(xChangePropertyReq); | |
214 | swapl(&stuff->window); | |
215 | swapl(&stuff->property); | |
216 | swapl(&stuff->type); | |
217 | swapl(&stuff->nUnits); | |
218 | switch (stuff->format) { | |
219 | case 8: | |
220 | break; | |
221 | case 16: | |
222 | SwapRestS(stuff); | |
223 | break; | |
224 | case 32: | |
225 | SwapRestL(stuff); | |
226 | break; | |
227 | } | |
228 | return ((*ProcVector[X_ChangeProperty]) (client)); | |
229 | } | |
230 | ||
231 | int | |
232 | SProcDeleteProperty(ClientPtr client) | |
233 | { | |
234 | REQUEST(xDeletePropertyReq); | |
235 | swaps(&stuff->length); | |
236 | REQUEST_SIZE_MATCH(xDeletePropertyReq); | |
237 | swapl(&stuff->window); | |
238 | swapl(&stuff->property); | |
239 | return ((*ProcVector[X_DeleteProperty]) (client)); | |
240 | ||
241 | } | |
242 | ||
243 | int | |
244 | SProcGetProperty(ClientPtr client) | |
245 | { | |
246 | REQUEST(xGetPropertyReq); | |
247 | swaps(&stuff->length); | |
248 | REQUEST_SIZE_MATCH(xGetPropertyReq); | |
249 | swapl(&stuff->window); | |
250 | swapl(&stuff->property); | |
251 | swapl(&stuff->type); | |
252 | swapl(&stuff->longOffset); | |
253 | swapl(&stuff->longLength); | |
254 | return ((*ProcVector[X_GetProperty]) (client)); | |
255 | } | |
256 | ||
257 | int | |
258 | SProcSetSelectionOwner(ClientPtr client) | |
259 | { | |
260 | REQUEST(xSetSelectionOwnerReq); | |
261 | swaps(&stuff->length); | |
262 | REQUEST_SIZE_MATCH(xSetSelectionOwnerReq); | |
263 | swapl(&stuff->window); | |
264 | swapl(&stuff->selection); | |
265 | swapl(&stuff->time); | |
266 | return ((*ProcVector[X_SetSelectionOwner]) (client)); | |
267 | } | |
268 | ||
269 | int | |
270 | SProcConvertSelection(ClientPtr client) | |
271 | { | |
272 | REQUEST(xConvertSelectionReq); | |
273 | swaps(&stuff->length); | |
274 | REQUEST_SIZE_MATCH(xConvertSelectionReq); | |
275 | swapl(&stuff->requestor); | |
276 | swapl(&stuff->selection); | |
277 | swapl(&stuff->target); | |
278 | swapl(&stuff->property); | |
279 | swapl(&stuff->time); | |
280 | return ((*ProcVector[X_ConvertSelection]) (client)); | |
281 | } | |
282 | ||
283 | int | |
284 | SProcSendEvent(ClientPtr client) | |
285 | { | |
286 | xEvent eventT = { .u.u.type = 0 }; | |
287 | EventSwapPtr proc; | |
288 | ||
289 | REQUEST(xSendEventReq); | |
290 | swaps(&stuff->length); | |
291 | REQUEST_SIZE_MATCH(xSendEventReq); | |
292 | swapl(&stuff->destination); | |
293 | swapl(&stuff->eventMask); | |
294 | ||
295 | /* Swap event */ | |
296 | proc = EventSwapVector[stuff->event.u.u.type & 0177]; | |
297 | if (!proc || proc == NotImplemented) /* no swapping proc; invalid event type? */ | |
298 | return BadValue; | |
299 | (*proc) (&stuff->event, &eventT); | |
300 | stuff->event = eventT; | |
301 | ||
302 | return ((*ProcVector[X_SendEvent]) (client)); | |
303 | } | |
304 | ||
305 | int | |
306 | SProcGrabPointer(ClientPtr client) | |
307 | { | |
308 | REQUEST(xGrabPointerReq); | |
309 | swaps(&stuff->length); | |
310 | REQUEST_SIZE_MATCH(xGrabPointerReq); | |
311 | swapl(&stuff->grabWindow); | |
312 | swaps(&stuff->eventMask); | |
313 | swapl(&stuff->confineTo); | |
314 | swapl(&stuff->cursor); | |
315 | swapl(&stuff->time); | |
316 | return ((*ProcVector[X_GrabPointer]) (client)); | |
317 | } | |
318 | ||
319 | int | |
320 | SProcGrabButton(ClientPtr client) | |
321 | { | |
322 | REQUEST(xGrabButtonReq); | |
323 | swaps(&stuff->length); | |
324 | REQUEST_SIZE_MATCH(xGrabButtonReq); | |
325 | swapl(&stuff->grabWindow); | |
326 | swaps(&stuff->eventMask); | |
327 | swapl(&stuff->confineTo); | |
328 | swapl(&stuff->cursor); | |
329 | swaps(&stuff->modifiers); | |
330 | return ((*ProcVector[X_GrabButton]) (client)); | |
331 | } | |
332 | ||
333 | int | |
334 | SProcUngrabButton(ClientPtr client) | |
335 | { | |
336 | REQUEST(xUngrabButtonReq); | |
337 | swaps(&stuff->length); | |
338 | REQUEST_SIZE_MATCH(xUngrabButtonReq); | |
339 | swapl(&stuff->grabWindow); | |
340 | swaps(&stuff->modifiers); | |
341 | return ((*ProcVector[X_UngrabButton]) (client)); | |
342 | } | |
343 | ||
344 | int | |
345 | SProcChangeActivePointerGrab(ClientPtr client) | |
346 | { | |
347 | REQUEST(xChangeActivePointerGrabReq); | |
348 | swaps(&stuff->length); | |
349 | REQUEST_SIZE_MATCH(xChangeActivePointerGrabReq); | |
350 | swapl(&stuff->cursor); | |
351 | swapl(&stuff->time); | |
352 | swaps(&stuff->eventMask); | |
353 | return ((*ProcVector[X_ChangeActivePointerGrab]) (client)); | |
354 | } | |
355 | ||
356 | int | |
357 | SProcGrabKeyboard(ClientPtr client) | |
358 | { | |
359 | REQUEST(xGrabKeyboardReq); | |
360 | swaps(&stuff->length); | |
361 | REQUEST_SIZE_MATCH(xGrabKeyboardReq); | |
362 | swapl(&stuff->grabWindow); | |
363 | swapl(&stuff->time); | |
364 | return ((*ProcVector[X_GrabKeyboard]) (client)); | |
365 | } | |
366 | ||
367 | int | |
368 | SProcGrabKey(ClientPtr client) | |
369 | { | |
370 | REQUEST(xGrabKeyReq); | |
371 | swaps(&stuff->length); | |
372 | REQUEST_SIZE_MATCH(xGrabKeyReq); | |
373 | swapl(&stuff->grabWindow); | |
374 | swaps(&stuff->modifiers); | |
375 | return ((*ProcVector[X_GrabKey]) (client)); | |
376 | } | |
377 | ||
378 | int | |
379 | SProcUngrabKey(ClientPtr client) | |
380 | { | |
381 | REQUEST(xUngrabKeyReq); | |
382 | swaps(&stuff->length); | |
383 | REQUEST_SIZE_MATCH(xUngrabKeyReq); | |
384 | swapl(&stuff->grabWindow); | |
385 | swaps(&stuff->modifiers); | |
386 | return ((*ProcVector[X_UngrabKey]) (client)); | |
387 | } | |
388 | ||
389 | int | |
390 | SProcGetMotionEvents(ClientPtr client) | |
391 | { | |
392 | REQUEST(xGetMotionEventsReq); | |
393 | swaps(&stuff->length); | |
394 | REQUEST_SIZE_MATCH(xGetMotionEventsReq); | |
395 | swapl(&stuff->window); | |
396 | swapl(&stuff->start); | |
397 | swapl(&stuff->stop); | |
398 | return ((*ProcVector[X_GetMotionEvents]) (client)); | |
399 | } | |
400 | ||
401 | int | |
402 | SProcTranslateCoords(ClientPtr client) | |
403 | { | |
404 | REQUEST(xTranslateCoordsReq); | |
405 | swaps(&stuff->length); | |
406 | REQUEST_SIZE_MATCH(xTranslateCoordsReq); | |
407 | swapl(&stuff->srcWid); | |
408 | swapl(&stuff->dstWid); | |
409 | swaps(&stuff->srcX); | |
410 | swaps(&stuff->srcY); | |
411 | return ((*ProcVector[X_TranslateCoords]) (client)); | |
412 | } | |
413 | ||
414 | int | |
415 | SProcWarpPointer(ClientPtr client) | |
416 | { | |
417 | REQUEST(xWarpPointerReq); | |
418 | swaps(&stuff->length); | |
419 | REQUEST_SIZE_MATCH(xWarpPointerReq); | |
420 | swapl(&stuff->srcWid); | |
421 | swapl(&stuff->dstWid); | |
422 | swaps(&stuff->srcX); | |
423 | swaps(&stuff->srcY); | |
424 | swaps(&stuff->srcWidth); | |
425 | swaps(&stuff->srcHeight); | |
426 | swaps(&stuff->dstX); | |
427 | swaps(&stuff->dstY); | |
428 | return ((*ProcVector[X_WarpPointer]) (client)); | |
429 | } | |
430 | ||
431 | int | |
432 | SProcSetInputFocus(ClientPtr client) | |
433 | { | |
434 | REQUEST(xSetInputFocusReq); | |
435 | swaps(&stuff->length); | |
436 | REQUEST_SIZE_MATCH(xSetInputFocusReq); | |
437 | swapl(&stuff->focus); | |
438 | swapl(&stuff->time); | |
439 | return ((*ProcVector[X_SetInputFocus]) (client)); | |
440 | } | |
441 | ||
442 | int | |
443 | SProcOpenFont(ClientPtr client) | |
444 | { | |
445 | REQUEST(xOpenFontReq); | |
446 | swaps(&stuff->length); | |
447 | REQUEST_AT_LEAST_SIZE(xOpenFontReq); | |
448 | swapl(&stuff->fid); | |
449 | swaps(&stuff->nbytes); | |
450 | return ((*ProcVector[X_OpenFont]) (client)); | |
451 | } | |
452 | ||
453 | int | |
454 | SProcListFonts(ClientPtr client) | |
455 | { | |
456 | REQUEST(xListFontsReq); | |
457 | swaps(&stuff->length); | |
458 | REQUEST_AT_LEAST_SIZE(xListFontsReq); | |
459 | swaps(&stuff->maxNames); | |
460 | swaps(&stuff->nbytes); | |
461 | return ((*ProcVector[X_ListFonts]) (client)); | |
462 | } | |
463 | ||
464 | int | |
465 | SProcListFontsWithInfo(ClientPtr client) | |
466 | { | |
467 | REQUEST(xListFontsWithInfoReq); | |
468 | swaps(&stuff->length); | |
469 | REQUEST_AT_LEAST_SIZE(xListFontsWithInfoReq); | |
470 | swaps(&stuff->maxNames); | |
471 | swaps(&stuff->nbytes); | |
472 | return ((*ProcVector[X_ListFontsWithInfo]) (client)); | |
473 | } | |
474 | ||
475 | int | |
476 | SProcSetFontPath(ClientPtr client) | |
477 | { | |
478 | REQUEST(xSetFontPathReq); | |
479 | swaps(&stuff->length); | |
480 | REQUEST_AT_LEAST_SIZE(xSetFontPathReq); | |
481 | swaps(&stuff->nFonts); | |
482 | return ((*ProcVector[X_SetFontPath]) (client)); | |
483 | } | |
484 | ||
485 | int | |
486 | SProcCreatePixmap(ClientPtr client) | |
487 | { | |
488 | REQUEST(xCreatePixmapReq); | |
489 | ||
490 | swaps(&stuff->length); | |
491 | REQUEST_SIZE_MATCH(xCreatePixmapReq); | |
492 | swapl(&stuff->pid); | |
493 | swapl(&stuff->drawable); | |
494 | swaps(&stuff->width); | |
495 | swaps(&stuff->height); | |
496 | return ((*ProcVector[X_CreatePixmap]) (client)); | |
497 | } | |
498 | ||
499 | int | |
500 | SProcCreateGC(ClientPtr client) | |
501 | { | |
502 | REQUEST(xCreateGCReq); | |
503 | swaps(&stuff->length); | |
504 | REQUEST_AT_LEAST_SIZE(xCreateGCReq); | |
505 | swapl(&stuff->gc); | |
506 | swapl(&stuff->drawable); | |
507 | swapl(&stuff->mask); | |
508 | SwapRestL(stuff); | |
509 | return ((*ProcVector[X_CreateGC]) (client)); | |
510 | } | |
511 | ||
512 | int | |
513 | SProcChangeGC(ClientPtr client) | |
514 | { | |
515 | REQUEST(xChangeGCReq); | |
516 | swaps(&stuff->length); | |
517 | REQUEST_AT_LEAST_SIZE(xChangeGCReq); | |
518 | swapl(&stuff->gc); | |
519 | swapl(&stuff->mask); | |
520 | SwapRestL(stuff); | |
521 | return ((*ProcVector[X_ChangeGC]) (client)); | |
522 | } | |
523 | ||
524 | int | |
525 | SProcCopyGC(ClientPtr client) | |
526 | { | |
527 | REQUEST(xCopyGCReq); | |
528 | swaps(&stuff->length); | |
529 | REQUEST_SIZE_MATCH(xCopyGCReq); | |
530 | swapl(&stuff->srcGC); | |
531 | swapl(&stuff->dstGC); | |
532 | swapl(&stuff->mask); | |
533 | return ((*ProcVector[X_CopyGC]) (client)); | |
534 | } | |
535 | ||
536 | int | |
537 | SProcSetDashes(ClientPtr client) | |
538 | { | |
539 | REQUEST(xSetDashesReq); | |
540 | swaps(&stuff->length); | |
541 | REQUEST_AT_LEAST_SIZE(xSetDashesReq); | |
542 | swapl(&stuff->gc); | |
543 | swaps(&stuff->dashOffset); | |
544 | swaps(&stuff->nDashes); | |
545 | return ((*ProcVector[X_SetDashes]) (client)); | |
546 | ||
547 | } | |
548 | ||
549 | int | |
550 | SProcSetClipRectangles(ClientPtr client) | |
551 | { | |
552 | REQUEST(xSetClipRectanglesReq); | |
553 | swaps(&stuff->length); | |
554 | REQUEST_AT_LEAST_SIZE(xSetClipRectanglesReq); | |
555 | swapl(&stuff->gc); | |
556 | swaps(&stuff->xOrigin); | |
557 | swaps(&stuff->yOrigin); | |
558 | SwapRestS(stuff); | |
559 | return ((*ProcVector[X_SetClipRectangles]) (client)); | |
560 | } | |
561 | ||
562 | int | |
563 | SProcClearToBackground(ClientPtr client) | |
564 | { | |
565 | REQUEST(xClearAreaReq); | |
566 | swaps(&stuff->length); | |
567 | REQUEST_SIZE_MATCH(xClearAreaReq); | |
568 | swapl(&stuff->window); | |
569 | swaps(&stuff->x); | |
570 | swaps(&stuff->y); | |
571 | swaps(&stuff->width); | |
572 | swaps(&stuff->height); | |
573 | return ((*ProcVector[X_ClearArea]) (client)); | |
574 | } | |
575 | ||
576 | int | |
577 | SProcCopyArea(ClientPtr client) | |
578 | { | |
579 | REQUEST(xCopyAreaReq); | |
580 | swaps(&stuff->length); | |
581 | REQUEST_SIZE_MATCH(xCopyAreaReq); | |
582 | swapl(&stuff->srcDrawable); | |
583 | swapl(&stuff->dstDrawable); | |
584 | swapl(&stuff->gc); | |
585 | swaps(&stuff->srcX); | |
586 | swaps(&stuff->srcY); | |
587 | swaps(&stuff->dstX); | |
588 | swaps(&stuff->dstY); | |
589 | swaps(&stuff->width); | |
590 | swaps(&stuff->height); | |
591 | return ((*ProcVector[X_CopyArea]) (client)); | |
592 | } | |
593 | ||
594 | int | |
595 | SProcCopyPlane(ClientPtr client) | |
596 | { | |
597 | REQUEST(xCopyPlaneReq); | |
598 | swaps(&stuff->length); | |
599 | REQUEST_SIZE_MATCH(xCopyPlaneReq); | |
600 | swapl(&stuff->srcDrawable); | |
601 | swapl(&stuff->dstDrawable); | |
602 | swapl(&stuff->gc); | |
603 | swaps(&stuff->srcX); | |
604 | swaps(&stuff->srcY); | |
605 | swaps(&stuff->dstX); | |
606 | swaps(&stuff->dstY); | |
607 | swaps(&stuff->width); | |
608 | swaps(&stuff->height); | |
609 | swapl(&stuff->bitPlane); | |
610 | return ((*ProcVector[X_CopyPlane]) (client)); | |
611 | } | |
612 | ||
613 | /* The following routine is used for all Poly drawing requests | |
614 | (except FillPoly, which uses a different request format) */ | |
615 | int | |
616 | SProcPoly(ClientPtr client) | |
617 | { | |
618 | REQUEST(xPolyPointReq); | |
619 | swaps(&stuff->length); | |
620 | REQUEST_AT_LEAST_SIZE(xPolyPointReq); | |
621 | swapl(&stuff->drawable); | |
622 | swapl(&stuff->gc); | |
623 | SwapRestS(stuff); | |
624 | return ((*ProcVector[stuff->reqType]) (client)); | |
625 | } | |
626 | ||
627 | /* cannot use SProcPoly for this one, because xFillPolyReq | |
628 | is longer than xPolyPointReq, and we don't want to swap | |
629 | the difference as shorts! */ | |
630 | int | |
631 | SProcFillPoly(ClientPtr client) | |
632 | { | |
633 | REQUEST(xFillPolyReq); | |
634 | swaps(&stuff->length); | |
635 | REQUEST_AT_LEAST_SIZE(xFillPolyReq); | |
636 | swapl(&stuff->drawable); | |
637 | swapl(&stuff->gc); | |
638 | SwapRestS(stuff); | |
639 | return ((*ProcVector[X_FillPoly]) (client)); | |
640 | } | |
641 | ||
642 | int | |
643 | SProcPutImage(ClientPtr client) | |
644 | { | |
645 | REQUEST(xPutImageReq); | |
646 | swaps(&stuff->length); | |
647 | REQUEST_AT_LEAST_SIZE(xPutImageReq); | |
648 | swapl(&stuff->drawable); | |
649 | swapl(&stuff->gc); | |
650 | swaps(&stuff->width); | |
651 | swaps(&stuff->height); | |
652 | swaps(&stuff->dstX); | |
653 | swaps(&stuff->dstY); | |
654 | /* Image should already be swapped */ | |
655 | return ((*ProcVector[X_PutImage]) (client)); | |
656 | ||
657 | } | |
658 | ||
659 | int | |
660 | SProcGetImage(ClientPtr client) | |
661 | { | |
662 | REQUEST(xGetImageReq); | |
663 | swaps(&stuff->length); | |
664 | REQUEST_SIZE_MATCH(xGetImageReq); | |
665 | swapl(&stuff->drawable); | |
666 | swaps(&stuff->x); | |
667 | swaps(&stuff->y); | |
668 | swaps(&stuff->width); | |
669 | swaps(&stuff->height); | |
670 | swapl(&stuff->planeMask); | |
671 | return ((*ProcVector[X_GetImage]) (client)); | |
672 | } | |
673 | ||
674 | /* ProcPolyText used for both PolyText8 and PolyText16 */ | |
675 | ||
676 | int | |
677 | SProcPolyText(ClientPtr client) | |
678 | { | |
679 | REQUEST(xPolyTextReq); | |
680 | swaps(&stuff->length); | |
681 | REQUEST_AT_LEAST_SIZE(xPolyTextReq); | |
682 | swapl(&stuff->drawable); | |
683 | swapl(&stuff->gc); | |
684 | swaps(&stuff->x); | |
685 | swaps(&stuff->y); | |
686 | return ((*ProcVector[stuff->reqType]) (client)); | |
687 | } | |
688 | ||
689 | /* ProcImageText used for both ImageText8 and ImageText16 */ | |
690 | ||
691 | int | |
692 | SProcImageText(ClientPtr client) | |
693 | { | |
694 | REQUEST(xImageTextReq); | |
695 | swaps(&stuff->length); | |
696 | REQUEST_AT_LEAST_SIZE(xImageTextReq); | |
697 | swapl(&stuff->drawable); | |
698 | swapl(&stuff->gc); | |
699 | swaps(&stuff->x); | |
700 | swaps(&stuff->y); | |
701 | return ((*ProcVector[stuff->reqType]) (client)); | |
702 | } | |
703 | ||
704 | int | |
705 | SProcCreateColormap(ClientPtr client) | |
706 | { | |
707 | REQUEST(xCreateColormapReq); | |
708 | swaps(&stuff->length); | |
709 | REQUEST_SIZE_MATCH(xCreateColormapReq); | |
710 | swapl(&stuff->mid); | |
711 | swapl(&stuff->window); | |
712 | swapl(&stuff->visual); | |
713 | return ((*ProcVector[X_CreateColormap]) (client)); | |
714 | } | |
715 | ||
716 | int | |
717 | SProcCopyColormapAndFree(ClientPtr client) | |
718 | { | |
719 | REQUEST(xCopyColormapAndFreeReq); | |
720 | swaps(&stuff->length); | |
721 | REQUEST_SIZE_MATCH(xCopyColormapAndFreeReq); | |
722 | swapl(&stuff->mid); | |
723 | swapl(&stuff->srcCmap); | |
724 | return ((*ProcVector[X_CopyColormapAndFree]) (client)); | |
725 | ||
726 | } | |
727 | ||
728 | int | |
729 | SProcAllocColor(ClientPtr client) | |
730 | { | |
731 | REQUEST(xAllocColorReq); | |
732 | swaps(&stuff->length); | |
733 | REQUEST_SIZE_MATCH(xAllocColorReq); | |
734 | swapl(&stuff->cmap); | |
735 | swaps(&stuff->red); | |
736 | swaps(&stuff->green); | |
737 | swaps(&stuff->blue); | |
738 | return ((*ProcVector[X_AllocColor]) (client)); | |
739 | } | |
740 | ||
741 | int | |
742 | SProcAllocNamedColor(ClientPtr client) | |
743 | { | |
744 | REQUEST(xAllocNamedColorReq); | |
745 | swaps(&stuff->length); | |
746 | REQUEST_AT_LEAST_SIZE(xAllocNamedColorReq); | |
747 | swapl(&stuff->cmap); | |
748 | swaps(&stuff->nbytes); | |
749 | return ((*ProcVector[X_AllocNamedColor]) (client)); | |
750 | } | |
751 | ||
752 | int | |
753 | SProcAllocColorCells(ClientPtr client) | |
754 | { | |
755 | REQUEST(xAllocColorCellsReq); | |
756 | swaps(&stuff->length); | |
757 | REQUEST_SIZE_MATCH(xAllocColorCellsReq); | |
758 | swapl(&stuff->cmap); | |
759 | swaps(&stuff->colors); | |
760 | swaps(&stuff->planes); | |
761 | return ((*ProcVector[X_AllocColorCells]) (client)); | |
762 | } | |
763 | ||
764 | int | |
765 | SProcAllocColorPlanes(ClientPtr client) | |
766 | { | |
767 | REQUEST(xAllocColorPlanesReq); | |
768 | swaps(&stuff->length); | |
769 | REQUEST_SIZE_MATCH(xAllocColorPlanesReq); | |
770 | swapl(&stuff->cmap); | |
771 | swaps(&stuff->colors); | |
772 | swaps(&stuff->red); | |
773 | swaps(&stuff->green); | |
774 | swaps(&stuff->blue); | |
775 | return ((*ProcVector[X_AllocColorPlanes]) (client)); | |
776 | } | |
777 | ||
778 | int | |
779 | SProcFreeColors(ClientPtr client) | |
780 | { | |
781 | REQUEST(xFreeColorsReq); | |
782 | swaps(&stuff->length); | |
783 | REQUEST_AT_LEAST_SIZE(xFreeColorsReq); | |
784 | swapl(&stuff->cmap); | |
785 | swapl(&stuff->planeMask); | |
786 | SwapRestL(stuff); | |
787 | return ((*ProcVector[X_FreeColors]) (client)); | |
788 | ||
789 | } | |
790 | ||
791 | void | |
792 | SwapColorItem(xColorItem * pItem) | |
793 | { | |
794 | swapl(&pItem->pixel); | |
795 | swaps(&pItem->red); | |
796 | swaps(&pItem->green); | |
797 | swaps(&pItem->blue); | |
798 | } | |
799 | ||
800 | int | |
801 | SProcStoreColors(ClientPtr client) | |
802 | { | |
803 | long count; | |
804 | xColorItem *pItem; | |
805 | ||
806 | REQUEST(xStoreColorsReq); | |
807 | swaps(&stuff->length); | |
808 | REQUEST_AT_LEAST_SIZE(xStoreColorsReq); | |
809 | swapl(&stuff->cmap); | |
810 | pItem = (xColorItem *) &stuff[1]; | |
811 | for (count = LengthRestB(stuff) / sizeof(xColorItem); --count >= 0;) | |
812 | SwapColorItem(pItem++); | |
813 | return ((*ProcVector[X_StoreColors]) (client)); | |
814 | } | |
815 | ||
816 | int | |
817 | SProcStoreNamedColor(ClientPtr client) | |
818 | { | |
819 | REQUEST(xStoreNamedColorReq); | |
820 | swaps(&stuff->length); | |
821 | REQUEST_AT_LEAST_SIZE(xStoreNamedColorReq); | |
822 | swapl(&stuff->cmap); | |
823 | swapl(&stuff->pixel); | |
824 | swaps(&stuff->nbytes); | |
825 | return ((*ProcVector[X_StoreNamedColor]) (client)); | |
826 | } | |
827 | ||
828 | int | |
829 | SProcQueryColors(ClientPtr client) | |
830 | { | |
831 | REQUEST(xQueryColorsReq); | |
832 | swaps(&stuff->length); | |
833 | REQUEST_AT_LEAST_SIZE(xQueryColorsReq); | |
834 | swapl(&stuff->cmap); | |
835 | SwapRestL(stuff); | |
836 | return ((*ProcVector[X_QueryColors]) (client)); | |
837 | } | |
838 | ||
839 | int | |
840 | SProcLookupColor(ClientPtr client) | |
841 | { | |
842 | REQUEST(xLookupColorReq); | |
843 | swaps(&stuff->length); | |
844 | REQUEST_AT_LEAST_SIZE(xLookupColorReq); | |
845 | swapl(&stuff->cmap); | |
846 | swaps(&stuff->nbytes); | |
847 | return ((*ProcVector[X_LookupColor]) (client)); | |
848 | } | |
849 | ||
850 | int | |
851 | SProcCreateCursor(ClientPtr client) | |
852 | { | |
853 | REQUEST(xCreateCursorReq); | |
854 | swaps(&stuff->length); | |
855 | REQUEST_SIZE_MATCH(xCreateCursorReq); | |
856 | swapl(&stuff->cid); | |
857 | swapl(&stuff->source); | |
858 | swapl(&stuff->mask); | |
859 | swaps(&stuff->foreRed); | |
860 | swaps(&stuff->foreGreen); | |
861 | swaps(&stuff->foreBlue); | |
862 | swaps(&stuff->backRed); | |
863 | swaps(&stuff->backGreen); | |
864 | swaps(&stuff->backBlue); | |
865 | swaps(&stuff->x); | |
866 | swaps(&stuff->y); | |
867 | return ((*ProcVector[X_CreateCursor]) (client)); | |
868 | } | |
869 | ||
870 | int | |
871 | SProcCreateGlyphCursor(ClientPtr client) | |
872 | { | |
873 | REQUEST(xCreateGlyphCursorReq); | |
874 | swaps(&stuff->length); | |
875 | REQUEST_SIZE_MATCH(xCreateGlyphCursorReq); | |
876 | swapl(&stuff->cid); | |
877 | swapl(&stuff->source); | |
878 | swapl(&stuff->mask); | |
879 | swaps(&stuff->sourceChar); | |
880 | swaps(&stuff->maskChar); | |
881 | swaps(&stuff->foreRed); | |
882 | swaps(&stuff->foreGreen); | |
883 | swaps(&stuff->foreBlue); | |
884 | swaps(&stuff->backRed); | |
885 | swaps(&stuff->backGreen); | |
886 | swaps(&stuff->backBlue); | |
887 | return ((*ProcVector[X_CreateGlyphCursor]) (client)); | |
888 | } | |
889 | ||
890 | int | |
891 | SProcRecolorCursor(ClientPtr client) | |
892 | { | |
893 | REQUEST(xRecolorCursorReq); | |
894 | swaps(&stuff->length); | |
895 | REQUEST_SIZE_MATCH(xRecolorCursorReq); | |
896 | swapl(&stuff->cursor); | |
897 | swaps(&stuff->foreRed); | |
898 | swaps(&stuff->foreGreen); | |
899 | swaps(&stuff->foreBlue); | |
900 | swaps(&stuff->backRed); | |
901 | swaps(&stuff->backGreen); | |
902 | swaps(&stuff->backBlue); | |
903 | return ((*ProcVector[X_RecolorCursor]) (client)); | |
904 | } | |
905 | ||
906 | int | |
907 | SProcQueryBestSize(ClientPtr client) | |
908 | { | |
909 | REQUEST(xQueryBestSizeReq); | |
910 | swaps(&stuff->length); | |
911 | REQUEST_SIZE_MATCH(xQueryBestSizeReq); | |
912 | swapl(&stuff->drawable); | |
913 | swaps(&stuff->width); | |
914 | swaps(&stuff->height); | |
915 | return ((*ProcVector[X_QueryBestSize]) (client)); | |
916 | ||
917 | } | |
918 | ||
919 | int | |
920 | SProcQueryExtension(ClientPtr client) | |
921 | { | |
922 | REQUEST(xQueryExtensionReq); | |
923 | swaps(&stuff->length); | |
924 | REQUEST_AT_LEAST_SIZE(xQueryExtensionReq); | |
925 | swaps(&stuff->nbytes); | |
926 | return ((*ProcVector[X_QueryExtension]) (client)); | |
927 | } | |
928 | ||
929 | int | |
930 | SProcChangeKeyboardMapping(ClientPtr client) | |
931 | { | |
932 | REQUEST(xChangeKeyboardMappingReq); | |
933 | swaps(&stuff->length); | |
934 | REQUEST_AT_LEAST_SIZE(xChangeKeyboardMappingReq); | |
935 | SwapRestL(stuff); | |
936 | return ((*ProcVector[X_ChangeKeyboardMapping]) (client)); | |
937 | } | |
938 | ||
939 | int | |
940 | SProcChangeKeyboardControl(ClientPtr client) | |
941 | { | |
942 | REQUEST(xChangeKeyboardControlReq); | |
943 | swaps(&stuff->length); | |
944 | REQUEST_AT_LEAST_SIZE(xChangeKeyboardControlReq); | |
945 | swapl(&stuff->mask); | |
946 | SwapRestL(stuff); | |
947 | return ((*ProcVector[X_ChangeKeyboardControl]) (client)); | |
948 | } | |
949 | ||
950 | int | |
951 | SProcChangePointerControl(ClientPtr client) | |
952 | { | |
953 | REQUEST(xChangePointerControlReq); | |
954 | swaps(&stuff->length); | |
955 | REQUEST_SIZE_MATCH(xChangePointerControlReq); | |
956 | swaps(&stuff->accelNum); | |
957 | swaps(&stuff->accelDenum); | |
958 | swaps(&stuff->threshold); | |
959 | return ((*ProcVector[X_ChangePointerControl]) (client)); | |
960 | } | |
961 | ||
962 | int | |
963 | SProcSetScreenSaver(ClientPtr client) | |
964 | { | |
965 | REQUEST(xSetScreenSaverReq); | |
966 | swaps(&stuff->length); | |
967 | REQUEST_SIZE_MATCH(xSetScreenSaverReq); | |
968 | swaps(&stuff->timeout); | |
969 | swaps(&stuff->interval); | |
970 | return ((*ProcVector[X_SetScreenSaver]) (client)); | |
971 | } | |
972 | ||
973 | int | |
974 | SProcChangeHosts(ClientPtr client) | |
975 | { | |
976 | REQUEST(xChangeHostsReq); | |
977 | swaps(&stuff->length); | |
978 | REQUEST_AT_LEAST_SIZE(xChangeHostsReq); | |
979 | swaps(&stuff->hostLength); | |
980 | return ((*ProcVector[X_ChangeHosts]) (client)); | |
981 | ||
982 | } | |
983 | ||
984 | int | |
985 | SProcRotateProperties(ClientPtr client) | |
986 | { | |
987 | REQUEST(xRotatePropertiesReq); | |
988 | swaps(&stuff->length); | |
989 | REQUEST_AT_LEAST_SIZE(xRotatePropertiesReq); | |
990 | swapl(&stuff->window); | |
991 | swaps(&stuff->nAtoms); | |
992 | swaps(&stuff->nPositions); | |
993 | SwapRestL(stuff); | |
994 | return ((*ProcVector[X_RotateProperties]) (client)); | |
995 | } | |
996 | ||
997 | int | |
998 | SProcNoOperation(ClientPtr client) | |
999 | { | |
1000 | REQUEST(xReq); | |
1001 | swaps(&stuff->length); | |
1002 | return ((*ProcVector[X_NoOperation]) (client)); | |
1003 | } | |
1004 | ||
1005 | void | |
1006 | SwapConnClientPrefix(xConnClientPrefix * pCCP) | |
1007 | { | |
1008 | swaps(&pCCP->majorVersion); | |
1009 | swaps(&pCCP->minorVersion); | |
1010 | swaps(&pCCP->nbytesAuthProto); | |
1011 | swaps(&pCCP->nbytesAuthString); | |
1012 | } |