15 # ifdef EFL_ECORE_BUILD
17 # define EAPI __declspec(dllexport)
20 # endif /* ! DLL_EXPORT */
22 # define EAPI __declspec(dllimport)
23 # endif /* ! EFL_ECORE_BUILD */
27 # define EAPI __attribute__ ((visibility("default")))
38 * @brief The file that provides the program utility, main loop and timer
41 * This header provides the Ecore event handling loop. For more
42 * details, see @ref Ecore_Main_Loop_Group.
44 * For the main loop to be of any use, you need to be able to add events
45 * and event handlers. Events for file descriptor events are covered in
46 * @ref Ecore_FD_Handler_Group.
48 * Time functions are covered in @ref Ecore_Time_Group.
50 * There is also provision for callbacks for when the loop enters or
51 * exits an idle state. See @ref Idle_Group for more information.
53 * Functions are also provided for spawning child processes using fork.
54 * See @ref Ecore_Exe_Basic_Group and @ref Ecore_Exe_Signal_Group for
59 # include <winsock2.h>
60 #elif (defined (__FreeBSD__) && (__FreeBSD_version >= 420001)) || defined (__OpenBSD__)
61 # include <sys/select.h>
64 # include <sys/time.h>
68 #include <sys/types.h>
74 #define ECORE_VERSION_MAJOR 0
75 #define ECORE_VERSION_MINOR 9
77 typedef struct _Ecore_Version
85 EAPI extern Ecore_Version *ecore_version;
87 #define ECORE_CALLBACK_CANCEL EINA_FALSE /**< Return value to remove a callback */
88 #define ECORE_CALLBACK_RENEW EINA_TRUE /**< Return value to keep a callback */
90 #define ECORE_CALLBACK_PASS_ON EINA_TRUE /**< Return value to pass event to next handler */
91 #define ECORE_CALLBACK_DONE EINA_FALSE /**< Return value to stop event handling */
93 #define ECORE_EVENT_NONE 0
94 #define ECORE_EVENT_SIGNAL_USER 1 /**< User signal event */
95 #define ECORE_EVENT_SIGNAL_HUP 2 /**< Hup signal event */
96 #define ECORE_EVENT_SIGNAL_EXIT 3 /**< Exit signal event */
97 #define ECORE_EVENT_SIGNAL_POWER 4 /**< Power signal event */
98 #define ECORE_EVENT_SIGNAL_REALTIME 5 /**< Realtime signal event */
99 #define ECORE_EVENT_COUNT 6
101 #define ECORE_EXE_PRIORITY_INHERIT 9999
103 EAPI extern int ECORE_EXE_EVENT_ADD; /**< A child process has been added */
104 EAPI extern int ECORE_EXE_EVENT_DEL; /**< A child process has been deleted (it exited, naming consistant with the rest of ecore). */
105 EAPI extern int ECORE_EXE_EVENT_DATA; /**< Data from a child process. */
106 EAPI extern int ECORE_EXE_EVENT_ERROR; /**< Errors from a child process. */
108 enum _Ecore_Fd_Handler_Flags
110 ECORE_FD_READ = 1, /**< Fd Read mask */
111 ECORE_FD_WRITE = 2, /**< Fd Write mask */
112 ECORE_FD_ERROR = 4 /**< Fd Error mask */
114 typedef enum _Ecore_Fd_Handler_Flags Ecore_Fd_Handler_Flags;
116 enum _Ecore_Exe_Flags /* flags for executing a child with its stdin and/or stdout piped back */
118 ECORE_EXE_PIPE_READ = 1, /**< Exe Pipe Read mask */
119 ECORE_EXE_PIPE_WRITE = 2, /**< Exe Pipe Write mask */
120 ECORE_EXE_PIPE_ERROR = 4, /**< Exe Pipe error mask */
121 ECORE_EXE_PIPE_READ_LINE_BUFFERED = 8, /**< Reads are buffered until a newline and delivered 1 event per line */
122 ECORE_EXE_PIPE_ERROR_LINE_BUFFERED = 16, /**< Errors are buffered until a newline and delivered 1 event per line */
123 ECORE_EXE_PIPE_AUTO = 32, /**< stdout and stderr are buffered automatically */
124 ECORE_EXE_RESPAWN = 64, /**< FIXME: Exe is restarted if it dies */
125 ECORE_EXE_USE_SH = 128, /**< Use /bin/sh to run the command. */
126 ECORE_EXE_NOT_LEADER = 256 /**< Do not use setsid() to have the executed process be its own session leader */
128 typedef enum _Ecore_Exe_Flags Ecore_Exe_Flags;
130 enum _Ecore_Exe_Win32_Priority
132 ECORE_EXE_WIN32_PRIORITY_IDLE, /**< Idle priority, for monitoring the system */
133 ECORE_EXE_WIN32_PRIORITY_BELOW_NORMAL, /**< Below default priority */
134 ECORE_EXE_WIN32_PRIORITY_NORMAL, /**< Default priority */
135 ECORE_EXE_WIN32_PRIORITY_ABOVE_NORMAL, /**< Above default priority */
136 ECORE_EXE_WIN32_PRIORITY_HIGH, /**< High priority, use with care as other threads in the system will not get processor time */
137 ECORE_EXE_WIN32_PRIORITY_REALTIME /**< Realtime priority, should be almost never used as it can interrupt system threads that manage mouse input, keyboard input, and background disk flushing */
139 typedef enum _Ecore_Exe_Win32_Priority Ecore_Exe_Win32_Priority;
141 enum _Ecore_Poller_Type /* Poller types */
143 ECORE_POLLER_CORE = 0 /**< The core poller interval */
145 typedef enum _Ecore_Poller_Type Ecore_Poller_Type;
147 typedef struct _Ecore_Exe Ecore_Exe; /**< A handle for spawned processes */
148 typedef struct _Ecore_Timer Ecore_Timer; /**< A handle for timers */
149 typedef struct _Ecore_Idler Ecore_Idler; /**< A handle for idlers */
150 typedef struct _Ecore_Idle_Enterer Ecore_Idle_Enterer; /**< A handle for idle enterers */
151 typedef struct _Ecore_Idle_Exiter Ecore_Idle_Exiter; /**< A handle for idle exiters */
152 typedef struct _Ecore_Fd_Handler Ecore_Fd_Handler; /**< A handle for Fd handlers */
153 typedef struct _Ecore_Win32_Handler Ecore_Win32_Handler; /**< A handle for HANDLE handlers on Windows */
154 typedef struct _Ecore_Event_Handler Ecore_Event_Handler; /**< A handle for an event handler */
155 typedef struct _Ecore_Event_Filter Ecore_Event_Filter; /**< A handle for an event filter */
156 typedef struct _Ecore_Event Ecore_Event; /**< A handle for an event */
157 typedef struct _Ecore_Animator Ecore_Animator; /**< A handle for animators */
158 typedef struct _Ecore_Pipe Ecore_Pipe; /**< A handle for pipes */
159 typedef struct _Ecore_Poller Ecore_Poller; /**< A handle for pollers */
160 typedef struct _Ecore_Event_Signal_User Ecore_Event_Signal_User; /**< User signal event */
161 typedef struct _Ecore_Event_Signal_Hup Ecore_Event_Signal_Hup; /**< Hup signal event */
162 typedef struct _Ecore_Event_Signal_Exit Ecore_Event_Signal_Exit; /**< Exit signal event */
163 typedef struct _Ecore_Event_Signal_Power Ecore_Event_Signal_Power; /**< Power signal event */
164 typedef struct _Ecore_Event_Signal_Realtime Ecore_Event_Signal_Realtime; /**< Realtime signal event */
165 typedef struct _Ecore_Exe_Event_Add Ecore_Exe_Event_Add; /**< Spawned Exe add event */
166 typedef struct _Ecore_Exe_Event_Del Ecore_Exe_Event_Del; /**< Spawned Exe exit event */
167 typedef struct _Ecore_Exe_Event_Data_Line Ecore_Exe_Event_Data_Line; /**< Lines from a child process */
168 typedef struct _Ecore_Exe_Event_Data Ecore_Exe_Event_Data; /**< Data from a child process */
171 typedef struct _Ecore_Thread_Data
176 typedef struct _Ecore_Thread Ecore_Thread;
177 typedef void (*Ecore_Thread_Blocking_Cb) (void *data);
178 typedef void (*Ecore_Thread_End_Cb) (void *data);
179 typedef void (*Ecore_Thread_Cancel_Cb) (void *data);
180 typedef void (*Ecore_Thread_Heavy_Cb) (Ecore_Thread *thread, void *data);
181 typedef void (*Ecore_Thread_Notify_Cb) (Ecore_Thread *thread, void *msg_data, void *data);
185 typedef struct _Ecore_Job Ecore_Job; /**< A job handle */
187 struct _Ecore_Event_Signal_User /** User signal event */
189 int number; /**< The signal number. Either 1 or 2 */
190 void *ext_data; /**< Extension data - not used */
193 siginfo_t data; /**< Signal info */
197 struct _Ecore_Event_Signal_Hup /** Hup signal event */
199 void *ext_data; /**< Extension data - not used */
202 siginfo_t data; /**< Signal info */
206 struct _Ecore_Event_Signal_Exit /** Exit request event */
208 unsigned int interrupt : 1; /**< Set if the exit request was an interrupt signal*/
209 unsigned int quit : 1; /**< set if the exit request was a quit signal */
210 unsigned int terminate : 1; /**< Set if the exit request was a terminate singal */
211 void *ext_data; /**< Extension data - not used */
214 siginfo_t data; /**< Signal info */
218 struct _Ecore_Event_Signal_Power /** Power event */
220 void *ext_data; /**< Extension data - not used */
223 siginfo_t data; /**< Signal info */
227 struct _Ecore_Event_Signal_Realtime /** Realtime event */
229 int num; /**< The realtime signal's number */
232 siginfo_t data; /**< Signal info */
236 struct _Ecore_Exe_Event_Add /** Process add event */
238 Ecore_Exe *exe; /**< The handle to the added process */
239 void *ext_data; /**< Extension data - not used */
242 struct _Ecore_Exe_Event_Del /** Process exit event */
244 pid_t pid; /**< The process ID of the process that exited */
245 int exit_code; /**< The exit code of the process */
246 Ecore_Exe *exe; /**< The handle to the exited process, or NULL if not found */
247 int exit_signal; /** < The signal that caused the process to exit */
248 unsigned int exited : 1; /** < set to 1 if the process exited of its own accord */
249 unsigned int signalled : 1; /** < set to 1 id the process exited due to uncaught signal */
250 void *ext_data; /**< Extension data - not used */
252 siginfo_t data; /**< Signal info */
256 struct _Ecore_Exe_Event_Data_Line /**< Lines from a child process */
262 struct _Ecore_Exe_Event_Data /** Data from a child process event */
264 Ecore_Exe *exe; /**< The handle to the process */
265 void *data; /**< the raw binary data from the child process that was recieved */
266 int size; /**< the size of this data in bytes */
267 Ecore_Exe_Event_Data_Line *lines; /**< an array of line data if line buffered, the last one has it's line member set to NULL */
270 EAPI int ecore_init(void);
271 EAPI int ecore_shutdown(void);
273 EAPI void ecore_app_args_set(int argc, const char **argv);
274 EAPI void ecore_app_args_get(int *argc, char ***argv);
275 EAPI void ecore_app_restart(void);
277 EAPI Ecore_Event_Handler *ecore_event_handler_add(int type, Eina_Bool (*func) (void *data, int type, void *event), const void *data);
278 EAPI void *ecore_event_handler_del(Ecore_Event_Handler *event_handler);
279 EAPI Ecore_Event *ecore_event_add(int type, void *ev, void (*func_free) (void *data, void *ev), void *data);
280 EAPI void *ecore_event_del(Ecore_Event *event);
281 EAPI int ecore_event_type_new(void);
282 EAPI Ecore_Event_Filter *ecore_event_filter_add(void * (*func_start) (void *data), Eina_Bool (*func_filter) (void *data, void *loop_data, int type, void *event), void (*func_end) (void *data, void *loop_data), const void *data);
283 EAPI void *ecore_event_filter_del(Ecore_Event_Filter *ef);
284 EAPI int ecore_event_current_type_get(void);
285 EAPI void *ecore_event_current_event_get(void);
288 EAPI void ecore_exe_run_priority_set(int pri);
289 EAPI int ecore_exe_run_priority_get(void);
290 EAPI Ecore_Exe *ecore_exe_run(const char *exe_cmd, const void *data);
291 EAPI Ecore_Exe *ecore_exe_pipe_run(const char *exe_cmd, Ecore_Exe_Flags flags, const void *data);
292 EAPI void ecore_exe_callback_pre_free_set(Ecore_Exe *exe, void (*func)(void *data, const Ecore_Exe *exe));
293 EAPI Eina_Bool ecore_exe_send(Ecore_Exe *exe, const void *data, int size);
294 EAPI void ecore_exe_close_stdin(Ecore_Exe *exe);
295 EAPI void ecore_exe_auto_limits_set(Ecore_Exe *exe, int start_bytes, int end_bytes, int start_lines, int end_lines);
296 EAPI Ecore_Exe_Event_Data *ecore_exe_event_data_get(Ecore_Exe *exe, Ecore_Exe_Flags flags);
297 EAPI void ecore_exe_event_data_free(Ecore_Exe_Event_Data *data);
298 EAPI void *ecore_exe_free(Ecore_Exe *exe);
299 EAPI pid_t ecore_exe_pid_get(const Ecore_Exe *exe);
300 EAPI void ecore_exe_tag_set(Ecore_Exe *exe, const char *tag);
301 EAPI const char *ecore_exe_tag_get(const Ecore_Exe *exe);
302 EAPI const char *ecore_exe_cmd_get(const Ecore_Exe *exe);
303 EAPI void *ecore_exe_data_get(const Ecore_Exe *exe);
304 EAPI Ecore_Exe_Flags ecore_exe_flags_get(const Ecore_Exe *exe);
305 EAPI void ecore_exe_pause(Ecore_Exe *exe);
306 EAPI void ecore_exe_continue(Ecore_Exe *exe);
307 EAPI void ecore_exe_interrupt(Ecore_Exe *exe);
308 EAPI void ecore_exe_quit(Ecore_Exe *exe);
309 EAPI void ecore_exe_terminate(Ecore_Exe *exe);
310 EAPI void ecore_exe_kill(Ecore_Exe *exe);
311 EAPI void ecore_exe_signal(Ecore_Exe *exe, int num);
312 EAPI void ecore_exe_hup(Ecore_Exe *exe);
314 EAPI Ecore_Idler *ecore_idler_add(Eina_Bool (*func) (void *data), const void *data);
315 EAPI void *ecore_idler_del(Ecore_Idler *idler);
317 EAPI Ecore_Idle_Enterer *ecore_idle_enterer_add(Eina_Bool (*func) (void *data), const void *data);
318 EAPI Ecore_Idle_Enterer *ecore_idle_enterer_before_add(Eina_Bool (*func) (void *data), const void *data);
319 EAPI void *ecore_idle_enterer_del(Ecore_Idle_Enterer *idle_enterer);
321 EAPI Ecore_Idle_Exiter *ecore_idle_exiter_add(Eina_Bool (*func) (void *data), const void *data);
322 EAPI void *ecore_idle_exiter_del(Ecore_Idle_Exiter *idle_exiter);
324 EAPI void ecore_main_loop_iterate(void);
326 EAPI void ecore_main_loop_select_func_set(int (*func)(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, struct timeval *timeout));
327 EAPI void *ecore_main_loop_select_func_get(void);
329 EAPI Eina_Bool ecore_main_loop_glib_integrate(void);
330 EAPI void ecore_main_loop_glib_always_integrate_disable(void);
332 EAPI void ecore_main_loop_begin(void);
333 EAPI void ecore_main_loop_quit(void);
334 EAPI Ecore_Fd_Handler *ecore_main_fd_handler_add(int fd, Ecore_Fd_Handler_Flags flags,
335 Eina_Bool (*func) (void *data, Ecore_Fd_Handler *fd_handler), const void *data,
336 Eina_Bool (*buf_func) (void *buf_data, Ecore_Fd_Handler *fd_handler), const void *buf_data);
337 EAPI void ecore_main_fd_handler_prepare_callback_set(Ecore_Fd_Handler *fd_handler, void (*func) (void *data, Ecore_Fd_Handler *fd_handler), const void *data);
338 EAPI void *ecore_main_fd_handler_del(Ecore_Fd_Handler *fd_handler);
339 EAPI int ecore_main_fd_handler_fd_get(Ecore_Fd_Handler *fd_handler);
340 EAPI int ecore_main_fd_handler_active_get(Ecore_Fd_Handler *fd_handler, Ecore_Fd_Handler_Flags flags);
341 EAPI void ecore_main_fd_handler_active_set(Ecore_Fd_Handler *fd_handler, Ecore_Fd_Handler_Flags flags);
343 EAPI Ecore_Win32_Handler *ecore_main_win32_handler_add(void *h, Eina_Bool (*func) (void *data, Ecore_Win32_Handler *wh), const void *data);
344 EAPI void *ecore_main_win32_handler_del(Ecore_Win32_Handler *win32_handler);
346 EAPI Ecore_Pipe *ecore_pipe_add(void (*handler) (void *data, void *buffer, unsigned int nbyte), const void *data);
347 EAPI void *ecore_pipe_del(Ecore_Pipe *p);
348 EAPI Eina_Bool ecore_pipe_write(Ecore_Pipe *p, const void *buffer, unsigned int nbytes);
349 EAPI void ecore_pipe_write_close(Ecore_Pipe *p);
350 EAPI void ecore_pipe_read_close(Ecore_Pipe *p);
354 EAPI Ecore_Thread *ecore_thread_run(Ecore_Thread_Blocking_Cb,
356 Ecore_Thread_Cancel_Cb,
358 EAPI Ecore_Thread *ecore_long_run(Ecore_Thread_Heavy_Cb,
359 Ecore_Thread_Notify_Cb,
361 Ecore_Thread_Cancel_Cb,
363 Eina_Bool try_no_queue);
364 EAPI Eina_Bool ecore_thread_cancel(Ecore_Thread *thread);
365 EAPI Eina_Bool ecore_thread_check(Ecore_Thread *thread);
366 EAPI Eina_Bool ecore_thread_notify(Ecore_Thread *thread, const void *msg_data);
367 EAPI int ecore_thread_active_get(void);
368 EAPI int ecore_thread_pending_get(void);
369 EAPI int ecore_thread_pending_long_get(void);
370 EAPI int ecore_thread_pending_total_get(void);
371 EAPI int ecore_thread_max_get(void);
372 EAPI void ecore_thread_max_set(int num);
373 EAPI void ecore_thread_max_reset(void);
374 EAPI int ecore_thread_available_get(void);
376 EAPI Eina_Bool ecore_thread_pool_data_add(Ecore_Thread *thread, const char *key, void *value, Eina_Free_Cb cb, Eina_Bool direct);
377 EAPI Ecore_Thread_Data *ecore_thread_pool_data_set(Ecore_Thread *thread, const char *key, void *value, Eina_Free_Cb cb);
378 EAPI const void *ecore_thread_pool_data_find(Ecore_Thread *thread, const char *key);
379 EAPI Eina_Bool ecore_thread_pool_data_del(Ecore_Thread *thread, const char *key);
380 EAPI const void *ecore_thread_pool_data_wait(Ecore_Thread *thread, const char *key, double seconds);
382 EAPI Eina_Bool ecore_thread_global_data_add(const char *key, void *value, Eina_Free_Cb cb, Eina_Bool direct);
383 EAPI Ecore_Thread_Data *ecore_thread_global_data_set(const char *key, void *value, Eina_Free_Cb cb);
384 EAPI const void *ecore_thread_global_data_find(const char *key);
385 EAPI Eina_Bool ecore_thread_global_data_del(const char *key);
386 EAPI const void *ecore_thread_global_data_wait(const char *key, double seconds);
391 EAPI double ecore_time_get(void);
392 EAPI double ecore_loop_time_get(void);
394 EAPI Ecore_Timer *ecore_timer_add(double in, Eina_Bool (*func) (void *data), const void *data);
395 EAPI Ecore_Timer *ecore_timer_loop_add(double in, Eina_Bool (*func) (void *data), const void *data);
396 EAPI void *ecore_timer_del(Ecore_Timer *timer);
397 EAPI void ecore_timer_interval_set(Ecore_Timer *timer, double in);
398 EAPI double ecore_timer_interval_get(Ecore_Timer *timer);
399 EAPI void ecore_timer_freeze(Ecore_Timer *timer);
400 EAPI void ecore_timer_thaw(Ecore_Timer *timer);
401 EAPI void ecore_timer_delay(Ecore_Timer *timer, double add);
402 EAPI double ecore_timer_pending_get(Ecore_Timer *timer);
404 EAPI double ecore_timer_precision_get(void);
405 EAPI void ecore_timer_precision_set(double precision);
407 EAPI Ecore_Animator *ecore_animator_add(Eina_Bool (*func) (void *data), const void *data);
408 EAPI void *ecore_animator_del(Ecore_Animator *animator);
409 EAPI void ecore_animator_freeze(Ecore_Animator *animator);
410 EAPI void ecore_animator_thaw(Ecore_Animator *animator);
411 EAPI void ecore_animator_frametime_set(double frametime);
412 EAPI double ecore_animator_frametime_get(void);
414 EAPI void ecore_poller_poll_interval_set(Ecore_Poller_Type type, double poll_time);
415 EAPI double ecore_poller_poll_interval_get(Ecore_Poller_Type type);
416 EAPI Eina_Bool ecore_poller_poller_interval_set(Ecore_Poller *poller, int interval);
417 EAPI int ecore_poller_poller_interval_get(Ecore_Poller *poller);
418 EAPI Ecore_Poller *ecore_poller_add(Ecore_Poller_Type type, int interval, Eina_Bool (*func) (void *data), const void *data);
419 EAPI void *ecore_poller_del(Ecore_Poller *poller);
421 EAPI Ecore_Job *ecore_job_add(void (*func) (void *data), const void *data);
422 EAPI void *ecore_job_del(Ecore_Job *job);