Tizen 2.1 release
[platform/core/uifw/e17.git] / src / bin / e.h
1 #ifndef E_H
2 # define E_H
3
4 /**
5  * @defgroup API Enlightenment API
6  *
7  * Application programming interface to be used by modules to extend
8  * Enlightenment.
9  *
10  * @{
11  */
12
13 # ifdef HAVE_CONFIG_H
14 #  include "config.h"
15 # endif
16
17 # define USE_IPC
18 # if 0
19 #  define OBJECT_PARANOIA_CHECK
20 #  define OBJECT_CHECK
21 # endif
22
23 # ifndef _FILE_OFFSET_BITS
24 #  define _FILE_OFFSET_BITS 64
25 # endif
26
27 # ifdef HAVE_ALLOCA_H
28 #  include <alloca.h>
29 # elif defined __GNUC__
30 #  define alloca __builtin_alloca
31 # elif defined _AIX
32 #  define alloca __alloca
33 # elif defined _MSC_VER
34 #  include <malloc.h>
35 #  define alloca _alloca
36 # else
37 #  include <stddef.h>
38 #  ifdef  __cplusplus
39 extern "C"
40 #  endif
41 void *alloca(size_t);
42 # endif
43
44 # ifdef __linux__
45 #  include <features.h>
46 # endif
47
48 # include <stdio.h>
49 # include <stdlib.h>
50 # include <unistd.h>
51 # include <string.h>
52 # include <sys/types.h>
53 # include <sys/stat.h>
54 # include <sys/time.h>
55 # include <sys/param.h>
56 # include <sys/resource.h>
57 # include <utime.h>
58 # include <dlfcn.h>
59 # include <math.h>
60 # include <fcntl.h>
61 # include <fnmatch.h>
62 # include <limits.h>
63 # include <ctype.h>
64 # include <time.h>
65 # include <dirent.h>
66 # include <pwd.h>
67 # include <grp.h>
68 # include <glob.h>
69 # include <locale.h>
70 # include <errno.h>
71 # include <signal.h>
72 # include <inttypes.h>
73
74 # ifdef HAVE_GETTEXT
75 #  include <libintl.h>
76 # endif
77
78 # ifndef _POSIX_HOST_NAME_MAX
79 #  define _POSIX_HOST_NAME_MAX 255
80 # endif
81
82 # ifdef HAVE_VALGRIND
83 #  include <memcheck.h>
84 # endif
85
86 # ifdef __GLIBC__
87 #  include <execinfo.h>
88 # endif
89
90 # include <setjmp.h>
91 # include <Eina.h>
92 # include <Eet.h>
93 # include <Evas.h>
94 # include <Evas_Engine_Buffer.h>
95 # include <Ecore.h>
96 # include <Ecore_X.h>
97 # include <Ecore_Evas.h>
98 # include <Ecore_Input.h>
99 # include <Ecore_Input_Evas.h>
100 # include <Ecore_Con.h>
101 # include <Ecore_Ipc.h>
102 # include <Ecore_File.h>
103 # include <Efreet.h>
104 # include <Efreet_Mime.h>
105 # include <Edje.h>
106 # include <E_DBus.h>
107 # include <Eio.h>
108
109 # ifdef HAVE_HAL
110 #  include <E_Hal.h>
111 # endif
112
113 # ifdef EAPI
114 #  undef EAPI
115 # endif
116 # ifdef WIN32
117 #  ifdef BUILDING_DLL
118 #   define EAPI __declspec(dllexport)
119 #  else
120 #   define EAPI __declspec(dllimport)
121 #  endif
122 # else
123 #  ifdef __GNUC__
124 #   if __GNUC__ >= 4
125 /* BROKEN in gcc 4 on amd64 */
126 #    if 0
127 #     pragma GCC visibility push(hidden)
128 #    endif
129 #    define EAPI __attribute__ ((visibility("default")))
130 #   else
131 #    define EAPI
132 #   endif
133 #  else
134 #   define EAPI
135 #  endif
136 # endif
137
138 # ifdef EINTERN
139 #  undef EINTERN
140 # endif
141 # ifdef __GNUC__
142 #  if __GNUC__ >= 4
143 #   define EINTERN __attribute__ ((visibility("hidden")))
144 #  else
145 #   define EINTERN
146 #  endif
147 # else
148 #  define EINTERN
149 # endif
150
151 #ifndef strdupa
152 # define strdupa(str)       strcpy(alloca(strlen(str) + 1), str)
153 #endif
154
155 #ifndef strndupa
156 # define strndupa(str, len) strncpy(alloca(len + 1), str, len)
157 #endif
158
159 typedef struct _E_Before_Idler E_Before_Idler;
160 typedef struct _E_Rect         E_Rect;
161
162 /* convenience macro to compress code and avoid typos */
163 # define E_FN_DEL(_fn, _h) if (_h) { _fn(_h); _h = NULL; }
164 # define E_INTERSECTS(x, y, w, h, xx, yy, ww, hh) \
165   (((x) < ((xx) + (ww))) && ((y) < ((yy) + (hh))) && (((x) + (w)) > (xx)) && (((y) + (h)) > (yy)))
166 # define E_INSIDE(x, y, xx, yy, ww, hh) \
167   (((x) < ((xx) + (ww))) && ((y) < ((yy) + (hh))) && ((x) >= (xx)) && ((y) >= (yy)))
168 # define E_CONTAINS(x, y, w, h, xx, yy, ww, hh) \
169   (((xx) >= (x)) && (((x) + (w)) >= ((xx) + (ww))) && ((yy) >= (y)) && (((y) + (h)) >= ((yy) + (hh))))
170 # define E_SPANS_COMMON(x1, w1, x2, w2) \
171   (!((((x2) + (w2)) <= (x1)) || ((x2) >= ((x1) + (w1)))))
172 # define E_REALLOC(p, s, n)   p = (s *)realloc(p, sizeof(s) * n)
173 # define E_NEW(s, n)          (s *)calloc(n, sizeof(s))
174 # define E_NEW_RAW(s, n)      (s *)malloc(n * sizeof(s))
175 # define E_FREE(p)            do { free(p); p = NULL; } while (0)
176 # define E_FREE_LIST(list, free)    \
177   do                                \
178     {                               \
179        void *_tmp_;                 \
180        EINA_LIST_FREE(list, _tmp_) \
181          {                          \
182             free(_tmp_);            \
183          }                          \
184     }                               \
185   while (0)
186
187 # define E_LIST_HANDLERS_APPEND(list, type, callback, data) \
188   do \
189     { \
190        Ecore_Event_Handler *_eh; \
191        _eh = ecore_event_handler_add(type, (Ecore_Event_Handler_Cb)callback, data); \
192        if (_eh) \
193          list = eina_list_append(list, _eh); \
194        else \
195          ERR("E_LIST_HANDLERS_APPEND"); \
196     } \
197   while (0)
198
199 # define E_CLAMP(x, min, max) (x < min ? min : (x > max ? max : x))
200 # define E_RECTS_CLIP_TO_RECT(_x, _y, _w, _h, _cx, _cy, _cw, _ch) \
201   {                                                               \
202      if (E_INTERSECTS(_x, _y, _w, _h, _cx, _cy, _cw, _ch))        \
203        {                                                          \
204           if ((int)_x < (int)(_cx))                               \
205             {                                                     \
206                _w += _x - (_cx);                                  \
207                _x = (_cx);                                        \
208                if ((int)_w < 0) _w = 0;                           \
209             }                                                     \
210           if ((int)(_x + _w) > (int)((_cx) + (_cw)))              \
211             _w = (_cx) + (_cw) - _x;                              \
212           if ((int)_y < (int)(_cy))                               \
213             {                                                     \
214                _h += _y - (_cy);                                  \
215                _y = (_cy);                                        \
216                if ((int)_h < 0) _h = 0;                           \
217             }                                                     \
218           if ((int)(_y + _h) > (int)((_cy) + (_ch)))              \
219             _h = (_cy) + (_ch) - _y;                              \
220        }                                                          \
221      else                                                         \
222        {                                                          \
223           _w = 0; _h = 0;                                         \
224        }                                                          \
225   }
226
227 # define E_REMOTE_OPTIONS 1
228 # define E_REMOTE_OUT     2
229 # define E_WM_IN          3
230 # define E_REMOTE_IN      4
231 # define E_ENUM           5
232 # define E_LIB_IN         6
233
234 # define E_TYPEDEFS       1
235 # include "e_includes.h"
236 # undef E_TYPEDEFS
237 # include "e_includes.h"
238
239 EAPI E_Before_Idler *e_main_idler_before_add(int (*func)(void *data), void *data, int once);
240 EAPI void            e_main_idler_before_del(E_Before_Idler *eb);
241 EAPI double          e_main_ts(const char *str);
242
243 struct _E_Before_Idler
244 {
245    int       (*func)(void *data);
246    void     *data;
247    Eina_Bool once : 1;
248    Eina_Bool delete_me : 1;
249 };
250
251 struct _E_Rect
252 {
253    int x, y, w, h;
254 };
255
256 extern EAPI E_Path *path_data;
257 extern EAPI E_Path *path_images;
258 extern EAPI E_Path *path_fonts;
259 extern EAPI E_Path *path_themes;
260 extern EAPI E_Path *path_icons;
261 extern EAPI E_Path *path_modules;
262 extern EAPI E_Path *path_backgrounds;
263 extern EAPI E_Path *path_messages;
264 extern EAPI Eina_Bool good;
265 extern EAPI Eina_Bool evil;
266 extern EAPI Eina_Bool starting;
267 extern EAPI Eina_Bool stopping;
268 extern EAPI Eina_Bool restart;
269
270 extern EAPI Eina_Bool e_precache_end;
271 extern EAPI Eina_Bool x_fatal;
272
273 extern EAPI unsigned long e_alert_composite_win;
274
275 //#define SMARTERR(args...) abort()
276 #define SMARTERRNR() return
277 #define SMARTERR(x)  return x
278
279 /**
280  * @}
281  */
282
283 /**
284  * @defgroup Optional_Modules Optional Modules
285  * @{
286  *
287  * @defgroup Optional_Conf Configurations
288  * @defgroup Optional_Control Controls
289  * @defgroup Optional_Devices Devices & Hardware
290  * @defgroup Optional_Fileman File Managers
291  * @defgroup Optional_Gadgets Gadgets
292  * @defgroup Optional_Launcher Launchers
293  * @defgroup Optional_Layouts Layout Managers
294  * @defgroup Optional_Look Look & Feel
295  * @defgroup Optional_Monitors Monitors & Notifications
296  * @defgroup Optional_Mobile Mobile Specific Extensions
297  * @}
298  */
299
300 #endif