1 /**************************************************************************
5 Copyright (c) 2013 Samsung Electronics Co., Ltd All Rights Reserved
7 Contact: Boram Park <boram1288.park@samsung.com>
8 Sangjin LEE <lsj119@samsung.com>
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:
18 The above copyright notice and this permission notice (including the
19 next paragraph) shall be included in all copies or substantial portions
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.
30 **************************************************************************/
32 #ifndef __XDBG_TYPES_H__
33 #define __XDBG_TYPES_H__
38 #include <X11/Xdefs.h> /* for Bool */
40 #include <X11/extensions/Xfixes.h>
44 #define XDBG_PATH_MAX 1024
45 #define XDBG_BUF_SIZE 64
47 #define MAX(a,b) (((a) > (b)) ? (a) : (b))
48 #define MIN(a,b) (((a) < (b)) ? (a) : (b))
49 #define SWAP(a, b) ({int t; t = a; a = b; b = t;})
51 #define WARNING_IF_FAIL(cond) \
52 {if (!(cond)) { fprintf (stderr, "[%s] '%s' failed.\n", __FUNCTION__, #cond);}}
53 #define RETURN_IF_FAIL(cond) \
54 {if (!(cond)) { fprintf (stderr, "[%s] '%s' failed.\n", __FUNCTION__, #cond); return; }}
55 #define RETURN_VAL_IF_FAIL(cond, val) \
56 {if (!(cond)) { fprintf (stderr, "[%s] '%s' failed.\n", __FUNCTION__, #cond); return val; }}
57 #define RETURN_VAL_IF_ERRNO(cond, val, errno) \
58 {if (!(cond)) { fprintf (stderr, "[%s] '%s' failed. (err=%s(%d))\n", __FUNCTION__, #cond, strerror(errno), errno); return val; }}
59 #define GOTO_IF_FAIL(cond, dst) \
60 {if (!(cond)) { fprintf (stderr, "[%s] '%s' failed.\n", __FUNCTION__, #cond); goto dst; }}
61 #define GOTO_IF_ERRNO(cond, dst, errno) \
62 {if (!(cond)) { fprintf (stderr, "[%s] '%s' failed. (err=%s(%d))\n", __FUNCTION__, #cond, strerror(errno), errno); goto dst; }}
64 #define XDBG_LOG(fmt, ARG...) { fprintf (stderr, fmt, ##ARG); }
66 #define REPLY(fmt, ARG...) \
68 if (reply && len && *len > 0) \
70 int s = snprintf (reply, *len, fmt, ##ARG); \
76 #define UNKNOWN_EVENT "<unknown>"
87 #define EVLOG_MASK_CLIENT (1<<0)
88 #define EVLOG_MASK_REQUEST (1<<1)
89 #define EVLOG_MASK_EVENT (1<<2)
90 #define EVLOG_MASK_REPLY (1<<3)
91 #define EVLOG_MASK_ERROR (1<<4)
92 #define EVLOG_MASK_ATOM (1<<5)
93 #define EVLOG_MASK_REGION (1<<6)
95 #define EVLOG_PRINT_DEFAULT 0
96 #define EVLOG_PRINT_DETAIL 1
97 #define EVLOG_PRINT_REPLY_DETAIL 2
100 typedef struct _EvlogTable
103 char buf[XDBG_BUF_SIZE];
104 struct xorg_list link;
105 } EvlogAtomTable, EvlogRegionTable;
107 typedef struct _EvlogList
109 struct xorg_list list;
112 } EvlogAtom, EvlogRegion;
114 typedef struct _EvlogClient
120 char command[PATH_MAX+1];
124 typedef struct _EvlogRequest
129 char name[PATH_MAX+1];
132 typedef struct _EvlogEvent
136 char name[PATH_MAX+1];
139 typedef struct _EvlogReply
143 char name[PATH_MAX+1];
149 typedef struct _EvlogError
157 typedef struct _EvlogInfo
168 EvlogRegion evregion;
174 typedef struct _ExtensionInfo ExtensionInfo;
176 struct _ExtensionInfo
178 void (*get_base_func) (ExtensionInfo *extinfo);
182 char* (*req_func) (EvlogInfo *evinfo, int detail_level, char *reply, int *len);
183 char* (*evt_func) (EvlogInfo *evinfo, int first_base, int detail_level, char *reply, int *len);
184 char* (*rep_func) (EvlogInfo *evinfo, int detail_level, char *reply, int *len);