1 /*
2 * Request, Reply, Event, Error Printing
3 *
4 * James Peterson, 1988
5 *
6 * Copyright (C) 1988 MCC
7 *
8 * Permission to use, copy, modify, distribute, and sell this software and its
9 * documentation for any purpose is hereby granted without fee, provided that
10 * the above copyright notice appear in all copies and that both that
11 * copyright notice and this permission notice appear in supporting
12 * documentation, and that the name of MCC not be used in
13 * advertising or publicity pertaining to distribution of the software without
14 * specific, written prior permission. MCC makes no
15 * representations about the suitability of this software for any purpose. It
16 * is provided "as is" without express or implied warranty.
17 *
18 * MCC DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
19 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
20 * EVENT SHALL MCC BE LIABLE FOR ANY SPECIAL, INDIRECT OR
21 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
22 * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
23 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
24 * PERFORMANCE OF THIS SOFTWARE.
25 *
26 */
27 /*
28 * Copyright (c) 2002, 2009, 2012, Oracle and/or its affiliates.
29 * All rights reserved.
30 *
31 * Permission is hereby granted, free of charge, to any person obtaining a
32 * copy of this software and associated documentation files (the "Software"),
33 * to deal in the Software without restriction, including without limitation
34 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
35 * and/or sell copies of the Software, and to permit persons to whom the
36 * Software is furnished to do so, subject to the following conditions:
37 *
38 * The above copyright notice and this permission notice (including the next
39 * paragraph) shall be included in all copies or substantial portions of the
40 * Software.
41 *
42 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
43 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
44 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
45 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
46 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
47 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
48 * DEALINGS IN THE SOFTWARE.
49 *
50 */
51
52 #include "scope.h"
53 #include "x11.h"
54
55 static void PrintFailedSetUpReply(const unsigned char *buf);
56 static void PrintSuccessfulSetUpReply(const unsigned char *buf);
57 static void ListFontsWithInfoReply1(const unsigned char *buf);
58 static void ListFontsWithInfoReply2(const unsigned char *buf);
59
60
61 /* ************************************************************ */
62 /* */
63 /* */
64 /* ************************************************************ */
65
66 /*
67 In printing the contents of the fields of the X11 packets, some
68 fields are of obvious value, and others are of lesser value. To
69 control the amount of output, we generate our output according
70 to the level of Verbose-ness that was selected by the user.
71
72 Verbose = 0 == Headers only, time and request/reply/... names.
73
74 Verbose = 1 == Very useful content fields.
75
76 Verbose = 2 == Almost everything.
77
78 Verbose = 3 == Every single bit and byte.
79
80 */
81
82 /*
83 To aid in making the choice between level 1 and level 2, we
84 define the following define, which does not print relatively
85 unimportant fields.
86 */
87
88 #define printfield(a,b,c,d,e) if (Verbose > 1) PrintField(a,b,c,d,e)
89
90 /* ************************************************************ */
91 /* */
92 /* */
93 /* ************************************************************ */
94
95 void
PrintSetUpMessage(const unsigned char * buf)96 PrintSetUpMessage(const unsigned char *buf)
97 {
98 short n;
99 short d;
100
101 enterprocedure("PrintSetUpMessage");
102 if (Verbose < 1)
103 return;
104 SetIndentLevel(PRINTCLIENT);
105 PrintField(buf, 0, 1, BYTEMODE, "byte-order");
106 PrintField(buf, 2, 2, CARD16, "major-version");
107 PrintField(buf, 4, 2, CARD16, "minor-version");
108 printfield(buf, 6, 2, DVALUE2(n), "length of name");
109 n = IShort(&buf[6]);
110 printfield(buf, 8, 2, DVALUE2(d), "length of data");
111 d = IShort(&buf[8]);
112 PrintString8(&buf[12], n, "authorization-protocol-name");
113 PrintString8(&buf[pad((long) (12 + n))], d, "authorization-protocol-data");
114 }
115
116 void
PrintSetUpReply(const unsigned char * buf)117 PrintSetUpReply(const unsigned char *buf)
118 {
119 enterprocedure("PrintSetUpReply");
120 SetIndentLevel(PRINTSERVER);
121 if (IByte(&buf[0]))
122 PrintSuccessfulSetUpReply(buf);
123 else
124 PrintFailedSetUpReply(buf);
125 }
126
127 static void
PrintFailedSetUpReply(const unsigned char * buf)128 PrintFailedSetUpReply(const unsigned char *buf)
129 {
130 short n;
131
132 PrintField(buf, 0, 1, 0, "SetUp Failed");
133 if (Verbose < 1)
134 return;
135 printfield(buf, 1, 1, DVALUE1(n), "length of reason in bytes");
136 n = IByte(&buf[1]);
137 PrintField(buf, 2, 2, CARD16, "major-version");
138 PrintField(buf, 4, 2, CARD16, "minor-version");
139 printfield(buf, 6, 2, DVALUE2((n + p) / 4), "length of data");
140 PrintString8(&buf[8], n, "reason");
141 }
142
143 static void
PrintSuccessfulSetUpReply(const unsigned char * buf)144 PrintSuccessfulSetUpReply(const unsigned char *buf)
145 {
146 short v;
147 short n;
148 short m;
149
150 if (Verbose < 1)
151 return;
152 PrintField(buf, 2, 2, CARD16, "protocol-major-version");
153 PrintField(buf, 4, 2, CARD16, "protocol-minor-version");
154 printfield(buf, 6, 2, DVALUE2(8 + 2 * n + (v + p + m) / 4),
155 "length of data");
156 PrintField(buf, 8, 4, CARD32, "release-number");
157 PrintField(buf, 12, 4, CARD32, "resource-id-base");
158 PrintField(buf, 16, 4, CARD32, "resource-id-mask");
159 PrintField(buf, 20, 4, CARD32, "motion-buffer-size");
160 printfield(buf, 24, 2, DVALUE2(v), "length of vendor");
161 v = IShort(&buf[24]);
162 printfield(buf, 26, 2, CARD16, "maximum-request-length");
163 printfield(buf, 28, 1, CARD8, "number of roots");
164 m = IByte(&buf[28]);
165 printfield(buf, 29, 1, DVALUE1(n), "number of pixmap-formats");
166 n = IByte(&buf[29]);
167 PrintField(buf, 30, 1, BYTEORDER, "image-byte-order");
168 PrintField(buf, 31, 1, BYTEORDER, "bitmap-format-bit-order");
169 PrintField(buf, 32, 1, CARD8, "bitmap-format-scanline-unit");
170 PrintField(buf, 33, 1, CARD8, "bitmap-format-scanline-pad");
171 PrintField(buf, 34, 1, KEYCODE, "min-keycode");
172 PrintField(buf, 35, 1, KEYCODE, "max-keycode");
173 PrintString8(&buf[40], v, "vendor");
174 PrintList(&buf[pad((long) (40 + v))], (long) n, FORMAT, "pixmap-formats");
175 PrintList(&buf[pad((long) (40 + v) + 8 * n)], (long) m, SCREEN, "roots");
176 }
177
178 /* ************************************************************ */
179 /* */
180 /* */
181 /* ************************************************************ */
182
183 const char *REQUESTHEADER = "............REQUEST";
184 const char *EVENTHEADER = "..............EVENT";
185 const char *ERRORHEADER = "..............ERROR";
186 const char *REPLYHEADER = "..............REPLY";
187
188
189 /* ************************************************************ */
190 /* */
191 /* */
192 /* ************************************************************ */
193
194 /* Error Printing procedures */
195
196 /* generic routine for printing common format error messages with a
197 labeled bad value in bytes 4-7. */
198 void
printErrorWithValue(const unsigned char * buf,short FieldType,const char * desc)199 printErrorWithValue(const unsigned char *buf,
200 short FieldType, const char *desc)
201 {
202 PrintField(buf, 1, 1, ERROR, ERRORHEADER);
203 if (Verbose < 1)
204 return;
205 printfield(buf, 2, 2, CARD16, "sequence number");
206 PrintField(buf, 4, 4, FieldType, desc);
207 PrintField(buf, 8, 2, CARD16, "minor opcode");
208 PrintField(buf, 10, 1, CARD8, "major opcode");
209 }
210
211 /* generic routine for printing common format error messages with
212 no additional information provided. */
213 void
printErrorNoValue(const unsigned char * buf)214 printErrorNoValue(const unsigned char *buf)
215 {
216 PrintField(buf, 1, 1, ERROR, ERRORHEADER);
217 if (Verbose < 1)
218 return;
219 printfield(buf, 2, 2, CARD16, "sequence number");
220 /* 4 bytes unused */
221 PrintField(buf, 8, 2, CARD16, "minor opcode");
222 PrintField(buf, 10, 1, CARD8, "major opcode");
223 }
224
225 void
RequestError(const unsigned char * buf)226 RequestError(const unsigned char *buf)
227 {
228 printErrorNoValue(buf);
229 }
230
231 void
ValueError(const unsigned char * buf)232 ValueError(const unsigned char *buf)
233 {
234 printErrorWithValue(buf, INT32, "bad value");
235 }
236
237 void
WindowError(const unsigned char * buf)238 WindowError(const unsigned char *buf)
239 {
240 printErrorWithValue(buf, CARD32, "bad resource id");
241 }
242
243 void
PixmapError(const unsigned char * buf)244 PixmapError(const unsigned char *buf)
245 {
246 printErrorWithValue(buf, CARD32, "bad resource id");
247 }
248
249 void
AtomError(const unsigned char * buf)250 AtomError(const unsigned char *buf)
251 {
252 printErrorWithValue(buf, CARD32, "bad atom id");
253 }
254
255 void
CursorError(const unsigned char * buf)256 CursorError(const unsigned char *buf)
257 {
258 printErrorWithValue(buf, CARD32, "bad resource id");
259 }
260
261 void
FontError(const unsigned char * buf)262 FontError(const unsigned char *buf)
263 {
264 printErrorWithValue(buf, CARD32, "bad resource id");
265 }
266
267 void
MatchError(const unsigned char * buf)268 MatchError(const unsigned char *buf)
269 {
270 printErrorNoValue(buf);
271 }
272
273 void
DrawableError(const unsigned char * buf)274 DrawableError(const unsigned char *buf)
275 {
276 printErrorWithValue(buf, CARD32, "bad resource id");
277 }
278
279 void
AccessError(const unsigned char * buf)280 AccessError(const unsigned char *buf)
281 {
282 printErrorNoValue(buf);
283 }
284
285 void
AllocError(const unsigned char * buf)286 AllocError(const unsigned char *buf)
287 {
288 printErrorNoValue(buf);
289 }
290
291 void
ColormapError(const unsigned char * buf)292 ColormapError(const unsigned char *buf)
293 {
294 printErrorWithValue(buf, CARD32, "bad resource id");
295 }
296
297 void
GContextError(const unsigned char * buf)298 GContextError(const unsigned char *buf)
299 {
300 printErrorWithValue(buf, CARD32, "bad resource id");
301 }
302
303 void
IDChoiceError(const unsigned char * buf)304 IDChoiceError(const unsigned char *buf)
305 {
306 printErrorWithValue(buf, CARD32, "bad resource id");
307 }
308
309 void
NameError(const unsigned char * buf)310 NameError(const unsigned char *buf)
311 {
312 printErrorNoValue(buf);
313 }
314
315 void
LengthError(const unsigned char * buf)316 LengthError(const unsigned char *buf)
317 {
318 printErrorNoValue(buf);
319 }
320
321 void
ImplementationError(const unsigned char * buf)322 ImplementationError(const unsigned char *buf)
323 {
324 printErrorNoValue(buf);
325 }
326
327 void
UnknownError(const unsigned char * buf)328 UnknownError(const unsigned char *buf)
329 {
330 printErrorWithValue(buf, CARD32, "bad resource id");
331 }
332
333 /* ************************************************************ */
334 /* */
335 /* */
336 /* ************************************************************ */
337
338 /* Event Printing procedures */
339
340 void
KeyPressEvent(const unsigned char * buf)341 KeyPressEvent(const unsigned char *buf)
342 {
343 PrintField(buf, 0, 1, EVENT, EVENTHEADER); /* KeyPress */
344 if (Verbose < 1)
345 return;
346 PrintField(buf, 1, 1, KEYCODE, "detail");
347 printfield(buf, 2, 2, CARD16, "sequence number");
348 PrintField(buf, 4, 4, TIMESTAMP, "time");
349 PrintField(buf, 8, 4, WINDOW, "root");
350 PrintField(buf, 12, 4, WINDOW, "event");
351 PrintField(buf, 16, 4, WINDOW, "child");
352 PrintField(buf, 20, 2, INT16, "root-x");
353 PrintField(buf, 22, 2, INT16, "root-y");
354 PrintField(buf, 24, 2, INT16, "event-x");
355 PrintField(buf, 26, 2, INT16, "event-y");
356 PrintField(buf, 28, 2, SETofKEYBUTMASK, "state");
357 PrintField(buf, 30, 1, BOOL, "same-screen");
358 }
359
360 void
KeyReleaseEvent(const unsigned char * buf)361 KeyReleaseEvent(const unsigned char *buf)
362 {
363 PrintField(buf, 0, 1, EVENT, EVENTHEADER); /* KeyRelease */
364 if (Verbose < 1)
365 return;
366 PrintField(buf, 1, 1, KEYCODE, "detail");
367 printfield(buf, 2, 2, CARD16, "sequence number");
368 PrintField(buf, 4, 4, TIMESTAMP, "time");
369 PrintField(buf, 8, 4, WINDOW, "root");
370 PrintField(buf, 12, 4, WINDOW, "event");
371 PrintField(buf, 16, 4, WINDOW, "child");
372 PrintField(buf, 20, 2, INT16, "root-x");
373 PrintField(buf, 22, 2, INT16, "root-y");
374 PrintField(buf, 24, 2, INT16, "event-x");
375 PrintField(buf, 26, 2, INT16, "event-y");
376 PrintField(buf, 28, 2, SETofKEYBUTMASK, "state");
377 PrintField(buf, 30, 1, BOOL, "same-screen");
378 }
379
380 void
ButtonPressEvent(const unsigned char * buf)381 ButtonPressEvent(const unsigned char *buf)
382 {
383 PrintField(buf, 0, 1, EVENT, EVENTHEADER); /* ButtonPress */
384 if (Verbose < 1)
385 return;
386 PrintField(buf, 1, 1, BUTTON, "detail");
387 printfield(buf, 2, 2, CARD16, "sequence number");
388 PrintField(buf, 4, 4, TIMESTAMP, "time");
389 PrintField(buf, 8, 4, WINDOW, "root");
390 PrintField(buf, 12, 4, WINDOW, "event");
391 PrintField(buf, 16, 4, WINDOW, "child");
392 PrintField(buf, 20, 2, INT16, "root-x");
393 PrintField(buf, 22, 2, INT16, "root-y");
394 PrintField(buf, 24, 2, INT16, "event-x");
395 PrintField(buf, 26, 2, INT16, "event-y");
396 PrintField(buf, 28, 2, SETofKEYBUTMASK, "state");
397 PrintField(buf, 30, 1, BOOL, "same-screen");
398 }
399
400 void
ButtonReleaseEvent(const unsigned char * buf)401 ButtonReleaseEvent(const unsigned char *buf)
402 {
403 PrintField(buf, 0, 1, EVENT, EVENTHEADER); /* ButtonRelease */
404 if (Verbose < 1)
405 return;
406 PrintField(buf, 1, 1, BUTTON, "detail");
407 printfield(buf, 2, 2, CARD16, "sequence number");
408 PrintField(buf, 4, 4, TIMESTAMP, "time");
409 PrintField(buf, 8, 4, WINDOW, "root");
410 PrintField(buf, 12, 4, WINDOW, "event");
411 PrintField(buf, 16, 4, WINDOW, "child");
412 PrintField(buf, 20, 2, INT16, "root-x");
413 PrintField(buf, 22, 2, INT16, "root-y");
414 PrintField(buf, 24, 2, INT16, "event-x");
415 PrintField(buf, 26, 2, INT16, "event-y");
416 PrintField(buf, 28, 2, SETofKEYBUTMASK, "state");
417 PrintField(buf, 30, 1, BOOL, "same-screen");
418 }
419
420 void
MotionNotifyEvent(const unsigned char * buf)421 MotionNotifyEvent(const unsigned char *buf)
422 {
423 PrintField(buf, 0, 1, EVENT, EVENTHEADER); /* MotionNotify */
424 if (Verbose < 1)
425 return;
426 PrintField(buf, 1, 1, MOTIONDETAIL, "detail");
427 printfield(buf, 2, 2, CARD16, "sequence number");
428 PrintField(buf, 4, 4, TIMESTAMP, "time");
429 PrintField(buf, 8, 4, WINDOW, "root");
430 PrintField(buf, 12, 4, WINDOW, "event");
431 PrintField(buf, 16, 4, WINDOW, "child");
432 PrintField(buf, 20, 2, INT16, "root-x");
433 PrintField(buf, 22, 2, INT16, "root-y");
434 PrintField(buf, 24, 2, INT16, "event-x");
435 PrintField(buf, 26, 2, INT16, "event-y");
436 PrintField(buf, 28, 2, SETofKEYBUTMASK, "state");
437 PrintField(buf, 30, 1, BOOL, "same-screen");
438 }
439
440 void
EnterNotifyEvent(const unsigned char * buf)441 EnterNotifyEvent(const unsigned char *buf)
442 {
443 PrintField(buf, 0, 1, EVENT, EVENTHEADER); /* EnterNotify */
444 if (Verbose < 1)
445 return;
446 PrintField(buf, 1, 1, ENTERDETAIL, "detail");
447 printfield(buf, 2, 2, CARD16, "sequence number");
448 PrintField(buf, 4, 4, TIMESTAMP, "time");
449 PrintField(buf, 8, 4, WINDOW, "root");
450 PrintField(buf, 12, 4, WINDOW, "event");
451 PrintField(buf, 16, 4, WINDOW, "child");
452 PrintField(buf, 20, 2, INT16, "root-x");
453 PrintField(buf, 22, 2, INT16, "root-y");
454 PrintField(buf, 24, 2, INT16, "event-x");
455 PrintField(buf, 26, 2, INT16, "event-y");
456 PrintField(buf, 28, 2, SETofKEYBUTMASK, "state");
457 PrintField(buf, 30, 1, BUTTONMODE, "mode");
458 PrintField(buf, 31, 1, SCREENFOCUS, "same-screen, focus");
459 }
460
461 void
LeaveNotifyEvent(const unsigned char * buf)462 LeaveNotifyEvent(const unsigned char *buf)
463 {
464 PrintField(buf, 0, 1, EVENT, EVENTHEADER); /* LeaveNotify */
465 if (Verbose < 1)
466 return;
467 PrintField(buf, 1, 1, ENTERDETAIL, "detail");
468 printfield(buf, 2, 2, CARD16, "sequence number");
469 PrintField(buf, 4, 4, TIMESTAMP, "time");
470 PrintField(buf, 8, 4, WINDOW, "root");
471 PrintField(buf, 12, 4, WINDOW, "event");
472 PrintField(buf, 16, 4, WINDOW, "child");
473 PrintField(buf, 20, 2, INT16, "root-x");
474 PrintField(buf, 22, 2, INT16, "root-y");
475 PrintField(buf, 24, 2, INT16, "event-x");
476 PrintField(buf, 26, 2, INT16, "event-y");
477 PrintField(buf, 28, 2, SETofKEYBUTMASK, "state");
478 PrintField(buf, 30, 1, BUTTONMODE, "mode");
479 PrintField(buf, 31, 1, SCREENFOCUS, "same-screen, focus");
480 }
481
482 void
FocusInEvent(const unsigned char * buf)483 FocusInEvent(const unsigned char *buf)
484 {
485 PrintField(buf, 0, 1, EVENT, EVENTHEADER); /* FocusIn */
486 if (Verbose < 1)
487 return;
488 PrintField(buf, 1, 1, ENTERDETAIL, "detail");
489 printfield(buf, 2, 2, CARD16, "sequence number");
490 PrintField(buf, 4, 4, WINDOW, "event");
491 PrintField(buf, 8, 1, BUTTONMODE, "mode");
492 }
493
494 void
FocusOutEvent(const unsigned char * buf)495 FocusOutEvent(const unsigned char *buf)
496 {
497 PrintField(buf, 0, 1, EVENT, EVENTHEADER); /* FocusOut */
498 if (Verbose < 1)
499 return;
500 PrintField(buf, 1, 1, ENTERDETAIL, "detail");
501 printfield(buf, 2, 2, CARD16, "sequence number");
502 PrintField(buf, 4, 4, WINDOW, "event");
503 PrintField(buf, 8, 1, BUTTONMODE, "mode");
504 }
505
506 void
KeymapNotifyEvent(const unsigned char * buf)507 KeymapNotifyEvent(const unsigned char *buf)
508 {
509 PrintField(buf, 0, 1, EVENT, EVENTHEADER); /* KeymapNotify */
510 if (Verbose < 1)
511 return;
512 PrintBytes(&buf[1], (long) 31, "keys");
513 }
514
515 void
ExposeEvent(const unsigned char * buf)516 ExposeEvent(const unsigned char *buf)
517 {
518 PrintField(buf, 0, 1, EVENT, EVENTHEADER); /* Expose */
519 if (Verbose < 1)
520 return;
521 printfield(buf, 2, 2, CARD16, "sequence number");
522 PrintField(buf, 4, 4, WINDOW, "window");
523 PrintField(buf, 8, 2, CARD16, "x");
524 PrintField(buf, 10, 2, CARD16, "y");
525 PrintField(buf, 12, 2, CARD16, "width");
526 PrintField(buf, 14, 2, CARD16, "height");
527 PrintField(buf, 16, 2, CARD16, "count");
528 }
529
530 void
GraphicsExposureEvent(const unsigned char * buf)531 GraphicsExposureEvent(const unsigned char *buf)
532 {
533 PrintField(buf, 0, 1, EVENT, EVENTHEADER); /* GraphicsExposure */
534 if (Verbose < 1)
535 return;
536 printfield(buf, 2, 2, CARD16, "sequence number");
537 PrintField(buf, 4, 4, DRAWABLE, "drawable");
538 PrintField(buf, 8, 2, CARD16, "x");
539 PrintField(buf, 10, 2, CARD16, "y");
540 PrintField(buf, 12, 2, CARD16, "width");
541 PrintField(buf, 14, 2, CARD16, "height");
542 PrintField(buf, 16, 2, CARD16, "minor-opcode");
543 PrintField(buf, 18, 2, CARD16, "count");
544 PrintField(buf, 20, 1, CARD8, "major-opcode");
545 }
546
547 void
NoExposureEvent(const unsigned char * buf)548 NoExposureEvent(const unsigned char *buf)
549 {
550 PrintField(buf, 0, 1, EVENT, EVENTHEADER); /* NoExposure */
551 if (Verbose < 1)
552 return;
553 printfield(buf, 2, 2, CARD16, "sequence number");
554 PrintField(buf, 4, 4, DRAWABLE, "drawable");
555 PrintField(buf, 8, 2, CARD16, "minor-opcode");
556 PrintField(buf, 10, 1, CARD8, "major-opcode");
557 }
558
559 void
VisibilityNotifyEvent(const unsigned char * buf)560 VisibilityNotifyEvent(const unsigned char *buf)
561 {
562 PrintField(buf, 0, 1, EVENT, EVENTHEADER); /* VisibilityNotify */
563 if (Verbose < 1)
564 return;
565 printfield(buf, 2, 2, CARD16, "sequence number");
566 PrintField(buf, 4, 4, WINDOW, "window");
567 PrintField(buf, 8, 1, VISIBLE, "state");
568 }
569
570 void
CreateNotifyEvent(const unsigned char * buf)571 CreateNotifyEvent(const unsigned char *buf)
572 {
573 PrintField(buf, 0, 1, EVENT, EVENTHEADER); /* CreateNotify */
574 if (Verbose < 1)
575 return;
576 printfield(buf, 2, 2, CARD16, "sequence number");
577 PrintField(buf, 4, 4, WINDOW, "parent");
578 PrintField(buf, 8, 4, WINDOW, "window");
579 PrintField(buf, 12, 2, INT16, "x");
580 PrintField(buf, 14, 2, INT16, "y");
581 PrintField(buf, 16, 2, CARD16, "width");
582 PrintField(buf, 18, 2, CARD16, "height");
583 PrintField(buf, 20, 2, CARD16, "border-width");
584 PrintField(buf, 22, 1, BOOL, "override-redirect");
585 }
586
587 void
DestroyNotifyEvent(const unsigned char * buf)588 DestroyNotifyEvent(const unsigned char *buf)
589 {
590 PrintField(buf, 0, 1, EVENT, EVENTHEADER); /* DestroyNotify */
591 if (Verbose < 1)
592 return;
593 printfield(buf, 2, 2, CARD16, "sequence number");
594 PrintField(buf, 4, 4, WINDOW, "event");
595 PrintField(buf, 8, 4, WINDOW, "window");
596 }
597
598 void
UnmapNotifyEvent(const unsigned char * buf)599 UnmapNotifyEvent(const unsigned char *buf)
600 {
601 PrintField(buf, 0, 1, EVENT, EVENTHEADER); /* UnmapNotify */
602 if (Verbose < 1)
603 return;
604 printfield(buf, 2, 2, CARD16, "sequence number");
605 PrintField(buf, 4, 4, WINDOW, "event");
606 PrintField(buf, 8, 4, WINDOW, "window");
607 PrintField(buf, 12, 1, BOOL, "from-configure");
608 }
609
610 void
MapNotifyEvent(const unsigned char * buf)611 MapNotifyEvent(const unsigned char *buf)
612 {
613 PrintField(buf, 0, 1, EVENT, EVENTHEADER); /* MapNotify */
614 if (Verbose < 1)
615 return;
616 printfield(buf, 2, 2, CARD16, "sequence number");
617 PrintField(buf, 4, 4, WINDOW, "event");
618 PrintField(buf, 8, 4, WINDOW, "window");
619 PrintField(buf, 12, 1, BOOL, "override-redirect");
620 }
621
622 void
MapRequestEvent(const unsigned char * buf)623 MapRequestEvent(const unsigned char *buf)
624 {
625 PrintField(buf, 0, 1, EVENT, EVENTHEADER); /* MapRequest */
626 if (Verbose < 1)
627 return;
628 printfield(buf, 2, 2, CARD16, "sequence number");
629 PrintField(buf, 4, 4, WINDOW, "parent");
630 PrintField(buf, 8, 4, WINDOW, "window");
631 }
632
633 void
ReparentNotifyEvent(const unsigned char * buf)634 ReparentNotifyEvent(const unsigned char *buf)
635 {
636 PrintField(buf, 0, 1, EVENT, EVENTHEADER); /* ReparentNotify */
637 if (Verbose < 1)
638 return;
639 printfield(buf, 2, 2, CARD16, "sequence number");
640 PrintField(buf, 4, 4, WINDOW, "event");
641 PrintField(buf, 8, 4, WINDOW, "window");
642 PrintField(buf, 12, 4, WINDOW, "parent");
643 PrintField(buf, 16, 2, INT16, "x");
644 PrintField(buf, 18, 2, INT16, "y");
645 PrintField(buf, 20, 1, BOOL, "override-redirect");
646 }
647
648 void
ConfigureNotifyEvent(const unsigned char * buf)649 ConfigureNotifyEvent(const unsigned char *buf)
650 {
651 PrintField(buf, 0, 1, EVENT, EVENTHEADER); /* ConfigureNotify */
652 if (Verbose < 1)
653 return;
654 printfield(buf, 2, 2, CARD16, "sequence number");
655 PrintField(buf, 4, 4, WINDOW, "event");
656 PrintField(buf, 8, 4, WINDOW, "window");
657 PrintField(buf, 12, 4, WINDOW, "above-sibling");
658 PrintField(buf, 16, 2, INT16, "x");
659 PrintField(buf, 18, 2, INT16, "y");
660 PrintField(buf, 20, 2, CARD16, "width");
661 PrintField(buf, 22, 2, CARD16, "height");
662 PrintField(buf, 24, 2, CARD16, "border-width");
663 PrintField(buf, 26, 1, BOOL, "override-redirect");
664 }
665
666 void
ConfigureRequestEvent(const unsigned char * buf)667 ConfigureRequestEvent(const unsigned char *buf)
668 {
669 PrintField(buf, 0, 1, EVENT, EVENTHEADER); /* ConfigureRequest */
670 if (Verbose < 1)
671 return;
672 PrintField(buf, 1, 1, STACKMODE, "stack-mode");
673 printfield(buf, 2, 2, CARD16, "sequence number");
674 PrintField(buf, 4, 4, WINDOW, "parent");
675 PrintField(buf, 8, 4, WINDOW, "window");
676 PrintField(buf, 12, 4, WINDOW, "sibling");
677 PrintField(buf, 16, 2, INT16, "x");
678 PrintField(buf, 18, 2, INT16, "y");
679 PrintField(buf, 20, 2, CARD16, "width");
680 PrintField(buf, 22, 2, CARD16, "height");
681 PrintField(buf, 24, 2, CARD16, "border-width");
682 PrintField(buf, 26, 2, CONFIGURE_BITMASK, "value-mask");
683 }
684
685 void
GravityNotifyEvent(const unsigned char * buf)686 GravityNotifyEvent(const unsigned char *buf)
687 {
688 PrintField(buf, 0, 1, EVENT, EVENTHEADER); /* GravityNotify */
689 if (Verbose < 1)
690 return;
691 printfield(buf, 2, 2, CARD16, "sequence number");
692 PrintField(buf, 4, 4, WINDOW, "event");
693 PrintField(buf, 8, 4, WINDOW, "window");
694 PrintField(buf, 12, 2, INT16, "x");
695 PrintField(buf, 14, 2, INT16, "y");
696 }
697
698 void
ResizeRequestEvent(const unsigned char * buf)699 ResizeRequestEvent(const unsigned char *buf)
700 {
701 PrintField(buf, 0, 1, EVENT, EVENTHEADER); /* ResizeRequest */
702 if (Verbose < 1)
703 return;
704 printfield(buf, 2, 2, CARD16, "sequence number");
705 PrintField(buf, 4, 4, WINDOW, "window");
706 PrintField(buf, 8, 2, CARD16, "width");
707 PrintField(buf, 10, 2, CARD16, "height");
708 }
709
710 void
CirculateNotifyEvent(const unsigned char * buf)711 CirculateNotifyEvent(const unsigned char *buf)
712 {
713 PrintField(buf, 0, 1, EVENT, EVENTHEADER); /* CirculateNotify */
714 if (Verbose < 1)
715 return;
716 printfield(buf, 2, 2, CARD16, "sequence number");
717 PrintField(buf, 4, 4, WINDOW, "event");
718 PrintField(buf, 8, 4, WINDOW, "window");
719 PrintField(buf, 12, 4, WINDOW, "parent");
720 PrintField(buf, 16, 1, CIRSTAT, "place");
721 }
722
723 void
CirculateRequestEvent(const unsigned char * buf)724 CirculateRequestEvent(const unsigned char *buf)
725 {
726 PrintField(buf, 0, 1, EVENT, EVENTHEADER); /* CirculateRequest */
727 if (Verbose < 1)
728 return;
729 printfield(buf, 2, 2, CARD16, "sequence number");
730 PrintField(buf, 4, 4, WINDOW, "parent");
731 PrintField(buf, 8, 4, WINDOW, "window");
732 PrintField(buf, 16, 1, CIRSTAT, "place");
733 }
734
735 void
PropertyNotifyEvent(const unsigned char * buf)736 PropertyNotifyEvent(const unsigned char *buf)
737 {
738 PrintField(buf, 0, 1, EVENT, EVENTHEADER); /* PropertyNotify */
739 if (Verbose < 1)
740 return;
741 printfield(buf, 2, 2, CARD16, "sequence number");
742 PrintField(buf, 4, 4, WINDOW, "window");
743 PrintField(buf, 8, 4, ATOM, "atom");
744 PrintField(buf, 12, 4, TIMESTAMP, "time");
745 PrintField(buf, 16, 1, PROPCHANGE, "state");
746 }
747
748 void
SelectionClearEvent(const unsigned char * buf)749 SelectionClearEvent(const unsigned char *buf)
750 {
751 PrintField(buf, 0, 1, EVENT, EVENTHEADER); /* SelectionClear */
752 if (Verbose < 1)
753 return;
754 printfield(buf, 2, 2, CARD16, "sequence number");
755 PrintField(buf, 4, 4, TIMESTAMP, "time");
756 PrintField(buf, 8, 4, WINDOW, "owner");
757 PrintField(buf, 12, 4, ATOM, "selection");
758 }
759
760 void
SelectionRequestEvent(const unsigned char * buf)761 SelectionRequestEvent(const unsigned char *buf)
762 {
763 PrintField(buf, 0, 1, EVENT, EVENTHEADER); /* SelectionRequest */
764 if (Verbose < 1)
765 return;
766 printfield(buf, 2, 2, CARD16, "sequence number");
767 PrintField(buf, 4, 4, TIMESTAMP, "time");
768 PrintField(buf, 8, 4, WINDOW, "owner");
769 PrintField(buf, 12, 4, WINDOW, "requestor");
770 PrintField(buf, 16, 4, ATOM, "selection");
771 PrintField(buf, 20, 4, ATOM, "target");
772 PrintField(buf, 24, 4, ATOM, "property");
773 }
774
775 void
SelectionNotifyEvent(const unsigned char * buf)776 SelectionNotifyEvent(const unsigned char *buf)
777 {
778 PrintField(buf, 0, 1, EVENT, EVENTHEADER); /* SelectionNotify */
779 if (Verbose < 1)
780 return;
781 printfield(buf, 2, 2, CARD16, "sequence number");
782 PrintField(buf, 4, 4, TIMESTAMP, "time");
783 PrintField(buf, 8, 4, WINDOW, "requestor");
784 PrintField(buf, 12, 4, ATOM, "selection");
785 PrintField(buf, 16, 4, ATOM, "target");
786 PrintField(buf, 20, 4, ATOM, "property");
787 }
788
789 void
ColormapNotifyEvent(const unsigned char * buf)790 ColormapNotifyEvent(const unsigned char *buf)
791 {
792 PrintField(buf, 0, 1, EVENT, EVENTHEADER); /* ColormapNotify */
793 if (Verbose < 1)
794 return;
795 printfield(buf, 2, 2, CARD16, "sequence number");
796 PrintField(buf, 4, 4, WINDOW, "window");
797 PrintField(buf, 8, 4, COLORMAP, "colormap");
798 PrintField(buf, 12, 1, BOOL, "new");
799 PrintField(buf, 13, 1, CMAPCHANGE, "state");
800 }
801
802 void
ClientMessageEvent(const unsigned char * buf)803 ClientMessageEvent(const unsigned char *buf)
804 {
805 PrintField(buf, 0, 1, EVENT, EVENTHEADER); /* ClientMessage */
806 if (Verbose < 1)
807 return;
808 PrintField(buf, 1, 1, CARD8, "format");
809 printfield(buf, 2, 2, CARD16, "sequence number");
810 PrintField(buf, 4, 4, WINDOW, "window");
811 PrintField(buf, 8, 4, ATOM, "type");
812 PrintBytes(&buf[12], (long) 20, "data");
813 }
814
815 void
MappingNotifyEvent(const unsigned char * buf)816 MappingNotifyEvent(const unsigned char *buf)
817 {
818 PrintField(buf, 0, 1, EVENT, EVENTHEADER); /* MappingNotify */
819 if (Verbose < 1)
820 return;
821 printfield(buf, 2, 2, CARD16, "sequence number");
822 PrintField(buf, 4, 1, MAPOBJECT, "request");
823 PrintField(buf, 5, 1, KEYCODE, "first-keycode");
824 PrintField(buf, 6, 1, CARD8, "count");
825 }
826
827 void
UnknownGenericEvent(const unsigned char * buf)828 UnknownGenericEvent(const unsigned char *buf)
829 {
830 long n;
831
832 PrintField(buf, 0, 1, EVENT, EVENTHEADER); /* GenericEvent */
833 if (Verbose < 1)
834 return;
835 PrintField(buf, 1, 1, EXTENSION, "extension");
836 printfield(buf, 2, 2, CARD16, "sequence number");
837 printfield(buf, 4, 4, DVALUE4(n), "event length");
838 PrintField(buf, 8, 2, CARD16, "event type");
839
840 n = ILong(&buf[4]) + 5;
841 (void) PrintList(&buf[12], n, CARD32, "data");
842 }
843
844 void
UnknownEvent(const unsigned char * buf)845 UnknownEvent(const unsigned char *buf)
846 {
847 PrintField(buf, 0, 1, EVENT, EVENTHEADER);
848 if (Verbose < 1)
849 return;
850 PrintField(buf, 1, 1, CARD8, "detail");
851 printfield(buf, 2, 2, CARD16, "sequence number");
852 PrintBytes(&buf[4], 28, "data");
853 }
854
855 /* ************************************************************ */
856 /* */
857 /* */
858 /* ************************************************************ */
859
860 /* Request and Reply Printing procedures */
861
862 void
ExtendedRequest(int fd,const unsigned char * buf)863 ExtendedRequest(int fd, const unsigned char *buf)
864 {
865 short n;
866
867 PrintField(buf, 0, 1, REQUEST, REQUESTHEADER);
868 if (Verbose < 1)
869 return;
870 if (Verbose > 1)
871 PrintField(SBf, 0, 4, CARD32, "sequence number");
872
873 PrintField(buf, 1, 1, CARD8, "minor opcode");
874 printreqlen(buf, fd, DVALUE2(n - 1));
875
876 n = CS[fd].requestLen - 1;
877 (void) PrintList(&buf[4], n, CARD32, "data");
878 }
879
880 void
UnknownReply(const unsigned char * buf)881 UnknownReply(const unsigned char *buf)
882 {
883 long n;
884
885 PrintField(RBf, 0, 1, REPLY, REPLYHEADER);
886 if (Verbose < 1)
887 return;
888 PrintField(buf, 1, 1, CARD8, "data");
889 printfield(buf, 2, 2, CARD16, "sequence number");
890 printfield(buf, 4, 4, DVALUE4(n), "reply length");
891 n = ILong(&buf[4]) + 6;
892 (void) PrintList(&buf[8], n, CARD32, "data");
893 }
894
895 void
CreateWindow(FD fd,const unsigned char * buf)896 CreateWindow(FD fd, const unsigned char *buf)
897 {
898 /* Request CreateWindow is opcode 1 */
899 PrintField(buf, 0, 1, REQUEST, REQUESTHEADER); /* CreateWindow */
900 if (Verbose < 1)
901 return;
902 if (Verbose > 1)
903 PrintField(SBf, 0, 4, CARD32, "sequence number");
904
905 PrintField(buf, 1, 1, CARD8, "depth");
906 printreqlen(buf, fd, DVALUE2(8 + n));
907 PrintField(buf, 4, 4, WINDOW, "wid");
908 PrintField(buf, 8, 4, WINDOW, "parent");
909 PrintField(buf, 12, 2, INT16, "x");
910 PrintField(buf, 14, 2, INT16, "y");
911 PrintField(buf, 16, 2, CARD16, "width");
912 PrintField(buf, 18, 2, CARD16, "height");
913 PrintField(buf, 20, 2, CARD16, "border-width");
914 PrintField(buf, 22, 2, WINDOWCLASS, "class");
915 PrintField(buf, 24, 4, VISUALIDC, "visual");
916 PrintField(buf, 28, 4, WINDOW_BITMASK, "value-mask");
917 PrintValues(&buf[28], 4, WINDOW_BITMASK, &buf[32], "value-list");
918 }
919
920 void
ChangeWindowAttributes(FD fd,const unsigned char * buf)921 ChangeWindowAttributes(FD fd, const unsigned char *buf)
922 {
923 /* Request ChangeWindowAttributes is opcode 2 */
924 PrintField(buf, 0, 1, REQUEST, REQUESTHEADER); /* ChangeWindowAttributes */
925 if (Verbose < 1)
926 return;
927 if (Verbose > 1)
928 PrintField(SBf, 0, 4, CARD32, "sequence number");
929
930 printreqlen(buf, fd, DVALUE2(3 + n));
931 PrintField(buf, 4, 4, WINDOW, "window");
932 PrintField(buf, 8, 4, WINDOW_BITMASK, "value-mask");
933 PrintValues(&buf[8], 4, WINDOW_BITMASK, &buf[12], "value-list");
934 }
935
936 void
GetWindowAttributes(FD fd,const unsigned char * buf)937 GetWindowAttributes(FD fd, const unsigned char *buf)
938 {
939 /* Request GetWindowAttributes is opcode 3 */
940 PrintField(buf, 0, 1, REQUEST, REQUESTHEADER); /* GetWindowAttributes */
941 if (Verbose < 1)
942 return;
943 if (Verbose > 1)
944 PrintField(SBf, 0, 4, CARD32, "sequence number");
945
946 printreqlen(buf, fd, CONST2(2));
947 PrintField(buf, 4, 4, WINDOW, "window");
948 }
949
950 void
GetWindowAttributesReply(const unsigned char * buf)951 GetWindowAttributesReply(const unsigned char *buf)
952 {
953 PrintField(RBf, 0, 1, REPLY, REPLYHEADER); /* GetWindowAttributes */
954 if (Verbose < 1)
955 return;
956 PrintField(buf, 1, 1, BACKSTORE, "backing-store");
957 printfield(buf, 2, 2, CARD16, "sequence number");
958 printfield(buf, 4, 4, CONST4(3), "reply length");
959 PrintField(buf, 8, 4, VISUALID, "visual");
960 PrintField(buf, 12, 2, WINDOWCLASS, "class");
961 PrintField(buf, 14, 1, BITGRAVITY, "bit-gravity");
962 PrintField(buf, 15, 1, WINGRAVITY, "win-gravity");
963 PrintField(buf, 16, 4, CARD32, "backing-planes");
964 PrintField(buf, 20, 4, CARD32, "backing-pixel");
965 PrintField(buf, 24, 1, BOOL, "save-under");
966 PrintField(buf, 25, 1, BOOL, "map-is-installed");
967 PrintField(buf, 26, 1, MAPSTATE, "map-state");
968 PrintField(buf, 27, 1, BOOL, "override-redirect");
969 PrintField(buf, 28, 4, COLORMAP, "colormap");
970 PrintField(buf, 32, 4, SETofEVENT, "all-event-masks");
971 PrintField(buf, 36, 4, SETofEVENT, "your-event-mask");
972 PrintField(buf, 40, 2, SETofDEVICEEVENT, "do-not-propagate-mask");
973 }
974
975 void
DestroyWindow(FD fd,const unsigned char * buf)976 DestroyWindow(FD fd, const unsigned char *buf)
977 {
978 /* Request DestroyWindow is opcode 4 */
979 PrintField(buf, 0, 1, REQUEST, REQUESTHEADER); /* DestroyWindow */
980 if (Verbose < 1)
981 return;
982 if (Verbose > 1)
983 PrintField(SBf, 0, 4, CARD32, "sequence number");
984
985 printreqlen(buf, fd, CONST2(2));
986 PrintField(buf, 4, 4, WINDOW, "window");
987 }
988
989 void
DestroySubwindows(FD fd,const unsigned char * buf)990 DestroySubwindows(FD fd, const unsigned char *buf)
991 {
992 /* Request DestroySubwindows is opcode 5 */
993 PrintField(buf, 0, 1, REQUEST, REQUESTHEADER); /* DestroySubwindows */
994 if (Verbose < 1)
995 return;
996 if (Verbose > 1)
997 PrintField(SBf, 0, 4, CARD32, "sequence number");
998
999 printreqlen(buf, fd, CONST2(2));
1000 PrintField(buf, 4, 4, WINDOW, "window");
1001 }
1002
1003 void
ChangeSaveSet(FD fd,const unsigned char * buf)1004 ChangeSaveSet(FD fd, const unsigned char *buf)
1005 {
1006 /* Request ChangeSaveSet is opcode 6 */
1007 PrintField(buf, 0, 1, REQUEST, REQUESTHEADER); /* ChangeSaveSet */
1008 if (Verbose < 1)
1009 return;
1010 if (Verbose > 1)
1011 PrintField(SBf, 0, 4, CARD32, "sequence number");
1012
1013 PrintField(buf, 1, 1, INS_DEL, "mode");
1014 printreqlen(buf, fd, CONST2(2));
1015 PrintField(buf, 4, 4, WINDOW, "window");
1016 }
1017
1018 void
ReparentWindow(FD fd,const unsigned char * buf)1019 ReparentWindow(FD fd, const unsigned char *buf)
1020 {
1021 /* Request ReparentWindow is opcode 7 */
1022 PrintField(buf, 0, 1, REQUEST, REQUESTHEADER); /* ReparentWindow */
1023 if (Verbose < 1)
1024 return;
1025 if (Verbose > 1)
1026 PrintField(SBf, 0, 4, CARD32, "sequence number");
1027
1028 printreqlen(buf, fd, CONST2(4));
1029 PrintField(buf, 4, 4, WINDOW, "window");
1030 PrintField(buf, 8, 4, WINDOW, "parent");
1031 PrintField(buf, 12, 2, INT16, "x");
1032 PrintField(buf, 14, 2, INT16, "y");
1033 }
1034
1035 void
MapWindow(FD fd,const unsigned char * buf)1036 MapWindow(FD fd, const unsigned char *buf)
1037 {
1038 /* Request MapWindow is opcode 8 */
1039 PrintField(buf, 0, 1, REQUEST, REQUESTHEADER); /* MapWindow */
1040 if (Verbose < 1)
1041 return;
1042 if (Verbose > 1)
1043 PrintField(SBf, 0, 4, CARD32, "sequence number");
1044
1045 printreqlen(buf, fd, CONST2(2));
1046 PrintField(buf, 4, 4, WINDOW, "window");
1047 }
1048
1049 void
MapSubwindows(FD fd,const unsigned char * buf)1050 MapSubwindows(FD fd, const unsigned char *buf)
1051 {
1052 /* Request MapSubwindows is opcode 9 */
1053 PrintField(buf, 0, 1, REQUEST, REQUESTHEADER); /* MapSubwindows */
1054 if (Verbose < 1)
1055 return;
1056 if (Verbose > 1)
1057 PrintField(SBf, 0, 4, CARD32, "sequence number");
1058
1059 printreqlen(buf, fd, CONST2(2));
1060 PrintField(buf, 4, 4, WINDOW, "window");
1061 }
1062
1063 void
UnmapWindow(FD fd,const unsigned char * buf)1064 UnmapWindow(FD fd, const unsigned char *buf)
1065 {
1066 /* Request UnmapWindow is opcode 10 */
1067 PrintField(buf, 0, 1, REQUEST, REQUESTHEADER); /* UnmapWindow */
1068 if (Verbose < 1)
1069 return;
1070 if (Verbose > 1)
1071 PrintField(SBf, 0, 4, CARD32, "sequence number");
1072
1073 printreqlen(buf, fd, CONST2(2));
1074 PrintField(buf, 4, 4, WINDOW, "window");
1075 }
1076
1077 void
UnmapSubwindows(FD fd,const unsigned char * buf)1078 UnmapSubwindows(FD fd, const unsigned char *buf)
1079 {
1080 /* Request UnmapSubwindows is opcode 11 */
1081 PrintField(buf, 0, 1, REQUEST, REQUESTHEADER); /* UnmapSubwindows */
1082 if (Verbose < 1)
1083 return;
1084 if (Verbose > 1)
1085 PrintField(SBf, 0, 4, CARD32, "sequence number");
1086
1087 printreqlen(buf, fd, CONST2(2));
1088 PrintField(buf, 4, 4, WINDOW, "window");
1089 }
1090
1091 void
ConfigureWindow(FD fd,const unsigned char * buf)1092 ConfigureWindow(FD fd, const unsigned char *buf)
1093 {
1094 /* Request ConfigureWindow is opcode 12 */
1095 PrintField(buf, 0, 1, REQUEST, REQUESTHEADER); /* ConfigureWindow */
1096 if (Verbose < 1)
1097 return;
1098 if (Verbose > 1)
1099 PrintField(SBf, 0, 4, CARD32, "sequence number");
1100
1101 printreqlen(buf, fd, DVALUE2(3 + n));
1102 PrintField(buf, 4, 4, WINDOW, "window");
1103 PrintField(buf, 8, 2, CONFIGURE_BITMASK, "value-mask");
1104 PrintValues(&buf[8], 2, CONFIGURE_BITMASK, &buf[12], "value-list");
1105 }
1106
1107 void
CirculateWindow(FD fd,const unsigned char * buf)1108 CirculateWindow(FD fd, const unsigned char *buf)
1109 {
1110 /* Request CirculateWindow is opcode 13 */
1111 PrintField(buf, 0, 1, REQUEST, REQUESTHEADER); /* CirculateWindow */
1112 if (Verbose < 1)
1113 return;
1114 if (Verbose > 1)
1115 PrintField(SBf, 0, 4, CARD32, "sequence number");
1116
1117 PrintField(buf, 1, 1, CIRMODE, "direction");
1118 printreqlen(buf, fd, CONST2(2));
1119 PrintField(buf, 4, 4, WINDOW, "window");
1120 }
1121
1122 void
GetGeometry(FD fd,const unsigned char * buf)1123 GetGeometry(FD fd, const unsigned char *buf)
1124 {
1125 /* Request GetGeometry is opcode 14 */
1126 PrintField(buf, 0, 1, REQUEST, REQUESTHEADER); /* GetGeometry */
1127 if (Verbose < 1)
1128 return;
1129 if (Verbose > 1)
1130 PrintField(SBf, 0, 4, CARD32, "sequence number");
1131
1132 printreqlen(buf, fd, CONST2(2));
1133 PrintField(buf, 4, 4, DRAWABLE, "drawable");
1134 }
1135
1136 void
GetGeometryReply(const unsigned char * buf)1137 GetGeometryReply(const unsigned char *buf)
1138 {
1139 PrintField(RBf, 0, 1, REPLY, REPLYHEADER); /* GetGeometry */
1140 if (Verbose < 1)
1141 return;
1142 PrintField(buf, 1, 1, CARD8, "depth");
1143 printfield(buf, 2, 2, CARD16, "sequence number");
1144 printfield(buf, 4, 4, CONST4(0), "reply length");
1145 PrintField(buf, 8, 4, WINDOW, "root");
1146 PrintField(buf, 12, 2, INT16, "x");
1147 PrintField(buf, 14, 2, INT16, "y");
1148 PrintField(buf, 16, 2, CARD16, "width");
1149 PrintField(buf, 18, 2, CARD16, "height");
1150 PrintField(buf, 20, 2, CARD16, "border-width");
1151 }
1152
1153 void
QueryTree(FD fd,const unsigned char * buf)1154 QueryTree(FD fd, const unsigned char *buf)
1155 {
1156 /* Request QueryTree is opcode 15 */
1157 PrintField(buf, 0, 1, REQUEST, REQUESTHEADER); /* QueryTree */
1158 if (Verbose < 1)
1159 return;
1160 if (Verbose > 1)
1161 PrintField(SBf, 0, 4, CARD32, "sequence number");
1162
1163 printreqlen(buf, fd, CONST2(2));
1164 PrintField(buf, 4, 4, WINDOW, "window");
1165 }
1166
1167 void
QueryTreeReply(const unsigned char * buf)1168 QueryTreeReply(const unsigned char *buf)
1169 {
1170 short n;
1171
1172 PrintField(RBf, 0, 1, REPLY, REPLYHEADER); /* QueryTree */
1173 if (Verbose < 1)
1174 return;
1175 printfield(buf, 2, 2, CARD16, "sequence number");
1176 printfield(buf, 4, 4, DVALUE4(n), "reply length");
1177 PrintField(buf, 8, 4, WINDOW, "root");
1178 PrintField(buf, 12, 4, WINDOW, "parent");
1179 printfield(buf, 16, 2, DVALUE2(n), "number of children");
1180 n = IShort(&buf[16]);
1181 PrintList(&buf[32], (long) n, WINDOW, "children");
1182 }
1183
1184 /* Keep track of InternAtom & GetAtomName requests so we can add them to
1185 our tables */
1186 struct atomic_req {
1187 uint32_t seq;
1188 uint32_t atom;
1189 char *name;
1190 struct atomic_req *next;
1191 };
1192
1193 static struct atomic_req *pending_atom_reqs;
1194
1195 static void
start_atom_request(uint32_t atom,char * name)1196 start_atom_request(uint32_t atom, char *name)
1197 {
1198 struct atomic_req *new_ar = malloc(sizeof(struct atomic_req));
1199
1200 if (new_ar) {
1201 new_ar->seq = ILong(SBf);
1202 new_ar->atom = atom;
1203 new_ar->name = name;
1204 new_ar->next = NULL;
1205
1206 if (pending_atom_reqs == NULL)
1207 pending_atom_reqs = new_ar;
1208 else {
1209 struct atomic_req *ar;
1210 for (ar = pending_atom_reqs; ar->next != NULL; ar = ar->next) {
1211 /* find list tail */
1212 }
1213 ar->next = new_ar;
1214 }
1215 }
1216 }
1217
1218 static void
finish_atom_request(uint32_t seq,uint32_t atom,char * name)1219 finish_atom_request(uint32_t seq, uint32_t atom, char *name)
1220 {
1221 struct atomic_req *ar, *par, *next;
1222
1223 for (ar = pending_atom_reqs, par = NULL; ar != NULL; ar = next) {
1224 next = ar->next;
1225 if (ar->seq == seq) {
1226 if (ar->atom == 0)
1227 ar->atom = atom;
1228 if (ar->name == NULL)
1229 ar->name = name;
1230 DefineAtom(ar->atom, ar->name);
1231 free(ar->name); /* DefineAtom makes a copy if needed */
1232 free(ar);
1233 if (par == NULL)
1234 pending_atom_reqs = next;
1235 else
1236 par->next = next;
1237 }
1238 else
1239 par = ar;
1240 }
1241 }
1242
1243 void
InternAtom(FD fd,const unsigned char * buf)1244 InternAtom(FD fd, const unsigned char *buf)
1245 {
1246 short n;
1247
1248 /* Request InternAtom is opcode 16 */
1249 PrintField(buf, 0, 1, REQUEST, REQUESTHEADER); /* InternAtom */
1250 if (Verbose < 1)
1251 return;
1252 if (Verbose > 1)
1253 PrintField(SBf, 0, 4, CARD32, "sequence number");
1254
1255 PrintField(buf, 1, 1, BOOL, "only-if-exists");
1256 printreqlen(buf, fd, DVALUE2(2 + (n + p) / 4));
1257 printfield(buf, 4, 2, DVALUE2(n), "length of name");
1258 n = IShort(&buf[4]);
1259 PrintString8(&buf[8], n, "name");
1260
1261 if (n > 0) {
1262 char *name = malloc(n + 1);
1263 if (name != NULL) {
1264 memcpy(name, buf + 8, n);
1265 name[n] = 0;
1266 start_atom_request(0, name);
1267 }
1268 }
1269 }
1270
1271 void
InternAtomReply(const unsigned char * buf)1272 InternAtomReply(const unsigned char *buf)
1273 {
1274 uint32_t seq, atom;
1275
1276 PrintField(RBf, 0, 1, REPLY, REPLYHEADER); /* InternAtom */
1277 if (Verbose < 1)
1278 return;
1279 printfield(buf, 2, 2, CARD16, "sequence number");
1280 printfield(buf, 4, 4, CONST4(0), "reply length");
1281 PrintField(buf, 8, 4, ATOM, "atom");
1282
1283 seq = IShort(&buf[2]);
1284 atom = ILong(&buf[8]);
1285 finish_atom_request(seq, atom, NULL);
1286 }
1287
1288 void
GetAtomName(FD fd,const unsigned char * buf)1289 GetAtomName(FD fd, const unsigned char *buf)
1290 {
1291 uint32_t atom;
1292
1293 /* Request GetAtomName is opcode 17 */
1294 PrintField(buf, 0, 1, REQUEST, REQUESTHEADER); /* GetAtomName */
1295 if (Verbose < 1)
1296 return;
1297 if (Verbose > 1)
1298 PrintField(SBf, 0, 4, CARD32, "sequence number");
1299
1300 printreqlen(buf, fd, CONST2(2));
1301 PrintField(buf, 4, 4, ATOM, "atom");
1302
1303 atom = ILong(&buf[4]);
1304 start_atom_request(atom, NULL);
1305 }
1306
1307 void
GetAtomNameReply(const unsigned char * buf)1308 GetAtomNameReply(const unsigned char *buf)
1309 {
1310 short n;
1311 uint32_t seq;
1312 char *name;
1313
1314 PrintField(RBf, 0, 1, REPLY, REPLYHEADER); /* GetAtomName */
1315 if (Verbose < 1)
1316 return;
1317 printfield(buf, 2, 2, CARD16, "sequence number");
1318 printfield(buf, 4, 4, DVALUE4((n + p) / 4), "reply length");
1319 printfield(buf, 8, 2, DVALUE2(n), "length of name");
1320 n = IShort(&buf[8]);
1321 PrintString8(&buf[32], n, "name");
1322
1323 seq = IShort(&buf[2]);
1324 name = malloc(n + 1);
1325 if (name != NULL) {
1326 memcpy(name, buf + 32, n);
1327 name[n] = 0;
1328 }
1329 finish_atom_request(seq, 0, name);
1330 }
1331
1332 void
ChangeProperty(FD fd,const unsigned char * buf)1333 ChangeProperty(FD fd, const unsigned char *buf)
1334 {
1335 uint32_t n;
1336 uint8_t unit;
1337 uint32_t type;
1338
1339 /* Request ChangeProperty is opcode 18 */
1340 PrintField(buf, 0, 1, REQUEST, REQUESTHEADER); /* ChangeProperty */
1341 if (Verbose < 1)
1342 return;
1343 if (Verbose > 1)
1344 PrintField(SBf, 0, 4, CARD32, "sequence number");
1345
1346 PrintField(buf, 1, 1, CHANGEMODE, "mode");
1347 printreqlen(buf, fd, DVALUE2(6 + (n + p) / 4));
1348 PrintField(buf, 4, 4, WINDOW, "window");
1349 PrintField(buf, 8, 4, ATOM, "property");
1350 PrintField(buf, 12, 4, ATOM, "type");
1351 type = ILong(&buf[12]);
1352 PrintField(buf, 16, 1, CARD8, "format");
1353 unit = IByte(&buf[16]) / 8;
1354 printfield(buf, 20, 4, CARD32, "length of data");
1355 n = ILong(&buf[20]);
1356 PrintPropertyValues(&buf[24], type, unit, n, "data");
1357 }
1358
1359 void
DeleteProperty(FD fd,const unsigned char * buf)1360 DeleteProperty(FD fd, const unsigned char *buf)
1361 {
1362 /* Request DeleteProperty is opcode 19 */
1363 PrintField(buf, 0, 1, REQUEST, REQUESTHEADER); /* DeleteProperty */
1364 if (Verbose < 1)
1365 return;
1366 if (Verbose > 1)
1367 PrintField(SBf, 0, 4, CARD32, "sequence number");
1368
1369 printreqlen(buf, fd, CONST2(3));
1370 PrintField(buf, 4, 4, WINDOW, "window");
1371 PrintField(buf, 8, 4, ATOM, "property");
1372 }
1373
1374 void
GetProperty(FD fd,const unsigned char * buf)1375 GetProperty(FD fd, const unsigned char *buf)
1376 {
1377 /* Request GetProperty is opcode 20 */
1378 PrintField(buf, 0, 1, REQUEST, REQUESTHEADER); /* GetProperty */
1379 if (Verbose < 1)
1380 return;
1381 if (Verbose > 1)
1382 PrintField(SBf, 0, 4, CARD32, "sequence number");
1383
1384 PrintField(buf, 1, 1, BOOL, "delete");
1385 printreqlen(buf, fd, CONST2(6));
1386 PrintField(buf, 4, 4, WINDOW, "window");
1387 PrintField(buf, 8, 4, ATOM, "property");
1388 PrintField(buf, 12, 4, ATOMT, "type");
1389 PrintField(buf, 16, 4, CARD32, "long-offset");
1390 printfield(buf, 20, 4, CARD32, "long-length");
1391 }
1392
1393 void
GetPropertyReply(const unsigned char * buf)1394 GetPropertyReply(const unsigned char *buf)
1395 {
1396 long n;
1397 short unit;
1398 long type;
1399
1400 PrintField(RBf, 0, 1, REPLY, REPLYHEADER); /* GetProperty */
1401 if (Verbose < 1)
1402 return;
1403 PrintField(buf, 1, 1, CARD8, "format");
1404 unit = IByte(&buf[1]) / 8;
1405 printfield(buf, 2, 2, CARD16, "sequence number");
1406 printfield(buf, 4, 4, DVALUE4((n + p) / 4), "reply length");
1407 PrintField(buf, 8, 4, ATOM, "type");
1408 type = ILong(&buf[8]);
1409 PrintField(buf, 12, 4, CARD32, "bytes-after");
1410 printfield(buf, 16, 4, CARD32, "length of value");
1411 n = ILong(&buf[16]);
1412 PrintPropertyValues(&buf[32], type, unit, n, "value");
1413 }
1414
1415 void
ListProperties(FD fd,const unsigned char * buf)1416 ListProperties(FD fd, const unsigned char *buf)
1417 {
1418 /* Request ListProperties is opcode 21 */
1419 PrintField(buf, 0, 1, REQUEST, REQUESTHEADER); /* ListProperties */
1420 if (Verbose < 1)
1421 return;
1422 if (Verbose > 1)
1423 PrintField(SBf, 0, 4, CARD32, "sequence number");
1424
1425 printreqlen(buf, fd, CONST2(2));
1426 PrintField(buf, 4, 4, WINDOW, "window");
1427 }
1428
1429 void
ListPropertiesReply(const unsigned char * buf)1430 ListPropertiesReply(const unsigned char *buf)
1431 {
1432 short n;
1433
1434 PrintField(RBf, 0, 1, REPLY, REPLYHEADER); /* ListProperties */
1435 if (Verbose < 1)
1436 return;
1437 printfield(buf, 2, 2, CARD16, "sequence number");
1438 printfield(buf, 4, 4, DVALUE4(n), "reply length");
1439 printfield(buf, 8, 2, DVALUE2(n), "number of atoms");
1440 n = IShort(&buf[8]);
1441 PrintList(&buf[32], (long) n, ATOM, "atoms");
1442 }
1443
1444 void
SetSelectionOwner(FD fd,const unsigned char * buf)1445 SetSelectionOwner(FD fd, const unsigned char *buf)
1446 {
1447 /* Request SetSelectionOwner is opcode 22 */
1448 PrintField(buf, 0, 1, REQUEST, REQUESTHEADER); /* SetSelectionOwner */
1449 if (Verbose < 1)
1450 return;
1451 if (Verbose > 1)
1452 PrintField(SBf, 0, 4, CARD32, "sequence number");
1453
1454 printreqlen(buf, fd, CONST2(4));
1455 PrintField(buf, 4, 4, WINDOW, "owner");
1456 PrintField(buf, 8, 4, ATOM, "selection");
1457 PrintField(buf, 12, 4, TIMESTAMP, "time");
1458 }
1459
1460 void
GetSelectionOwner(FD fd,const unsigned char * buf)1461 GetSelectionOwner(FD fd, const unsigned char *buf)
1462 {
1463 /* Request GetSelectionOwner is opcode 23 */
1464 PrintField(buf, 0, 1, REQUEST, REQUESTHEADER); /* GetSelectionOwner */
1465 if (Verbose < 1)
1466 return;
1467 if (Verbose > 1)
1468 PrintField(SBf, 0, 4, CARD32, "sequence number");
1469
1470 printreqlen(buf, fd, CONST2(2));
1471 PrintField(buf, 4, 4, ATOM, "selection");
1472 }
1473
1474 void
GetSelectionOwnerReply(const unsigned char * buf)1475 GetSelectionOwnerReply(const unsigned char *buf)
1476 {
1477 PrintField(RBf, 0, 1, REPLY, REPLYHEADER); /* GetSelectionOwner */
1478 if (Verbose < 1)
1479 return;
1480 printfield(buf, 2, 2, CARD16, "sequence number");
1481 printfield(buf, 4, 4, CONST4(0), "reply length");
1482 PrintField(buf, 8, 4, WINDOW, "owner");
1483 }
1484
1485 void
ConvertSelection(FD fd,const unsigned char * buf)1486 ConvertSelection(FD fd, const unsigned char *buf)
1487 {
1488 /* Request ConvertSelection is opcode 24 */
1489 PrintField(buf, 0, 1, REQUEST, REQUESTHEADER); /* ConvertSelection */
1490 if (Verbose < 1)
1491 return;
1492 if (Verbose > 1)
1493 PrintField(SBf, 0, 4, CARD32, "sequence number");
1494
1495 printreqlen(buf, fd, CONST2(6));
1496 PrintField(buf, 4, 4, WINDOW, "requestor");
1497 PrintField(buf, 8, 4, ATOM, "selection");
1498 PrintField(buf, 12, 4, ATOM, "target");
1499 PrintField(buf, 16, 4, ATOM, "property");
1500 PrintField(buf, 20, 4, TIMESTAMP, "time");
1501 }
1502
1503 void
SendEvent(FD fd,const unsigned char * buf)1504 SendEvent(FD fd, const unsigned char *buf)
1505 {
1506 /* Request SendEvent is opcode 25 */
1507 PrintField(buf, 0, 1, REQUEST, REQUESTHEADER); /* SendEvent */
1508 if (Verbose < 1)
1509 return;
1510 if (Verbose > 1)
1511 PrintField(SBf, 0, 4, CARD32, "sequence number");
1512
1513 PrintField(buf, 1, 1, BOOL, "propagate");
1514 printreqlen(buf, fd, CONST2(11));
1515 PrintField(buf, 4, 4, WINDOWD, "destination");
1516 PrintField(buf, 8, 4, SETofEVENT, "event-mask");
1517 PrintField(buf, 12, 32, EVENTFORM, "event");
1518 }
1519
1520 void
GrabPointer(FD fd,const unsigned char * buf)1521 GrabPointer(FD fd, const unsigned char *buf)
1522 {
1523 /* Request GrabPointer is opcode 26 */
1524 PrintField(buf, 0, 1, REQUEST, REQUESTHEADER); /* GrabPointer */
1525 if (Verbose < 1)
1526 return;
1527 if (Verbose > 1)
1528 PrintField(SBf, 0, 4, CARD32, "sequence number");
1529
1530 PrintField(buf, 1, 1, BOOL, "owner-events");
1531 printreqlen(buf, fd, CONST2(6));
1532 PrintField(buf, 4, 4, WINDOW, "grab-window");
1533 PrintField(buf, 8, 2, SETofPOINTEREVENT, "event-mask");
1534 PrintField(buf, 10, 1, PK_MODE, "pointer-mode");
1535 PrintField(buf, 11, 1, PK_MODE, "keyboard-mode");
1536 PrintField(buf, 12, 4, WINDOW, "confine-to");
1537 PrintField(buf, 16, 4, CURSOR, "cursor");
1538 PrintField(buf, 20, 4, TIMESTAMP, "time");
1539 }
1540
1541 void
GrabPointerReply(const unsigned char * buf)1542 GrabPointerReply(const unsigned char *buf)
1543 {
1544 PrintField(RBf, 0, 1, REPLY, REPLYHEADER); /* GrabPointer */
1545 if (Verbose < 1)
1546 return;
1547 PrintField(buf, 1, 1, GRABSTAT, "status");
1548 printfield(buf, 2, 2, CARD16, "sequence number");
1549 printfield(buf, 4, 4, CONST4(0), "reply length");
1550 }
1551
1552 void
UngrabPointer(FD fd,const unsigned char * buf)1553 UngrabPointer(FD fd, const unsigned char *buf)
1554 {
1555 /* Request UngrabPointer is opcode 27 */
1556 PrintField(buf, 0, 1, REQUEST, REQUESTHEADER); /* UngrabPointer */
1557 if (Verbose < 1)
1558 return;
1559 if (Verbose > 1)
1560 PrintField(SBf, 0, 4, CARD32, "sequence number");
1561
1562 printreqlen(buf, fd, CONST2(2));
1563 PrintField(buf, 4, 4, TIMESTAMP, "time");
1564 }
1565
1566 void
GrabButton(FD fd,const unsigned char * buf)1567 GrabButton(FD fd, const unsigned char *buf)
1568 {
1569 /* Request GrabButton is opcode 28 */
1570 PrintField(buf, 0, 1, REQUEST, REQUESTHEADER); /* GrabButton */
1571 if (Verbose < 1)
1572 return;
1573 if (Verbose > 1)
1574 PrintField(SBf, 0, 4, CARD32, "sequence number");
1575
1576 PrintField(buf, 1, 1, BOOL, "owner-events");
1577 printreqlen(buf, fd, CONST2(6));
1578 PrintField(buf, 4, 4, WINDOW, "grab-window");
1579 PrintField(buf, 8, 2, SETofPOINTEREVENT, "event-mask");
1580 PrintField(buf, 10, 1, PK_MODE, "pointer-mode");
1581 PrintField(buf, 11, 1, PK_MODE, "keyboard-mode");
1582 PrintField(buf, 12, 4, WINDOW, "confine-to");
1583 PrintField(buf, 16, 4, CURSOR, "cursor");
1584 PrintField(buf, 20, 1, BUTTONA, "button");
1585 PrintField(buf, 22, 2, SETofKEYMASK, "modifiers");
1586 }
1587
1588 void
UngrabButton(FD fd,const unsigned char * buf)1589 UngrabButton(FD fd, const unsigned char *buf)
1590 {
1591 /* Request UngrabButton is opcode 29 */
1592 PrintField(buf, 0, 1, REQUEST, REQUESTHEADER); /* UngrabButton */
1593 if (Verbose < 1)
1594 return;
1595 if (Verbose > 1)
1596 PrintField(SBf, 0, 4, CARD32, "sequence number");
1597
1598 PrintField(buf, 1, 1, BUTTONA, "button");
1599 printreqlen(buf, fd, CONST2(3));
1600 PrintField(buf, 4, 4, WINDOW, "grab-window");
1601 PrintField(buf, 8, 2, SETofKEYMASK, "modifiers");
1602 }
1603
1604 void
ChangeActivePointerGrab(FD fd,const unsigned char * buf)1605 ChangeActivePointerGrab(FD fd, const unsigned char *buf)
1606 {
1607 /* Request ChangeActivePointerGrab is opcode 30 */
1608 PrintField(buf, 0, 1, REQUEST,
1609 REQUESTHEADER); /* ChangeActivePointerGrab */
1610 if (Verbose < 1)
1611 return;
1612 if (Verbose > 1)
1613 PrintField(SBf, 0, 4, CARD32, "sequence number");
1614
1615 printreqlen(buf, fd, CONST2(4));
1616 PrintField(buf, 4, 4, CURSOR, "cursor");
1617 PrintField(buf, 8, 4, TIMESTAMP, "time");
1618 PrintField(buf, 12, 2, SETofPOINTEREVENT, "event-mask");
1619 }
1620
1621 void
GrabKeyboard(FD fd,const unsigned char * buf)1622 GrabKeyboard(FD fd, const unsigned char *buf)
1623 {
1624 /* Request GrabKeyboard is opcode 31 */
1625 PrintField(buf, 0, 1, REQUEST, REQUESTHEADER); /* GrabKeyboard */
1626 if (Verbose < 1)
1627 return;
1628 if (Verbose > 1)
1629 PrintField(SBf, 0, 4, CARD32, "sequence number");
1630
1631 PrintField(buf, 1, 1, BOOL, "owner-events");
1632 printreqlen(buf, fd, CONST2(4));
1633 PrintField(buf, 4, 4, WINDOW, "grab-window");
1634 PrintField(buf, 8, 4, TIMESTAMP, "time");
1635 PrintField(buf, 12, 1, PK_MODE, "pointer-mode");
1636 PrintField(buf, 13, 1, PK_MODE, "keyboard-mode");
1637 }
1638
1639 void
GrabKeyboardReply(const unsigned char * buf)1640 GrabKeyboardReply(const unsigned char *buf)
1641 {
1642 PrintField(RBf, 0, 1, REPLY, REPLYHEADER); /* GrabKeyboard */
1643 if (Verbose < 1)
1644 return;
1645 PrintField(buf, 1, 1, GRABSTAT, "status");
1646 printfield(buf, 2, 2, CARD16, "sequence number");
1647 printfield(buf, 4, 4, CONST4(0), "reply length");
1648 }
1649
1650 void
UngrabKeyboard(FD fd,const unsigned char * buf)1651 UngrabKeyboard(FD fd, const unsigned char *buf)
1652 {
1653 /* Request UngrabKeyboard is opcode 32 */
1654 PrintField(buf, 0, 1, REQUEST, REQUESTHEADER); /* UngrabKeyboard */
1655 if (Verbose < 1)
1656 return;
1657 if (Verbose > 1)
1658 PrintField(SBf, 0, 4, CARD32, "sequence number");
1659
1660 printreqlen(buf, fd, CONST2(2));
1661 PrintField(buf, 4, 4, TIMESTAMP, "time");
1662 }
1663
1664 void
GrabKey(FD fd,const unsigned char * buf)1665 GrabKey(FD fd, const unsigned char *buf)
1666 {
1667 /* Request GrabKey is opcode 33 */
1668 PrintField(buf, 0, 1, REQUEST, REQUESTHEADER); /* GrabKey */
1669 if (Verbose < 1)
1670 return;
1671 if (Verbose > 1)
1672 PrintField(SBf, 0, 4, CARD32, "sequence number");
1673
1674 PrintField(buf, 1, 1, BOOL, "owner-events");
1675 printreqlen(buf, fd, CONST2(4));
1676 PrintField(buf, 4, 4, WINDOW, "grab-window");
1677 PrintField(buf, 8, 2, SETofKEYMASK, "modifiers");
1678 PrintField(buf, 10, 1, KEYCODEA, "key");
1679 PrintField(buf, 11, 1, PK_MODE, "pointer-mode");
1680 PrintField(buf, 12, 1, PK_MODE, "keyboard-mode");
1681 }
1682
1683 void
UngrabKey(FD fd,const unsigned char * buf)1684 UngrabKey(FD fd, const unsigned char *buf)
1685 {
1686 /* Request UngrabKey is opcode 34 */
1687 PrintField(buf, 0, 1, REQUEST, REQUESTHEADER); /* UngrabKey */
1688 if (Verbose < 1)
1689 return;
1690 if (Verbose > 1)
1691 PrintField(SBf, 0, 4, CARD32, "sequence number");
1692
1693 PrintField(buf, 1, 1, KEYCODEA, "key");
1694 printreqlen(buf, fd, CONST2(3));
1695 PrintField(buf, 4, 4, WINDOW, "grab-window");
1696 PrintField(buf, 8, 2, SETofKEYMASK, "modifiers");
1697 }
1698
1699 void
AllowEvents(FD fd,const unsigned char * buf)1700 AllowEvents(FD fd, const unsigned char *buf)
1701 {
1702 /* Request AllowEvents is opcode 35 */
1703 PrintField(buf, 0, 1, REQUEST, REQUESTHEADER); /* AllowEvents */
1704 if (Verbose < 1)
1705 return;
1706 if (Verbose > 1)
1707 PrintField(SBf, 0, 4, CARD32, "sequence number");
1708
1709 PrintField(buf, 1, 1, EVENTMODE, "mode");
1710 printreqlen(buf, fd, CONST2(2));
1711 PrintField(buf, 4, 4, TIMESTAMP, "time");
1712 }
1713
1714 void
GrabServer(FD fd,const unsigned char * buf)1715 GrabServer(FD fd, const unsigned char *buf)
1716 {
1717 /* Request GrabServer is opcode 36 */
1718 PrintField(buf, 0, 1, REQUEST, REQUESTHEADER); /* GrabServer */
1719 if (Verbose < 1)
1720 return;
1721 if (Verbose > 1)
1722 PrintField(SBf, 0, 4, CARD32, "sequence number");
1723
1724 printreqlen(buf, fd, CONST2(1));
1725 }
1726
1727 void
UngrabServer(FD fd,const unsigned char * buf)1728 UngrabServer(FD fd, const unsigned char *buf)
1729 {
1730 /* Request UngrabServer is opcode 37 */
1731 PrintField(buf, 0, 1, REQUEST, REQUESTHEADER); /* UngrabServer */
1732 if (Verbose < 1)
1733 return;
1734 if (Verbose > 1)
1735 PrintField(SBf, 0, 4, CARD32, "sequence number");
1736
1737 printreqlen(buf, fd, CONST2(1));
1738 }
1739
1740 void
QueryPointer(FD fd,const unsigned char * buf)1741 QueryPointer(FD fd, const unsigned char *buf)
1742 {
1743 /* Request QueryPointer is opcode 38 */
1744 PrintField(buf, 0, 1, REQUEST, REQUESTHEADER); /* QueryPointer */
1745 if (Verbose < 1)
1746 return;
1747 if (Verbose > 1)
1748 PrintField(SBf, 0, 4, CARD32, "sequence number");
1749
1750 printreqlen(buf, fd, CONST2(2));
1751 PrintField(buf, 4, 4, WINDOW, "window");
1752 }
1753
1754 void
QueryPointerReply(const unsigned char * buf)1755 QueryPointerReply(const unsigned char *buf)
1756 {
1757 PrintField(RBf, 0, 1, REPLY, REPLYHEADER); /* QueryPointer */
1758 if (Verbose < 1)
1759 return;
1760 PrintField(buf, 1, 1, BOOL, "same-screen");
1761 printfield(buf, 2, 2, CARD16, "sequence number");
1762 printfield(buf, 4, 4, CONST4(0), "reply length");
1763 PrintField(buf, 8, 4, WINDOW, "root");
1764 PrintField(buf, 12, 4, WINDOW, "child");
1765 PrintField(buf, 16, 2, INT16, "root-x");
1766 PrintField(buf, 18, 2, INT16, "root-y");
1767 PrintField(buf, 20, 2, INT16, "win-x");
1768 PrintField(buf, 22, 2, INT16, "win-y");
1769 PrintField(buf, 24, 2, SETofKEYBUTMASK, "mask");
1770 }
1771
1772 void
GetMotionEvents(FD fd,const unsigned char * buf)1773 GetMotionEvents(FD fd, const unsigned char *buf)
1774 {
1775 /* Request GetMotionEvents is opcode 39 */
1776 PrintField(buf, 0, 1, REQUEST, REQUESTHEADER); /* GetMotionEvents */
1777 if (Verbose < 1)
1778 return;
1779 if (Verbose > 1)
1780 PrintField(SBf, 0, 4, CARD32, "sequence number");
1781
1782 printreqlen(buf, fd, CONST2(4));
1783 PrintField(buf, 4, 4, WINDOW, "window");
1784 PrintField(buf, 8, 4, TIMESTAMP, "start");
1785 PrintField(buf, 12, 4, TIMESTAMP, "stop");
1786 }
1787
1788 void
GetMotionEventsReply(const unsigned char * buf)1789 GetMotionEventsReply(const unsigned char *buf)
1790 {
1791 long n;
1792
1793 PrintField(RBf, 0, 1, REPLY, REPLYHEADER); /* GetMotionEvents */
1794 if (Verbose < 1)
1795 return;
1796 printfield(buf, 2, 2, CARD16, "sequence number");
1797 printfield(buf, 4, 4, DVALUE4(2 * n), "reply length");
1798 printfield(buf, 8, 4, DVALUE4(n), "number of events");
1799 n = ILong(&buf[8]);
1800 PrintList(&buf[32], n, TIMECOORD, "events");
1801 }
1802
1803 void
TranslateCoordinates(FD fd,const unsigned char * buf)1804 TranslateCoordinates(FD fd, const unsigned char *buf)
1805 {
1806 /* Request TranslateCoordinates is opcode 40 */
1807 PrintField(buf, 0, 1, REQUEST, REQUESTHEADER); /* TranslateCoordinates */
1808 if (Verbose < 1)
1809 return;
1810 if (Verbose > 1)
1811 PrintField(SBf, 0, 4, CARD32, "sequence number");
1812
1813 printreqlen(buf, fd, CONST2(4));
1814 PrintField(buf, 4, 4, WINDOW, "src-window");
1815 PrintField(buf, 8, 4, WINDOW, "dst-window");
1816 PrintField(buf, 12, 2, INT16, "src-x");
1817 PrintField(buf, 14, 2, INT16, "src-y");
1818 }
1819
1820 void
TranslateCoordinatesReply(const unsigned char * buf)1821 TranslateCoordinatesReply(const unsigned char *buf)
1822 {
1823 PrintField(RBf, 0, 1, REPLY, REPLYHEADER); /* TranslateCoordinates */
1824 if (Verbose < 1)
1825 return;
1826 PrintField(buf, 1, 1, BOOL, "same-screen");
1827 printfield(buf, 2, 2, CARD16, "sequence number");
1828 printfield(buf, 4, 4, CONST4(0), "reply length");
1829 PrintField(buf, 8, 4, WINDOW, "child");
1830 PrintField(buf, 12, 2, INT16, "dst-x");
1831 PrintField(buf, 14, 2, INT16, "dst-y");
1832 }
1833
1834 void
WarpPointer(FD fd,const unsigned char * buf)1835 WarpPointer(FD fd, const unsigned char *buf)
1836 {
1837 /* Request WarpPointer is opcode 41 */
1838 PrintField(buf, 0, 1, REQUEST, REQUESTHEADER); /* WarpPointer */
1839 if (Verbose < 1)
1840 return;
1841 if (Verbose > 1)
1842 PrintField(SBf, 0, 4, CARD32, "sequence number");
1843
1844 printreqlen(buf, fd, CONST2(6));
1845 PrintField(buf, 4, 4, WINDOW, "src-window");
1846 PrintField(buf, 8, 4, WINDOW, "dst-window");
1847 PrintField(buf, 12, 2, INT16, "src-x");
1848 PrintField(buf, 14, 2, INT16, "src-y");
1849 PrintField(buf, 16, 2, CARD16, "src-width");
1850 PrintField(buf, 18, 2, CARD16, "src-height");
1851 PrintField(buf, 20, 2, INT16, "dst-x");
1852 PrintField(buf, 22, 2, INT16, "dst-y");
1853 }
1854
1855 void
SetInputFocus(FD fd,const unsigned char * buf)1856 SetInputFocus(FD fd, const unsigned char *buf)
1857 {
1858 /* Request SetInputFocus is opcode 42 */
1859 PrintField(buf, 0, 1, REQUEST, REQUESTHEADER); /* SetInputFocus */
1860 if (Verbose < 1)
1861 return;
1862 if (Verbose > 1)
1863 PrintField(SBf, 0, 4, CARD32, "sequence number");
1864
1865 PrintField(buf, 1, 1, FOCUSAGENT, "revert-to");
1866 printreqlen(buf, fd, CONST2(3));
1867 PrintField(buf, 4, 4, WINDOWNR, "focus");
1868 PrintField(buf, 8, 4, TIMESTAMP, "time");
1869 }
1870
1871 void
GetInputFocus(FD fd,const unsigned char * buf)1872 GetInputFocus(FD fd, const unsigned char *buf)
1873 {
1874 /* Request GetInputFocus is opcode 43 */
1875 PrintField(buf, 0, 1, REQUEST, REQUESTHEADER); /* GetInputFocus */
1876 if (Verbose < 1)
1877 return;
1878 if (Verbose > 1)
1879 PrintField(SBf, 0, 4, CARD32, "sequence number");
1880
1881 printreqlen(buf, fd, CONST2(1));
1882 }
1883
1884 void
GetInputFocusReply(const unsigned char * buf)1885 GetInputFocusReply(const unsigned char *buf)
1886 {
1887 PrintField(RBf, 0, 1, REPLY, REPLYHEADER); /* GetInputFocus */
1888 if (Verbose < 1)
1889 return;
1890 PrintField(buf, 1, 1, FOCUSAGENT, "revert-to");
1891 printfield(buf, 2, 2, CARD16, "sequence number");
1892 printfield(buf, 4, 4, CONST4(0), "reply length");
1893 PrintField(buf, 8, 4, WINDOWNR, "focus");
1894 }
1895
1896 void
QueryKeymap(FD fd,const unsigned char * buf)1897 QueryKeymap(FD fd, const unsigned char *buf)
1898 {
1899 /* Request QueryKeymap is opcode 44 */
1900 PrintField(buf, 0, 1, REQUEST, REQUESTHEADER); /* QueryKeymap */
1901 if (Verbose < 1)
1902 return;
1903 if (Verbose > 1)
1904 PrintField(SBf, 0, 4, CARD32, "sequence number");
1905
1906 printreqlen(buf, fd, CONST2(1));
1907 }
1908
1909 void
QueryKeymapReply(const unsigned char * buf)1910 QueryKeymapReply(const unsigned char *buf)
1911 {
1912 PrintField(RBf, 0, 1, REPLY, REPLYHEADER); /* QueryKeymap */
1913 if (Verbose < 1)
1914 return;
1915 printfield(buf, 2, 2, CARD16, "sequence number");
1916 printfield(buf, 4, 4, CONST4(2), "reply length");
1917 PrintBytes(&buf[8], 32L, "keys");
1918 }
1919
1920 void
OpenFont(FD fd,const unsigned char * buf)1921 OpenFont(FD fd, const unsigned char *buf)
1922 {
1923 short n;
1924
1925 /* Request OpenFont is opcode 45 */
1926 PrintField(buf, 0, 1, REQUEST, REQUESTHEADER); /* OpenFont */
1927 if (Verbose < 1)
1928 return;
1929 if (Verbose > 1)
1930 PrintField(SBf, 0, 4, CARD32, "sequence number");
1931
1932 printreqlen(buf, fd, DVALUE2(3 + (n + p) / 4));
1933 PrintField(buf, 4, 4, FONT, "font-id");
1934 printfield(buf, 8, 2, DVALUE2(n), "length of name");
1935 n = IShort(&buf[8]);
1936 PrintString8(&buf[12], n, "name");
1937 }
1938
1939 void
CloseFont(FD fd,const unsigned char * buf)1940 CloseFont(FD fd, const unsigned char *buf)
1941 {
1942 /* Request CloseFont is opcode 46 */
1943 PrintField(buf, 0, 1, REQUEST, REQUESTHEADER); /* CloseFont */
1944 if (Verbose < 1)
1945 return;
1946 if (Verbose > 1)
1947 PrintField(SBf, 0, 4, CARD32, "sequence number");
1948
1949 printreqlen(buf, fd, CONST2(2));
1950 PrintField(buf, 4, 4, FONT, "font");
1951 }
1952
1953 void
QueryFont(FD fd,const unsigned char * buf)1954 QueryFont(FD fd, const unsigned char *buf)
1955 {
1956 /* Request QueryFont is opcode 47 */
1957 PrintField(buf, 0, 1, REQUEST, REQUESTHEADER); /* QueryFont */
1958 if (Verbose < 1)
1959 return;
1960 if (Verbose > 1)
1961 PrintField(SBf, 0, 4, CARD32, "sequence number");
1962
1963 printreqlen(buf, fd, CONST2(2));
1964 PrintField(buf, 4, 4, FONTABLE, "font");
1965 }
1966
1967 void
QueryFontReply(const unsigned char * buf)1968 QueryFontReply(const unsigned char *buf)
1969 {
1970 short n;
1971 long m;
1972 long k;
1973
1974 PrintField(RBf, 0, 1, REPLY, REPLYHEADER); /* QueryFont */
1975 if (Verbose < 1)
1976 return;
1977 printfield(buf, 2, 2, CARD16, "sequence number");
1978 printfield(buf, 4, 4, DVALUE4(7 + 2 * n + 3 * m), "reply length");
1979 PrintField(buf, 8, 12, CHARINFO, "min-bounds");
1980 PrintField(buf, 24, 12, CHARINFO, "max-bounds");
1981 PrintField(buf, 40, 2, CARD16, "min-char-or-byte2");
1982 PrintField(buf, 42, 2, CARD16, "max-char-or-byte2");
1983 PrintField(buf, 44, 2, CARD16, "default-char");
1984 printfield(buf, 46, 2, DVALUE2(n), "number of FONTPROPs");
1985 n = IShort(&buf[46]);
1986 PrintField(buf, 48, 1, DIRECT, "draw-direction");
1987 PrintField(buf, 49, 1, CARD8, "min-byte1");
1988 PrintField(buf, 50, 1, CARD8, "max-byte1");
1989 PrintField(buf, 51, 1, BOOL, "all-chars-exist");
1990 PrintField(buf, 52, 2, INT16, "font-ascent");
1991 PrintField(buf, 54, 2, INT16, "font-descent");
1992 printfield(buf, 56, 4, DVALUE4(m), "number of CHARINFOs");
1993 m = ILong(&buf[56]);
1994 k = PrintList(&buf[60], (long) n, FONTPROP, "properties");
1995 PrintList(&buf[60 + k], (long) m, CHARINFO, "char-infos");
1996 }
1997
1998 void
QueryTextExtents(FD fd,const unsigned char * buf)1999 QueryTextExtents(FD fd, const unsigned char *buf)
2000 {
2001 uint32_t n;
2002
2003 /* Request QueryTextExtents is opcode 48 */
2004 PrintField(buf, 0, 1, REQUEST, REQUESTHEADER); /* QueryTextExtents */
2005 if (Verbose < 1)
2006 return;
2007 if (Verbose > 1)
2008 PrintField(SBf, 0, 4, CARD32, "sequence number");
2009
2010 printfield(buf, 1, 1, BOOL, "odd length?");
2011 n = (getreqlen(fd, buf) - 2) * 4 / 2;
2012 printreqlen(buf, fd, DVALUE2(2 + (2 * n + p) / 4));
2013 if (IBool(&buf[1]))
2014 n -= 1;
2015 PrintField(buf, 4, 4, FONTABLE, "font");
2016 PrintString16(&buf[8], n, "string");
2017 }
2018
2019 void
QueryTextExtentsReply(const unsigned char * buf)2020 QueryTextExtentsReply(const unsigned char *buf)
2021 {
2022 PrintField(RBf, 0, 1, REPLY, REPLYHEADER); /* QueryTextExtents */
2023 if (Verbose < 1)
2024 return;
2025 PrintField(buf, 1, 1, DIRECT, "draw-direction");
2026 printfield(buf, 2, 2, CARD16, "sequence number");
2027 printfield(buf, 4, 4, CONST4(0), "reply length");
2028 PrintField(buf, 8, 2, INT16, "font-ascent");
2029 PrintField(buf, 10, 2, INT16, "font-descent");
2030 PrintField(buf, 12, 2, INT16, "overall-ascent");
2031 PrintField(buf, 14, 2, INT16, "overall-descent");
2032 PrintField(buf, 16, 4, INT32, "overall-width");
2033 PrintField(buf, 20, 4, INT32, "overall-left");
2034 PrintField(buf, 24, 4, INT32, "overall-right");
2035 }
2036
2037 void
ListFonts(FD fd,const unsigned char * buf)2038 ListFonts(FD fd, const unsigned char *buf)
2039 {
2040 short n;
2041
2042 /* Request ListFonts is opcode 49 */
2043 PrintField(buf, 0, 1, REQUEST, REQUESTHEADER); /* ListFonts */
2044 if (Verbose < 1)
2045 return;
2046 if (Verbose > 1)
2047 PrintField(SBf, 0, 4, CARD32, "sequence number");
2048
2049 printreqlen(buf, fd, DVALUE2(2 + (n + p) / 4));
2050 PrintField(buf, 4, 2, CARD16, "max-names");
2051 printfield(buf, 6, 2, DVALUE2(n), "length of pattern");
2052 n = IShort(&buf[6]);
2053 PrintString8(&buf[8], n, "pattern");
2054 }
2055
2056 void
ListFontsReply(const unsigned char * buf)2057 ListFontsReply(const unsigned char *buf)
2058 {
2059 short n;
2060
2061 PrintField(RBf, 0, 1, REPLY, REPLYHEADER); /* ListFonts */
2062 if (Verbose < 1)
2063 return;
2064 printfield(buf, 2, 2, CARD16, "sequence number");
2065 printfield(buf, 4, 4, DVALUE4((n + p) / 4), "reply length");
2066 printfield(buf, 8, 2, CARD16, "number of names");
2067 n = IShort(&buf[8]);
2068 PrintListSTR(&buf[32], (long) n, "names");
2069 }
2070
2071 void
ListFontsWithInfo(FD fd,const unsigned char * buf)2072 ListFontsWithInfo(FD fd, const unsigned char *buf)
2073 {
2074 short n;
2075
2076 /* Request ListFontsWithInfo is opcode 50 */
2077 PrintField(buf, 0, 1, REQUEST, REQUESTHEADER); /* ListFontsWithInfo */
2078 if (Verbose < 1)
2079 return;
2080 if (Verbose > 1)
2081 PrintField(SBf, 0, 4, CARD32, "sequence number");
2082
2083 printreqlen(buf, fd, DVALUE2(2 + (n + p) / 4));
2084 PrintField(buf, 4, 2, CARD16, "max-names");
2085 printfield(buf, 6, 2, DVALUE2(n), "length of pattern");
2086 n = IShort(&buf[6]);
2087 PrintString8(&buf[8], n, "pattern");
2088 }
2089
2090 void
ListFontsWithInfoReply(const unsigned char * buf)2091 ListFontsWithInfoReply(const unsigned char *buf)
2092 {
2093 short which;
2094
2095 PrintField(RBf, 0, 1, REPLY, REPLYHEADER); /* ListFontsWithInfo */
2096 if (Verbose < 1)
2097 return;
2098 which = IByte(&buf[1]);
2099 if (which != 0) {
2100 ListFontsWithInfoReply1(buf);
2101 KeepLastReplyExpected();
2102 }
2103 else
2104 ListFontsWithInfoReply2(buf);
2105 }
2106
2107 static void
ListFontsWithInfoReply1(const unsigned char * buf)2108 ListFontsWithInfoReply1(const unsigned char *buf)
2109 {
2110 short n;
2111 short m;
2112
2113 printfield(buf, 1, 1, DVALUE1(n), "length of name in bytes");
2114 n = IByte(&buf[1]);
2115 printfield(buf, 2, 2, CARD16, "sequence number");
2116 printfield(buf, 4, 4, DVALUE4(7 + 2 * m + (n + p) / 4), "reply length");
2117 PrintField(buf, 8, 12, CHARINFO, "min-bounds");
2118 PrintField(buf, 24, 12, CHARINFO, "max-bounds");
2119 PrintField(buf, 40, 2, CARD16, "min-char-or-byte2");
2120 PrintField(buf, 42, 2, CARD16, "max-char-or-byte2");
2121 PrintField(buf, 44, 2, CARD16, "default-char");
2122 printfield(buf, 46, 2, DVALUE2(m), "number of FONTPROPs");
2123 m = IShort(&buf[46]);
2124 PrintField(buf, 48, 1, DIRECT, "draw-direction");
2125 PrintField(buf, 49, 1, CARD8, "min-byte1");
2126 PrintField(buf, 50, 1, CARD8, "max-byte1");
2127 PrintField(buf, 51, 1, BOOL, "all-chars-exist");
2128 PrintField(buf, 52, 2, INT16, "font-ascent");
2129 PrintField(buf, 54, 2, INT16, "font-descent");
2130 PrintField(buf, 56, 4, CARD32, "replies-hint");
2131 PrintList(&buf[60], (long) m, FONTPROP, "properties");
2132 PrintString8(&buf[60 + 8 * m], n, "name");
2133 }
2134
2135 static void
ListFontsWithInfoReply2(const unsigned char * buf)2136 ListFontsWithInfoReply2(const unsigned char *buf)
2137 {
2138 PrintField(buf, 1, 1, CONST1(0), "last-reply indicator");
2139 printfield(buf, 2, 2, CARD16, "sequence number");
2140 printfield(buf, 4, 4, CONST4(7), "reply length");
2141 }
2142
2143 void
SetFontPath(FD fd,const unsigned char * buf)2144 SetFontPath(FD fd, const unsigned char *buf)
2145 {
2146 short n;
2147
2148 /* Request SetFontPath is opcode 51 */
2149 PrintField(buf, 0, 1, REQUEST, REQUESTHEADER); /* SetFontPath */
2150 if (Verbose < 1)
2151 return;
2152 if (Verbose > 1)
2153 PrintField(SBf, 0, 4, CARD32, "sequence number");
2154
2155 printreqlen(buf, fd, DVALUE2(2 + (n + p) / 4));
2156 printfield(buf, 4, 2, CARD16, "number of paths");
2157 n = IShort(&buf[4]);
2158 PrintListSTR(&buf[8], (long) n, "paths");
2159 }
2160
2161 void
GetFontPath(FD fd,const unsigned char * buf)2162 GetFontPath(FD fd, const unsigned char *buf)
2163 {
2164 /* Request GetFontPath is opcode 52 */
2165 PrintField(buf, 0, 1, REQUEST, REQUESTHEADER); /* GetFontPath */
2166 if (Verbose < 1)
2167 return;
2168 if (Verbose > 1)
2169 PrintField(SBf, 0, 4, CARD32, "sequence number");
2170
2171 PrintField(buf, 2, 2, CONST2(1), "request list");
2172 }
2173
2174 void
GetFontPathReply(const unsigned char * buf)2175 GetFontPathReply(const unsigned char *buf)
2176 {
2177 short n;
2178
2179 PrintField(RBf, 0, 1, REPLY, REPLYHEADER); /* GetFontPath */
2180 if (Verbose < 1)
2181 return;
2182 printfield(buf, 2, 2, CARD16, "sequence number");
2183 printfield(buf, 4, 4, DVALUE4((n + p) / 4), "reply length");
2184 printfield(buf, 8, 2, CARD16, "number of paths");
2185
2186 n = IShort(&buf[8]);
2187 PrintListSTR(&buf[32], (long) n, "paths");
2188 }
2189
2190 void
CreatePixmap(FD fd,const unsigned char * buf)2191 CreatePixmap(FD fd, const unsigned char *buf)
2192 {
2193 /* Request CreatePixmap is opcode 53 */
2194 PrintField(buf, 0, 1, REQUEST, REQUESTHEADER); /* CreatePixmap */
2195 if (Verbose < 1)
2196 return;
2197 if (Verbose > 1)
2198 PrintField(SBf, 0, 4, CARD32, "sequence number");
2199
2200 PrintField(buf, 1, 1, CARD8, "depth");
2201 printreqlen(buf, fd, CONST2(4));
2202 PrintField(buf, 4, 4, PIXMAP, "pixmap-id");
2203 PrintField(buf, 8, 4, DRAWABLE, "drawable");
2204 PrintField(buf, 12, 2, CARD16, "width");
2205 PrintField(buf, 14, 2, CARD16, "height");
2206 }
2207
2208 void
FreePixmap(FD fd,const unsigned char * buf)2209 FreePixmap(FD fd, const unsigned char *buf)
2210 {
2211 /* Request FreePixmap is opcode 54 */
2212 PrintField(buf, 0, 1, REQUEST, REQUESTHEADER); /* FreePixmap */
2213 if (Verbose < 1)
2214 return;
2215 if (Verbose > 1)
2216 PrintField(SBf, 0, 4, CARD32, "sequence number");
2217
2218 printreqlen(buf, fd, CONST2(2));
2219 PrintField(buf, 4, 4, PIXMAP, "pixmap");
2220 }
2221
2222 static const uint32_t GCDefaults[] = {
2223 3, /* function GXcopy */
2224 (uint32_t) ~0, /* planemask */
2225 0, /* foreground */
2226 1, /* background */
2227 0, /* line width */
2228 0, /* line style Solid */
2229 1, /* cap style Butt */
2230 0, /* join style Miter */
2231 0, /* fill style Solid */
2232 0, /* fill rule EvenOdd */
2233 0, /* tile */
2234 0, /* stipple */
2235 0, /* ts org x */
2236 0, /* ts org y */
2237 0, /* font */
2238 0, /* sub window mode ClipByChildren */
2239 1, /* graphics expose True */
2240 0, /* clip x org */
2241 0, /* clip y org */
2242 0, /* clip mask */
2243 0, /* dash offset */
2244 4, /* dashes */
2245 1, /* arc mode PieSlice */
2246 };
2247
2248 void
CreateGC(FD fd,const unsigned char * buf)2249 CreateGC(FD fd, const unsigned char *buf)
2250 {
2251 CreateValueRec(ILong(buf + 4), 23, GCDefaults);
2252 SetValueRec(ILong(buf + 4), &buf[12], 4, GC_BITMASK, &buf[16]);
2253
2254 /* Request CreateGC is opcode 55 */
2255 PrintField(buf, 0, 1, REQUEST, REQUESTHEADER); /* CreateGC */
2256 if (Verbose < 1)
2257 return;
2258 if (Verbose > 1)
2259 PrintField(SBf, 0, 4, CARD32, "sequence number");
2260
2261 printreqlen(buf, fd, DVALUE2(4 + n));
2262 PrintField(buf, 4, 4, GCONTEXT, "graphic-context-id");
2263 PrintField(buf, 8, 4, DRAWABLE, "drawable");
2264 PrintField(buf, 12, 4, GC_BITMASK, "value-mask");
2265 PrintValues(&buf[12], 4, GC_BITMASK, &buf[16], "value-list");
2266 }
2267
2268 void
ChangeGC(FD fd,const unsigned char * buf)2269 ChangeGC(FD fd, const unsigned char *buf)
2270 {
2271 SetValueRec(ILong(buf + 4), &buf[8], 4, GC_BITMASK, &buf[12]);
2272
2273 /* Request ChangeGC is opcode 56 */
2274 PrintField(buf, 0, 1, REQUEST, REQUESTHEADER); /* ChangeGC */
2275 if (Verbose < 1)
2276 return;
2277 if (Verbose > 1)
2278 PrintField(SBf, 0, 4, CARD32, "sequence number");
2279
2280 printreqlen(buf, fd, DVALUE2(3 + n));
2281 PrintField(buf, 4, 4, GCONTEXT, "gc");
2282 PrintField(buf, 8, 4, GC_BITMASK, "value-mask");
2283 PrintValues(&buf[8], 4, GC_BITMASK, &buf[12], "value-list");
2284 }
2285
2286 void
CopyGC(FD fd,const unsigned char * buf)2287 CopyGC(FD fd, const unsigned char *buf)
2288 {
2289 /* Request CopyGC is opcode 57 */
2290 PrintField(buf, 0, 1, REQUEST, REQUESTHEADER); /* CopyGC */
2291 if (Verbose < 1)
2292 return;
2293 if (Verbose > 1)
2294 PrintField(SBf, 0, 4, CARD32, "sequence number");
2295
2296 printreqlen(buf, fd, CONST2(4));
2297 PrintField(buf, 4, 4, GCONTEXT, "src-gc");
2298 PrintField(buf, 8, 4, GCONTEXT, "dst-gc");
2299 PrintField(buf, 12, 4, GC_BITMASK, "value-mask");
2300 }
2301
2302 void
SetDashes(FD fd,const unsigned char * buf)2303 SetDashes(FD fd, const unsigned char *buf)
2304 {
2305 short n;
2306
2307 /* Request SetDashes is opcode 58 */
2308 PrintField(buf, 0, 1, REQUEST, REQUESTHEADER); /* SetDashes */
2309 if (Verbose < 1)
2310 return;
2311 if (Verbose > 1)
2312 PrintField(SBf, 0, 4, CARD32, "sequence number");
2313
2314 printreqlen(buf, fd, DVALUE2(3 + (n + p) / 4));
2315 PrintField(buf, 4, 4, GCONTEXT, "gc");
2316 PrintField(buf, 8, 2, CARD16, "dash-offset");
2317 printfield(buf, 10, 2, DVALUE2(n), "length of dashes");
2318 n = IShort(&buf[10]);
2319 PrintBytes(&buf[12], (long) n, "dashes");
2320 }
2321
2322 void
SetClipRectangles(FD fd,const unsigned char * buf)2323 SetClipRectangles(FD fd, const unsigned char *buf)
2324 {
2325 uint32_t n;
2326
2327 /* Request SetClipRectangles is opcode 59 */
2328 PrintField(buf, 0, 1, REQUEST, REQUESTHEADER); /* SetClipRectangles */
2329 if (Verbose < 1)
2330 return;
2331 if (Verbose > 1)
2332 PrintField(SBf, 0, 4, CARD32, "sequence number");
2333
2334 PrintField(buf, 1, 1, RECTORDER, "ordering");
2335 n = (getreqlen(fd, buf) - 3) / 2;
2336 printreqlen(buf, fd, DVALUE2(3 + 2 * n));
2337 PrintField(buf, 4, 4, GCONTEXT, "gc");
2338 PrintField(buf, 8, 2, INT16, "clip-x-origin");
2339 PrintField(buf, 10, 2, INT16, "clip-y-origin");
2340 PrintList(&buf[12], (long) n, RECTANGLE, "rectangles");
2341 }
2342
2343 void
FreeGC(FD fd,const unsigned char * buf)2344 FreeGC(FD fd, const unsigned char *buf)
2345 {
2346 DeleteValueRec(ILong(&buf[4]));
2347
2348 /* Request FreeGC is opcode 60 */
2349 PrintField(buf, 0, 1, REQUEST, REQUESTHEADER); /* FreeGC */
2350 if (Verbose < 1)
2351 return;
2352 if (Verbose > 1)
2353 PrintField(SBf, 0, 4, CARD32, "sequence number");
2354
2355 printreqlen(buf, fd, CONST2(2));
2356 PrintField(buf, 4, 4, GCONTEXT, "gc");
2357 }
2358
2359 void
ClearArea(FD fd,const unsigned char * buf)2360 ClearArea(FD fd, const unsigned char *buf)
2361 {
2362 /* Request ClearArea is opcode 61 */
2363 PrintField(buf, 0, 1, REQUEST, REQUESTHEADER); /* ClearArea */
2364 if (Verbose < 1)
2365 return;
2366 if (Verbose > 1)
2367 PrintField(SBf, 0, 4, CARD32, "sequence number");
2368
2369 PrintField(buf, 1, 1, BOOL, "exposures");
2370 printreqlen(buf, fd, CONST2(4));
2371 PrintField(buf, 4, 4, WINDOW, "window");
2372 PrintField(buf, 8, 2, INT16, "x");
2373 PrintField(buf, 10, 2, INT16, "y");
2374 PrintField(buf, 12, 2, CARD16, "width");
2375 PrintField(buf, 14, 2, CARD16, "height");
2376 }
2377
2378 void
CopyArea(FD fd,const unsigned char * buf)2379 CopyArea(FD fd, const unsigned char *buf)
2380 {
2381 /* Request CopyArea is opcode 62 */
2382 PrintField(buf, 0, 1, REQUEST, REQUESTHEADER); /* CopyArea */
2383 if (Verbose < 1)
2384 return;
2385 if (Verbose > 1)
2386 PrintField(SBf, 0, 4, CARD32, "sequence number");
2387
2388 printreqlen(buf, fd, CONST2(7));
2389 PrintField(buf, 4, 4, DRAWABLE, "src-drawable");
2390 PrintField(buf, 8, 4, DRAWABLE, "dst-drawable");
2391 PrintField(buf, 12, 4, GCONTEXT, "gc");
2392 if (Verbose > 2)
2393 PrintValueRec(ILong(&buf[12]),
2394 GC_function | GC_plane_mask | GC_graphics_exposures,
2395 GC_BITMASK);
2396 PrintField(buf, 16, 2, INT16, "src-x");
2397 PrintField(buf, 18, 2, INT16, "src-y");
2398 PrintField(buf, 20, 2, INT16, "dst-x");
2399 PrintField(buf, 22, 2, INT16, "dst-y");
2400 PrintField(buf, 24, 2, CARD16, "width");
2401 PrintField(buf, 26, 2, CARD16, "height");
2402 }
2403
2404 void
CopyPlane(FD fd,const unsigned char * buf)2405 CopyPlane(FD fd, const unsigned char *buf)
2406 {
2407 /* Request CopyPlane is opcode 63 */
2408 PrintField(buf, 0, 1, REQUEST, REQUESTHEADER); /* CopyPlane */
2409 if (Verbose < 1)
2410 return;
2411 if (Verbose > 1)
2412 PrintField(SBf, 0, 4, CARD32, "sequence number");
2413
2414 printreqlen(buf, fd, CONST2(8));
2415 PrintField(buf, 4, 4, DRAWABLE, "src-drawable");
2416 PrintField(buf, 8, 4, DRAWABLE, "dst-drawable");
2417 PrintField(buf, 12, 4, GCONTEXT, "gc");
2418 if (Verbose > 2)
2419 PrintValueRec(ILong(&buf[12]),
2420 GC_function |
2421 GC_plane_mask |
2422 GC_foreground |
2423 GC_background |
2424 GC_graphics_exposures,
2425 GC_BITMASK);
2426 PrintField(buf, 16, 2, INT16, "src-x");
2427 PrintField(buf, 18, 2, INT16, "src-y");
2428 PrintField(buf, 20, 2, INT16, "dst-x");
2429 PrintField(buf, 22, 2, INT16, "dst-y");
2430 PrintField(buf, 24, 2, CARD16, "width");
2431 PrintField(buf, 26, 2, CARD16, "height");
2432 PrintField(buf, 28, 4, CARD32, "bit-plane");
2433 }
2434
2435 void
PolyPoint(FD fd,const unsigned char * buf)2436 PolyPoint(FD fd, const unsigned char *buf)
2437 {
2438 uint32_t n;
2439
2440 /* Request PolyPoint is opcode 64 */
2441 PrintField(buf, 0, 1, REQUEST, REQUESTHEADER); /* PolyPoint */
2442 if (Verbose < 1)
2443 return;
2444 if (Verbose > 1)
2445 PrintField(SBf, 0, 4, CARD32, "sequence number");
2446
2447 PrintField(buf, 1, 1, COORMODE, "coordinate-mode");
2448 n = (getreqlen(fd, buf) - 3);
2449 printreqlen(buf, fd, DVALUE2(3 + n));
2450 PrintField(buf, 4, 4, DRAWABLE, "drawable");
2451 PrintField(buf, 8, 4, GCONTEXT, "gc");
2452 if (Verbose > 2)
2453 PrintValueRec(ILong(&buf[8]),
2454 GC_function | GC_plane_mask | GC_foreground, GC_BITMASK);
2455 (void) PrintList(&buf[12], (long) n, POINT, "points");
2456 }
2457
2458 void
PolyLine(FD fd,const unsigned char * buf)2459 PolyLine(FD fd, const unsigned char *buf)
2460 {
2461 uint32_t n;
2462
2463 /* Request PolyLine is opcode 65 */
2464 PrintField(buf, 0, 1, REQUEST, REQUESTHEADER); /* PolyLine */
2465 if (Verbose < 1)
2466 return;
2467 if (Verbose > 1)
2468 PrintField(SBf, 0, 4, CARD32, "sequence number");
2469
2470 PrintField(buf, 1, 1, COORMODE, "coordinate-mode");
2471 n = (getreqlen(fd, buf) - 3);
2472 printreqlen(buf, fd, DVALUE2(3 + n));
2473 PrintField(buf, 4, 4, DRAWABLE, "drawable");
2474 PrintField(buf, 8, 4, GCONTEXT, "gc");
2475 if (Verbose > 2)
2476 PrintValueRec(ILong(&buf[8]),
2477 GC_function |
2478 GC_plane_mask |
2479 GC_line_width |
2480 GC_line_style |
2481 GC_cap_style |
2482 GC_join_style |
2483 GC_fill_style |
2484 GC_foreground |
2485 GC_background |
2486 GC_tile |
2487 GC_stipple,
2488 GC_BITMASK);
2489 (void) PrintList(&buf[12], (long) n, POINT, "points");
2490 }
2491
2492 void
PolySegment(FD fd,const unsigned char * buf)2493 PolySegment(FD fd, const unsigned char *buf)
2494 {
2495 uint32_t n;
2496
2497 /* Request PolySegment is opcode 66 */
2498 PrintField(buf, 0, 1, REQUEST, REQUESTHEADER); /* PolySegment */
2499 if (Verbose < 1)
2500 return;
2501 if (Verbose > 1)
2502 PrintField(SBf, 0, 4, CARD32, "sequence number");
2503
2504 n = (getreqlen(fd, buf) - 3) / 2;
2505 printreqlen(buf, fd, DVALUE2(3 + 2 * n));
2506 PrintField(buf, 4, 4, DRAWABLE, "drawable");
2507 PrintField(buf, 8, 4, GCONTEXT, "gc");
2508 if (Verbose > 2)
2509 PrintValueRec(ILong(&buf[8]),
2510 GC_function |
2511 GC_plane_mask |
2512 GC_line_width |
2513 GC_line_style |
2514 GC_cap_style |
2515 GC_fill_style |
2516 GC_foreground |
2517 GC_background |
2518 GC_tile |
2519 GC_stipple,
2520 GC_BITMASK);
2521 (void) PrintList(&buf[12], (long) n, SEGMENT, "segments");
2522 }
2523
2524 void
PolyRectangle(FD fd,const unsigned char * buf)2525 PolyRectangle(FD fd, const unsigned char *buf)
2526 {
2527 uint32_t n;
2528
2529 /* Request PolyRectangle is opcode 67 */
2530 PrintField(buf, 0, 1, REQUEST, REQUESTHEADER); /* PolyRectangle */
2531 if (Verbose < 1)
2532 return;
2533 if (Verbose > 1)
2534 PrintField(SBf, 0, 4, CARD32, "sequence number");
2535
2536 n = (getreqlen(fd, buf) - 3) / 2;
2537 printreqlen(buf, fd, DVALUE2(3 + 2 * n));
2538 PrintField(buf, 4, 4, DRAWABLE, "drawable");
2539 PrintField(buf, 8, 4, GCONTEXT, "gc");
2540 if (Verbose > 2)
2541 PrintValueRec(ILong(&buf[8]),
2542 GC_function |
2543 GC_plane_mask |
2544 GC_line_width |
2545 GC_line_style |
2546 GC_cap_style |
2547 GC_join_style |
2548 GC_fill_style |
2549 GC_foreground |
2550 GC_background |
2551 GC_tile |
2552 GC_stipple,
2553 GC_BITMASK);
2554 (void) PrintList(&buf[12], (long) n, RECTANGLE, "rectangles");
2555 }
2556
2557 void
PolyArc(FD fd,const unsigned char * buf)2558 PolyArc(FD fd, const unsigned char *buf)
2559 {
2560 uint32_t n;
2561
2562 /* Request PolyArc is opcode 68 */
2563 PrintField(buf, 0, 1, REQUEST, REQUESTHEADER); /* PolyArc */
2564 if (Verbose < 1)
2565 return;
2566 if (Verbose > 1)
2567 PrintField(SBf, 0, 4, CARD32, "sequence number");
2568
2569 n = (getreqlen(fd, buf) - 3) / 3;
2570 printreqlen(buf, fd, DVALUE2(3 + 3 * n));
2571 PrintField(buf, 4, 4, DRAWABLE, "drawable");
2572 PrintField(buf, 8, 4, GCONTEXT, "gc");
2573 if (Verbose > 2)
2574 PrintValueRec(ILong(&buf[8]),
2575 GC_function |
2576 GC_plane_mask |
2577 GC_line_width |
2578 GC_line_style |
2579 GC_cap_style |
2580 GC_join_style |
2581 GC_fill_style |
2582 GC_foreground |
2583 GC_background |
2584 GC_tile |
2585 GC_stipple,
2586 GC_BITMASK);
2587 (void) PrintList(&buf[12], (long) n, ARC, "arcs");
2588 }
2589
2590 void
FillPoly(FD fd,const unsigned char * buf)2591 FillPoly(FD fd, const unsigned char *buf)
2592 {
2593 uint32_t n;
2594
2595 /* Request FillPoly is opcode 69 */
2596 PrintField(buf, 0, 1, REQUEST, REQUESTHEADER); /* FillPoly */
2597 if (Verbose < 1)
2598 return;
2599 if (Verbose > 1)
2600 PrintField(SBf, 0, 4, CARD32, "sequence number");
2601
2602 n = (getreqlen(fd, buf) - 4);
2603 printreqlen(buf, fd, DVALUE2(4 + n));
2604 PrintField(buf, 4, 4, DRAWABLE, "drawable");
2605 PrintField(buf, 8, 4, GCONTEXT, "gc");
2606 if (Verbose > 2)
2607 PrintValueRec(ILong(buf + 8),
2608 GC_function |
2609 GC_plane_mask |
2610 GC_fill_style |
2611 GC_fill_rule |
2612 GC_foreground |
2613 GC_background |
2614 GC_tile |
2615 GC_stipple,
2616 GC_BITMASK);
2617 PrintField(buf, 12, 1, POLYSHAPE, "shape");
2618 PrintField(buf, 13, 1, COORMODE, "coordinate-mode");
2619 PrintList(&buf[16], (long) n, POINT, "points");
2620 }
2621
2622 void
PolyFillRectangle(FD fd,const unsigned char * buf)2623 PolyFillRectangle(FD fd, const unsigned char *buf)
2624 {
2625 uint32_t n;
2626
2627 /* Request PolyFillRectangle is opcode 70 */
2628 PrintField(buf, 0, 1, REQUEST, REQUESTHEADER); /* PolyFillRectangle */
2629 if (Verbose < 1)
2630 return;
2631 if (Verbose > 1)
2632 PrintField(SBf, 0, 4, CARD32, "sequence number");
2633
2634 n = (getreqlen(fd, buf) - 3) / 2;
2635 printreqlen(buf, fd, DVALUE2(3 + 2 * n));
2636 PrintField(buf, 4, 4, DRAWABLE, "drawable");
2637 PrintField(buf, 8, 4, GCONTEXT, "gc");
2638 if (Verbose > 2)
2639 PrintValueRec(ILong(buf + 8),
2640 GC_function |
2641 GC_plane_mask |
2642 GC_fill_style |
2643 GC_foreground |
2644 GC_background |
2645 GC_tile |
2646 GC_stipple,
2647 GC_BITMASK);
2648 (void) PrintList(&buf[12], (long) n, RECTANGLE, "rectangles");
2649 }
2650
2651 void
PolyFillArc(FD fd,const unsigned char * buf)2652 PolyFillArc(FD fd, const unsigned char *buf)
2653 {
2654 uint32_t n;
2655
2656 /* Request PolyFillArc is opcode 71 */
2657 PrintField(buf, 0, 1, REQUEST, REQUESTHEADER); /* PolyFillArc */
2658 if (Verbose < 1)
2659 return;
2660 if (Verbose > 1)
2661 PrintField(SBf, 0, 4, CARD32, "sequence number");
2662
2663 n = (getreqlen(fd, buf) - 3) / 3;
2664 printreqlen(buf, fd, DVALUE2(3 + 3 * n));
2665 PrintField(buf, 4, 4, DRAWABLE, "drawable");
2666 PrintField(buf, 8, 4, GCONTEXT, "gc");
2667 if (Verbose > 2)
2668 PrintValueRec(ILong(&buf[8]),
2669 GC_function |
2670 GC_plane_mask |
2671 GC_arc_mode |
2672 GC_fill_style |
2673 GC_foreground |
2674 GC_background |
2675 GC_tile |
2676 GC_stipple,
2677 GC_BITMASK);
2678 (void) PrintList(&buf[12], (long) n, ARC, "arcs");
2679 }
2680
2681 void
PutImage(FD fd,const unsigned char * buf)2682 PutImage(FD fd, const unsigned char *buf)
2683 {
2684 uint32_t n;
2685
2686 /* Request PutImage is opcode 72 */
2687 PrintField(buf, 0, 1, REQUEST, REQUESTHEADER); /* PutImage */
2688 if (Verbose < 1)
2689 return;
2690 if (Verbose > 1)
2691 PrintField(SBf, 0, 4, CARD32, "sequence number");
2692
2693 PrintField(buf, 1, 1, IMAGEMODE, "format");
2694
2695 /* the size of the Image is overestimated by the following computation of n,
2696 because we ignore that padding of the request to a multiple of 4 bytes.
2697 The image may not be a multiple of 4 bytes. The actual size of the image
2698 is determined as follows: for format = Bitmap or format = XYPixmap, the
2699 size is (left-pad + width) [ pad to multiple of bitmap-scanline-pad from
2700 SetUpReply ] divide by 8 to get bytes times height times depth for format
2701 = ZPixmap, take the depth and use it to find the bits-per-pixel and
2702 scanline-pad given in one of the SetUpReply DEPTH records. width *
2703 bits-per-pixel pad to multiple of scanline-pad divide by 8 to get bytes
2704 times height times depth For simplicity, we ignore all this and just use
2705 the request length to (over)estimate the size of the image */
2706
2707 n = (getreqlen(fd, buf) - 6) * 4;
2708 printreqlen(buf, fd, DVALUE2(6 + (n + p) / 4));
2709 PrintField(buf, 4, 4, DRAWABLE, "drawable");
2710 PrintField(buf, 8, 4, GCONTEXT, "gc");
2711 if (Verbose > 2)
2712 PrintValueRec(ILong(&buf[8]),
2713 GC_function |
2714 GC_plane_mask |
2715 GC_foreground |
2716 GC_background,
2717 GC_BITMASK);
2718 PrintField(buf, 12, 2, CARD16, "width");
2719 PrintField(buf, 14, 2, CARD16, "height");
2720 PrintField(buf, 16, 2, INT16, "dst-x");
2721 PrintField(buf, 18, 2, INT16, "dst-y");
2722 PrintField(buf, 20, 1, CARD8, "left-pad");
2723 PrintField(buf, 21, 1, CARD8, "depth");
2724
2725 if (Verbose > 3)
2726 PrintBytes(&buf[24], (long) n, "data");
2727 }
2728
2729 void
GetImage(FD fd,const unsigned char * buf)2730 GetImage(FD fd, const unsigned char *buf)
2731 {
2732 /* Request GetImage is opcode 73 */
2733 PrintField(buf, 0, 1, REQUEST, REQUESTHEADER); /* GetImage */
2734 if (Verbose < 1)
2735 return;
2736 if (Verbose > 1)
2737 PrintField(SBf, 0, 4, CARD32, "sequence number");
2738
2739 PrintField(buf, 1, 1, IMAGEMODE, "format");
2740 printreqlen(buf, fd, CONST2(5));
2741 PrintField(buf, 4, 4, DRAWABLE, "drawable");
2742 PrintField(buf, 8, 2, INT16, "x");
2743 PrintField(buf, 10, 2, INT16, "y");
2744 PrintField(buf, 12, 2, CARD16, "width");
2745 PrintField(buf, 14, 2, CARD16, "height");
2746 PrintField(buf, 16, 4, CARD32, "plane-mask");
2747 }
2748
2749 void
GetImageReply(const unsigned char * buf)2750 GetImageReply(const unsigned char *buf)
2751 {
2752 long n;
2753
2754 PrintField(RBf, 0, 1, REPLY, REPLYHEADER); /* GetImage */
2755 if (Verbose < 1)
2756 return;
2757 PrintField(buf, 1, 1, CARD8, "depth");
2758 printfield(buf, 2, 2, CARD16, "sequence number");
2759 printfield(buf, 4, 4, DVALUE4((n + p) / 4), "reply length");
2760
2761 /* to properly compute the actual size of the image, we have to remember the
2762 width and height values from the request. Again, we (over)estimate its
2763 length from the length of the reply */
2764 n = ILong(&buf[4]) * 4;
2765 PrintField(buf, 8, 4, VISUALID, "visual");
2766 if (Verbose > 3)
2767 PrintBytes(&buf[32], n, "data");
2768 }
2769
2770 void
PolyText8(FD fd,const unsigned char * buf)2771 PolyText8(FD fd, const unsigned char *buf)
2772 {
2773 uint32_t n;
2774
2775 /* Request PolyText8 is opcode 74 */
2776 PrintField(buf, 0, 1, REQUEST, REQUESTHEADER); /* PolyText8 */
2777 if (Verbose < 1)
2778 return;
2779 if (Verbose > 1)
2780 PrintField(SBf, 0, 4, CARD32, "sequence number");
2781
2782 n = (getreqlen(fd, buf) - 4) * 4;
2783 printreqlen(buf, fd, DVALUE2(4 + (n + p) / 4));
2784 PrintField(buf, 4, 4, DRAWABLE, "drawable");
2785 PrintField(buf, 8, 4, GCONTEXT, "gc");
2786 if (Verbose > 2)
2787 PrintValueRec(ILong(&buf[8]),
2788 GC_function |
2789 GC_plane_mask |
2790 GC_fill_style |
2791 GC_font |
2792 GC_foreground |
2793 GC_background |
2794 GC_tile |
2795 GC_stipple,
2796 GC_BITMASK);
2797 PrintField(buf, 12, 2, INT16, "x");
2798 PrintField(buf, 14, 2, INT16, "y");
2799 PrintTextList8(&buf[16], n, "items");
2800 }
2801
2802 void
PolyText16(FD fd,const unsigned char * buf)2803 PolyText16(FD fd, const unsigned char *buf)
2804 {
2805 uint32_t n;
2806
2807 /* Request PolyText16 is opcode 75 */
2808 PrintField(buf, 0, 1, REQUEST, REQUESTHEADER); /* PolyText16 */
2809 if (Verbose < 1)
2810 return;
2811 if (Verbose > 1)
2812 PrintField(SBf, 0, 4, CARD32, "sequence number");
2813
2814 n = (getreqlen(fd, buf) - 4) * 4;
2815 printreqlen(buf, fd, DVALUE2(4 + (n + p) / 4));
2816 PrintField(buf, 4, 4, DRAWABLE, "drawable");
2817 PrintField(buf, 8, 4, GCONTEXT, "gc");
2818 if (Verbose > 2)
2819 PrintValueRec(ILong(&buf[8]),
2820 GC_function |
2821 GC_plane_mask |
2822 GC_fill_style |
2823 GC_font |
2824 GC_foreground |
2825 GC_background |
2826 GC_tile |
2827 GC_stipple,
2828 GC_BITMASK);
2829 PrintField(buf, 12, 2, INT16, "x");
2830 PrintField(buf, 14, 2, INT16, "y");
2831 PrintTextList16(&buf[16], n, "items");
2832 }
2833
2834 void
ImageText8(FD fd,const unsigned char * buf)2835 ImageText8(FD fd, const unsigned char *buf)
2836 {
2837 short n;
2838
2839 /* Request ImageText8 is opcode 76 */
2840 PrintField(buf, 0, 1, REQUEST, REQUESTHEADER); /* ImageText8 */
2841 if (Verbose < 1)
2842 return;
2843 if (Verbose > 1)
2844 PrintField(SBf, 0, 4, CARD32, "sequence number");
2845
2846 printfield(buf, 1, 1, DVALUE1(n), "length of string");
2847 n = IByte(&buf[1]);
2848 printreqlen(buf, fd, DVALUE2(4 + (n + p) / 4));
2849 PrintField(buf, 4, 4, DRAWABLE, "drawable");
2850 PrintField(buf, 8, 4, GCONTEXT, "gc");
2851 if (Verbose > 2)
2852 PrintValueRec(ILong(&buf[8]),
2853 GC_plane_mask |
2854 GC_font |
2855 GC_foreground |
2856 GC_background,
2857 GC_BITMASK);
2858 PrintField(buf, 12, 2, INT16, "x");
2859 PrintField(buf, 14, 2, INT16, "y");
2860 PrintTString8(&buf[16], (long) n, "string");
2861 }
2862
2863 void
ImageText16(FD fd,const unsigned char * buf)2864 ImageText16(FD fd, const unsigned char *buf)
2865 {
2866 short n;
2867
2868 /* Request ImageText16 is opcode 77 */
2869 PrintField(buf, 0, 1, REQUEST, REQUESTHEADER); /* ImageText16 */
2870 if (Verbose < 1)
2871 return;
2872 if (Verbose > 1)
2873 PrintField(SBf, 0, 4, CARD32, "sequence number");
2874
2875 printfield(buf, 1, 1, DVALUE1(n), "length of string");
2876 n = IByte(&buf[1]);
2877 printreqlen(buf, fd, DVALUE2(4 + (2 * n + p) / 4));
2878 PrintField(buf, 4, 4, DRAWABLE, "drawable");
2879 PrintField(buf, 8, 4, GCONTEXT, "gc");
2880 if (Verbose > 2)
2881 PrintValueRec(ILong(&buf[8]),
2882 GC_plane_mask |
2883 GC_font |
2884 GC_foreground |
2885 GC_background,
2886 GC_BITMASK);
2887 PrintField(buf, 12, 2, INT16, "x");
2888 PrintField(buf, 14, 2, INT16, "y");
2889 PrintTString16(&buf[16], (long) n, "string");
2890 }
2891
2892 void
CreateColormap(FD fd,const unsigned char * buf)2893 CreateColormap(FD fd, const unsigned char *buf)
2894 {
2895 /* Request CreateColormap is opcode 78 */
2896 PrintField(buf, 0, 1, REQUEST, REQUESTHEADER); /* CreateColormap */
2897 if (Verbose < 1)
2898 return;
2899 if (Verbose > 1)
2900 PrintField(SBf, 0, 4, CARD32, "sequence number");
2901
2902 PrintField(buf, 1, 1, ALLORNONE, "alloc");
2903 printreqlen(buf, fd, CONST2(4));
2904 PrintField(buf, 4, 4, COLORMAP, "color-map-id");
2905 PrintField(buf, 8, 4, WINDOW, "window");
2906 PrintField(buf, 12, 4, VISUALID, "visual");
2907 }
2908
2909 void
FreeColormap(FD fd,const unsigned char * buf)2910 FreeColormap(FD fd, const unsigned char *buf)
2911 {
2912 /* Request FreeColormap is opcode 79 */
2913 PrintField(buf, 0, 1, REQUEST, REQUESTHEADER); /* FreeColormap */
2914 if (Verbose < 1)
2915 return;
2916 if (Verbose > 1)
2917 PrintField(SBf, 0, 4, CARD32, "sequence number");
2918
2919 printreqlen(buf, fd, CONST2(2));
2920 PrintField(buf, 4, 4, COLORMAP, "cmap");
2921 }
2922
2923 void
CopyColormapAndFree(FD fd,const unsigned char * buf)2924 CopyColormapAndFree(FD fd, const unsigned char *buf)
2925 {
2926 /* Request CopyColormapAndFree is opcode 80 */
2927 PrintField(buf, 0, 1, REQUEST, REQUESTHEADER); /* CopyColormapAndFree */
2928 if (Verbose < 1)
2929 return;
2930 if (Verbose > 1)
2931 PrintField(SBf, 0, 4, CARD32, "sequence number");
2932
2933 printreqlen(buf, fd, CONST2(3));
2934 PrintField(buf, 4, 4, COLORMAP, "color-map-id");
2935 PrintField(buf, 8, 4, COLORMAP, "src-cmap");
2936 }
2937
2938 void
InstallColormap(FD fd,const unsigned char * buf)2939 InstallColormap(FD fd, const unsigned char *buf)
2940 {
2941 /* Request InstallColormap is opcode 81 */
2942 PrintField(buf, 0, 1, REQUEST, REQUESTHEADER); /* InstallColormap */
2943 if (Verbose < 1)
2944 return;
2945 if (Verbose > 1)
2946 PrintField(SBf, 0, 4, CARD32, "sequence number");
2947
2948 printreqlen(buf, fd, CONST2(2));
2949 PrintField(buf, 4, 4, COLORMAP, "cmap");
2950 }
2951
2952 void
UninstallColormap(FD fd,const unsigned char * buf)2953 UninstallColormap(FD fd, const unsigned char *buf)
2954 {
2955 /* Request UninstallColormap is opcode 82 */
2956 PrintField(buf, 0, 1, REQUEST, REQUESTHEADER); /* UninstallColormap */
2957 if (Verbose < 1)
2958 return;
2959 if (Verbose > 1)
2960 PrintField(SBf, 0, 4, CARD32, "sequence number");
2961
2962 printreqlen(buf, fd, CONST2(2));
2963 PrintField(buf, 4, 4, COLORMAP, "cmap");
2964 }
2965
2966 void
ListInstalledColormaps(FD fd,const unsigned char * buf)2967 ListInstalledColormaps(FD fd, const unsigned char *buf)
2968 {
2969 /* Request ListInstalledColormaps is opcode 83 */
2970 PrintField(buf, 0, 1, REQUEST, REQUESTHEADER); /* ListInstalledColormaps */
2971 if (Verbose < 1)
2972 return;
2973 if (Verbose > 1)
2974 PrintField(SBf, 0, 4, CARD32, "sequence number");
2975
2976 printreqlen(buf, fd, CONST2(2));
2977 PrintField(buf, 4, 4, WINDOW, "window");
2978 }
2979
2980 void
ListInstalledColormapsReply(const unsigned char * buf)2981 ListInstalledColormapsReply(const unsigned char *buf)
2982 {
2983 short n;
2984
2985 PrintField(RBf, 0, 1, REPLY, REPLYHEADER); /* ListInstalledColormaps */
2986 if (Verbose < 1)
2987 return;
2988 printfield(buf, 2, 2, CARD16, "sequence number");
2989 printfield(buf, 4, 4, DVALUE4(n), "reply length");
2990 printfield(buf, 8, 2, DVALUE2(n), "number of cmaps");
2991 n = IShort(&buf[8]);
2992 PrintList(&buf[32], (long) n, COLORMAP, "cmaps");
2993 }
2994
2995 void
AllocColor(FD fd,const unsigned char * buf)2996 AllocColor(FD fd, const unsigned char *buf)
2997 {
2998 /* Request AllocColor is opcode 84 */
2999 PrintField(buf, 0, 1, REQUEST, REQUESTHEADER); /* AllocColor */
3000 if (Verbose < 1)
3001 return;
3002 if (Verbose > 1)
3003 PrintField(SBf, 0, 4, CARD32, "sequence number");
3004
3005 printreqlen(buf, fd, CONST2(4));
3006 PrintField(buf, 4, 4, COLORMAP, "cmap");
3007 PrintField(buf, 8, 2, CARD16, "red");
3008 PrintField(buf, 10, 2, CARD16, "green");
3009 PrintField(buf, 12, 2, CARD16, "blue");
3010 }
3011
3012 void
AllocColorReply(const unsigned char * buf)3013 AllocColorReply(const unsigned char *buf)
3014 {
3015 PrintField(RBf, 0, 1, REPLY, REPLYHEADER); /* AllocColor */
3016 if (Verbose < 1)
3017 return;
3018 printfield(buf, 2, 2, CARD16, "sequence number");
3019 printfield(buf, 4, 4, CONST4(0), "reply length");
3020 PrintField(buf, 8, 2, CARD16, "red");
3021 PrintField(buf, 10, 2, CARD16, "green");
3022 PrintField(buf, 12, 2, CARD16, "blue");
3023 PrintField(buf, 16, 4, CARD32, "pixel");
3024 }
3025
3026 void
AllocNamedColor(FD fd,const unsigned char * buf)3027 AllocNamedColor(FD fd, const unsigned char *buf)
3028 {
3029 short n;
3030
3031 /* Request AllocNamedColor is opcode 85 */
3032 PrintField(buf, 0, 1, REQUEST, REQUESTHEADER); /* AllocNamedColor */
3033 if (Verbose < 1)
3034 return;
3035 if (Verbose > 1)
3036 PrintField(SBf, 0, 4, CARD32, "sequence number");
3037
3038 printreqlen(buf, fd, DVALUE2(3 + (n + p) / 4));
3039 PrintField(buf, 4, 4, COLORMAP, "cmap");
3040 printfield(buf, 8, 2, DVALUE2(n), "length of name");
3041 n = IShort(&buf[8]);
3042 PrintString8(&buf[12], n, "name");
3043 }
3044
3045 void
AllocNamedColorReply(const unsigned char * buf)3046 AllocNamedColorReply(const unsigned char *buf)
3047 {
3048 PrintField(RBf, 0, 1, REPLY, REPLYHEADER); /* AllocNamedColor */
3049 if (Verbose < 1)
3050 return;
3051 printfield(buf, 2, 2, CARD16, "sequence number");
3052 printfield(buf, 4, 4, CONST4(0), "reply length");
3053 PrintField(buf, 8, 4, CARD32, "pixel");
3054 PrintField(buf, 12, 2, CARD16, "exact-red");
3055 PrintField(buf, 14, 2, CARD16, "exact-green");
3056 PrintField(buf, 16, 2, CARD16, "exact-blue");
3057 PrintField(buf, 18, 2, CARD16, "visual-red");
3058 PrintField(buf, 20, 2, CARD16, "visual-green");
3059 PrintField(buf, 22, 2, CARD16, "visual-blue");
3060 }
3061
3062 void
AllocColorCells(FD fd,const unsigned char * buf)3063 AllocColorCells(FD fd, const unsigned char *buf)
3064 {
3065 /* Request AllocColorCells is opcode 86 */
3066 PrintField(buf, 0, 1, REQUEST, REQUESTHEADER); /* AllocColorCells */
3067 if (Verbose < 1)
3068 return;
3069 if (Verbose > 1)
3070 PrintField(SBf, 0, 4, CARD32, "sequence number");
3071
3072 PrintField(buf, 1, 1, BOOL, "contiguous");
3073 printreqlen(buf, fd, CONST2(3));
3074 PrintField(buf, 4, 4, COLORMAP, "cmap");
3075 PrintField(buf, 8, 2, CARD16, "colors");
3076 PrintField(buf, 10, 2, CARD16, "planes");
3077 }
3078
3079 void
AllocColorCellsReply(const unsigned char * buf)3080 AllocColorCellsReply(const unsigned char *buf)
3081 {
3082 short n;
3083 short m;
3084 short k;
3085
3086 PrintField(RBf, 0, 1, REPLY, REPLYHEADER); /* AllocColorCells */
3087 if (Verbose < 1)
3088 return;
3089 printfield(buf, 2, 2, CARD16, "sequence number");
3090 printfield(buf, 4, 4, DVALUE4(n + m), "reply length");
3091 printfield(buf, 8, 2, DVALUE2(n), "number of pixels");
3092 n = IShort(&buf[8]);
3093 printfield(buf, 10, 2, DVALUE2(m), "number of masks");
3094 m = IShort(&buf[10]);
3095 k = PrintList(&buf[32], (long) n, CARD32, "pixels");
3096 PrintList(&buf[32 + k], (long) m, CARD32, "masks");
3097 }
3098
3099 void
AllocColorPlanes(FD fd,const unsigned char * buf)3100 AllocColorPlanes(FD fd, const unsigned char *buf)
3101 {
3102 /* Request AllocColorPlanes is opcode 87 */
3103 PrintField(buf, 0, 1, REQUEST, REQUESTHEADER); /* AllocColorPlanes */
3104 if (Verbose < 1)
3105 return;
3106 if (Verbose > 1)
3107 PrintField(SBf, 0, 4, CARD32, "sequence number");
3108
3109 PrintField(buf, 1, 1, BOOL, "contiguous");
3110 printreqlen(buf, fd, CONST2(4));
3111 PrintField(buf, 4, 4, COLORMAP, "cmap");
3112 PrintField(buf, 8, 2, CARD16, "colors");
3113 PrintField(buf, 10, 2, CARD16, "reds");
3114 PrintField(buf, 12, 2, CARD16, "greens");
3115 PrintField(buf, 14, 2, CARD16, "blues");
3116 }
3117
3118 void
AllocColorPlanesReply(const unsigned char * buf)3119 AllocColorPlanesReply(const unsigned char *buf)
3120 {
3121 short n;
3122
3123 PrintField(RBf, 0, 1, REPLY, REPLYHEADER); /* AllocColorPlanes */
3124 if (Verbose < 1)
3125 return;
3126 printfield(buf, 2, 2, CARD16, "sequence number");
3127 printfield(buf, 4, 4, DVALUE4(n), "reply length");
3128 printfield(buf, 8, 2, DVALUE2(n), "number of pixels");
3129 n = IShort(&buf[8]);
3130 PrintField(buf, 12, 4, CARD32, "red-mask");
3131 PrintField(buf, 16, 4, CARD32, "green-mask");
3132 PrintField(buf, 20, 4, CARD32, "blue-mask");
3133 PrintList(&buf[32], (long) n, CARD32, "pixels");
3134 }
3135
3136 void
FreeColors(FD fd,const unsigned char * buf)3137 FreeColors(FD fd, const unsigned char *buf)
3138 {
3139 uint32_t n;
3140
3141 /* Request FreeColors is opcode 88 */
3142 PrintField(buf, 0, 1, REQUEST, REQUESTHEADER); /* FreeColors */
3143 if (Verbose < 1)
3144 return;
3145 if (Verbose > 1)
3146 PrintField(SBf, 0, 4, CARD32, "sequence number");
3147
3148 n = getreqlen(fd, buf) - 3;
3149 printreqlen(buf, fd, DVALUE2(3 + n));
3150 PrintField(buf, 4, 4, COLORMAP, "cmap");
3151 PrintField(buf, 8, 4, CARD32, "plane-mask");
3152 PrintList(&buf[12], (long) n, CARD32, "pixels");
3153 }
3154
3155 void
StoreColors(FD fd,const unsigned char * buf)3156 StoreColors(FD fd, const unsigned char *buf)
3157 {
3158 uint32_t n;
3159
3160 /* Request StoreColors is opcode 89 */
3161 PrintField(buf, 0, 1, REQUEST, REQUESTHEADER); /* StoreColors */
3162 if (Verbose < 1)
3163 return;
3164 if (Verbose > 1)
3165 PrintField(SBf, 0, 4, CARD32, "sequence number");
3166
3167 n = (getreqlen(fd, buf) - 2) / 3;
3168 printreqlen(buf, fd, DVALUE2(2 + 3 * n));
3169 PrintField(buf, 4, 4, COLORMAP, "cmap");
3170 PrintList(&buf[8], (long) n, COLORITEM, "items");
3171 }
3172
3173 void
StoreNamedColor(FD fd,const unsigned char * buf)3174 StoreNamedColor(FD fd, const unsigned char *buf)
3175 {
3176 short n;
3177
3178 /* Request StoreNamedColor is opcode 90 */
3179 PrintField(buf, 0, 1, REQUEST, REQUESTHEADER); /* StoreNamedColor */
3180 if (Verbose < 1)
3181 return;
3182 if (Verbose > 1)
3183 PrintField(SBf, 0, 4, CARD32, "sequence number");
3184
3185 PrintField(buf, 1, 1, COLORMASK, "which colors?");
3186 printreqlen(buf, fd, DVALUE2(4 + (n + p) / 4));
3187 PrintField(buf, 4, 4, COLORMAP, "cmap");
3188 PrintField(buf, 8, 4, CARD32, "pixel");
3189 printfield(buf, 12, 2, DVALUE2(n), "length of name");
3190 n = IShort(&buf[12]);
3191 PrintString8(&buf[16], n, "name");
3192 }
3193
3194 void
QueryColors(FD fd,const unsigned char * buf)3195 QueryColors(FD fd, const unsigned char *buf)
3196 {
3197 uint32_t n;
3198
3199 /* Request QueryColors is opcode 91 */
3200 PrintField(buf, 0, 1, REQUEST, REQUESTHEADER); /* QueryColors */
3201 if (Verbose < 1)
3202 return;
3203 if (Verbose > 1)
3204 PrintField(SBf, 0, 4, CARD32, "sequence number");
3205
3206 n = getreqlen(fd, buf) - 2;
3207 printreqlen(buf, fd, DVALUE2(2 + n));
3208 PrintField(buf, 4, 4, COLORMAP, "cmap");
3209 PrintList(&buf[8], (long) n, CARD32, "pixels");
3210 }
3211
3212 void
QueryColorsReply(const unsigned char * buf)3213 QueryColorsReply(const unsigned char *buf)
3214 {
3215 short n;
3216
3217 PrintField(RBf, 0, 1, REPLY, REPLYHEADER); /* QueryColors */
3218 if (Verbose < 1)
3219 return;
3220 printfield(buf, 2, 2, CARD16, "sequence number");
3221 printfield(buf, 4, 4, DVALUE4(2 * n), "reply length");
3222 printfield(buf, 8, 2, DVALUE2(n), "number of colors");
3223 n = IShort(&buf[8]);
3224 PrintList(&buf[32], (long) n, RGB, "colors");
3225 }
3226
3227 void
LookupColor(FD fd,const unsigned char * buf)3228 LookupColor(FD fd, const unsigned char *buf)
3229 {
3230 short n;
3231
3232 /* Request LookupColor is opcode 92 */
3233 PrintField(buf, 0, 1, REQUEST, REQUESTHEADER); /* LookupColor */
3234 if (Verbose < 1)
3235 return;
3236 if (Verbose > 1)
3237 PrintField(SBf, 0, 4, CARD32, "sequence number");
3238
3239 printreqlen(buf, fd, DVALUE2(3 + (n + p) / 4));
3240 PrintField(buf, 4, 4, COLORMAP, "cmap");
3241 printfield(buf, 8, 2, DVALUE2(n), "length of name");
3242 n = IShort(&buf[8]);
3243 PrintString8(&buf[12], n, "name");
3244 }
3245
3246 void
LookupColorReply(const unsigned char * buf)3247 LookupColorReply(const unsigned char *buf)
3248 {
3249 PrintField(RBf, 0, 1, REPLY, REPLYHEADER); /* LookupColor */
3250 if (Verbose < 1)
3251 return;
3252 printfield(buf, 2, 2, CARD16, "sequence number");
3253 printfield(buf, 4, 4, CONST4(0), "reply length");
3254 PrintField(buf, 8, 2, CARD16, "exact-red");
3255 PrintField(buf, 10, 2, CARD16, "exact-green");
3256 PrintField(buf, 12, 2, CARD16, "exact-blue");
3257 PrintField(buf, 14, 2, CARD16, "visual-red");
3258 PrintField(buf, 16, 2, CARD16, "visual-green");
3259 PrintField(buf, 18, 2, CARD16, "visual-blue");
3260 }
3261
3262 void
CreateCursor(FD fd,const unsigned char * buf)3263 CreateCursor(FD fd, const unsigned char *buf)
3264 {
3265 /* Request CreateCursor is opcode 93 */
3266 PrintField(buf, 0, 1, REQUEST, REQUESTHEADER); /* CreateCursor */
3267 if (Verbose < 1)
3268 return;
3269 if (Verbose > 1)
3270 PrintField(SBf, 0, 4, CARD32, "sequence number");
3271
3272 printreqlen(buf, fd, CONST2(8));
3273 PrintField(buf, 4, 4, CURSOR, "cursor-id");
3274 PrintField(buf, 8, 4, PIXMAP, "source");
3275 PrintField(buf, 12, 4, PIXMAP, "mask");
3276 PrintField(buf, 16, 2, CARD16, "fore-red");
3277 PrintField(buf, 18, 2, CARD16, "fore-green");
3278 PrintField(buf, 20, 2, CARD16, "fore-blue");
3279 PrintField(buf, 22, 2, CARD16, "back-red");
3280 PrintField(buf, 24, 2, CARD16, "back-green");
3281 PrintField(buf, 26, 2, CARD16, "back-blue");
3282 PrintField(buf, 28, 2, CARD16, "x");
3283 PrintField(buf, 30, 2, CARD16, "y");
3284 }
3285
3286 void
CreateGlyphCursor(FD fd,const unsigned char * buf)3287 CreateGlyphCursor(FD fd, const unsigned char *buf)
3288 {
3289 /* Request CreateGlyphCursor is opcode 94 */
3290 PrintField(buf, 0, 1, REQUEST, REQUESTHEADER); /* CreateGlyphCursor */
3291 if (Verbose < 1)
3292 return;
3293 if (Verbose > 1)
3294 PrintField(SBf, 0, 4, CARD32, "sequence number");
3295
3296 printreqlen(buf, fd, CONST2(8));
3297 PrintField(buf, 4, 4, CURSOR, "cursor-id");
3298 PrintField(buf, 8, 4, FONT, "source-font");
3299 PrintField(buf, 12, 4, FONT, "mask-font");
3300 PrintField(buf, 16, 2, CARD16, "source-char");
3301 PrintField(buf, 18, 2, CARD16, "mask-char");
3302 PrintField(buf, 20, 2, CARD16, "fore-red");
3303 PrintField(buf, 22, 2, CARD16, "fore-green");
3304 PrintField(buf, 24, 2, CARD16, "fore-blue");
3305 PrintField(buf, 26, 2, CARD16, "back-red");
3306 PrintField(buf, 28, 2, CARD16, "back-green");
3307 PrintField(buf, 30, 2, CARD16, "back-blue");
3308 }
3309
3310 void
FreeCursor(FD fd,const unsigned char * buf)3311 FreeCursor(FD fd, const unsigned char *buf)
3312 {
3313 /* Request FreeCursor is opcode 95 */
3314 PrintField(buf, 0, 1, REQUEST, REQUESTHEADER); /* FreeCursor */
3315 if (Verbose < 1)
3316 return;
3317 if (Verbose > 1)
3318 PrintField(SBf, 0, 4, CARD32, "sequence number");
3319
3320 printreqlen(buf, fd, CONST2(2));
3321 PrintField(buf, 4, 4, CURSOR, "cursor");
3322 }
3323
3324 void
RecolorCursor(FD fd,const unsigned char * buf)3325 RecolorCursor(FD fd, const unsigned char *buf)
3326 {
3327 /* Request RecolorCursor is opcode 96 */
3328 PrintField(buf, 0, 1, REQUEST, REQUESTHEADER); /* RecolorCursor */
3329 if (Verbose < 1)
3330 return;
3331 if (Verbose > 1)
3332 PrintField(SBf, 0, 4, CARD32, "sequence number");
3333
3334 printreqlen(buf, fd, CONST2(5));
3335 PrintField(buf, 4, 4, CURSOR, "cursor");
3336 PrintField(buf, 8, 2, CARD16, "fore-red");
3337 PrintField(buf, 10, 2, CARD16, "fore-green");
3338 PrintField(buf, 12, 2, CARD16, "fore-blue");
3339 PrintField(buf, 14, 2, CARD16, "back-red");
3340 PrintField(buf, 16, 2, CARD16, "back-green");
3341 PrintField(buf, 18, 2, CARD16, "back-blue");
3342 }
3343
3344 void
QueryBestSize(FD fd,const unsigned char * buf)3345 QueryBestSize(FD fd, const unsigned char *buf)
3346 {
3347 /* Request QueryBestSize is opcode 97 */
3348 PrintField(buf, 0, 1, REQUEST, REQUESTHEADER); /* QueryBestSize */
3349 if (Verbose < 1)
3350 return;
3351 if (Verbose > 1)
3352 PrintField(SBf, 0, 4, CARD32, "sequence number");
3353
3354 PrintField(buf, 1, 1, OBJECTCLASS, "class");
3355 printreqlen(buf, fd, CONST2(3));
3356 PrintField(buf, 4, 4, DRAWABLE, "drawable");
3357 PrintField(buf, 8, 2, CARD16, "width");
3358 PrintField(buf, 10, 2, CARD16, "height");
3359 }
3360
3361 void
QueryBestSizeReply(const unsigned char * buf)3362 QueryBestSizeReply(const unsigned char *buf)
3363 {
3364 PrintField(RBf, 0, 1, REPLY, REPLYHEADER); /* QueryBestSize */
3365 if (Verbose < 1)
3366 return;
3367 printfield(buf, 2, 2, CARD16, "sequence number");
3368 printfield(buf, 4, 4, CONST4(0), "reply length");
3369 PrintField(buf, 8, 2, CARD16, "width");
3370 PrintField(buf, 10, 2, CARD16, "height");
3371 }
3372
3373 void
QueryExtension(FD fd,const unsigned char * buf)3374 QueryExtension(FD fd, const unsigned char *buf)
3375 {
3376 short n;
3377
3378 /* Request QueryExtension is opcode 98 */
3379 PrintField(buf, 0, 1, REQUEST, REQUESTHEADER); /* QueryExtension */
3380 if (Verbose < 1)
3381 return;
3382 if (Verbose > 1)
3383 PrintField(SBf, 0, 4, CARD32, "sequence number");
3384
3385 printreqlen(buf, fd, DVALUE2(2 + (n + p) / 4));
3386 printfield(buf, 4, 2, DVALUE2(n), "length of name");
3387 n = IShort(&buf[4]);
3388 PrintString8(&buf[8], (long) n, "name");
3389 }
3390
3391 void
QueryExtensionReply(const unsigned char * buf)3392 QueryExtensionReply(const unsigned char *buf)
3393 {
3394 PrintField(RBf, 0, 1, REPLY, REPLYHEADER); /* QueryExtension */
3395 if (Verbose < 1)
3396 return;
3397 printfield(buf, 2, 2, CARD16, "sequence number");
3398 printfield(buf, 4, 4, CONST4(0), "reply length");
3399 PrintField(buf, 8, 1, BOOL, "present");
3400 PrintField(buf, 9, 1, CARD8, "major-opcode");
3401 PrintField(buf, 10, 1, CARD8, "first-event");
3402 PrintField(buf, 11, 1, CARD8, "first-error");
3403 }
3404
3405 void
ListExtensions(FD fd,const unsigned char * buf)3406 ListExtensions(FD fd, const unsigned char *buf)
3407 {
3408 /* Request ListExtensions is opcode 99 */
3409 PrintField(buf, 0, 1, REQUEST, REQUESTHEADER); /* ListExtensions */
3410 if (Verbose < 1)
3411 return;
3412 if (Verbose > 1)
3413 PrintField(SBf, 0, 4, CARD32, "sequence number");
3414
3415 printreqlen(buf, fd, CONST2(1));
3416 }
3417
3418 void
ListExtensionsReply(const unsigned char * buf)3419 ListExtensionsReply(const unsigned char *buf)
3420 {
3421 short n;
3422
3423 PrintField(RBf, 0, 1, REPLY, REPLYHEADER); /* ListExtensions */
3424 if (Verbose < 1)
3425 return;
3426 printfield(buf, 1, 1, CARD8, "number names");
3427 n = IByte(&buf[1]);
3428 printfield(buf, 2, 2, CARD16, "sequence number");
3429 printfield(buf, 4, 4, DVALUE4((n + p) / 4), "reply length");
3430 PrintListSTR(&buf[32], (long) n, "names");
3431 }
3432
3433 void
ChangeKeyboardMapping(FD fd,const unsigned char * buf)3434 ChangeKeyboardMapping(FD fd, const unsigned char *buf)
3435 {
3436 short n;
3437 short m;
3438
3439 /* Request ChangeKeyboardMapping is opcode 100 */
3440 PrintField(buf, 0, 1, REQUEST, REQUESTHEADER); /* ChangeKeyboardMapping */
3441 if (Verbose < 1)
3442 return;
3443 if (Verbose > 1)
3444 PrintField(SBf, 0, 4, CARD32, "sequence number");
3445
3446 PrintField(buf, 1, 1, DVALUE1(n), "keycode-count");
3447 n = IByte(&buf[1]);
3448 printreqlen(buf, fd, DVALUE2(2 + nm));
3449 PrintField(buf, 4, 1, KEYCODE, "first-keycode");
3450 PrintField(buf, 5, 1, DVALUE1(m), "keysyms-per-keycode");
3451 m = IByte(&buf[5]);
3452 PrintList(&buf[8], (long) (n * m), KEYSYM, "keysyms");
3453 }
3454
3455 void
GetKeyboardMapping(FD fd,const unsigned char * buf)3456 GetKeyboardMapping(FD fd, const unsigned char *buf)
3457 {
3458 /* Request GetKeyboardMapping is opcode 101 */
3459 PrintField(buf, 0, 1, REQUEST, REQUESTHEADER); /* GetKeyboardMapping */
3460 if (Verbose < 1)
3461 return;
3462 if (Verbose > 1)
3463 PrintField(SBf, 0, 4, CARD32, "sequence number");
3464
3465 printreqlen(buf, fd, CONST2(2));
3466 PrintField(buf, 4, 1, KEYCODE, "first-keycode");
3467 PrintField(buf, 5, 1, CARD8, "count");
3468 }
3469
3470 void
GetKeyboardMappingReply(const unsigned char * buf)3471 GetKeyboardMappingReply(const unsigned char *buf)
3472 {
3473 long n;
3474
3475 PrintField(RBf, 0, 1, REPLY, REPLYHEADER); /* GetKeyboardMapping */
3476 if (Verbose < 1)
3477 return;
3478 PrintField(buf, 1, 1, DVALUE1(n), "keysyms-per-keycode");
3479 printfield(buf, 2, 2, CARD16, "sequence number");
3480 printfield(buf, 4, 4, DVALUE4(n * m), "reply length");
3481 n = ILong(&buf[4]);
3482 PrintList(&buf[32], n, KEYSYM, "keysyms");
3483 }
3484
3485 void
ChangeKeyboardControl(FD fd,const unsigned char * buf)3486 ChangeKeyboardControl(FD fd, const unsigned char *buf)
3487 {
3488 /* Request ChangeKeyboardControl is opcode 102 */
3489 PrintField(buf, 0, 1, REQUEST, REQUESTHEADER); /* ChangeKeyboardControl */
3490 if (Verbose < 1)
3491 return;
3492 if (Verbose > 1)
3493 PrintField(SBf, 0, 4, CARD32, "sequence number");
3494
3495 printreqlen(buf, fd, DVALUE2(2 + n));
3496 PrintField(buf, 4, 4, KEYBOARD_BITMASK, "value-mask");
3497 PrintValues(&buf[4], 4, KEYBOARD_BITMASK, &buf[8], "value-list");
3498 }
3499
3500 void
GetKeyboardControl(FD fd,const unsigned char * buf)3501 GetKeyboardControl(FD fd, const unsigned char *buf)
3502 {
3503 /* Request GetKeyboardControl is opcode 103 */
3504 PrintField(buf, 0, 1, REQUEST, REQUESTHEADER); /* GetKeyboardControl */
3505 if (Verbose < 1)
3506 return;
3507 if (Verbose > 1)
3508 PrintField(SBf, 0, 4, CARD32, "sequence number");
3509
3510 printreqlen(buf, fd, CONST2(1));
3511 }
3512
3513 void
GetKeyboardControlReply(const unsigned char * buf)3514 GetKeyboardControlReply(const unsigned char *buf)
3515 {
3516 PrintField(RBf, 0, 1, REPLY, REPLYHEADER); /* GetKeyboardControl */
3517 if (Verbose < 1)
3518 return;
3519 PrintField(buf, 1, 1, OFF_ON, "global-auto-repeat");
3520 printfield(buf, 2, 2, CARD16, "sequence number");
3521 printfield(buf, 4, 4, CONST4(5), "reply length");
3522 PrintField(buf, 8, 4, CARD32, "led-mask");
3523 PrintField(buf, 12, 1, CARD8, "key-click-percent");
3524 PrintField(buf, 13, 1, CARD8, "bell-percent");
3525 PrintField(buf, 14, 2, CARD16, "bell-pitch");
3526 PrintField(buf, 16, 2, CARD16, "bell-duration");
3527 PrintBytes(&buf[20], 32L, "auto-repeats");
3528 }
3529
3530 void
Bell(FD fd,const unsigned char * buf)3531 Bell(FD fd, const unsigned char *buf)
3532 {
3533 /* Request Bell is opcode 104 */
3534 PrintField(buf, 0, 1, REQUEST, REQUESTHEADER); /* Bell */
3535 if (Verbose < 1)
3536 return;
3537 if (Verbose > 1)
3538 PrintField(SBf, 0, 4, CARD32, "sequence number");
3539
3540 PrintField(buf, 1, 1, INT8, "percent");
3541 printreqlen(buf, fd, CONST2(1));
3542 }
3543
3544 void
ChangePointerControl(FD fd,const unsigned char * buf)3545 ChangePointerControl(FD fd, const unsigned char *buf)
3546 {
3547 /* Request ChangePointerControl is opcode 105 */
3548 PrintField(buf, 0, 1, REQUEST, REQUESTHEADER); /* ChangePointerControl */
3549 if (Verbose < 1)
3550 return;
3551 if (Verbose > 1)
3552 PrintField(SBf, 0, 4, CARD32, "sequence number");
3553
3554 printreqlen(buf, fd, CONST2(3));
3555 PrintField(buf, 4, 2, INT16, "acceleration-numerator");
3556 PrintField(buf, 6, 2, INT16, "acceleration-denominator");
3557 PrintField(buf, 8, 2, INT16, "threshold");
3558 PrintField(buf, 10, 1, BOOL, "do-acceleration");
3559 PrintField(buf, 11, 1, BOOL, "do-threshold");
3560 }
3561
3562 void
GetPointerControl(FD fd,const unsigned char * buf)3563 GetPointerControl(FD fd, const unsigned char *buf)
3564 {
3565 /* Request GetPointerControl is opcode 106 */
3566 PrintField(buf, 0, 1, REQUEST, REQUESTHEADER); /* GetPointerControl */
3567 if (Verbose < 1)
3568 return;
3569 if (Verbose > 1)
3570 PrintField(SBf, 0, 4, CARD32, "sequence number");
3571
3572 printreqlen(buf, fd, CONST2(1));
3573 }
3574
3575 void
GetPointerControlReply(const unsigned char * buf)3576 GetPointerControlReply(const unsigned char *buf)
3577 {
3578 PrintField(RBf, 0, 1, REPLY, REPLYHEADER); /* GetPointerControl */
3579 if (Verbose < 1)
3580 return;
3581 printfield(buf, 2, 2, CARD16, "sequence number");
3582 printfield(buf, 4, 4, CONST4(0), "reply length");
3583 PrintField(buf, 8, 2, CARD16, "acceleration-numerator");
3584 PrintField(buf, 10, 2, CARD16, "acceleration-denominator");
3585 PrintField(buf, 12, 2, CARD16, "threshold");
3586 }
3587
3588 void
SetScreenSaver(FD fd,const unsigned char * buf)3589 SetScreenSaver(FD fd, const unsigned char *buf)
3590 {
3591 /* Request SetScreenSaver is opcode 107 */
3592 PrintField(buf, 0, 1, REQUEST, REQUESTHEADER); /* SetScreenSaver */
3593 if (Verbose < 1)
3594 return;
3595 if (Verbose > 1)
3596 PrintField(SBf, 0, 4, CARD32, "sequence number");
3597
3598 printreqlen(buf, fd, CONST2(3));
3599 PrintField(buf, 4, 2, INT16, "timeout");
3600 PrintField(buf, 6, 2, INT16, "interval");
3601 PrintField(buf, 8, 1, NO_YES, "prefer-blanking");
3602 PrintField(buf, 9, 1, NO_YES, "allow-exposures");
3603 }
3604
3605 void
GetScreenSaver(FD fd,const unsigned char * buf)3606 GetScreenSaver(FD fd, const unsigned char *buf)
3607 {
3608 /* Request GetScreenSaver is opcode 108 */
3609 PrintField(buf, 0, 1, REQUEST, REQUESTHEADER); /* GetScreenSaver */
3610 if (Verbose < 1)
3611 return;
3612 if (Verbose > 1)
3613 PrintField(SBf, 0, 4, CARD32, "sequence number");
3614
3615 printreqlen(buf, fd, CONST2(1));
3616 }
3617
3618 void
GetScreenSaverReply(const unsigned char * buf)3619 GetScreenSaverReply(const unsigned char *buf)
3620 {
3621 PrintField(RBf, 0, 1, REPLY, REPLYHEADER); /* GetScreenSaver */
3622 if (Verbose < 1)
3623 return;
3624 printfield(buf, 2, 2, CARD16, "sequence number");
3625 printfield(buf, 4, 4, CONST4(0), "reply length");
3626 PrintField(buf, 8, 2, CARD16, "timeout");
3627 PrintField(buf, 10, 2, CARD16, "interval");
3628 PrintField(buf, 12, 1, NO_YES, "prefer-blanking");
3629 PrintField(buf, 13, 1, NO_YES, "allow-exposures");
3630 }
3631
3632 void
ChangeHosts(FD fd,const unsigned char * buf)3633 ChangeHosts(FD fd, const unsigned char *buf)
3634 {
3635 short n;
3636
3637 /* Request ChangeHosts is opcode 109 */
3638 PrintField(buf, 0, 1, REQUEST, REQUESTHEADER); /* ChangeHosts */
3639 if (Verbose < 1)
3640 return;
3641 if (Verbose > 1)
3642 PrintField(SBf, 0, 4, CARD32, "sequence number");
3643
3644 PrintField(buf, 1, 1, INS_DEL, "mode");
3645 printreqlen(buf, fd, DVALUE2(2 + (n + p) / 4));
3646 n = IShort(&buf[6]);
3647 PrintField(buf, 4, 4 + n, HOST, "host");
3648 }
3649
3650 void
ListHosts(FD fd,const unsigned char * buf)3651 ListHosts(FD fd, const unsigned char *buf)
3652 {
3653 /* Request ListHosts is opcode 110 */
3654 PrintField(buf, 0, 1, REQUEST, REQUESTHEADER); /* ListHosts */
3655 if (Verbose < 1)
3656 return;
3657 if (Verbose > 1)
3658 PrintField(SBf, 0, 4, CARD32, "sequence number");
3659
3660 printreqlen(buf, fd, CONST2(1));
3661 }
3662
3663 void
ListHostsReply(const unsigned char * buf)3664 ListHostsReply(const unsigned char *buf)
3665 {
3666 short n;
3667
3668 PrintField(RBf, 0, 1, REPLY, REPLYHEADER); /* ListHosts */
3669 if (Verbose < 1)
3670 return;
3671 PrintField(buf, 1, 1, DIS_EN, "mode");
3672 printfield(buf, 2, 2, CARD16, "sequence number");
3673 printfield(buf, 4, 4, DVALUE4(n / 4), "reply length");
3674 printfield(buf, 8, 2, CARD16, "number of hosts");
3675
3676 n = IShort(&buf[8]);
3677 PrintList(&buf[32], (long) n, HOST, "hosts");
3678 }
3679
3680 void
SetAccessControl(FD fd,const unsigned char * buf)3681 SetAccessControl(FD fd, const unsigned char *buf)
3682 {
3683 /* Request SetAccessControl is opcode 111 */
3684 PrintField(buf, 0, 1, REQUEST, REQUESTHEADER); /* SetAccessControl */
3685 if (Verbose < 1)
3686 return;
3687 if (Verbose > 1)
3688 PrintField(SBf, 0, 4, CARD32, "sequence number");
3689
3690 PrintField(buf, 1, 1, DIS_EN, "mode");
3691 printreqlen(buf, fd, CONST2(1));
3692 }
3693
3694 void
SetCloseDownMode(FD fd,const unsigned char * buf)3695 SetCloseDownMode(FD fd, const unsigned char *buf)
3696 {
3697 /* Request SetCloseDownMode is opcode 112 */
3698 PrintField(buf, 0, 1, REQUEST, REQUESTHEADER); /* SetCloseDownMode */
3699 if (Verbose < 1)
3700 return;
3701 if (Verbose > 1)
3702 PrintField(SBf, 0, 4, CARD32, "sequence number");
3703
3704 PrintField(buf, 1, 1, CLOSEMODE, "mode");
3705 printreqlen(buf, fd, CONST2(1));
3706 }
3707
3708 void
KillClient(FD fd,const unsigned char * buf)3709 KillClient(FD fd, const unsigned char *buf)
3710 {
3711 /* Request KillClient is opcode 113 */
3712 PrintField(buf, 0, 1, REQUEST, REQUESTHEADER); /* KillClient */
3713 if (Verbose < 1)
3714 return;
3715 if (Verbose > 1)
3716 PrintField(SBf, 0, 4, CARD32, "sequence number");
3717
3718 printreqlen(buf, fd, CONST2(2));
3719 PrintField(buf, 4, 4, RESOURCEID, "resource");
3720 }
3721
3722 void
RotateProperties(FD fd,const unsigned char * buf)3723 RotateProperties(FD fd, const unsigned char *buf)
3724 {
3725 short n;
3726
3727 /* Request RotateProperties is opcode 114 */
3728 PrintField(buf, 0, 1, REQUEST, REQUESTHEADER); /* RotateProperties */
3729 if (Verbose < 1)
3730 return;
3731 if (Verbose > 1)
3732 PrintField(SBf, 0, 4, CARD32, "sequence number");
3733
3734 printreqlen(buf, fd, DVALUE2(3 + n));
3735 PrintField(buf, 4, 4, WINDOW, "window");
3736 printfield(buf, 8, 2, DVALUE2(n), "number of properties");
3737 n = IShort(&buf[8]);
3738 PrintField(buf, 10, 2, INT16, "delta");
3739 PrintList(&buf[12], (long) n, ATOM, "properties");
3740 }
3741
3742 void
ForceScreenSaver(FD fd,const unsigned char * buf)3743 ForceScreenSaver(FD fd, const unsigned char *buf)
3744 {
3745 /* Request ForceScreenSaver is opcode 115 */
3746 PrintField(buf, 0, 1, REQUEST, REQUESTHEADER); /* ForceScreenSaver */
3747 if (Verbose < 1)
3748 return;
3749 if (Verbose > 1)
3750 PrintField(SBf, 0, 4, CARD32, "sequence number");
3751
3752 PrintField(buf, 1, 1, SAVEMODE, "mode");
3753 printreqlen(buf, fd, CONST2(1));
3754 }
3755
3756 void
SetPointerMapping(FD fd,const unsigned char * buf)3757 SetPointerMapping(FD fd, const unsigned char *buf)
3758 {
3759 short n;
3760
3761 /* Request SetPointerMapping is opcode 116 */
3762 PrintField(buf, 0, 1, REQUEST, REQUESTHEADER); /* SetPointerMapping */
3763 if (Verbose < 1)
3764 return;
3765 if (Verbose > 1)
3766 PrintField(SBf, 0, 4, CARD32, "sequence number");
3767
3768 printfield(buf, 1, 1, DVALUE1(n), "length of map");
3769 n = IByte(&buf[1]);
3770 printreqlen(buf, fd, DVALUE2(1 + (n + p) / 4));
3771 PrintBytes(&buf[4], (long) n, "map");
3772 }
3773
3774 void
SetPointerMappingReply(const unsigned char * buf)3775 SetPointerMappingReply(const unsigned char *buf)
3776 {
3777 PrintField(RBf, 0, 1, REPLY, REPLYHEADER); /* SetPointerMapping */
3778 if (Verbose < 1)
3779 return;
3780 PrintField(buf, 1, 1, RSTATUS, "status");
3781 printfield(buf, 2, 2, CARD16, "sequence number");
3782 printfield(buf, 4, 4, CONST4(0), "reply length");
3783 }
3784
3785 void
GetPointerMapping(FD fd,const unsigned char * buf)3786 GetPointerMapping(FD fd, const unsigned char *buf)
3787 {
3788 /* Request GetPointerMapping is opcode 117 */
3789 PrintField(buf, 0, 1, REQUEST, REQUESTHEADER); /* GetPointerMapping */
3790 if (Verbose < 1)
3791 return;
3792 if (Verbose > 1)
3793 PrintField(SBf, 0, 4, CARD32, "sequence number");
3794
3795 printreqlen(buf, fd, CONST2(1));
3796 }
3797
3798 void
GetPointerMappingReply(const unsigned char * buf)3799 GetPointerMappingReply(const unsigned char *buf)
3800 {
3801 short n;
3802
3803 PrintField(RBf, 0, 1, REPLY, REPLYHEADER); /* GetPointerMapping */
3804 if (Verbose < 1)
3805 return;
3806 printfield(buf, 1, 1, DVALUE1(n), "length of map");
3807 n = IByte(&buf[1]);
3808 printfield(buf, 2, 2, CARD16, "sequence number");
3809 printfield(buf, 4, 4, DVALUE4((n + p) / 4), "reply length");
3810 PrintBytes(&buf[32], (long) n, "map");
3811 }
3812
3813 void
SetModifierMapping(FD fd,const unsigned char * buf)3814 SetModifierMapping(FD fd, const unsigned char *buf)
3815 {
3816 short n;
3817
3818 /* Request SetModifierMapping is opcode 118 */
3819 PrintField(buf, 0, 1, REQUEST, REQUESTHEADER); /* SetModifierMapping */
3820 if (Verbose < 1)
3821 return;
3822 if (Verbose > 1)
3823 PrintField(SBf, 0, 4, CARD32, "sequence number");
3824
3825 PrintField(buf, 1, 1, DVALUE1(n), "keycodes-per-modifier");
3826 n = IByte(&buf[1]);
3827 printreqlen(buf, fd, DVALUE2(1 + 2 * n));
3828 PrintBytes(&buf[4 + 0 * n], (long) n, "Shift keycodes");
3829 PrintBytes(&buf[4 + 1 * n], (long) n, "Lock keycodes");
3830 PrintBytes(&buf[4 + 2 * n], (long) n, "Control keycodes");
3831 PrintBytes(&buf[4 + 3 * n], (long) n, "Mod1 keycodes");
3832 PrintBytes(&buf[4 + 4 * n], (long) n, "Mod2 keycodes");
3833 PrintBytes(&buf[4 + 5 * n], (long) n, "Mod3 keycodes");
3834 PrintBytes(&buf[4 + 6 * n], (long) n, "Mod4 keycodes");
3835 PrintBytes(&buf[4 + 7 * n], (long) n, "Mod5 keycodes");
3836 }
3837
3838 void
SetModifierMappingReply(const unsigned char * buf)3839 SetModifierMappingReply(const unsigned char *buf)
3840 {
3841 PrintField(RBf, 0, 1, REPLY, REPLYHEADER); /* SetModifierMapping */
3842 if (Verbose < 1)
3843 return;
3844 PrintField(buf, 1, 1, RSTATUS, "status");
3845 printfield(buf, 2, 2, CARD16, "sequence number");
3846 printfield(buf, 4, 4, CONST4(0), "reply length");
3847 }
3848
3849 void
GetModifierMapping(FD fd,const unsigned char * buf)3850 GetModifierMapping(FD fd, const unsigned char *buf)
3851 {
3852 /* Request GetModifierMapping is opcode 119 */
3853 PrintField(buf, 0, 1, REQUEST, REQUESTHEADER); /* GetModifierMapping */
3854 if (Verbose < 1)
3855 return;
3856 if (Verbose > 1)
3857 PrintField(SBf, 0, 4, CARD32, "sequence number");
3858
3859 printreqlen(buf, fd, CONST2(1));
3860 }
3861
3862 void
GetModifierMappingReply(const unsigned char * buf)3863 GetModifierMappingReply(const unsigned char *buf)
3864 {
3865 short n;
3866
3867 PrintField(RBf, 0, 1, REPLY, REPLYHEADER); /* GetModifierMapping */
3868 if (Verbose < 1)
3869 return;
3870 PrintField(buf, 1, 1, DVALUE1(n), "keycodes-per-modifier");
3871 n = IByte(&buf[1]);
3872 printfield(buf, 2, 2, CARD16, "sequence number");
3873 printfield(buf, 4, 4, DVALUE4(2 * n), "reply length");
3874 PrintList(&buf[32], (long) n, KEYCODE, "keycodes");
3875 }
3876
3877 void
NoOperation(FD fd,const unsigned char * buf)3878 NoOperation(FD fd, const unsigned char *buf)
3879 {
3880 /* Request NoOperation is opcode 127 */
3881 PrintField(buf, 0, 1, REQUEST, REQUESTHEADER); /* NoOperation */
3882 if (Verbose < 1)
3883 return;
3884 if (Verbose > 1)
3885 PrintField(SBf, 0, 4, CARD32, "sequence number");
3886
3887 printreqlen(buf, fd, CONST2(1));
3888 }
3889