summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authorVincent Torri <vincent.torri@gmail.com>2012-12-02 22:35:45 +0000
committerVincent Torri <vincent.torri@gmail.com>2012-12-02 22:35:45 +0000
commit7d6010b12c47a20e492da808e3192c3f87dab619 (patch)
tree26c6fd189e046a76560c0bc740b85f4d767ae399 /src/lib
parent53fc441d5475155965d92da89502fe4634a561b2 (diff)
merge: add escape ecore, fix several bugs
SVN revision: 79995
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/ecore/Ecore.h2954
-rw-r--r--src/lib/ecore/Ecore_Getopt.h419
-rw-r--r--src/lib/ecore/ecore.c878
-rw-r--r--src/lib/ecore/ecore_alloc.c132
-rw-r--r--src/lib/ecore/ecore_anim.c633
-rw-r--r--src/lib/ecore/ecore_app.c98
-rw-r--r--src/lib/ecore/ecore_events.c648
-rw-r--r--src/lib/ecore/ecore_exe.c1913
-rw-r--r--src/lib/ecore/ecore_exe_ps3.c20
-rw-r--r--src/lib/ecore/ecore_exe_win32.c1055
-rw-r--r--src/lib/ecore/ecore_exe_wince.c21
-rw-r--r--src/lib/ecore/ecore_getopt.c1936
-rw-r--r--src/lib/ecore/ecore_glib.c346
-rw-r--r--src/lib/ecore/ecore_idle_enterer.c313
-rw-r--r--src/lib/ecore/ecore_idle_exiter.c264
-rw-r--r--src/lib/ecore/ecore_idler.c247
-rw-r--r--src/lib/ecore/ecore_job.c198
-rw-r--r--src/lib/ecore/ecore_main.c2111
-rw-r--r--src/lib/ecore/ecore_pipe.c748
-rw-r--r--src/lib/ecore/ecore_poll.c490
-rw-r--r--src/lib/ecore/ecore_private.h398
-rw-r--r--src/lib/ecore/ecore_signal.c594
-rw-r--r--src/lib/ecore/ecore_thread.c1509
-rw-r--r--src/lib/ecore/ecore_throttle.c104
-rw-r--r--src/lib/ecore/ecore_time.c184
-rw-r--r--src/lib/ecore/ecore_timer.c1015
-rw-r--r--src/lib/ecore_cocoa/Ecore_Cocoa.h147
-rw-r--r--src/lib/ecore_cocoa/Ecore_Cocoa_Keys.h285
-rw-r--r--src/lib/ecore_cocoa/ecore_cocoa.m283
-rw-r--r--src/lib/ecore_cocoa/ecore_cocoa_private.h11
-rw-r--r--src/lib/ecore_cocoa/ecore_cocoa_window.m163
-rw-r--r--src/lib/ecore_con/Ecore_Con.h1948
-rw-r--r--src/lib/ecore_con/Ecore_Con_Eet.h73
-rw-r--r--src/lib/ecore_con/dns.c7878
-rw-r--r--src/lib/ecore_con/dns.h1076
-rw-r--r--src/lib/ecore_con/ecore_con.c2596
-rw-r--r--src/lib/ecore_con/ecore_con_alloc.c101
-rw-r--r--src/lib/ecore_con/ecore_con_ares.c628
-rw-r--r--src/lib/ecore_con/ecore_con_dns.c344
-rw-r--r--src/lib/ecore_con/ecore_con_eet.c822
-rw-r--r--src/lib/ecore_con/ecore_con_info.c458
-rw-r--r--src/lib/ecore_con/ecore_con_local.c325
-rw-r--r--src/lib/ecore_con/ecore_con_local_win32.c754
-rw-r--r--src/lib/ecore_con/ecore_con_private.h390
-rw-r--r--src/lib/ecore_con/ecore_con_socks.c962
-rw-r--r--src/lib/ecore_con/ecore_con_ssl.c2141
-rw-r--r--src/lib/ecore_con/ecore_con_url.c1683
-rw-r--r--src/lib/ecore_directfb/Ecore_DirectFB.h181
-rw-r--r--src/lib/ecore_directfb/ecore_directfb.c758
-rw-r--r--src/lib/ecore_directfb/ecore_directfb_keys.h184
-rw-r--r--src/lib/ecore_directfb/ecore_directfb_private.h52
-rw-r--r--src/lib/ecore_evas/Ecore_Evas.h2256
-rw-r--r--src/lib/ecore_evas/ecore_evas.c2781
-rw-r--r--src/lib/ecore_evas/ecore_evas_buffer.c836
-rw-r--r--src/lib/ecore_evas/ecore_evas_cocoa.c584
-rw-r--r--src/lib/ecore_evas/ecore_evas_directfb.c606
-rw-r--r--src/lib/ecore_evas/ecore_evas_ews.c1469
-rw-r--r--src/lib/ecore_evas/ecore_evas_extn.c2266
-rw-r--r--src/lib/ecore_evas/ecore_evas_fb.c678
-rw-r--r--src/lib/ecore_evas/ecore_evas_private.h490
-rw-r--r--src/lib/ecore_evas/ecore_evas_psl1ght.c515
-rw-r--r--src/lib/ecore_evas/ecore_evas_sdl.c665
-rw-r--r--src/lib/ecore_evas/ecore_evas_util.c451
-rw-r--r--src/lib/ecore_evas/ecore_evas_wayland_common.c785
-rw-r--r--src/lib/ecore_evas/ecore_evas_wayland_egl.c434
-rw-r--r--src/lib/ecore_evas/ecore_evas_wayland_shm.c656
-rw-r--r--src/lib/ecore_evas/ecore_evas_win32.c1524
-rw-r--r--src/lib/ecore_evas/ecore_evas_wince.c67
-rw-r--r--src/lib/ecore_evas/ecore_evas_x.c3663
-rw-r--r--src/lib/ecore_fb/Ecore_Fb.h100
-rw-r--r--src/lib/ecore_fb/ecore_fb.c129
-rw-r--r--src/lib/ecore_fb/ecore_fb_kbd.c326
-rw-r--r--src/lib/ecore_fb/ecore_fb_keytable.h129
-rw-r--r--src/lib/ecore_fb/ecore_fb_li.c721
-rw-r--r--src/lib/ecore_fb/ecore_fb_private.h94
-rw-r--r--src/lib/ecore_fb/ecore_fb_ps2.c223
-rw-r--r--src/lib/ecore_fb/ecore_fb_ts.c362
-rw-r--r--src/lib/ecore_fb/ecore_fb_vt.c322
-rw-r--r--src/lib/ecore_file/Ecore_File.h190
-rw-r--r--src/lib/ecore_file/ecore_file.c1137
-rw-r--r--src/lib/ecore_file/ecore_file_download.c455
-rw-r--r--src/lib/ecore_file/ecore_file_monitor.c180
-rw-r--r--src/lib/ecore_file/ecore_file_monitor_inotify.c331
-rw-r--r--src/lib/ecore_file/ecore_file_monitor_poll.c340
-rw-r--r--src/lib/ecore_file/ecore_file_monitor_win32.c310
-rw-r--r--src/lib/ecore_file/ecore_file_path.c192
-rw-r--r--src/lib/ecore_file/ecore_file_private.h129
-rw-r--r--src/lib/ecore_imf/Ecore_IMF.h577
-rw-r--r--src/lib/ecore_imf/Ecore_IMF_Evas.h50
-rw-r--r--src/lib/ecore_imf/ecore_imf.c73
-rw-r--r--src/lib/ecore_imf/ecore_imf_context.c1900
-rw-r--r--src/lib/ecore_imf/ecore_imf_evas.c324
-rw-r--r--src/lib/ecore_imf/ecore_imf_module.c212
-rw-r--r--src/lib/ecore_imf/ecore_imf_private.h84
-rw-r--r--src/lib/ecore_input/Ecore_Input.h236
-rw-r--r--src/lib/ecore_input/Ecore_Input_Evas.h64
-rw-r--r--src/lib/ecore_input/ecore_input.c127
-rw-r--r--src/lib/ecore_input/ecore_input_compose.c61
-rw-r--r--src/lib/ecore_input/ecore_input_compose.h9895
-rw-r--r--src/lib/ecore_input/ecore_input_evas.c418
-rw-r--r--src/lib/ecore_input/ecore_input_evas_private.h37
-rw-r--r--src/lib/ecore_input/ecore_input_private.h37
-rw-r--r--src/lib/ecore_ipc/Ecore_Ipc.h328
-rw-r--r--src/lib/ecore_ipc/ecore_ipc.c1599
-rw-r--r--src/lib/ecore_ipc/ecore_ipc_private.h105
-rw-r--r--src/lib/ecore_sdl/Ecore_Sdl.h114
-rw-r--r--src/lib/ecore_sdl/Ecore_Sdl_Keys.h266
-rw-r--r--src/lib/ecore_sdl/ecore_sdl.c334
-rw-r--r--src/lib/ecore_sdl/ecore_sdl_private.h36
-rw-r--r--src/lib/ecore_wayland/Ecore_Wayland.h392
-rw-r--r--src/lib/ecore_wayland/ecore_wl.c497
-rw-r--r--src/lib/ecore_wayland/ecore_wl_dnd.c485
-rw-r--r--src/lib/ecore_wayland/ecore_wl_input.c1208
-rw-r--r--src/lib/ecore_wayland/ecore_wl_output.c87
-rw-r--r--src/lib/ecore_wayland/ecore_wl_private.h103
-rw-r--r--src/lib/ecore_wayland/ecore_wl_window.c707
-rw-r--r--src/lib/ecore_win32/Ecore_Win32.h526
-rw-r--r--src/lib/ecore_win32/ecore_win32.c841
-rw-r--r--src/lib/ecore_win32/ecore_win32_cursor.c305
-rwxr-xr-xsrc/lib/ecore_win32/ecore_win32_dnd.c221
-rw-r--r--src/lib/ecore_win32/ecore_win32_dnd_data_object.cpp209
-rw-r--r--src/lib/ecore_win32/ecore_win32_dnd_data_object.h49
-rw-r--r--src/lib/ecore_win32/ecore_win32_dnd_drop_source.cpp92
-rw-r--r--src/lib/ecore_win32/ecore_win32_dnd_drop_source.h36
-rw-r--r--src/lib/ecore_win32/ecore_win32_dnd_drop_target.cpp232
-rw-r--r--src/lib/ecore_win32/ecore_win32_dnd_drop_target.h47
-rw-r--r--src/lib/ecore_win32/ecore_win32_dnd_enumformatetc.cpp157
-rw-r--r--src/lib/ecore_win32/ecore_win32_dnd_enumformatetc.h50
-rw-r--r--src/lib/ecore_win32/ecore_win32_event.c1307
-rw-r--r--src/lib/ecore_win32/ecore_win32_private.h170
-rw-r--r--src/lib/ecore_win32/ecore_win32_window.c1418
-rw-r--r--src/lib/ecore_wince/Ecore_WinCE.h314
-rw-r--r--src/lib/ecore_wince/ecore_wince.c400
-rw-r--r--src/lib/ecore_wince/ecore_wince_event.c1123
-rw-r--r--src/lib/ecore_wince/ecore_wince_private.h85
-rw-r--r--src/lib/ecore_wince/ecore_wince_window.c827
-rw-r--r--src/lib/ecore_x/Ecore_X.h2407
-rw-r--r--src/lib/ecore_x/Ecore_X_Atoms.h292
-rw-r--r--src/lib/ecore_x/Ecore_X_Cursor.h87
-rw-r--r--src/lib/ecore_x/ecore_x_atoms_decl.h602
-rw-r--r--src/lib/ecore_x/xcb/ecore_xcb.c1583
-rw-r--r--src/lib/ecore_x/xcb/ecore_xcb_atoms.c149
-rw-r--r--src/lib/ecore_x/xcb/ecore_xcb_composite.c290
-rw-r--r--src/lib/ecore_x/xcb/ecore_xcb_cursor.c400
-rw-r--r--src/lib/ecore_x/xcb/ecore_xcb_damage.c155
-rw-r--r--src/lib/ecore_x/xcb/ecore_xcb_dnd.c688
-rw-r--r--src/lib/ecore_x/xcb/ecore_xcb_dpms.c320
-rw-r--r--src/lib/ecore_x/xcb/ecore_xcb_drawable.c123
-rw-r--r--src/lib/ecore_x/xcb/ecore_xcb_e.c1576
-rw-r--r--src/lib/ecore_x/xcb/ecore_xcb_error.c123
-rw-r--r--src/lib/ecore_x/xcb/ecore_xcb_events.c2824
-rw-r--r--src/lib/ecore_x/xcb/ecore_xcb_extensions.c148
-rw-r--r--src/lib/ecore_x/xcb/ecore_xcb_gc.c173
-rw-r--r--src/lib/ecore_x/xcb/ecore_xcb_gesture.c203
-rw-r--r--src/lib/ecore_x/xcb/ecore_xcb_icccm.c1569
-rw-r--r--src/lib/ecore_x/xcb/ecore_xcb_image.c738
-rw-r--r--src/lib/ecore_x/xcb/ecore_xcb_input.c274
-rw-r--r--src/lib/ecore_x/xcb/ecore_xcb_keymap.c491
-rw-r--r--src/lib/ecore_x/xcb/ecore_xcb_mwm.c104
-rw-r--r--src/lib/ecore_x/xcb/ecore_xcb_netwm.c1604
-rw-r--r--src/lib/ecore_x/xcb/ecore_xcb_pixmap.c128
-rw-r--r--src/lib/ecore_x/xcb/ecore_xcb_private.h468
-rw-r--r--src/lib/ecore_x/xcb/ecore_xcb_randr.c3807
-rw-r--r--src/lib/ecore_x/xcb/ecore_xcb_region.c159
-rw-r--r--src/lib/ecore_x/xcb/ecore_xcb_render.c225
-rw-r--r--src/lib/ecore_x/xcb/ecore_xcb_screensaver.c370
-rw-r--r--src/lib/ecore_x/xcb/ecore_xcb_selection.c1026
-rw-r--r--src/lib/ecore_x/xcb/ecore_xcb_shape.c50
-rw-r--r--src/lib/ecore_x/xcb/ecore_xcb_sync.c338
-rw-r--r--src/lib/ecore_x/xcb/ecore_xcb_textlist.c509
-rw-r--r--src/lib/ecore_x/xcb/ecore_xcb_vsync.c375
-rw-r--r--src/lib/ecore_x/xcb/ecore_xcb_window.c2238
-rw-r--r--src/lib/ecore_x/xcb/ecore_xcb_window_prop.c720
-rw-r--r--src/lib/ecore_x/xcb/ecore_xcb_window_shadow.c410
-rw-r--r--src/lib/ecore_x/xcb/ecore_xcb_window_shape.c790
-rw-r--r--src/lib/ecore_x/xcb/ecore_xcb_xdefaults.c116
-rw-r--r--src/lib/ecore_x/xcb/ecore_xcb_xfixes.c744
-rw-r--r--src/lib/ecore_x/xcb/ecore_xcb_xinerama.c139
-rw-r--r--src/lib/ecore_x/xcb/ecore_xcb_xtest.c215
-rw-r--r--src/lib/ecore_x/xlib/ecore_x.c2242
-rw-r--r--src/lib/ecore_x/xlib/ecore_x_atoms.c109
-rw-r--r--src/lib/ecore_x/xlib/ecore_x_composite.c176
-rw-r--r--src/lib/ecore_x/xlib/ecore_x_cursor.c246
-rw-r--r--src/lib/ecore_x/xlib/ecore_x_damage.c71
-rw-r--r--src/lib/ecore_x/xlib/ecore_x_dnd.c706
-rw-r--r--src/lib/ecore_x/xlib/ecore_x_dpms.c247
-rw-r--r--src/lib/ecore_x/xlib/ecore_x_drawable.c118
-rw-r--r--src/lib/ecore_x/xlib/ecore_x_e.c1670
-rw-r--r--src/lib/ecore_x/xlib/ecore_x_error.c126
-rw-r--r--src/lib/ecore_x/xlib/ecore_x_events.c2523
-rw-r--r--src/lib/ecore_x/xlib/ecore_x_fixes.c365
-rw-r--r--src/lib/ecore_x/xlib/ecore_x_gc.c171
-rw-r--r--src/lib/ecore_x/xlib/ecore_x_gesture.c137
-rw-r--r--src/lib/ecore_x/xlib/ecore_x_icccm.c1214
-rw-r--r--src/lib/ecore_x/xlib/ecore_x_image.c626
-rw-r--r--src/lib/ecore_x/xlib/ecore_x_mwm.c106
-rw-r--r--src/lib/ecore_x/xlib/ecore_x_netwm.c2083
-rw-r--r--src/lib/ecore_x/xlib/ecore_x_pixmap.c121
-rw-r--r--src/lib/ecore_x/xlib/ecore_x_private.h379
-rw-r--r--src/lib/ecore_x/xlib/ecore_x_randr.c103
-rw-r--r--src/lib/ecore_x/xlib/ecore_x_randr.h7
-rw-r--r--src/lib/ecore_x/xlib/ecore_x_randr_11.c334
-rw-r--r--src/lib/ecore_x/xlib/ecore_x_randr_12.c2438
-rw-r--r--src/lib/ecore_x/xlib/ecore_x_randr_12_edid.c463
-rw-r--r--src/lib/ecore_x/xlib/ecore_x_randr_13.c68
-rw-r--r--src/lib/ecore_x/xlib/ecore_x_region.c158
-rw-r--r--src/lib/ecore_x/xlib/ecore_x_screensaver.c204
-rw-r--r--src/lib/ecore_x/xlib/ecore_x_selection.c1021
-rw-r--r--src/lib/ecore_x/xlib/ecore_x_sync.c159
-rw-r--r--src/lib/ecore_x/xlib/ecore_x_test.c167
-rw-r--r--src/lib/ecore_x/xlib/ecore_x_vsync.c351
-rw-r--r--src/lib/ecore_x/xlib/ecore_x_window.c1727
-rw-r--r--src/lib/ecore_x/xlib/ecore_x_window_prop.c760
-rw-r--r--src/lib/ecore_x/xlib/ecore_x_window_shape.c658
-rw-r--r--src/lib/ecore_x/xlib/ecore_x_xi2.c336
-rw-r--r--src/lib/ecore_x/xlib/ecore_x_xinerama.c91
-rw-r--r--src/lib/escape/Escape.h52
-rw-r--r--src/lib/escape/escape_libgen.c90
-rw-r--r--src/lib/escape/escape_libgen.h32
-rw-r--r--src/lib/escape/escape_mman.c67
-rw-r--r--src/lib/escape/escape_unistd.c186
-rw-r--r--src/lib/escape/escape_unistd.h107
-rw-r--r--src/lib/escape/sys/mman.h179
223 files changed, 151576 insertions, 0 deletions
diff --git a/src/lib/ecore/Ecore.h b/src/lib/ecore/Ecore.h
new file mode 100644
index 0000000000..5a02211526
--- /dev/null
+++ b/src/lib/ecore/Ecore.h
@@ -0,0 +1,2954 @@
1/**
2 @brief Ecore Library Public API Calls
3
4 These routines are used for Ecore Library interaction
5 */
6
7/**
8
9 @mainpage Ecore
10
11 @version 1.7
12 @date 2000-2012
13
14 Please see the @ref authors page for contact details.
15
16 @section intro Introduction
17
18 Ecore is a library of convenience functions. A brief explanation of how to use
19 it can be found in @ref Ecore_Main_Loop_Page.
20
21 The Ecore library provides the following modules:
22 @li @ref Ecore_Main_Loop_Group
23 @li @ref Ecore_File_Group
24 @li @ref Ecore_Con_Group
25 @li @ref Ecore_Evas_Group
26 @li @ref Ecore_FB_Group
27 @li @ref Ecore_IMF_Lib_Group
28 @li @ref Ecore_IMF_Context_Group
29 @li @ref Ecore_IMF_Context_Module_Group
30 @li @ref Ecore_IMF_Evas_Group
31 @li @link Ecore_Ipc.h Ecore_IPC - Inter Process Communication functions. @endlink
32 @li @link Ecore_X.h Ecore_X - X Windows System wrapper. @endlink
33 @li @ref Ecore_Win32_Group
34 @li @ref Ecore_WinCE_Group
35
36 For more info on Ecore usage, there are these @ref Examples.
37
38 @section compiling How to compile using Ecore?
39 pkgconfig (.pc) files are installed for every ecore module.
40 Thus, to compile using any of them, you can use something like the following:
41
42@verbatim
43gcc *.c $(pkg-config ecore ecore-$x ecore-$y [...] --cflags --libs)
44@endverbatim
45
46 @section install How is it installed?
47
48 Suggested configure options for ecore for a Linux desktop X display
49 with OpenGL and Software support, communication (networking) and
50 IPC (inter process communication):
51
52@verbatim
53./configure \
54 --enable-ecore-con \
55 --enable-ecore-ipc \
56 --enable-ecore-file \
57 --enable-ecore-input \
58 --enable-ecore-input-evas \
59 --enable-ecore-x \
60 --enable-ecore-evas \
61 --enable-ecore-evas-software-buffer \
62 --enable-ecore-evas-software-x11 \
63 --enable-ecore-evas-opengl-x11
64make
65sudo make install
66@endverbatim
67
68 */
69
70/**
71 @page authors Authors
72 @author Carsten Haitzler <raster@rasterman.com>
73 @author Tom Gilbert <tom@linuxbrit.co.uk>
74 @author Burra <burra@colorado.edu>
75 @author Chris Ross <chris@darkrock.co.uk>
76 @author Term <term@twistedpath.org>
77 @author Tilman Sauerbeck <tilman@code-monkey.de>
78 @author Ibukun Olumuyiwa <ibukun@computer.org>
79 @author Yuri <da2001@hotmail.ru>
80 @author Nicholas Curran <quasar@bigblue.net.au>
81 @author Howell Tam <pigeon@pigeond.net>
82 @author Nathan Ingersoll <rbdpngn@users.sourceforge.net>
83 @author Andrew Elcock <andy@elcock.org>
84 @author Kim Woelders <kim@woelders.dk>
85 @author Sebastian Dransfeld <sebastid@tango.flipp.net>
86 @author Simon Poole <simon.armlinux@themalago.net>
87 @author Jorge Luis Zapata Muga <jorgeluis.zapata@gmail.com>
88 @author dan sinclair <zero@everburning.com>
89 @author Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de>
90 @author David 'onefang' Seikel <onefang@gmail.com>
91 @author Hisham 'CodeWarrior' Mardam Bey <hisham@hisham.cc>
92 @author Brian 'rephorm' Mattern <rephorm@rephorm.com>
93 @author Tim Horton <hortont424@gmail.com>
94 @author Arnaud de Turckheim 'quarium' <quarium@gmail.com>
95 @author Matt Barclay <mbarclay@gmail.com>
96 @author Peter Wehrfritz <peter.wehrfritz@web.de>
97 @author Albin "Lutin" Tonnerre <albin.tonnerre@gmail.com>
98 @author Vincent Torri <vincent.torri@gmail.com>
99 @author Lars Munch <lars@segv.dk>
100 @author Andre Dieb <andre.dieb@gmail.com>
101 @author Mathieu Taillefumier <mathieu.taillefumier@free.fr>
102 @author Rui Miguel Silva Seabra <rms@1407.org>
103 @author Samsung Electronics
104 @author Samsung SAIT
105 @author Nicolas Aguirre <aguirre.nicolas@gmail.com>
106 @author Brett Nash <nash@nash.id.au>
107 @author Mike Blumenkrantz <michael.blumenkrantz@gmail.com>
108 @author Leif Middelschulte <leif.middelschulte@gmail.com>
109 @author Mike McCormack <mj.mccormack@samsung.com>
110 @author Sangho Park <gouache95@gmail.com>
111 @author Jihoon Kim <jihoon48.kim@samsung.com> <imfine98@gmail.com>
112 @author PnB <Poor.NewBie@gmail.com>
113 @author Daniel Juyung Seo <seojuyung2@gmail.com> <juyung.seo@samsung.com>
114 @author Christopher 'devilhorns' Michael <cpmichael1@comcast.net>
115 @author ChunEon Park <hermet@hermet.pe.kr>
116 @author xlopez@igalia.com
117 @author Rafael Antognolli <antognolli@profusion.mobi>
118 @author Kim Yunhan <spbear@gmail.com>
119 @author Youness Alaoui <kakaroto@kakaroto.homelinux.net>
120 @author Bluezery <ohpowel@gmail.com>
121 @author Doyoun Kang <wayofmine@gmail.com> <doyoun.kang@samsung.com>
122 @author Haifeng Deng <haifeng.deng@samsung.com>
123 @author Jérémy Zurcher <jeremy@asynk.ch>
124 @author Vikram Narayanan <vikram186@gmail.com>
125
126 Please contact <enlightenment-devel@lists.sourceforge.net> to get in
127 contact with the developers and maintainers.
128 */
129
130/**
131 * @page Ecore_Main_Loop_Page The Ecore Main Loop
132 *
133 * @section intro What is Ecore?
134 *
135 * Ecore is a clean and tiny event loop library with many modules to do lots of
136 * convenient things for a programmer, to save time and effort. It's small and
137 * lean, designed to work from embedded systems all the way up to large and
138 * powerful multi-cpu workstations. The main loop has a number of primitives to
139 * be used with its main loop. It serializes all the primitives and allows for
140 * great responsiveness without the need for threads(or any other concurrency).
141 *
142 * @subsection timers Timers
143 *
144 * Timers serve two main purposes: doing something at a specified time and
145 * repeatedly doing something with a set interval.
146 * @see Ecore_Timer_Group
147 *
148 * @subsection pollers Pollers
149 *
150 * Pollers allow for polling to be centralized into a single place therefore
151 * alleviating the need for different parts of the program to wake up at
152 * different times to do polling, thereby making the code simpler and more
153 * efficient.
154 * @see Ecore_Poller_Group
155 *
156 * @subsection idler Idlers
157 *
158 * There are three types of idlers, enterers, idlers(proper) and exiters, they
159 * are called, respectively, when the program is about to enter an idle state,
160 * when the program is idle and when the program is leaving an idle state. Idler
161 * enterers are usually a good place to update the program state. Proper idlers
162 * are the appropriate place to do heavy computational tasks thereby using what
163 * would otherwise be wasted CPU cycles. Exiters are the perfect place to do
164 * anything your program should do just before processing events(also timers,
165 * poolers, file descriptor handlers and animators)
166 * @see Ecore_Idle_Group
167 *
168 * @subsection fd_handler File descriptor handlers
169 *
170 * File descriptor handlers allow you to monitor when there is data available to
171 * read on file descriptors, when writing will not block or if there was an
172 * error. Any valid file descriptor can be used with this API, regardless of if
173 * was gotten with an OS specific API or from ecore.
174 * @see Ecore_FD_Handler_Group
175 *
176 * @subsection animators Animators
177 *
178 * Ecore provides a facility called animators, so named since the intended use
179 * was in animations, that facilitates knowing what percentage of a given
180 * interval has elapsed. This is perfect for performing animations, but is not
181 * limited to that use, it can, for example, also be used to create a progress
182 * bar.
183 * @see Ecore_Animator_Group
184 *
185 * @subsection ev_handlers Event handlers
186 *
187 * Event handlers are, arguably, the most important feature of the ecore main
188 * loop, they are what allows the programmer to easily handle user interaction.
189 * Events however are not only things the user does, events can represent
190 * anything for which a type is created.
191 * @see Ecore_Event_Group
192 *
193 * All of these primitives are discussed in more detail in their respective
194 * pages linked above.
195 *
196 * Here is a diagram of the main loop flow of a simple program:
197 *
198 * @image html prog_flow.png
199 * @image latex prog_flow.eps width=\textwidth
200 *
201 *
202 *
203 * @section work How does Ecore work?
204 *
205 * Ecore is very easy to learn and use. All the function calls are designed to
206 * be easy to remember, explicit in describing what they do, and heavily
207 * name-spaced. Ecore programs can start and be very simple.
208 *
209 * For example:
210 *
211 * @code
212 * #include <Ecore.h>
213 *
214 * int
215 * main(int argc, const char **argv)
216 * {
217 * ecore_init();
218 * ecore_app_args_set(argc, argv);
219 * ecore_main_loop_begin();
220 * ecore_shutdown();
221 * return 0;
222 * }
223 * @endcode
224 *
225 * This program is very simple and doesn't check for errors, but it does start up
226 * and begin a main loop waiting for events or timers to tick off. This program
227 * doesn't set up any, but now we can expand on this simple program a little
228 * more by adding some event handlers and timers.
229 *
230 * @code
231 * #include <Ecore.h>
232 *
233 * Ecore_Timer *timer1 = NULL;
234 * Ecore_Event_Handler *handler1 = NULL;
235 * double start_time = 0.0;
236 *
237 * int
238 * timer_func(void *data)
239 * {
240 * printf("Tick timer. Sec: %3.2f\n", ecore_time_get() - start_time);
241 * return 1;
242 * }
243 *
244 * int
245 * exit_func(void *data, int ev_type, void *ev)
246 * {
247 * Ecore_Event_Signal_Exit *e;
248 *
249 * e = (Ecore_Event_Signal_Exit *)ev;
250 * if (e->interrupt) printf("Exit: interrupt\n");
251 * else if (e->quit) printf("Exit: quit\n");
252 * else if (e->terminate) printf("Exit: terminate\n");
253 * ecore_main_loop_quit();
254 * return 1;
255 * }
256 *
257 * int
258 * main(int argc, const char **argv)
259 * {
260 * ecore_init();
261 * ecore_app_args_set(argc, argv);
262 * start_time = ecore_time_get();
263 * handler1 = ecore_event_handler_add(ECORE_EVENT_SIGNAL_EXIT, exit_func, NULL);
264 * timer1 = ecore_timer_add(0.5, timer_func, NULL);
265 * ecore_main_loop_begin();
266 * ecore_shutdown();
267 * return 0;
268 * }
269 * @endcode
270 *
271 * In the previous example, we initialize our application and get the time at
272 * which our program has started so we can calculate an offset. We set
273 * up a timer to tick off in 0.5 seconds, and since it returns 1, will
274 * keep ticking off every 0.5 seconds until it returns 0, or is deleted
275 * by hand. An event handler is set up to call a function -
276 * exit_func(),
277 * whenever an event of type ECORE_EVENT_SIGNAL_EXIT is received (CTRL-C
278 * on the command line will cause such an event to happen). If this event
279 * occurs it tells you what kind of exit signal was received, and asks
280 * the main loop to quit when it is finished by calling
281 * ecore_main_loop_quit().
282 *
283 * The handles returned by ecore_timer_add() and
284 * ecore_event_handler_add() are
285 * only stored here as an example. If you don't need to address the timer or
286 * event handler again you don't need to store the result, so just call the
287 * function, and don't assign the result to any variable.
288 *
289 * This program looks slightly more complex than needed to do these simple
290 * things, but in principle, programs don't get any more complex. You add more
291 * event handlers, for more events, will have more timers and such, BUT it all
292 * follows the same principles as shown in this example.
293 *
294 */
295
296/*
297 @page Ecore_Config_Page The Enlightened Property Library
298
299 The Enlightened Property Library (Ecore_Config) is an abstraction
300 from the complexities of writing your own configuration. It provides
301 many features using the Enlightenment 17 development libraries.
302
303 To use the library, you:
304 @li Set the default values of your properties.
305 @li Load the configuration from a file. You must set the default values
306 first, so that the library knows the correct type of each argument.
307
308 The following examples show how to use the Enlightened Property Library:
309 @li @link config_basic_example.c config_basic_example.c @endlink
310 @li @link config_listener_example.c config_listener_example.c @endlink
311
312 */
313
314/**
315 @page X_Window_System_Page X Window System
316
317 The Ecore library includes a wrapper for handling the X window system.
318 This page briefly explains what the X window system is and various terms
319 that are used.
320 */
321
322#ifndef _ECORE_H
323#define _ECORE_H
324
325#ifdef _MSC_VER
326# include <Evil.h>
327#endif
328
329#include <Eina.h>
330
331/* This include has been added to support Eo in Ecore */
332#include <Eo.h>
333
334#ifdef EAPI
335# undef EAPI
336#endif
337
338#ifdef _WIN32
339# ifdef EFL_ECORE_BUILD
340# ifdef DLL_EXPORT
341# define EAPI __declspec(dllexport)
342# else
343# define EAPI
344# endif /* ! DLL_EXPORT */
345# else
346# define EAPI __declspec(dllimport)
347# endif /* ! EFL_ECORE_BUILD */
348#else
349# ifdef __GNUC__
350# if __GNUC__ >= 4
351# define EAPI __attribute__ ((visibility("default")))
352# else
353# define EAPI
354# endif
355# else
356# define EAPI
357# endif
358#endif /* ! _WIN32 */
359
360#ifdef _WIN32
361# include <winsock2.h>
362#elif defined (__FreeBSD__) || defined (__OpenBSD__)
363# include <sys/select.h>
364# include <signal.h>
365#elif defined (__ANDROID__)
366# include <sys/select.h>
367#else
368# include <sys/time.h>
369# if !defined (EXOTIC_NO_SIGNAL)
370# include <signal.h>
371# endif
372#endif
373
374#include <sys/types.h>
375
376#ifdef __cplusplus
377extern "C" {
378#endif
379
380/**
381 * @defgroup Ecore_Init_Group Ecore initialization, shutdown functions and reset on fork.
382 *
383 * @{
384 */
385
386EAPI int ecore_init(void);
387EAPI int ecore_shutdown(void);
388/**
389 * @}
390 */
391
392/**
393 * @defgroup Ecore_Main_Loop_Group Ecore main loop
394 *
395 * This group discusses functions that are acting on Ecore's main loop itself or
396 * on events and infrastructure directly linked to it. Most programs only need
397 * to start and end the main loop, the rest of the function discussed here are
398 * meant to be used in special situations, and with great care.
399 *
400 * For details on the usage of ecore's main loop and how it interacts with other
401 * ecore facilities see: @ref Ecore_Main_Loop_Page.
402 *
403 * @{
404 */
405
406#define ECORE_VERSION_MAJOR 1
407#define ECORE_VERSION_MINOR 8
408
409typedef struct _Ecore_Version
410{
411 int major;
412 int minor;
413 int micro;
414 int revision;
415} Ecore_Version;
416
417EAPI extern Ecore_Version *ecore_version;
418
419#define ECORE_CALLBACK_CANCEL EINA_FALSE /**< Return value to remove a callback */
420#define ECORE_CALLBACK_RENEW EINA_TRUE /**< Return value to keep a callback */
421
422#define ECORE_CALLBACK_PASS_ON EINA_TRUE /**< Return value to pass event to next handler */
423#define ECORE_CALLBACK_DONE EINA_FALSE /**< Return value to stop event handling */
424
425/**
426 * @typedef Ecore_Task_Cb Ecore_Task_Cb
427 * A callback run for a task (timer, idler, poller, animator, etc)
428 */
429typedef Eina_Bool (*Ecore_Task_Cb)(void *data);
430
431/**
432 * @typedef Ecore_Select_Function
433 * A function which can be used to replace select() in the main loop
434 */
435typedef int (*Ecore_Select_Function)(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, struct timeval *timeout);
436
437EAPI void ecore_main_loop_iterate(void);
438
439EAPI void ecore_main_loop_select_func_set(Ecore_Select_Function func);
440EAPI Ecore_Select_Function ecore_main_loop_select_func_get(void);
441
442EAPI Eina_Bool ecore_main_loop_glib_integrate(void);
443EAPI void ecore_main_loop_glib_always_integrate_disable(void);
444
445EAPI void ecore_main_loop_begin(void);
446EAPI void ecore_main_loop_quit(void);
447
448/**
449 * @typedef Ecore_Cb Ecore_Cb
450 * A generic callback called as a hook when a certain point in
451 * execution is reached.
452 */
453typedef void (*Ecore_Cb)(void *data);
454
455/**
456 * @typedef Ecore_Data_Cb Ecore_Data_Cb
457 * A callback which is used to return data to the main function
458 */
459typedef void *(*Ecore_Data_Cb)(void *data);
460
461/**
462 * Add a function to be called by ecore_fork_reset()
463 *
464 * This queues @p func to be called (and passed @p data as its argument) when
465 * ecore_fork_reset() is called. This allows other libraries and subsystems
466 * to also reset their internal state after a fork.
467 *
468 * @since 1.7
469 */
470EAPI Eina_Bool ecore_fork_reset_callback_add(Ecore_Cb func, const void *data);
471
472/**
473 * This removes the callback specified
474 *
475 * This deletes the callback added by ecore_fork_reset_callback_add() using
476 * the function and data pointer to specify which to remove.
477 *
478 * @since 1.7
479 */
480EAPI Eina_Bool ecore_fork_reset_callback_del(Ecore_Cb func, const void *data);
481
482/**
483 * Reset the ecore internal state after a fork
484 *
485 * Ecore maintains internal data that can be affected by the fork() system call
486 * which creates a duplicate of the current process. This also duplicates
487 * file descriptors which is problematic in that these file descriptors still
488 * point to their original sources. This function makes ecore reset internal
489 * state (e.g. pipes used for signalling between threads) so they function
490 * correctly afterwards.
491 *
492 * It is highly suggested that you call this function after any fork()
493 * system call inside the child process if you intend to use ecore features
494 * after this point and not call any exec() family functions. Not doing so
495 * will cause possible misbehaviour.
496 *
497 * @since 1.7
498 */
499EAPI void ecore_fork_reset(void);
500
501/**
502 * @brief Call callback asynchronously in the main loop.
503 * @since 1.1.0
504 *
505 * @param callback The callback to call in the main loop
506 * @param data The data to give to that call back
507 *
508 * For all calls that need to happen in the main loop (most EFL functions do),
509 * this helper function provides the infrastructure needed to do it safely
510 * by avoiding dead lock, race condition and properly wake up the main loop.
511 *
512 * Remember after that function call, you should never touch again the @p data
513 * in the thread, it is owned by the main loop and your callback should take
514 * care of freeing it if necessary.
515 */
516EAPI void ecore_main_loop_thread_safe_call_async(Ecore_Cb callback, void *data);
517
518/**
519 * @brief Call callback synchronously in the main loop.
520 * @since 1.1.0
521 *
522 * @param callback The callback to call in the main loop
523 * @param data The data to give to that call back
524 * @return the value returned by the callback in the main loop
525 *
526 * For all calls that need to happen in the main loop (most EFL functions do),
527 * this helper function provides the infrastructure needed to do it safely
528 * by avoiding dead lock, race condition and properly wake up the main loop.
529 *
530 * Remember this function will block until the callback is executed in the
531 * main loop. It can take time and you have no guaranty about the timeline.
532 */
533EAPI void *ecore_main_loop_thread_safe_call_sync(Ecore_Data_Cb callback, void *data);
534
535/**
536 * @brief This function suspend the main loop in a know state
537 * @since 1.1.0
538 *
539 * @result the number of time ecore_thread_main_loop_begin() has been called
540 * in this thread, if the main loop was suspended correctly. If not, it return @c -1.
541 *
542 * This function suspend the main loop in a know state, this let you
543 * use any EFL call you want after it return. Be carefully, the main loop
544 * is blocked until you call ecore_thread_main_loop_end(). This is
545 * the only sane way to achieve pseudo thread safety.
546 *
547 * Notice that until the main loop is blocked, the thread is blocked
548 * and their is noway around that.
549 *
550 * We still advise you, when possible, to use ecore_main_loop_thread_safe_call_async()
551 * as it will not block the thread nor the main loop.
552 */
553EAPI int ecore_thread_main_loop_begin(void);
554
555/**
556 * @brief Unlock the main loop.
557 * @since 1.1.0
558 *
559 * @result the number of time ecore_thread_main_loop_end() need to be called before
560 * the main loop is unlocked again. @c -1 will be returned if you are trying to unlock
561 * when there wasn't enough call to ecore_thread_main_loop_begin().
562 *
563 * After a call to ecore_thread_main_loop_begin(), you need to absolutely
564 * call ecore_thread_main_loop_end(), or you application will stay frozen.
565 */
566EAPI int ecore_thread_main_loop_end(void);
567
568/**
569 * @}
570 */
571
572/**
573 * @defgroup Ecore_Event_Group Ecore Event functions
574 *
575 * Ecore events provide two main features that are of use to those using ecore:
576 * creating events and being notified of events. Those two will usually be used
577 * in different contexts, creating events is mainly done by libraries wrapping
578 * some system functionality while being notified of events is mainly a
579 * necessity of applications.
580 *
581 * For a program to be notified of events it's interested in it needs to have a
582 * function to process the event and to register that function as the callback
583 * to the event, that's all:
584 * @code
585 * ecore_event_handler_add(EVENT_TYPE, _my_event_handler, some_data);
586 * ...
587 * static Eina_Bool
588 * _my_event_handler(void *data, int type, void *event)
589 * {
590 * //data is some_data
591 * //event is provided by whoever created the event
592 * //Do really cool stuff with event
593 * }
594 * @endcode
595 *
596 * One very important thing to note here is the @c EVENT_TYPE, to register a
597 * handler for an event you must know its type before hand. Ecore provides
598 * the following events which are emitted in response to POSIX
599 * signals(https://en.wikipedia.org/wiki/Signal_%28computing%29):
600 * @li @b ECORE_EVENT_SIGNAL_USER
601 * @li @b ECORE_EVENT_SIGNAL_HUP
602 * @li @b ECORE_EVENT_SIGNAL_POWER
603 * @li @b ECORE_EVENT_SIGNAL_EXIT
604 *
605 * @warning Don't override these using the @c signal or @c sigaction calls.
606 * These, however, aren't the only signals one can handle. Many
607 * libraries(including ecore modules) have their own signals that can be
608 * listened for and handled, to do that one only needs to know the type of the
609 * event. This information can be found on the documentation of the library
610 * emitting the signal, so, for example, for events related to windowing one
611 * would look in @ref Ecore_Evas_Group.
612 *
613 * Examples of libraries that integrate into ecore's main loop by providing
614 * events are @ref Ecore_Con_Group, @ref Ecore_Evas_Group and @ref
615 * Ecore_Exe_Group, amongst others. This usage can be divided into two parts,
616 * setup and adding events. The setup is very simple, all that needs doing is
617 * getting a type id for the event:
618 * @code
619 * int MY_EV_TYPE = ecore_event_type_new();
620 * @endcode
621 * @note This variable should be declared in the header since it'll be needed by
622 * anyone wishing to register a handler to your event.
623 *
624 * The complexity of adding of an event to the queue depends on whether that
625 * event sends uses @c event, if it doesn't it a one-liner:
626 * @code
627 * ecore_event_add(MY_EV_TYPE, NULL, NULL, NULL);
628 * @endcode
629 * The usage when an @c event is needed is not that much more complex and can be
630 * seen in @ref ecore_event_add.
631 *
632 * Examples that deals with events:
633 * @li @ref ecore_event_example_01_c
634 * @li @ref ecore_event_example_02_c
635 *
636 * @ingroup Ecore_Main_Loop_Group
637 *
638 * @{
639 */
640
641#define ECORE_EVENT_NONE 0
642#define ECORE_EVENT_SIGNAL_USER 1 /**< User signal event */
643#define ECORE_EVENT_SIGNAL_HUP 2 /**< Hup signal event */
644#define ECORE_EVENT_SIGNAL_EXIT 3 /**< Exit signal event */
645#define ECORE_EVENT_SIGNAL_POWER 4 /**< Power signal event */
646#define ECORE_EVENT_SIGNAL_REALTIME 5 /**< Realtime signal event */
647#define ECORE_EVENT_COUNT 6
648
649typedef struct _Ecore_Win32_Handler Ecore_Win32_Handler; /**< A handle for HANDLE handlers on Windows */
650typedef struct _Ecore_Event_Handler Ecore_Event_Handler; /**< A handle for an event handler */
651typedef struct _Ecore_Event_Filter Ecore_Event_Filter; /**< A handle for an event filter */
652typedef struct _Ecore_Event Ecore_Event; /**< A handle for an event */
653typedef struct _Ecore_Event_Signal_User Ecore_Event_Signal_User; /**< User signal event */
654typedef struct _Ecore_Event_Signal_Hup Ecore_Event_Signal_Hup; /**< Hup signal event */
655typedef struct _Ecore_Event_Signal_Exit Ecore_Event_Signal_Exit; /**< Exit signal event */
656typedef struct _Ecore_Event_Signal_Power Ecore_Event_Signal_Power; /**< Power signal event */
657typedef struct _Ecore_Event_Signal_Realtime Ecore_Event_Signal_Realtime; /**< Realtime signal event */
658
659/**
660 * @typedef Ecore_Filter_Cb
661 * A callback used for filtering events from the main loop.
662 */
663typedef Eina_Bool (*Ecore_Filter_Cb)(void *data, void *loop_data, int type, void *event);
664
665/**
666 * @typedef Ecore_End_Cb Ecore_End_Cb
667 * This is the callback which is called at the end of a function,
668 * usually for cleanup purposes.
669 */
670typedef void (*Ecore_End_Cb)(void *user_data, void *func_data);
671
672/**
673 * @typedef Ecore_Event_Handler_Cb Ecore_Event_Handler_Cb
674 * A callback used by the main loop to handle events of a specified
675 * type.
676 */
677typedef Eina_Bool (*Ecore_Event_Handler_Cb)(void *data, int type, void *event);
678
679struct _Ecore_Event_Signal_User /** User signal event */
680{
681 int number; /**< The signal number. Either 1 or 2 */
682 void *ext_data; /**< Extension data - not used */
683
684#if !defined (_WIN32) && !defined (__lv2ppu__) && !defined (EXOTIC_NO_SIGNAL)
685 siginfo_t data; /**< Signal info */
686#endif
687};
688
689struct _Ecore_Event_Signal_Hup /** Hup signal event */
690{
691 void *ext_data; /**< Extension data - not used */
692
693#if !defined (_WIN32) && !defined (__lv2ppu__) && !defined (EXOTIC_NO_SIGNAL)
694 siginfo_t data; /**< Signal info */
695#endif
696};
697
698struct _Ecore_Event_Signal_Exit /** Exit request event */
699{
700 Eina_Bool interrupt : 1; /**< Set if the exit request was an interrupt signal*/
701 Eina_Bool quit : 1; /**< set if the exit request was a quit signal */
702 Eina_Bool terminate : 1; /**< Set if the exit request was a terminate signal */
703 void *ext_data; /**< Extension data - not used */
704
705#if !defined (_WIN32) && !defined (__lv2ppu__) && !defined (EXOTIC_NO_SIGNAL)
706 siginfo_t data; /**< Signal info */
707#endif
708};
709
710struct _Ecore_Event_Signal_Power /** Power event */
711{
712 void *ext_data; /**< Extension data - not used */
713
714#if !defined (_WIN32) && !defined (__lv2ppu__) && !defined (EXOTIC_NO_SIGNAL)
715 siginfo_t data; /**< Signal info */
716#endif
717};
718
719struct _Ecore_Event_Signal_Realtime /** Realtime event */
720{
721 int num; /**< The realtime signal's number */
722
723#if !defined (_WIN32) && !defined (__lv2ppu__) && !defined (EXOTIC_NO_SIGNAL)
724 siginfo_t data; /**< Signal info */
725#endif
726};
727
728/**
729 * @brief Add an event handler.
730 * @param type The type of the event this handler will get called for
731 * @param func The function to call when the event is found in the queue
732 * @param data A data pointer to pass to the called function @p func
733 * @return A new Event handler, or @c NULL on failure.
734 *
735 * Add an event handler to the list of handlers. This will, on success, return
736 * a handle to the event handler object that was created, that can be used
737 * later to remove the handler using ecore_event_handler_del(). The @p type
738 * parameter is the integer of the event type that will trigger this callback
739 * to be called. The callback @p func is called when this event is processed
740 * and will be passed the event type, a pointer to the private event
741 * structure that is specific to that event type, and a data pointer that is
742 * provided in this call as the @p data parameter.
743 *
744 * When the callback @p func is called, it must return 1 or 0. If it returns
745 * 1 (or ECORE_CALLBACK_PASS_ON), It will keep being called as per normal, for
746 * each handler set up for that event type. If it returns 0 (or
747 * ECORE_CALLBACK_DONE), it will cease processing handlers for that particular
748 * event, so all handler set to handle that event type that have not already
749 * been called, will not be.
750 */
751EAPI Ecore_Event_Handler *ecore_event_handler_add(int type, Ecore_Event_Handler_Cb func, const void *data);
752/**
753 * @brief Delete an event handler.
754 * @param event_handler Event handler handle to delete
755 * @return Data passed to handler
756 *
757 * Delete a specified event handler from the handler list. On success this will
758 * delete the event handler and return the pointer passed as @p data when the
759 * handler was added by ecore_event_handler_add(). On failure @c NULL will be
760 * returned. Once a handler is deleted it will no longer be called.
761 */
762EAPI void *ecore_event_handler_del(Ecore_Event_Handler *event_handler);
763/**
764 * @brief Add an event to the event queue.
765 * @param type The event type to add to the end of the event queue
766 * @param ev The data structure passed as @c event to event handlers
767 * @param func_free The function to be called to free @a ev
768 * @param data The data pointer to be passed to the free function
769 * @return A Handle for that event on success, otherwise NULL
770 *
771 * If it succeeds, an event of type @a type will be added to the queue for
772 * processing by event handlers added by ecore_event_handler_add(). The @a ev
773 * parameter will be passed as the @c event parameter of the handler. When the
774 * event is no longer needed, @a func_free will be called and passed @a ev for
775 * cleaning up. If @p func_free is NULL, free() will be called with the private
776 * structure pointer.
777 */
778EAPI Ecore_Event *ecore_event_add(int type, void *ev, Ecore_End_Cb func_free, void *data);
779/**
780 * @brief Delete an event from the queue.
781 * @param event The event handle to delete
782 * @return The data pointer originally set for the event free function
783 *
784 * This deletes the event @p event from the event queue, and returns the
785 * @p data parameter originally set when adding it with ecore_event_add(). This
786 * does not immediately call the free function, and it may be called later on
787 * cleanup, and so if the free function depends on the data pointer to work,
788 * you should defer cleaning of this till the free function is called later.
789 */
790EAPI void *ecore_event_del(Ecore_Event *event);
791/**
792 * @brief Get the data associated with an #Ecore_Event_Handler
793 * @param eh The event handler
794 * @return The data
795 *
796 * This function returns the data previously associated with @p eh by
797 * ecore_event_handler_add().
798 */
799EAPI void *ecore_event_handler_data_get(Ecore_Event_Handler *eh);
800/**
801 * @brief Set the data associated with an #Ecore_Event_Handler
802 * @param eh The event handler
803 * @param data The data to associate
804 * @return The previous data
805 *
806 * This function sets @p data to @p eh and returns the old data pointer
807 * which was previously associated with @p eh by ecore_event_handler_add().
808 */
809EAPI void *ecore_event_handler_data_set(Ecore_Event_Handler *eh, const void *data);
810/**
811 * @brief Allocate a new event type id sensibly and return the new id.
812 * @return A new event type id.
813 *
814 * This function allocates a new event type id and returns it. Once an event
815 * type has been allocated it can never be de-allocated during the life of
816 * the program. There is no guarantee of the contents of this event ID, or how
817 * it is calculated, except that the ID will be unique to the current instance
818 * of the process.
819 */
820EAPI int ecore_event_type_new(void);
821/**
822 * @brief Add a filter the current event queue.
823 *
824 * @param func_start Function to call just before filtering and return data
825 * @param func_filter Function to call on each event
826 * @param func_end Function to call after the queue has been filtered
827 * @param data Data to pass to the filter functions
828 * @return A filter handle on success, @c NULL otherwise.
829 *
830 * Adds a callback to filter events from the event queue. Filters are called on
831 * the queue just before Event handler processing to try and remove redundant
832 * events. Just as processing is about to start @a func_start is called and
833 * passed the @a data pointer, the return value of this functions is passed to
834 * @a func_filter as loop_data. @a func_filter is also passed @a data and the
835 * event type and event structure. If this @a func_filter returns
836 * @c EINA_FALSE, the event is removed from the queue, if it returns
837 * @c EINA_TRUE, the event is kept. When processing is finished @p func_end is
838 * called and is passed the loop_data(returned by @c func_start) and @p data
839 * pointer to clean up.
840 */
841EAPI Ecore_Event_Filter *ecore_event_filter_add(Ecore_Data_Cb func_start, Ecore_Filter_Cb func_filter, Ecore_End_Cb func_end, const void *data);
842/**
843 * @brief Delete an event filter.
844 * @param ef The event filter handle
845 * @return The data set for the filter on success, @c NULL otherwise.
846 *
847 * Delete a filter that has been added by its @p ef handle.
848 */
849EAPI void *ecore_event_filter_del(Ecore_Event_Filter *ef);
850/**
851 * @brief Return the current event type being handled.
852 * @return The current event type being handled if inside a handler callback,
853 * ECORE_EVENT_NONE otherwise
854 *
855 * If the program is currently inside an Ecore event handler callback this
856 * will return the type of the current event being processed.
857 *
858 * This is useful when certain Ecore modules such as Ecore_Evas "swallow"
859 * events and not all the original information is passed on. In special cases
860 * this extra information may be useful or needed and using this call can let
861 * the program know if the event type being handled is one it wants to get more
862 * information about.
863 */
864EAPI int ecore_event_current_type_get(void);
865/**
866 * @brief Return the current event type pointer handled.
867 * @return The current event pointer being handled if inside a handler callback,
868 * @c NULL otherwise.
869 *
870 * If the program is currently inside an Ecore event handler callback this
871 * will return the pointer of the current event being processed.
872 *
873 * This is useful when certain Ecore modules such as Ecore_Evas "swallow"
874 * events and not all the original information is passed on. In special cases
875 * this extra information may be useful or needed and using this call can let
876 * the program access the event data if the type of the event is handled by
877 * the program.
878 */
879EAPI void *ecore_event_current_event_get(void);
880
881/**
882 * @}
883 */
884
885/**
886 * @defgroup Ecore_Exe_Group Process Spawning Functions
887 *
888 * This module is responsible for managing portable processes using Ecore.
889 * With this module you're able to spawn processes and you also can pause,
890 * quit your spawned processes.
891 * An interaction between your process and those spawned is possible
892 * using pipes or signals.
893 *
894 * Example
895 * @li @ref Ecore_exe_simple_example_c
896 *
897 * @ingroup Ecore_Main_Loop_Group
898 *
899 * @{
900 */
901
902/** Inherit priority from parent process */
903#define ECORE_EXE_PRIORITY_INHERIT 9999
904
905EAPI extern int ECORE_EXE_EVENT_ADD; /**< A child process has been added */
906EAPI extern int ECORE_EXE_EVENT_DEL; /**< A child process has been deleted (it exited, naming consistent with the rest of ecore). */
907EAPI extern int ECORE_EXE_EVENT_DATA; /**< Data from a child process. */
908EAPI extern int ECORE_EXE_EVENT_ERROR; /**< Errors from a child process. */
909
910/**
911 * @enum _Ecore_Exe_Flags
912 * Flags for executing a child with its stdin and/or stdout piped back.
913 */
914enum _Ecore_Exe_Flags /* flags for executing a child with its stdin and/or stdout piped back */
915{
916 ECORE_EXE_NONE = 0, /**< No exe flags at all */
917 ECORE_EXE_PIPE_READ = 1, /**< Exe Pipe Read mask */
918 ECORE_EXE_PIPE_WRITE = 2, /**< Exe Pipe Write mask */
919 ECORE_EXE_PIPE_ERROR = 4, /**< Exe Pipe error mask */
920 ECORE_EXE_PIPE_READ_LINE_BUFFERED = 8, /**< Reads are buffered until a newline and split 1 line per Ecore_Exe_Event_Data_Line */
921 ECORE_EXE_PIPE_ERROR_LINE_BUFFERED = 16, /**< Errors are buffered until a newline and split 1 line per Ecore_Exe_Event_Data_Line */
922 ECORE_EXE_PIPE_AUTO = 32, /**< stdout and stderr are buffered automatically */
923 ECORE_EXE_RESPAWN = 64, /**< FIXME: Exe is restarted if it dies */
924 ECORE_EXE_USE_SH = 128, /**< Use /bin/sh to run the command. */
925 ECORE_EXE_NOT_LEADER = 256, /**< Do not use setsid() to have the executed process be its own session leader */
926 ECORE_EXE_TERM_WITH_PARENT = 512 /**< Makes child receive SIGTERM when parent dies. */
927};
928typedef enum _Ecore_Exe_Flags Ecore_Exe_Flags;
929
930/**
931 * @enum _Ecore_Exe_Win32_Priority
932 * Defines the priority of the proccess.
933 */
934enum _Ecore_Exe_Win32_Priority
935{
936 ECORE_EXE_WIN32_PRIORITY_IDLE, /**< Idle priority, for monitoring the system */
937 ECORE_EXE_WIN32_PRIORITY_BELOW_NORMAL, /**< Below default priority */
938 ECORE_EXE_WIN32_PRIORITY_NORMAL, /**< Default priority */
939 ECORE_EXE_WIN32_PRIORITY_ABOVE_NORMAL, /**< Above default priority */
940 ECORE_EXE_WIN32_PRIORITY_HIGH, /**< High priority, use with care as other threads in the system will not get processor time */
941 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 */
942};
943typedef enum _Ecore_Exe_Win32_Priority Ecore_Exe_Win32_Priority;
944
945typedef struct _Ecore_Exe Ecore_Exe; /**< A handle for spawned processes */
946
947/**
948 * @typedef Ecore_Exe_Cb Ecore_Exe_Cb
949 * A callback to run with the associated @ref Ecore_Exe, usually
950 * for cleanup purposes.
951 */
952typedef void (*Ecore_Exe_Cb)(void *data, const Ecore_Exe *exe);
953
954typedef struct _Ecore_Exe_Event_Add Ecore_Exe_Event_Add; /**< Spawned Exe add event */
955typedef struct _Ecore_Exe_Event_Del Ecore_Exe_Event_Del; /**< Spawned Exe exit event */
956typedef struct _Ecore_Exe_Event_Data_Line Ecore_Exe_Event_Data_Line; /**< Lines from a child process */
957typedef struct _Ecore_Exe_Event_Data Ecore_Exe_Event_Data; /**< Data from a child process */
958
959struct _Ecore_Exe_Event_Add /** Process add event */
960{
961 Ecore_Exe *exe; /**< The handle to the added process */
962 void *ext_data; /**< Extension data - not used */
963};
964
965struct _Ecore_Exe_Event_Del /** Process exit event */
966{
967 pid_t pid; /**< The process ID of the process that exited */
968 int exit_code; /**< The exit code of the process */
969 Ecore_Exe *exe; /**< The handle to the exited process, or @c NULL if not found */
970 int exit_signal; /** < The signal that caused the process to exit */
971 Eina_Bool exited : 1; /** < set to 1 if the process exited of its own accord */
972 Eina_Bool signalled : 1; /** < set to 1 id the process exited due to uncaught signal */
973 void *ext_data; /**< Extension data - not used */
974#if !defined (_WIN32) && !defined (__lv2ppu__) && !defined (EXOTIC_NO_SIGNAL)
975 siginfo_t data; /**< Signal info */
976#endif
977};
978
979struct _Ecore_Exe_Event_Data_Line /**< Lines from a child process */
980{
981 char *line; /**< The bytes of a line of buffered data */
982 int size; /**< The size of the line buffer in bytes */
983};
984
985struct _Ecore_Exe_Event_Data /** Data from a child process event */
986{
987 Ecore_Exe *exe; /**< The handle to the process */
988 void *data; /**< the raw binary data from the child process that was received */
989 int size; /**< the size of this data in bytes */
990 Ecore_Exe_Event_Data_Line *lines; /**< an array of line data if line buffered, the last one has it's line member set to @c NULL */
991};
992
993EAPI void ecore_exe_run_priority_set(int pri);
994EAPI int ecore_exe_run_priority_get(void);
995EAPI Ecore_Exe *ecore_exe_run(const char *exe_cmd, const void *data);
996EAPI Ecore_Exe *ecore_exe_pipe_run(const char *exe_cmd, Ecore_Exe_Flags flags, const void *data);
997EAPI void ecore_exe_callback_pre_free_set(Ecore_Exe *exe, Ecore_Exe_Cb func);
998EAPI Eina_Bool ecore_exe_send(Ecore_Exe *exe, const void *data, int size);
999EAPI void ecore_exe_close_stdin(Ecore_Exe *exe);
1000EAPI void ecore_exe_auto_limits_set(Ecore_Exe *exe, int start_bytes, int end_bytes, int start_lines, int end_lines);
1001EAPI Ecore_Exe_Event_Data *ecore_exe_event_data_get(Ecore_Exe *exe, Ecore_Exe_Flags flags);
1002EAPI void ecore_exe_event_data_free(Ecore_Exe_Event_Data *data);
1003EAPI void *ecore_exe_free(Ecore_Exe *exe);
1004EAPI pid_t ecore_exe_pid_get(const Ecore_Exe *exe);
1005EAPI void ecore_exe_tag_set(Ecore_Exe *exe, const char *tag);
1006EAPI const char *ecore_exe_tag_get(const Ecore_Exe *exe);
1007EAPI const char *ecore_exe_cmd_get(const Ecore_Exe *exe);
1008EAPI void *ecore_exe_data_get(const Ecore_Exe *exe);
1009EAPI void *ecore_exe_data_set(Ecore_Exe *exe, void *data);
1010EAPI Ecore_Exe_Flags ecore_exe_flags_get(const Ecore_Exe *exe);
1011EAPI void ecore_exe_pause(Ecore_Exe *exe);
1012EAPI void ecore_exe_continue(Ecore_Exe *exe);
1013EAPI void ecore_exe_interrupt(Ecore_Exe *exe);
1014EAPI void ecore_exe_quit(Ecore_Exe *exe);
1015EAPI void ecore_exe_terminate(Ecore_Exe *exe);
1016EAPI void ecore_exe_kill(Ecore_Exe *exe);
1017EAPI void ecore_exe_signal(Ecore_Exe *exe, int num);
1018EAPI void ecore_exe_hup(Ecore_Exe *exe);
1019
1020/**
1021 * @}
1022 */
1023
1024/**
1025 * @defgroup Ecore_FD_Handler_Group File Descriptor Handling Functions
1026 *
1027 * @brief Functions that deal with file descriptor handlers.
1028 *
1029 * File descriptor handlers facilitate reading, writing and checking for errors
1030 * without blocking the program or doing expensive pooling. This can be used to
1031 * monitor a socket, pipe, or other stream for which an FD can be had.
1032 *
1033 * @warning File descriptor handlers can't be used to monitor for file creation,
1034 * modification or deletion, see @ref Ecore_File_Group for this.
1035 *
1036 * One common FD to be monitored is the standard input(stdin), monitoring it for
1037 * reading requires a single call:
1038 * @code
1039 * static Eina_Bool
1040 * _my_cb_func(void *data, Ecore_Fd_Handler *handler)
1041 * {
1042 * char c;
1043 * scanf("%c", &c); //Guaranteed not to block
1044 * ... do stuff with c ...
1045 * }
1046 * ecore_main_fd_handler_add(STDIN_FILENO, ECORE_FD_READ, _my_cb_func, NULL, NULL, NULL);
1047 * @endcode
1048 *
1049 * When using a socket, pipe or other stream it's important to remember that
1050 * errors may occur and as such to monitor not only for reading/writing but also
1051 * for errors using the @ref ECORE_FD_ERROR flag.
1052 *
1053 * Example of use of a file descriptor handler:
1054 * @li @ref ecore_fd_handler_example_c
1055 *
1056 * @ingroup Ecore_Main_Loop_Group
1057 *
1058 * @{
1059 */
1060
1061typedef struct _Ecore_Fd_Handler Ecore_Fd_Handler; /**< A handle for Fd handlers */
1062
1063/**
1064 * @enum _Ecore_Fd_Handler_Flags
1065 * What to monitor the file descriptor for: reading, writing or error.
1066 */
1067enum _Ecore_Fd_Handler_Flags
1068{
1069 ECORE_FD_READ = 1, /**< Fd Read mask */
1070 ECORE_FD_WRITE = 2, /**< Fd Write mask */
1071 ECORE_FD_ERROR = 4 /**< Fd Error mask */
1072};
1073typedef enum _Ecore_Fd_Handler_Flags Ecore_Fd_Handler_Flags;
1074
1075/**
1076 * @typedef Ecore_Fd_Cb Ecore_Fd_Cb
1077 * A callback used by an @ref Ecore_Fd_Handler.
1078 */
1079typedef Eina_Bool (*Ecore_Fd_Cb)(void *data, Ecore_Fd_Handler *fd_handler);
1080
1081/**
1082 * @typedef Ecore_Fd_Prep_Cb Ecore_Fd_Prep_Cb
1083 * A callback used by an @ref Ecore_Fd_Handler.
1084 */
1085typedef void (*Ecore_Fd_Prep_Cb)(void *data, Ecore_Fd_Handler *fd_handler);
1086
1087/**
1088 * @typedef Ecore_Win32_Handle_Cb Ecore_Win32_Handle_Cb
1089 * A callback used by an @ref Ecore_Win32_Handler.
1090 */
1091typedef Eina_Bool (*Ecore_Win32_Handle_Cb)(void *data, Ecore_Win32_Handler *wh);
1092
1093/**
1094 * @brief Adds a callback for activity on the given file descriptor.
1095 *
1096 * @param fd The file descriptor to watch.
1097 * @param flags To monitor it for reading use @c ECORE_FD_READ, for writing @c
1098 * ECORE_FD_WRITE, and for error @c ECORE_FD_ERROR. Values by |(ored).
1099 * @param func The callback function.
1100 * @param data The data to pass to the callback.
1101 * @param buf_func The function to call to check if any data has been buffered
1102 * and already read from the fd. May be @c NULL.
1103 * @param buf_data The data to pass to the @p buf_func function.
1104 * @return A fd handler handle on success, @c NULL otherwise.
1105 *
1106 * @a func will be called during the execution of @ref Ecore_Main_Loop_Page
1107 * when the file descriptor is available for reading, writing, or there has been
1108 * an error(depending on the given @a flags).
1109 *
1110 * When @a func returns ECORE_CALLBACK_CANCEL, it indicates that the
1111 * handler should be marked for deletion (identical to calling @ref
1112 * ecore_main_fd_handler_del).
1113 *
1114 * @warning @a buf_func is meant for @b internal use only and should be @b
1115 * avoided.
1116 *
1117 * The return value of @a buf_func has a different meaning, when it returns
1118 * ECORE_CALLBACK_CANCEL, it indicates that @a func @b shouldn't be called, and
1119 * when it returns ECORE_CALLBACK_RENEW it indicates @a func should be called.
1120 * The return value of @a buf_func will not cause the FD handler to be deleted.
1121 *
1122 * @a buf_func is called during event loop handling to check if data that has
1123 * been read from the file descriptor is in a buffer and is available to read.
1124 * Some systems, notably xlib, handle their own buffering, and would otherwise
1125 * not work with select(). These systems should use a @a buf_func. This is a
1126 * most annoying hack, only ecore_x uses it, so refer to that for an example.
1127 *
1128 * @warning This function should @b not be used for monitoring "normal" files, like text files.
1129 *
1130 */
1131EAPI Ecore_Fd_Handler *ecore_main_fd_handler_add(int fd, Ecore_Fd_Handler_Flags flags, Ecore_Fd_Cb func, const void *data, Ecore_Fd_Cb buf_func, const void *buf_data);
1132
1133/**
1134 * @brief Adds a callback for activity on the given file descriptor.
1135 *
1136 * @param fd The file descriptor to watch.
1137 * @param flags To monitor it for reading use @c ECORE_FD_READ, for writing @c
1138 * ECORE_FD_WRITE, and for error @c ECORE_FD_ERROR. Values by |(ored).
1139 * @param func The callback function.
1140 * @param data The data to pass to the callback.
1141 * @param buf_func The function to call to check if any data has been buffered
1142 * and already read from the fd. May be @c NULL.
1143 * @param buf_data The data to pass to the @p buf_func function.
1144 * @return A fd handler handle on success, @c NULL otherwise.
1145 *
1146 * This function is identical to ecore_main_fd_handler_add, except that it supports regular files.
1147 * @warning This function should ONLY be called with ECORE_FD_ERROR, otherwise it will call the fd
1148 * handler constantly.
1149 * @warning Do not use this function unless you know what you are doing.
1150 *
1151 * @since 1.7
1152 */
1153EAPI Ecore_Fd_Handler *ecore_main_fd_handler_file_add(int fd, Ecore_Fd_Handler_Flags flags, Ecore_Fd_Cb func, const void *data, Ecore_Fd_Cb buf_func, const void *buf_data);
1154
1155/**
1156 * @brief Set the prepare callback with data for a given #Ecore_Fd_Handler
1157 *
1158 * @param fd_handler The fd handler
1159 * @param func The prep function
1160 * @param data The data to pass to the prep function
1161 *
1162 * This function will be called prior to any fd handler's callback function
1163 * (even the other fd handlers), before entering the main loop select function.
1164 *
1165 * @note Once a prepare callback is set for a fd handler, it cannot be changed.
1166 * You need to delete the fd handler and create a new one, to set another
1167 * callback.
1168 * @note You probably don't need this function. It is only necessary for very
1169 * uncommon cases that need special behavior.
1170 */
1171EAPI void ecore_main_fd_handler_prepare_callback_set(Ecore_Fd_Handler *fd_handler, Ecore_Fd_Prep_Cb func, const void *data);
1172/**
1173 * @brief Marks an FD handler for deletion.
1174 * @param fd_handler The FD handler.
1175 * @return The data pointer set using @ref ecore_main_fd_handler_add, for
1176 * @a fd_handler on success, @c NULL otherwise.
1177 * This function marks an fd handler to be deleted during an iteration of the
1178 * main loop. It does NOT close the associated fd!
1179 *
1180 * @warning If the underlying fd is already closed ecore may complain if the
1181 * main loop is using epoll internally, and also in some rare cases this may
1182 * cause crashes and instability. Remember to delete your fd handlers before the
1183 * fds they listen to are closed.
1184 */
1185EAPI void *ecore_main_fd_handler_del(Ecore_Fd_Handler *fd_handler);
1186/**
1187 * @brief Retrieves the file descriptor that the given handler is handling.
1188 * @param fd_handler The given FD handler.
1189 * @return The file descriptor the handler is watching.
1190 */
1191EAPI int ecore_main_fd_handler_fd_get(Ecore_Fd_Handler *fd_handler);
1192/**
1193 * @brief Gets which flags are active on an FD handler.
1194 * @param fd_handler The given FD handler.
1195 * @param flags The flags, @c ECORE_FD_READ, @c ECORE_FD_WRITE or
1196 * @c ECORE_FD_ERROR to query.
1197 * @return @c EINA_TRUE if any of the given flags are active, @c EINA_FALSE
1198 * otherwise.
1199 */
1200EAPI Eina_Bool ecore_main_fd_handler_active_get(Ecore_Fd_Handler *fd_handler, Ecore_Fd_Handler_Flags flags);
1201/**
1202 * @brief Set what active streams the given FD handler should be monitoring.
1203 * @param fd_handler The given FD handler.
1204 * @param flags The flags to be watching.
1205 */
1206EAPI void ecore_main_fd_handler_active_set(Ecore_Fd_Handler *fd_handler, Ecore_Fd_Handler_Flags flags);
1207
1208EAPI Ecore_Win32_Handler *ecore_main_win32_handler_add(void *h, Ecore_Win32_Handle_Cb func, const void *data);
1209EAPI void *ecore_main_win32_handler_del(Ecore_Win32_Handler *win32_handler);
1210
1211/**
1212 * @}
1213 */
1214
1215/**
1216 * @defgroup Ecore_Poller_Group Ecore Poll functions
1217 *
1218 * Ecore poller provides infrastructure for the creation of pollers. Pollers
1219 * are, in essence, callbacks that share a single timer per type. Because not
1220 * all pollers need to be called at the same frequency the user may specify the
1221 * frequency in ticks(each expiration of the shared timer is called a tick, in
1222 * ecore poller parlance) for each added poller. Ecore pollers should only be
1223 * used when the poller doesn't have specific requirements on the exact times
1224 * to poll.
1225 *
1226 * This architecture means that the main loop is only woken up once to handle
1227 * all pollers of that type, this will save power as the CPU has more of a
1228 * chance to go into a low power state the longer it is asleep for, so this
1229 * should be used in situations where power usage is a concern.
1230 *
1231 * For now only 1 core poller type is supported: ECORE_POLLER_CORE, the default
1232 * interval for ECORE_POLLER_CORE is 0.125(or 1/8th) second.
1233 *
1234 * The creation of a poller is extremely simple and only requires one line:
1235 * @code
1236 * ecore_poller_add(ECORE_POLLER_CORE, 1, my_poller_function, NULL);
1237 * @endcode
1238 * This sample creates a poller to call @c my_poller_function at every tick with
1239 * @c NULL as data.
1240 *
1241 * Example:
1242 * @li @ref ecore_poller_example_c
1243 *
1244 * @ingroup Ecore_Main_Loop_Group
1245 *
1246 * @{
1247 */
1248
1249/**
1250 * @enum _Ecore_Poller_Type
1251 * Defines the frequency of ticks for the poller.
1252 */
1253enum _Ecore_Poller_Type /* Poller types */
1254{
1255 ECORE_POLLER_CORE = 0 /**< The core poller interval */
1256};
1257typedef enum _Ecore_Poller_Type Ecore_Poller_Type;
1258
1259/*
1260 * @since 1.8
1261 */
1262
1263typedef Eo Ecore_Poller; /**< A handle for pollers */
1264
1265#define ECORE_POLLER_CLASS ecore_poller_class_get()
1266const Eo_Class *ecore_poller_class_get(void) EINA_CONST;
1267extern EAPI Eo_Op ECORE_POLLER_BASE_ID;
1268
1269enum
1270{
1271 ECORE_POLLER_SUB_ID_CONSTRUCTOR,
1272 ECORE_POLLER_SUB_ID_INTERVAL_SET,
1273 ECORE_POLLER_SUB_ID_INTERVAL_GET,
1274 ECORE_POLLER_SUB_ID_LAST,
1275};
1276
1277#define ECORE_POLLER_ID(sub_id) (ECORE_POLLER_BASE_ID + sub_id)
1278
1279/**
1280 * @def ecore_poller_constructor
1281 * @since 1.8
1282 *
1283 * Contructor with parameters for Ecore Poller.
1284 *
1285 * @param[in] type
1286 * @param[in] interval
1287 * @param[in] func
1288 * @param[in] data
1289 *
1290 */
1291#define ecore_poller_constructor(type, interval, func, data) ECORE_POLLER_ID(ECORE_POLLER_SUB_ID_CONSTRUCTOR), EO_TYPECHECK(Ecore_Poller_Type, type), EO_TYPECHECK(int, interval), EO_TYPECHECK(Ecore_Task_Cb, func), EO_TYPECHECK(const void *, data)
1292
1293/**
1294 * @def ecore_poller_interval_set
1295 * @since 1.8
1296 *
1297 * Changes the polling interval rate of poller.
1298 *
1299 * @param[in] interval
1300 * @param[out] ret
1301 *
1302 * @see ecore_poller_poller_interval_set
1303 */
1304#define ecore_poller_interval_set(interval, ret) ECORE_POLLER_ID(ECORE_POLLER_SUB_ID_INTERVAL_SET), EO_TYPECHECK(int, interval), EO_TYPECHECK(Eina_Bool *, ret)
1305
1306/**
1307 * @def ecore_poller_interval_get
1308 * @since 1.8
1309 *
1310 * Gets the polling interval rate of poller.
1311 *
1312 * @param[out] ret
1313 *
1314 * @see ecore_poller_poller_interval_get
1315 */
1316#define ecore_poller_interval_get(ret) ECORE_POLLER_ID(ECORE_POLLER_SUB_ID_INTERVAL_GET), EO_TYPECHECK(int *, ret)
1317
1318
1319/**
1320 * @brief Sets the time(in seconds) between ticks for the given poller type.
1321 * @param type The poller type to adjust.
1322 * @param poll_time The time(in seconds) between ticks of the timer.
1323 *
1324 * This will adjust the time between ticks of the given timer type defined by
1325 * @p type to the time period defined by @p poll_time.
1326 */
1327EAPI void ecore_poller_poll_interval_set(Ecore_Poller_Type type, double poll_time);
1328/**
1329 * @brief Gets the time(in seconds) between ticks for the given poller type.
1330 * @param type The poller type to query.
1331 * @return The time in seconds between ticks of the poller timer.
1332 *
1333 * This will get the time between ticks of the specified poller timer.
1334 */
1335EAPI double ecore_poller_poll_interval_get(Ecore_Poller_Type type);
1336/**
1337 * @brief Changes the polling interval rate of @p poller.
1338 * @param poller The Ecore_Poller to change the interval of.
1339 * @param interval The tick interval to set; must be a power of 2 and <= 32768.
1340 * @return Returns true on success, false on failure.
1341 *
1342 * This allows the changing of a poller's polling interval. It is useful when
1343 * you want to alter a poll rate without deleting and re-creating a poller.
1344 */
1345EAPI Eina_Bool ecore_poller_poller_interval_set(Ecore_Poller *poller, int interval);
1346/**
1347 * @brief Gets the polling interval rate of @p poller.
1348 * @param poller The Ecore_Poller to change the interval of.
1349 * @return Returns the interval, in ticks, that @p poller polls at.
1350 *
1351 * This returns a poller's polling interval, or 0 on error.
1352 */
1353EAPI int ecore_poller_poller_interval_get(Ecore_Poller *poller);
1354/**
1355 * @brief Creates a poller to call the given function at a particular tick interval.
1356 * @param type The ticker type to attach the poller to. Must be ECORE_POLLER_CORE.
1357 * @param interval The poll interval.
1358 * @param func The poller function.
1359 * @param data Data to pass to @a func when it is called.
1360 * @return A poller object on success, @c NULL otherwise.
1361 *
1362 * This function adds @a func as a poller callback that will be called every @a
1363 * interval ticks together with other pollers of type @a type. @a func will be
1364 * passed the @p data pointer as a parameter.
1365 *
1366 * The @p interval must be between 1 and 32768 inclusive, and must be a power of
1367 * 2 (i.e. 1, 2, 4, 8, 16, ... 16384, 32768). The exact tick in which @a func
1368 * will be called is undefined, as only the interval between calls can be
1369 * defined. Ecore will endeavor to keep pollers synchronized and to call as
1370 * many in 1 wakeup event as possible. If @a interval is not a power of two, the
1371 * closest power of 2 greater than @a interval will be used.
1372 *
1373 * When the poller @p func is called, it must return a value of either
1374 * ECORE_CALLBACK_RENEW(or 1) or ECORE_CALLBACK_CANCEL(or 0). If it
1375 * returns 1, it will be called again at the next tick, or if it returns
1376 * 0 it will be deleted automatically making any references/handles for it
1377 * invalid.
1378 */
1379EAPI Ecore_Poller *ecore_poller_add(Ecore_Poller_Type type, int interval, Ecore_Task_Cb func, const void *data);
1380/**
1381 * @brief Delete the specified poller from the timer list.
1382 * @param poller The poller to delete.
1383 * @return The data pointer set for the timer when @ref ecore_poller_add was
1384 * called on success, @c NULL otherwise.
1385 *
1386 * @note @a poller must be a valid handle. If the poller function has already
1387 * returned 0, the handle is no longer valid (and does not need to be deleted).
1388 */
1389EAPI void *ecore_poller_del(Ecore_Poller *poller);
1390
1391/**
1392 * @}
1393 */
1394
1395/**
1396 * @defgroup Ecore_Animator_Group Ecore Animator functions
1397 *
1398 * @brief Ecore animators are a helper to simplify creating
1399 * animations.
1400 *
1401 * Creating an animation is as simple as saying for how long it
1402 * should be run and having a callback that does the animation,
1403 * something like this:
1404 * @code
1405 * static Eina_Bool
1406 * _do_animation(void *data, double pos)
1407 * {
1408 * evas_object_move(data, 100 * pos, 100 * pos);
1409 * ... do some more animating ...
1410 * }
1411 * ...
1412 *ecore_animator_timeline_add(2, _do_animation, my_evas_object);
1413 * @endcode
1414 * In the sample above we create an animation to move
1415 * @c my_evas_object from position (0,0) to (100,100) in 2 seconds.
1416 *
1417 * If your animation will run for an unspecified amount of time you
1418 * can use ecore_animator_add(), which is like using
1419 *ecore_timer_add() with the interval being the
1420 * @ref ecore_animator_frametime_set "framerate". Note that this has
1421 * tangible benefits to creating a timer for each animation in terms
1422 * of performance.
1423 *
1424 * For a more detailed example that show several animation see
1425 * @ref tutorial_ecore_animator.
1426 *
1427 * @ingroup Ecore_Main_Loop_Group
1428 *
1429 * @{
1430 */
1431
1432/*
1433 * @since 1.8
1434 */
1435typedef Eo Ecore_Animator; /**< A handle for animators */
1436#define ECORE_ANIMATOR_CLASS ecore_animator_class_get()
1437const Eo_Class *ecore_animator_class_get(void) EINA_CONST;
1438
1439extern EAPI Eo_Op ECORE_ANIMATOR_BASE_ID;
1440
1441enum
1442{
1443 ECORE_ANIMATOR_SUB_ID_CONSTRUCTOR,
1444 ECORE_ANIMATOR_SUB_ID_TIMELINE_CONSTRUCTOR,
1445 ECORE_ANIMATOR_SUB_ID_LAST
1446};
1447
1448#define ECORE_ANIMATOR_ID(sub_id) (ECORE_ANIMATOR_BASE_ID + sub_id)
1449
1450/**
1451 * @def ecore_animator_constructor
1452 * @since 1.8
1453 *
1454 * Contructor.
1455 *
1456 * @param[in] func
1457 * @param[in] data
1458 *
1459 */
1460#define ecore_animator_constructor(func, data) ECORE_ANIMATOR_ID(ECORE_ANIMATOR_SUB_ID_CONSTRUCTOR), EO_TYPECHECK(Ecore_Task_Cb, func), EO_TYPECHECK(const void *, data)
1461
1462/**
1463 * @def ecore_animator_timeline_constructor
1464 * @since 1.8
1465 *
1466 * Contructor.
1467 *
1468 * @param[in] runtime
1469 * @param[in] func
1470 * @param[in] data
1471 *
1472 */
1473#define ecore_animator_timeline_constructor(runtime, func, data) ECORE_ANIMATOR_ID(ECORE_ANIMATOR_SUB_ID_TIMELINE_CONSTRUCTOR), EO_TYPECHECK(double, runtime), EO_TYPECHECK(Ecore_Timeline_Cb, func), EO_TYPECHECK(const void *, data)
1474
1475/**
1476 * @enum _Ecore_Pos_Map
1477 * Defines the position mappings for the animation.
1478 */
1479enum _Ecore_Pos_Map /* Position mappings */
1480{
1481 ECORE_POS_MAP_LINEAR, /**< Linear 0.0 -> 1.0 */
1482 ECORE_POS_MAP_ACCELERATE, /**< Start slow then speed up */
1483 ECORE_POS_MAP_DECELERATE, /**< Start fast then slow down */
1484 ECORE_POS_MAP_SINUSOIDAL, /**< Start slow, speed up then slow down at end */
1485 ECORE_POS_MAP_ACCELERATE_FACTOR, /**< Start slow then speed up, v1 being a power factor, 0.0 being linear, 1.0 being normal accelerate, 2.0 being much more pronounced accelerate (squared), 3.0 being cubed, etc. */
1486 ECORE_POS_MAP_DECELERATE_FACTOR, /**< Start fast then slow down, v1 being a power factor, 0.0 being linear, 1.0 being normal decelerate, 2.0 being much more pronounced decelerate (squared), 3.0 being cubed, etc. */
1487 ECORE_POS_MAP_SINUSOIDAL_FACTOR, /**< Start slow, speed up then slow down at end, v1 being a power factor, 0.0 being linear, 1.0 being normal sinusoidal, 2.0 being much more pronounced sinusoidal (squared), 3.0 being cubed, etc. */
1488 ECORE_POS_MAP_DIVISOR_INTERP, /**< Start at gradient * v1, interpolated via power of v2 curve */
1489 ECORE_POS_MAP_BOUNCE, /**< Start at 0.0 then "drop" like a ball bouncing to the ground at 1.0, and bounce v2 times, with decay factor of v1 */
1490 ECORE_POS_MAP_SPRING /**< Start at 0.0 then "wobble" like a spring rest position 1.0, and wobble v2 times, with decay factor of v1 */
1491};
1492typedef enum _Ecore_Pos_Map Ecore_Pos_Map;
1493
1494/**
1495 * @enum _Ecore_Animator_Source
1496 * Defines the timing sources for animators.
1497 */
1498enum _Ecore_Animator_Source /* Timing sources for animators */
1499{
1500 ECORE_ANIMATOR_SOURCE_TIMER, /**< The default system clock/timer based animator that ticks every "frametime" seconds */
1501 ECORE_ANIMATOR_SOURCE_CUSTOM /**< A custom animator trigger that you need to call ecore_animator_trigger() to make it tick */
1502};
1503typedef enum _Ecore_Animator_Source Ecore_Animator_Source;
1504
1505/**
1506 * @typedef Ecore_Timeline_Cb Ecore_Timeline_Cb
1507 * A callback run for a task (animators with runtimes)
1508 */
1509typedef Eina_Bool (*Ecore_Timeline_Cb)(void *data, double pos);
1510
1511/**
1512 * @brief Add an animator to call @p func at every animation tick during main
1513 * loop execution.
1514 *
1515 * @param func The function to call when it ticks off
1516 * @param data The data to pass to the function
1517 * @return A handle to the new animator
1518 *
1519 * This function adds a animator and returns its handle on success and @c NULL
1520 * on failure. The function @p func will be called every N seconds where N is
1521 * the @p frametime interval set by ecore_animator_frametime_set(). The
1522 * function will be passed the @p data pointer as its parameter.
1523 *
1524 * When the animator @p func is called, it must return a value of either 1 or
1525 * 0. If it returns 1 (or ECORE_CALLBACK_RENEW), it will be called again at
1526 * the next tick, or if it returns 0 (or ECORE_CALLBACK_CANCEL) it will be
1527 * deleted automatically making any references/handles for it invalid.
1528 *
1529 * @note The default @p frametime value is 1/30th of a second.
1530 *
1531 * @see ecore_animator_timeline_add()
1532 * @see ecore_animator_frametime_set()
1533 */
1534EAPI Ecore_Animator *ecore_animator_add(Ecore_Task_Cb func, const void *data);
1535/**
1536 * @brief Add a animator that runs for a limited time
1537 *
1538 * @param runtime The time to run in seconds
1539 * @param func The function to call when it ticks off
1540 * @param data The data to pass to the function
1541 * @return A handle to the new animator
1542 *
1543 * This function is just like ecore_animator_add() except the animator only
1544 * runs for a limited time specified in seconds by @p runtime. Once the
1545 * runtime the animator has elapsed (animator finished) it will automatically
1546 * be deleted. The callback function @p func can return ECORE_CALLBACK_RENEW
1547 * to keep the animator running or ECORE_CALLBACK_CANCEL ro stop it and have
1548 * it be deleted automatically at any time.
1549 *
1550 * The @p func will ALSO be passed a position parameter that will be in value
1551 * from 0.0 to 1.0 to indicate where along the timeline (0.0 start, 1.0 end)
1552 * the animator run is at. If the callback wishes not to have a linear
1553 * transition it can "map" this value to one of several curves and mappings
1554 * via ecore_animator_pos_map().
1555 *
1556 * @note The default @p frametime value is 1/30th of a second.
1557 *
1558 * @see ecore_animator_add()
1559 * @see ecore_animator_pos_map()
1560 * @since 1.1.0
1561 */
1562EAPI Ecore_Animator *ecore_animator_timeline_add(double runtime, Ecore_Timeline_Cb func, const void *data);
1563/**
1564 * @brief Delete the specified animator from the animator list.
1565 *
1566 * @param animator The animator to delete
1567 * @return The data pointer set for the animator on add
1568 *
1569 * Delete the specified @p animator from the set of animators that are
1570 * executed during main loop execution. This function returns the data
1571 * parameter that was being passed to the callback on success, or @c NULL on
1572 * failure. After this call returns the specified animator object @p animator
1573 * is invalid and should not be used again. It will not get called again after
1574 * deletion.
1575 */
1576EAPI void *ecore_animator_del(Ecore_Animator *animator);
1577/**
1578 * @brief Suspend the specified animator.
1579 *
1580 * @param animator The animator to delete
1581 *
1582 * The specified @p animator will be temporarily removed from the set of
1583 * animators that are executed during main loop.
1584 *
1585 * @warning Freezing an animator doesn't freeze accounting of how long that
1586 * animator has been running. Therefore if the animator was created with
1587 *ecore_animator_timeline_add() the @p pos argument given to the callback
1588 * will increase as if the animator hadn't been frozen and the animator may
1589 * have it's execution halted if @p runtime elapsed.
1590 */
1591EAPI void ecore_animator_freeze(Ecore_Animator *animator);
1592/**
1593 * @brief Restore execution of the specified animator.
1594 *
1595 * @param animator The animator to delete
1596 *
1597 * The specified @p animator will be put back in the set of animators that are
1598 * executed during main loop.
1599 */
1600EAPI void ecore_animator_thaw(Ecore_Animator *animator);
1601/**
1602 * @brief Set the animator call interval in seconds.
1603 *
1604 * @param frametime The time in seconds in between animator ticks.
1605 *
1606 * This function sets the time interval (in seconds) between animator ticks.
1607 * At every tick the callback of every existing animator will be called.
1608 *
1609 * @warning Too small a value may cause performance issues and too high a
1610 * value may cause your animation to seem "jerky".
1611 *
1612 * @note The default @p frametime value is 1/30th of a second.
1613 */
1614EAPI void ecore_animator_frametime_set(double frametime);
1615/**
1616 * @brief Get the animator call interval in seconds.
1617 *
1618 * @return The time in second in between animator ticks.
1619 *
1620 * This function retrieves the time in seconds between animator ticks.
1621 *
1622 * @see ecore_animator_frametime_set()
1623 */
1624EAPI double ecore_animator_frametime_get(void);
1625/**
1626 * @brief Maps an input position from 0.0 to 1.0 along a timeline to a
1627 * position in a different curve.
1628 *
1629 * @param pos The input position to map
1630 * @param map The mapping to use
1631 * @param v1 A parameter use by the mapping (pass 0.0 if not used)
1632 * @param v2 A parameter use by the mapping (pass 0.0 if not used)
1633 * @return The mapped value
1634 *
1635 * Takes an input position (0.0 to 1.0) and maps to a new position (normally
1636 * between 0.0 and 1.0, but it may go above/below 0.0 or 1.0 to show that it
1637 * has "overshot" the mark) using some interpolation (mapping) algorithm.
1638 *
1639 * This function useful to create non-linear animations. It offers a variety
1640 * of possible animation curves to be used:
1641 * @li ECORE_POS_MAP_LINEAR - Linear, returns @p pos
1642 * @li ECORE_POS_MAP_ACCELERATE - Start slow then speed up
1643 * @li ECORE_POS_MAP_DECELERATE - Start fast then slow down
1644 * @li ECORE_POS_MAP_SINUSOIDAL - Start slow, speed up then slow down at end
1645 * @li ECORE_POS_MAP_ACCELERATE_FACTOR - Start slow then speed up, v1 being a
1646 * power factor, 0.0 being linear, 1.0 being ECORE_POS_MAP_ACCELERATE, 2.0
1647 * being much more pronounced accelerate (squared), 3.0 being cubed, etc.
1648 * @li ECORE_POS_MAP_DECELERATE_FACTOR - Start fast then slow down, v1 being a
1649 * power factor, 0.0 being linear, 1.0 being ECORE_POS_MAP_DECELERATE, 2.0
1650 * being much more pronounced decelerate (squared), 3.0 being cubed, etc.
1651 * @li ECORE_POS_MAP_SINUSOIDAL_FACTOR - Start slow, speed up then slow down
1652 * at end, v1 being a power factor, 0.0 being linear, 1.0 being
1653 * ECORE_POS_MAP_SINUSOIDAL, 2.0 being much more pronounced sinusoidal
1654 * (squared), 3.0 being cubed, etc.
1655 * @li ECORE_POS_MAP_DIVISOR_INTERP - Start at gradient * v1, interpolated via
1656 * power of v2 curve
1657 * @li ECORE_POS_MAP_BOUNCE - Start at 0.0 then "drop" like a ball bouncing to
1658 * the ground at 1.0, and bounce v2 times, with decay factor of v1
1659 * @li ECORE_POS_MAP_SPRING - Start at 0.0 then "wobble" like a spring rest
1660 * position 1.0, and wobble v2 times, with decay factor of v1
1661 * @note When not listed v1 and v2 have no effect.
1662 *
1663 * @image html ecore-pos-map.png
1664 * @image latex ecore-pos-map.eps width=\textwidth
1665 *
1666 * One way to use this would be:
1667 * @code
1668 * double pos; // input position in a timeline from 0.0 to 1.0
1669 * double out; // output position after mapping
1670 * int x1, y1, x2, y2; // x1 & y1 are start position, x2 & y2 are end position
1671 * int x, y; // x & y are the calculated position
1672 *
1673 * out = ecore_animator_pos_map(pos, ECORE_POS_MAP_BOUNCE, 1.8, 7);
1674 * x = (x1 * out) + (x2 * (1.0 - out));
1675 * y = (y1 * out) + (y2 * (1.0 - out));
1676 * move_my_object_to(myobject, x, y);
1677 * @endcode
1678 * This will make an animation that bounces 7 each times diminishing by a
1679 * factor of 1.8.
1680 *
1681 * @see _Ecore_Pos_Map
1682 *
1683 * @since 1.1.0
1684 */
1685EAPI double ecore_animator_pos_map(double pos, Ecore_Pos_Map map, double v1, double v2);
1686/**
1687 * @brief Set the source of animator ticks for the mainloop
1688 *
1689 * @param source The source of animator ticks to use
1690 *
1691 * This sets the source of animator ticks. When an animator is active the
1692 * mainloop will "tick" over frame by frame calling all animators that are
1693 * registered until none are. The mainloop will tick at a given rate based
1694 * on the animator source. The default source is the system clock timer
1695 * source - ECORE_ANIMATOR_SOURCE_TIMER. This source uses the system clock
1696 * to tick over every N seconds (specified by ecore_animator_frametime_set(),
1697 * with the default being 1/30th of a second unless set otherwise). You can
1698 * set a custom tick source by setting the source to
1699 * ECORE_ANIMATOR_SOURCE_CUSTOM and then drive it yourself based on some input
1700 * tick source (like another application via ipc, some vertical blanking
1701 * interrupt interrupt etc.) using
1702 *ecore_animator_custom_source_tick_begin_callback_set() and
1703 *ecore_animator_custom_source_tick_end_callback_set() to set the functions
1704 * that will be called to start and stop the ticking source, which when it
1705 * gets a "tick" should call ecore_animator_custom_tick() to make the "tick" over 1
1706 * frame.
1707 */
1708EAPI void ecore_animator_source_set(Ecore_Animator_Source source);
1709/**
1710 * @brief Get the animator source currently set.
1711 *
1712 * @return The current animator source
1713 *
1714 * This gets the current animator source.
1715 *
1716 * @see ecore_animator_source_set()
1717 */
1718EAPI Ecore_Animator_Source ecore_animator_source_get(void);
1719/**
1720 * @brief Set the function that begins a custom animator tick source
1721 *
1722 * @param func The function to call when ticking is to begin
1723 * @param data The data passed to the tick begin function as its parameter
1724 *
1725 * The Ecore Animator infrastructure handles tracking if animators are needed
1726 * or not and which ones need to be called and when, but when the tick source
1727 * is custom, you have to provide a tick source by calling
1728 *ecore_animator_custom_tick() to indicate a frame tick happened. In order
1729 * to allow the source of ticks to be dynamically enabled or disabled as
1730 * needed, the @p func when set is called to enable the tick source to
1731 * produce tick events that call ecore_animator_custom_tick(). If @p func
1732 * is @c NULL then no function is called to begin custom ticking.
1733 *
1734 * @see ecore_animator_source_set()
1735 * @see ecore_animator_custom_source_tick_end_callback_set()
1736 * @see ecore_animator_custom_tick()
1737 */
1738EAPI void ecore_animator_custom_source_tick_begin_callback_set(Ecore_Cb func, const void *data);
1739/**
1740 * @brief Set the function that ends a custom animator tick source
1741 *
1742 * @param func The function to call when ticking is to end
1743 * @param data The data passed to the tick end function as its parameter
1744 *
1745 * This function is a matching pair to the function set by
1746 * ecore_animator_custom_source_tick_begin_callback_set() and is called
1747 * when ticking is to stop. If @p func is @c NULL then no function will be
1748 * called to stop ticking. For more information please see
1749 * ecore_animator_custom_source_tick_begin_callback_set().
1750 *
1751 * @see ecore_animator_source_set()
1752 * @see ecore_animator_custom_source_tick_begin_callback_set()
1753 * @see ecore_animator_custom_tick()
1754 */
1755EAPI void ecore_animator_custom_source_tick_end_callback_set(Ecore_Cb func, const void *data);
1756/**
1757 * @brief Trigger a custom animator tick
1758 *
1759 * When animator source is set to ECORE_ANIMATOR_SOURCE_CUSTOM, then calling
1760 * this function triggers a run of all animators currently registered with
1761 * Ecore as this indicates a "frame tick" happened. This will do nothing if
1762 * the animator source(set by ecore_animator_source_set()) is not set to
1763 * ECORE_ANIMATOR_SOURCE_CUSTOM.
1764 *
1765 * @see ecore_animator_source_set()
1766 * @see ecore_animator_custom_source_tick_begin_callback_set
1767 * @see ecore_animator_custom_source_tick_end_callback_set()()
1768 */
1769EAPI void ecore_animator_custom_tick(void);
1770
1771/**
1772 * @}
1773 */
1774
1775/**
1776 * @defgroup Ecore_Time_Group Ecore time functions
1777 *
1778 * These are function to retrieve time in a given format.
1779 *
1780 * Examples:
1781 * @li @ref ecore_time_functions_example_c
1782 * @{
1783 */
1784EAPI double ecore_time_get(void);
1785EAPI double ecore_time_unix_get(void);
1786EAPI double ecore_loop_time_get(void);
1787
1788/**
1789 * @}
1790 */
1791
1792/**
1793 * @defgroup Ecore_Timer_Group Ecore Timer functions
1794 *
1795 * Ecore provides very flexible timer functionality. The basic usage of timers,
1796 * to call a certain function at a certain interval can be achieved with a
1797 * single line:
1798 * @code
1799 * Eina_Bool my_func(void *data) {
1800 * do_funky_stuff_with_data(data);
1801 * return EINA_TRUE;
1802 * }
1803 * ecore_timer_add(interval_in_seconds, my_func, data_given_to_function);
1804 * @endcode
1805 * @note If the function was to be executed only once simply return
1806 * @c EINA_FALSE instead.
1807 *
1808 * An example that shows the usage of a lot of these:
1809 * @li @ref ecore_timer_example_c
1810 *
1811 * @ingroup Ecore_Main_Loop_Group
1812 *
1813 * @{
1814 */
1815
1816/*
1817 * @since 1.8
1818 */
1819typedef Eo Ecore_Timer; /**< A handle for timers */
1820
1821#define ECORE_TIMER_CLASS ecore_timer_class_get()
1822const Eo_Class *ecore_timer_class_get(void) EINA_CONST;
1823extern EAPI Eo_Op ECORE_TIMER_BASE_ID;
1824
1825enum
1826{
1827 ECORE_TIMER_SUB_ID_CONSTRUCTOR,
1828 ECORE_TIMER_SUB_ID_LOOP_CONSTRUCTOR,
1829 ECORE_TIMER_SUB_ID_INTERVAL_SET,
1830 ECORE_TIMER_SUB_ID_INTERVAL_GET,
1831 ECORE_TIMER_SUB_ID_DELAY,
1832 ECORE_TIMER_SUB_ID_RESET,
1833 ECORE_TIMER_SUB_ID_PENDING_GET,
1834 ECORE_TIMER_SUB_ID_LAST,
1835};
1836
1837#define ECORE_TIMER_ID(sub_id) (ECORE_TIMER_BASE_ID + sub_id)
1838
1839/**
1840 * @def ecore_timer_constructor
1841 * @since 1.8
1842 *
1843 * Contructor.
1844 *
1845 * @param[in] in
1846 * @param[in] func
1847 * @param[in] data
1848 *
1849 */
1850#define ecore_timer_constructor(in, func, data) ECORE_TIMER_ID(ECORE_TIMER_SUB_ID_CONSTRUCTOR), EO_TYPECHECK(double, in), EO_TYPECHECK(Ecore_Task_Cb, func), EO_TYPECHECK(const void *, data)
1851
1852/**
1853 * @def ecore_timer_loop_constructor
1854 * @since 1.8
1855 *
1856 * Contructor.
1857 *
1858 * @param[in] in
1859 * @param[in] func
1860 * @param[in] data
1861 *
1862 */
1863#define ecore_timer_loop_constructor(in, func, data) ECORE_TIMER_ID(ECORE_TIMER_SUB_ID_LOOP_CONSTRUCTOR), EO_TYPECHECK(double, in), EO_TYPECHECK(Ecore_Task_Cb, func), EO_TYPECHECK(const void *, data)
1864
1865/**
1866 * @def ecore_obj_timer_interval_set
1867 * @since 1.8
1868 *
1869 * Change the interval the timer ticks of.
1870 *
1871 * @param[in] in
1872 *
1873 * @see ecore_timer_interval_set
1874 */
1875#define ecore_obj_timer_interval_set(in) ECORE_TIMER_ID(ECORE_TIMER_SUB_ID_INTERVAL_SET), EO_TYPECHECK(double, in)
1876
1877/**
1878 * @def ecore_obj_timer_interval_get
1879 * @since 1.8
1880 *
1881 * Get the interval the timer ticks on.
1882 *
1883 * @param[out] ret
1884 *
1885 * @see ecore_timer_interval_get
1886 */
1887#define ecore_obj_timer_interval_get(ret) ECORE_TIMER_ID(ECORE_TIMER_SUB_ID_INTERVAL_GET), EO_TYPECHECK(double *, ret)
1888
1889/**
1890 * @def ecore_obj_timer_delay
1891 * @since 1.8
1892 *
1893 * Add some delay for the next occurrence of a timer.
1894 *
1895 * @param[in] add
1896 *
1897 * @see ecore_timer_delay
1898 */
1899#define ecore_obj_timer_delay(add) ECORE_TIMER_ID(ECORE_TIMER_SUB_ID_DELAY), EO_TYPECHECK(double, add)
1900
1901/**
1902 * @def ecore_obj_timer_reset
1903 * @since 1.8
1904 *
1905 * Reset a timer to its full interval.
1906 *
1907 * @see ecore_timer_reset
1908 */
1909#define ecore_obj_timer_reset() ECORE_TIMER_ID(ECORE_TIMER_SUB_ID_RESET)
1910
1911/**
1912 * @def ecore_obj_timer_pending_get
1913 * @since 1.8
1914 *
1915 * Get the pending time regarding a timer.
1916 *
1917 * @param[out] ret
1918 *
1919 * @see ecore_timer_pending_get
1920 */
1921#define ecore_obj_timer_pending_get(ret) ECORE_TIMER_ID(ECORE_TIMER_SUB_ID_PENDING_GET), EO_TYPECHECK(double *, ret)
1922
1923EAPI Ecore_Timer *ecore_timer_add(double in, Ecore_Task_Cb func, const void *data);
1924EAPI Ecore_Timer *ecore_timer_loop_add(double in, Ecore_Task_Cb func, const void *data);
1925EAPI void *ecore_timer_del(Ecore_Timer *timer);
1926EAPI void ecore_timer_interval_set(Ecore_Timer *timer, double in);
1927EAPI double ecore_timer_interval_get(Ecore_Timer *timer);
1928EAPI void ecore_timer_freeze(Ecore_Timer *timer);
1929EAPI void ecore_timer_thaw(Ecore_Timer *timer);
1930EAPI void ecore_timer_delay(Ecore_Timer *timer, double add);
1931EAPI void ecore_timer_reset(Ecore_Timer *timer);
1932EAPI double ecore_timer_pending_get(Ecore_Timer *timer);
1933EAPI double ecore_timer_precision_get(void);
1934EAPI void ecore_timer_precision_set(double precision);
1935EAPI char *ecore_timer_dump(void);
1936
1937/**
1938 * @}
1939 */
1940
1941/**
1942 * @defgroup Ecore_Idle_Group Ecore Idle functions
1943 *
1944 * The idler functionality in Ecore allows for callbacks to be called when the
1945 * program isn't handling @ref Ecore_Event_Group "events", @ref Ecore_Timer_Group
1946 * "timers" or @ref Ecore_FD_Handler_Group "fd handlers".
1947 *
1948 * There are three types of idlers: Enterers, Idlers(proper) and Exiters. They
1949 * are called, respectively, when the program is about to enter an idle state,
1950 * when the program is in an idle state and when the program has just left an
1951 * idle state and will begin processing @ref Ecore_Event_Group "events", @ref
1952 * Ecore_Timer_Group "timers" or @ref Ecore_FD_Handler_Group "fd handlers".
1953 *
1954 * Enterer callbacks are good for updating your program's state, if
1955 * it has a state engine. Once all of the enterer handlers are
1956 * called, the program will enter a "sleeping" state.
1957 *
1958 * Idler callbacks are called when the main loop has called all
1959 * enterer handlers. They are useful for interfaces that require
1960 * polling and timers would be too slow to use.
1961 *
1962 * Exiter callbacks are called when the main loop wakes up from an idle state.
1963 *
1964 * If no idler callbacks are specified, then the process literally
1965 * goes to sleep. Otherwise, the idler callbacks are called
1966 * continuously while the loop is "idle", using as much CPU as is
1967 * available to the process.
1968 *
1969 * @note Idle state doesn't mean that the @b program is idle, but
1970 * that the <b>main loop</b> is idle. It doesn't have any timers,
1971 * events, fd handlers or anything else to process (which in most
1972 * <em>event driven</em> programs also means that the @b program is
1973 * idle too, but it's not a rule). The program itself may be doing
1974 * a lot of processing in the idler, or in another thread, for
1975 * example.
1976 *
1977 * Example with functions that deal with idle state:
1978 *
1979 * @li @ref ecore_idler_example_c
1980 *
1981 * @ingroup Ecore_Main_Loop_Group
1982 *
1983 * @{
1984 */
1985
1986/*
1987 * @since 1.8
1988 */
1989typedef Eo Ecore_Idler; /**< A handle for idlers */
1990#define ECORE_IDLER_CLASS ecore_idler_class_get()
1991const Eo_Class *ecore_idler_class_get(void) EINA_CONST;
1992
1993extern EAPI Eo_Op ECORE_IDLER_BASE_ID;
1994
1995enum
1996{
1997 ECORE_IDLER_SUB_ID_CONSTRUCTOR,
1998 ECORE_IDLER_SUB_ID_LAST
1999};
2000
2001#define ECORE_IDLER_ID(sub_id) (ECORE_IDLER_BASE_ID + sub_id)
2002
2003/**
2004 * @def ecore_idler_constructor
2005 * @since 1.8
2006 *
2007 * Contructor.
2008 *
2009 * @param[in] func
2010 * @param[in] data
2011 *
2012 */
2013#define ecore_idler_constructor(func, data) ECORE_IDLER_ID(ECORE_IDLER_SUB_ID_CONSTRUCTOR), EO_TYPECHECK(Ecore_Task_Cb, func), EO_TYPECHECK(const void *, data)
2014
2015/**
2016 *
2017 */
2018
2019typedef Eo Ecore_Idle_Enterer; /**< A handle for idle enterers */
2020#define ECORE_IDLE_ENTERER_CLASS ecore_idle_enterer_class_get()
2021const Eo_Class *ecore_idle_enterer_class_get(void) EINA_CONST;
2022
2023extern EAPI Eo_Op ECORE_IDLE_ENTERER_BASE_ID;
2024
2025enum
2026{
2027 ECORE_IDLE_ENTERER_SUB_ID_AFTER_CONSTRUCTOR,
2028 ECORE_IDLE_ENTERER_SUB_ID_BEFORE_CONSTRUCTOR,
2029 ECORE_IDLE_ENTERER_SUB_ID_LAST
2030};
2031
2032#define ECORE_IDLE_ENTERER_ID(sub_id) (ECORE_IDLE_ENTERER_BASE_ID + sub_id)
2033
2034/**
2035 * @def ecore_idle_enterer_after_constructor
2036 * @since 1.8
2037 *
2038 * Contructor. Will insert the handler at the end of the list.
2039 *
2040 * @param[in] func
2041 * @param[in] data
2042 *
2043 */
2044#define ecore_idle_enterer_after_constructor(func, data) ECORE_IDLE_ENTERER_ID(ECORE_IDLE_ENTERER_SUB_ID_AFTER_CONSTRUCTOR), EO_TYPECHECK(Ecore_Task_Cb, func), EO_TYPECHECK(const void *, data)
2045
2046/**
2047 * @def ecore_idle_enterer_before_constructor
2048 * @since 1.8
2049 *
2050 * Contructor. Will insert the handler at the beginning of the list.
2051 *
2052 * @param[in] func
2053 * @param[in] data
2054 *
2055 */
2056#define ecore_idle_enterer_before_constructor(func, data) ECORE_IDLE_ENTERER_ID(ECORE_IDLE_ENTERER_SUB_ID_BEFORE_CONSTRUCTOR), EO_TYPECHECK(Ecore_Task_Cb, func), EO_TYPECHECK(const void *, data)
2057
2058/**
2059 *
2060 */
2061
2062/*
2063 * @since 1.8
2064 */
2065typedef Eo Ecore_Idle_Exiter; /**< A handle for idle exiters */
2066#define ECORE_IDLE_EXITER_CLASS ecore_idle_exiter_class_get()
2067const Eo_Class *ecore_idle_exiter_class_get(void) EINA_CONST;
2068
2069extern EAPI Eo_Op ECORE_IDLE_EXITER_BASE_ID;
2070
2071enum
2072{
2073 ECORE_IDLE_EXITER_SUB_ID_CONSTRUCTOR,
2074 ECORE_IDLE_EXITER_SUB_ID_LAST
2075};
2076
2077#define ECORE_IDLE_EXITER_ID(sub_id) (ECORE_IDLE_EXITER_BASE_ID + sub_id)
2078
2079/**
2080 * @def ecore_idle_exiter_constructor
2081 * @since 1.8
2082 *
2083 * Contructor.
2084 *
2085 * @param[in] func
2086 * @param[in] data
2087 *
2088 */
2089#define ecore_idle_exiter_constructor(func, data) ECORE_IDLE_EXITER_ID(ECORE_IDLE_EXITER_SUB_ID_CONSTRUCTOR), EO_TYPECHECK(Ecore_Task_Cb, func), EO_TYPECHECK(const void *, data)
2090
2091/**
2092 * Add an idler handler.
2093 * @param func The function to call when idling.
2094 * @param data The data to be passed to this @p func call.
2095 * @return A idler handle if successfully added, @c NULL otherwise.
2096 *
2097 * Add an idler handle to the event loop, returning a handle on
2098 * success and @c NULL otherwise. The function @p func will be called
2099 * repeatedly while no other events are ready to be processed, as
2100 * long as it returns @c 1 (or ECORE_CALLBACK_RENEW). A return of @c 0
2101 * (or ECORE_CALLBACK_CANCEL) deletes the idler.
2102 *
2103 * Idlers are useful for progressively prossessing data without blocking.
2104 */
2105EAPI Ecore_Idler *ecore_idler_add(Ecore_Task_Cb func, const void *data);
2106
2107/**
2108 * Delete an idler callback from the list to be executed.
2109 * @param idler The handle of the idler callback to delete
2110 * @return The data pointer passed to the idler callback on success, @c NULL
2111 * otherwise.
2112 */
2113EAPI void *ecore_idler_del(Ecore_Idler *idler);
2114
2115EAPI Ecore_Idle_Enterer *ecore_idle_enterer_add(Ecore_Task_Cb func, const void *data);
2116EAPI Ecore_Idle_Enterer *ecore_idle_enterer_before_add(Ecore_Task_Cb func, const void *data);
2117EAPI void *ecore_idle_enterer_del(Ecore_Idle_Enterer *idle_enterer);
2118
2119EAPI Ecore_Idle_Exiter *ecore_idle_exiter_add(Ecore_Task_Cb func, const void *data);
2120EAPI void *ecore_idle_exiter_del(Ecore_Idle_Exiter *idle_exiter);
2121
2122/**
2123 * @}
2124 */
2125
2126/**
2127 * @defgroup Ecore_Thread_Group Ecore Thread functions
2128 *
2129 * Facilities to run heavy tasks in different threads to avoid blocking
2130 * the main loop.
2131 *
2132 * The EFL is, for the most part, not thread safe. This means that if you
2133 * have some task running in another thread and you have, for example, an
2134 * Evas object to show the status progress of this task, you cannot update
2135 * the object from within the thread. This can only be done from the main
2136 * thread, the one running the main loop. This problem can be solved
2137 * by running a thread that sends messages to the main one using an
2138 * @ref Ecore_Pipe_Group "Ecore_Pipe", but when you need to handle other
2139 * things like cancelling the thread, your code grows in complexity and gets
2140 * much harder to maintain.
2141 *
2142 * Ecore Thread is here to solve that problem. It is @b not a simple wrapper
2143 * around standard POSIX threads (or the equivalent in other systems) and
2144 * it's not meant to be used to run parallel tasks throughout the entire
2145 * duration of the program, especially when these tasks are performance
2146 * critical, as Ecore manages these tasks using a pool of threads based on
2147 * system configuration.
2148 *
2149 * What Ecore Thread does, is make it a lot easier to dispatch a worker
2150 * function to perform some heavy task and then get the result once it
2151 * completes, without blocking the application's UI. In addition, cancelling
2152 * and rescheduling comes practically for free and the developer needs not
2153 * worry about how many threads are launched, since Ecore will schedule
2154 * them according to the number of processors the system has and maximum
2155 * amount of concurrent threads set for the application.
2156 *
2157 * At the system level, Ecore will start a new thread on an as-needed basis
2158 * until the maximum set is reached. When no more threads can be launched,
2159 * new worker functions will be queued in a waiting list until a thread
2160 * becomes available. This way, system threads will be shared throughout
2161 * different worker functions, but running only one at a time. At the same
2162 * time, a worker function that is rescheduled may be run on a different
2163 * thread the next time.
2164 *
2165 * The ::Ecore_Thread handler has two meanings, depending on what context
2166 * it is on. The one returned when starting a worker with any of the
2167 * functions ecore_thread_run() or ecore_thread_feedback_run() is an
2168 * identifier of that specific instance of the function and can be used from
2169 * the main loop with the ecore_thread_cancel() and ecore_thread_check()
2170 * functions. This handler must not be shared with the worker function
2171 * function running in the thread. This same handler will be the one received
2172 * on the @c end, @c cancel and @c feedback callbacks.
2173 *
2174 * The worker function, that's the one running in the thread, also receives
2175 * an ::Ecore_Thread handler that can be used with ecore_thread_cancel() and
2176 *ecore_thread_check(), sharing the flag with the main loop. But this
2177 * handler is also associated with the thread where the function is running.
2178 * This has strong implications when working with thread local data.
2179 *
2180 * There are two kinds of worker threads Ecore handles: simple, or short,
2181 * workers and feedback workers.
2182 *
2183 * The first kind is for simple functions that perform a
2184 * usually small but time consuming task. Ecore will run this function in
2185 * a thread as soon as one becomes available and notify the calling user of
2186 * its completion once the task is done.
2187 *
2188 * The following image shows the flow of a program running four tasks on
2189 * a pool of two threads.
2190 *
2191 * @image html ecore_thread.png
2192 * @image rtf ecore_thread.png
2193 * @image latex ecore_thread.eps width=\textwidth
2194 *
2195 * For larger tasks that may require continuous communication with the main
2196 * program, the feedback workers provide the same functionality plus a way
2197 * for the function running in the thread to send messages to the main
2198 * thread.
2199 *
2200 * The next diagram omits some details shown in the previous one regarding
2201 * how threads are spawned and tasks are queued, but illustrates how feedback
2202 * jobs communicate with the main loop and the special case of threads
2203 * running out of pool.
2204 *
2205 * @image html ecore_thread_feedback.png
2206 * @image rtf ecore_thread_feedback.png
2207 * @image latex ecore_thread_feedback.eps width=\textwidth
2208 *
2209 * See an overview example in @ref ecore_thread_example_c.
2210 *
2211 * @ingroup Ecore_Main_Loop_Group
2212 *
2213 * @{
2214 */
2215
2216typedef struct _Ecore_Thread Ecore_Thread; /**< A handle for threaded jobs */
2217
2218/**
2219 * @typedef Ecore_Thread_Cb Ecore_Thread_Cb
2220 * A callback used by Ecore_Thread helper.
2221 */
2222typedef void (*Ecore_Thread_Cb)(void *data, Ecore_Thread *thread);
2223/**
2224 * @typedef Ecore_Thread_Notify_Cb Ecore_Thread_Notify_Cb
2225 * A callback used by the main loop to receive data sent by an
2226 * @ref Ecore_Thread_Group.
2227 */
2228typedef void (*Ecore_Thread_Notify_Cb)(void *data, Ecore_Thread *thread, void *msg_data);
2229
2230/**
2231 * Schedule a task to run in a parallel thread to avoid locking the main loop
2232 *
2233 * @param func_blocking The function that should run in another thread.
2234 * @param func_end Function to call from main loop when @p func_blocking
2235 * completes its task successfully (may be NULL)
2236 * @param func_cancel Function to call from main loop if the thread running
2237 * @p func_blocking is cancelled or fails to start (may be NULL)
2238 * @param data User context data to pass to all callbacks.
2239 * @return A new thread handler, or @c NULL on failure.
2240 *
2241 * This function will try to create a new thread to run @p func_blocking in,
2242 * or if the maximum number of concurrent threads has been reached, will
2243 * add it to the pending list, where it will wait until a thread becomes
2244 * available. The return value will be an ::Ecore_Thread handle that can
2245 * be used to cancel the thread before its completion.
2246 *
2247 * @note This function should always return immediately, but in the rare
2248 * case that Ecore is built with no thread support, @p func_blocking will
2249 * be called here, actually blocking the main loop.
2250 *
2251 * Once a thread becomes available, @p func_blocking will be run in it until
2252 * it finishes, then @p func_end is called from the thread containing the
2253 * main loop to inform the user of its completion. While in @p func_blocking,
2254 * no functions from the EFL can be used, except for those from Eina that are
2255 * marked to be thread-safe. Even for the latter, caution needs to be taken
2256 * if the data is shared across several threads.
2257 *
2258 * @p func_end will be called from the main thread when @p func_blocking ends,
2259 * so here it's safe to use anything from the EFL freely.
2260 *
2261 * The thread can also be cancelled before its completion calling
2262 *ecore_thread_cancel(), either from the main thread or @p func_blocking.
2263 * In this case, @p func_cancel will be called, also from the main thread
2264 * to inform of this happening. If the thread could not be created, this
2265 * function will be called and it's @c thread parameter will be NULL. It's
2266 * also safe to call any EFL function here, as it will be running in the
2267 * main thread.
2268 *
2269 * Inside @p func_blocking, it's possible to call ecore_thread_reschedule()
2270 * to tell Ecore that this function should be called again.
2271 *
2272 * Be aware that no assumptions can be made about the order in which the
2273 * @p func_end callbacks for each task will be called. Once the function is
2274 * running in a different thread, it's the OS that will handle its running
2275 * schedule, and different functions may take longer to finish than others.
2276 * Also remember that just starting several tasks together doesn't mean they
2277 * will be running at the same time. Ecore will schedule them based on the
2278 * number of threads available for the particular system it's running in,
2279 * so some of the jobs started may be waiting until another one finishes
2280 * before it can execute its own @p func_blocking.
2281 *
2282 * @see ecore_thread_feedback_run()
2283 * @see ecore_thread_cancel()
2284 * @see ecore_thread_reschedule()
2285 * @see ecore_thread_max_set()
2286 */
2287EAPI Ecore_Thread *ecore_thread_run(Ecore_Thread_Cb func_blocking, Ecore_Thread_Cb func_end, Ecore_Thread_Cb func_cancel, const void *data);
2288/**
2289 * Launch a thread to run a task that can talk back to the main thread
2290 *
2291 * @param func_heavy The function that should run in another thread.
2292 * @param func_notify Function that receives the data sent from the thread
2293 * @param func_end Function to call from main loop when @p func_heavy
2294 * completes its task successfully
2295 * @param func_cancel Function to call from main loop if the thread running
2296 * @p func_heavy is cancelled or fails to start
2297 * @param data User context data to pass to all callback.
2298 * @param try_no_queue If you want to run outside of the thread pool.
2299 * @return A new thread handler, or @c NULL on failure.
2300 *
2301 * See ecore_thread_run() for a general description of this function.
2302 *
2303 * The difference with the above is that ecore_thread_run() is meant for
2304 * tasks that don't need to communicate anything until they finish, while
2305 * this function is provided with a new callback, @p func_notify, that will
2306 * be called from the main thread for every message sent from @p func_heavy
2307 * with ecore_thread_feedback().
2308 *
2309 * Like with ecore_thread_run(), a new thread will be launched to run
2310 * @p func_heavy unless the maximum number of simultaneous threads has been
2311 * reached, in which case the function will be scheduled to run whenever a
2312 * running task ends and a thread becomes free. But if @p try_no_queue is
2313 * set, Ecore will first try to launch a thread outside of the pool to run
2314 * the task. If it fails, it will revert to the normal behaviour of using a
2315 * thread from the pool as if @p try_no_queue had not been set.
2316 *
2317 * Keep in mind that Ecore handles the thread pool based on the number of
2318 * CPUs available, but running a thread outside of the pool doesn't count for
2319 * this, so having too many of them may have drastic effects over the
2320 * program's performance.
2321 *
2322 * @see ecore_thread_feedback()
2323 * @see ecore_thread_run()
2324 * @see ecore_thread_cancel()
2325 * @see ecore_thread_reschedule()
2326 * @see ecore_thread_max_set()
2327 */
2328EAPI Ecore_Thread *ecore_thread_feedback_run(Ecore_Thread_Cb func_heavy, Ecore_Thread_Notify_Cb func_notify,
2329 Ecore_Thread_Cb func_end, Ecore_Thread_Cb func_cancel,
2330 const void *data, Eina_Bool try_no_queue);
2331/**
2332 * Cancel a running thread.
2333 *
2334 * @param thread The thread to cancel.
2335 * @return Will return @c EINA_TRUE if the thread has been cancelled,
2336 * @c EINA_FALSE if it is pending.
2337 *
2338 * This function can be called both in the main loop or in the running thread.
2339 *
2340 * This function cancels a running thread. If @p thread can be immediately
2341 * cancelled (it's still pending execution after creation or rescheduling),
2342 * then the @c cancel callback will be called, @p thread will be freed and
2343 * the function will return @c EINA_TRUE.
2344 *
2345 * If the thread is already running, then this function returns @c EINA_FALSE
2346 * after marking the @p thread as pending cancellation. For the thread to
2347 * actually be terminated, it needs to return from the user function back
2348 * into Ecore control. This can happen in several ways:
2349 * @li The function ends and returns normally. If it hadn't been cancelled,
2350 * @c func_end would be called here, but instead @c func_cancel will happen.
2351 * @li The function returns after requesting to be rescheduled with
2352 * ecore_thread_reschedule().
2353 * @li The function is prepared to leave early by checking if
2354 * ecore_thread_check() returns @c EINA_TRUE.
2355 *
2356 * The user function can cancel itself by calling ecore_thread_cancel(), but
2357 * it should always use the ::Ecore_Thread handle passed to it and never
2358 * share it with the main loop thread by means of shared user data or any
2359 * other way.
2360 *
2361 * @p thread will be freed and should not be used again if this function
2362 * returns @c EINA_TRUE or after the @c func_cancel callback returns.
2363 *
2364 * @see ecore_thread_check()
2365 */
2366EAPI Eina_Bool ecore_thread_cancel(Ecore_Thread *thread);
2367/**
2368 * Checks if a thread is pending cancellation
2369 *
2370 * @param thread The thread to test.
2371 * @return @c EINA_TRUE if the thread is pending cancellation,
2372 * @c EINA_FALSE if it is not.
2373 *
2374 * This function can be called both in the main loop or in the running thread.
2375 *
2376 * When ecore_thread_cancel() is called on an already running task, the
2377 * thread is marked as pending cancellation. This function returns @c EINA_TRUE
2378 * if this mark is set for the given @p thread and can be used from the
2379 * main loop thread to check if a still active thread has been cancelled,
2380 * or from the user function running in the thread to check if it should
2381 * stop doing what it's doing and return early, effectively cancelling the
2382 * task.
2383 *
2384 * @see ecore_thread_cancel()
2385 */
2386EAPI Eina_Bool ecore_thread_check(Ecore_Thread *thread);
2387/**
2388 * Sends data from the worker thread to the main loop
2389 *
2390 * @param thread The current ::Ecore_Thread context to send data from
2391 * @param msg_data Data to be transmitted to the main loop
2392 * @return @c EINA_TRUE if @p msg_data was successfully sent to main loop,
2393 * @c EINA_FALSE if anything goes wrong.
2394 *
2395 * You should use this function only in the @c func_heavy call.
2396 *
2397 * Only the address to @p msg_data will be sent and once this function
2398 * returns @c EINA_TRUE, the job running in the thread should never touch the
2399 * contents of it again. The data sent should be malloc()'ed or something
2400 * similar, as long as it's not memory local to the thread that risks being
2401 * overwritten or deleted once it goes out of scope or the thread finishes.
2402 *
2403 * Care must be taken that @p msg_data is properly freed in the @c func_notify
2404 * callback set when creating the thread.
2405 *
2406 * @see ecore_thread_feedback_run()
2407 */
2408EAPI Eina_Bool ecore_thread_feedback(Ecore_Thread *thread, const void *msg_data);
2409/**
2410 * Asks for the function in the thread to be called again at a later time
2411 *
2412 * @param thread The current ::Ecore_Thread context to rescheduled
2413 * @return @c EINA_TRUE if the task was successfully rescheduled,
2414 * @c EINA_FALSE if anything goes wrong.
2415 *
2416 * This function should be called only from the same function represented
2417 * by @p thread.
2418 *
2419 * Calling this function will mark the thread for a reschedule, so as soon
2420 * as it returns, it will be added to the end of the list of pending tasks.
2421 * If no other tasks are waiting or there are sufficient threads available,
2422 * the rescheduled task will be launched again immediately.
2423 *
2424 * This should never return @c EINA_FALSE, unless it was called from the wrong
2425 * thread or with the wrong arguments.
2426 *
2427 * The @c func_end callback set when the thread is created will not be
2428 * called until the function in the thread returns without being rescheduled.
2429 * Similarly, if the @p thread is cancelled, the reschedule will not take
2430 * effect.
2431 */
2432EAPI Eina_Bool ecore_thread_reschedule(Ecore_Thread *thread);
2433/**
2434 * Gets the number of active threads running jobs
2435 *
2436 * @return Number of active threads running jobs
2437 *
2438 * This returns the number of threads currently running jobs of any type
2439 * through the Ecore_Thread API.
2440 *
2441 * @note Jobs started through the ecore_thread_feedback_run() function with
2442 * the @c try_no_queue parameter set to @c EINA_TRUE will not be accounted for
2443 * in the return of this function unless the thread creation fails and it
2444 * falls back to using one from the pool.
2445 */
2446EAPI int ecore_thread_active_get(void);
2447/**
2448 * Gets the number of short jobs waiting for a thread to run
2449 *
2450 * @return Number of pending threads running "short" jobs
2451 *
2452 * This returns the number of tasks started with ecore_thread_run() that are
2453 * pending, waiting for a thread to become available to run them.
2454 */
2455EAPI int ecore_thread_pending_get(void);
2456/**
2457 * Gets the number of feedback jobs waiting for a thread to run
2458 *
2459 * @return Number of pending threads running "feedback" jobs
2460 *
2461 * This returns the number of tasks started with ecore_thread_feedback_run()
2462 * that are pending, waiting for a thread to become available to run them.
2463 */
2464EAPI int ecore_thread_pending_feedback_get(void);
2465/**
2466 * Gets the total number of pending jobs
2467 *
2468 * @return Number of pending threads running jobs
2469 *
2470 * Same as the sum of ecore_thread_pending_get() and
2471 *ecore_thread_pending_feedback_get().
2472 */
2473EAPI int ecore_thread_pending_total_get(void);
2474/**
2475 * Gets the maximum number of threads that can run simultaneously
2476 *
2477 * @return Max possible number of Ecore_Thread's running concurrently
2478 *
2479 * This returns the maximum number of Ecore_Thread's that may be running at
2480 * the same time. If this number is reached, new jobs started by either
2481 *ecore_thread_run() or ecore_thread_feedback_run() will be added to the
2482 * respective pending queue until one of the running threads finishes its
2483 * task and becomes available to run a new one.
2484 *
2485 * By default, this will be the number of available CPUs for the
2486 * running program (as returned by eina_cpu_count()), or 1 if this value
2487 * could not be fetched.
2488 *
2489 * @see ecore_thread_max_set()
2490 * @see ecore_thread_max_reset()
2491 */
2492EAPI int ecore_thread_max_get(void);
2493/**
2494 * Sets the maximum number of threads allowed to run simultaneously
2495 *
2496 * @param num The new maximum
2497 *
2498 * This sets a new value for the maximum number of concurrently running
2499 * Ecore_Thread's. It @b must an integer between 1 and (16 * @c x), where @c x
2500 * is the number for CPUs available.
2501 *
2502 * @see ecore_thread_max_get()
2503 * @see ecore_thread_max_reset()
2504 */
2505EAPI void ecore_thread_max_set(int num);
2506/**
2507 * Resets the maximum number of concurrently running threads to the default
2508 *
2509 * This resets the value returned by ecore_thread_max_get() back to its
2510 * default.
2511 *
2512 * @see ecore_thread_max_get()
2513 * @see ecore_thread_max_set()
2514 */
2515EAPI void ecore_thread_max_reset(void);
2516/**
2517 * Gets the number of threads available for running tasks
2518 *
2519 * @return The number of available threads
2520 *
2521 * Same as doing ecore_thread_max_get() - ecore_thread_active_get().
2522 *
2523 * This function may return a negative number only in the case the user
2524 * changed the maximum number of running threads while other tasks are
2525 * running.
2526 */
2527EAPI int ecore_thread_available_get(void);
2528/**
2529 * Adds some data to a hash local to the thread
2530 *
2531 * @param thread The thread context the data belongs to
2532 * @param key The name under which the data will be stored
2533 * @param value The data to add
2534 * @param cb Function to free the data when removed from the hash
2535 * @param direct If true, this will not copy the key string (like
2536 * eina_hash_direct_add())
2537 * @return @c EINA_TRUE on success, @c EINA_FALSE on failure.
2538 *
2539 * Ecore Thread has a mechanism to share data across several worker functions
2540 * that run on the same system thread. That is, the data is stored per
2541 * thread and for a worker function to have access to it, it must be run
2542 * by the same thread that stored the data.
2543 *
2544 * When there are no more workers pending, the thread will be destroyed
2545 * along with the internal hash and any data left in it will be freed with
2546 * the @p cb function given.
2547 *
2548 * This set of functions is useful to share things around several instances
2549 * of a function when that thing is costly to create and can be reused, but
2550 * may only be used by one function at a time.
2551 *
2552 * For example, if you have a program doing requisitions to a database,
2553 * these requisitions can be done in threads so that waiting for the
2554 * database to respond doesn't block the UI. Each of these threads will
2555 * run a function, and each function will be dependent on a connection to
2556 * the database, which may not be able to handle more than one request at
2557 * a time so for each running function you will need one connection handle.
2558 * The options then are:
2559 * @li Each function opens a connection when it's called, does the work and
2560 * closes the connection when it finishes. This may be costly, wasting a lot
2561 * of time on resolving hostnames, negotiating permissions and allocating
2562 * memory.
2563 * @li Open the connections in the main loop and pass it to the threads
2564 * using the data pointer. Even worse, it's just as costly as before and now
2565 * it may even be kept with connections open doing nothing until a thread
2566 * becomes available to run the function.
2567 * @li Have a way to share connection handles, so that each instance of the
2568 * function can check if an available connection exists, and if it doesn't,
2569 * create one and add it to the pool. When no more connections are needed,
2570 * they are all closed.
2571 *
2572 * The last option is the most efficient, but it requires a lot of work to
2573 * implement properly. Using thread local data helps to achieve the same
2574 * result while avoiding doing all the tracking work on your code. The way
2575 * to use it would be, at the worker function, to ask for the connection
2576 * with ecore_thread_local_data_find() and if it doesn't exist, then open
2577 * a new one and save it with ecore_thread_local_data_add(). Do the work and
2578 * forget about the connection handle, when everything is done the function
2579 * just ends. The next worker to run on that thread will check if a
2580 * connection exists and find that it does, so the process of opening a
2581 * new one has been spared. When no more workers exist, the thread is
2582 * destroyed and the callback used when saving the connection will be called
2583 * to close it.
2584 *
2585 * This function adds the data @p value to the thread data under the given
2586 * @p key.
2587 * No other value in the hash may have the same @p key. If you need to
2588 * change the value under a @p key, or you don't know if one exists already,
2589 * you can use ecore_thread_local_data_set().
2590 *
2591 * Neither @p key nor @p value may be @c NULL and @p key will be copied in the
2592 * hash, unless @p direct is set, in which case the string used should not
2593 * be freed until the data is removed from the hash.
2594 *
2595 * The @p cb function will be called when the data in the hash needs to be
2596 * freed, be it because it got deleted with ecore_thread_local_data_del() or
2597 * because @p thread was terminated and the hash destroyed. This parameter
2598 * may be NULL, in which case @p value needs to be manually freed after
2599 * removing it from the hash with either ecore_thread_local_data_del() or
2600 * ecore_thread_local_data_set(), but it's very unlikely that this is what
2601 * you want.
2602 *
2603 * This function, and all of the others in the @c ecore_thread_local_data
2604 * family of functions, can only be called within the worker function running
2605 * in the thread. Do not call them from the main loop or from a thread
2606 * other than the one represented by @p thread.
2607 *
2608 * @see ecore_thread_local_data_set()
2609 * @see ecore_thread_local_data_find()
2610 * @see ecore_thread_local_data_del()
2611 */
2612EAPI Eina_Bool ecore_thread_local_data_add(Ecore_Thread *thread, const char *key, void *value,
2613 Eina_Free_Cb cb, Eina_Bool direct);
2614/**
2615 * Sets some data in the hash local to the given thread
2616 *
2617 * @param thread The thread context the data belongs to
2618 * @param key The name under which the data will be stored
2619 * @param value The data to add
2620 * @param cb Function to free the data when removed from the hash
2621 *
2622 * If no data exists in the hash under the @p key, this function adds
2623 * @p value in the hash under the given @p key and returns NULL.
2624 * The key itself is copied.
2625 *
2626 * If the hash already contains something under @p key, the data will be
2627 * replaced by @p value and the old value will be returned.
2628 *
2629 * @c NULL will also be returned if either @p key or @p value are @c NULL, or
2630 * if an error occurred.
2631 *
2632 * This function, and all of the others in the @c ecore_thread_local_data
2633 * family of functions, can only be called within the worker function running
2634 * in the thread. Do not call them from the main loop or from a thread
2635 * other than the one represented by @p thread.
2636 *
2637 * @see ecore_thread_local_data_add()
2638 * @see ecore_thread_local_data_del()
2639 * @see ecore_thread_local_data_find()
2640 */
2641EAPI void *ecore_thread_local_data_set(Ecore_Thread *thread, const char *key, void *value, Eina_Free_Cb cb);
2642/**
2643 * Gets data stored in the hash local to the given thread
2644 *
2645 * @param thread The thread context the data belongs to
2646 * @param key The name under which the data is stored
2647 * @return The value under the given key, or @c NULL on error.
2648 *
2649 * Finds and return the data stored in the shared hash under the key @p key.
2650 *
2651 * This function, and all of the others in the @c ecore_thread_local_data
2652 * family of functions, can only be called within the worker function running
2653 * in the thread. Do not call them from the main loop or from a thread
2654 * other than the one represented by @p thread.
2655 *
2656 * @see ecore_thread_local_data_add()
2657 * @see ecore_thread_local_data_wait()
2658 */
2659EAPI void *ecore_thread_local_data_find(Ecore_Thread *thread, const char *key);
2660/**
2661 * Deletes from the thread's hash the data corresponding to the given key
2662 *
2663 * @param thread The thread context the data belongs to
2664 * @param key The name under which the data is stored
2665 * @return @c EINA_TRUE on success, @c EINA_FALSE on failure.
2666 *
2667 * If there's any data stored associated with @p key in the global hash,
2668 * this function will remove it from it and return @c EINA_TRUE. If no data
2669 * exists or an error occurs, it returns @c EINA_FALSE.
2670 *
2671 * If the data was added to the hash with a free function, then it will
2672 * also be freed after removing it from the hash, otherwise it requires
2673 * to be manually freed by the user, which means that if no other reference
2674 * to it exists before calling this function, it will result in a memory
2675 * leak.
2676 *
2677 * This function, and all of the others in the @c ecore_thread_local_data
2678 * family of functions, can only be called within the worker function running
2679 * in the thread. Do not call them from the main loop or from a thread
2680 * other than the one represented by @p thread.
2681 *
2682 * @see ecore_thread_local_data_add()
2683 */
2684EAPI Eina_Bool ecore_thread_local_data_del(Ecore_Thread *thread, const char *key);
2685
2686/**
2687 * Adds some data to a hash shared by all threads
2688 *
2689 * @param key The name under which the data will be stored
2690 * @param value The data to add
2691 * @param cb Function to free the data when removed from the hash
2692 * @param direct If true, this will not copy the key string (like
2693 * eina_hash_direct_add())
2694 * @return @c EINA_TRUE on success, @c EINA_FALSE on failure.
2695 *
2696 * Ecore Thread keeps a hash that can be used to share data across several
2697 * threads, including the main loop one, without having to manually handle
2698 * mutexes to do so safely.
2699 *
2700 * This function adds the data @p value to this hash under the given @p key.
2701 * No other value in the hash may have the same @p key. If you need to
2702 * change the value under a @p key, or you don't know if one exists already,
2703 * you can use ecore_thread_global_data_set().
2704 *
2705 * Neither @p key nor @p value may be @c NULL and @p key will be copied in the
2706 * hash, unless @p direct is set, in which case the string used should not
2707 * be freed until the data is removed from the hash.
2708 *
2709 * The @p cb function will be called when the data in the hash needs to be
2710 * freed, be it because it got deleted with ecore_thread_global_data_del() or
2711 * because Ecore Thread was shut down and the hash destroyed. This parameter
2712 * may be NULL, in which case @p value needs to be manually freed after
2713 * removing it from the hash with either ecore_thread_global_data_del() or
2714 *ecore_thread_global_data_set().
2715 *
2716 * Manually freeing any data that was added to the hash with a @p cb function
2717 * is likely to produce a segmentation fault, or any other strange
2718 * happenings, later on in the program.
2719 *
2720 * @see ecore_thread_global_data_del()
2721 * @see ecore_thread_global_data_set()
2722 * @see ecore_thread_global_data_find()
2723 */
2724EAPI Eina_Bool ecore_thread_global_data_add(const char *key, void *value, Eina_Free_Cb cb, Eina_Bool direct);
2725/**
2726 * Sets some data in the hash shared by all threads
2727 *
2728 * @param key The name under which the data will be stored
2729 * @param value The data to add
2730 * @param cb Function to free the data when removed from the hash
2731 *
2732 * If no data exists in the hash under the @p key, this function adds
2733 * @p value in the hash under the given @p key and returns NULL.
2734 * The key itself is copied.
2735 *
2736 * If the hash already contains something under @p key, the data will be
2737 * replaced by @p value and the old value will be returned.
2738 *
2739 * @c NULL will also be returned if either @p key or @p value are @c NULL, or
2740 * if an error occurred.
2741 *
2742 * @see ecore_thread_global_data_add()
2743 * @see ecore_thread_global_data_del()
2744 * @see ecore_thread_global_data_find()
2745 */
2746EAPI void *ecore_thread_global_data_set(const char *key, void *value, Eina_Free_Cb cb);
2747/**
2748 * Gets data stored in the hash shared by all threads
2749 *
2750 * @param key The name under which the data is stored
2751 * @return The value under the given key, or @c NULL on error.
2752 *
2753 * Finds and return the data stored in the shared hash under the key @p key.
2754 *
2755 * Keep in mind that the data returned may be used by more than one thread
2756 * at the same time and no reference counting is done on it by Ecore.
2757 * Freeing the data or modifying its contents may require additional
2758 * precautions to be considered, depending on the application's design.
2759 *
2760 * @see ecore_thread_global_data_add()
2761 * @see ecore_thread_global_data_wait()
2762 */
2763EAPI void *ecore_thread_global_data_find(const char *key);
2764/**
2765 * Deletes from the shared hash the data corresponding to the given key
2766 *
2767 * @param key The name under which the data is stored
2768 * @return @c EINA_TRUE on success, @c EINA_FALSE on failure.
2769 *
2770 * If there's any data stored associated with @p key in the global hash,
2771 * this function will remove it from it and return @c EINA_TRUE. If no data
2772 * exists or an error occurs, it returns @c EINA_FALSE.
2773 *
2774 * If the data was added to the hash with a free function, then it will
2775 * also be freed after removing it from the hash, otherwise it requires
2776 * to be manually freed by the user, which means that if no other reference
2777 * to it exists before calling this function, it will result in a memory
2778 * leak.
2779 *
2780 * Note, also, that freeing data that other threads may be using will result
2781 * in a crash, so appropriate care must be taken by the application when
2782 * that possibility exists.
2783 *
2784 * @see ecore_thread_global_data_add()
2785 */
2786EAPI Eina_Bool ecore_thread_global_data_del(const char *key);
2787/**
2788 * Gets data stored in the shared hash, or wait for it if it doesn't exist
2789 *
2790 * @param key The name under which the data is stored
2791 * @param seconds The amount of time in seconds to wait for the data.
2792 * @return The value under the given key, or @c NULL on error.
2793 *
2794 * Finds and return the data stored in the shared hash under the key @p key.
2795 *
2796 * If there's nothing in the hash under the given @p key, the function
2797 * will block and wait up to @p seconds seconds for some other thread to
2798 * add it with either ecore_thread_global_data_add() or
2799 * ecore_thread_global_data_set(). If after waiting there's still no data
2800 * to get, @c NULL will be returned.
2801 *
2802 * If @p seconds is 0, then no waiting will happen and this function works
2803 * like ecore_thread_global_data_find(). If @p seconds is less than 0, then
2804 * the function will wait indefinitely.
2805 *
2806 * Keep in mind that the data returned may be used by more than one thread
2807 * at the same time and no reference counting is done on it by Ecore.
2808 * Freeing the data or modifying its contents may require additional
2809 * precautions to be considered, depending on the application's design.
2810 *
2811 * @see ecore_thread_global_data_add()
2812 * @see ecore_thread_global_data_find()
2813 */
2814EAPI void *ecore_thread_global_data_wait(const char *key, double seconds);
2815
2816/**
2817 * @}
2818 */
2819
2820/**
2821 * @defgroup Ecore_Pipe_Group Pipe wrapper
2822 *
2823 * These functions wrap the pipe / write / read functions to easily
2824 * integrate its use into ecore's main loop.
2825 *
2826 * The ecore_pipe_add() function creates file descriptors (sockets
2827 * on Windows) and attach a handle to the ecore main loop. That
2828 * handle is called when data is read in the pipe. To write data in
2829 * the pipe, just call ecore_pipe_write(). When you are done, just
2830 * call ecore_pipe_del().
2831 *
2832 * For examples see here:
2833 * @li @ref tutorial_ecore_pipe_gstreamer_example
2834 * @li @ref tutorial_ecore_pipe_simple_example
2835 *
2836 * @ingroup Ecore_Main_Loop_Group
2837 *
2838 * @{
2839 */
2840
2841typedef struct _Ecore_Pipe Ecore_Pipe; /**< A handle for pipes */
2842
2843/**
2844 * @typedef Ecore_Pipe_Cb Ecore_Pipe_Cb
2845 * The callback that data written to the pipe is sent to.
2846 */
2847typedef void (*Ecore_Pipe_Cb)(void *data, void *buffer, unsigned int nbyte);
2848
2849EAPI Ecore_Pipe *ecore_pipe_add(Ecore_Pipe_Cb handler, const void *data);
2850EAPI void *ecore_pipe_del(Ecore_Pipe *p);
2851EAPI Eina_Bool ecore_pipe_write(Ecore_Pipe *p, const void *buffer, unsigned int nbytes);
2852EAPI void ecore_pipe_write_close(Ecore_Pipe *p);
2853EAPI void ecore_pipe_read_close(Ecore_Pipe *p);
2854EAPI void ecore_pipe_thaw(Ecore_Pipe *p);
2855EAPI void ecore_pipe_freeze(Ecore_Pipe *p);
2856EAPI int ecore_pipe_wait(Ecore_Pipe *p, int message_count, double wait);
2857
2858/**
2859 * @}
2860 */
2861
2862/**
2863 * @defgroup Ecore_Job_Group Ecore Job functions
2864 *
2865 * You can queue jobs that are to be done by the main loop when the
2866 * current event is dealt with.
2867 *
2868 * Jobs are processed by the main loop similarly to events. They
2869 * also will be executed in the order in which they were added.
2870 *
2871 * A good use for them is when you don't want to execute an action
2872 * immediately, but want to give the control back to the main loop
2873 * so that it will call your job callback when jobs start being
2874 * processed (and if there are other jobs added before yours, they
2875 * will be processed first). This also gives the chance to other
2876 * actions in your program to cancel the job before it is started.
2877 *
2878 * Examples of using @ref Ecore_Job :
2879 * @li @ref ecore_job_example_c
2880 *
2881 * @ingroup Ecore_Main_Loop_Group
2882 *
2883 * @{
2884 */
2885
2886/*
2887 * @since 1.8
2888 */
2889typedef Eo Ecore_Job; /**< A job handle */
2890#define ECORE_JOB_CLASS ecore_job_class_get()
2891const Eo_Class *ecore_job_class_get(void) EINA_CONST;
2892
2893extern EAPI Eo_Op ECORE_JOB_BASE_ID;
2894
2895enum
2896{
2897 ECORE_JOB_SUB_ID_CONSTRUCTOR,
2898 ECORE_JOB_SUB_ID_LAST
2899};
2900
2901#define ECORE_JOB_ID(sub_id) (ECORE_JOB_BASE_ID + sub_id)
2902
2903/**
2904 * @def ecore_job_constructor
2905 * @since 1.8
2906 *
2907 * Contructor.
2908 *
2909 * @param[in] func
2910 * @param[in] data
2911 *
2912 */
2913#define ecore_job_constructor(func, data) ECORE_JOB_ID(ECORE_JOB_SUB_ID_CONSTRUCTOR), EO_TYPECHECK(Ecore_Cb, func), EO_TYPECHECK(const void *, data)
2914
2915EAPI Ecore_Job *ecore_job_add(Ecore_Cb func, const void *data);
2916EAPI void *ecore_job_del(Ecore_Job *job);
2917
2918/**
2919 * @}
2920 */
2921
2922/**
2923 * @defgroup Ecore_Application_Group Ecore Application functions
2924 *
2925 * @{
2926 */
2927
2928EAPI void ecore_app_args_set(int argc, const char **argv);
2929EAPI void ecore_app_args_get(int *argc, char ***argv);
2930EAPI void ecore_app_restart(void);
2931
2932/**
2933 * @}
2934 */
2935
2936/**
2937 * @defgroup Ecore_Throttle_Group Ecore Throttle functions
2938 *
2939 * @ingroup Ecore_Main_Loop_Group
2940 *
2941 * @{
2942 */
2943
2944EAPI void ecore_throttle_adjust(double amount);
2945EAPI double ecore_throttle_get(void);
2946
2947/**
2948 * @}
2949 */
2950
2951#ifdef __cplusplus
2952}
2953#endif
2954#endif
diff --git a/src/lib/ecore/Ecore_Getopt.h b/src/lib/ecore/Ecore_Getopt.h
new file mode 100644
index 0000000000..0a11787d4d
--- /dev/null
+++ b/src/lib/ecore/Ecore_Getopt.h
@@ -0,0 +1,419 @@
1#ifndef _ECORE_GETOPT_H
2#define _ECORE_GETOPT_H
3
4#include <stdio.h>
5#include <Eina.h>
6
7#ifdef EAPI
8# undef EAPI
9#endif
10
11#ifdef _WIN32
12# ifdef EFL_ECORE_BUILD
13# ifdef DLL_EXPORT
14# define EAPI __declspec(dllexport)
15# else
16# define EAPI
17# endif /* ! DLL_EXPORT */
18# else
19# define EAPI __declspec(dllimport)
20# endif /* ! EFL_ECORE_BUILD */
21#else
22# ifdef __GNUC__
23# if __GNUC__ >= 4
24# define EAPI __attribute__ ((visibility("default")))
25# else
26# define EAPI
27# endif
28# else
29# define EAPI
30# endif
31#endif /* ! _WIN32 */
32
33/**
34 * @file Ecore_Getopt.h
35 * @brief Contains powerful getopt replacement.
36 *
37 * This replacement handles both short (-X) or long options (--ABC)
38 * options, with various actions supported, like storing one value and
39 * already converting to required type, counting number of
40 * occurrences, setting true or false values, show help, license,
41 * copyright and even support user-defined callbacks.
42 *
43 * It is provided a set of C Pre Processor macros so definition is
44 * straightforward.
45 *
46 * Values will be stored elsewhere indicated by an array of pointers
47 * to values, it is given in separate to parser description so you can
48 * use multiple values with the same parser.
49 */
50
51#ifdef __cplusplus
52extern "C" {
53#endif
54
55typedef enum {
56 ECORE_GETOPT_ACTION_STORE,
57 ECORE_GETOPT_ACTION_STORE_CONST,
58 ECORE_GETOPT_ACTION_STORE_TRUE,
59 ECORE_GETOPT_ACTION_STORE_FALSE,
60 ECORE_GETOPT_ACTION_CHOICE,
61 ECORE_GETOPT_ACTION_APPEND,
62 ECORE_GETOPT_ACTION_COUNT,
63 ECORE_GETOPT_ACTION_CALLBACK,
64 ECORE_GETOPT_ACTION_HELP,
65 ECORE_GETOPT_ACTION_VERSION,
66 ECORE_GETOPT_ACTION_COPYRIGHT,
67 ECORE_GETOPT_ACTION_LICENSE
68} Ecore_Getopt_Action;
69
70typedef enum {
71 ECORE_GETOPT_TYPE_STR,
72 ECORE_GETOPT_TYPE_BOOL,
73 ECORE_GETOPT_TYPE_SHORT,
74 ECORE_GETOPT_TYPE_INT,
75 ECORE_GETOPT_TYPE_LONG,
76 ECORE_GETOPT_TYPE_USHORT,
77 ECORE_GETOPT_TYPE_UINT,
78 ECORE_GETOPT_TYPE_ULONG,
79 ECORE_GETOPT_TYPE_DOUBLE
80} Ecore_Getopt_Type;
81
82typedef enum {
83 ECORE_GETOPT_DESC_ARG_REQUIREMENT_NO = 0,
84 ECORE_GETOPT_DESC_ARG_REQUIREMENT_YES = 1,
85 ECORE_GETOPT_DESC_ARG_REQUIREMENT_OPTIONAL = 3
86} Ecore_Getopt_Desc_Arg_Requirement;
87
88typedef union _Ecore_Getopt_Value Ecore_Getopt_Value;
89
90typedef struct _Ecore_Getopt_Desc_Store Ecore_Getopt_Desc_Store;
91typedef struct _Ecore_Getopt_Desc_Callback Ecore_Getopt_Desc_Callback;
92typedef struct _Ecore_Getopt_Desc Ecore_Getopt_Desc;
93typedef struct _Ecore_Getopt Ecore_Getopt;
94
95union _Ecore_Getopt_Value
96{
97 char **strp;
98 unsigned char *boolp;
99 short *shortp;
100 int *intp;
101 long *longp;
102 unsigned short *ushortp;
103 unsigned int *uintp;
104 unsigned long *ulongp;
105 double *doublep;
106 Eina_List **listp;
107 void **ptrp;
108};
109
110struct _Ecore_Getopt_Desc_Store
111{
112 Ecore_Getopt_Type type; /**< type of data being handled */
113 Ecore_Getopt_Desc_Arg_Requirement arg_req;
114 union
115 {
116 const char *strv;
117 Eina_Bool boolv;
118 short shortv;
119 int intv;
120 long longv;
121 unsigned short ushortv;
122 unsigned int uintv;
123 unsigned long ulongv;
124 double doublev;
125 } def;
126};
127
128struct _Ecore_Getopt_Desc_Callback
129{
130 Eina_Bool (*func)(const Ecore_Getopt *parser,
131 const Ecore_Getopt_Desc *desc,
132 const char *str,
133 void *data,
134 Ecore_Getopt_Value *storage);
135 const void *data;
136 Ecore_Getopt_Desc_Arg_Requirement arg_req;
137 const char *def;
138};
139
140struct _Ecore_Getopt_Desc
141{
142 char shortname; /**< used with a single dash */
143 const char *longname; /**< used with double dashes */
144 const char *help; /**< used by --help/ecore_getopt_help() */
145 const char *metavar; /**< used by ecore_getopt_help() with nargs > 0 */
146
147 Ecore_Getopt_Action action; /**< define how to handle it */
148 union
149 {
150 const Ecore_Getopt_Desc_Store store;
151 const void *store_const;
152 const char *const *choices; /* NULL terminated. */
153 const Ecore_Getopt_Type append_type;
154 const Ecore_Getopt_Desc_Callback callback;
155 const void *dummy;
156 } action_param;
157};
158
159struct _Ecore_Getopt
160{
161 const char *prog; /**< to be used when ecore_app_args_get() fails */
162 const char *usage; /**< usage example, %prog is replaced */
163 const char *version; /**< if exists, --version will work */
164 const char *copyright; /**< if exists, --copyright will work */
165 const char *license; /**< if exists, --license will work */
166 const char *description; /**< long description, possible multiline */
167 Eina_Bool strict : 1; /**< fail on errors */
168 const Ecore_Getopt_Desc descs[]; /* NULL terminated. */
169};
170
171#define ECORE_GETOPT_STORE_FULL(shortname, longname, help, metavar, type, arg_requirement, default_value) \
172 {shortname, longname, help, metavar, ECORE_GETOPT_ACTION_STORE, \
173 {.store = {type, arg_requirement, default_value}}}
174
175#define ECORE_GETOPT_STORE(shortname, longname, help, type) \
176 ECORE_GETOPT_STORE_FULL(shortname, longname, help, NULL, type, \
177 ECORE_GETOPT_DESC_ARG_REQUIREMENT_YES, {})
178
179#define ECORE_GETOPT_STORE_STR(shortname, longname, help) \
180 ECORE_GETOPT_STORE(shortname, longname, help, ECORE_GETOPT_TYPE_STR)
181#define ECORE_GETOPT_STORE_BOOL(shortname, longname, help) \
182 ECORE_GETOPT_STORE(shortname, longname, help, ECORE_GETOPT_TYPE_BOOL)
183#define ECORE_GETOPT_STORE_SHORT(shortname, longname, help) \
184 ECORE_GETOPT_STORE(shortname, longname, help, ECORE_GETOPT_TYPE_SHORT)
185#define ECORE_GETOPT_STORE_INT(shortname, longname, help) \
186 ECORE_GETOPT_STORE(shortname, longname, help, ECORE_GETOPT_TYPE_INT)
187#define ECORE_GETOPT_STORE_LONG(shortname, longname, help) \
188 ECORE_GETOPT_STORE(shortname, longname, help, ECORE_GETOPT_TYPE_LONG)
189#define ECORE_GETOPT_STORE_USHORT(shortname, longname, help) \
190 ECORE_GETOPT_STORE(shortname, longname, help, ECORE_GETOPT_TYPE_USHORT)
191#define ECORE_GETOPT_STORE_UINT(shortname, longname, help) \
192 ECORE_GETOPT_STORE(shortname, longname, help, ECORE_GETOPT_TYPE_UINT)
193#define ECORE_GETOPT_STORE_ULONG(shortname, longname, help) \
194 ECORE_GETOPT_STORE(shortname, longname, help, ECORE_GETOPT_TYPE_ULONG)
195#define ECORE_GETOPT_STORE_DOUBLE(shortname, longname, help) \
196 ECORE_GETOPT_STORE(shortname, longname, help, ECORE_GETOPT_TYPE_DOUBLE)
197
198#define ECORE_GETOPT_STORE_METAVAR(shortname, longname, help, metavar, type) \
199 ECORE_GETOPT_STORE_FULL(shortname, longname, help, metavar, type, \
200 ECORE_GETOPT_DESC_ARG_REQUIREMENT_YES, {})
201
202#define ECORE_GETOPT_STORE_METAVAR_STR(shortname, longname, help, metavar) \
203 ECORE_GETOPT_STORE_METAVAR(shortname, longname, help, metavar, ECORE_GETOPT_TYPE_STR)
204#define ECORE_GETOPT_STORE_METAVAR_BOOL(shortname, longname, help, metavar) \
205 ECORE_GETOPT_STORE_METAVAR(shortname, longname, help, metavar, ECORE_GETOPT_TYPE_BOOL)
206#define ECORE_GETOPT_STORE_METAVAR_SHORT(shortname, longname, help, metavar) \
207 ECORE_GETOPT_STORE_METAVAR(shortname, longname, help, metavar, ECORE_GETOPT_TYPE_SHORT)
208#define ECORE_GETOPT_STORE_METAVAR_INT(shortname, longname, help, metavar) \
209 ECORE_GETOPT_STORE_METAVAR(shortname, longname, help, metavar, ECORE_GETOPT_TYPE_INT)
210#define ECORE_GETOPT_STORE_METAVAR_LONG(shortname, longname, help, metavar) \
211 ECORE_GETOPT_STORE_METAVAR(shortname, longname, help, metavar, ECORE_GETOPT_TYPE_LONG)
212#define ECORE_GETOPT_STORE_METAVAR_USHORT(shortname, longname, help, metavar) \
213 ECORE_GETOPT_STORE_METAVAR(shortname, longname, help, metavar, ECORE_GETOPT_TYPE_USHORT)
214#define ECORE_GETOPT_STORE_METAVAR_UINT(shortname, longname, help, metavar) \
215 ECORE_GETOPT_STORE_METAVAR(shortname, longname, help, metavar, ECORE_GETOPT_TYPE_UINT)
216#define ECORE_GETOPT_STORE_METAVAR_ULONG(shortname, longname, help, metavar) \
217 ECORE_GETOPT_STORE_METAVAR(shortname, longname, help, metavar, ECORE_GETOPT_TYPE_ULONG)
218#define ECORE_GETOPT_STORE_METAVAR_DOUBLE(shortname, longname, help, metavar) \
219 ECORE_GETOPT_STORE_METAVAR(shortname, longname, help, metavar, ECORE_GETOPT_TYPE_DOUBLE)
220
221#define ECORE_GETOPT_STORE_DEF(shortname, longname, help, type, default_value) \
222 ECORE_GETOPT_STORE_FULL(shortname, longname, help, NULL, type, \
223 ECORE_GETOPT_DESC_ARG_REQUIREMENT_OPTIONAL, \
224 default_value)
225
226#define ECORE_GETOPT_STORE_DEF_STR(shortname, longname, help, default_value) \
227 ECORE_GETOPT_STORE_DEF(shortname, longname, help, \
228 ECORE_GETOPT_TYPE_STR, \
229 {.strv = default_value})
230#define ECORE_GETOPT_STORE_DEF_BOOL(shortname, longname, help, default_value) \
231 ECORE_GETOPT_STORE_DEF(shortname, longname, help, \
232 ECORE_GETOPT_TYPE_BOOL, \
233 {.boolv = default_value})
234#define ECORE_GETOPT_STORE_DEF_SHORT(shortname, longname, help, default_value) \
235 ECORE_GETOPT_STORE_DEF(shortname, longname, help, \
236 ECORE_GETOPT_TYPE_SHORT, \
237 {.shortv = default_value})
238#define ECORE_GETOPT_STORE_DEF_INT(shortname, longname, help, default_value) \
239 ECORE_GETOPT_STORE_DEF(shortname, longname, help, \
240 ECORE_GETOPT_TYPE_INT, \
241 {.intv = default_value})
242#define ECORE_GETOPT_STORE_DEF_LONG(shortname, longname, help, default_value) \
243 ECORE_GETOPT_STORE_DEF(shortname, longname, help, \
244 ECORE_GETOPT_TYPE_LONG, \
245 {.longv = default_value})
246#define ECORE_GETOPT_STORE_DEF_USHORT(shortname, longname, help, default_value) \
247 ECORE_GETOPT_STORE_DEF(shortname, longname, help, \
248 ECORE_GETOPT_TYPE_USHORT, \
249 {.ushortv = default_value})
250#define ECORE_GETOPT_STORE_DEF_UINT(shortname, longname, help, default_value) \
251 ECORE_GETOPT_STORE_DEF(shortname, longname, help, \
252 ECORE_GETOPT_TYPE_UINT, \
253 {.uintv = default_value})
254#define ECORE_GETOPT_STORE_DEF_ULONG(shortname, longname, help, default_value) \
255 ECORE_GETOPT_STORE_DEF(shortname, longname, help, \
256 ECORE_GETOPT_TYPE_ULONG, \
257 {.ulongv = default_value})
258#define ECORE_GETOPT_STORE_DEF_DOUBLE(shortname, longname, help, default_value) \
259 ECORE_GETOPT_STORE_DEF(shortname, longname, help, \
260 ECORE_GETOPT_TYPE_DOUBLE, \
261 {.doublev = default_value})
262
263#define ECORE_GETOPT_STORE_FULL_STR(shortname, longname, help, metavar, arg_requirement, default_value) \
264 ECORE_GETOPT_STORE_FULL(shortname, longname, help, metavar, \
265 ECORE_GETOPT_TYPE_STR, \
266 arg_requirement, \
267 {.strv = default_value})
268#define ECORE_GETOPT_STORE_FULL_BOOL(shortname, longname, help, metavar, arg_requirement, default_value) \
269 ECORE_GETOPT_STORE_FULL(shortname, longname, help, metavar, \
270 ECORE_GETOPT_TYPE_BOOL, \
271 arg_requirement, \
272 {.boolv = default_value})
273#define ECORE_GETOPT_STORE_FULL_SHORT(shortname, longname, help, metavar, arg_requirement, default_value) \
274 ECORE_GETOPT_STORE_FULL(shortname, longname, help, metavar, \
275 ECORE_GETOPT_TYPE_SHORT, \
276 arg_requirement, \
277 {.shortv = default_value})
278#define ECORE_GETOPT_STORE_FULL_INT(shortname, longname, help, metavar, arg_requirement, default_value) \
279 ECORE_GETOPT_STORE_FULL(shortname, longname, help, metavar, \
280 ECORE_GETOPT_TYPE_INT, \
281 arg_requirement, \
282 {.intv = default_value})
283#define ECORE_GETOPT_STORE_FULL_LONG(shortname, longname, help, metavar, arg_requirement, default_value) \
284 ECORE_GETOPT_STORE_FULL(shortname, longname, help, metavar, \
285 ECORE_GETOPT_TYPE_LONG, \
286 arg_requirement, \
287 {.longv = default_value})
288#define ECORE_GETOPT_STORE_FULL_USHORT(shortname, longname, help, metavar, arg_requirement, default_value) \
289 ECORE_GETOPT_STORE_FULL(shortname, longname, help, metavar, \
290 ECORE_GETOPT_TYPE_USHORT, \
291 arg_requirement, \
292 {.ushortv = default_value})
293#define ECORE_GETOPT_STORE_FULL_UINT(shortname, longname, help, metavar, arg_requirement, default_value) \
294 ECORE_GETOPT_STORE_FULL(shortname, longname, help, metavar, \
295 ECORE_GETOPT_TYPE_UINT, \
296 arg_requirement, \
297 {.uintv = default_value})
298#define ECORE_GETOPT_STORE_FULL_ULONG(shortname, longname, help, metavar, arg_requirement, default_value) \
299 ECORE_GETOPT_STORE_FULL(shortname, longname, help, metavar, \
300 ECORE_GETOPT_TYPE_ULONG, \
301 arg_requirement, \
302 {.ulongv = default_value})
303#define ECORE_GETOPT_STORE_FULL_DOUBLE(shortname, longname, help, metavar, arg_requirement, default_value) \
304 ECORE_GETOPT_STORE_FULL(shortname, longname, help, metavar, \
305 ECORE_GETOPT_TYPE_DOUBLE, \
306 arg_requirement, \
307 {.doublev = default_value})
308
309#define ECORE_GETOPT_STORE_CONST(shortname, longname, help, value) \
310 {shortname, longname, help, NULL, ECORE_GETOPT_ACTION_STORE_CONST, \
311 {.store_const = value}}
312#define ECORE_GETOPT_STORE_TRUE(shortname, longname, help) \
313 {shortname, longname, help, NULL, ECORE_GETOPT_ACTION_STORE_TRUE, \
314 {.dummy = NULL}}
315#define ECORE_GETOPT_STORE_FALSE(shortname, longname, help) \
316 {shortname, longname, help, NULL, ECORE_GETOPT_ACTION_STORE_FALSE, \
317 {.dummy = NULL}}
318
319#define ECORE_GETOPT_CHOICE(shortname, longname, help, choices_array) \
320 {shortname, longname, help, NULL, ECORE_GETOPT_ACTION_CHOICE, \
321 {.choices = choices_array}}
322#define ECORE_GETOPT_CHOICE_METAVAR(shortname, longname, help, metavar, choices_array) \
323 {shortname, longname, help, metavar, ECORE_GETOPT_ACTION_CHOICE, \
324 {.choices = choices_array}}
325
326#define ECORE_GETOPT_APPEND(shortname, longname, help, sub_type) \
327 {shortname, longname, help, NULL, ECORE_GETOPT_ACTION_APPEND, \
328 {.append_type = sub_type}}
329#define ECORE_GETOPT_APPEND_METAVAR(shortname, longname, help, metavar, type) \
330 {shortname, longname, help, metavar, ECORE_GETOPT_ACTION_APPEND, \
331 {.append_type = type}}
332
333#define ECORE_GETOPT_COUNT(shortname, longname, help) \
334 {shortname, longname, help, NULL, ECORE_GETOPT_ACTION_COUNT, \
335 {.dummy = NULL}}
336
337#define ECORE_GETOPT_CALLBACK_FULL(shortname, longname, help, metavar, callback_func, callback_data, argument_requirement, default_value) \
338 {shortname, longname, help, metavar, ECORE_GETOPT_ACTION_CALLBACK, \
339 {.callback = {callback_func, callback_data, \
340 argument_requirement, default_value}}}
341#define ECORE_GETOPT_CALLBACK_NOARGS(shortname, longname, help, callback_func, callback_data) \
342 ECORE_GETOPT_CALLBACK_FULL(shortname, longname, help, NULL, \
343 callback_func, callback_data, \
344 ECORE_GETOPT_DESC_ARG_REQUIREMENT_NO, \
345 NULL)
346#define ECORE_GETOPT_CALLBACK_ARGS(shortname, longname, help, metavar, callback_func, callback_data) \
347 ECORE_GETOPT_CALLBACK_FULL(shortname, longname, help, metavar, \
348 callback_func, callback_data, \
349 ECORE_GETOPT_DESC_ARG_REQUIREMENT_YES, \
350 NULL)
351
352#define ECORE_GETOPT_HELP(shortname, longname) \
353 {shortname, longname, "show this message.", NULL, \
354 ECORE_GETOPT_ACTION_HELP, \
355 {.dummy = NULL}}
356
357#define ECORE_GETOPT_VERSION(shortname, longname) \
358 {shortname, longname, "show program version.", NULL, \
359 ECORE_GETOPT_ACTION_VERSION, \
360 {.dummy = NULL}}
361
362#define ECORE_GETOPT_COPYRIGHT(shortname, longname) \
363 {shortname, longname, "show copyright.", NULL, \
364 ECORE_GETOPT_ACTION_COPYRIGHT, \
365 {.dummy = NULL}}
366
367#define ECORE_GETOPT_LICENSE(shortname, longname) \
368 {shortname, longname, "show license.", NULL, \
369 ECORE_GETOPT_ACTION_LICENSE, \
370 {.dummy = NULL}}
371
372#define ECORE_GETOPT_SENTINEL {0, NULL, NULL, NULL, 0, {.dummy = NULL}}
373
374#define ECORE_GETOPT_VALUE_STR(val) {.strp = &(val)}
375#define ECORE_GETOPT_VALUE_BOOL(val) {.boolp = &(val)}
376#define ECORE_GETOPT_VALUE_SHORT(val) {.shortp = &(val)}
377#define ECORE_GETOPT_VALUE_INT(val) {.intp = &(val)}
378#define ECORE_GETOPT_VALUE_LONG(val) {.longp = &(val)}
379#define ECORE_GETOPT_VALUE_USHORT(val) {.ushortp = &(val)}
380#define ECORE_GETOPT_VALUE_UINT(val) {.uintp = &(val)}
381#define ECORE_GETOPT_VALUE_ULONG(val) {.ulongp = &(val)}
382#define ECORE_GETOPT_VALUE_DOUBLE(val) {.doublep = &(val)}
383#define ECORE_GETOPT_VALUE_PTR(val) {.ptrp = &(val)}
384#define ECORE_GETOPT_VALUE_PTR_CAST(val) {.ptrp = (void **)&(val)}
385#define ECORE_GETOPT_VALUE_LIST(val) {.listp = &(val)}
386#define ECORE_GETOPT_VALUE_NONE {.ptrp = NULL}
387
388EAPI void
389ecore_getopt_help(FILE *fp,
390 const Ecore_Getopt *info);
391
392EAPI Eina_Bool
393 ecore_getopt_parser_has_duplicates(const Ecore_Getopt *parser);
394EAPI int
395 ecore_getopt_parse(const Ecore_Getopt *parser,
396 Ecore_Getopt_Value *values,
397 int argc,
398 char **argv);
399
400EAPI Eina_List *ecore_getopt_list_free(Eina_List *list);
401
402/* helper functions to be used with ECORE_GETOPT_CALLBACK_*() */
403EAPI Eina_Bool
404ecore_getopt_callback_geometry_parse(const Ecore_Getopt *parser,
405 const Ecore_Getopt_Desc *desc,
406 const char *str,
407 void *data,
408 Ecore_Getopt_Value *storage);
409EAPI Eina_Bool
410ecore_getopt_callback_size_parse(const Ecore_Getopt *parser,
411 const Ecore_Getopt_Desc *desc,
412 const char *str,
413 void *data,
414 Ecore_Getopt_Value *storage);
415
416#ifdef __cplusplus
417}
418#endif
419#endif /* _ECORE_GETOPT_H */
diff --git a/src/lib/ecore/ecore.c b/src/lib/ecore/ecore.c
new file mode 100644
index 0000000000..3aa15bf77c
--- /dev/null
+++ b/src/lib/ecore/ecore.c
@@ -0,0 +1,878 @@
1#ifdef HAVE_CONFIG_H
2# include <config.h>
3#endif
4
5#include <stdlib.h>
6#include <stdio.h>
7#include <sys/types.h>
8#include <sys/stat.h>
9#include <fcntl.h>
10#include <errno.h>
11
12#ifdef HAVE_UNISTD_H
13# include <unistd.h>
14#endif
15
16#ifdef HAVE_LOCALE_H
17# include <locale.h>
18#endif
19
20#ifdef HAVE_LANGINFO_H
21# include <langinfo.h>
22#endif
23
24#ifdef HAVE_SYS_MMAN_H
25# include <sys/mman.h>
26#endif
27
28#ifdef HAVE_EVIL
29# include <Evil.h>
30#endif
31#include <Eina.h>
32
33#include "Ecore.h"
34#include "ecore_private.h"
35
36#if HAVE_MALLINFO
37#include <malloc.h>
38
39
40static Ecore_Version _version = { VMAJ, VMIN, VMIC, VREV };
41EAPI Ecore_Version *ecore_version = &_version;
42
43#define KEEP_MAX(Global, Local) \
44 if (Global < (Local)) \
45 Global = Local;
46
47static Eina_Bool _ecore_memory_statistic(void *data);
48static int _ecore_memory_max_total = 0;
49static int _ecore_memory_max_free = 0;