Initialize Tizen 2.3
[adaptation/xorg/driver/xserver-xorg-module-xdbg.git] / common / xdbg_evlog_event.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 "xdbg_types.h"
56 #include "xdbg_evlog.h"
57 #include "xdbg_evlog_event.h"
58
59
60 #define UNKNOWN_EVENT "<unknown>"
61
62
63 char *
64 xDbgEvlogEvent (EvlogInfo *evinfo, int detail_level, char *reply, int *len)
65 {
66     extern ExtensionInfo* Sorted_Evlog_extensions;
67     extern int Extensions_size;
68     EvlogEvent ev;
69     xEvent *xEvt = NULL;
70     int type;
71
72     RETURN_VAL_IF_FAIL (evinfo != NULL, reply);
73     RETURN_VAL_IF_FAIL (evinfo->type == EVENT, reply);
74
75     ev = evinfo->evt;
76     xEvt = ev.ptr;
77     type = xEvt->u.u.type;
78
79     REPLY ("%s", ev.name);
80
81     if (type > 0x7F)
82         REPLY ("(U)");
83     else
84         REPLY ("(S)");
85
86     type &= 0x7F;
87
88     if (type < EXTENSION_EVENT_BASE)
89     {
90         return xDbgEvlogEventCore (evinfo, detail_level, reply, len);
91     }
92     else
93     {
94         int i;
95
96         for (i = 0 ; i < Extensions_size ; i++)
97         {
98             if (Sorted_Evlog_extensions[i].evt_base == 0)
99                 continue;
100
101             if (i != Extensions_size - 1)
102             {
103                 if (type >= Sorted_Evlog_extensions[i].evt_base &&
104                      type < Sorted_Evlog_extensions[i+1].evt_base)
105                 {
106                     return Sorted_Evlog_extensions[i].evt_func (evinfo, Sorted_Evlog_extensions[i].evt_base, detail_level, reply, len);
107                 }
108                 continue;
109             }
110
111             return Sorted_Evlog_extensions[i].evt_func (evinfo, Sorted_Evlog_extensions[i].evt_base, detail_level, reply, len);
112         }
113
114     }
115
116     return reply;
117 }