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>"
88 #define EVLOG_MASK_CLIENT (1<<0)
89 #define EVLOG_MASK_REQUEST (1<<1)
90 #define EVLOG_MASK_EVENT (1<<2)
91 #define EVLOG_MASK_REPLY (1<<3)
92 #define EVLOG_MASK_ERROR (1<<4)
93 #define EVLOG_MASK_ATOM (1<<5)
94 #define EVLOG_MASK_REGION (1<<6)
96 #define EVLOG_PRINT_DEFAULT 0
97 #define EVLOG_PRINT_DETAIL 1
98 #define EVLOG_PRINT_REPLY_DETAIL 2
101 typedef struct _EvlogTable
104 char buf[XDBG_BUF_SIZE];
105 struct xorg_list link;
106 } EvlogAtomTable, EvlogRegionTable;
108 typedef struct _EvlogList
110 struct xorg_list list;
113 } EvlogAtom, EvlogRegion;
115 typedef struct _EvlogClient
121 char command[PATH_MAX+1];
125 typedef struct _EvlogRequest
130 char name[PATH_MAX+1];
133 typedef struct _EvlogEvent
137 char name[PATH_MAX+1];
140 typedef struct _EvlogReply
144 char name[PATH_MAX+1];
150 typedef struct _EvlogError
152 char errorName[PATH_MAX+1];
153 char majorName[PATH_MAX+1];
160 typedef struct _EvlogInfo
171 EvlogRegion evregion;
177 typedef struct _ExtensionInfo ExtensionInfo;
179 struct _ExtensionInfo
181 void (*get_base_func) (ExtensionInfo *extinfo);
185 char* (*req_func) (EvlogInfo *evinfo, int detail_level, char *reply, int *len);
186 char* (*evt_func) (EvlogInfo *evinfo, int first_base, int detail_level, char *reply, int *len);
187 char* (*rep_func) (EvlogInfo *evinfo, int detail_level, char *reply, int *len);