Initialize Tizen 2.3
[adaptation/xorg/driver/xserver-xorg-module-xdbg.git] / common / xdbg_evlog_xext.c
1 /**************************************************************************
2
3 xdbg
4
5 Copyright (c) 2013 Samsung Electronics Co., Ltd All Rights Reserved
6
7 Contact: Boram Park <boram1288.park@samsung.com>
8          Sangjin LEE <lsj119@samsung.com>
9
10 Permission is hereby granted, free of charge, to any person obtaining a
11 copy of this software and associated documentation files (the
12 "Software"), to deal in the Software without restriction, including
13 without limitation the rights to use, copy, modify, merge, publish,
14 distribute, sub license, and/or sell copies of the Software, and to
15 permit persons to whom the Software is furnished to do so, subject to
16 the following conditions:
17
18 The above copyright notice and this permission notice (including the
19 next paragraph) shall be included in all copies or substantial portions
20 of the Software.
21
22 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
23 OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
24 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
25 IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
26 ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
27 TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
28 SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
29
30 **************************************************************************/
31
32 #ifdef HAVE_CONFIG_H
33 #include "config.h"
34 #endif
35
36 #include <stdio.h>
37 #include <string.h>
38 #include <strings.h>
39 #include <sys/types.h>
40 #include <sys/fcntl.h>
41 #include <unistd.h>
42 #include <stdarg.h>
43 #include <fcntl.h>
44 #include <unistd.h>
45
46 #include <dix.h>
47 #define XREGISTRY
48 #include <registry.h>
49 #include <xace.h>
50 #include <xacestr.h>
51 #include <X11/Xatom.h>
52 #include <X11/Xlib.h>
53 #include <windowstr.h>
54
55 #include <X11/extensions/XShm.h>
56 #include <X11/extensions/dpms.h>
57 #include <X11/extensions/sync.h>
58 #include <X11/extensions/xtestext1.h>
59 #include <X11/extensions/XTest.h>
60 #include <X11/Xlibint.h>
61
62 #include <X11/extensions/dpmsproto.h>
63 #include <X11/extensions/shmproto.h>
64 #include <X11/extensions/syncproto.h>
65 #include <X11/extensions/xtestext1proto.h>
66 #include <X11/extensions/xtestproto.h>
67
68 #include "xdbg_types.h"
69 #include "xdbg_evlog_xext.h"
70 #include "xdbg_evlog.h"
71
72 static char *
73 _EvlogRequestXextDpms(EvlogInfo *evinfo, int detail_level, char *reply, int *len)
74 {
75     xReq *req = evinfo->req.ptr;
76
77     switch (req->data)
78     {
79     case X_DPMSSetTimeouts:
80         {
81             xDPMSSetTimeoutsReq *stuff = (xDPMSSetTimeoutsReq *)req;
82             REPLY (": Standby(%d) Suspend(%d) off(%d)",
83                 stuff->standby,
84                 stuff->suspend,
85                 stuff->off);
86
87             return reply;
88         }
89
90     case X_DPMSForceLevel:
91         {
92             xDPMSForceLevelReq *stuff = (xDPMSForceLevelReq *)req;
93             REPLY (": Level(%d)",
94                 stuff->level);
95
96             return reply;
97         }
98
99     default:
100             break;
101     }
102
103     return reply;
104 }
105
106
107 static char *
108 _EvlogRequestXextShm (EvlogInfo *evinfo, int detail_level, char *reply, int *len)
109 {
110     xReq *req = evinfo->req.ptr;
111
112     switch (req->data)
113     {
114     case X_ShmPutImage:
115         {
116             xShmPutImageReq *stuff = (xShmPutImageReq *)req;
117             REPLY (": XID(0x%lx) gc(0x%lx) size(%dx%d) src(%d,%d %dx%d) dst(%d,%d)",
118                 stuff->drawable,
119                 stuff->gc,
120                 stuff->totalWidth,
121                 stuff->totalHeight,
122                 stuff->srcX,
123                 stuff->srcY,
124                 stuff->srcWidth,
125                 stuff->srcHeight,
126                 stuff->dstX,
127                 stuff->dstY);
128
129             if (detail_level >= EVLOG_PRINT_DETAIL)
130             {
131                 const char *format;
132                 char dformat[10];
133
134                 switch (stuff->format)
135                 {
136                     case XYBitmap:  format = "XYBitmap"; break;
137                     case XYPixmap:  format = "XYPixmap"; break;
138                     case ZPixmap:  format = "ZPixmap"; break;
139                     default:  format = dformat; snprintf (dformat, 10, "%d", stuff->format); break;
140                 }
141
142                 REPLY ("\n");
143                 REPLY ("%67s depth(%d) format(%s) send_event(%s) shmseg(0x%lx) offset(%ld)",
144                     " ",
145                     stuff->depth,
146                     format,
147                     stuff->sendEvent ? "YES" : "NO",
148                     stuff->shmseg,
149                     stuff->offset);
150             }
151
152             return reply;
153         }
154
155     case X_ShmGetImage:
156         {
157             xShmGetImageReq *stuff = (xShmGetImageReq *)req;
158             REPLY (": XID(0x%lx) size(%dx%d) coord(%d,%d)",
159                 stuff->drawable,
160                 stuff->width,
161                 stuff->height,
162                 stuff->x,
163                 stuff->y);
164
165             if (detail_level >= EVLOG_PRINT_DETAIL)
166             {
167                 const char *format;
168                 char  dformat[10];
169
170                 switch (stuff->format)
171                 {
172                     case XYBitmap:  format = "XYBitmap"; break;
173                     case XYPixmap:  format = "XYPixmap"; break;
174                     case ZPixmap:  format = "ZPixmap"; break;
175                     default:  format = dformat; snprintf (dformat, 10, "%d", stuff->format); break;
176                 }
177
178                 REPLY ("\n");
179                 REPLY ("%67s format(%s) plain_mask(0x%lx) shmseg(0x%lx) offset(%ld)",
180                     " ",
181                     format,
182                     stuff->planeMask,
183                     stuff->shmseg,
184                     stuff->offset);
185             }
186
187             return reply;
188         }
189
190     case X_ShmCreatePixmap:
191         {
192             xShmCreatePixmapReq *stuff = (xShmCreatePixmapReq *)req;
193             REPLY (": Pixmap(0x%lx) Drawable(0x%lx) size(%dx%d)",
194                 stuff->pid,
195                 stuff->drawable,
196                 stuff->width,
197                 stuff->height);
198
199             if (detail_level >= EVLOG_PRINT_DETAIL)
200             {
201                 REPLY ("\n");
202                 REPLY ("%67s depth(%d) shmseg(0x%lx) offset(%ld)",
203                     " ",
204                     stuff->depth,
205                     stuff->shmseg,
206                     stuff->offset);
207             }
208
209             return reply;
210         }
211
212     default:
213             break;
214     }
215
216     return reply;
217 }
218
219 static char *
220 _EvlogRequestXextSync(EvlogInfo *evinfo, int detail_level, char *reply, int *len)
221 {
222     xReq *req = evinfo->req.ptr;
223
224     switch (req->data)
225     {
226     case X_SyncCreateCounter:
227         {
228             xSyncCreateCounterReq *stuff = (xSyncCreateCounterReq *)req;
229             REPLY (": XID(0x%lx) initValue(%ld/%ld)",
230                 stuff->cid,
231                 stuff->initial_value_hi,
232                 stuff->initial_value_lo);
233
234             return reply;
235         }
236
237     case X_SyncSetCounter:
238         {
239             xSyncSetCounterReq *stuff = (xSyncSetCounterReq *)req;
240             REPLY (": XID(0x%lx) Value(%ld/%ld)",
241                 stuff->cid,
242                 stuff->value_hi,
243                 stuff->value_lo);
244
245             return reply;
246         }
247
248     case X_SyncChangeCounter:
249         {
250             xSyncChangeCounterReq *stuff = (xSyncChangeCounterReq *)req;
251             REPLY (": XID(0x%lx) Value(%ld/%ld)",
252                 stuff->cid,
253                 stuff->value_hi,
254                 stuff->value_lo);
255
256             return reply;
257         }
258
259     case X_SyncQueryCounter:
260         {
261             xSyncQueryCounterReq *stuff = (xSyncQueryCounterReq *)req;
262             REPLY (": XID(0x%lx)",
263                 stuff->counter);
264
265             return reply;
266         }
267
268     case X_SyncDestroyCounter:
269         {
270             xSyncDestroyCounterReq *stuff = (xSyncDestroyCounterReq *)req;
271             REPLY (": XID(0x%lx)",
272                 stuff->counter);
273
274             return reply;
275         }
276
277     case X_SyncAwait:
278         {
279             xSyncAwaitReq *stuff = (xSyncAwaitReq*)req;
280             xSyncWaitCondition *pProtocolWaitConds;
281
282             pProtocolWaitConds = (xSyncWaitCondition *) &stuff[1];
283             REPLY (": XID(0x%lx) VType:%d TType:%d Value(%d/%d)",
284                 pProtocolWaitConds->counter,
285                 (unsigned int)pProtocolWaitConds->value_type,
286                 (unsigned int)pProtocolWaitConds->test_type,
287                 (unsigned int)pProtocolWaitConds->wait_value_hi,
288                 (unsigned int)pProtocolWaitConds->wait_value_lo);
289         }
290
291     default:
292             break;
293     }
294
295     return reply;
296 }
297
298 static char *
299 _EvlogRequestXextXtestExt1(EvlogInfo *evinfo, int detail_level, char *reply, int *len)
300 {
301     xReq *req = evinfo->req.ptr;
302
303     switch (req->data)
304     {
305     case X_TestFakeInput:
306         {
307             xTestFakeInputReq *stuff = (xTestFakeInputReq *)req;
308             REPLY (": XID(0x%lx)",
309                 stuff->ack);
310
311             return reply;
312         }
313
314     case X_TestGetInput:
315         {
316             xTestGetInputReq *stuff = (xTestGetInputReq *)req;
317             REPLY (": XID(0x%lx)",
318                 stuff->mode);
319
320             return reply;
321         }
322
323     default:
324             break;
325     }
326
327     return reply;
328 }
329
330
331 static char *
332 _EvlogRequestXextXtest(EvlogInfo *evinfo, int detail_level, char *reply, int *len)
333 {
334     xReq *req = evinfo->req.ptr;
335
336     switch (req->data)
337     {
338     case X_XTestGetVersion:
339         {
340             xXTestGetVersionReq *stuff = (xXTestGetVersionReq *)req;
341             REPLY (": MajorVersion(%d) MinorVersion(%d)",
342                 stuff->majorVersion,
343                 stuff->minorVersion);
344
345             return reply;
346         }
347
348     case X_XTestCompareCursor:
349         {
350             xXTestCompareCursorReq *stuff = (xXTestCompareCursorReq *)req;
351             REPLY (": XID(0x%lx) Cursor(0x%lx)",
352                 stuff->window,
353                 stuff->cursor);
354
355             return reply;
356         }
357
358     case X_XTestFakeInput:
359         {
360             xXTestFakeInputReq *stuff = (xXTestFakeInputReq *)req;
361             REPLY (": XID(0x%lx) coord(%d,%d)",
362                 stuff->root,
363                 stuff->rootX,
364                 stuff->rootY);
365
366             if (detail_level >= EVLOG_PRINT_DETAIL)
367             {
368                 REPLY (" type(%d) detail(%d) time(%lums) device_id(%d)",
369                     stuff->type,
370                     stuff->detail,
371                     stuff->time,
372                     stuff->deviceid);
373             }
374
375             return reply;
376         }
377     }
378
379     return reply;
380 }
381
382 static char *
383 _EvlogRequestXextShape(EvlogInfo *evinfo, int detail_level, char *reply, int *len)
384 {
385     xReq *req = evinfo->req.ptr;
386
387     switch (req->data)
388     {
389     case X_ShapeRectangles:
390         {
391             xShapeRectanglesReq *stuff = (xShapeRectanglesReq *)req;
392             REPLY (": XID(0x%lx) coord(%d,%d)",
393                 stuff->dest,
394                 stuff->xOff,
395                 stuff->yOff);
396
397             if (detail_level >= EVLOG_PRINT_DETAIL)
398             {
399                 int i;
400                 int nrect;
401                 xRectangle *prect;
402                 const char *destKind, *ordering;
403                 char  ddestKind[10], dordering[10];
404
405                 switch (stuff->destKind)
406                 {
407                     case ShapeBounding:  destKind = "ShapeBounding"; break;
408                     case ShapeClip:  destKind = "ShapeClip"; break;
409                     case ShapeInput:  destKind = "ShapeInput"; break;
410                     default:  destKind = ddestKind; snprintf (ddestKind, 10, "%d", stuff->destKind); break;
411                 }
412
413                 switch (stuff->ordering)
414                 {
415                     case Unsorted:  ordering = "Unsorted"; break;
416                     case YSorted:  ordering = "YSorted"; break;
417                     case YXSorted:  ordering = "YXSorted"; break;
418                     case YXBanded:  ordering = "YXBanded"; break;
419                     default:  ordering = dordering; snprintf (dordering, 10, "%d", stuff->ordering); break;
420                 }
421
422                 nrect = ((stuff->length * 4) - sizeof(xShapeRectanglesReq)) / sizeof(xRectangle);
423                 prect = (xRectangle *) &stuff[1];
424
425                 REPLY (" op(%d) destKind(%s) ordering(%s) nrect(%d)",
426                     stuff->op,
427                     destKind,
428                     ordering,
429                     nrect);
430
431                 REPLY ("\n");
432                 REPLY ("%67s Region", " ");
433                 REPLY ("(");
434
435                 for (i = 0 ; i < nrect ; i++)
436                 {
437                     REPLY("[%d,%d %dx%d]", 
438                         prect[i].x,
439                         prect[i].y,
440                         prect[i].width,
441                         prect[i].height);
442
443                     if(i != nrect - 1)
444                         REPLY (", ");
445                 }
446
447                 REPLY (")");
448             }
449
450             return reply;
451         }
452
453     case X_ShapeMask:
454         {
455             xShapeMaskReq *stuff = (xShapeMaskReq *)req;
456             REPLY (": XID(0x%lx) coord(%d,%d) src(0x%lx)",
457                 stuff->dest,
458                 stuff->xOff,
459                 stuff->yOff,
460                 stuff->src);
461
462             if (detail_level >= EVLOG_PRINT_DETAIL)
463             {
464                 const char *destKind;
465                 char  ddestKind[10];
466
467                 switch (stuff->destKind)
468                 {
469                     case ShapeBounding:  destKind = "ShapeBounding"; break;
470                     case ShapeClip:  destKind = "ShapeClip"; break;
471                     case ShapeInput:  destKind = "ShapeInput"; break;
472                     default:  destKind = ddestKind; snprintf (ddestKind, 10, "%d", stuff->destKind); break;
473                 }
474
475                 REPLY (" op(%d) destKind(%s)",
476                     stuff->op,
477                     destKind);
478             }
479
480             return reply;
481         }
482
483     case X_ShapeCombine:
484         {
485             xShapeCombineReq *stuff = (xShapeCombineReq *)req;
486             REPLY (": XID(0x%lx) coord(%d,%d) src(0x%lx)",
487                 stuff->dest,
488                 stuff->xOff,
489                 stuff->yOff,
490                 stuff->src);
491
492             if (detail_level >= EVLOG_PRINT_DETAIL)
493             {
494                 const char *destKind, *srcKind;
495                 char  ddestKind[10], dsrcKind[10];
496
497                 switch (stuff->destKind)
498                 {
499                     case ShapeBounding:  destKind = "ShapeBounding"; break;
500                     case ShapeClip:  destKind = "ShapeClip"; break;
501                     case ShapeInput:  destKind = "ShapeInput"; break;
502                     default:  destKind = ddestKind; snprintf (ddestKind, 10, "%d", stuff->destKind); break;
503                 }
504
505                 switch (stuff->srcKind)
506                 {
507                     case ShapeBounding:  srcKind = "ShapeBounding"; break;
508                     case ShapeClip:  srcKind = "ShapeClip"; break;
509                     case ShapeInput:  srcKind = "ShapeInput"; break;
510                     default:  srcKind = dsrcKind; snprintf (dsrcKind, 10, "%d", stuff->srcKind); break;
511                 }
512
513                 REPLY (" op(%d) destKind(%s) srcKind(%s)",
514                     stuff->op,
515                     destKind,
516                     srcKind);
517             }
518
519             return reply;
520         }
521
522     case X_ShapeOffset:
523         {
524             xShapeOffsetReq *stuff = (xShapeOffsetReq *)req;
525             REPLY (": XID(0x%lx) coord(%d,%d)",
526                 stuff->dest,
527                 stuff->xOff,
528                 stuff->yOff);
529
530             if (detail_level >= EVLOG_PRINT_DETAIL)
531             {
532                 const char *destKind;
533                 char  ddestKind[10];
534
535                 switch (stuff->destKind)
536                 {
537                     case ShapeBounding:  destKind = "ShapeBounding"; break;
538                     case ShapeClip:  destKind = "ShapeClip"; break;
539                     case ShapeInput:  destKind = "ShapeInput"; break;
540                     default:  destKind = ddestKind; snprintf (ddestKind, 10, "%d", stuff->destKind); break;
541                 }
542
543                 REPLY (" destKind(%s)",
544                     destKind);
545             }
546
547             return reply;
548         }
549
550     case X_ShapeQueryExtents:
551         {
552             xShapeQueryExtentsReq *stuff = (xShapeQueryExtentsReq *)req;
553             REPLY (": XID(0x%lx)",
554                 stuff->window);
555
556             return reply;
557         }
558
559     case X_ShapeSelectInput:
560         {
561             xShapeSelectInputReq *stuff = (xShapeSelectInputReq *)req;
562             REPLY (": XID(0x%lx)",
563                 stuff->window);
564
565             if (detail_level >= EVLOG_PRINT_DETAIL)
566             {
567                 REPLY (" enable(%s)",
568                     stuff->enable ? "YES" : "NO");
569             }
570
571             return reply;
572         }
573
574     case X_ShapeInputSelected:
575         {
576             xShapeInputSelectedReq *stuff = (xShapeInputSelectedReq *)req;
577             REPLY (": XID(0x%lx)",
578                 stuff->window);
579
580             return reply;
581         }
582
583     case X_ShapeGetRectangles:
584         {
585             xShapeGetRectanglesReq *stuff = (xShapeGetRectanglesReq *)req;
586             REPLY (": XID(0x%lx)",
587                 stuff->window);
588
589             if (detail_level >= EVLOG_PRINT_DETAIL)
590             {
591                 const char *kind;
592                 char  dkind[10];
593
594                 switch (stuff->kind)
595                 {
596                     case ShapeBounding:  kind = "ShapeBounding"; break;
597                     case ShapeClip:  kind = "ShapeClip"; break;
598                     case ShapeInput:  kind = "ShapeInput"; break;
599                     default:  kind = dkind; snprintf (dkind, 10, "%d", stuff->kind); break;
600                 }
601
602                 REPLY (" kind(%s)",
603                     kind);
604             }
605
606             return reply;
607         }
608
609     default:
610             break;
611     }
612
613     return reply;
614 }
615
616 static char *
617 _EvlogEventXextDpms (EvlogInfo *evinfo, int first_base, int detail_level, char *reply, int *len)
618 {
619 #if 0
620     xEvent *evt = evinfo->evt.ptr;
621
622     switch ((evt->u.u.type & 0x7F) - first_base)
623     {
624
625     default:
626             break;
627     }
628 #endif
629     return reply;
630 }
631
632
633 static char *
634 _EvlogEventXextShm (EvlogInfo *evinfo, int first_base, int detail_level, char *reply, int *len)
635 {
636     xEvent *evt = evinfo->evt.ptr;
637
638     switch ((evt->u.u.type & 0x7F) - first_base)
639     {
640     case ShmCompletion:
641         {
642             xShmCompletionEvent *stuff = (xShmCompletionEvent *) evt;
643             REPLY (": XID(0x%lx)",
644                 stuff->drawable);
645
646             if (detail_level >= EVLOG_PRINT_DETAIL)
647             {
648                 REPLY (" sequence_num(%d) major_event(%d) minor_event(%d) shmseg(0x%lx) offset(%ld)",
649                     stuff->sequenceNumber,
650                     stuff->majorEvent,
651                     stuff->minorEvent,
652                     stuff->shmseg,
653                     stuff->offset);
654             }
655             return reply;
656         }
657
658     default:
659             break;
660     }
661
662     return reply;
663 }
664
665
666 static char *
667 _EvlogEventXextSync (EvlogInfo *evinfo, int first_base, int detail_level, char *reply, int *len)
668 {
669     xEvent *evt = evinfo->evt.ptr;
670
671     switch ((evt->u.u.type & 0x7F) - first_base)
672     {
673     case XSyncCounterNotify:
674         {
675             xSyncCounterNotifyEvent *stuff = (xSyncCounterNotifyEvent *) evt;
676             REPLY (": XID(0x%lx) WaitValue(0x%lx/0x%lx) CounterValue(0x%lx/0x%lx)",
677                 stuff->counter,
678                 stuff->wait_value_hi,
679                 stuff->wait_value_lo,
680                 stuff->counter_value_hi,
681                 stuff->counter_value_lo);
682
683             if (detail_level >= EVLOG_PRINT_DETAIL)
684             {
685                 REPLY ("\n");
686                 REPLY ("%67s sequence_num(%d) time(%lums) count(%d) destroyed(%s)",
687                     " ",
688                     stuff->sequenceNumber,
689                     stuff->time,
690                     stuff->count,
691                     stuff->destroyed ? "YES" : "NO");
692             }
693
694             return reply;
695         }
696
697     case XSyncAlarmNotify:
698         {
699             xSyncAlarmNotifyEvent *stuff = (xSyncAlarmNotifyEvent *) evt;
700             REPLY (": XID(0x%lx) CounterValue(0x%lx/0x%lx) AlarmValue(0x%lx/0x%lx)",
701                 stuff->alarm,
702                 stuff->counter_value_hi,
703                 stuff->counter_value_lo,
704                 stuff->alarm_value_hi,
705                 stuff->alarm_value_lo);
706
707             if (detail_level >= EVLOG_PRINT_DETAIL)
708             {
709                 REPLY ("\n");
710                 REPLY ("%67s sequence_num(%d) time(%lums) state(%d)",
711                     " ",
712                     stuff->sequenceNumber,
713                     stuff->time,
714                     stuff->state);
715             }
716
717             return reply;
718         }
719
720     default:
721             break;
722     }
723
724     return reply;
725 }
726
727
728 static char *
729 _EvlogEventXextXtestExt1 (EvlogInfo *evinfo, int first_base, int detail_level, char *reply, int *len)
730 {
731     xEvent *evt = evinfo->evt.ptr;
732
733     switch ((evt->u.u.type & 0x7F) - first_base)
734     {
735
736     default:
737             break;
738     }
739
740     return reply;
741 }
742
743 static char *
744 _EvlogEventXextXtest (EvlogInfo *evinfo, int first_base, int detail_level, char *reply, int *len)
745 {
746     xEvent *evt = evinfo->evt.ptr;
747
748     switch ((evt->u.u.type & 0x7F) - first_base)
749     {
750
751     default:
752             break;
753     }
754
755     return reply;
756 }
757
758 static char *
759 _EvlogEventXextShape (EvlogInfo *evinfo, int first_base, int detail_level, char *reply, int *len)
760 {
761     xEvent *evt = evinfo->evt.ptr;
762
763     switch ((evt->u.u.type & 0x7F) - first_base)
764     {
765     case ShapeNotify:
766         {
767             xShapeNotifyEvent *stuff = (xShapeNotifyEvent *) evt;
768             REPLY (": XID(0x%lx) coord(%d,%d %dx%d)",
769                 stuff->window,
770                 stuff->x,
771                 stuff->y,
772                 stuff->width,
773                 stuff->height);
774
775             if (detail_level >= EVLOG_PRINT_DETAIL)
776             {
777                 const char *kind;
778                 char dkind[10];
779
780                 switch (stuff->kind)
781                 {
782                     case ShapeBounding:  kind = "ShapeBounding"; break;
783                     case ShapeClip:  kind = "ShapeClip"; break;
784                     case ShapeInput:  kind = "ShapeInput"; break;
785                     default:  kind = dkind; snprintf (dkind, 10, "%d", stuff->kind); break;
786                 }
787
788
789                 REPLY ("\n");
790                 REPLY ("%67s kind(%s) sequence_num(%d) time(%lums) shaped(%s)",
791                     " ",
792                     kind,
793                     stuff->sequenceNumber,
794                     stuff->time,
795                     stuff->shaped ? "EXIST" : "NON_EXIST");
796             }
797
798             return reply;
799         }
800
801     default:
802             break;
803     }
804
805     return reply;
806 }
807
808 static char *
809 _EvlogReplyXextDpms (EvlogInfo *evinfo, int detail_level, char *reply, int *len)
810 {
811     xGenericReply *rep = evinfo->rep.ptr;
812
813     switch (evinfo->rep.reqData)
814     {
815     case X_DPMSSetTimeouts:
816         {
817             if (evinfo->rep.isStart)
818             {
819                 xDPMSGetTimeoutsReply *stuff = (xDPMSGetTimeoutsReply *)rep;
820                 REPLY (": Standby(%usec) Suspend(%usec) off(%usec) sequence_num(%d)",
821                     stuff->standby,
822                     stuff->suspend,
823                     stuff->off,
824                     stuff->sequenceNumber);
825             }
826             else
827             {
828                 return reply;
829             }
830
831             return reply;
832         }
833
834     default:
835             break;
836     }
837
838     return reply;
839 }
840
841 static char *
842 _EvlogReplyXextShm (EvlogInfo *evinfo, int detail_level, char *reply, int *len)
843 {
844     xGenericReply *rep = evinfo->rep.ptr;
845
846     switch (evinfo->rep.reqData)
847     {
848     case X_ShmGetImage:
849         {
850             if (evinfo->rep.isStart)
851             {
852                 xShmGetImageReply *stuff = (xShmGetImageReply *)rep;
853                 REPLY (": Visual(0x%lx) size(%ld) sequence_num(%d)",
854                     stuff->visual,
855                     stuff->size,
856                     stuff->sequenceNumber);
857             }
858             else
859             {
860                 return reply;
861             }
862
863             return reply;
864         }
865
866     default:
867             break;
868     }
869
870     return reply;
871 }
872
873 static char *
874 _EvlogReplyXextSync (EvlogInfo *evinfo, int detail_level, char *reply, int *len)
875 {
876     xGenericReply *rep = evinfo->rep.ptr;
877
878     switch (evinfo->rep.reqData)
879     {
880         case X_SyncQueryCounter:
881         {
882             if (evinfo->rep.isStart)
883             {
884                 xSyncQueryCounterReply *stuff = (xSyncQueryCounterReply *)rep;
885                 REPLY (": Value(%ld/%ld) sequence_num(%d)",
886                     stuff->value_hi,
887                     stuff->value_lo,
888                     stuff->sequenceNumber);
889             }
890             else
891             {
892                 return reply;
893             }
894
895             return reply;
896         }
897
898     default:
899             break;
900     }
901
902     return reply;
903 }
904
905 static char *
906 _EvlogReplyXextXtestExt1 (EvlogInfo *evinfo, int detail_level, char *reply, int *len)
907 {
908     xGenericReply *rep = evinfo->rep.ptr;
909
910     switch (evinfo->rep.reqData)
911     {
912         case X_TestQueryInputSize:
913         {
914             if (evinfo->rep.isStart)
915             {
916                 xTestQueryInputSizeReply *stuff = (xTestQueryInputSizeReply *)rep;
917                 REPLY (": sizeReturn(0x%lx) sequence_num(%d)",
918                     stuff->size_return,
919                     stuff->sequenceNumber);
920             }
921             else
922             {
923                 return reply;
924             }
925
926             return reply;
927         }
928
929     default:
930             break;
931     }
932
933     return reply;
934 }
935
936 static char *
937 _EvlogReplyXextXtest (EvlogInfo *evinfo, int detail_level, char *reply, int *len)
938 {
939     xGenericReply *rep = evinfo->rep.ptr;
940
941     switch (evinfo->rep.reqData)
942     {
943     case X_XTestGetVersion:
944         {
945             if (evinfo->rep.isStart)
946             {
947                 xXTestGetVersionReply *stuff = (xXTestGetVersionReply *)rep;
948                 REPLY (": MinorVersion(%d) sequence_num(%d)",
949                     stuff->minorVersion,
950                     stuff->sequenceNumber);
951             }
952             else
953             {
954                 return reply;
955             }
956
957             return reply;
958         }
959
960     default:
961             break;
962     }
963
964     return reply;
965 }
966
967 static char *
968 _EvlogReplyXextShape(EvlogInfo *evinfo, int detail_level, char *reply, int *len)
969 {
970     xGenericReply *rep = evinfo->rep.ptr;
971
972     switch (evinfo->rep.reqData)
973     {
974     case X_ShapeQueryVersion:
975         {
976             if (evinfo->rep.isStart)
977             {
978                 xShapeQueryVersionReply *stuff = (xShapeQueryVersionReply *)rep;
979                 REPLY (": MajorVersion(%d) MinorVersion(%d)",
980                     stuff->majorVersion,
981                     stuff->minorVersion);
982             }
983             else
984             {
985                 return reply;
986             }
987
988             return reply;
989         }
990
991     case X_ShapeQueryExtents:
992         {
993             if (evinfo->rep.isStart)
994             {
995                 xShapeQueryExtentsReply *stuff = (xShapeQueryExtentsReply *)rep;
996
997                 REPLY (": bounding_shaped(%s)",
998                     stuff->boundingShaped ? "YES" : "NO");
999
1000                 if (stuff->boundingShaped)
1001                     REPLY (" bounding(%d,%d %dx%d)",
1002                         stuff->xClipShape,
1003                         stuff->yClipShape,
1004                         stuff->widthClipShape,
1005                         stuff->heightClipShape);
1006                 else
1007                     REPLY (" bounding(None)");
1008
1009
1010                 REPLY (" clip_shaped(%s)",
1011                     stuff->clipShaped ? "YES" : "NO");
1012
1013                 if (stuff->boundingShaped)
1014                     REPLY (" clip(%d,%d %dx%d)",
1015                         stuff->xBoundingShape,
1016                         stuff->yBoundingShape,
1017                         stuff->widthBoundingShape,
1018                         stuff->heightBoundingShape);
1019                 else
1020                     REPLY (" clip(None)");
1021
1022             }
1023             else
1024             {
1025                 return reply;
1026             }
1027
1028             return reply;
1029         }
1030
1031     case X_ShapeInputSelected:
1032         {
1033             if (evinfo->rep.isStart)
1034             {
1035                 xShapeInputSelectedReply *stuff = (xShapeInputSelectedReply *)rep;
1036
1037                 REPLY (" enable(%s)",
1038                     stuff->enabled ? "YES" : "NO");
1039             }
1040             else
1041             {
1042                 return reply;
1043             }
1044
1045             return reply;
1046         }
1047
1048     case X_ShapeGetRectangles:
1049         {
1050             if (evinfo->rep.isStart)
1051             {
1052                 xShapeGetRectanglesReply *stuff = (xShapeGetRectanglesReply *)rep;
1053
1054                 const char *ordering;
1055                 char dordering[10];
1056
1057                 switch (stuff->ordering)
1058                 {
1059                     case Unsorted:  ordering = "Unsorted"; break;
1060                     case YSorted:  ordering = "YSorted"; break;
1061                     case YXSorted:  ordering = "YXSorted"; break;
1062                     case YXBanded:  ordering = "YXBanded"; break;
1063                     default:  ordering = dordering; snprintf (dordering, 10, "%d", stuff->ordering); break;
1064                 }
1065                 REPLY (": ordering(%s) nrects(%ld)",
1066                     ordering,
1067                     stuff->nrects);
1068             }
1069             else
1070             {
1071                 xRectangle *stuff = (xRectangle *)rep;
1072                 int i;
1073
1074                 REPLY ("Region");
1075                 REPLY ("(");
1076                 for (i = 0 ; i < evinfo->rep.size / sizeof(xRectangle) ; i ++)
1077                 {
1078                     REPLY ("[%d,%d %dx%d]",
1079                         stuff->x,
1080                         stuff->y,
1081                         stuff->width,
1082                         stuff->height);
1083
1084                     if(i != evinfo->rep.size / sizeof(xRectangle) - 1)
1085                         REPLY (", ");
1086                 }
1087                 REPLY (")");
1088
1089                 return reply;
1090             }
1091
1092             return reply;
1093         }
1094
1095     default:
1096             break;
1097     }
1098
1099     return reply;
1100 }
1101
1102 void
1103 xDbgEvlogXextDpmsGetBase (ExtensionInfo *extinfo)
1104 {
1105 #ifdef XDBG_CLIENT
1106     RETURN_IF_FAIL (extinfo != NULL);
1107
1108     extinfo->req_func = _EvlogRequestXextDpms;
1109     extinfo->evt_func = _EvlogEventXextDpms;
1110     extinfo->rep_func = _EvlogReplyXextDpms;
1111 #else
1112     ExtensionEntry *xext = CheckExtension (DPMSExtensionName);
1113     RETURN_IF_FAIL (xext != NULL);
1114     RETURN_IF_FAIL (extinfo != NULL);
1115
1116     extinfo->opcode = xext->base;
1117     extinfo->evt_base = xext->eventBase;
1118     extinfo->err_base = xext->errorBase;
1119     extinfo->req_func = _EvlogRequestXextDpms;
1120     extinfo->evt_func = _EvlogEventXextDpms;
1121     extinfo->rep_func = _EvlogReplyXextDpms;
1122 #endif
1123 }
1124
1125
1126 void
1127 xDbgEvlogXextShmGetBase (ExtensionInfo *extinfo)
1128 {
1129 #ifdef XDBG_CLIENT
1130     RETURN_IF_FAIL (extinfo != NULL);
1131
1132     extinfo->req_func = _EvlogRequestXextShm;
1133     extinfo->evt_func = _EvlogEventXextShm;
1134     extinfo->rep_func = _EvlogReplyXextShm;
1135 #else
1136     ExtensionEntry *xext = CheckExtension (SHMNAME);
1137     RETURN_IF_FAIL (xext != NULL);
1138     RETURN_IF_FAIL (extinfo != NULL);
1139
1140     extinfo->opcode = xext->base;
1141     extinfo->evt_base = xext->eventBase;
1142     extinfo->err_base = xext->errorBase;
1143     extinfo->req_func = _EvlogRequestXextShm;
1144     extinfo->evt_func = _EvlogEventXextShm;
1145     extinfo->rep_func = _EvlogReplyXextShm;
1146 #endif
1147 }
1148
1149
1150 void
1151 xDbgEvlogXextSyncGetBase (ExtensionInfo *extinfo)
1152 {
1153 #ifdef XDBG_CLIENT
1154     RETURN_IF_FAIL (extinfo != NULL);
1155
1156     extinfo->req_func = _EvlogRequestXextSync;
1157     extinfo->evt_func = _EvlogEventXextSync;
1158     extinfo->rep_func = _EvlogReplyXextSync;
1159 #else
1160     ExtensionEntry *xext = CheckExtension (SYNC_NAME);
1161     RETURN_IF_FAIL (xext != NULL);
1162     RETURN_IF_FAIL (extinfo != NULL);
1163
1164     extinfo->opcode = xext->base;
1165     extinfo->evt_base = xext->eventBase;
1166     extinfo->err_base = xext->errorBase;
1167     extinfo->req_func = _EvlogRequestXextSync;
1168     extinfo->evt_func = _EvlogEventXextSync;
1169     extinfo->rep_func = _EvlogReplyXextSync;
1170 #endif
1171
1172 }
1173
1174
1175 void
1176 xDbgEvlogXextXtestExt1GetBase (ExtensionInfo *extinfo)
1177 {
1178 #ifdef XDBG_CLIENT
1179     RETURN_IF_FAIL (extinfo != NULL);
1180
1181     extinfo->req_func = _EvlogRequestXextXtestExt1;
1182     extinfo->evt_func = _EvlogEventXextXtestExt1;
1183     extinfo->rep_func = _EvlogReplyXextXtestExt1;
1184 #else
1185     ExtensionEntry *xext = CheckExtension (XTestEXTENSION_NAME);
1186     RETURN_IF_FAIL (xext != NULL);
1187     RETURN_IF_FAIL (extinfo != NULL);
1188
1189     extinfo->opcode = xext->base;
1190     extinfo->evt_base = xext->eventBase;
1191     extinfo->err_base = xext->errorBase;
1192     extinfo->req_func = _EvlogRequestXextXtestExt1;
1193     extinfo->evt_func = _EvlogEventXextXtestExt1;
1194     extinfo->rep_func = _EvlogReplyXextXtestExt1;
1195 #endif
1196
1197 }
1198
1199
1200 void
1201 xDbgEvlogXextXtestGetBase (ExtensionInfo *extinfo)
1202 {
1203 #ifdef XDBG_CLIENT
1204     RETURN_IF_FAIL (extinfo != NULL);
1205
1206     extinfo->req_func = _EvlogRequestXextXtest;
1207     extinfo->evt_func = _EvlogEventXextXtest;
1208     extinfo->rep_func = _EvlogReplyXextXtest;
1209 #else
1210     ExtensionEntry *xext = CheckExtension (XTestExtensionName);
1211     RETURN_IF_FAIL (xext != NULL);
1212     RETURN_IF_FAIL (extinfo != NULL);
1213
1214     extinfo->opcode = xext->base;
1215     extinfo->evt_base = xext->eventBase;
1216     extinfo->err_base = xext->errorBase;
1217     extinfo->req_func = _EvlogRequestXextXtest;
1218     extinfo->evt_func = _EvlogEventXextXtest;
1219     extinfo->rep_func = _EvlogReplyXextXtest;
1220 #endif
1221 }
1222
1223 void
1224 xDbgEvlogXextShapeGetBase (ExtensionInfo *extinfo)
1225 {
1226 #ifdef XDBG_CLIENT
1227     RETURN_IF_FAIL (extinfo != NULL);
1228
1229     extinfo->req_func = _EvlogRequestXextShape;
1230     extinfo->evt_func = _EvlogEventXextShape;
1231     extinfo->rep_func = _EvlogReplyXextShape;
1232 #else
1233     ExtensionEntry *xext = CheckExtension (SHAPENAME);
1234     RETURN_IF_FAIL (xext != NULL);
1235     RETURN_IF_FAIL (extinfo != NULL);
1236
1237     extinfo->opcode = xext->base;
1238     extinfo->evt_base = xext->eventBase;
1239     extinfo->err_base = xext->errorBase;
1240     extinfo->req_func = _EvlogRequestXextShape;
1241     extinfo->evt_func = _EvlogEventXextShape;
1242     extinfo->rep_func = _EvlogReplyXextShape;
1243 #endif
1244 }