aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/libraries/eina/src/include
diff options
context:
space:
mode:
authorDavid Walter Seikel2012-01-04 18:41:13 +1000
committerDavid Walter Seikel2012-01-04 18:41:13 +1000
commitdd7595a3475407a7fa96a97393bae8c5220e8762 (patch)
treee341e911d7eb911a51684a7412ef7f7c7605d28e /libraries/eina/src/include
parentAdd the skeleton. (diff)
downloadSledjHamr-dd7595a3475407a7fa96a97393bae8c5220e8762.zip
SledjHamr-dd7595a3475407a7fa96a97393bae8c5220e8762.tar.gz
SledjHamr-dd7595a3475407a7fa96a97393bae8c5220e8762.tar.bz2
SledjHamr-dd7595a3475407a7fa96a97393bae8c5220e8762.tar.xz
Add the base Enlightenment Foundation Libraries - eina, eet, evas, ecore, embryo, and edje.
Note that embryo wont be used, but I'm not sure yet if you can build edje without it.
Diffstat (limited to 'libraries/eina/src/include')
-rw-r--r--libraries/eina/src/include/Eina.h194
-rw-r--r--libraries/eina/src/include/Makefile.am89
-rw-r--r--libraries/eina/src/include/Makefile.in560
-rw-r--r--libraries/eina/src/include/eina_accessor.h340
-rw-r--r--libraries/eina/src/include/eina_array.h449
-rw-r--r--libraries/eina/src/include/eina_benchmark.h453
-rw-r--r--libraries/eina/src/include/eina_binbuf.h217
-rw-r--r--libraries/eina/src/include/eina_binshare.h193
-rw-r--r--libraries/eina/src/include/eina_clist.h456
-rw-r--r--libraries/eina/src/include/eina_config.h67
-rw-r--r--libraries/eina/src/include/eina_config.h.in67
-rw-r--r--libraries/eina/src/include/eina_convert.h374
-rw-r--r--libraries/eina/src/include/eina_counter.h213
-rw-r--r--libraries/eina/src/include/eina_cpu.h39
-rw-r--r--libraries/eina/src/include/eina_error.h198
-rw-r--r--libraries/eina/src/include/eina_file.h392
-rw-r--r--libraries/eina/src/include/eina_fp.h111
-rw-r--r--libraries/eina/src/include/eina_hamster.h58
-rw-r--r--libraries/eina/src/include/eina_hash.h1040
-rw-r--r--libraries/eina/src/include/eina_inline_array.x164
-rw-r--r--libraries/eina/src/include/eina_inline_f16p16.x83
-rw-r--r--libraries/eina/src/include/eina_inline_f32p32.x110
-rw-r--r--libraries/eina/src/include/eina_inline_f8p24.x82
-rw-r--r--libraries/eina/src/include/eina_inline_fp.x153
-rw-r--r--libraries/eina/src/include/eina_inline_hash.x151
-rw-r--r--libraries/eina/src/include/eina_inline_list.x67
-rw-r--r--libraries/eina/src/include/eina_inline_lock_posix.x509
-rw-r--r--libraries/eina/src/include/eina_inline_lock_void.x247
-rw-r--r--libraries/eina/src/include/eina_inline_lock_win32.x466
-rw-r--r--libraries/eina/src/include/eina_inline_lock_wince.x178
-rw-r--r--libraries/eina/src/include/eina_inline_log.x197
-rw-r--r--libraries/eina/src/include/eina_inline_mempool.x127
-rw-r--r--libraries/eina/src/include/eina_inline_rbtree.x50
-rw-r--r--libraries/eina/src/include/eina_inline_rectangle.x254
-rw-r--r--libraries/eina/src/include/eina_inline_str.x76
-rw-r--r--libraries/eina/src/include/eina_inline_stringshare.x91
-rw-r--r--libraries/eina/src/include/eina_inline_tiler.x151
-rw-r--r--libraries/eina/src/include/eina_inline_trash.x90
-rw-r--r--libraries/eina/src/include/eina_inline_ustringshare.x93
-rw-r--r--libraries/eina/src/include/eina_inlist.h813
-rw-r--r--libraries/eina/src/include/eina_iterator.h337
-rw-r--r--libraries/eina/src/include/eina_lalloc.h60
-rw-r--r--libraries/eina/src/include/eina_list.h1631
-rw-r--r--libraries/eina/src/include/eina_lock.h125
-rw-r--r--libraries/eina/src/include/eina_log.h888
-rw-r--r--libraries/eina/src/include/eina_magic.h322
-rw-r--r--libraries/eina/src/include/eina_main.h162
-rw-r--r--libraries/eina/src/include/eina_matrixsparse.h399
-rw-r--r--libraries/eina/src/include/eina_mempool.h123
-rw-r--r--libraries/eina/src/include/eina_mmap.h59
-rw-r--r--libraries/eina/src/include/eina_module.h343
-rw-r--r--libraries/eina/src/include/eina_prefix.h228
-rw-r--r--libraries/eina/src/include/eina_quadtree.h53
-rw-r--r--libraries/eina/src/include/eina_rbtree.h271
-rw-r--r--libraries/eina/src/include/eina_rectangle.h239
-rw-r--r--libraries/eina/src/include/eina_refcount.h76
-rw-r--r--libraries/eina/src/include/eina_safety_checks.h254
-rw-r--r--libraries/eina/src/include/eina_sched.h39
-rw-r--r--libraries/eina/src/include/eina_simple_xml_parser.h386
-rw-r--r--libraries/eina/src/include/eina_str.h325
-rw-r--r--libraries/eina/src/include/eina_strbuf.h605
-rw-r--r--libraries/eina/src/include/eina_stringshare.h321
-rw-r--r--libraries/eina/src/include/eina_tiler.h310
-rw-r--r--libraries/eina/src/include/eina_trash.h100
-rw-r--r--libraries/eina/src/include/eina_types.h282
-rw-r--r--libraries/eina/src/include/eina_unicode.h177
-rw-r--r--libraries/eina/src/include/eina_ustrbuf.h446
-rw-r--r--libraries/eina/src/include/eina_ustringshare.h200
-rw-r--r--libraries/eina/src/include/eina_xattr.h168
69 files changed, 18591 insertions, 0 deletions
diff --git a/libraries/eina/src/include/Eina.h b/libraries/eina/src/include/Eina.h
new file mode 100644
index 0000000..68c41f5
--- /dev/null
+++ b/libraries/eina/src/include/Eina.h
@@ -0,0 +1,194 @@
1/* EINA - EFL data type library
2 * Copyright (C) 2008-2011 Enlightenment Developers:
3 * Albin "Lutin" Tonnerre <albin.tonnerre@gmail.com>
4 * Alexandre "diaxen" Becoulet <diaxen@free.fr>
5 * Andre Dieb <andre.dieb@gmail.com>
6 * Arnaud de Turckheim "quarium" <quarium@gmail.com>
7 * Carsten Haitzler <raster@rasterman.com>
8 * Cedric Bail <cedric.bail@free.fr>
9 * Corey "atmos" Donohoe <atmos@atmos.org>
10 * Fabiano FidĂȘncio <fidencio@profusion.mobi>
11 * Gustavo Chaves <glima@profusion.mobi>
12 * Gustavo Sverzut Barbieri <barbieri@gmail.com>
13 * Jorge Luis "turran" Zapata <jorgeluis.zapata@gmail.com>
14 * Peter "pfritz" Wehrfritz <peter.wehrfritz@web.de>
15 * Raphael Kubo da Costa <kubo@profusion.mobi>
16 * Tilman Sauerbeck <tilman@code-monkey.de>
17 * Vincent "caro" Torri <vtorri at univ-evry dot fr>
18 * Tom Hacohen <tom@stosb.com>
19 *
20 * This library is free software; you can redistribute it and/or
21 * modify it under the terms of the GNU Lesser General Public
22 * License as published by the Free Software Foundation; either
23 * version 2.1 of the License, or (at your option) any later version.
24 *
25 * This library is distributed in the hope that it will be useful,
26 * but WITHOUT ANY WARRANTY; without even the implied warranty of
27 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
28 * Lesser General Public License for more details.
29 *
30 * You should have received a copy of the GNU Lesser General Public
31 * License along with this library;
32 * if not, see <http://www.gnu.org/licenses/>.
33 */
34
35#ifndef EINA_H_
36#define EINA_H_
37
38/**
39 * @file
40 * @brief Eina Utility library
41 *
42 * These routines are used for Eina.
43 */
44
45/**
46 * @mainpage Eina
47 *
48 * @version 1.1
49 * @date 2008-2011
50 *
51 * @section eina_intro_sec Introduction
52 *
53 * The Eina library is a library that implements an API for data types
54 * in an efficient way. It also provides some useful tools like
55 * opening shared libraries, errors management, type conversion,
56 * time accounting and memory pool.
57 *
58 * This library is cross-platform and can be compiled and used on
59 * Linux, BSD, Opensolaris and Windows (XP and CE).
60 *
61 * The data types that are available are (see @ref Eina_Data_Types_Group):
62 * @li @ref Eina_Array_Group standard array of @c void* data.
63 * @li @ref Eina_Hash_Group standard hash of @c void* data.
64 * @li @ref Eina_Inline_List_Group list with nodes inlined into user type.
65 * @li @ref Eina_CList_Group compact inlined list.
66 * @li @ref Eina_List_Group standard list of @c void* data.
67 * @li @ref Eina_Iterator_Group Iterator functions.
68 * @li @ref Eina_Matrixsparse_Group sparse matrix of @c void* data.
69 * @li @ref Eina_Rbtree_Group red-black tree with nodes inlined into user type.
70 * @li @ref Eina_String_Buffer_Group mutable string to prepend, insert or append strings to a buffer.
71 * @li @ref Eina_Stringshare_Group saves memory by sharing read-only string references.
72 * @li @ref Eina_Tiler_Group split, merge and navigates into 2D tiled regions.
73 * @li @ref Eina_Trash_Group container of unused but allocated data.
74 *
75 * The tools that are available are (see @ref Eina_Tools_Group):
76 * @li @ref Eina_Benchmark_Group helper to write benchmarks.
77 * @li @ref Eina_Convert_Group faster conversion from strings to integers, double, etc.
78 * @li @ref Eina_Counter_Group measures number of calls and their time.
79 * @li @ref Eina_Error_Group error identifiers.
80 * @li @ref Eina_File_Group simple file list and path split.
81 * @li @ref Eina_Lalloc_Group simple lazy allocator.
82 * @li @ref Eina_Log_Group full-featured logging system.
83 * @li @ref Eina_Magic_Group provides runtime type checking.
84 * @li @ref Eina_Memory_Pool_Group abstraction for various memory allocators.
85 * @li @ref Eina_Module_Group lists, loads and share modules using Eina_Module standard.
86 * @li @ref Eina_Rectangle_Group rectangle structure and standard manipulation methods.
87 * @li @ref Eina_Safety_Checks_Group extra checks that will report unexpected conditions and can be disabled at compile time.
88 * @li @ref Eina_String_Group a set of functions that manages C strings.
89 *
90 * Please see the @ref authors page for contact details.
91 *
92 * @defgroup Eina_Data_Types_Group Data types
93 *
94 * Eina provide easy to use and optimized data types and structures.
95 *
96 *
97 * @defgroup Eina_Containers_Group Containers
98 *
99 * Containers are data types that hold data and allow iteration over
100 * their elements with an @ref Eina_Iterator_Group, or eventually an
101 * @ref Eina_Accessor_Group.
102 *
103 *
104 * @defgroup Eina_Tools_Group Tools
105 *
106 * Eina tools aims to help application development, providing ways to
107 * make it safer, log errors, manage memory more efficiently and more.
108 *
109 */
110
111/**
112 *
113 * @page authors Authors
114 *
115 * @author Albin "Lutin" Tonnerre <albin.tonnerre@@gmail.com>
116 * @author Alexandre "diaxen" Becoulet <diaxen@@free.fr>
117 * @author Andre Dieb <andre.dieb@@gmail.com>
118 * @author Arnaud de Turckheim "quarium" <quarium@@gmail.com>
119 * @author Carsten Haitzler <raster@@rasterman.com>
120 * @author Cedric Bail <cedric.bail@@free.fr>
121 * @author Corey "atmos" Donohoe <atmos@@atmos.org>
122 * @author Fabiano FidĂȘncio <fidencio@@profusion.mobi>
123 * @author Gustavo Chaves <glima@@profusion.mobi>
124 * @author Gustavo Sverzut Barbieri <barbieri@@profusion.mobi>
125 * @author Jorge Luis "turran" Zapata <jorgeluis.zapata@@gmail.com>
126 * @author Peter "pfritz" Wehrfritz <peter.wehrfritz@@web.de>
127 * @author Raphael Kubo da Costa <kubo@@profusion.mobi>
128 * @author Tilman Sauerbeck <tilman@@code-monkey.de>
129 * @author Vincent "caro" Torri <vtorri at univ-evry dot fr>
130 * @author Tom Hacohen <tom@@stosb.com>
131 *
132 * Please contact <enlightenment-devel@lists.sourceforge.net> to get in
133 * contact with the developers and maintainers.
134 *
135 */
136
137#ifdef _WIN32
138# include <Evil.h>
139#endif
140
141#ifdef __cplusplus
142extern "C" {
143#endif
144
145#include "eina_config.h"
146#include "eina_types.h"
147#include "eina_main.h"
148#include "eina_fp.h"
149#include "eina_rectangle.h"
150#include "eina_clist.h"
151#include "eina_inlist.h"
152#include "eina_file.h"
153#include "eina_list.h"
154#include "eina_hash.h"
155#include "eina_trash.h"
156#include "eina_lalloc.h"
157#include "eina_module.h"
158#include "eina_mempool.h"
159#include "eina_error.h"
160#include "eina_log.h"
161#include "eina_array.h"
162#include "eina_binshare.h"
163#include "eina_stringshare.h"
164#include "eina_ustringshare.h"
165#include "eina_magic.h"
166#include "eina_counter.h"
167#include "eina_rbtree.h"
168#include "eina_accessor.h"
169#include "eina_iterator.h"
170#include "eina_benchmark.h"
171#include "eina_convert.h"
172#include "eina_cpu.h"
173#include "eina_sched.h"
174#include "eina_tiler.h"
175#include "eina_hamster.h"
176#include "eina_matrixsparse.h"
177#include "eina_str.h"
178#include "eina_strbuf.h"
179#include "eina_binbuf.h"
180#include "eina_ustrbuf.h"
181#include "eina_unicode.h"
182#include "eina_quadtree.h"
183#include "eina_simple_xml_parser.h"
184#include "eina_lock.h"
185#include "eina_prefix.h"
186#include "eina_refcount.h"
187#include "eina_mmap.h"
188#include "eina_xattr.h"
189
190#ifdef __cplusplus
191}
192#endif
193
194#endif /* EINA_H */
diff --git a/libraries/eina/src/include/Makefile.am b/libraries/eina/src/include/Makefile.am
new file mode 100644
index 0000000..41a37cb
--- /dev/null
+++ b/libraries/eina/src/include/Makefile.am
@@ -0,0 +1,89 @@
1MAINTAINERCLEANFILES = Makefile.in
2
3EINAHEADERS = \
4eina_safety_checks.h \
5eina_error.h \
6eina_log.h \
7eina_inline_log.x \
8eina_fp.h \
9eina_inline_f32p32.x \
10eina_inline_f16p16.x \
11eina_inline_f8p24.x \
12eina_inline_fp.x \
13eina_hash.h \
14eina_inline_hash.x \
15eina_lalloc.h \
16eina_clist.h \
17eina_inlist.h \
18eina_list.h \
19eina_file.h \
20eina_mempool.h \
21eina_module.h \
22eina_rectangle.h \
23eina_types.h \
24eina_array.h \
25eina_counter.h \
26eina_inline_array.x \
27eina_magic.h \
28eina_stringshare.h \
29eina_binshare.h \
30eina_binbuf.h \
31eina_ustringshare.h \
32eina_inline_stringshare.x \
33eina_inline_ustringshare.x \
34eina_inline_list.x \
35eina_accessor.h \
36eina_convert.h \
37eina_rbtree.h \
38eina_benchmark.h \
39eina_inline_rbtree.x \
40eina_inline_mempool.x \
41eina_inline_rectangle.x \
42eina_inline_trash.x \
43eina_trash.h \
44eina_iterator.h \
45eina_main.h \
46eina_cpu.h \
47eina_sched.h \
48eina_tiler.h \
49eina_hamster.h \
50eina_matrixsparse.h \
51eina_inline_tiler.x \
52eina_str.h \
53eina_inline_str.x \
54eina_strbuf.h \
55eina_ustrbuf.h \
56eina_unicode.h \
57eina_quadtree.h \
58eina_simple_xml_parser.h \
59eina_lock.h \
60eina_prefix.h \
61eina_refcount.h \
62eina_mmap.h \
63eina_xattr.h
64
65# Will be back for developper after 1.1.
66# eina_object.h
67
68if EINA_HAVE_THREADS
69if EINA_HAVE_WINCE
70EINAHEADERS += eina_inline_lock_wince.x
71else
72if EINA_HAVE_WIN32
73EINAHEADERS += eina_inline_lock_win32.x
74else
75EINAHEADERS += eina_inline_lock_posix.x
76endif
77endif
78else
79EINAHEADERS += eina_inline_lock_void.x
80endif
81
82installed_mainheaderdir = $(includedir)/eina-@VMAJ@
83dist_installed_mainheader_DATA = Eina.h eina_config.h
84
85installed_headersdir = $(includedir)/eina-@VMAJ@/eina
86dist_installed_headers_DATA = $(EINAHEADERS)
87
88EXTRA_DIST = \
89eina_config.h.in
diff --git a/libraries/eina/src/include/Makefile.in b/libraries/eina/src/include/Makefile.in
new file mode 100644
index 0000000..f6e0074
--- /dev/null
+++ b/libraries/eina/src/include/Makefile.in
@@ -0,0 +1,560 @@
1# Makefile.in generated by automake 1.11.1 from Makefile.am.
2# @configure_input@
3
4# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
5# 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation,
6# Inc.
7# This Makefile.in is free software; the Free Software Foundation
8# gives unlimited permission to copy and/or distribute it,
9# with or without modifications, as long as this notice is preserved.
10
11# This program is distributed in the hope that it will be useful,
12# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
13# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
14# PARTICULAR PURPOSE.
15
16@SET_MAKE@
17
18VPATH = @srcdir@
19pkgdatadir = $(datadir)/@PACKAGE@
20pkgincludedir = $(includedir)/@PACKAGE@
21pkglibdir = $(libdir)/@PACKAGE@
22pkglibexecdir = $(libexecdir)/@PACKAGE@
23am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
24install_sh_DATA = $(install_sh) -c -m 644
25install_sh_PROGRAM = $(install_sh) -c
26install_sh_SCRIPT = $(install_sh) -c
27INSTALL_HEADER = $(INSTALL_DATA)
28transform = $(program_transform_name)
29NORMAL_INSTALL = :
30PRE_INSTALL = :
31POST_INSTALL = :
32NORMAL_UNINSTALL = :
33PRE_UNINSTALL = :
34POST_UNINSTALL = :
35build_triplet = @build@
36host_triplet = @host@
37
38# Will be back for developper after 1.1.
39# eina_object.h
40@EINA_HAVE_THREADS_TRUE@@EINA_HAVE_WINCE_TRUE@am__append_1 = eina_inline_lock_wince.x
41@EINA_HAVE_THREADS_TRUE@@EINA_HAVE_WIN32_TRUE@@EINA_HAVE_WINCE_FALSE@am__append_2 = eina_inline_lock_win32.x
42@EINA_HAVE_THREADS_TRUE@@EINA_HAVE_WIN32_FALSE@@EINA_HAVE_WINCE_FALSE@am__append_3 = eina_inline_lock_posix.x
43@EINA_HAVE_THREADS_FALSE@am__append_4 = eina_inline_lock_void.x
44subdir = src/include
45DIST_COMMON = $(am__dist_installed_headers_DATA_DIST) \
46 $(dist_installed_mainheader_DATA) $(srcdir)/Makefile.am \
47 $(srcdir)/Makefile.in $(srcdir)/eina_config.h.in
48ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
49am__aclocal_m4_deps = $(top_srcdir)/m4/efl_attribute.m4 \
50 $(top_srcdir)/m4/efl_benchmark.m4 \
51 $(top_srcdir)/m4/efl_compiler_flag.m4 \
52 $(top_srcdir)/m4/efl_coverage.m4 $(top_srcdir)/m4/efl_cpu.m4 \
53 $(top_srcdir)/m4/efl_doxygen.m4 \
54 $(top_srcdir)/m4/efl_examples.m4 \
55 $(top_srcdir)/m4/efl_fnmatch.m4 \
56 $(top_srcdir)/m4/efl_path_max.m4 $(top_srcdir)/m4/efl_tests.m4 \
57 $(top_srcdir)/m4/efl_threads.m4 \
58 $(top_srcdir)/m4/efl_voltron.m4 $(top_srcdir)/m4/eina_bench.m4 \
59 $(top_srcdir)/m4/eina_check.m4 $(top_srcdir)/m4/libtool.m4 \
60 $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \
61 $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \
62 $(top_srcdir)/acinclude.m4 $(top_srcdir)/configure.ac
63am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
64 $(ACLOCAL_M4)
65mkinstalldirs = $(install_sh) -d
66CONFIG_HEADER = $(top_builddir)/config.h
67CONFIG_CLEAN_FILES = eina_config.h
68CONFIG_CLEAN_VPATH_FILES =
69AM_V_GEN = $(am__v_GEN_$(V))
70am__v_GEN_ = $(am__v_GEN_$(AM_DEFAULT_VERBOSITY))
71am__v_GEN_0 = @echo " GEN " $@;
72AM_V_at = $(am__v_at_$(V))
73am__v_at_ = $(am__v_at_$(AM_DEFAULT_VERBOSITY))
74am__v_at_0 = @
75SOURCES =
76DIST_SOURCES =
77am__dist_installed_headers_DATA_DIST = eina_safety_checks.h \
78 eina_error.h eina_log.h eina_inline_log.x eina_fp.h \
79 eina_inline_f32p32.x eina_inline_f16p16.x eina_inline_f8p24.x \
80 eina_inline_fp.x eina_hash.h eina_inline_hash.x eina_lalloc.h \
81 eina_clist.h eina_inlist.h eina_list.h eina_file.h \
82 eina_mempool.h eina_module.h eina_rectangle.h eina_types.h \
83 eina_array.h eina_counter.h eina_inline_array.x eina_magic.h \
84 eina_stringshare.h eina_binshare.h eina_binbuf.h \
85 eina_ustringshare.h eina_inline_stringshare.x \
86 eina_inline_ustringshare.x eina_inline_list.x eina_accessor.h \
87 eina_convert.h eina_rbtree.h eina_benchmark.h \
88 eina_inline_rbtree.x eina_inline_mempool.x \
89 eina_inline_rectangle.x eina_inline_trash.x eina_trash.h \
90 eina_iterator.h eina_main.h eina_cpu.h eina_sched.h \
91 eina_tiler.h eina_hamster.h eina_matrixsparse.h \
92 eina_inline_tiler.x eina_str.h eina_inline_str.x eina_strbuf.h \
93 eina_ustrbuf.h eina_unicode.h eina_quadtree.h \
94 eina_simple_xml_parser.h eina_lock.h eina_prefix.h \
95 eina_refcount.h eina_mmap.h eina_xattr.h \
96 eina_inline_lock_wince.x eina_inline_lock_win32.x \
97 eina_inline_lock_posix.x eina_inline_lock_void.x
98am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
99am__vpath_adj = case $$p in \
100 $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
101 *) f=$$p;; \
102 esac;
103am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`;
104am__install_max = 40
105am__nobase_strip_setup = \
106 srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'`
107am__nobase_strip = \
108 for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||"
109am__nobase_list = $(am__nobase_strip_setup); \
110 for p in $$list; do echo "$$p $$p"; done | \
111 sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \
112 $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \
113 if (++n[$$2] == $(am__install_max)) \
114 { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \
115 END { for (dir in files) print dir, files[dir] }'
116am__base_list = \
117 sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \
118 sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g'
119am__installdirs = "$(DESTDIR)$(installed_headersdir)" \
120 "$(DESTDIR)$(installed_mainheaderdir)"
121DATA = $(dist_installed_headers_DATA) \
122 $(dist_installed_mainheader_DATA)
123DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
124ACLOCAL = @ACLOCAL@
125ALLOCA = @ALLOCA@
126AMTAR = @AMTAR@
127AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
128AR = @AR@
129AS = @AS@
130AUTOCONF = @AUTOCONF@
131AUTOHEADER = @AUTOHEADER@
132AUTOMAKE = @AUTOMAKE@
133AWK = @AWK@
134CC = @CC@
135CCDEPMODE = @CCDEPMODE@
136CFLAGS = @CFLAGS@
137CHECK_CFLAGS = @CHECK_CFLAGS@
138CHECK_LIBS = @CHECK_LIBS@
139CPP = @CPP@
140CPPFLAGS = @CPPFLAGS@
141CXX = @CXX@
142CXXCPP = @CXXCPP@
143CXXDEPMODE = @CXXDEPMODE@
144CXXFLAGS = @CXXFLAGS@
145CYGPATH_W = @CYGPATH_W@
146DEFS = @DEFS@
147DEPDIR = @DEPDIR@
148DLLTOOL = @DLLTOOL@
149DSYMUTIL = @DSYMUTIL@
150DUMPBIN = @DUMPBIN@
151ECHO_C = @ECHO_C@
152ECHO_N = @ECHO_N@
153ECHO_T = @ECHO_T@
154ECORE_EVAS_CFLAGS = @ECORE_EVAS_CFLAGS@
155ECORE_EVAS_LIBS = @ECORE_EVAS_LIBS@
156EFL_COVERAGE_CFLAGS = @EFL_COVERAGE_CFLAGS@
157EFL_COVERAGE_LIBS = @EFL_COVERAGE_LIBS@
158EFL_EINA_BUILD = @EFL_EINA_BUILD@
159EFL_FNMATCH_LIBS = @EFL_FNMATCH_LIBS@
160EFL_PTHREAD_CFLAGS = @EFL_PTHREAD_CFLAGS@
161EFL_PTHREAD_LIBS = @EFL_PTHREAD_LIBS@
162EFL_SIMD_FLAGS = @EFL_SIMD_FLAGS@
163EGREP = @EGREP@
164EINA_CFLAGS = @EINA_CFLAGS@
165EINA_CONFIGURE_DEFAULT_MEMPOOL = @EINA_CONFIGURE_DEFAULT_MEMPOOL@
166EINA_CONFIGURE_HAVE_DEBUG_THREADS = @EINA_CONFIGURE_HAVE_DEBUG_THREADS@
167EINA_CONFIGURE_HAVE_INTTYPES_H = @EINA_CONFIGURE_HAVE_INTTYPES_H@
168EINA_CONFIGURE_HAVE_ON_OFF_THREADS = @EINA_CONFIGURE_HAVE_ON_OFF_THREADS@
169EINA_CONFIGURE_HAVE_STDINT_H = @EINA_CONFIGURE_HAVE_STDINT_H@
170EINA_CONFIGURE_HAVE_THREADS = @EINA_CONFIGURE_HAVE_THREADS@
171EINA_CONFIGURE_MAGIC_DEBUG = @EINA_CONFIGURE_MAGIC_DEBUG@
172EINA_CONFIGURE_SAFETY_CHECKS = @EINA_CONFIGURE_SAFETY_CHECKS@
173EINA_CPPFLAGS = @EINA_CPPFLAGS@
174EINA_LIBS = @EINA_LIBS@
175EINA_SIZEOF_WCHAR_T = @EINA_SIZEOF_WCHAR_T@
176EMEMOA_CFLAGS = @EMEMOA_CFLAGS@
177EMEMOA_LIBS = @EMEMOA_LIBS@
178ESCAPE_CFLAGS = @ESCAPE_CFLAGS@
179ESCAPE_LIBS = @ESCAPE_LIBS@
180EVIL_CFLAGS = @EVIL_CFLAGS@
181EVIL_LIBS = @EVIL_LIBS@
182EXEEXT = @EXEEXT@
183FGREP = @FGREP@
184GLIB_CFLAGS = @GLIB_CFLAGS@
185GLIB_LIBS = @GLIB_LIBS@
186GREP = @GREP@
187INSTALL = @INSTALL@
188INSTALL_DATA = @INSTALL_DATA@
189INSTALL_PROGRAM = @INSTALL_PROGRAM@
190INSTALL_SCRIPT = @INSTALL_SCRIPT@
191INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
192LD = @LD@
193LDFLAGS = @LDFLAGS@
194LIBOBJS = @LIBOBJS@
195LIBS = @LIBS@
196LIBTOOL = @LIBTOOL@
197LIPO = @LIPO@
198LN_S = @LN_S@
199LTLIBOBJS = @LTLIBOBJS@
200MAKEINFO = @MAKEINFO@
201MKDIR_P = @MKDIR_P@
202MODULE_ARCH = @MODULE_ARCH@
203NM = @NM@
204NMEDIT = @NMEDIT@
205OBJDUMP = @OBJDUMP@
206OBJEXT = @OBJEXT@
207OTOOL = @OTOOL@
208OTOOL64 = @OTOOL64@
209PACKAGE = @PACKAGE@
210PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
211PACKAGE_NAME = @PACKAGE_NAME@
212PACKAGE_STRING = @PACKAGE_STRING@
213PACKAGE_TARNAME = @PACKAGE_TARNAME@
214PACKAGE_URL = @PACKAGE_URL@
215PACKAGE_VERSION = @PACKAGE_VERSION@
216PATH_SEPARATOR = @PATH_SEPARATOR@
217PKG_CONFIG = @PKG_CONFIG@
218PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@
219PKG_CONFIG_PATH = @PKG_CONFIG_PATH@
220RANLIB = @RANLIB@
221SED = @SED@
222SET_MAKE = @SET_MAKE@
223SHELL = @SHELL@
224STRIP = @STRIP@
225VALGRIND_CFLAGS = @VALGRIND_CFLAGS@
226VALGRIND_LIBS = @VALGRIND_LIBS@
227VERSION = @VERSION@
228VMAJ = @VMAJ@
229abs_builddir = @abs_builddir@
230abs_srcdir = @abs_srcdir@
231abs_top_builddir = @abs_top_builddir@
232abs_top_srcdir = @abs_top_srcdir@
233ac_ct_CC = @ac_ct_CC@
234ac_ct_CXX = @ac_ct_CXX@
235ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
236am__include = @am__include@
237am__leading_dot = @am__leading_dot@
238am__quote = @am__quote@
239am__tar = @am__tar@
240am__untar = @am__untar@
241bindir = @bindir@
242build = @build@
243build_alias = @build_alias@
244build_cpu = @build_cpu@
245build_os = @build_os@
246build_vendor = @build_vendor@
247builddir = @builddir@
248datadir = @datadir@
249datarootdir = @datarootdir@
250dlopen_libs = @dlopen_libs@
251docdir = @docdir@
252dvidir = @dvidir@
253efl_doxygen = @efl_doxygen@
254efl_have_doxygen = @efl_have_doxygen@
255exec_prefix = @exec_prefix@
256have_lcov = @have_lcov@
257host = @host@
258host_alias = @host_alias@
259host_cpu = @host_cpu@
260host_os = @host_os@
261host_vendor = @host_vendor@
262htmldir = @htmldir@
263iconv_libs = @iconv_libs@
264includedir = @includedir@
265infodir = @infodir@
266install_sh = @install_sh@
267libdir = @libdir@
268libexecdir = @libexecdir@
269localedir = @localedir@
270localstatedir = @localstatedir@
271lt_ECHO = @lt_ECHO@
272lt_enable_auto_import = @lt_enable_auto_import@
273mandir = @mandir@
274mkdir_p = @mkdir_p@
275oldincludedir = @oldincludedir@
276pdfdir = @pdfdir@
277pkgconfig_requires_private = @pkgconfig_requires_private@
278prefix = @prefix@
279program_transform_name = @program_transform_name@
280psdir = @psdir@
281release_info = @release_info@
282requirement_eina = @requirement_eina@
283rt_libs = @rt_libs@
284sbindir = @sbindir@
285sharedstatedir = @sharedstatedir@
286srcdir = @srcdir@
287sysconfdir = @sysconfdir@
288target_alias = @target_alias@
289top_build_prefix = @top_build_prefix@
290top_builddir = @top_builddir@
291top_srcdir = @top_srcdir@
292version_info = @version_info@
293MAINTAINERCLEANFILES = Makefile.in
294EINAHEADERS = eina_safety_checks.h eina_error.h eina_log.h \
295 eina_inline_log.x eina_fp.h eina_inline_f32p32.x \
296 eina_inline_f16p16.x eina_inline_f8p24.x eina_inline_fp.x \
297 eina_hash.h eina_inline_hash.x eina_lalloc.h eina_clist.h \
298 eina_inlist.h eina_list.h eina_file.h eina_mempool.h \
299 eina_module.h eina_rectangle.h eina_types.h eina_array.h \
300 eina_counter.h eina_inline_array.x eina_magic.h \
301 eina_stringshare.h eina_binshare.h eina_binbuf.h \
302 eina_ustringshare.h eina_inline_stringshare.x \
303 eina_inline_ustringshare.x eina_inline_list.x eina_accessor.h \
304 eina_convert.h eina_rbtree.h eina_benchmark.h \
305 eina_inline_rbtree.x eina_inline_mempool.x \
306 eina_inline_rectangle.x eina_inline_trash.x eina_trash.h \
307 eina_iterator.h eina_main.h eina_cpu.h eina_sched.h \
308 eina_tiler.h eina_hamster.h eina_matrixsparse.h \
309 eina_inline_tiler.x eina_str.h eina_inline_str.x eina_strbuf.h \
310 eina_ustrbuf.h eina_unicode.h eina_quadtree.h \
311 eina_simple_xml_parser.h eina_lock.h eina_prefix.h \
312 eina_refcount.h eina_mmap.h eina_xattr.h $(am__append_1) \
313 $(am__append_2) $(am__append_3) $(am__append_4)
314installed_mainheaderdir = $(includedir)/eina-@VMAJ@
315dist_installed_mainheader_DATA = Eina.h eina_config.h
316installed_headersdir = $(includedir)/eina-@VMAJ@/eina
317dist_installed_headers_DATA = $(EINAHEADERS)
318EXTRA_DIST = \
319eina_config.h.in
320
321all: all-am
322
323.SUFFIXES:
324$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
325 @for dep in $?; do \
326 case '$(am__configure_deps)' in \
327 *$$dep*) \
328 ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
329 && { if test -f $@; then exit 0; else break; fi; }; \
330 exit 1;; \
331 esac; \
332 done; \
333 echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu src/include/Makefile'; \
334 $(am__cd) $(top_srcdir) && \
335 $(AUTOMAKE) --gnu src/include/Makefile
336.PRECIOUS: Makefile
337Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
338 @case '$?' in \
339 *config.status*) \
340 cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
341 *) \
342 echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
343 cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
344 esac;
345
346$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
347 cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
348
349$(top_srcdir)/configure: $(am__configure_deps)
350 cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
351$(ACLOCAL_M4): $(am__aclocal_m4_deps)
352 cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
353$(am__aclocal_m4_deps):
354eina_config.h: $(top_builddir)/config.status $(srcdir)/eina_config.h.in
355 cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@
356
357mostlyclean-libtool:
358 -rm -f *.lo
359
360clean-libtool:
361 -rm -rf .libs _libs
362install-dist_installed_headersDATA: $(dist_installed_headers_DATA)
363 @$(NORMAL_INSTALL)
364 test -z "$(installed_headersdir)" || $(MKDIR_P) "$(DESTDIR)$(installed_headersdir)"
365 @list='$(dist_installed_headers_DATA)'; test -n "$(installed_headersdir)" || list=; \
366 for p in $$list; do \
367 if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
368 echo "$$d$$p"; \
369 done | $(am__base_list) | \
370 while read files; do \
371 echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(installed_headersdir)'"; \
372 $(INSTALL_DATA) $$files "$(DESTDIR)$(installed_headersdir)" || exit $$?; \
373 done
374
375uninstall-dist_installed_headersDATA:
376 @$(NORMAL_UNINSTALL)
377 @list='$(dist_installed_headers_DATA)'; test -n "$(installed_headersdir)" || list=; \
378 files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \
379 test -n "$$files" || exit 0; \
380 echo " ( cd '$(DESTDIR)$(installed_headersdir)' && rm -f" $$files ")"; \
381 cd "$(DESTDIR)$(installed_headersdir)" && rm -f $$files
382install-dist_installed_mainheaderDATA: $(dist_installed_mainheader_DATA)
383 @$(NORMAL_INSTALL)
384 test -z "$(installed_mainheaderdir)" || $(MKDIR_P) "$(DESTDIR)$(installed_mainheaderdir)"
385 @list='$(dist_installed_mainheader_DATA)'; test -n "$(installed_mainheaderdir)" || list=; \
386 for p in $$list; do \
387 if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
388 echo "$$d$$p"; \
389 done | $(am__base_list) | \
390 while read files; do \
391 echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(installed_mainheaderdir)'"; \
392 $(INSTALL_DATA) $$files "$(DESTDIR)$(installed_mainheaderdir)" || exit $$?; \
393 done
394
395uninstall-dist_installed_mainheaderDATA:
396 @$(NORMAL_UNINSTALL)
397 @list='$(dist_installed_mainheader_DATA)'; test -n "$(installed_mainheaderdir)" || list=; \
398 files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \
399 test -n "$$files" || exit 0; \
400 echo " ( cd '$(DESTDIR)$(installed_mainheaderdir)' && rm -f" $$files ")"; \
401 cd "$(DESTDIR)$(installed_mainheaderdir)" && rm -f $$files
402tags: TAGS
403TAGS:
404
405ctags: CTAGS
406CTAGS:
407
408
409distdir: $(DISTFILES)
410 @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
411 topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
412 list='$(DISTFILES)'; \
413 dist_files=`for file in $$list; do echo $$file; done | \
414 sed -e "s|^$$srcdirstrip/||;t" \
415 -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
416 case $$dist_files in \
417 */*) $(MKDIR_P) `echo "$$dist_files" | \
418 sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
419 sort -u` ;; \
420 esac; \
421 for file in $$dist_files; do \
422 if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
423 if test -d $$d/$$file; then \
424 dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
425 if test -d "$(distdir)/$$file"; then \
426 find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
427 fi; \
428 if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
429 cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
430 find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
431 fi; \
432 cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
433 else \
434 test -f "$(distdir)/$$file" \
435 || cp -p $$d/$$file "$(distdir)/$$file" \
436 || exit 1; \
437 fi; \
438 done
439check-am: all-am
440check: check-am
441all-am: Makefile $(DATA)
442installdirs:
443 for dir in "$(DESTDIR)$(installed_headersdir)" "$(DESTDIR)$(installed_mainheaderdir)"; do \
444 test -z "$$dir" || $(MKDIR_P) "$$dir"; \
445 done
446install: install-am
447install-exec: install-exec-am
448install-data: install-data-am
449uninstall: uninstall-am
450
451install-am: all-am
452 @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
453
454installcheck: installcheck-am
455install-strip:
456 $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
457 install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
458 `test -z '$(STRIP)' || \
459 echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
460mostlyclean-generic:
461
462clean-generic:
463
464distclean-generic:
465 -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
466 -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
467
468maintainer-clean-generic:
469 @echo "This command is intended for maintainers to use"
470 @echo "it deletes files that may require special tools to rebuild."
471 -test -z "$(MAINTAINERCLEANFILES)" || rm -f $(MAINTAINERCLEANFILES)
472clean: clean-am
473
474clean-am: clean-generic clean-libtool mostlyclean-am
475
476distclean: distclean-am
477 -rm -f Makefile
478distclean-am: clean-am distclean-generic
479
480dvi: dvi-am
481
482dvi-am:
483
484html: html-am
485
486html-am:
487
488info: info-am
489
490info-am:
491
492install-data-am: install-dist_installed_headersDATA \
493 install-dist_installed_mainheaderDATA
494
495install-dvi: install-dvi-am
496
497install-dvi-am:
498
499install-exec-am:
500
501install-html: install-html-am
502
503install-html-am:
504
505install-info: install-info-am
506
507install-info-am:
508
509install-man:
510
511install-pdf: install-pdf-am
512
513install-pdf-am:
514
515install-ps: install-ps-am
516
517install-ps-am:
518
519installcheck-am:
520
521maintainer-clean: maintainer-clean-am
522 -rm -f Makefile
523maintainer-clean-am: distclean-am maintainer-clean-generic
524
525mostlyclean: mostlyclean-am
526
527mostlyclean-am: mostlyclean-generic mostlyclean-libtool
528
529pdf: pdf-am
530
531pdf-am:
532
533ps: ps-am
534
535ps-am:
536
537uninstall-am: uninstall-dist_installed_headersDATA \
538 uninstall-dist_installed_mainheaderDATA
539
540.MAKE: install-am install-strip
541
542.PHONY: all all-am check check-am clean clean-generic clean-libtool \
543 distclean distclean-generic distclean-libtool distdir dvi \
544 dvi-am html html-am info info-am install install-am \
545 install-data install-data-am \
546 install-dist_installed_headersDATA \
547 install-dist_installed_mainheaderDATA install-dvi \
548 install-dvi-am install-exec install-exec-am install-html \
549 install-html-am install-info install-info-am install-man \
550 install-pdf install-pdf-am install-ps install-ps-am \
551 install-strip installcheck installcheck-am installdirs \
552 maintainer-clean maintainer-clean-generic mostlyclean \
553 mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
554 uninstall uninstall-am uninstall-dist_installed_headersDATA \
555 uninstall-dist_installed_mainheaderDATA
556
557
558# Tell versions [3.59,3.63) of GNU make to not export all variables.
559# Otherwise a system limit (for SysV at least) may be exceeded.
560.NOEXPORT:
diff --git a/libraries/eina/src/include/eina_accessor.h b/libraries/eina/src/include/eina_accessor.h
new file mode 100644
index 0000000..cae7a5c
--- /dev/null
+++ b/libraries/eina/src/include/eina_accessor.h
@@ -0,0 +1,340 @@
1/* EINA - EFL data type library
2 * Copyright (C) 2008 Cedric Bail
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library;
16 * if not, see <http://www.gnu.org/licenses/>.
17 */
18
19#ifndef EINA_ACCESSOR_H__
20#define EINA_ACCESSOR_H__
21
22#include "eina_config.h"
23
24#include "eina_types.h"
25#include "eina_magic.h"
26
27/**
28 * @page eina_accessor_example_01_page Eina_Accessor usage
29 * @dontinclude eina_accessor_01.c
30 *
31 * We start by including necessary headers, declaring variables and
32 * initializing eina:
33 * @skip #include
34 * @until eina_init
35 *
36 * Next we populate our array and list:
37 * @until }
38 *
39 * Now that we have two containers populated we can actually start the example
40 * and create an accessor:
41 * @until accessor_new
42 *
43 * Once having the accessor we can use it to access certain elements in the
44 * container:
45 * @until }
46 * @note Unlike iterators accessors allow us non-linear access, which allows us
47 * to print only the odd elements in the container.
48 *
49 * As with every other resource we allocate we need to free the accessor(and the
50 * array):
51 * @until array_free
52 *
53 * Now we create another accessor, this time for the list:
54 * @until accessor_new
55 *
56 * And now the interesting bit, we use the same code we used above to print
57 * parts of the array to print parts of the list:
58 * @until }
59 *
60 * And to free the list we use a gimmick, instead of freeing @a list, we ask the
61 * accessor for it's container and free that:
62 * @until list_free
63 *
64 * Finally we shut eina down and leave:
65 * @until }
66 *
67 * The full source code can be found on the examples folder
68 * on the @ref eina_accessor_01_c "eina_accessor_01.c" file.
69 */
70
71/**
72 * @page eina_accessor_01_c Eina_Accessor usage example
73 *
74 * @include eina_accessor_01.c
75 * @example eina_accessor_01.c
76 */
77
78/**
79 * @addtogroup Eina_Accessor_Group Accessor Functions
80 *
81 * @brief These functions manage accessor on containers.
82 *
83 * These functions allow to access elements of a container in a
84 * generic way, without knowing which container is used (a bit like
85 * iterators in the C++ STL). Accessors allows random access (that is, any
86 * element in the container). For sequential access, see
87 * @ref Eina_Iterator_Group.
88 *
89 * An accessor is created from container data types, so no creation
90 * function is available here. An accessor is deleted with
91 * eina_accessor_free(). To get the data of an element at a given
92 * position, use eina_accessor_data_get(). To call a function on
93 * chosen elements of a container, use eina_accessor_over().
94 *
95 * See an example @ref eina_accessor_example_01_page "here".
96 */
97
98/**
99 * @addtogroup Eina_Content_Access_Group Content Access
100 *
101 * @{
102 */
103
104/**
105 * @defgroup Eina_Accessor_Group Accessor Functions
106 *
107 * @{
108 */
109
110/**
111 * @typedef Eina_Accessor
112 * Abstract type for accessors.
113 */
114typedef struct _Eina_Accessor Eina_Accessor;
115
116/**
117 * @typedef Eina_Accessor_Get_At_Callback
118 * Type for a callback that returns the data of a container as the given index.
119 */
120typedef Eina_Bool (*Eina_Accessor_Get_At_Callback)(Eina_Accessor *it,
121 unsigned int idx,
122 void **data);
123
124/**
125 * @typedef Eina_Accessor_Get_Container_Callback
126 * Type for a callback that returns the container.
127 */
128typedef void *(*Eina_Accessor_Get_Container_Callback)(Eina_Accessor *it);
129
130/**
131 * @typedef Eina_Accessor_Free_Callback
132 * Type for a callback that frees the container.
133 */
134typedef void (*Eina_Accessor_Free_Callback)(Eina_Accessor *it);
135
136/**
137 * @typedef Eina_Accessor_Lock_Callback
138 * Type for a callback that lock the container.
139 */
140typedef Eina_Bool (*Eina_Accessor_Lock_Callback)(Eina_Accessor *it);
141
142/**
143 * @struct _Eina_Accessor
144 * Type to provide random access to data structures.
145 */
146struct _Eina_Accessor
147{
148#define EINA_ACCESSOR_VERSION 1
149 int version; /**< Version of the Accessor API. */
150
151 Eina_Accessor_Get_At_Callback get_at EINA_ARG_NONNULL(1, 3) EINA_WARN_UNUSED_RESULT; /**< Callback called when a data element is requested. */
152 Eina_Accessor_Get_Container_Callback get_container EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT; /**< Callback called when the container is requested. */
153 Eina_Accessor_Free_Callback free EINA_ARG_NONNULL(1); /**< Callback called when the container is freed. */
154
155 Eina_Accessor_Lock_Callback lock EINA_WARN_UNUSED_RESULT; /**< Callback called when the container is locked. */
156 Eina_Accessor_Lock_Callback unlock EINA_WARN_UNUSED_RESULT; /**< Callback called when the container is unlocked. */
157
158#define EINA_MAGIC_ACCESSOR 0x98761232
159 EINA_MAGIC
160};
161
162/**
163 * @def FUNC_ACCESSOR_GET_AT(Function)
164 * Helper macro to cast @p Function to a Eina_Accessor_Get_At_Callback.
165 */
166#define FUNC_ACCESSOR_GET_AT(Function) ((Eina_Accessor_Get_At_Callback)Function)
167
168/**
169 * @def FUNC_ACCESSOR_GET_CONTAINER(Function)
170 * Helper macro to cast @p Function to a Eina_Accessor_Get_Container_Callback.
171 */
172#define FUNC_ACCESSOR_GET_CONTAINER(Function) ((Eina_Accessor_Get_Container_Callback)Function)
173
174/**
175 * @def FUNC_ACCESSOR_FREE(Function)
176 * Helper macro to cast @p Function to a Eina_Accessor_Free_Callback.
177 */
178#define FUNC_ACCESSOR_FREE(Function) ((Eina_Accessor_Free_Callback)Function)
179
180/**
181 * @def FUNC_ACCESSOR_LOCK(Function)
182 * Helper macro to cast @p Function to a Eina_Iterator_Lock_Callback.
183 */
184#define FUNC_ACCESSOR_LOCK(Function) ((Eina_Accessor_Lock_Callback)Function)
185
186
187/**
188 * @brief Free an accessor.
189 *
190 * @param accessor The accessor to free.
191 *
192 * This function frees @p accessor if it is not @c NULL;
193 */
194EAPI void eina_accessor_free(Eina_Accessor *accessor) EINA_ARG_NONNULL(1);
195
196/**
197 * @brief Retrieve the data of an accessor at a given position.
198 *
199 * @param accessor The accessor.
200 * @param position The position of the element.
201 * @param data The pointer that stores the data to retrieve.
202 * @return #EINA_TRUE on success, #EINA_FALSE otherwise.
203 *
204 * This function retrieves the data of the element pointed by
205 * @p accessor at the porition @p position, and stores it in
206 * @p data. If @p accessor is @c NULL or if an error occurred,
207 * #EINA_FALSE is returned, otherwise EINA_TRUE is returned.
208 */
209EAPI Eina_Bool eina_accessor_data_get(Eina_Accessor *accessor,
210 unsigned int position,
211 void **data) EINA_ARG_NONNULL(1);
212
213/**
214 * @brief Return the container of an accessor.
215 *
216 * @param accessor The accessor.
217 * @return The container which created the accessor.
218 *
219 * This function returns the container which created @p accessor. If
220 * @p accessor is @c NULL, this function returns @c NULL.
221 */
222EAPI void *eina_accessor_container_get(Eina_Accessor *accessor) EINA_ARG_NONNULL(1) EINA_PURE;
223
224/**
225 * @brief Iterate over the container and execute a callback on chosen elements.
226 *
227 * @param accessor The accessor.
228 * @param cb The callback called on the chosen elements.
229 * @param start The position of the first element.
230 * @param end The position of the last element.
231 * @param fdata The data passed to the callback.
232 *
233 * This function iterates over the elements pointed by @p accessor,
234 * starting from the element at position @p start and ending to the
235 * element at position @p end. For Each element, the callback
236 * @p cb is called with the data @p fdata. If @p accessor is @c NULL
237 * or if @p start is greter or equal than @p end, the function returns
238 * immediately.
239 */
240EAPI void eina_accessor_over(Eina_Accessor *accessor,
241 Eina_Each_Cb cb,
242 unsigned int start,
243 unsigned int end,
244 const void *fdata) EINA_ARG_NONNULL(1, 2);
245
246/**
247 * @brief Lock the container of the accessor.
248 *
249 * @param accessor The accessor.
250 * @return #EINA_TRUE on success, #EINA_FALSE otherwise.
251 *
252 * If the container of the @p accessor permits it, it will be locked. When a
253 * container is locked calling eina_accessor_over() on it will return
254 * immediately. If @p accessor is @c NULL or if a problem occurred, #EINA_FALSE
255 * is returned, otherwise #EINA_TRUE is returned. If the container isn't
256 * lockable, it will return EINA_TRUE.
257 *
258 * @warning None of the existing eina data structures are lockable.
259 */
260EAPI Eina_Bool eina_accessor_lock(Eina_Accessor *accessor) EINA_ARG_NONNULL(1);
261
262/**
263 * @brief Unlock the container of the accessor.
264 *
265 * @param accessor The accessor.
266 * @return #EINA_TRUE on success, #EINA_FALSE otherwise.
267 *
268 * If the container of the @p accessor permits it and was previously
269 * locked, it will be unlocked. If @p accessor is @c NULL or if a
270 * problem occurred, #EINA_FALSE is returned, otherwise #EINA_TRUE
271 * is returned. If the container is not lockable, it will return
272 * EINA_TRUE.
273 *
274 * @warning None of the existing eina data structures are lockable.
275 */
276EAPI Eina_Bool eina_accessor_unlock(Eina_Accessor *accessor) EINA_ARG_NONNULL(1);
277
278/**
279 * @def EINA_ACCESSOR_FOREACH
280 * @brief Macro to iterate over all elements easily.
281 *
282 * @param accessor The accessor to use.
283 * @param counter A counter used by eina_accessor_data_get() when
284 * iterating over the container.
285 * @param data Where to store * data, must be a pointer support getting
286 * its address since * eina_accessor_data_get() requires a pointer to
287 * pointer!
288 *
289 * This macro allows a convenient way to loop over all elements in an
290 * accessor, very similar to EINA_LIST_FOREACH().
291 *
292 * This macro can be used for freeing the data of a list, like in the
293 * following example. It has the same goal as the one documented in
294 * EINA_LIST_FOREACH(), but using accessors:
295 *
296 * @code
297 * Eina_List *list;
298 * Eina_Accessor *accessor;
299 * unsigned int i;
300 * char *data;
301 *
302 * // list is already filled,
303 * // its elements are just duplicated strings
304 *
305 * accessor = eina_list_accessor_new(list);
306 * EINA_ACCESSOR_FOREACH(accessor, i, data)
307 * free(data);
308 * eina_accessor_free(accessor);
309 * eina_list_free(list);
310 * @endcode
311 *
312 * @note if the datatype provides both iterators and accessors prefer
313 * to use iterators to iterate over, as they're likely to be more
314 * optimized for such task.
315 *
316 * @note this example is not optimal algorithm to release a list since
317 * it will walk the list twice, but it serves as an example. For
318 * optimized version use EINA_LIST_FREE()
319 *
320 * @warning unless explicitly stated in functions returning accessors,
321 * do not modify the accessed object while you walk it, in this
322 * example using lists, do not remove list nodes or you might
323 * crash! This is not a limitiation of accessors themselves,
324 * rather in the accessors implementations to keep them as simple
325 * and fast as possible.
326 */
327#define EINA_ACCESSOR_FOREACH(accessor, counter, data) \
328 for ((counter) = 0; \
329 eina_accessor_data_get((accessor), (counter), (void **)(void *)&(data)); \
330 (counter)++)
331
332/**
333 * @}
334 */
335
336/**
337 * @}
338 */
339
340#endif
diff --git a/libraries/eina/src/include/eina_array.h b/libraries/eina/src/include/eina_array.h
new file mode 100644
index 0000000..d33f5e9
--- /dev/null
+++ b/libraries/eina/src/include/eina_array.h
@@ -0,0 +1,449 @@
1/* EINA - EFL data type library
2 * Copyright (C) 2008 Cedric Bail
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library;
16 * if not, see <http://www.gnu.org/licenses/>.
17 */
18
19#ifndef EINA_ARRAY_H_
20#define EINA_ARRAY_H_
21
22#include <stdlib.h>
23
24#include "eina_config.h"
25
26#include "eina_types.h"
27#include "eina_error.h"
28#include "eina_iterator.h"
29#include "eina_accessor.h"
30#include "eina_magic.h"
31
32
33/**
34 * @page array_01_example_page Basic array usage
35 * @dontinclude eina_array_01.c
36 *
37 * For this example we add stdlib.h, stdio.h and string.h for some
38 * convenience functions. The first thing to do to be able to use an
39 * @ref Eina_Array is to include Eina.h:
40 * @skip #include
41 * @until Eina.h
42 *
43 * Here we have a callback that prints the element given to it:
44 * @until }
45 *
46 * Now we create our entry point and declare some variables, nothing especial:
47 * @until unsigned
48 *
49 * Before we can start using any array function we need to initialize eina:
50 * @until eina_init
51 *
52 * So now to actually creating our array. The only interesting thing here is the
53 * argument given to the eina_array_new() function, this argument sets how fast
54 * the array grows.
55 * @until array_new
56 *
57 * If you know before hand how big the array will need to be you should set the
58 * step to that. In our case we can set it to the number of string we have and
59 * since we didn't do that in the eina_array_new() we can do it now:
60 * @until array_step_set
61 *
62 * Now let us populate our array with some strings:
63 * @until push
64 * @note Notice we use strdup, so we will have to free that memory later on.
65 *
66 * Now lets check the size of the array:
67 * @until printf
68 *
69 * And now we call a function on every member of our array to print it:
70 * @until foreach
71 *
72 * One of the strenghts of @ref Eina_Array over @ref Eina_List is that it has
73 * very fast random access to elements, so this is very efficient:
74 * @until printf
75 *
76 * And now we free up the memory allocated with the strdup()s:
77 * @until free
78 *
79 * And the array memory itself:
80 * @until array_free
81 *
82 * And finally shutdown eina and exit:
83 * @until }
84 *
85 * The full source code can be found on the examples folder
86 * on the @ref eina_array_01_c "eina_array_01.c" file.
87 */
88
89/**
90 * @page eina_array_01_c Basic array usage example
91 *
92 * @include eina_array_01.c
93 * @example eina_array_01.c
94 */
95
96/**
97 * @page array_02_example_page Removing array elements
98 * @dontinclude eina_array_02.c
99 *
100 * Just the usual includes:
101 * @skip #include
102 * @until Eina.h
103 *
104 * This the callback we are going to use to decide which strings stay on the
105 * array and which will be removed, we use something simple, but this can be as
106 * complex as you like:
107 * @until }
108 *
109 * This is the same code we used before to populate the list with the slight
110 * difference of not using strdup:
111 * @until array_push
112 *
113 * So we have added all our elements to the array, but it turns out that is not
114 * the elements we wanted, so let's empty the array and add the correct strings:
115 * @until array_push
116 *
117 * It seems we made a little mistake in one of our strings so we need to replace
118 * it, here is how:
119 * @until data_set
120 *
121 * Now that there is a populated array we can remove elements from it easily:
122 * @until array_remove
123 *
124 * And check that the elements were actually removed:
125 * @until printf
126 *
127 * Since this time we didn't use strdup we don't need to free each string:
128 * @until }
129 *
130 * The full source code can be found on the examples folder
131 * on the @ref eina_array_02_c "eina_array_02.c" file.
132 */
133
134/**
135 * @page eina_array_02_c Basic array usage example
136 *
137 * @include eina_array_02.c
138 * @example eina_array_02.c
139 */
140
141/**
142 * @addtogroup Eina_Array_Group Array
143 *
144 * @brief These functions provide array management.
145 *
146 * The Array data type in Eina is designed to have very fast access to
147 * its data (compared to the Eina @ref Eina_List_Group). On the other hand,
148 * data can be added or removed only at the end of the array. To insert
149 * data at any place, the Eina @ref Eina_List_Group is the correct container
150 * to use.
151 *
152 * To use the array data type, eina_init() must be called before any
153 * other array functions. When no more eina array functions are used,
154 * eina_shutdown() must be called to free all the resources.
155 *
156 * An array must be created with eina_array_new(). It allocates all
157 * the necessary data for an array. When not needed anymore, an array
158 * is freed with eina_array_free(). This function does not free any
159 * allocated memory used to store the data of each element. For that,
160 * just iterate over the array to free them. A convenient way to do
161 * that is by using #EINA_ARRAY_ITER_NEXT. An example of code is given
162 * in the description of this macro.
163 *
164 * @warning Functions do not check if the used array is valid or not. It's up to
165 * the user to be sure of that. It is designed like that for performance
166 * reasons.
167 *
168 * The usual features of an array are classic ones: to append an
169 * element, use eina_array_push() and to remove the last element, use
170 * eina_array_pop(). To retrieve the element at a given position, use
171 * eina_array_data_get(). The number of elements can be retrieved with
172 * eina_array_count_get().
173 *
174 * Eina_Array is different from a conventional C array in a number of ways, most
175 * importantly they grow and shrink dynamically, this means that if you add an
176 * element to a full array it grows and that when you remove an element from an
177 * array it @b may shrink.
178 *
179 * When the array needs to grow it allocates memory not just for the element
180 * currently being added since that would mean allocating memory(which is
181 * computationally expensive) often, instead it grows to be able to hold @p step
182 * more elements. Similarly if you remove elements in such a way that that the
183 * array is left holding its capacity - @p step elements it will shrink.
184 *
185 * The following image illustrates how an Eina_Array grows:
186 *
187 * @image html eina_array-growth.png
188 * @image latex eina_array-growth.eps width=\textwidth
189 *
190 * Eina_Array only stores pointers but it can store data of any type in the form
191 * of void pointers.
192 *
193 * See here some examples:
194 * @li @ref array_01_example_page
195 * @li @ref array_02_example_page
196 */
197
198/**
199 * @addtogroup Eina_Data_Types_Group Data Types
200 *
201 * @{
202 */
203
204/**
205 * @addtogroup Eina_Containers_Group Containers
206 *
207 * @{
208 */
209
210/**
211 * @defgroup Eina_Array_Group Array
212 *
213 * @{
214 */
215
216/**
217 * @typedef Eina_Array
218 * Type for a generic vector.
219 */
220typedef struct _Eina_Array Eina_Array;
221
222/**
223 * @typedef Eina_Array_Iterator
224 * Type for an iterator on arrays, used with #EINA_ARRAY_ITER_NEXT.
225 */
226typedef void **Eina_Array_Iterator;
227
228/**
229 * @struct _Eina_Array
230 * Type for an array of data.
231 */
232struct _Eina_Array
233{
234#define EINA_ARRAY_VERSION 1
235 int version; /**< Should match EINA_ARRAY_VERSION used when compiled your apps, provided for ABI compatibility */
236
237 void **data; /**< Pointer to a vector of pointer to payload */
238 unsigned int total; /**< Total number of slots in the vector */
239 unsigned int count; /**< Number of active slots in the vector */
240 unsigned int step; /**< How much must we grow the vector when it is full */
241 EINA_MAGIC
242};
243
244
245/**
246 * @brief Create a new array.
247 *
248 * @param step The count of pointers to add when increasing the array size.
249 * @return @c NULL on failure, non @c NULL otherwise.
250 *
251 * This function creates a new array. When adding an element, the array
252 * allocates @p step elements. When that buffer is full, then adding
253 * another element will increase the buffer by @p step elements again.
254 *
255 * This function return a valid array on success, or @c NULL if memory
256 * allocation fails. In that case, the error is set to
257 * #EINA_ERROR_OUT_OF_MEMORY.
258 */
259EAPI Eina_Array *eina_array_new(unsigned int step) EINA_WARN_UNUSED_RESULT EINA_MALLOC EINA_WARN_UNUSED_RESULT;
260
261/**
262 * @brief Free an array.
263 *
264 * @param array The array to free.
265 *
266 * This function frees @p array. It calls first eina_array_flush() then
267 * free the memory of the pointer. It does not free the memory
268 * allocated for the elements of @p array. To free them, use
269 * #EINA_ARRAY_ITER_NEXT. For performance reasons, there is no check
270 * of @p array.
271 */
272EAPI void eina_array_free(Eina_Array *array) EINA_ARG_NONNULL(1);
273
274/**
275 * @brief Set the step of an array.
276 *
277 * @param array The array.
278 * @param sizeof_eina_array Should be the value returned by sizeof(Eina_Array).
279 * @param step The count of pointers to add when increasing the array size.
280 *
281 * This function sets the step of @p array to @p step. For performance
282 * reasons, there is no check of @p array. If it is @c NULL or
283 * invalid, the program may crash.
284 *
285 * @warning This function can @b only be called on uninitialized arrays.
286 */
287EAPI void eina_array_step_set(Eina_Array *array,
288 unsigned int sizeof_eina_array,
289 unsigned int step) EINA_ARG_NONNULL(1);
290/**
291 * @brief Clean an array.
292 *
293 * @param array The array to clean.
294 *
295 * This function sets the count member of @p array to 0, however it doesn't free
296 * any space. This is particularly useful if you need to empty the array and
297 * add lots of elements quickly. For performance reasons, there is no check of
298 * @p array. If it is @c NULL or invalid, the program may crash.
299 */
300static inline void eina_array_clean(Eina_Array *array) EINA_ARG_NONNULL(1);
301
302/**
303 * @brief Flush an array.
304 *
305 * @param array The array to flush.
306 *
307 * This function sets the count and total members of @p array to 0,
308 * frees and set to NULL its data member. For performance reasons,
309 * there is no check of @p array. If it is @c NULL or invalid, the
310 * program may crash.
311 */
312EAPI void eina_array_flush(Eina_Array *array) EINA_ARG_NONNULL(1);
313
314/**
315 * @brief Rebuild an array by specifying the data to keep.
316 *
317 * @param array The array.
318 * @param keep The functions which selects the data to keep.
319 * @param gdata The data to pass to the function keep.
320 * @return #EINA_TRUE on success, #EINA_FALSE oterwise.
321 *
322 * This function rebuilds @p array be specifying the elements to keep with the
323 * function @p keep. No empty/invalid fields are left in the array. @p gdata is
324 * an additional data to pass to @p keep. For performance reasons, there is no
325 * check of @p array. If it is @c NULL or invalid, the program may crash.
326 *
327 * If it wasn't able to remove items due to an allocation failure, it will
328 * return #EINA_FALSE and the error is set to #EINA_ERROR_OUT_OF_MEMORY.
329 */
330EAPI Eina_Bool eina_array_remove(Eina_Array * array,
331 Eina_Bool (*keep)(void *data, void *gdata),
332 void *gdata) EINA_ARG_NONNULL(1, 2);
333static inline Eina_Bool eina_array_push(Eina_Array *array,
334 const void *data) EINA_ARG_NONNULL(1, 2);
335static inline void *eina_array_pop(Eina_Array *array) EINA_ARG_NONNULL(1);
336static inline void *eina_array_data_get(const Eina_Array *array,
337 unsigned int idx) EINA_ARG_NONNULL(1);
338/**
339 * @brief Set the data at a given position in an array.
340 *
341 * @param array The array.
342 * @param idx The potition of the data to set.
343 * @param data The data to set.
344 *
345 * This function sets the data at the position @p idx in @p
346 * array to @p data, this effectively replaces the previously held data, you
347 * must therefore get a pointer to it first if you need to free it. For
348 * performance reasons, there is no check of @p array or @p idx. If it is @c
349 * NULL or invalid, the program may crash.
350*/
351static inline void eina_array_data_set(const Eina_Array *array,
352 unsigned int idx,
353 const void *data) EINA_ARG_NONNULL(1);
354static inline unsigned int eina_array_count_get(const Eina_Array *array) EINA_ARG_NONNULL(1);
355
356/**
357 * @brief Returned a new iterator associated to an array.
358 *
359 * @param array The array.
360 * @return A new iterator.
361 *
362 * This function returns a newly allocated iterator associated to
363 * @p array. If @p array is @c NULL or the count member of @p array is
364 * less or equal than 0, this function returns NULL. If the memory can
365 * not be allocated, NULL is returned and #EINA_ERROR_OUT_OF_MEMORY is
366 * set. Otherwise, a valid iterator is returned.
367 */
368EAPI Eina_Iterator *eina_array_iterator_new(const Eina_Array *array) EINA_MALLOC EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT;
369
370/**
371 * @brief Returned a new accessor associated to an array.
372 *
373 * @param array The array.
374 * @return A new accessor.
375 *
376 * This function returns a newly allocated accessor associated to
377 * @p array. If @p array is @c NULL or the count member of @p array is
378 * less or equal than 0, this function returns NULL. If the memory can
379 * not be allocated, NULL is returned and #EINA_ERROR_OUT_OF_MEMORY is
380 * set. Otherwise, a valid accessor is returned.
381 */
382EAPI Eina_Accessor *eina_array_accessor_new(const Eina_Array *array) EINA_MALLOC EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT;
383/**
384 * @brief Provide a safe way to iterate over an array
385 *
386 * @param array The array to iterate over.
387 * @param cb The callback to call for each item.
388 * @param fdata The user data to pass to the callback.
389 * @return EINA_TRUE if it successfully iterate all items of the array.
390 *
391 * This function provide a safe way to iterate over an array. @p cb should
392 * return EINA_TRUE as long as you want the function to continue iterating,
393 * by returning EINA_FALSE it will stop and return EINA_FALSE as a result.
394 */
395static inline Eina_Bool eina_array_foreach(Eina_Array *array,
396 Eina_Each_Cb cb,
397 void *data);
398/**
399 * @def EINA_ARRAY_ITER_NEXT
400 * @brief Macro to iterate over an array easily.
401 *
402 * @param array The array to iterate over.
403 * @param index The integer number that is increased while itareting.
404 * @param item The data
405 * @param iterator The iterator
406 *
407 * This macro allows the iteration over @p array in an easy way. It
408 * iterates from the first element to the last one. @p index is an
409 * integer that increases from 0 to the number of elements. @p item is
410 * the data of each element of @p array, so it is a pointer to a type
411 * chosen by the user. @p iterator is of type #Eina_Array_Iterator.
412 *
413 * This macro can be used for freeing the data of an array, like in
414 * the following example:
415 *
416 * @code
417 * Eina_Array *array;
418 * char *item;
419 * Eina_Array_Iterator iterator;
420 * unsigned int i;
421 *
422 * // array is already filled,
423 * // its elements are just duplicated strings,
424 * // EINA_ARRAY_ITER_NEXT will be used to free those strings
425 *
426 * EINA_ARRAY_ITER_NEXT(array, i, item, iterator)
427 * free(item);
428 * @endcode
429 */
430#define EINA_ARRAY_ITER_NEXT(array, index, item, iterator) \
431 for (index = 0, iterator = (array)->data; \
432 (index < eina_array_count_get(array)) && ((item = *((iterator)++))); \
433 ++(index))
434
435#include "eina_inline_array.x"
436
437/**
438 * @}
439 */
440
441/**
442 * @}
443 */
444
445/**
446 * @}
447 */
448
449#endif
diff --git a/libraries/eina/src/include/eina_benchmark.h b/libraries/eina/src/include/eina_benchmark.h
new file mode 100644
index 0000000..721e1c0
--- /dev/null
+++ b/libraries/eina/src/include/eina_benchmark.h
@@ -0,0 +1,453 @@
1/* EINA - EFL data type library
2 * Copyright (C) 2008 Cedric Bail
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library;
16 * if not, see <http://www.gnu.org/licenses/>.
17 */
18
19#ifndef EINA_BENCHMARK_H_
20#define EINA_BENCHMARK_H_
21
22#include "eina_array.h"
23
24
25
26/**
27 * @page tutorial_benchmark_page Benchmark Tutorial
28 *
29 * The Benchmark module allows you to write easily benchmarks
30 * framework in a project for timing critical part and detect slow
31 * parts of code. In addition it automatically creates data files of
32 * these benchmark, as well as a gnuplot file which can display the
33 * comparison curves of the benchmarks.
34 *
35 * @section tutorial_benchmark_basic_usage Basic Usage
36 *
37 * To create a basic benchmark, you have to follow these steps:
38 *
39 * @li Create a new bechmark
40 * @li Write the functions that wraps the the functions you want to
41 * bechmark.
42 * @li Register these wrappers functions.
43 * @li Run the benchmark.
44 * @li Free the memory.
45 *
46 * Here is a basic example of bechmark which creates two functions
47 * that will be run. These functions just print a message.
48 *
49 * @code
50 * #include <stdlib.h>
51 * #include <stdio.h>
52 *
53 * #include <Eina.h>
54 *
55 * static
56 * void work1(int request)
57 * {
58 * printf ("work1 in progress... Request: %d\n", request);
59 * }
60 *
61 * static
62 * void work2(int request)
63 * {
64 * printf ("work2 in progress... Request: %d\n", request);
65 * }
66 *
67 * int main()
68 * {
69 * Eina_Benchmark *test;
70 * Eina_Array *ea;
71 *
72 * if (!eina_init())
73 * return EXIT_FAILURE;
74 *
75 * test = eina_benchmark_new("test", "run");
76 * if (!test)
77 * goto shutdown_eina;
78 *
79 * eina_benchmark_register(test, "work-1", EINA_BENCHMARK(work1), 200, 300, 10);
80 * eina_benchmark_register(test, "work-2", EINA_BENCHMARK(work2), 100, 150, 5);
81 *
82 * ea = eina_benchmark_run(test);
83 *
84 * eina_benchmark_free(test);
85 * eina_shutdown();
86 *
87 * return EXIT_SUCCESS;
88 *
89 * shutdown_eina:
90 * eina_shutdown();
91 *
92 * return EXIT_FAILURE;
93 * }
94 * @endcode
95 *
96 * As "test", "run" are passed to eina_benchmark_new() and as the tests
97 * "work-1" and "work-2" are registered, the data files
98 * bench_test_run.work-1.data and bench_test_run.work-2.data will be
99 * created after the eina_benchmark_run() call. They contain four
100 * columns. The file bench_test_run.work-1.data contains for example:
101 *
102 * @code
103 * # specimen experiment time starting time ending time
104 * 200 23632 2852446 2876078
105 * 210 6924 2883046 2889970
106 * 220 6467 2895962 2902429
107 * 230 6508 2908271 2914779
108 * 240 6278 2920610 2926888
109 * 250 6342 2932830 2939172
110 * 260 6252 2944954 2951206
111 * 270 6463 2956978 2963441
112 * 280 6347 2969548 2975895
113 * 290 6457 2981702 2988159
114 * @endcode
115 *
116 * The first column (specimen) is the integer passed to the work1()
117 * function when the test is run. The second column (experiment time)
118 * is the time, in nanosecond, that work1() takes. The third and
119 * fourth columnd are self-explicit.
120 *
121 * You can see that the integer passed work1() starts from 200 and
122 * finishes at 290, with a step of 10. These values are computed withe
123 * last 3 values passed to eina_benchmark_register(). See the document
124 * of that function for the detailed behavior.
125 *
126 * The gnuplot file will be named bench_test_run.gnuplot. Just run:
127 *
128 * @code
129 * gnuplot bench_test_run.gnuplot
130 * @endcode
131 *
132 * to create the graphic of the comparison curves. The image file is
133 * named output_test_run.png.
134 *
135 * @section tutorial_benchmark_advanced_usage More Advanced Usage
136 *
137 * In this section, several test will be created and run. The idea is
138 * exactly the same than in the previous section, but with some basic
139 * automatic way to run all the benchmarks. The following code
140 * benchmarks some Eina converts functions, and some Eina containers
141 * types:
142 *
143 * @code
144 * #include <stdlib.h>
145 * #include <stdio.h>
146 * #include <time.h>
147 *
148 * #include <Eina.h>
149 *
150 * static void bench_convert(Eina_Benchmark *bench);
151 * static void bench_container(Eina_Benchmark *bench);
152 *
153 * typedef struct _Benchmark_Case Benchmark_Case;
154 *
155 * struct _Benchmark_Case
156 * {
157 * const char *bench_case;
158 * void (*build)(Eina_Benchmark *bench);
159 * };
160 *
161 * static const Benchmark_Case benchmarks[] = {
162 * { "Bench 1", bench_convert },
163 * { "Bench 2", bench_container },
164 * { NULL, NULL }
165 * };
166 *
167 * static
168 * void convert1(int request)
169 * {
170 * char tmp[128];
171 * int i;
172 *
173 * srand(time(NULL));
174 *
175 * for (i = 0; i < request; ++i)
176 * eina_convert_itoa(rand(), tmp);
177 * }
178 *
179 * static
180 * void convert2(int request)
181 * {
182 * char tmp[128];
183 * int i;
184 *
185 * srand(time(NULL));
186 *
187 * for (i = 0; i < request; ++i)
188 * eina_convert_xtoa(rand(), tmp);
189 * }
190 *
191 * static void
192 * bench_convert(Eina_Benchmark *bench)
193 * {
194 * eina_benchmark_register(bench, "convert-1", EINA_BENCHMARK(convert1), 200, 400, 10);
195 * eina_benchmark_register(bench, "convert-2", EINA_BENCHMARK(convert2), 200, 400, 10);
196 * }
197 *
198 * static
199 * void array(int request)
200 * {
201 * Eina_Array *array;
202 * Eina_Array_Iterator it;
203 * int *data;
204 * int i;
205 *
206 * srand(time(NULL));
207 *
208 * array = eina_array_new(64);
209 *
210 * for (i = 0; i < request; ++i)
211 * {
212 * data = (int *)malloc(sizeof(int));
213 * if (!data) continue;
214 * *data = rand();
215 * eina_array_push(array, data);
216 * }
217 *
218 * EINA_ARRAY_ITER_NEXT(array, i, data, it)
219 * free(data);
220 *
221 * eina_array_free(array);
222 * }
223 *
224 * static
225 * void list(int request)
226 * {
227 * Eina_List *l = NULL;
228 * int *data;
229 * int i;
230 *
231 * srand(time(NULL));
232 *
233 * for (i = 0; i < request; ++i)
234 * {
235 * data = (int *)malloc(sizeof(int));
236 * if (!data) continue;
237 * *data = rand();
238 * l = eina_list_prepend(l, data);
239 * }
240 *
241 * while (l)
242 * {
243 * free(eina_list_data_get(l));
244 * l = eina_list_remove_list(l, l);
245 * }
246 * }
247 *
248 * static void
249 * bench_container(Eina_Benchmark *bench)
250 * {
251 * eina_benchmark_register(bench, "array", EINA_BENCHMARK(array), 200, 300, 10);
252 * eina_benchmark_register(bench, "list", EINA_BENCHMARK(list), 200, 300, 10);
253 * }
254 *
255 * int main()
256 * {
257 * Eina_Benchmark *test;
258 * Eina_Array *ea;
259 * unsigned int i;
260 *
261 * if (!eina_init())
262 * return EXIT_FAILURE;
263 *
264 * for (i = 0; benchmarks[i].bench_case != NULL; ++i)
265 * {
266 * test = eina_benchmark_new(benchmarks[i].bench_case, "Benchmark example");
267 * if (!test)
268 * continue;
269 *
270 * benchmarks[i].build(test);
271 *
272 * ea = eina_benchmark_run(test);
273 *
274 * eina_benchmark_free(test);
275 * }
276 *
277 * eina_shutdown();
278 *
279 * return EXIT_SUCCESS;
280 * }
281 * @endcode
282 *
283 * gnuplot can be used to see how are performed the convert functions
284 * together, as well as how are performed the containers. So it is now
285 * easy to see that the hexadecimal convert function is faster than
286 * the decimal one, and that arrays are faster than lists.
287 *
288 * You can improve all that by executing automatically gnuplot in your
289 * program, or integrate the Eina benchmark framework in an autotooled
290 * project. See that
291 * <a href="http://trac.enlightenment.org/e/wiki/AutotoolsIntegration#Benchmark">page</a>
292 * for more informations.
293 *
294 */
295
296
297/**
298 * @addtogroup Eina_Benchmark_Group Benchmark
299 *
300 * These functions allow you to add benchmark framework in a project
301 * for timing critical part and detect slow parts of code. It is used
302 * in Eina to compare the time used by eina, glib, evas and ecore data
303 * types.
304 *
305 * To use the benchmark module, Eina must be initialized with
306 * eina_init() and later shut down with eina_shutdown(). A benchmark
307 * is created with eina_benchmark_new() and freed with
308 * eina_benchmark_free().
309 *
310 * eina_benchmark_register() adds a test to a benchmark. That test can
311 * be run a certain amount of times. Adding more than one test to be
312 * executed allows the comparison between several parts of a program,
313 * or different implementations.
314 *
315 * eina_benchmark_run() runs all the tests registered with
316 * eina_benchmark_register(). The amount of time of each test is
317 * written in a gnuplot file.
318 *
319 * For more information, you can look at the @ref tutorial_benchmark_page.
320 */
321
322/**
323 * @addtogroup Eina_Tools_Group Tools
324 *
325 * @{
326 */
327
328/**
329 * @defgroup Eina_Benchmark_Group Benchmark
330 *
331 * @{
332 */
333
334/**
335 * @typedef Eina_Benchmark
336 * Type for a benchmark.
337 */
338typedef struct _Eina_Benchmark Eina_Benchmark;
339
340/**
341 * @typedef Eina_Benchmark_Specimens
342 * Type for a test function to be called when running a benchmark.
343 */
344typedef void (*Eina_Benchmark_Specimens)(int request);
345
346/**
347 * @def EINA_BENCHMARK
348 * @brief cast to an #Eina_Benchmark_Specimens.
349 *
350 * @param function The function to cast.
351 *
352 * This macro casts @p function to Eina_Benchmark_Specimens.
353 */
354#define EINA_BENCHMARK(function) ((Eina_Benchmark_Specimens)function)
355
356
357/**
358 * @brief Create a new array.
359 *
360 * @param name The name of the benchmark.
361 * @param run The name of the run.
362 * @return @c NULL on failure, non @c NULL otherwise.
363 *
364 * This function creates a new benchmark. @p name and @p run are used
365 * to name the gnuplot file that eina_benchmark_run() will create.
366 *
367 * This function return a valid benchmark on success, or @c NULL if
368 * memory allocation fails. In that case, the error is set to
369 * #EINA_ERROR_OUT_OF_MEMORY.
370 *
371 * When the new module is not needed anymore, use
372 * eina_benchmark_free() to free the allocated memory.
373 */
374EAPI Eina_Benchmark *eina_benchmark_new(const char *name,
375 const char *run);
376
377/**
378 * @brief Free a benchmark object.
379 *
380 * @param bench The benchmark to free.
381 *
382 * This function removes all the benchmark tests that have been
383 * registered and frees @p bench. If @p bench is @c NULL, this
384 * function returns immediately.
385 */
386EAPI void eina_benchmark_free(Eina_Benchmark *bench);
387
388/**
389 * @brief Add a test to a benchmark.
390 *
391 * @param bench The benchmark.
392 * @param name The name of the test.
393 * @param bench_cb The test function to be called.
394 * @param count_start The start data to be passed to @p bench_cb.
395 * @param count_end The end data to be passed to @p bench_cb.
396 * @param count_step The step data to be passed to @p bench_cb.
397 * @return #EINA_FALSE on failure, #EINA_TRUE otherwise.
398 *
399 * This function adds the test named @p name to @p benchmark. @p
400 * bench_cb is the function called when the test is executed. That
401 * test can be executed a certain amount of time. @p start, @p end and
402 * @p step define a loop with a step increment. The integer that is
403 * increasing by @p step from @p start to @p end is passed to @p
404 * bench_cb when eina_benchmark_run() is called.
405 *
406 * If @p bench is @c NULL, this function returns imediatly. If the
407 * allocation of the memory of the test to add fails, the error is set
408 * to #EINA_ERROR_OUT_OF_MEMORY. This function returns #EINA_FALSE
409 * on failure, #EINA_TRUE otherwise.
410 */
411EAPI Eina_Bool eina_benchmark_register(Eina_Benchmark *bench,
412 const char *name,
413 Eina_Benchmark_Specimens bench_cb,
414 int count_start,
415 int count_end,
416 int count_set);
417
418/**
419 * @brief Run the benchmark tests that have been registered.
420 *
421 * @param bench The benchmark.
422 * @return The list of names of the test files.
423 *
424 * This function runs all the tests that as been registered with
425 * eina_benchmark_register() and save the result in a gnuplot
426 * file. The name of the file has the following format:
427 *
428 * @code
429 * bench_[name]_[run]%s.gnuplot
430 * @endcode
431 *
432 * where [name] and [run] are the values passed to
433 * eina_benchmark_new().
434 *
435 * Each registered test is executed and timed. The time is written to
436 * the gnuplot file. The number of times each test is executed is
437 * controlled by the parameters passed to eina_benchmark_register().
438 *
439 * If @p bench is @c NULL, this functions returns @c NULL
440 * immediately. Otherwise, it returns the list of the names of each
441 * test.
442 */
443EAPI Eina_Array *eina_benchmark_run(Eina_Benchmark *bench);
444
445/**
446 * @}
447 */
448
449/**
450 * @}
451 */
452
453#endif /* EINA_BENCHMARK_H_ */
diff --git a/libraries/eina/src/include/eina_binbuf.h b/libraries/eina/src/include/eina_binbuf.h
new file mode 100644
index 0000000..92f788e
--- /dev/null
+++ b/libraries/eina/src/include/eina_binbuf.h
@@ -0,0 +1,217 @@
1#ifndef EINA_BINBUF_H
2#define EINA_BINBUF_H
3
4#include <stddef.h>
5#include <stdarg.h>
6
7#include "eina_types.h"
8
9/**
10 * @addtogroup Eina_Binary_Buffer_Group Binary Buffer
11 *
12 * @brief These functions provide string buffers management.
13 *
14 * The Binary Buffer data type is designed to be a mutable string,
15 * allowing to append, prepend or insert a string to a buffer.
16 */
17
18/**
19 * @addtogroup Eina_Data_Types_Group Data Types
20 *
21 * @{
22 */
23
24/**
25 * @defgroup Eina_Binary_Buffer_Group Binary Buffer
26 *
27 * @{
28 */
29
30/**
31 * @typedef Eina_Binbuf
32 * Type for a string buffer.
33 */
34typedef struct _Eina_Strbuf Eina_Binbuf;
35
36/**
37 * @brief Create a new string buffer.
38 *
39 * @return Newly allocated string buffer instance.
40 *
41 * This function creates a new string buffer. On error, @c NULL is
42 * returned and Eina error is set to #EINA_ERROR_OUT_OF_MEMORY. To
43 * free the resources, use eina_binbuf_free().
44 *
45 * @see eina_binbuf_free()
46 * @see eina_binbuf_append()
47 * @see eina_binbuf_string_get()
48 */
49EAPI Eina_Binbuf *eina_binbuf_new(void) EINA_MALLOC EINA_WARN_UNUSED_RESULT;
50
51/**
52 * @brief Free a string buffer.
53 *
54 * @param buf The string buffer to free.
55 *
56 * This function frees the memory of @p buf. @p buf must have been
57 * created by eina_binbuf_new().
58 */
59EAPI void eina_binbuf_free(Eina_Binbuf *buf) EINA_ARG_NONNULL(1);
60
61/**
62 * @brief Reset a string buffer.
63 *
64 * @param buf The string buffer to reset.
65 *
66 * This function reset @p buf: the buffer len is set to 0, and the
67 * string is set to '\\0'. No memory is free'd.
68 */
69EAPI void eina_binbuf_reset(Eina_Binbuf *buf) EINA_ARG_NONNULL(1);
70
71/**
72 * @brief Append a string of exact length to a buffer, reallocating as necessary.
73 *
74 * @param buf The string buffer to append to.
75 * @param str The string to append.
76 * @param length The exact length to use.
77 * @return #EINA_TRUE on success, #EINA_FALSE on failure.
78 *
79 * This function appends @p str to @p buf. @p str must be of size at
80 * most @p length. It is slightly faster than eina_binbuf_append() as
81 * it does not compute the size of @p str. It is useful when dealing
82 * with strings of known size, such as eina_strngshare. If @p buf
83 * can't append it, #EINA_FALSE is returned, otherwise #EINA_TRUE is
84 * returned.
85 *
86 * @see eina_stringshare_length()
87 * @see eina_binbuf_append()
88 * @see eina_binbuf_append_n()
89 */
90EAPI Eina_Bool eina_binbuf_append_length(Eina_Binbuf *buf, const unsigned char *str, size_t length) EINA_ARG_NONNULL(1, 2);
91
92/**
93 * @brief Append a character to a string buffer, reallocating as
94 * necessary.
95 *
96 * @param buf The string buffer to append to.
97 * @param c The char to append.
98 * @return #EINA_TRUE on success, #EINA_FALSE on failure.
99 *
100 * This function inserts @p c to @p buf. If it can not insert it,
101 * #EINA_FALSE is returned, otherwise #EINA_TRUE is returned.
102 */
103EAPI Eina_Bool eina_binbuf_append_char(Eina_Binbuf *buf, unsigned char c) EINA_ARG_NONNULL(1);
104
105/**
106 * @brief Insert a string of exact length to a buffer, reallocating as necessary.
107 *
108 * @param buf The string buffer to insert to.
109 * @param str The string to insert.
110 * @param length The exact length to use.
111 * @param pos The position to insert the string.
112 * @return #EINA_TRUE on success, #EINA_FALSE on failure.
113 *
114 * This function inserts @p str to @p buf. @p str must be of size at
115 * most @p length. It is slightly faster than eina_binbuf_insert() as
116 * it does not compute the size of @p str. It is useful when dealing
117 * with strings of known size, such as eina_strngshare. If @p buf
118 * can't insert it, #EINA_FALSE is returned, otherwise #EINA_TRUE is
119 * returned.
120 *
121 * @see eina_stringshare_length()
122 * @see eina_binbuf_insert()
123 * @see eina_binbuf_insert_n()
124 */
125EAPI Eina_Bool eina_binbuf_insert_length(Eina_Binbuf *buf, const unsigned char *str, size_t length, size_t pos) EINA_ARG_NONNULL(1, 2);
126
127/**
128 * @brief Insert a character to a string buffer, reallocating as
129 * necessary.
130 *
131 * @param buf The string buffer to insert to.
132 * @param c The char to insert.
133 * @param pos The position to insert the char.
134 * @return #EINA_TRUE on success, #EINA_FALSE on failure.
135 *
136 * This function inserts @p c to @p buf at position @p pos. If @p buf
137 * can't append it, #EINA_FALSE is returned, otherwise #EINA_TRUE is
138 * returned.
139 */
140EAPI Eina_Bool eina_binbuf_insert_char(Eina_Binbuf *buf, unsigned char c, size_t pos) EINA_ARG_NONNULL(1);
141
142/**
143 * @brief Remove a slice of the given string buffer.
144 *
145 * @param buf The string buffer to remove a slice.
146 * @param start The initial (inclusive) slice position to start
147 * removing, in bytes.
148 * @param end The final (non-inclusive) slice position to finish
149 * removing, in bytes.
150 * @return #EINA_TRUE on success, #EINA_FALSE on failure.
151 *
152 * This function removes a slice of @p buf, starting at @p start
153 * (inclusive) and ending at @p end (non-inclusive). Both values are
154 * in bytes. It returns #EINA_FALSE on failure, #EINA_TRUE otherwise.
155 */
156
157EAPI Eina_Bool eina_binbuf_remove(Eina_Binbuf *buf, size_t start, size_t end) EINA_ARG_NONNULL(1);
158
159/**
160 * @brief Retrieve a pointer to the contents of a string buffer
161 *
162 * @param buf The string buffer.
163 * @return The current string in the string buffer.
164 *
165 * This function returns the string contained in @p buf. The returned
166 * value must not be modified and will no longer be valid if @p buf is
167 * modified. In other words, any eina_binbuf_append() or similar will
168 * make that pointer invalid.
169 *
170 * @see eina_binbuf_string_steal()
171 */
172EAPI const unsigned char *eina_binbuf_string_get(const Eina_Binbuf *buf) EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT;
173
174/**
175 * @brief Steal the contents of a string buffer.
176 *
177 * @param buf The string buffer to steal.
178 * @return The current string in the string buffer.
179 *
180 * This function returns the string contained in @p buf. @p buf is
181 * then initialized and does not own the returned string anymore. The
182 * caller must release the memory of the returned string by calling
183 * free().
184 *
185 * @see eina_binbuf_string_get()
186 */
187EAPI unsigned char *eina_binbuf_string_steal(Eina_Binbuf *buf) EINA_MALLOC EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1);
188
189/**
190 * @brief Free the contents of a string buffer but not the buffer.
191 *
192 * @param buf The string buffer to free the string of.
193 *
194 * This function frees the string contained in @p buf without freeing
195 * @p buf.
196 */
197EAPI void eina_binbuf_string_free(Eina_Binbuf *buf) EINA_ARG_NONNULL(1);
198
199/**
200 * @brief Retrieve the length of the string buffer content.
201 *
202 * @param buf The string buffer.
203 * @return The current length of the string, in bytes.
204 *
205 * This function returns the length of @p buf.
206 */
207EAPI size_t eina_binbuf_length_get(const Eina_Binbuf *buf) EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT;
208
209/**
210 * @}
211 */
212
213/**
214 * @}
215 */
216
217#endif /* EINA_STRBUF_H */
diff --git a/libraries/eina/src/include/eina_binshare.h b/libraries/eina/src/include/eina_binshare.h
new file mode 100644
index 0000000..55b17a6
--- /dev/null
+++ b/libraries/eina/src/include/eina_binshare.h
@@ -0,0 +1,193 @@
1/* EINA - EFL data type library
2 * Copyright (C) 2002-2008 Carsten Haitzler, Jorge Luis Zapata Muga, Cedric Bail
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library;
16 * if not, see <http://www.gnu.org/licenses/>.
17 *
18 * This file incorporates work covered by the following copyright and
19 * permission notice:
20 *
21 * Copyright (C) 2008 Peter Wehrfritz
22 *
23 * Permission is hereby granted, free of charge, to any person obtaining a copy
24 * of this software and associated documentation files (the "Software"), to
25 * deal in the Software without restriction, including without limitation the
26 * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
27 * sell copies of the Software, and to permit persons to whom the Software is
28 * furnished to do so, subject to the following conditions:
29 *
30 * The above copyright notice and this permission notice shall be included in
31 * all copies of the Software and its Copyright notices. In addition publicly
32 * documented acknowledgment must be given that this software has been used if no
33 * source code of this software is made available publicly. This includes
34 * acknowledgments in either Copyright notices, Manuals, Publicity and Marketing
35 * documents or any documentation provided with any product containing this
36 * software. This License does not apply to any software that links to the
37 * libraries provided by this software (statically or dynamically), but only to
38 * the software provided.
39 *
40 * Please see the OLD-COPYING.PLAIN for a plain-english explanation of this notice
41 * and it's intent.
42 *
43 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
44 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
45 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
46 * THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
47 * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
48 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
49 */
50
51#ifndef EINA_BINSHARE_H_
52#define EINA_BINSHARE_H_
53
54#include "eina_types.h"
55
56/**
57 * @page tutorial_binshare_page Binary Share Tutorial
58 *
59 * Should call eina_binshare_init() before usage and eina_binshare_shutdown() after.
60 * to be written...
61 *
62 */
63
64/**
65 * @addtogroup Eina_Binshare_Group Binary Share
66 *
67 * These functions allow you to store one copy of an object, and use it
68 * throughout your program.
69 *
70 * This is a method to reduce the number of duplicated objects kept in
71 * memory.
72 *
73 * For more information, you can look at the @ref tutorial_binshare_page.
74 */
75
76/**
77 * @addtogroup Eina_Data_Types_Group Data Types
78 *
79 * @{
80 */
81
82/**
83 * @defgroup Eina_Binshare_Group Binary Share
84 *
85 * @{
86 */
87
88
89/**
90 * @brief Retrieve an instance of an object for use in a program.
91 *
92 * @param obj The binary object to retrieve an instance of.
93 * @param olen The byte size
94 * @return A pointer to an instance of the object on success.
95 * @c NULL on failure.
96 *
97 * This function retrieves an instance of @p obj. If @p obj is
98 * @c NULL, then @c NULL is returned. If @p obj is already stored, it
99 * is just returned and its reference counter is increased. Otherwise
100 * it is added to the objects to be searched and a duplicated object
101 * of @p obj is returned.
102 *
103 * This function does not check object size, but uses the
104 * exact given size. This can be used to share part of a larger
105 * object or subobject.
106 *
107 * @see eina_binshare_add()
108 */
109EAPI const void *eina_binshare_add_length(const void *obj,
110 unsigned int olen) EINA_PURE EINA_WARN_UNUSED_RESULT;
111
112/**
113 * Increment references of the given shared object.
114 *
115 * @param obj The shared object.
116 * @return A pointer to an instance of the object on success.
117 * @c NULL on failure.
118 *
119 * This is similar to eina_share_common_add(), but it's faster since it will
120 * avoid lookups if possible, but on the down side it requires the parameter
121 * to be shared before, in other words, it must be the return of a previous
122 * eina_binshare_add().
123 *
124 * There is no unref since this is the work of eina_binshare_del().
125 */
126EAPI const void *eina_binshare_ref(const void *obj);
127
128/**
129 * @brief Note that the given object has lost an instance.
130 *
131 * @param obj object The given object.
132 *
133 * This function decreases the reference counter associated to @p obj
134 * if it exists. If that counter reaches 0, the memory associated to
135 * @p obj is freed. If @p obj is NULL, the function returns
136 * immediately.
137 *
138 * Note that if the given pointer is not shared or NULL, bad things
139 * will happen, likely a segmentation fault.
140 */
141EAPI void eina_binshare_del(const void *obj);
142
143/**
144 * @brief Note that the given object @b must be shared.
145 *
146 * @param obj the shared object to know the length. It is safe to
147 * give NULL, in that case -1 is returned.
148 * @return The length of the shared object.
149 *
150 * This function is a cheap way to known the length of a shared
151 * object. Note that if the given pointer is not shared, bad
152 * things will happen, likely a segmentation fault. If in doubt, try
153 * strlen().
154 */
155EAPI int eina_binshare_length(const void *obj) EINA_WARN_UNUSED_RESULT;
156
157/**
158 * @brief Dump the contents of the share_common.
159 *
160 * This function dumps all objects in the share_common to stdout with a
161 * DDD: prefix per line and a memory usage summary.
162 */
163EAPI void eina_binshare_dump(void);
164
165/**
166 * @brief Retrieve an instance of a blob for use in a program.
167 *
168 * @param ptr The binary blob to retrieve an instance of.
169 * @return A pointer to an instance of the string on success.
170 * @c NULL on failure.
171 *
172 * This macro retrieves an instance of @p obj. If @p obj is
173 * @c NULL, then @c NULL is returned. If @p obj is already stored, it
174 * is just returned and its reference counter is increased. Otherwise
175 * it is added to the blobs to be searched and a duplicated blob
176 * of @p obj is returned.
177 *
178 * This macro essentially calls eina_binshare_add_length with ptr and sizeof(*ptr)
179 * as the parameters. It's useful for pointers to structures.
180 *
181 * @see eina_stringshare_add_length()
182 */
183#define eina_binshare_add(ptr) eina_binshare_add_length(ptr, sizeof(*ptr))
184
185/**
186 * @}
187 */
188
189/**
190 * @}
191 */
192
193#endif /* EINA_STRINGSHARE_H_ */
diff --git a/libraries/eina/src/include/eina_clist.h b/libraries/eina/src/include/eina_clist.h
new file mode 100644
index 0000000..68f15df
--- /dev/null
+++ b/libraries/eina/src/include/eina_clist.h
@@ -0,0 +1,456 @@
1/*
2 * Linked lists support
3 *
4 * Copyright (C) 2002 Alexandre Julliard
5 * Copyright (C) 2011 Mike McCormack (adapted for Eina)
6 *
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
11 *
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
20 */
21
22#ifndef __EINA_CLIST_H__
23#define __EINA_CLIST_H__
24
25/**
26 * @addtogroup Eina_CList_Group Compact inline list
27 * @brief Eina_Clist is a compact (inline) list implementation
28 *
29 * Elements of this list are members of the structs stored in the list
30 *
31 * Advantages over @ref Eina_List and @ref Eina_Inlist:
32 * - uses less memory (two machine words per item)
33 * - allows removing items without knowing which list they're in using O(1) time
34 * - no need to keep updating the head pointer as the list is changed
35 *
36 * Disadvantages:
37 * - O(N) time to calculate list length
38 * - requires one list entry in a struct per list (i.e. it's an inlist)
39 * - requires a head/tail pointer
40 * - need to know the list head when moving to next or previous pointer
41 *
42 * @note There's no NULL at the end of the list, the last item points to the head.
43 *
44 * @note List heads must be initialized with EINA_CLIST_INIT or by calling eina_clist_element_init
45 */
46
47/* Define a list like so:
48 *
49 * @code
50 * struct gadget
51 * {
52 * struct Eina_Clist entry; <-- doesn't have to be the first item in the struct
53 * int a, b;
54 * };
55 *
56 * static Eina_Clist global_gadgets = EINA_CLIST_INIT( global_gadgets );
57 * @endcode
58 *
59 * or
60 *
61 * @code
62 * struct some_global_thing
63 * {
64 * Eina_Clist gadgets;
65 * };
66 *
67 * eina_clist_init( &some_global_thing->gadgets );
68 * @endcode
69 *
70 * Manipulate it like this:
71 *
72 * @code
73 * eina_clist_add_head( &global_gadgets, &new_gadget->entry );
74 * eina_clist_remove( &new_gadget->entry );
75 * eina_clist_add_after( &some_random_gadget->entry, &new_gadget->entry );
76 * @endcode
77 *
78 * And to iterate over it:
79 *
80 * @code
81 * struct gadget *gadget;
82 * EINA_CLIST_FOR_EACH_ENTRY( gadget, &global_gadgets, struct gadget, entry )
83 * {
84 * ...
85 * }
86 * @endcode
87 *
88 */
89
90/**
91 * @addtogroup Eina_Data_Types_Group Data Types
92 *
93 * @{
94 */
95
96/**
97 * @addtogroup Eina_Containers_Group Containers
98 *
99 * @{
100 */
101
102/**
103 * @defgroup Eina_CList_Group Compact list
104 *
105 * @{
106 */
107
108/**
109 * @typedef Eina_Clist
110 * This is the list head and the list entry.
111 * @since 1.1.0
112 */
113typedef struct _Eina_Clist Eina_Clist;
114
115/**
116 * @struct _Eina_Clist
117 * Compact list type
118 * @note This structure is used as both the list head and the list entry.
119 * @since 1.1.0
120 */
121struct _Eina_Clist
122{
123 Eina_Clist *next;
124 Eina_Clist *prev;
125};
126
127/**
128 * Add an element after the specified one.
129 *
130 * @param elem An element in the list
131 * @param to_add The element to add to the list
132 * @pre The list head must be initialized once before adding anything.
133 * @pre The element is not in any list.
134 *
135 * @note There's no need to initialize an element before adding it to the list.
136 * @since 1.1.0
137 */
138static inline void eina_clist_add_after(Eina_Clist *elem, Eina_Clist *to_add)
139{
140 to_add->next = elem->next;
141 to_add->prev = elem;
142 elem->next->prev = to_add;
143 elem->next = to_add;
144}
145
146/**
147 * Add an element before the specified one.
148 *
149 * @param elem An element in the list
150 * @param to_add The element to add to the list
151 * @pre The list head must be initialized once before adding anything.
152 * @pre The element is not in any list.
153 *
154 * @note There's no need to initialize an element before adding it to the list.
155 * @since 1.1.0
156 */
157static inline void eina_clist_add_before(Eina_Clist *elem, Eina_Clist *to_add)
158{
159 to_add->next = elem;
160 to_add->prev = elem->prev;
161 elem->prev->next = to_add;
162 elem->prev = to_add;
163}
164
165/**
166 * Add element at the head of the list.
167 *
168 * @param list The list
169 * @param elem An element
170 * @pre The list head must be initialized once before adding anything.
171 * @pre The element is not in any list.
172 *
173 * @note There's no need to initialize an element before adding it to the list.
174 * @since 1.1.0
175 */
176static inline void eina_clist_add_head(Eina_Clist *list, Eina_Clist *elem)
177{
178 eina_clist_add_after(list, elem);
179}
180
181/**
182 * Add element at the tail of the list.
183 *
184 * @param list The list
185 * @param elem An element
186 * @pre The list head must be initialized once before adding anything.
187 * @pre The element is not in any list.
188 *
189 * @note There's no need to initialize an element before adding it to the list.
190 * @since 1.1.0
191 */
192static inline void eina_clist_add_tail(Eina_Clist *list, Eina_Clist *elem)
193{
194 eina_clist_add_before(list, elem);
195}
196
197/**
198 * Init an (unlinked) element.
199 *
200 * Call this function on elements that have not been added to the list
201 * if you want eina_clist_element_init() to work correctly
202 *
203 * @param elem An element
204 * @pre The element is not in any list.
205 * @post The element is marked as not being in any list
206 *
207 * @note It is not necessary to call this before adding an element to this list.
208 * @since 1.1.0
209 */
210static inline void eina_clist_element_init(Eina_Clist *elem)
211{
212 elem->next = NULL;
213 elem->prev = NULL;
214}
215
216/**
217 * Check if an element is in a list or not.
218 *
219 * @param elem An element
220 *
221 * @pre Either eina_clist_element_init() has been called on @a elem,
222 * it has been added to a list or remove from a list.
223 * @since 1.1.0
224 */
225static inline int eina_clist_element_is_linked(Eina_Clist *elem)
226{
227 return (elem->next != NULL && elem->prev != NULL);
228}
229
230/**
231 * Remove an element from its list.
232 *
233 * @param elem An element
234 * @pre The element is in a list already
235 * @post The element is marked as not being in any list
236 * @since 1.1.0
237 */
238static inline void eina_clist_remove(Eina_Clist *elem)
239{
240 elem->next->prev = elem->prev;
241 elem->prev->next = elem->next;
242 eina_clist_element_init(elem);
243}
244
245/**
246 * Get the next element.
247 *
248 * @param list The list
249 * @param elem An element
250 * @pre @a elem is in @a list
251 * @return The element after @elem in @list or NULL if @a elem is last in @a list
252 * @since 1.1.0
253 */
254static inline Eina_Clist *eina_clist_next(const Eina_Clist *list, const Eina_Clist *elem)
255{
256 Eina_Clist *ret = elem->next;
257 if (elem->next == list) ret = NULL;
258 return ret;
259}
260
261/**
262 * Get the previous element.
263 *
264 * @param list The list
265 * @param elem An element
266 *
267 * @return The element before @a elem or NULL if @a elem is the first in the list
268 * @since 1.1.0
269 */
270static inline Eina_Clist *eina_clist_prev(const Eina_Clist *list, const Eina_Clist *elem)
271{
272 Eina_Clist *ret = elem->prev;
273 if (elem->prev == list) ret = NULL;
274 return ret;
275}
276
277/**
278 * Get the first element.
279 *
280 * @param list The list
281 * @returns The first element in @a list or NULL if @a list is empty
282 * @since 1.1.0
283 */
284static inline Eina_Clist *eina_clist_head(const Eina_Clist *list)
285{
286 return eina_clist_next(list, list);
287}
288
289/**
290 * Get the last element.
291 *
292 * @param list The list
293 * @returns The last element in @a list or NULL if @list is empty
294 * @since 1.1.0
295 */
296static inline Eina_Clist *eina_clist_tail(const Eina_Clist *list)
297{
298 return eina_clist_prev(list, list);
299}
300
301/**
302 * Check if a list is empty.
303 *
304 * @param list The list
305 * @returns non-zero if @a list is empty, zero if it is not
306 * @since 1.1.0
307 */
308static inline int eina_clist_empty(const Eina_Clist *list)
309{
310 return list->next == list;
311}
312
313/**
314 * Initialize a list
315 *
316 * @param list The list
317 * @pre The list is uninitialized
318 * @post The list contains no items
319 *
320 * @note Don't call this function on a list with items
321 * @note This function must be called. Don't try do
322 * initialize the list by zero'ing out the list head.
323 * @since 1.1.0
324 */
325static inline void eina_clist_init(Eina_Clist *list)
326{
327 list->next = list->prev = list;
328}
329
330/**
331 * Count the elements of a list
332 *
333 * @param list The list
334 * @returns The number of items in the list
335 * @since 1.1.0
336 */
337static inline unsigned int eina_clist_count(const Eina_Clist *list)
338{
339 unsigned count = 0;
340 const Eina_Clist *ptr;
341 for (ptr = list->next; ptr != list; ptr = ptr->next) count++;
342 return count;
343}
344
345/**
346 * Move all elements from src to the tail of dst
347 *
348 * @param dst List to be appended to
349 * @param src List to append
350 *
351 * @post @a src is initialized but empty after this operation
352 * @since 1.1.0
353 */
354static inline void eina_clist_move_tail(Eina_Clist *dst, Eina_Clist *src)
355{
356 if (eina_clist_empty(src)) return;
357
358 dst->prev->next = src->next;
359 src->next->prev = dst->prev;
360 dst->prev = src->prev;
361 src->prev->next = dst;
362 eina_clist_init(src);
363}
364
365/**
366 * move all elements from src to the head of dst
367 *
368 * @param dst List to be prepended to
369 * @param src List to prepend
370 *
371 * @post @a src is initialized but empty after this operation
372 * @since 1.1.0
373 */
374static inline void eina_clist_move_head(Eina_Clist *dst, Eina_Clist *src)
375{
376 if (eina_clist_empty(src)) return;
377
378 dst->next->prev = src->prev;
379 src->prev->next = dst->next;
380 dst->next = src->next;
381 src->next->prev = dst;
382 eina_clist_init(src);
383}
384
385/**
386 * iterate through the list
387 */
388#define EINA_CLIST_FOR_EACH(cursor,list) \
389 for ((cursor) = (list)->next; (cursor) != (list); (cursor) = (cursor)->next)
390
391/* iterate through the list, with safety against removal */
392#define EINA_CLIST_FOR_EACH_SAFE(cursor, cursor2, list) \
393 for ((cursor) = (list)->next, (cursor2) = (cursor)->next; \
394 (cursor) != (list); \
395 (cursor) = (cursor2), (cursor2) = (cursor)->next)
396
397/* iterate through the list using a list entry */
398#define EINA_CLIST_FOR_EACH_ENTRY(elem, list, type, field) \
399 for ((elem) = EINA_CLIST_ENTRY((list)->next, type, field); \
400 &(elem)->field != (list); \
401 (elem) = EINA_CLIST_ENTRY((elem)->field.next, type, field))
402
403/* iterate through the list using a list entry, with safety against removal */
404#define EINA_CLIST_FOR_EACH_ENTRY_SAFE(cursor, cursor2, list, type, field) \
405 for ((cursor) = EINA_CLIST_ENTRY((list)->next, type, field), \
406 (cursor2) = EINA_CLIST_ENTRY((cursor)->field.next, type, field); \
407 &(cursor)->field != (list); \
408 (cursor) = (cursor2), \
409 (cursor2) = EINA_CLIST_ENTRY((cursor)->field.next, type, field))
410
411/* iterate through the list in reverse order */
412#define EINA_CLIST_FOR_EACH_REV(cursor,list) \
413 for ((cursor) = (list)->prev; (cursor) != (list); (cursor) = (cursor)->prev)
414
415/* iterate through the list in reverse order, with safety against removal */
416#define EINA_CLIST_FOR_EACH_SAFE_REV(cursor, cursor2, list) \
417 for ((cursor) = (list)->prev, (cursor2) = (cursor)->prev; \
418 (cursor) != (list); \
419 (cursor) = (cursor2), (cursor2) = (cursor)->prev)
420
421/* iterate through the list in reverse order using a list entry */
422#define EINA_CLIST_FOR_EACH_ENTRY_REV(elem, list, type, field) \
423 for ((elem) = EINA_CLIST_ENTRY((list)->prev, type, field); \
424 &(elem)->field != (list); \
425 (elem) = EINA_CLIST_ENTRY((elem)->field.prev, type, field))
426
427/* iterate through the list in reverse order using a list entry, with safety against removal */
428#define EINA_CLIST_FOR_EACH_ENTRY_SAFE_REV(cursor, cursor2, list, type, field) \
429 for ((cursor) = EINA_CLIST_ENTRY((list)->prev, type, field), \
430 (cursor2) = EINA_CLIST_ENTRY((cursor)->field.prev, type, field); \
431 &(cursor)->field != (list); \
432 (cursor) = (cursor2), \
433 (cursor2) = EINA_CLIST_ENTRY((cursor)->field.prev, type, field))
434
435/* macros for statically initialized lists */
436#undef EINA_CLIST_INIT
437#define EINA_CLIST_INIT(list) { &(list), &(list) }
438
439/* get pointer to object containing list element */
440#undef EINA_CLIST_ENTRY
441#define EINA_CLIST_ENTRY(elem, type, field) \
442 ((type *)((char *)(elem) - (unsigned long)(&((type *)0)->field)))
443
444/*
445 * @}
446 */
447
448/*
449 * @}
450 */
451
452/*
453 * @}
454 */
455
456#endif /* __EINA_CLIST_H__ */
diff --git a/libraries/eina/src/include/eina_config.h b/libraries/eina/src/include/eina_config.h
new file mode 100644
index 0000000..3341731
--- /dev/null
+++ b/libraries/eina/src/include/eina_config.h
@@ -0,0 +1,67 @@
1/* EINA - EFL data type library
2 * Copyright (C) 2008 Cedric Bail
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library;
16 * if not, see <http://www.gnu.org/licenses/>.
17 */
18
19#ifndef EINA_CONFIG_H_
20#define EINA_CONFIG_H_
21
22#ifdef EINA_MAGIC_DEBUG
23# undef EINA_MAGIC_DEBUG
24#endif
25#define EINA_MAGIC_DEBUG
26
27#ifdef EINA_DEFAULT_MEMPOOL
28# undef EINA_DEFAULT_MEMPOOL
29#endif
30
31
32#ifdef EINA_SAFETY_CHECKS
33# undef EINA_SAFETY_CHECKS
34#endif
35#define EINA_SAFETY_CHECKS
36
37#ifdef EINA_HAVE_INTTYPES_H
38# undef EINA_HAVE_INTTYPES_H
39#endif
40#define EINA_HAVE_INTTYPES_H
41
42#ifdef EINA_HAVE_STDINT_H
43# undef EINA_HAVE_STDINT_H
44#endif
45#define EINA_HAVE_STDINT_H
46
47#ifdef EINA_HAVE_THREADS
48# undef EINA_HAVE_THREADS
49#endif
50#define EINA_HAVE_THREADS
51
52#ifdef EINA_HAVE_DEBUG_THREADS
53# undef EINA_HAVE_DEBUG_THREADS
54#endif
55
56
57#ifdef EINA_SIZEOF_WCHAR_T
58# undef EINA_SIZEOF_WCHAR_T
59#endif
60#define EINA_SIZEOF_WCHAR_T 4
61
62#ifdef EINA_HAVE_ON_OFF_THREADS
63# undef EINA_HAVE_ON_OFF_THREADS
64#endif
65
66
67#endif /* EINA_CONFIG_H_ */
diff --git a/libraries/eina/src/include/eina_config.h.in b/libraries/eina/src/include/eina_config.h.in
new file mode 100644
index 0000000..be328cd
--- /dev/null
+++ b/libraries/eina/src/include/eina_config.h.in
@@ -0,0 +1,67 @@
1/* EINA - EFL data type library
2 * Copyright (C) 2008 Cedric Bail
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library;
16 * if not, see <http://www.gnu.org/licenses/>.
17 */
18
19#ifndef EINA_CONFIG_H_
20#define EINA_CONFIG_H_
21
22#ifdef EINA_MAGIC_DEBUG
23# undef EINA_MAGIC_DEBUG
24#endif
25@EINA_CONFIGURE_MAGIC_DEBUG@
26
27#ifdef EINA_DEFAULT_MEMPOOL
28# undef EINA_DEFAULT_MEMPOOL
29#endif
30@EINA_CONFIGURE_DEFAULT_MEMPOOL@
31
32#ifdef EINA_SAFETY_CHECKS
33# undef EINA_SAFETY_CHECKS
34#endif
35@EINA_CONFIGURE_SAFETY_CHECKS@
36
37#ifdef EINA_HAVE_INTTYPES_H
38# undef EINA_HAVE_INTTYPES_H
39#endif
40@EINA_CONFIGURE_HAVE_INTTYPES_H@
41
42#ifdef EINA_HAVE_STDINT_H
43# undef EINA_HAVE_STDINT_H
44#endif
45@EINA_CONFIGURE_HAVE_STDINT_H@
46
47#ifdef EINA_HAVE_THREADS
48# undef EINA_HAVE_THREADS
49#endif
50@EINA_CONFIGURE_HAVE_THREADS@
51
52#ifdef EINA_HAVE_DEBUG_THREADS
53# undef EINA_HAVE_DEBUG_THREADS
54#endif
55@EINA_CONFIGURE_HAVE_DEBUG_THREADS@
56
57#ifdef EINA_SIZEOF_WCHAR_T
58# undef EINA_SIZEOF_WCHAR_T
59#endif
60#define EINA_SIZEOF_WCHAR_T @EINA_SIZEOF_WCHAR_T@
61
62#ifdef EINA_HAVE_ON_OFF_THREADS
63# undef EINA_HAVE_ON_OFF_THREADS
64#endif
65@EINA_CONFIGURE_HAVE_ON_OFF_THREADS@
66
67#endif /* EINA_CONFIG_H_ */
diff --git a/libraries/eina/src/include/eina_convert.h b/libraries/eina/src/include/eina_convert.h
new file mode 100644
index 0000000..af839e2
--- /dev/null
+++ b/libraries/eina/src/include/eina_convert.h
@@ -0,0 +1,374 @@
1/* EINA - EFL data type library
2 * Copyright (C) 2008 Cedric BAIL, Vincent Torri
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library;
16 * if not, see <http://www.gnu.org/licenses/>.
17 */
18
19#ifndef EINA_CONVERT_H_
20#define EINA_CONVERT_H_
21
22#include "eina_types.h"
23#include "eina_error.h"
24
25#include "eina_fp.h"
26
27
28/**
29 * @addtogroup Eina_Convert_Group Convert
30 *
31 * These functions allow you to convert integer or real numbers to
32 * string or conversely.
33 *
34 * To use these functions, you have to call eina_init()
35 * first, and eina_shutdown() when eina is not used anymore.
36 *
37 * @section Eina_Convert_From_Integer_To_Sring Conversion from integer to string
38 *
39 * To convert an integer to a string in the decimal base,
40 * eina_convert_itoa() should be used. If the hexadecimal base is
41 * wanted, eina_convert_xtoa() should be used. They all need a bufffer
42 * sufficiently large to store all the cyphers.
43 *
44 * Here is an example of use:
45 *
46 * @code
47 * #include <stdlib.h>
48 * #include <stdio.h>
49 *
50 * #include <Eina.h>
51 *
52 * int main(void)
53 * {
54 * char tmp[128];
55 *
56 * if (!eina_init())
57 * {
58 * printf ("Error during the initialization of eina.\n");
59 * return EXIT_FAILURE;
60 * }
61 *
62 * eina_convert_itoa(45, tmp);
63 * printf("value: %s\n", tmp);
64 * eina_convert_xtoa(0xA1, tmp);
65 * printf("value: %s\n", tmp);
66 *
67 * eina_shutdown();
68 *
69 * return EXIT_SUCCESS;
70 * }
71 * @endcode
72 *
73 * Compile this code with the following command:
74 *
75 * @code
76 * gcc -Wall -o test_eina_convert test_eina.c `pkg-config --cflags --libs eina`
77 * @endcode
78 *
79 * @note
80 * The alphabetical cyphers are in lower case.
81 *
82 * @section Eina_Convert_Double Conversion double / string
83 *
84 * To convert a double to a string, eina_convert_dtoa() should be
85 * used. Like with the integer functions, a buffer must be used. The
86 * resulting string ghas the following format (which is the result
87 * obtained with snprintf() and the @%a modifier):
88 *
89 * @code
90 * [-]0xh.hhhhhp[+-]e
91 * @endcode
92 *
93 * To convert a string to a double, eina_convert_atod() should be
94 * used. The format of the string must be as above. Then, the double
95 * has the following mantiss and exponent:
96 *
97 * @code
98 * mantiss : [-]hhhhhh
99 * exponent : 2^([+-]e - 4 * n)
100 * @endcode
101 *
102 * with n being number of cypers after the point in the string
103 * format. To obtain the double number from the mantiss and exponent,
104 * use ldexp().
105 *
106 * Here is an example of use:
107 *
108 * @code
109 * #include <stdlib.h>
110 * #include <stdio.h>
111 * #include <math.h>
112 *
113 * #include <Eina.h>
114 *
115 * int main(void)
116 * {
117 * char tmp[128];
118 * long long int m = 0;
119 * long int e = 0;
120 * double r;
121 *
122 * if (!eina_init())
123 * {
124 * printf ("Error during the initialization of eina.\n");
125 * return EXIT_FAILURE;
126 * }
127 *
128 * printf("initial value : 40.56\n");
129 * eina_convert_dtoa(40.56, tmp);
130 * printf("result dtoa : %s\n", tmp);
131
132 * eina_convert_atod(tmp, 128, &m, &e);
133 * r = ldexp((double)m, e);
134 * printf("result atod : %f\n", r);
135 *
136 * eina_shutdown();
137 *
138 * return EXIT_SUCCESS;
139 * }
140 * @endcode
141 *
142 * Compile this code with the following command:
143 *
144 * @code
145 * gcc -Wall -o test_eina_convert test_eina.c `pkg-config --cflags --libs eina` -lm
146 * @endcode
147 */
148
149/**
150 * @addtogroup Eina_Tools_Group Tools
151 *
152 * @{
153 */
154
155/**
156 * @defgroup Eina_Convert_Group Convert
157 *
158 * @{
159 */
160
161/**
162 * @var EINA_ERROR_CONVERT_P_NOT_FOUND
163 * Error identifier corresponding to string not containing 'p'.
164 */
165
166EAPI extern Eina_Error EINA_ERROR_CONVERT_P_NOT_FOUND;
167
168/**
169 * @var EINA_ERROR_CONVERT_0X_NOT_FOUND
170 * Error identifier corresponding to string not containing '0x'.
171 */
172EAPI extern Eina_Error EINA_ERROR_CONVERT_0X_NOT_FOUND;
173
174/**
175 * @var EINA_ERROR_CONVERT_OUTRUN_STRING_LENGTH
176 * Error identifier corresponding to length of the string being too small.
177 */
178EAPI extern Eina_Error EINA_ERROR_CONVERT_OUTRUN_STRING_LENGTH;
179
180/**
181 * @brief Convert an integer number to a string in decimal base.
182 *
183 * @param n The integer to convert.
184 * @param s The buffer to store the converted integer.
185 * @return The length of the string, including the nul terminated
186 * character.
187 *
188 * This function converts @p n to a nul terminated string. The
189 * converted string is in decimal base. As no check is done, @p s must
190 * be a buffer that is sufficiently large to store the integer.
191 *
192 * The returned value is the length of the string, including the nul
193 * terminated character.
194 */
195EAPI int eina_convert_itoa(int n, char *s) EINA_ARG_NONNULL(2);
196
197/**
198 * @brief Convert an integer number to a string in hexadecimal base.
199 *
200 * @param n The integer to convert.
201 * @param s The buffer to store the converted integer.
202 * @return The length of the string, including the nul terminated
203 * character.
204 *
205 * This function converts @p n to a nul terminated string. The
206 * converted string is in hexadecimal base and the alphabetical
207 * cyphers are in lower case. As no check is done, @p s must be a
208 * buffer that is sufficiently large to store the integer.
209 *
210 * The returned value is the length of the string, including the nul
211 * terminated character.
212 */
213EAPI int eina_convert_xtoa(unsigned int n, char *s) EINA_ARG_NONNULL(2);
214
215
216/**
217 * @brief Convert a double to a string.
218 *
219 * @param d The double to convert.
220 * @param des The destination buffer to store the converted double.
221 * @return #EINA_TRUE on success, #EINA_FALSE otherwise.
222 *
223 * This function converts the double @p d to a string. The string is
224 * stored in the buffer pointed by @p des and must be sufficiently
225 * large to contain the converted double. The returned string is nul
226 * terminated and has the following format:
227 *
228 * @code
229 * [-]0xh.hhhhhp[+-]e
230 * @endcode
231 *
232 * where the h are the hexadecimal cyphers of the mantiss and e the
233 * exponent (a decimal number).
234 *
235 * The returned value is the length of the string, including the nul
236 * character.
237 */
238EAPI int eina_convert_dtoa(double d, char *des) EINA_ARG_NONNULL(2);
239
240/**
241 * @brief Convert a string to a double.
242 *
243 * @param src The string to convert.
244 * @param length The length of the string.
245 * @param m The mantisse.
246 * @param e The exponent.
247 * @return #EINA_TRUE on success, #EINA_FALSE otherwise.
248 *
249 * This function converts the string @p s of length @p length that
250 * represent a double in hexadecimal base to a double. It is used to
251 * replace the use of snprintf() with the \%a modifier, which is
252 * missing on some platform (like Windows (tm) or OpenBSD).
253 *
254 * The string must have the following format:
255 *
256 * @code
257 * [-]0xh.hhhhhp[+-]e
258 * @endcode
259 *
260 * where the h are the hexadecimal cyphers of the mantiss and e the
261 * exponent (a decimal number). If n is the number of cypers after the
262 * point, the returned mantiss and exponents are:
263 *
264 * @code
265 * mantiss : [-]hhhhhh
266 * exponent : 2^([+-]e - 4 * n)
267 * @endcode
268 *
269 * The mantiss and exponent are stored in the buffers pointed
270 * respectively by @p m and @p e.
271 *
272 * If the string is invalid, the error is set to:
273 *
274 * @li #EINA_ERROR_CONVERT_0X_NOT_FOUND if no 0x is found,
275 * @li #EINA_ERROR_CONVERT_P_NOT_FOUND if no p is found,
276 * @li #EINA_ERROR_CONVERT_OUTRUN_STRING_LENGTH if @p length is not
277 * correct.
278 *
279 * In those cases, #EINA_FALSE is returned, otherwise #EINA_TRUE is
280 * returned.
281 */
282EAPI Eina_Bool eina_convert_atod(const char *src,
283 int length,
284 long long *m,
285 long *e) EINA_ARG_NONNULL(1, 3, 4);
286
287
288/**
289 * @brief Convert a 32.32 fixed point number to a string.
290 *
291 * @param fp The fixed point number to convert.
292 * @param des The destination buffer to store the converted fixed point number.
293 * @return #EINA_TRUE on success, #EINA_FALSE otherwise.
294 *
295 * This function converts the 32.32 fixed point number @p fp to a
296 * string. The string is stored in the buffer pointed by @p des and
297 * must be sufficiently large to contain the converted fixed point
298 * number. The returned string is terminated and has the following
299 * format:
300 *
301 * @code
302 * [-]0xh.hhhhhp[+-]e
303 * @endcode
304 *
305 * where the h are the hexadecimal cyphers of the mantiss and e the
306 * exponent (a decimal number).
307 *
308 * The returned value is the length of the string, including the nul
309 * character.
310 *
311 * @note The code is the same than eina_convert_dtoa() except that it
312 * implements the frexp() function for fixed point numbers and does
313 * some optimisations.
314 */
315EAPI int eina_convert_fptoa(Eina_F32p32 fp,
316 char *des) EINA_ARG_NONNULL(2);
317
318/**
319 * @brief Convert a string to a 32.32 fixed point number.
320 *
321 * @param src The string to convert.
322 * @param length The length of the string.
323 * @param fp The fixed point number.
324 * @return #EINA_TRUE on success, #EINA_FALSE otherwise.
325 *
326 * This function converts the string @p src of length @p length that
327 * represent a double in hexadecimal base to a 32.32 fixed point
328 * number stored in @p fp. The function always tries to convert the
329 * string with eina_convert_atod().
330 *
331 * The string must have the following format:
332 *
333 * @code
334 * [-]0xh.hhhhhp[+-]e
335 * @endcode
336 *
337 * where the h are the hexadecimal cyphers of the mantiss and e the
338 * exponent (a decimal number). If n is the number of cypers after the
339 * point, the returned mantiss and exponents are:
340 *
341 * @code
342 * mantiss : [-]hhhhhh
343 * exponent : 2^([+-]e - 4 * n)
344 * @endcode
345 *
346 * The mantiss and exponent are stored in the buffers pointed
347 * respectively by @p m and @p e.
348 *
349 * If the string is invalid, the error is set to:
350 *
351 * @li #EINA_ERROR_CONVERT_0X_NOT_FOUND if no 0x is found,
352 * @li #EINA_ERROR_CONVERT_P_NOT_FOUND if no p is found,
353 * @li #EINA_ERROR_CONVERT_OUTRUN_STRING_LENGTH if @p length is not
354 * correct.
355 *
356 * In those cases, or if @p fp is @c NULL, #EINA_FALSE is returned,
357 * otherwise @p fp is computed and #EINA_TRUE is returned.
358 *
359 * @note The code uses eina_convert_atod() and do the correct bit
360 * shift to compute the fixed point number.
361 */
362EAPI Eina_Bool eina_convert_atofp(const char *src,
363 int length,
364 Eina_F32p32 *fp) EINA_ARG_NONNULL(1, 3);
365
366/**
367 * @}
368 */
369
370/**
371 * @}
372 */
373
374#endif /* EINA_CONVERT_H_ */
diff --git a/libraries/eina/src/include/eina_counter.h b/libraries/eina/src/include/eina_counter.h
new file mode 100644
index 0000000..26bee06
--- /dev/null
+++ b/libraries/eina/src/include/eina_counter.h
@@ -0,0 +1,213 @@
1/* EINA - EFL data type library
2 * Copyright (C) 2008 Cedric Bail
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library;
16 * if not, see <http://www.gnu.org/licenses/>.
17 */
18
19#ifndef EINA_COUNTER_H_
20#define EINA_COUNTER_H_
21
22#include "eina_types.h"
23
24/**
25 * @addtogroup Eina_Counter_Group Counter
26 *
27 * @brief These functions allow you to get the time spent in a part of a code.
28 *
29 * Before using the counter system, Eina must be initialized with
30 * eina_init() and later shut down with eina_shutdown(). The create a
31 * counter, use eina_counter_new(). To free it, use
32 * eina_counter_free().
33 *
34 * To time a part of a code, call eina_counter_start() just before it,
35 * and eina_counter_stop() just after it. Each time you start to time
36 * a code, a clock is added to a list. You can give a number of that
37 * clock with the second argument of eina_counter_stop(). To send all
38 * the registered clocks to a stream (like stdout, ofr a file), use
39 * eina_counter_dump().
40 *
41 * Here is a straightforward example:
42 *
43 * @code
44 * #include <stdlib.h>
45 * #include <stdio.h>
46 *
47 * #include <eina_counter.h>
48 *
49 * void test_malloc(void)
50 * {
51 * int i;
52 *
53 * for (i = 0; i < 100000; ++i)
54 * {
55 * void *buf;
56 *
57 * buf = malloc(100);
58 * free(buf);
59 * }
60 * }
61 *
62 * int main(void)
63 * {
64 * Eina_Counter *counter;
65 *
66 * if (!eina_init())
67 * {
68 * printf("Error during the initialization of eina\n");
69 * return EXIT_FAILURE;
70 * }
71 *
72 * counter = eina_counter_new("malloc");
73 *
74 * eina_counter_start(counter);
75 * test_malloc();
76 * eina_counter_stop(counter, 1);
77 *
78 * char* result = eina_counter_dump(counter);
79 * printf("%s", result);
80 * free(result);
81 *
82 * eina_counter_free(counter);
83 * eina_shutdown();
84 *
85 * return EXIT_SUCCESS;
86 * }
87 * @endcode
88 *
89 * Compile this code with the following commant:
90 *
91 * @verbatim
92 * gcc -Wall -o test_eina_counter test_eina.c `pkg-config --cflags --libs eina`
93 * @endverbatim
94 *
95 * The result should be something like that:
96 *
97 * @verbatim
98 * \# specimen experiment time starting time ending time
99 * 1 9794125 783816 10577941
100 * @endverbatim
101 *
102 * Note that the displayed time is in nanosecond.
103 */
104
105/**
106 * @addtogroup Eina_Tools_Group Tools
107 *
108 * @{
109 */
110
111/**
112 * @defgroup Eina_Counter_Group Counter
113 *
114 * @{
115 */
116
117/**
118 * @typedef Eina_Counter
119 * Counter type.
120 */
121typedef struct _Eina_Counter Eina_Counter;
122
123
124/**
125 * @brief Return a counter.
126 *
127 * @param name The name of the counter.
128 * @return A newly allocated counter.
129 *
130 * This function returns a new counter. It is characterized by @p
131 * name. If @p name is @c NULL, the function returns @c NULL
132 * immediately. If memory allocation fails, @c NULL is returned and the
133 * error is set to #EINA_ERROR_OUT_OF_MEMORY.
134 *
135 * Whe the new counter is not needed anymore, use eina_counter_free() to
136 * free the allocated memory.
137 */
138EAPI Eina_Counter *eina_counter_new(const char *name) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1);
139
140/**
141 * @brief Delete a counter.
142 *
143 * @param counter The counter to delete.
144 *
145 * This function remove the clock of @p counter from the used clocks
146 * (see eina_counter_start()) and frees the memory allocated for
147 * @p counter. If @p counter is @c NULL, the function returns
148 * immediately.
149 */
150EAPI void eina_counter_free(Eina_Counter *counter) EINA_ARG_NONNULL(1);
151
152/**
153 * @brief Start the time count.
154 *
155 * @param counter The counter.
156 *
157 * This function specifies that the part of the code beginning just
158 * after its call is being to be timed, using @p counter. If
159 * @p counter is @c NULL, this function returns immediately.
160 *
161 * This function adds the clock associated to @p counter in a list. If
162 * the memory needed by that clock can not be allocated, the function
163 * returns and the error is set to #EINA_ERROR_OUT_OF_MEMORY.
164 *
165 * To stop the timing, eina_counter_stop() must be called with the
166 * same counter.
167 */
168EAPI void eina_counter_start(Eina_Counter *counter) EINA_ARG_NONNULL(1);
169
170/**
171 * @brief Stop the time count.
172 *
173 * @param counter The counter.
174 * @param specimen The number of the test.
175 *
176 * This function stop the timing that has been started with
177 * eina_counter_start(). @p counter must be the same than the one used
178 * with eina_counter_start(). @p specimen is the number of the
179 * test. If @p counter or its associated clock are @c NULL, or if the
180 * time can't be retrieved the function exits.
181 */
182EAPI void eina_counter_stop(Eina_Counter *counter,
183 int specimen) EINA_ARG_NONNULL(1);
184
185/**
186 * @brief Dump the result of all clocks of a counter to a stream.
187 *
188 * @return A string with a summary of the test.
189 * @param counter The counter.
190 *
191 * This function returns an malloc'd string containing the dump of
192 * all the valid clocks of @p counter.
193 * If @p counter @c NULL, the functions exits
194 * immediately. Otherwise, the output is formattted like that:
195 *
196 * @verbatim
197 * \# specimen experiment time starting time ending time
198 * 1 208 120000 120208
199 * @endverbatim
200 *
201 * The unit of time is the nanosecond.
202 */
203EAPI char *eina_counter_dump(Eina_Counter *counter) EINA_ARG_NONNULL(1);
204
205/**
206 * @}
207 */
208
209/**
210 * @}
211 */
212
213#endif /* EINA_COUNTER_H_ */
diff --git a/libraries/eina/src/include/eina_cpu.h b/libraries/eina/src/include/eina_cpu.h
new file mode 100644
index 0000000..ac32e1d
--- /dev/null
+++ b/libraries/eina/src/include/eina_cpu.h
@@ -0,0 +1,39 @@
1/* EINA - EFL data type library
2 * Copyright (C) 2007-2008 Jorge Luis Zapata Muga
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library;
16 * if not, see <http://www.gnu.org/licenses/>.
17 */
18
19#ifndef EINA_CPU_H_
20#define EINA_CPU_H_
21
22#include "eina_types.h"
23
24typedef enum _Eina_Cpu_Features
25{
26 EINA_CPU_MMX = 0x00000001,
27 EINA_CPU_SSE = 0x00000002,
28 EINA_CPU_SSE2 = 0x00000004,
29 EINA_CPU_SSE3 = 0x00000008,
30 /* TODO 3DNow! */
31 EINA_CPU_ALTIVEC = 0x00000010,
32 EINA_CPU_VIS = 0x00000020,
33 EINA_CPU_NEON = 0x00000040,
34} Eina_Cpu_Features;
35
36EAPI Eina_Cpu_Features eina_cpu_features_get(void);
37EAPI int eina_cpu_count(void);
38
39#endif /* EINA_CPU_H_ */
diff --git a/libraries/eina/src/include/eina_error.h b/libraries/eina/src/include/eina_error.h
new file mode 100644
index 0000000..2b0ae77
--- /dev/null
+++ b/libraries/eina/src/include/eina_error.h
@@ -0,0 +1,198 @@
1/* EINA - EFL data type library
2 * Copyright (C) 2007-2008 Jorge Luis Zapata Muga, Cedric Bail
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library;
16 * if not, see <http://www.gnu.org/licenses/>.
17 */
18
19#ifndef EINA_ERROR_H_
20#define EINA_ERROR_H_
21
22#include <stdarg.h>
23
24#include "eina_types.h"
25
26
27/**
28 * @page tutorial_error_page Error Tutorial
29 *
30 * @section tutorial_error_registering_msg Registering messages
31 *
32 * The error module can provide a system that mimics the errno system
33 * of the C standard library. It consists in 2 parts:
34 *
35 * @li a way of registering new messages with
36 * eina_error_msg_register() and eina_error_msg_get(),
37 * @li a way of setting / getting last error message with
38 * eina_error_set() / eina_error_get().
39 *
40 * So one has to fisrt register all the error messages that a program
41 * or a lib should manage. Then, when an error can occur, use
42 * eina_error_set(), and when errors are managed, use
43 * eina_error_get(). If eina_error_set() is used to set an error, do
44 * not forget to call before eina_error_set(), to remove previous set
45 * errors.
46 *
47 * Here is an example of use:
48 *
49 * @include eina_error_01.c
50 *
51 * Of course, instead of printf(), eina_log_print() can be used to
52 * have beautiful error messages.
53 */
54
55/**
56 * @addtogroup Eina_Error_Group Error
57 *
58 * @brief These functions provide error management for projects.
59 *
60 * The Eina error module provides a way to manage errors in a simple but
61 * powerful way in libraries and modules. It is also used in Eina itself.
62 * Similar to libC's @c errno and strerror() facilities, this is extensible and
63 * recommended for other libraries and applications.
64 *
65 * A simple example of how to use this can be seen @ref tutorial_error_page
66 * "here".
67 */
68
69/**
70 * @addtogroup Eina_Tools_Group Tools
71 *
72 * @{
73 */
74
75/**
76 * @defgroup Eina_Error_Group Error
77 *
78 * @{
79 */
80
81/**
82 * @typedef Eina_Error
83 * Error type.
84 */
85typedef int Eina_Error;
86
87/**
88 * @var EINA_ERROR_OUT_OF_MEMORY
89 * Error identifier corresponding to a lack of memory.
90 */
91
92EAPI extern Eina_Error EINA_ERROR_OUT_OF_MEMORY;
93
94/**
95 * @brief Register a new error type.
96 *
97 * @param msg The description of the error. It will be duplicated using
98 * eina_stringshare_add().
99 * @return The unique number identifier for this error.
100 *
101 * This function stores in a list the error message described by
102 * @p msg. The returned value is a unique identifier greater or equal
103 * than 1. The description can be retrieve later by passing to
104 * eina_error_msg_get() the returned value.
105 *
106 * @see eina_error_msg_static_register()
107 */
108EAPI Eina_Error eina_error_msg_register(const char *msg) EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT;
109
110/**
111 * @brief Register a new error type, statically allocated message.
112 *
113 * @param msg The description of the error. This string will not be
114 * duplicated and thus the given pointer should live during
115 * usage of eina_error.
116 * @return The unique number identifier for this error.
117 *
118 * This function stores in a list the error message described by
119 * @p msg. The returned value is a unique identifier greater or equal
120 * than 1. The description can be retrieve later by passing to
121 * eina_error_msg_get() the returned value.
122 *
123 * @see eina_error_msg_register()
124 */
125EAPI Eina_Error eina_error_msg_static_register(const char *msg) EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT;
126
127/**
128 * @brief Change the message of an already registered message
129 *
130 * @param error The Eina_Error to change the message of
131 * @param msg The description of the error. This string will be
132 * duplicated only if the error was registered with @ref eina_error_msg_register
133 * otherwise it must remain intact for the duration.
134 * @return EINA_TRUE if successful, EINA_FALSE on error
135 *
136 * This function modifies the message associated with @p error and changes
137 * it to @p msg. If the error was previously registered by @ref eina_error_msg_static_register
138 * then the string will not be duplicated, otherwise the previous message
139 * will be unrefed and @p msg copied.
140 *
141 * @see eina_error_msg_register()
142 */
143EAPI Eina_Bool eina_error_msg_modify(Eina_Error error,
144 const char *msg) EINA_ARG_NONNULL(2);
145
146/**
147 * @brief Return the last set error.
148 *
149 * @return The last error.
150 *
151 * This function returns the last error set by eina_error_set(). The
152 * description of the message is returned by eina_error_msg_get().
153 */
154EAPI Eina_Error eina_error_get(void);
155
156/**
157 * @brief Set the last error.
158 *
159 * @param err The error identifier.
160 *
161 * This function sets the last error identifier. The last error can be
162 * retrieved with eina_error_get().
163 *
164 * @note This is also used to clear previous errors, in that case @p err should
165 * be @c 0.
166 */
167EAPI void eina_error_set(Eina_Error err);
168
169/**
170 * @brief Return the description of the given an error number.
171 *
172 * @param error The error number.
173 * @return The description of the error.
174 *
175 * This function returns the description of an error that has been
176 * registered with eina_error_msg_register(). If an incorrect error is
177 * given, then @c NULL is returned.
178 */
179EAPI const char *eina_error_msg_get(Eina_Error error) EINA_PURE;
180
181/**
182 * @brief Find the #Eina_Error corresponding to a message string
183 * @param msg The error message string to match (NOT #NULL)
184 * @return The #Eina_Error matching @p msg, or 0 on failure
185 * This function attempts to match @p msg with its corresponding #Eina_Error value.
186 * If no such value is found, 0 is returned.
187 */
188EAPI Eina_Error eina_error_find(const char *msg) EINA_ARG_NONNULL(1) EINA_PURE;
189
190/**
191 * @}
192 */
193
194/**
195 * @}
196 */
197
198#endif /* EINA_ERROR_H_ */
diff --git a/libraries/eina/src/include/eina_file.h b/libraries/eina/src/include/eina_file.h
new file mode 100644
index 0000000..01ef8f5
--- /dev/null
+++ b/libraries/eina/src/include/eina_file.h
@@ -0,0 +1,392 @@
1/* EINA - EFL data type library
2 * Copyright (C) 2007-2008 Jorge Luis Zapata Muga
3 * 2011 Cedric Bail
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library;
17 * if not, see <http://www.gnu.org/licenses/>.
18 */
19
20#ifndef EINA_FILE_H_
21#define EINA_FILE_H_
22
23#include <limits.h>
24#include <time.h>
25
26#include "eina_types.h"
27#include "eina_array.h"
28#include "eina_iterator.h"
29
30
31/**
32 * @page eina_file_example_01_page
33 * @dontinclude eina_file_01.c
34 *
35 * For brevity includes, variable declarations and initialization was omitted
36 * from this page, however the full source code can be seen @ref
37 * eina_file_example_01 "here".
38 *
39 * Here we have a simple callback to print the name of a file and the path that
40 * contains it:
41 * @skip static
42 * @until }
43 *
44 * We can use this callback in the following call:
45 * @skipline eina_file_dir_list
46 *
47 * The above was a way to print the files in a directory, but it is not the only
48 * one:
49 * @until iterator_free
50 *
51 * And now two ways to get more information than just file names:
52 * @until iterator_free
53 * @until iterator_free
54 *
55 * The above ways of getting files on a list may produce the same output, but
56 * they have an important difference, eina_file_direct_ls() will @b not call
57 * stat, this means that on some systems it might not have file type
58 * information. On the other hand it might be faster than eina_file_stat_ls().
59 */
60/**
61 * @page eina_file_example_01
62 * @include eina_file_01.c
63 * @example eina_file_01.c
64 */
65/**
66 * @addtogroup Eina_Tools_Group Tools
67 *
68 * @{
69 */
70/**
71 * @addtogroup Eina_File_Group File
72 *
73 * @brief Functions to handle files and directories.
74 *
75 * This functions make it easier to do a number o file and directory operations
76 * such as getting the list of files in a directory, spliting paths and finding
77 * out file size and type.
78 *
79 * @warning All functions in this group are @b blocking which means they make
80 * take a long time to return, use them carefully.
81 *
82 * See an example @ref eina_file_example_01_page "here".
83 *
84 * @{
85 */
86
87/**
88 * @typedef Eina_File_Direct_Info
89 * A typedef to #_Eina_File_Direct_Info.
90 */
91typedef struct _Eina_File_Direct_Info Eina_File_Direct_Info;
92
93/**
94 * @typedef Eina_File_Dir_List_Cb
95 * Type for a callback to be called when iterating over the files of a
96 * directory.
97 */
98typedef void (*Eina_File_Dir_List_Cb)(const char *name, const char *path, void *data);
99
100/**
101 * @typedef Eina_File_Type
102 * file type in Eina_File_Direct_Info.
103 */
104typedef enum {
105 EINA_FILE_UNKNOWN, /**< Unknown file type. */
106 EINA_FILE_FIFO, /**< Named pipe (FIFO) type (unused on Windows). */
107 EINA_FILE_CHR, /**< Character device type (unused on Windows). */
108 EINA_FILE_DIR, /**< Directory type. */
109 EINA_FILE_BLK, /**< Block device type (unused on Windows). */
110 EINA_FILE_REG, /**< Regular file type. */
111 EINA_FILE_LNK, /**< Symbolic link type. */
112 EINA_FILE_SOCK, /**< UNIX domain socket type (unused on Windows). */
113 EINA_FILE_WHT /**< Whiteout file type (unused on Windows). */
114} Eina_File_Type;
115
116typedef struct _Eina_File Eina_File;
117
118typedef enum {
119 EINA_FILE_RANDOM, /**< Advise random memory access to the mapped memory. */
120 EINA_FILE_SEQUENTIAL, /**< Advise sequential memory access to the mapped memory. */
121 EINA_FILE_WILLNEED, /**< Advise need for all the mapped memory. */
122 EINA_FILE_POPULATE /**< Request all the mapped memory. */
123} Eina_File_Populate;
124
125/* Why do this? Well PATH_MAX may vary from when eina itself is compiled
126 * to when the app using eina is compiled. exposing the path buffer below
127 * can't safely and portably vary based on how/when you compile. it should
128 * always be the same for both eina inside AND for apps outside that use eina
129 * so define this to 8192 - most PATH_MAX values are like 4096 or 1024 (with
130 * windows i think being 260), so 8192 should cover almost all cases. there
131 * is a possibility that PATH_MAX could be more than 8192. if anyone spots
132 * a path_max that is bigger - let us know, but, for now we will assume
133 * it never happens */
134#define EINA_PATH_MAX 8192
135/**
136 * @struct _Eina_File_Direct_Info
137 * A structure to store informations of a path.
138 */
139struct _Eina_File_Direct_Info
140{
141 size_t path_length; /**< size of the whole path */
142 size_t name_length; /**< size of the filename/basename component */
143 size_t name_start; /**< where the filename/basename component starts */
144 Eina_File_Type type; /**< file type */
145 char path[EINA_PATH_MAX]; /**< the path */
146};
147
148/**
149 * @def EINA_FILE_DIR_LIST_CB
150 * @brief cast to an #Eina_File_Dir_List_Cb.
151 *
152 * @param function The function to cast.
153 *
154 * This macro casts @p function to Eina_File_Dir_List_Cb.
155 */
156#define EINA_FILE_DIR_LIST_CB(function) ((Eina_File_Dir_List_Cb)function)
157
158
159/**
160 * @brief List all files on the directory calling the function for every file found.
161 *
162 * @param dir The directory name.
163 * @param recursive Iterate recursively in the directory.
164 * @param cb The callback to be called.
165 * @param data The data to pass to the callback.
166 * @return #EINA_TRUE on success, #EINA_FALSE otherwise.
167 *
168 * This function calls @p cb for each file that is in @p dir. To have @p cb
169 * called on files that are in subdirectories of @p dir @p recursive should be
170 * EINA_TRUE. In other words if @p recursive is EINA_FALSE, only direct children
171 * of @p dir will be operated on, if @p recursive is EINA_TRUE the entire tree
172 * of files that is below @p dir will be operated on.
173 *
174 * If @p cb or @p dir are @c NULL, or if @p dir is a string of size 0,
175 * or if @p dir can not be opened, this function returns #EINA_FALSE
176 * immediately. otherwise, it returns #EINA_TRUE.
177 */
178EAPI Eina_Bool eina_file_dir_list(const char *dir,
179 Eina_Bool recursive,
180 Eina_File_Dir_List_Cb cb,
181 void *data) EINA_ARG_NONNULL(1, 3);
182
183/**
184 * @brief Split a path according to the delimiter of the filesystem.
185 *
186 * @param path The path to split.
187 * @return An array of the parts of the path to split.
188 *
189 * This function splits @p path according to the delimiter of the used
190 * filesystem. If @p path is @c NULL or if the array can not be
191 * created, @c NULL is returned, otherwise, an array with each part of @p path
192 * is returned.
193 */
194EAPI Eina_Array *eina_file_split(char *path) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1) EINA_MALLOC;
195
196/**
197 * @brief Get an iterator to list the content of a directory.
198 *
199 * @param dir The name of the directory to list
200 * @return Return an Eina_Iterator that will walk over the files and directories
201 * in @p dir. On failure it will return NULL.
202 *
203 * Returns an iterator for shared strings, the name of each file in @p dir will
204 * only be fetched when advancing the iterator, which means there is very little
205 * cost associated with creating the list and stopping halfway through it.
206 *
207 * @warning The iterator will hand the user a stringshared value with the full
208 * path. The user must free the string using eina_stringshare_del() on it.
209 *
210 * @note The container for the iterator is of type DIR*.
211 * @note The iterator will walk over '.' and '..' without returning them.
212 *
213 * @see eina_file_direct_ls()
214 */
215EAPI Eina_Iterator *eina_file_ls(const char *dir) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1) EINA_MALLOC;
216
217/**
218 * @brief Get an iterator to list the content of a directory, with direct
219 * information.
220 *
221 * @param dir The name of the directory to list
222 *
223 * @return Return an Eina_Iterator that will walk over the files and
224 * directory in the pointed directory. On failure it will
225 * return NULL.
226 *
227 * Returns an iterator for Eina_File_Direct_Info, the name of each file in @p
228 * dir will only be fetched when advancing the iterator, which means there is
229 * cost associated with creating the list and stopping halfway through it.
230 *
231 * @warning The Eina_File_Direct_Info returned by the iterator <b>must not</b>
232 * be modified in any way.
233 * @warning When the iterator is advanced or deleted the Eina_File_Direct_Info
234 * returned is no longer valid.
235 *
236 * @note The container for the iterator is of type DIR*.
237 * @note The iterator will walk over '.' and '..' without returning them.
238 * @note The difference between this function ahd eina_file_direct_ls() is that
239 * it guarantees the file type information will be correct incurring a
240 * possible performance penalty.
241 *
242 * @see eina_file_direct_ls()
243 */
244EAPI Eina_Iterator *eina_file_stat_ls(const char *dir) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1) EINA_MALLOC;
245
246/**
247 * @brief Get an iterator to list the content of a directory, with direct
248 * information.
249 *
250 * @param dir The name of the directory to list
251 *
252 * @return Return an Eina_Iterator that will walk over the files and
253 * directory in the pointed directory. On failure it will
254 * return NULL.
255 *
256 * Returns an iterator for Eina_File_Direct_Info, the name of each file in @p
257 * dir will only be fetched when advancing the iterator, which means there is
258 * cost associated with creating the list and stopping halfway through it.
259 *
260 * @warning If readdir_r doesn't contain file type information file type will
261 * be DT_UNKNOW.
262 * @warning The Eina_File_Direct_Info returned by the iterator <b>must not</b>
263 * be modified in any way.
264 * @warning When the iterator is advanced or deleted the Eina_File_Direct_Info
265 * returned is no longer valid.
266 *
267 * @note The container for the iterator is of type DIR*.
268 * @note The iterator will walk over '.' and '..' without returning them.
269 * @note The difference between this function ahd eina_file_stat_ls() is that
270 * it may not get the file type information however it is likely to be
271 * faster.
272 *
273 * @see eina_file_ls()
274 */
275EAPI Eina_Iterator *eina_file_direct_ls(const char *dir) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1) EINA_MALLOC;
276
277/**
278 * @brief Sanitize file path.
279 *
280 * @param path The path to sanitize
281 *
282 * @return an allocated string with the sanitized path.
283 *
284 * This function take care of adding the current working directory if it's a
285 * relative path and also remove all '..' and '//' reference in the original
286 * path.
287 *
288 * @since 1.1
289 */
290EAPI char *eina_file_path_sanitize(const char *path);
291
292/**
293 * @brief Get a read-only handler to a file.
294 *
295 * @param name Filename to open
296 * @param shared Requested a shm
297 *
298 * Opens a file in read-only mode. @p name should be an absolute path. An
299 * Eina_File handle can be shared among multiple instances if @p shared is
300 * EINA_TRUE.
301 *
302 * @since 1.1
303 */
304EAPI Eina_File *eina_file_open(const char *name, Eina_Bool shared) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1) EINA_MALLOC;
305
306/**
307 * @brief Unref file handler.
308 *
309 * @param file File handler to unref.
310 *
311 * Decremente file's refcount and if it reaches zero close it.
312 *
313 * @since 1.1
314 */
315EAPI void eina_file_close(Eina_File *file);
316
317/**
318 * @brief Get file size at open time.
319 *
320 * @param file The file handler to request the size from.
321 * @return The length of the file.
322 *
323 * @since 1.1
324 */
325EAPI size_t eina_file_size_get(Eina_File *file);
326
327/**
328 * @brief Get the last modification time of an open file.
329 *
330 * @param file The file handler to request the modification time from.
331 * @return The last modification time.
332 *
333 * @since 1.1
334 */
335EAPI time_t eina_file_mtime_get(Eina_File *file);
336
337/**
338 * @brief Get the filename of an open file.
339 *
340 * @param file The file handler to request the name from.
341 * @return Stringshared filename of the file.
342 *
343 * @since 1.1
344 */
345EAPI const char *eina_file_filename_get(Eina_File *file);
346
347/**
348 * @brief Map all the file to a buffer.
349 *
350 * @param file The file handler to map in memory
351 * @param rule The rule to apply to the mapped memory
352 * @return A pointer to a buffer that map all the file content. @c NULL if it fail.
353 *
354 * @since 1.1
355 */
356EAPI void *eina_file_map_all(Eina_File *file, Eina_File_Populate rule);
357
358/**
359 * @brief Map a part of the file.
360 *
361 * @param file The file handler to map in memory
362 * @param rule The rule to apply to the mapped memory
363 * @param offset The offset inside the file
364 * @param length The length of the memory to map
365 * @return A valid pointer to the system memory with @p length valid byte in it. And @c NULL if not inside the file or anything else goes wrong.
366 *
367 * This does handle refcounting so it will share map that target the same memory area.
368 *
369 * @since 1.1
370 */
371EAPI void *eina_file_map_new(Eina_File *file, Eina_File_Populate rule,
372 unsigned long int offset, unsigned long int length);
373
374/**
375 * @brief Unref and unmap memory if possible.
376 *
377 * @param file The file handler to unmap memory from.
378 * @param map Memory map to unref and unmap.
379 *
380 * @since 1.1
381 */
382EAPI void eina_file_map_free(Eina_File *file, void *map);
383
384/**
385 * @}
386 */
387
388/**
389 * @}
390 */
391
392#endif /* EINA_FILE_H_ */
diff --git a/libraries/eina/src/include/eina_fp.h b/libraries/eina/src/include/eina_fp.h
new file mode 100644
index 0000000..c73dc16
--- /dev/null
+++ b/libraries/eina/src/include/eina_fp.h
@@ -0,0 +1,111 @@
1/* EINA - EFL data type library
2 * Copyright (C) 2007-2008 Jorge Luis Zapata Muga
3 * Copyright (C) 2009 Cedric BAIL
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library;
17 * if not, see <http://www.gnu.org/licenses/>.
18 */
19
20#ifndef EINA_FP_H_
21# define EINA_FP_H_
22
23#include "eina_types.h"
24
25#ifdef _MSC_VER
26typedef unsigned __int64 uint64_t;
27typedef signed __int64 int64_t;
28typedef signed int int32_t;
29#else
30# include <stdint.h>
31#endif
32
33#define EINA_F32P32_PI 0x00000003243f6a89
34
35typedef int64_t Eina_F32p32;
36typedef int32_t Eina_F16p16;
37typedef int32_t Eina_F8p24;
38
39static inline Eina_F32p32 eina_f32p32_int_from(int32_t v);
40static inline int32_t eina_f32p32_int_to(Eina_F32p32 v);
41static inline Eina_F32p32 eina_f32p32_double_from(double v);
42static inline double eina_f32p32_double_to(Eina_F32p32 v);
43
44static inline Eina_F32p32 eina_f32p32_add(Eina_F32p32 a,
45 Eina_F32p32 b);
46static inline Eina_F32p32 eina_f32p32_sub(Eina_F32p32 a,
47 Eina_F32p32 b);
48static inline Eina_F32p32 eina_f32p32_mul(Eina_F32p32 a,
49 Eina_F32p32 b);
50static inline Eina_F32p32 eina_f32p32_scale(Eina_F32p32 a,
51 int b);
52static inline Eina_F32p32 eina_f32p32_div(Eina_F32p32 a,
53 Eina_F32p32 b);
54static inline Eina_F32p32 eina_f32p32_sqrt(Eina_F32p32 a);
55static inline unsigned int eina_f32p32_fracc_get(Eina_F32p32 v);
56
57// dont use llabs - issues if not on 64bit
58#define eina_fp32p32_llabs(a) ((a < 0) ? -(a) : (a))
59
60EAPI Eina_F32p32 eina_f32p32_cos(Eina_F32p32 a);
61EAPI Eina_F32p32 eina_f32p32_sin(Eina_F32p32 a);
62
63static inline Eina_F16p16 eina_f16p16_int_from(int32_t v);
64static inline int32_t eina_f16p16_int_to(Eina_F16p16 v);
65static inline Eina_F16p16 eina_f16p16_float_from(float v);
66static inline float eina_f16p16_float_to(Eina_F16p16 v);
67
68static inline Eina_F16p16 eina_f16p16_add(Eina_F16p16 a,
69 Eina_F16p16 b);
70static inline Eina_F16p16 eina_f16p16_sub(Eina_F16p16 a,
71 Eina_F16p16 b);
72static inline Eina_F16p16 eina_f16p16_mul(Eina_F16p16 a,
73 Eina_F16p16 b);
74static inline Eina_F16p16 eina_f16p16_scale(Eina_F16p16 a,
75 int b);
76static inline Eina_F16p16 eina_f16p16_div(Eina_F16p16 a,
77 Eina_F16p16 b);
78static inline Eina_F16p16 eina_f16p16_sqrt(Eina_F16p16 a);
79static inline unsigned int eina_f16p16_fracc_get(Eina_F16p16 v);
80
81static inline Eina_F8p24 eina_f8p24_int_from(int32_t v);
82static inline int32_t eina_f8p24_int_to(Eina_F8p24 v);
83static inline Eina_F8p24 eina_f8p24_float_from(float v);
84static inline float eina_f8p24_float_to(Eina_F8p24 v);
85
86static inline Eina_F8p24 eina_f8p24_add(Eina_F8p24 a,
87 Eina_F8p24 b);
88static inline Eina_F8p24 eina_f8p24_sub(Eina_F8p24 a,
89 Eina_F8p24 b);
90static inline Eina_F8p24 eina_f8p24_mul(Eina_F8p24 a,
91 Eina_F8p24 b);
92static inline Eina_F8p24 eina_f8p24_scale(Eina_F8p24 a,
93 int b);
94static inline Eina_F8p24 eina_f8p24_div(Eina_F8p24 a,
95 Eina_F8p24 b);
96static inline Eina_F8p24 eina_f8p24_sqrt(Eina_F8p24 a);
97static inline unsigned int eina_f8p24_fracc_get(Eina_F8p24 v);
98
99static inline Eina_F32p32 eina_f16p16_to_f32p32(Eina_F16p16 a);
100static inline Eina_F32p32 eina_f8p24_to_f32p32(Eina_F8p24 a);
101static inline Eina_F16p16 eina_f32p32_to_f16p16(Eina_F32p32 a);
102static inline Eina_F16p16 eina_f8p24_to_f16p16(Eina_F8p24 a);
103static inline Eina_F8p24 eina_f32p32_to_f8p24(Eina_F32p32 a);
104static inline Eina_F8p24 eina_f16p16_to_f8p24(Eina_F16p16 a);
105
106#include "eina_inline_f32p32.x"
107#include "eina_inline_f16p16.x"
108#include "eina_inline_f8p24.x"
109#include "eina_inline_fp.x"
110
111#endif
diff --git a/libraries/eina/src/include/eina_hamster.h b/libraries/eina/src/include/eina_hamster.h
new file mode 100644
index 0000000..bea759d
--- /dev/null
+++ b/libraries/eina/src/include/eina_hamster.h
@@ -0,0 +1,58 @@
1/* EINA - EFL data type library
2 * Copyright (C) 2008 Cedric Bail
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library;
16 * if not, see <http://www.gnu.org/licenses/>.
17 */
18
19#ifndef EINA_HAMSTER_H_
20#define EINA_HAMSTER_H_
21
22/**
23 * @addtogroup Eina_Hamster_Group Hamster
24 *
25 * @brief These functions provide hamster calls.
26 *
27 * @{
28 */
29
30/**
31 * @addtogroup Eina_Core_Group Core
32 *
33 * @{
34 */
35
36/**
37 * @defgroup Eina_Hamster_Group Hamster
38 */
39
40
41/**
42 * @brief Get the hamster count.
43 *
44 * @return The number of available hamsters.
45 *
46 * This function returns how many hamsters you have.
47 */
48EAPI int eina_hamster_count(void);
49
50/**
51 * @}
52 */
53
54/**
55 * @}
56 */
57
58#endif /* EINA_HAMSTER_H_ */
diff --git a/libraries/eina/src/include/eina_hash.h b/libraries/eina/src/include/eina_hash.h
new file mode 100644
index 0000000..c8eb048
--- /dev/null
+++ b/libraries/eina/src/include/eina_hash.h
@@ -0,0 +1,1040 @@
1/* EINA - EFL data type library
2 * Copyright (C) 2002-2008 Carsten Haitzler, Gustavo Sverzut Barbieri,
3 * Vincent Torri, Jorge Luis Zapata Muga, Cedric Bail
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library;
17 * if not, see <http://www.gnu.org/licenses/>.
18 */
19
20#ifndef EINA_HASH_H_
21#define EINA_HASH_H_
22
23#include "eina_types.h"
24#include "eina_iterator.h"
25
26/**
27 * @page hash_01_example_page Eina_Hash in action
28 * @dontinclude eina_hash_01.c
29 *
30 * We are going to store some tuples into our table, that will map each @a name
31 * to a @a number. The cost to access a given number from the name should be
32 * very small, even with many entries in our table. This is the initial data:
33 * @skip _Phone_Entry
34 * @until // _start_entries
35 *
36 * Before starting to play with the hash, let's write a callback that will be
37 * used to free the elements from it. Since we are just storing strduped
38 * strings, we just need to free them:
39 *
40 * @skip static
41 * @until }
42 *
43 * We also need a callback to iterate over the elements of the list later, so
44 * we are defining it now:
45 *
46 * @skip Eina_Bool
47 * @until }
48 *
49 * Now let's create our @ref Eina_Hash using @ref
50 * eina_hash_string_superfast_new :
51 *
52 * @skip eina_init
53 * @until phone_book
54 *
55 * Now we add the keys and data to the hash using @ref eina_hash_add . This
56 * means that the key is copied inside the table, together with the pointer to
57 * the data (phone numbers).
58 *
59 * @skip for
60 * @until }
61 *
62 * Some basic manipulations with the hash, like finding a value given a key,
63 * deleting an entry, modifying an entry are exemplified in the following lines.
64 * Notice that the @ref eina_hash_modify function returns the old value stored
65 * in that entry, and it needs to be freed, while the @ref eina_hash_del
66 * function already calls our free callback:
67 *
68 * @skip Look for
69 * @until free(
70 *
71 * The @ref eina_hash_set function can be used to set a key-value entry to the
72 * table if it doesn't exist, or to modify an existent entry. It returns the old
73 * entry if it was already set, and NULL otherwise. But since it will
74 * return NULL on error too, we need to check if an error has occurred:
75 *
76 * @skip Modify
77 * @until printf("\n");
78 *
79 * There are different ways of iterate over the entries of a hash. Here we show
80 * two of them: using @ref eina_hash_foreach and @ref Eina_Iterator .
81 *
82 * @skip List of phones
83 * @until eina_iterator_free(it);
84 *
85 * It's also possible to change the key for a specific entry, without having to
86 * remove the entry from the table and adding it again:
87 *
88 * @skipline eina_hash_move
89 *
90 * We can remove all the elements from the table without free the table itself:
91 *
92 * @skip Empty the phone book
93 * @until eina_hash_population
94 *
95 * Or free the the entire table with its content:
96 *
97 * @skipline eina_hash_free
98 *
99 *
100 * The full code for this example can be seen here: @ref eina_hash_01_c
101 */
102
103/**
104 * @page eina_hash_01_c Hash table in action
105 *
106 * @include eina_hash_01.c
107 * @example eina_hash_01.c
108 */
109
110/**
111 * @page hash_02_example_page Different types of tables
112 *
113 * This example shows two more types of hash tables that can be created using
114 * @ref Eina_Hash . For more types, consult the reference documentation of @ref
115 * eina_hash_new.
116 * @include eina_hash_02.c
117 * @example eina_hash_02.c
118 */
119
120/**
121 * @example eina_hash_03.c
122 * Same example as @ref hash_01_example_page but using a "string small" hash
123 * table instead of "string superfast".
124 */
125
126/**
127 * @example eina_hash_04.c
128 * Same example as @ref hash_01_example_page but using a "string djb2" hash
129 * table instead of "string superfast".
130 */
131
132/**
133 * @example eina_hash_05.c
134 * Same example as @ref hash_01_example_page but using a "int32" hash
135 * table instead of "string superfast".
136 */
137
138/**
139 * @example eina_hash_06.c
140 * Same example as @ref hash_01_example_page but using a "int64" hash
141 * table instead of "string superfast".
142 */
143
144/**
145 * @example eina_hash_07.c
146 * Same example as @ref hash_01_example_page but using a "pointer" hash
147 * table instead of "string superfast".
148 */
149
150/**
151 * @example eina_hash_08.c
152 * This example shows the the usage of eina_hash_add(), eina_hash_add_by_hash(),
153 * eina_hash_direct_add_by_hash(), eina_hash_del(), eina_hash_del_by_key_hash(),
154 * eina_hash_del_by_key(), eina_hash_del_by_data(), eina_hash_find_by_hash() and
155 * eina_hash_modify_by_hash().
156 */
157
158/**
159 * @addtogroup Eina_Hash_Group Hash Table
160 *
161 * @brief Hash table management. Useful for mapping keys to values.
162 *
163 * The hash table is useful for when one wants to implement a table that maps
164 * keys (usually strings) to data, and have relatively fast access time. The
165 * performance is proportional to the load factor of the table (number of
166 * elements / number of buckets). See @ref hashtable_algo for implementation
167 * details.
168 *
169 * Different implementations exists depending on what kind of key will be used
170 * to access the data: strings, integers, pointers, stringshared or your own.
171 *
172 * Eina hash tables can copy the keys when using eina_hash_add() or not when
173 * using eina_hash_direct_add().
174 *
175 * @section hashtable_algo Algorithm
176 *
177 * The Eina_Hash is implemented using an array of N "buckets", where each
178 * bucket is a pointer to a structure that is the head of a <a
179 * href="http://en.wikipedia.org/wiki/Red-black_tree">red-black tree</a>. The
180 * array can then be indexed by the [hash_of_element mod N]. The
181 * hash_of_element is calculated using the hashing function, passed as
182 * parameter to the @ref eina_hash_new function. N is the number of buckets
183 * (array positions), and is calculated based on the buckets_power_size
184 * (argument of @ref eina_hash_new too). The following picture ilustrates the
185 * basic idea:
186 *
187 * @htmlonly
188 * <img src="01_hash-table.png" width="500" />
189 * @endhtmlonly
190 * @image latex 01_hash-table.eps
191 *
192 * Adding an element to the hash table is made of:
193 * @li calculating the hash for that key (using the specified hash function);
194 * @li calculate the array position [hash mod N];
195 * @li add the element to the rbtree on that position.
196 *
197 * The two first steps have constant time, proportional to the hash function
198 * being used. Adding the key to the rbtree will be proportional on the number
199 * of keys on that bucket.
200 *
201 * The average cost of lookup depends on the number of keys per
202 * bucket (load factor) of the table, if the distribution of keys is
203 * sufficiently uniform.
204 *
205 * @section hashtable_perf Performance
206 *
207 * As said before, the performance depends on the load factor. So trying to keep
208 * the load factor as small as possible will improve the hash table performance. But
209 * increasing the buckets_power_size will also increase the memory consumption.
210 * The default hash table creation functions already have a good number of
211 * buckets, enough for most cases. Particularly for strings, if just a few keys
212 * (less than 30) will be added to the hash table, @ref
213 * eina_hash_string_small_new should be used, since it will reduce the memory
214 * consumption for the buckets, and you still won't have many collisions.
215 * However, @ref eina_hash_string_small_new still uses the same hash calculation
216 * function that @ref eina_hash_string_superfast_new, which is more complex than
217 * @ref eina_hash_string_djb2_new. The latter has a faster hash computation
218 * function, but that will imply on a not so good distribution. But if just a
219 * few keys are being added, this is not a problem, it will still have not many
220 * collisions and be faster to calculate the hash than in a hash created with
221 * @ref eina_hash_string_small_new and @ref eina_hash_string_superfast_new.
222 *
223 * A simple comparison between them would be:
224 *
225 * @li @c djb2 - faster hash function - 256 buckets (higher memory consumption)
226 * @li @c string_small - slower hash function but less collisions - 32 buckets
227 * (lower memory consumption)
228 * @li @c string_superfast - slower hash function but less collisions - 256 buckets
229 * (higher memory consumption)
230 *
231 * Basically for a very small number of keys (10 or less), @c djb2 should be
232 * used, or @c string_small if you have a restriction on memory usage. And for a
233 * higher number of keys, @c string_superfast should be always preferred.
234 *
235 * If just stringshared keys are being added, use @ref
236 * eina_hash_stringshared_new. If a lot of keys will be added to the hash table
237 * (e.g. more than 1000), then it's better to increase the buckets_power_size.
238 * See @ref eina_hash_new for more details.
239 *
240 * When adding a new key to a hash table, use @ref eina_hash_add or @ref
241 * eina_hash_direct_add (the latter if this key is already stored elsewhere). If
242 * the key may be already inside the hash table, instead of checking with
243 * @ref eina_hash_find and then doing @ref eina_hash_add, one can use just @ref
244 * eina_hash_set (this will change the data pointed by this key if it was
245 * already present in the table).
246 *
247 * @section hashtable_tutorial Tutorial
248 *
249 * These examples show many Eina_Hash functions in action:
250 * <ul>
251 * <li> @ref hash_01_example_page
252 * <li> @ref hash_02_example_page
253 * <li> Different types of hash in use:
254 * <ul>
255 * <li> @ref eina_hash_03.c "string small"
256 * <li> @ref eina_hash_04.c "string djb2"
257 * <li> @ref eina_hash_05.c "int32"
258 * <li> @ref eina_hash_06.c "int64"
259 * <li> @ref eina_hash_07.c "pointer"
260 * </ul>
261 * <li> @ref eina_hash_08.c "Different add and delete functions"
262 * </ul>
263 */
264
265/**
266 * @addtogroup Eina_Data_Types_Group Data Types
267 *
268 * @{
269 */
270
271/**
272 * @addtogroup Eina_Containers_Group Containers
273 *
274 * @{
275 */
276
277/**
278 * @defgroup Eina_Hash_Group Hash Table
279 *
280 * @{
281 */
282
283/**
284 * @typedef Eina_Hash
285 * Type for a generic hash table.
286 */
287typedef struct _Eina_Hash Eina_Hash;
288
289typedef struct _Eina_Hash_Tuple Eina_Hash_Tuple;
290
291struct _Eina_Hash_Tuple
292{
293 const void *key; /**< The key */
294 void *data; /**< The data associated to the key */
295 unsigned int key_length; /**< The length of the key */
296};
297
298typedef unsigned int (*Eina_Key_Length)(const void *key);
299#define EINA_KEY_LENGTH(Function) ((Eina_Key_Length)Function)
300typedef int (*Eina_Key_Cmp)(const void *key1, int key1_length, const void *key2, int key2_length);
301#define EINA_KEY_CMP(Function) ((Eina_Key_Cmp)Function)
302typedef int (*Eina_Key_Hash)(const void *key, int key_length);
303#define EINA_KEY_HASH(Function) ((Eina_Key_Hash)Function)
304typedef Eina_Bool (*Eina_Hash_Foreach)(const Eina_Hash *hash, const void *key, void *data, void *fdata);
305
306
307/**
308 * @brief Create a new hash table.
309 *
310 * @param key_length_cb The function called when getting the size of the key.
311 * @param key_cmp_cb The function called when comparing the keys.
312 * @param key_hash_cb The function called when getting the values.
313 * @param data_free_cb The function called on each value when the hash table is
314 * freed, or when an item is deleted from it. @c NULL can be passed as
315 * callback.
316 * @param buckets_power_size The size of the buckets.
317 * @return The new hash table.
318 *
319 * This function creates a new hash table using user-defined callbacks
320 * to manage the hash table. On failure, @c NULL is returned and
321 * #EINA_ERROR_OUT_OF_MEMORY is set. If @p key_cmp_cb or @p key_hash_cb
322 * are @c NULL, @c NULL is returned. If @p buckets_power_size is
323 * smaller or equal than 2, or if it is greater or equal than 17,
324 * @c NULL is returned.
325 *
326 * The number of buckets created will be 2 ^ @p buckets_power_size. This means
327 * that if @p buckets_power_size is 5, there will be created 32 buckets. for a
328 * @p buckets_power_size of 8, there will be 256 buckets.
329 *
330 * Pre-defined functions are available to create a hash table. See
331 * eina_hash_string_djb2_new(), eina_hash_string_superfast_new(),
332 * eina_hash_string_small_new(), eina_hash_int32_new(),
333 * eina_hash_int64_new(), eina_hash_pointer_new() and
334 * eina_hash_stringshared_new().
335 */
336EAPI Eina_Hash *eina_hash_new(Eina_Key_Length key_length_cb,
337 Eina_Key_Cmp key_cmp_cb,
338 Eina_Key_Hash key_hash_cb,
339 Eina_Free_Cb data_free_cb,
340 int buckets_power_size) EINA_MALLOC EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(2, 3);
341
342/**
343 * @brief Redefine the callback that clean the data of a hash
344 *
345 * @param hash The given hash table
346 * @param data_free_cb The function called on each value when the hash
347 * table is freed, or when an item is deleted from it. @c NULL can be passed as
348 * callback.
349 * @since 1.1
350 * See @ref eina_hash_new.
351 */
352EAPI void eina_hash_free_cb_set(Eina_Hash *hash, Eina_Free_Cb data_free_cb) EINA_ARG_NONNULL(1);
353
354/**
355 * @brief Create a new hash table using the djb2 algorithm.
356 *
357 * @param data_free_cb The function called on each value when the hash table
358 * is freed, or when an item is deleted from it. @c NULL can be passed as
359 * callback.
360 * @return The new hash table.
361 *
362 * This function creates a new hash table using the djb2 algorithm for
363 * table management and strcmp() to compare the keys. Values can then
364 * be looked up with pointers other than the original key pointer that
365 * was used to add values. On failure, this function returns @c NULL.
366 */
367EAPI Eina_Hash *eina_hash_string_djb2_new(Eina_Free_Cb data_free_cb);
368
369/**
370 * @brief Create a new hash table for use with strings.
371 *
372 * @param data_free_cb The function called on each value when the hash table
373 * is freed, or when an item is deleted from it. @c NULL can be passed as
374 * callback.
375 * @return The new hash table.
376 *
377 * This function creates a new hash table using the superfast algorithm
378 * for table management and strcmp() to compare the keys. Values can
379 * then be looked up with pointers other than the original key pointer
380 * that was used to add values. On failure, this function returns
381 * @c NULL.
382 */
383EAPI Eina_Hash *eina_hash_string_superfast_new(Eina_Free_Cb data_free_cb);
384
385/**
386 * @brief Create a new hash table for use with strings with small bucket size.
387 *
388 * @param data_free_cb The function called on each value when the hash table
389 * is freed, or when an item is deleted from it. @c NULL can be passed as
390 * callback.
391 * @return The new hash table.
392 *
393 * This function creates a new hash table using the superfast algorithm
394 * for table management and strcmp() to compare the keys, but with a
395 * smaller bucket size (compared to eina_hash_string_superfast_new())
396 * which will minimize the memory used by the returned hash
397 * table. Values can then be looked up with pointers other than the
398 * original key pointer that was used to add values. On failure, this
399 * function returns @c NULL.
400 */
401EAPI Eina_Hash *eina_hash_string_small_new(Eina_Free_Cb data_free_cb);
402
403/**
404 * @brief Create a new hash table for use with 32bit integers.
405 *
406 * @param data_free_cb The function called on each value when the hash table
407 * is freed, or when an item is deleted from it. @c NULL can be passed as
408 * callback.
409 * @return The new hash table.
410 *
411 * This function creates a new hash table where keys are 32bit integers.
412 * When adding or looking up in the hash table, pointers to 32bit integers
413 * must be passed. They can be addresses on the stack if you let the
414 * eina_hash copy the key. Values can then
415 * be looked up with pointers other than the original key pointer that was
416 * used to add values. This method is not suitable to match string keys as
417 * it would only match the first character.
418 * On failure, this function returns @c NULL.
419 */
420EAPI Eina_Hash *eina_hash_int32_new(Eina_Free_Cb data_free_cb);
421
422/**
423 * @brief Create a new hash table for use with 64bit integers.
424 *
425 * @param data_free_cb The function called on each value when the hash table
426 * is freed, or when an item is deleted from it. @c NULL can be passed as
427 * callback.
428 * @return The new hash table.
429 *
430 * This function creates a new hash table where keys are 64bit integers.
431 * When adding or looking up in the hash table, pointers to 64bit integers
432 * must be passed. They can be addresses on the stack. Values can then
433 * be looked up with pointers other than the original key pointer that was
434 * used to add values. This method is not suitable to match string keys as
435 * it would only match the first character.
436 * On failure, this function returns @c NULL.
437 */
438EAPI Eina_Hash *eina_hash_int64_new(Eina_Free_Cb data_free_cb);
439
440/**
441 * @brief Create a new hash table for use with pointers.
442 *
443 * @param data_free_cb The function called on each value when the hash table
444 * is freed, or when an item is deleted from it. @c NULL can be passed as
445 * callback.
446 * @return The new hash table.
447 *
448 * This function creates a new hash table using the int64/int32 algorithm for
449 * table management and dereferenced pointers to compare the
450 * keys. Values can then be looked up with pointers other than the
451 * original key pointer that was used to add values. This method may
452 * appear to be able to match string keys, actually it only matches
453 * the first character. On failure, this function returns @c NULL.
454 */
455EAPI Eina_Hash *eina_hash_pointer_new(Eina_Free_Cb data_free_cb);
456
457/**
458 * @brief Create a new hash table optimized for stringshared values.
459 *
460 * @param data_free_cb The function called on each value when the hash table
461 * is freed, or when an item is deleted from it. @c NULL can be passed as
462 * callback.
463 * @return The new hash table.
464 *
465 * This function creates a new hash table optimized for stringshared
466 * values. Values CAN NOT be looked up with pointers not
467 * equal to the original key pointer that was used to add a value. On failure,
468 * this function returns @c NULL.
469 *
470 * Excerpt of code that will NOT work with this type of hash:
471 *
472 * @code
473 * extern Eina_Hash *hash;
474 * extern const char *value;
475 * const char *a = eina_stringshare_add("key");
476 *
477 * eina_hash_add(hash, a, value);
478 * eina_hash_find(hash, "key")
479 * @endcode
480 */
481EAPI Eina_Hash *eina_hash_stringshared_new(Eina_Free_Cb data_free_cb);
482
483/**
484 * @brief Add an entry to the given hash table.
485 *
486 * @param hash The given hash table. Cannot be @c NULL.
487 * @param key A unique key. Cannot be @c NULL.
488 * @param data Data to associate with the string given by @p key. Cannot be @c
489 * NULL.
490 * @return #EINA_FALSE if an error occurred, #EINA_TRUE otherwise.
491 *
492 * This function adds @p key to @p hash. @p key is
493 * expected to be unique within the hash table. Key uniqueness varies
494 * depending on the type of @p hash: a stringshared @ref Eina_Hash
495 * need to have unique pointers (which implies unique strings).
496 * All other string hash types require the strings
497 * themselves to be unique. Pointer, int32 and int64 hashes need to have these
498 * values as unique. Failure to use sufficient uniqueness will
499 * result in unexpected results when inserting data pointers accessed
500 * with eina_hash_find(), and removed with eina_hash_del(). Key
501 * strings are case sensitive. If an error occurs, eina_error_get()
502 * should be used to determine if an allocation error occurred during
503 * this function. This function returns #EINA_FALSE if an error
504 * occurred, #EINA_TRUE otherwise.
505 */
506EAPI Eina_Bool eina_hash_add(Eina_Hash *hash,
507 const void *key,
508 const void *data) EINA_ARG_NONNULL(1, 2, 3);
509
510/**
511 * @brief Add an entry to the given hash table without duplicating the string
512 * key.
513 *
514 * @param hash The given hash table. Cannot be @c NULL.
515 * @param key A unique key. Cannot be @c NULL.
516 * @param data Data to associate with the string given by @p key. Cannot be @c
517 * NULL
518 * @return #EINA_FALSE if an error occurred, #EINA_TRUE otherwise.
519 *
520 * This function adds @p key to @p hash. @p key is
521 * expected to be unique within the hash table. Key uniqueness varies
522 * depending on the type of @p hash: a stringshared @ref Eina_Hash
523 * need have unique pointers (which implies unique strings).
524 * All other string hash types require the strings
525 * themselves to be unique. Pointer, int32 and int64 hashes need to have these
526 * values as unique. Failure to use sufficient uniqueness will
527 * result in unexpected results when inserting data pointers accessed
528 * with eina_hash_find(), and removed with eina_hash_del(). This
529 * function does not make a copy of @p key, so it must be a string
530 * constant or stored elsewhere ( in the object being added). Key
531 * strings are case sensitive. If an error occurs, eina_error_get()
532 * should be used to determine if an allocation error occurred during
533 * this function. This function returns #EINA_FALSE if an error
534 * occurred, #EINA_TRUE otherwise.
535 */
536EAPI Eina_Bool eina_hash_direct_add(Eina_Hash *hash,
537 const void *key,
538 const void *data) EINA_ARG_NONNULL(1, 2, 3);
539
540/**
541 * @brief Remove the entry identified by a key or a data from the given
542 * hash table.
543 *
544 * @param hash The given hash table.
545 * @param key The key.
546 * @param data The data pointer to remove if the key is @c NULL.
547 * @return #EINA_FALSE if an error occurred, #EINA_TRUE otherwise.
548 *
549 * This function removes the entry identified by @p key or @p data
550 * from @p hash. If a free function was given to the
551 * callback on creation, it will be called for the data being
552 * deleted. If @p hash is @c NULL, the functions returns immediately
553 * #EINA_FALSE. If @p key is @c NULL, then @p data is used to find the a
554 * match to remove, otherwise @p key is used and @p data is not
555 * required and can be @c NULL. This function returns #EINA_FALSE if
556 * an error occurred, #EINA_TRUE otherwise.
557 *
558 * @note if you know you already have the key, use
559 * eina_hash_del_by_key() or eina_hash_del_by_key_hash(). If you
560 * know you don't have the key, use eina_hash_del_by_data()
561 * directly.
562 */
563EAPI Eina_Bool eina_hash_del(Eina_Hash *hash,
564 const void *key,
565 const void *data) EINA_ARG_NONNULL(1);
566
567/**
568 * @brief Retrieve a specific entry in the given hash table.
569 *
570 * @param hash The given hash table.
571 * @param key The key of the entry to find.
572 * @return The data pointer for the stored entry on success, @c NULL
573 * otherwise.
574 *
575 * This function retrieves the entry associated to @p key in
576 * @p hash. If @p hash is @c NULL, this function returns immediately
577 * @c NULL. This function returns the data pointer on success, @c NULL
578 * otherwise.
579 */
580EAPI void *eina_hash_find(const Eina_Hash *hash,
581 const void *key) EINA_ARG_NONNULL(1, 2);
582
583/**
584 * @brief Modify the entry pointer at the specified key and return the old
585 * entry.
586 * @param hash The given hash table.
587 * @param key The key of the entry to modify.
588 * @param data The data to replace the old entry.
589 * @return The data pointer for the old stored entry on success, or
590 * @c NULL otherwise.
591 *
592 * This function modifies the data of @p key with @p data in @p
593 * hash. If no entry is found, nothing is added to @p hash. On success
594 * this function returns the old entry, otherwise it returns @c NULL.
595 */
596EAPI void *eina_hash_modify(Eina_Hash *hash,
597 const void *key,
598 const void *data) EINA_ARG_NONNULL(1, 2, 3);
599
600/**
601 * @brief Modify the entry pointer at the specified key and return the
602 * old entry or add the entry if not found.
603 *
604 * @param hash The given hash table.
605 * @param key The key of the entry to modify.
606 * @param data The data to replace the old entry
607 * @return The data pointer for the old stored entry, or @c NULL
608 * otherwise.
609 *
610 * This function modifies the data of @p key with @p data in @p
611 * hash. If no entry is found, @p data is added to @p hash with the
612 * key @p key. On success this function returns the old entry,
613 * otherwise it returns @c NULL. To check for errors, use
614 * eina_error_get().
615 */
616EAPI void *eina_hash_set(Eina_Hash *hash,
617 const void *key,
618 const void *data) EINA_ARG_NONNULL(1, 2);
619
620/**
621 * @brief Change the key associated with a data without triggering the
622 * free callback.
623 *
624 * @param hash The given hash table.
625 * @param old_key The current key associated with the data
626 * @param new_key The new key to associate data with
627 * @return EINA_FALSE in any case but success, EINA_TRUE on success.
628 *
629 * This function allows for the move of data from one key to another,
630 * but does not call the Eina_Free_Cb associated with the hash table
631 * when destroying the old key.
632 */
633EAPI Eina_Bool eina_hash_move(Eina_Hash *hash,
634 const void *old_key,
635 const void *new_key) EINA_ARG_NONNULL(1, 2, 3);
636
637/**
638 * Free the given hash table resources.
639 *
640 * @param hash The hash table to be freed.
641 *
642 * This function frees up all the memory allocated to storing @p hash,
643 * and call the free callback if it has been passed to the hash table
644 * at creation time. If no free callback has been passed, any entries
645 * in the table that the program has no more pointers for elsewhere
646 * may now be lost, so this should only be called if the program has
647 * already freed any allocated data in the hash table or has the
648 * pointers for data in the table stored elsewhere as well. If @p hash
649 * is @c NULL, the function returns immediately.
650 *
651 * Example:
652 * @code
653 * extern Eina_Hash *hash;
654 *
655 * eina_hash_free(hash);
656 * hash = NULL;
657 * @endcode
658 */
659EAPI void eina_hash_free(Eina_Hash *hash) EINA_ARG_NONNULL(1);
660
661/**
662 * Free the given hash table buckets resources.
663 *
664 * @param hash The hash table whose buckets have to be freed.
665 *
666 * This function frees up all the memory allocated to storing the
667 * buckets of @p hash, and calls the free callback on all hash table
668 * buckets if it has been passed to the hash table at creation time,
669 * then frees the buckets. If no free callback has been passed, no
670 * buckets value will be freed. If @p hash is @c NULL, the function
671 * returns immediately.
672 */
673EAPI void eina_hash_free_buckets(Eina_Hash *hash) EINA_ARG_NONNULL(1);
674
675/**
676 * @brief Returns the number of entries in the given hash table.
677 *
678 * @param hash The given hash table.
679 * @return The number of entries in the hash table.
680 *
681 * This function returns the number of entries in @p hash, or 0 on
682 * error. If @p hash is @c NULL, 0 is returned.
683 */
684EAPI int eina_hash_population(const Eina_Hash *hash) EINA_ARG_NONNULL(1);
685
686/**
687 * @brief Add an entry to the given hash table.
688 *
689 * @param hash The given hash table. Cannot be @c NULL.
690 * @param key A unique key. Cannot be @c NULL.
691 * @param key_length The length of the key.
692 * @param key_hash The hash that will always match key.
693 * @param data The data to associate with the string given by the key. Cannot be
694 * @c NULL.
695 * @return #EINA_FALSE if an error occurred, #EINA_TRUE otherwise.
696 *
697 * This function adds @p key to @p hash. @p hash, @p key and @p data
698 * cannot be @c NULL, in that case #EINA_FALSE is returned. @p key is
699 * expected to be a unique within the hash table. Otherwise,
700 * one cannot be sure which inserted data pointer will be accessed
701 * with @ref eina_hash_find, and removed with @ref eina_hash_del. Do
702 * not forget to count '\\0' for string when setting the value of
703 * @p key_length. @p key_hash is expected to always match
704 * @p key. Otherwise, one cannot be sure to find it again with @ref
705 * eina_hash_find_by_hash. Key strings are case sensitive. If an error
706 * occurs, eina_error_get() should be used to determine if an
707 * allocation error occurred during this function. This function
708 * returns #EINA_FALSE if an error occurred, #EINA_TRUE otherwise.
709 *
710 * @see eina_hash_add()
711 */
712EAPI Eina_Bool eina_hash_add_by_hash(Eina_Hash *hash,
713 const void *key,
714 int key_length,
715 int key_hash,
716 const void *data) EINA_ARG_NONNULL(1, 2, 5);
717
718/**
719 * @brief Add an entry to the given hash table and do not duplicate the string
720 * key.
721 *
722 * @param hash The given hash table. Cannot be @c NULL.
723 * @param key A unique key. Cannot be @c NULL.
724 * @param key_length Should be the length of @p key (don't forget to count
725 * '\\0' for string).
726 * @param key_hash The hash that will always match key.
727 * @param data Data to associate with the string given by @p key. Cannot be @c
728 * NULL.
729 * @return #EINA_FALSE if an error occurred, #EINA_TRUE otherwise.
730 *
731 * This function adds @p key to @p hash. @p hash, @p key and @p data
732 * can be @c NULL, in that case #EINA_FALSE is returned. @p key is
733 * expected to be unique within the hash table. Otherwise,
734 * one cannot be sure which inserted data pointer will be accessed
735 * with @ref eina_hash_find, and removed with @ref eina_hash_del. This
736 * function does not make a copy of @p key so it must be a string
737 * constant or stored elsewhere (in the object being added). Do
738 * not forget to count '\\0' for string when setting the value of
739 * @p key_length. @p key_hash is expected to always match
740 * @p key. Otherwise, one cannot be sure to find it again with @ref
741 * eina_hash_find_by_hash. Key strings are case sensitive. If an error
742 * occurs, eina_error_get() should be used to determine if an
743 * allocation error occurred during this function. This function
744 * returns #EINA_FALSE if an error occurred, #EINA_TRUE otherwise.
745 *
746 * @see eina_hash_direct_add()
747 */
748EAPI Eina_Bool eina_hash_direct_add_by_hash(Eina_Hash *hash,
749 const void *key,
750 int key_length,
751 int key_hash,
752 const void *data) EINA_ARG_NONNULL(1, 2, 5);
753
754/**
755 * @brief Remove the entry identified by a key and a key hash from the given
756 * hash table.
757 *
758 * @param hash The given hash table. Cannot be @c NULL.
759 * @param key The key. Cannot be @c NULL.
760 * @param key_length The length of the key.
761 * @param key_hash The hash that always match the key.
762 * @return #EINA_FALSE if an error occurred, #EINA_TRUE otherwise.
763 *
764 * This function removes the entry identified by @p key and
765 * @p key_hash from @p hash. If a free function was given to the
766 * callback on creation, it will be called for the data being
767 * deleted. Do not forget to count '\\0' for string when setting the
768 * value of @p key_length. If @p hash or @p key are @c NULL, the
769 * functions returns immediately #EINA_FALSE. This function returns
770 * #EINA_FALSE if an error occurred, #EINA_TRUE otherwise.
771 *
772 * @note if you don't have the key_hash, use eina_hash_del_by_key() instead.
773 * @note if you don't have the key, use eina_hash_del_by_data() instead.
774 */
775EAPI Eina_Bool eina_hash_del_by_key_hash(Eina_Hash *hash,
776 const void *key,
777 int key_length,
778 int key_hash) EINA_ARG_NONNULL(1, 2);
779
780/**
781 * @brief Remove the entry identified by a key from the given hash table.
782 *
783 * This version will calculate key length and hash by using functions
784 * provided to hash creation function.
785 *
786 * @param hash The given hash table. Cannot be @c NULL.
787 * @param key The key. Cannot be @c NULL.
788 * @return #EINA_FALSE if an error occurred, #EINA_TRUE otherwise.
789 *
790 * This function removes the entry identified by @p key from @p
791 * hash. The key length and hash will be calculated automatically by
792 * using functiond provided to has creation function. If a free
793 * function was given to the callback on creation, it will be called
794 * for the data being deleted. If @p hash or @p key are @c NULL, the
795 * functions returns immediately #EINA_FALSE. This function returns
796 * #EINA_FALSE if an error occurred, #EINA_TRUE otherwise.
797 *
798 * @note if you already have the key_hash, use eina_hash_del_by_key_hash()
799 * instead.
800 * @note if you don't have the key, use eina_hash_del_by_data() instead.
801 */
802EAPI Eina_Bool eina_hash_del_by_key(Eina_Hash *hash,
803 const void *key) EINA_ARG_NONNULL(1, 2);
804
805/**
806 * @brief Remove the entry identified by a data from the given hash table.
807 *
808 * This version is slow since there is no quick access to nodes based on data.
809 *
810 * @param hash The given hash table. Cannot be @c NULL.
811 * @param data The data value to search and remove. Cannot be @c NULL.
812 * @return #EINA_FALSE if an error occurred, #EINA_TRUE otherwise.
813 * thing goes fine.
814 *
815 * This function removes the entry identified by @p data from @p
816 * hash. If a free function was given to the callback on creation, it
817 * will be called for the data being deleted. If @p hash or @p data
818 * are @c NULL, the functions returns immediately #EINA_FALSE. This
819 * function returns #EINA_FALSE if an error occurred, #EINA_TRUE
820 * otherwise.
821 *
822 * @note if you already have the key, use eina_hash_del_by_key() or
823 * eina_hash_del_by_key_hash() instead.
824 */
825EAPI Eina_Bool eina_hash_del_by_data(Eina_Hash *hash,
826 const void *data) EINA_ARG_NONNULL(1, 2);
827
828/**
829 * @brief Remove the entry identified by a key and a key hash or a
830 * data from the given hash table.
831 *
832 * If @p key is @c NULL, then @p data is used to find a match to
833 * remove.
834 *
835 * @param hash The given hash table. Cannot be @c NULL.
836 * @param key The key.
837 * @param key_length The length of the key.
838 * @param key_hash The hash that always match the key.
839 * @param data The data pointer to remove if the key is @c NULL.
840 * @return #EINA_FALSE if an error occurred, #EINA_TRUE otherwise.
841 *
842 * This function removes the entry identified by @p key and
843 * @p key_hash, or @p data, from @p hash. If a free function was given to
844 * the callback on creation, it will be called for the data being
845 * deleted. If @p hash is @c NULL, the functions returns immediately
846 * #EINA_FALSE. If @p key is @c NULL, then @p key_length and @p key_hash
847 * are ignored and @p data is used to find a match to remove,
848 * otherwise @p key and @p key_hash are used and @p data is not
849 * required and can be @c NULL. Do not forget to count '\\0' for
850 * string when setting the value of @p key_length. This function
851 * returns #EINA_FALSE if an error occurred, #EINA_TRUE otherwise.
852 *
853 * @note if you know you already have the key, use eina_hash_del_by_key_hash(),
854 * if you know you don't have the key, use eina_hash_del_by_data()
855 * directly.
856 */
857EAPI Eina_Bool eina_hash_del_by_hash(Eina_Hash *hash,
858 const void *key,
859 int key_length,
860 int key_hash,
861 const void *data) EINA_ARG_NONNULL(1);
862
863/**
864 * @brief Retrieve a specific entry in the given hash table.
865 *
866 * @param hash The given hash table. Cannot be @c NULL.
867 * @param key The key of the entry to find.
868 * @param key_length The length of the key.
869 * @param key_hash The hash that always match the key
870 * @return The data pointer for the stored entry on success, @c NULL
871 * otherwise.
872 *
873 * This function retrieves the entry associated to @p key of length
874 * @p key_length in @p hash. @p key_hash is the hash that always match
875 * @p key. It is ignored if @p key is @c NULL. Do not forget to count
876 * '\\0' for string when setting the value of @p key_length. If
877 * @p hash is @c NULL, this function returns immediately @c NULL. This
878 * function returns the data pointer on success, @c NULL otherwise.
879 */
880EAPI void *eina_hash_find_by_hash(const Eina_Hash *hash,
881 const void *key,
882 int key_length,
883 int key_hash) EINA_ARG_NONNULL(1, 2);
884
885/**
886 * @brief Modify the entry pointer at the specified key and returns
887 * the old entry.
888 *
889 * @param hash The given hash table.
890 * @param key The key of the entry to modify.
891 * @param key_length Should be the length of @p key (don't forget to count
892 * '\\0' for string).
893 * @param key_hash The hash that always match the key. Ignored if @p key is
894 * @c NULL.
895 * @param data The data to replace the old entry, if it exists.
896 * @return The data pointer for the old stored entry, or @c NULL if not
897 * found. If an existing entry is not found, nothing is added to the
898 * hash.
899 */
900EAPI void *eina_hash_modify_by_hash(Eina_Hash *hash,
901 const void *key,
902 int key_length,
903 int key_hash,
904 const void *data) EINA_ARG_NONNULL(1, 2, 5);
905
906/**
907 * @brief Returned a new iterator associated to hash keys.
908 *
909 * @param hash The hash.
910 * @return A new iterator.
911 *
912 * This function returns a newly allocated iterator associated to @p
913 * hash. If @p hash is not populated, this function still returns a
914 * valid iterator that will always return false on
915 * eina_iterator_next(), thus keeping API sane.
916 *
917 * If the memory can not be allocated, NULL is returned and
918 * #EINA_ERROR_OUT_OF_MEMORY is set. Otherwise, a valid iterator is
919 * returned.
920 *
921 * @warning if the hash structure changes then the iterator becomes
922 * invalid! That is, if you add or remove items this iterator
923 * behavior is undefined and your program may crash!
924 */
925EAPI Eina_Iterator *eina_hash_iterator_key_new(const Eina_Hash *hash) EINA_MALLOC EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT;
926
927/**
928 * @brief Returned a new iterator associated to hash data.
929 *
930 * @param hash The hash.
931 * @return A new iterator.
932 *
933 * This function returns a newly allocated iterator associated to
934 * @p hash. If @p hash is not populated, this function still returns a
935 * valid iterator that will always return false on
936 * eina_iterator_next(), thus keeping API sane.
937 *
938 * If the memory can not be allocated, @c NULL is returned and
939 * #EINA_ERROR_OUT_OF_MEMORY is set. Otherwise, a valid iterator is
940 * returned.
941 *
942 * @warning if the hash structure changes then the iterator becomes
943 * invalid. That is, if you add or remove items this iterator behavior
944 * is undefined and your program may crash.
945 */
946EAPI Eina_Iterator *eina_hash_iterator_data_new(const Eina_Hash *hash) EINA_MALLOC EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT;
947
948/**
949 * @brief Returned a new iterator associated to hash keys and data.
950 *
951 * @param hash The hash.
952 * @return A new iterator.
953 *
954 * This function returns a newly allocated iterator associated to @p
955 * hash. If @p hash is not populated, this function still returns a
956 * valid iterator that will always return false on
957 * eina_iterator_next(), thus keeping API sane.
958 *
959 * If the memory can not be allocated, NULL is returned and
960 * #EINA_ERROR_OUT_OF_MEMORY is set. Otherwise, a valid iterator is
961 * returned.
962 *
963 * @note iterator data will provide values as Eina_Hash_Tuple that should not
964 * be modified!
965 *
966 * @warning if the hash structure changes then the iterator becomes
967 * invalid! That is, if you add or remove items this iterator
968 * behavior is undefined and your program may crash!
969 */
970EAPI Eina_Iterator *eina_hash_iterator_tuple_new(const Eina_Hash *hash) EINA_MALLOC EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT;
971
972/**
973 * @brief Call a function on every member stored in the hash table
974 *
975 * @param hash The hash table whose members will be walked
976 * @param func The function to call on each parameter
977 * @param fdata The data pointer to pass to the function being called
978 *
979 * This function goes through every entry in the hash table @p hash and calls
980 * the function @p func on each member. The function should @b not modify the
981 * hash table contents if it returns 1. @b If the hash table contents are
982 * modified by this function or the function wishes to stop processing it must
983 * return 0, otherwise return 1 to keep processing.
984 *
985 * Example:
986 * @code
987 * extern Eina_Hash *hash;
988 *
989 * Eina_Bool hash_fn(const Eina_Hash *hash, const void *key,
990 * void *data, void *fdata)
991 * {
992 * printf("Func data: %s, Hash entry: %s / %p\n",
993 * fdata, (const char *)key, data);
994 * return 1;
995 * }
996 *
997 * int main(int argc, char **argv)
998 * {
999 * char *hash_fn_data;
1000 *
1001 * hash_fn_data = strdup("Hello World");
1002 * eina_hash_foreach(hash, hash_fn, hash_fn_data);
1003 * free(hash_fn_data);
1004 * }
1005 * @endcode
1006 */
1007EAPI void eina_hash_foreach(const Eina_Hash *hash,
1008 Eina_Hash_Foreach cb,
1009 const void *fdata) EINA_ARG_NONNULL(1, 2);
1010/* Paul Hsieh (http://www.azillionmonkeys.com/qed/hash.html) hash function used by WebCore (http://webkit.org/blog/8/hashtables-part-2/) */
1011EAPI int eina_hash_superfast(const char *key,
1012 int len) EINA_ARG_NONNULL(1);
1013/* Hash function first reported by dan bernstein many years ago in comp.lang.c */
1014static inline int eina_hash_djb2(const char *key,
1015 int len) EINA_ARG_NONNULL(1);
1016static inline int eina_hash_djb2_len(const char *key,
1017 int *plen) EINA_ARG_NONNULL(1, 2);
1018/* Hash function from http://www.concentric.net/~Ttwang/tech/inthash.htm */
1019static inline int eina_hash_int32(const unsigned int *pkey,
1020 int len) EINA_ARG_NONNULL(1);
1021static inline int eina_hash_int64(const unsigned long int *pkey,
1022 int len) EINA_ARG_NONNULL(1);
1023/* http://sites.google.com/site/murmurhash/ */
1024static inline int eina_hash_murmur3(const char *key,
1025 int len) EINA_ARG_NONNULL(1);
1026#include "eina_inline_hash.x"
1027
1028/**
1029 * @}
1030 */
1031
1032/**
1033 * @}
1034 */
1035
1036/**
1037 * @}
1038 */
1039
1040#endif /*EINA_HASH_H_*/
diff --git a/libraries/eina/src/include/eina_inline_array.x b/libraries/eina/src/include/eina_inline_array.x
new file mode 100644
index 0000000..f9f6026
--- /dev/null
+++ b/libraries/eina/src/include/eina_inline_array.x
@@ -0,0 +1,164 @@
1/* EINA - EFL data type library
2 * Copyright (C) 2008 Cedric Bail
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library;
16 * if not, see <http://www.gnu.org/licenses/>.
17 */
18
19#ifndef EINA_INLINE_ARRAY_X_
20#define EINA_INLINE_ARRAY_X_
21
22#include <stdio.h>
23
24/**
25 * @cond LOCAL
26 */
27
28EAPI Eina_Bool eina_array_grow(Eina_Array *array);
29
30/**
31 * @endcond
32 */
33
34/**
35 * @addtogroup Eina_Array_Group Array
36 *
37 * @brief These functions provide array management.
38 *
39 * @{
40 */
41
42/**
43 * @brief Append a data to an array.
44 *
45 * @param array The array.
46 * @param data The data to add.
47 * @return #EINA_TRUE on success, #EINA_FALSE otherwise.
48 *
49 * This function appends @p data to @p array. For performance
50 * reasons, there is no check of @p array. If it is @c NULL or
51 * invalid, the program may crash. If @p data is @c NULL, or if an
52 * allocation is necessary and fails, #EINA_FALSE is returned and
53 * #EINA_ERROR_OUT_OF_MEMORY is set. Otherwise, #EINA_TRUE is
54 * returned.
55 */
56
57static inline Eina_Bool
58eina_array_push(Eina_Array *array, const void *data)
59{
60 if (!data) return EINA_FALSE;
61
62 if (EINA_UNLIKELY((array->count + 1) > array->total))
63 if (!eina_array_grow(array))
64 return EINA_FALSE;
65
66 array->data[array->count++] = (void*) data;
67
68 return EINA_TRUE;
69}
70
71/**
72 * @brief Remove the last data of an array.
73 *
74 * @param array The array.
75 * @return The retrieved data.
76 *
77 * This function removes the last data of @p array, decreases the count
78 * of @p array and returns the data. For performance reasons, there
79 * is no check of @p array. If it is @c NULL or invalid, the program
80 * may crash. If the count member is less or equal than 0, @c NULL is
81 * returned.
82 */
83static inline void *
84eina_array_pop(Eina_Array *array)
85{
86 void *ret = NULL;
87
88 if (array->count <= 0)
89 goto on_empty;
90
91 ret = array->data[--array->count];
92
93 on_empty:
94 return ret;
95}
96
97/**
98 * @brief Return the data at a given position in an array.
99 *
100 * @param array The array.
101 * @param idx The potition of the data to retrieve.
102 * @return The retrieved data.
103 *
104 * This function returns the data at the position @p idx in @p
105 * array. For performance reasons, there is no check of @p array or @p
106 * idx. If it is @c NULL or invalid, the program may crash.
107 */
108static inline void *
109eina_array_data_get(const Eina_Array *array, unsigned int idx)
110{
111 return array->data[idx];
112}
113
114static inline void
115eina_array_data_set(const Eina_Array *array, unsigned int idx, const void *data)
116{
117 array->data[idx] = (void*) data;
118}
119
120/**
121 * @brief Return the number of elements in an array.
122 *
123 * @param array The array.
124 * @return The number of elements.
125 *
126 * This function returns the number of elements in @p array. For
127 * performance reasons, there is no check of @p array. If it is
128 * @c NULL or invalid, the program may crash.
129 */
130static inline unsigned int
131eina_array_count_get(const Eina_Array *array)
132{
133 return array->count;
134}
135
136static inline Eina_Bool
137eina_array_foreach(Eina_Array *array, Eina_Each_Cb cb, void *fdata)
138{
139 void *data;
140 Eina_Array_Iterator iterator;
141 unsigned int i;
142 Eina_Bool ret = EINA_TRUE;
143
144 EINA_ARRAY_ITER_NEXT(array, i, data, iterator)
145 if (cb(array, data, fdata) != EINA_TRUE)
146 {
147 ret = EINA_FALSE;
148 break;
149 }
150
151 return ret;
152}
153
154static inline void
155eina_array_clean(Eina_Array *array)
156{
157 array->count = 0;
158}
159
160/**
161 * @}
162 */
163
164#endif
diff --git a/libraries/eina/src/include/eina_inline_f16p16.x b/libraries/eina/src/include/eina_inline_f16p16.x
new file mode 100644
index 0000000..e16d188
--- /dev/null
+++ b/libraries/eina/src/include/eina_inline_f16p16.x
@@ -0,0 +1,83 @@
1/* EINA - EFL data type library
2 * Copyright (C) 2007-2008 Jorge Luis Zapata Muga
3 * Copyright (C) 2009 Cedric BAIL
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library;
17 * if not, see <http://www.gnu.org/licenses/>.
18 */
19
20#ifndef EINA_INLINE_F16P16_X_
21#define EINA_INLINE_F16P16_X_
22
23static inline Eina_F16p16
24eina_f16p16_add(Eina_F16p16 a, Eina_F16p16 b)
25{
26 return a + b;
27}
28
29static inline Eina_F16p16
30eina_f16p16_sub(Eina_F16p16 a, Eina_F16p16 b)
31{
32 return a - b;
33}
34
35static inline Eina_F16p16
36eina_f16p16_mul(Eina_F16p16 a, Eina_F16p16 b)
37{
38 return (Eina_F16p16)(((int64_t)a * (int64_t)b) >> 16);
39}
40
41static inline Eina_F16p16
42eina_f16p16_scale(Eina_F16p16 a, int b)
43{
44 return a * b;
45}
46
47static inline Eina_F16p16
48eina_f16p16_div(Eina_F16p16 a, Eina_F16p16 b)
49{
50 return (Eina_F16p16) ((((int64_t) a) << 16) / (int64_t) b);
51}
52
53static inline Eina_F16p16
54eina_f16p16_sqrt(Eina_F16p16 a)
55{
56 unsigned int root, remHi, remLo, testDiv, count;
57
58 root = 0; /* Clear root */
59 remHi = 0; /* Clear high part of partial remainder */
60 remLo = a; /* Get argument into low part of partial remainder */
61 count = (15 + (16 >> 1)); /* Load loop counter */
62 do {
63 remHi = (remHi << 2) | (remLo >> 30);
64 remLo <<= 2; /* get 2 bits of arg */
65 root <<= 1; /* Get ready for the next bit in the root */
66 testDiv = (root << 1) + 1; /* Test radical */
67 if (remHi >= testDiv)
68 {
69 remHi -= testDiv;
70 root++;
71 }
72 } while (count-- != 0);
73
74 return root;
75}
76
77static inline unsigned int
78eina_f16p16_fracc_get(Eina_F16p16 v)
79{
80 return (v & 0xffff);
81}
82
83#endif
diff --git a/libraries/eina/src/include/eina_inline_f32p32.x b/libraries/eina/src/include/eina_inline_f32p32.x
new file mode 100644
index 0000000..73480de
--- /dev/null
+++ b/libraries/eina/src/include/eina_inline_f32p32.x
@@ -0,0 +1,110 @@
1/* EINA - EFL data type library
2 * Copyright (C) 2007-2009 Jorge Luis Zapata Muga, Cedric BAIL
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library;
16 * if not, see <http://www.gnu.org/licenses/>.
17 */
18
19#ifndef EINA_INLINE_F32P32_X_
20# define EINA_INLINE_F32P32_X_
21
22#include <stdlib.h>
23
24static inline Eina_F32p32
25eina_f32p32_add(Eina_F32p32 a, Eina_F32p32 b)
26{
27 return a + b;
28}
29
30static inline Eina_F32p32
31eina_f32p32_sub(Eina_F32p32 a, Eina_F32p32 b)
32{
33 return a - b;
34}
35
36static inline Eina_F32p32
37eina_f32p32_mul(Eina_F32p32 a, Eina_F32p32 b)
38{
39 /* Prevent overflow and do '(a * b) >> 32' */
40 /* Basically do: Eina_F16p16 * Eina_F16p16 = Eina_F32p32 */
41 Eina_F32p32 up;
42 Eina_F32p32 down;
43 Eina_F32p32 result;
44 uint64_t as, bs;
45 Eina_F32p32 sign;
46
47 sign = a ^ b;
48 as = eina_fp32p32_llabs(a);
49 bs = eina_fp32p32_llabs(b);
50
51 up = (as >> 16) * (bs >> 16);
52 down = (as & 0xFFFF) * (bs & 0xFFFF);
53
54 result = up + (down >> 32);
55
56 return sign < 0 ? - result : result;
57}
58
59static inline Eina_F32p32
60eina_f32p32_scale(Eina_F32p32 a, int b)
61{
62 return a * b;
63}
64
65static inline Eina_F32p32
66eina_f32p32_div(Eina_F32p32 a, Eina_F32p32 b)
67{
68 Eina_F32p32 sign;
69 Eina_F32p32 result;
70
71 sign = a ^ b;
72
73 if (b == 0)
74 return sign < 0 ? (Eina_F32p32) 0x8000000000000000ull : (Eina_F32p32) 0x7FFFFFFFFFFFFFFFull;
75
76 result = (eina_f32p32_mul(eina_fp32p32_llabs(a), (((uint64_t) 1 << 62) / ((uint64_t)(eina_fp32p32_llabs(b)) >> 2))));
77
78 return sign < 0 ? - result : result;
79}
80
81static inline Eina_F32p32
82eina_f32p32_sqrt(Eina_F32p32 a)
83{
84 uint64_t root, remHi, remLo, testDiv, count;
85
86 root = 0; /* Clear root */
87 remHi = 0; /* Clear high part of partial remainder */
88 remLo = a; /* Get argument into low part of partial remainder */
89 count = (31 + (32 >> 1)); /* Load loop counter */
90 do {
91 remHi = (remHi << 2) | (remLo >> 30);
92 remLo <<= 2; /* get 2 bits of arg */
93 root <<= 1; /* Get ready for the next bit in the root */
94 testDiv = (root << 1) + 1; /* Test radical */
95 if (remHi >= testDiv) {
96 remHi -= testDiv;
97 root++;
98 }
99 } while (count-- != 0);
100
101 return root;
102}
103
104static inline unsigned int
105eina_f32p32_fracc_get(Eina_F32p32 v)
106{
107 return (unsigned int)v;
108}
109
110#endif
diff --git a/libraries/eina/src/include/eina_inline_f8p24.x b/libraries/eina/src/include/eina_inline_f8p24.x
new file mode 100644
index 0000000..f80bf61
--- /dev/null
+++ b/libraries/eina/src/include/eina_inline_f8p24.x
@@ -0,0 +1,82 @@
1/* EINA - EFL data type library
2 * Copyright (C) 2007-2008 Jorge Luis Zapata Muga
3 * Copyright (C) 2009 Cedric BAIL
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library;
17 * if not, see <http://www.gnu.org/licenses/>.
18 */
19
20#ifndef EINA_INLINE_F8P24_X_
21#define EINA_INLINE_F8P24_X_
22
23static inline Eina_F8p24
24eina_f8p24_add(Eina_F8p24 a, Eina_F8p24 b)
25{
26 return a + b;
27}
28
29static inline Eina_F8p24
30eina_f8p24_sub(Eina_F8p24 a, Eina_F8p24 b)
31{
32 return a - b;
33}
34
35static inline Eina_F8p24
36eina_f8p24_mul(Eina_F8p24 a, Eina_F8p24 b)
37{
38 return (Eina_F8p24)(((int64_t) a * (int64_t) b) >> 24);
39}
40
41static inline Eina_F8p24
42eina_f8p24_scale(Eina_F8p24 a, int b)
43{
44 return a * b;
45}
46
47static inline Eina_F8p24
48eina_f8p24_div(Eina_F8p24 a, Eina_F8p24 b)
49{
50 return (Eina_F8p24) ((((int64_t) a) << 24) / (int64_t) b);
51}
52
53static inline Eina_F8p24
54eina_f8p24_sqrt(Eina_F8p24 a)
55{
56 unsigned int root, remHi, remLo, testDiv, count;
57
58 root = 0; /* Clear root */
59 remHi = 0; /* Clear high part of partial remainder */
60 remLo = a; /* Get argument into low part of partial remainder */
61 count = (23 + (24 >> 1)); /* Load loop counter */
62 do {
63 remHi = (remHi << 2) | (remLo >> 30);
64 remLo <<= 2; /* get 2 bits of arg */
65 root <<= 1; /* Get ready for the next bit in the root */
66 testDiv = (root << 1) + 1; /* Test radical */
67 if (remHi >= testDiv)
68 {
69 remHi -= testDiv;
70 root++;
71 }
72 } while (count-- != 0);
73 return (root);
74}
75
76static inline unsigned int
77eina_f8p24_fracc_get(Eina_F8p24 v)
78{
79 return (v & 0xffffff);
80}
81
82#endif
diff --git a/libraries/eina/src/include/eina_inline_fp.x b/libraries/eina/src/include/eina_inline_fp.x
new file mode 100644
index 0000000..de44123
--- /dev/null
+++ b/libraries/eina/src/include/eina_inline_fp.x
@@ -0,0 +1,153 @@
1/* EINA - EFL data type library
2 * Copyright (C) 2007-2008 Jorge Luis Zapata Muga
3 * Copyright (C) 2009 Cedric BAIL
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library;
17 * if not, see <http://www.gnu.org/licenses/>.
18 */
19
20#ifndef EINA_INLINE_FP_X_
21# define EINA_INLINE_FP_X_
22
23static inline Eina_F32p32
24eina_f32p32_int_from(int32_t v)
25{
26 return (Eina_F32p32)(v) << 32;
27}
28
29static inline int32_t
30eina_f32p32_int_to(Eina_F32p32 v)
31{
32 return (int32_t)(v >> 32);
33}
34
35static inline Eina_F32p32
36eina_f32p32_double_from(double v)
37{
38 Eina_F32p32 r;
39 r = (Eina_F32p32)(v * 4294967296.0 + (v < 0 ? -0.5 : 0.5));
40 return r;
41}
42
43static inline double
44eina_f32p32_double_to(Eina_F32p32 v)
45{
46 double r;
47 r = v / 4294967296.0;
48 return r;
49}
50
51
52
53static inline Eina_F16p16
54eina_f16p16_int_from(int32_t v)
55{
56 return v << 16;
57}
58
59static inline int32_t
60eina_f16p16_int_to(Eina_F16p16 v)
61{
62 return v >> 16;
63}
64
65static inline Eina_F16p16
66eina_f16p16_float_from(float v)
67{
68 Eina_F16p16 r;
69
70 r = (Eina_F16p16)(v * 65536.0f + (v < 0 ? -0.5f : 0.5f));
71 return r;
72}
73
74static inline float
75eina_f16p16_float_to(Eina_F16p16 v)
76{
77 float r;
78
79 r = v / 65536.0f;
80 return r;
81}
82
83
84
85static inline Eina_F8p24
86eina_f8p24_int_from(int32_t v)
87{
88 return v << 24;
89}
90
91static inline int32_t
92eina_f8p24_int_to(Eina_F8p24 v)
93{
94 return v >> 24;
95}
96
97static inline Eina_F8p24
98eina_f8p24_float_from(float v)
99{
100 Eina_F8p24 r;
101
102 r = (Eina_F8p24)(v * 16777216.0f + (v < 0 ? -0.5f : 0.5f));
103 return r;
104}
105
106static inline float
107eina_f8p24_float_to(Eina_F8p24 v)
108{
109 float r;
110
111 r = v / 16777216.0f;
112 return r;
113}
114
115
116
117static inline Eina_F32p32
118eina_f16p16_to_f32p32(Eina_F16p16 a)
119{
120 return ((Eina_F32p32) a) << 16;
121}
122
123static inline Eina_F32p32
124eina_f8p24_to_f32p32(Eina_F8p24 a)
125{
126 return ((Eina_F32p32) a) << 8;
127}
128
129static inline Eina_F16p16
130eina_f32p32_to_f16p16(Eina_F32p32 a)
131{
132 return (Eina_F16p16) (a >> 16);
133}
134
135static inline Eina_F16p16
136eina_f8p24_to_f16p16(Eina_F8p24 a)
137{
138 return (Eina_F16p16) (a >> 8);
139}
140
141static inline Eina_F8p24
142eina_f32p32_to_f8p24(Eina_F32p32 a)
143{
144 return (Eina_F8p24) (a >> 8);
145}
146
147static inline Eina_F8p24
148eina_f16p16_to_f8p24(Eina_F16p16 a)
149{
150 return (Eina_F8p24) (a << 8);
151}
152
153#endif
diff --git a/libraries/eina/src/include/eina_inline_hash.x b/libraries/eina/src/include/eina_inline_hash.x
new file mode 100644
index 0000000..f27060f
--- /dev/null
+++ b/libraries/eina/src/include/eina_inline_hash.x
@@ -0,0 +1,151 @@
1/* EINA - EFL data type library
2 * Copyright (C) 2002-2008 Carsten Haitzler
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library;
16 * if not, see <http://www.gnu.org/licenses/>.
17 */
18
19#ifndef EINA_INLINE_HASH_X_
20#define EINA_INLINE_HASH_X_
21
22/*
23 djb2 hash algorithm was first reported by dan bernstein, and was the old
24 default hash function for evas.
25 */
26static inline int
27eina_hash_djb2(const char *key, int len)
28{
29 unsigned int hash_num = 5381;
30 const unsigned char *ptr;
31
32 if (!key) return 0;
33 for (ptr = (unsigned char *)key; len; ptr++, len--)
34 hash_num = ((hash_num << 5) + hash_num) ^ *ptr; /* hash * 33 ^ c */
35
36 return (int)hash_num;
37}
38
39static inline int
40eina_hash_djb2_len(const char *key, int *plen)
41{
42 unsigned int hash_num = 5381;
43 int len = 0;
44 const unsigned char *ptr;
45
46 if (!key) return 0;
47
48 for (ptr = (unsigned char *)key; *ptr; ptr++, len++)
49 hash_num = ((hash_num << 5) + hash_num) ^ *ptr; /* hash * 33 ^ c */
50
51 *plen = len + 1;
52
53 return (int)hash_num;
54}
55
56static inline int
57eina_hash_int32(const unsigned int *pkey, int len)
58{
59 unsigned int key = *pkey;
60
61 (void) len;
62
63 key = ~key + (key << 15);
64 key ^= key >> 12;
65 key += key << 2;
66 key ^= key >> 4;
67 key *= 2057;
68 key ^= key >> 16;
69 return key;
70}
71
72static inline int
73eina_hash_int64(const unsigned long int *pkey, int len)
74{
75 unsigned long int key = *pkey;
76
77 (void) len;
78
79 key = ~key + (key << 18);
80 key ^= key >> 31;
81 key *= 21;
82 key ^= key >> 11;
83 key += key << 6;
84 key ^= key >> 22;
85 return (int) key;
86}
87
88static inline unsigned int _rotl32(unsigned int x, char r)
89{
90 return (x << r) | (x >> (32 - r));
91}
92
93static inline unsigned int _fmix32(unsigned int h)
94{
95 h ^= h >> 16;
96 h *= 0x85ebca6b;
97 h ^= h >> 13;
98 h *= 0xc2b2ae35;
99 h ^= h >> 16;
100
101 return h;
102}
103
104int
105eina_hash_murmur3(const char *key, int len)
106{
107 const unsigned char * data = (const unsigned char*)key;
108 const int nblocks = len / 4;
109 unsigned int h1 = 0, k1;
110 unsigned int c1 = 0xcc9e2d51;
111 unsigned int c2 = 0x1b873593;
112 const unsigned int * blocks = (const unsigned int *)(data + nblocks*4);
113 int i;
114 const unsigned char *tail;
115
116 for(i = -nblocks; i; i++)
117 {
118 k1 = blocks[i];
119
120 k1 *= c1;
121 k1 = _rotl32(k1, 15);
122 k1 *= c2;
123
124 h1 ^= k1;
125 h1 = _rotl32(h1, 13);
126 h1 = h1*5+0xe6546b64;
127 }
128
129 tail = (const unsigned char*)(data + nblocks*4);
130
131 k1 = 0;
132
133 switch(len & 3)
134 {
135 case 3:
136 k1 ^= tail[2] << 16;
137 case 2:
138 k1 ^= tail[1] << 8;
139 case 1:
140 k1 ^= tail[0];
141 k1 *= c1;
142 k1 = _rotl32(k1, 16);
143 k1 *= c2;
144 h1 ^= k1;
145 }
146
147 h1 ^= len;
148
149 return _fmix32(h1);
150}
151#endif
diff --git a/libraries/eina/src/include/eina_inline_list.x b/libraries/eina/src/include/eina_inline_list.x
new file mode 100644
index 0000000..3397a1b
--- /dev/null
+++ b/libraries/eina/src/include/eina_inline_list.x
@@ -0,0 +1,67 @@
1/* EINA - EFL data type library
2 * Copyright (C) 2002-2008 Carsten Haitzler, Vincent Torri, Jorge Luis Zapata Muga
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library;
16 * if not, see <http://www.gnu.org/licenses/>.
17 */
18
19#ifndef EINA_LIST_INLINE_H_
20#define EINA_LIST_INLINE_H_
21
22static inline Eina_List *
23eina_list_last(const Eina_List *list)
24{
25 if (!list) return NULL;
26 return list->accounting->last;
27}
28
29static inline Eina_List *
30eina_list_next(const Eina_List *list)
31{
32 if (!list) return NULL;
33 return list->next;
34}
35
36static inline Eina_List *
37eina_list_prev(const Eina_List *list)
38{
39 if (!list) return NULL;
40 return list->prev;
41}
42
43static inline void *
44eina_list_data_get(const Eina_List *list)
45{
46 if (!list) return NULL;
47 return list->data;
48}
49
50static inline void *
51eina_list_data_set(Eina_List *list, const void *data)
52{
53 void *tmp;
54 if (!list) return NULL;
55 tmp = list->data;
56 list->data = (void*) data;
57 return tmp;
58}
59
60static inline unsigned int
61eina_list_count(const Eina_List *list)
62{
63 if (!list) return 0;
64 return list->accounting->count;
65}
66
67#endif /* EINA_LIST_INLINE_H_ */
diff --git a/libraries/eina/src/include/eina_inline_lock_posix.x b/libraries/eina/src/include/eina_inline_lock_posix.x
new file mode 100644
index 0000000..77f5b8b
--- /dev/null
+++ b/libraries/eina/src/include/eina_inline_lock_posix.x
@@ -0,0 +1,509 @@
1/* EINA - EFL data type library
2 * Copyright (C) 2011 Vincent Torri
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library;
16 * if not, see <http://www.gnu.org/licenses/>.
17 */
18
19#ifndef EINA_INLINE_LOCK_POSIX_X_
20#define EINA_INLINE_LOCK_POSIX_X_
21
22#include <errno.h>
23#ifndef __USE_UNIX98
24# define __USE_UNIX98
25# include <pthread.h>
26# undef __USE_UNIX98
27#else
28# include <pthread.h>
29#endif
30
31#include <sys/time.h>
32
33#ifdef EINA_HAVE_DEBUG_THREADS
34#include <stdlib.h>
35#include <string.h>
36#include <assert.h>
37#include <execinfo.h>
38#define EINA_LOCK_DEBUG_BT_NUM 64
39typedef void (*Eina_Lock_Bt_Func) ();
40
41#include "eina_inlist.h"
42#endif
43
44typedef struct _Eina_Lock Eina_Lock;
45typedef struct _Eina_RWLock Eina_RWLock;
46typedef struct _Eina_Condition Eina_Condition;
47typedef pthread_key_t Eina_TLS;
48
49struct _Eina_Lock
50{
51#ifdef EINA_HAVE_DEBUG_THREADS
52 EINA_INLIST;
53#endif
54 pthread_mutex_t mutex;
55#ifdef EINA_HAVE_DEBUG_THREADS
56 pthread_t lock_thread_id;
57 Eina_Lock_Bt_Func lock_bt[EINA_LOCK_DEBUG_BT_NUM];
58 int lock_bt_num;
59 Eina_Bool locked : 1;
60#endif
61};
62
63struct _Eina_Condition
64{
65 Eina_Lock *lock;
66 pthread_cond_t condition;
67};
68
69struct _Eina_RWLock
70{
71 pthread_rwlock_t mutex;
72#ifdef EINA_HAVE_DEBUG_THREADS
73 pthread_t lock_thread_wid;
74#endif
75};
76
77EAPI extern Eina_Bool _eina_threads_activated;
78
79#ifdef EINA_HAVE_DEBUG_THREADS
80# include <sys/time.h>
81
82EAPI extern int _eina_threads_debug;
83EAPI extern pthread_t _eina_main_loop;
84EAPI extern pthread_mutex_t _eina_tracking_lock;
85EAPI extern Eina_Inlist *_eina_tracking;
86#endif
87
88static inline void
89eina_lock_debug(const Eina_Lock *mutex)
90{
91#ifdef EINA_HAVE_DEBUG_THREADS
92 printf("lock %p, locked: %i, by %i\n",
93 mutex, (int)mutex->locked, (int)mutex->lock_thread_id);
94 backtrace_symbols_fd((void **)mutex->lock_bt, mutex->lock_bt_num, 1);
95#else
96 (void) mutex;
97#endif
98}
99
100static inline Eina_Bool
101eina_lock_new(Eina_Lock *mutex)
102{
103 pthread_mutexattr_t attr;
104
105#ifdef EINA_HAVE_DEBUG_THREADS
106 if (!_eina_threads_activated)
107 assert(pthread_equal(_eina_main_loop, pthread_self()));
108#endif
109
110 if (pthread_mutexattr_init(&attr) != 0)
111 return EINA_FALSE;
112 /* NOTE: PTHREAD_MUTEX_RECURSIVE is not allowed at all, you will break on/off
113 feature for sure with that change. */
114#ifdef EINA_HAVE_DEBUG_THREADS
115 if (pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_ERRORCHECK) != 0)
116 return EINA_FALSE;
117 memset(mutex, 0, sizeof(Eina_Lock));
118#endif
119 if (pthread_mutex_init(&(mutex->mutex), &attr) != 0)
120 return EINA_FALSE;
121
122 pthread_mutexattr_destroy(&attr);
123
124 return EINA_TRUE;
125}
126
127static inline void
128eina_lock_free(Eina_Lock *mutex)
129{
130#ifdef EINA_HAVE_DEBUG_THREADS
131 if (!_eina_threads_activated)
132 assert(pthread_equal(_eina_main_loop, pthread_self()));
133#endif
134
135 pthread_mutex_destroy(&(mutex->mutex));
136#ifdef EINA_HAVE_DEBUG_THREADS
137 memset(mutex, 0, sizeof(Eina_Lock));
138#endif
139}
140
141static inline Eina_Lock_Result
142eina_lock_take(Eina_Lock *mutex)
143{
144 Eina_Lock_Result ret = EINA_LOCK_FAIL;
145 int ok;
146
147#ifdef EINA_HAVE_ON_OFF_THREADS
148 if (!_eina_threads_activated)
149 {
150#ifdef EINA_HAVE_DEBUG_THREADS
151 assert(pthread_equal(_eina_main_loop, pthread_self()));
152#endif
153 return EINA_LOCK_SUCCEED;
154 }
155#endif
156
157#ifdef EINA_HAVE_DEBUG_THREADS
158 if (_eina_threads_debug)
159 {
160 struct timeval t0, t1;
161 int dt;
162
163 gettimeofday(&t0, NULL);
164 ok = pthread_mutex_lock(&(mutex->mutex));
165 gettimeofday(&t1, NULL);
166
167 dt = (t1.tv_sec - t0.tv_sec) * 1000000;
168 if (t1.tv_usec > t0.tv_usec)
169 dt += (t1.tv_usec - t0.tv_usec);
170 else
171 dt -= t0.tv_usec - t1.tv_usec;
172 dt /= 1000;
173
174 if (dt > _eina_threads_debug) abort();
175 }
176 else
177 {
178#endif
179 ok = pthread_mutex_lock(&(mutex->mutex));
180#ifdef EINA_HAVE_DEBUG_THREADS
181 }
182#endif
183
184 if (ok == 0) ret = EINA_LOCK_SUCCEED;
185 else if (ok == EDEADLK)
186 {
187 printf("ERROR ERROR: DEADLOCK on lock %p\n", mutex);
188 eina_lock_debug(mutex);
189 ret = EINA_LOCK_DEADLOCK; // magic
190#ifdef EINA_HAVE_DEBUG_THREADS
191 if (_eina_threads_debug) abort();
192#endif
193 }
194
195#ifdef EINA_HAVE_DEBUG_THREADS
196 mutex->locked = 1;
197 mutex->lock_thread_id = pthread_self();
198 mutex->lock_bt_num = backtrace((void **)(mutex->lock_bt), EINA_LOCK_DEBUG_BT_NUM);
199
200 pthread_mutex_lock(&_eina_tracking_lock);
201 _eina_tracking = eina_inlist_append(_eina_tracking,
202 EINA_INLIST_GET(mutex));
203 pthread_mutex_unlock(&_eina_tracking_lock);
204#endif
205
206 return ret;
207}
208
209static inline Eina_Lock_Result
210eina_lock_take_try(Eina_Lock *mutex)
211{
212 Eina_Lock_Result ret = EINA_LOCK_FAIL;
213 int ok;
214
215#ifdef EINA_HAVE_ON_OFF_THREADS
216 if (!_eina_threads_activated)
217 {
218#ifdef EINA_HAVE_DEBUG_THREADS
219 assert(pthread_equal(_eina_main_loop, pthread_self()));
220#endif
221 return EINA_LOCK_SUCCEED;
222 }
223#endif
224
225#ifdef EINA_HAVE_DEBUG_THREADS
226 if (!_eina_threads_activated)
227 assert(pthread_equal(_eina_main_loop, pthread_self()));
228#endif
229
230 ok = pthread_mutex_trylock(&(mutex->mutex));
231 if (ok == 0) ret = EINA_LOCK_SUCCEED;
232 else if (ok == EDEADLK)
233 {
234 printf("ERROR ERROR: DEADLOCK on trylock %p\n", mutex);
235 ret = EINA_LOCK_DEADLOCK; // magic
236 }
237#ifdef EINA_HAVE_DEBUG_THREADS
238 if (ret == EINA_LOCK_SUCCEED)
239 {
240 mutex->locked = 1;
241 mutex->lock_thread_id = pthread_self();
242 mutex->lock_bt_num = backtrace((void **)(mutex->lock_bt), EINA_LOCK_DEBUG_BT_NUM);
243
244 pthread_mutex_lock(&_eina_tracking_lock);
245 _eina_tracking = eina_inlist_append(_eina_tracking,
246 EINA_INLIST_GET(mutex));
247 pthread_mutex_unlock(&_eina_tracking_lock);
248 }
249#endif
250 return ret;
251}
252
253static inline Eina_Lock_Result
254eina_lock_release(Eina_Lock *mutex)
255{
256 Eina_Lock_Result ret;
257
258#ifdef EINA_HAVE_ON_OFF_THREADS
259 if (!_eina_threads_activated)
260 {
261#ifdef EINA_HAVE_DEBUG_THREADS
262 assert(pthread_equal(_eina_main_loop, pthread_self()));
263#endif
264 return EINA_LOCK_SUCCEED;
265 }
266#endif
267
268#ifdef EINA_HAVE_DEBUG_THREADS
269 pthread_mutex_lock(&_eina_tracking_lock);
270 _eina_tracking = eina_inlist_remove(_eina_tracking,
271 EINA_INLIST_GET(mutex));
272 pthread_mutex_unlock(&_eina_tracking_lock);
273
274 mutex->locked = 0;
275 mutex->lock_thread_id = 0;
276 memset(mutex->lock_bt, 0, EINA_LOCK_DEBUG_BT_NUM * sizeof(Eina_Lock_Bt_Func));
277 mutex->lock_bt_num = 0;
278#endif
279 ret = (pthread_mutex_unlock(&(mutex->mutex)) == 0) ?
280 EINA_LOCK_SUCCEED : EINA_LOCK_FAIL;
281 return ret;
282}
283
284static inline Eina_Bool
285eina_condition_new(Eina_Condition *cond, Eina_Lock *mutex)
286{
287#ifdef EINA_HAVE_DEBUG_THREADS
288 assert(mutex != NULL);
289 if (!_eina_threads_activated)
290 assert(pthread_equal(_eina_main_loop, pthread_self()));
291 memset(cond, 0, sizeof (Eina_Condition));
292#endif
293
294 cond->lock = mutex;
295 if (pthread_cond_init(&cond->condition, NULL) != 0)
296 {
297#ifdef EINA_HAVE_DEBUG_THREADS
298 if (errno == EBUSY)
299 printf("eina_condition_new on already initialized Eina_Condition\n");
300#endif
301 return EINA_FALSE;
302 }
303
304 return EINA_TRUE;
305}
306
307static inline void
308eina_condition_free(Eina_Condition *cond)
309{
310#ifdef EINA_HAVE_DEBUG_THREADS
311 if (!_eina_threads_activated)
312 assert(pthread_equal(_eina_main_loop, pthread_self()));
313#endif
314
315 pthread_cond_destroy(&(cond->condition));
316#ifdef EINA_HAVE_DEBUG_THREADS
317 memset(cond, 0, sizeof (Eina_Condition));
318#endif
319}
320
321static inline Eina_Bool
322eina_condition_wait(Eina_Condition *cond)
323{
324 Eina_Bool r;
325
326#ifdef EINA_HAVE_DEBUG_THREADS
327 assert(_eina_threads_activated);
328 assert(cond->lock != NULL);
329
330 pthread_mutex_lock(&_eina_tracking_lock);
331 _eina_tracking = eina_inlist_remove(_eina_tracking,
332 EINA_INLIST_GET(cond->lock));
333 pthread_mutex_unlock(&_eina_tracking_lock);
334#endif
335
336 r = pthread_cond_wait(&(cond->condition),
337 &(cond->lock->mutex)) == 0 ? EINA_TRUE : EINA_FALSE;
338
339#ifdef EINA_HAVE_DEBUG_THREADS
340 pthread_mutex_lock(&_eina_tracking_lock);
341 _eina_tracking = eina_inlist_append(_eina_tracking,
342 EINA_INLIST_GET(cond->lock));
343 pthread_mutex_unlock(&_eina_tracking_lock);
344#endif
345
346 return r;
347}
348
349static inline Eina_Bool
350eina_condition_timedwait(Eina_Condition *cond, double t)
351{
352 struct timespec tv;
353 Eina_Bool r;
354
355#ifdef EINA_HAVE_DEBUG_THREADS
356 assert(_eina_threads_activated);
357 assert(cond->lock != NULL);
358
359 pthread_mutex_lock(&_eina_tracking_lock);
360 _eina_tracking = eina_inlist_remove(_eina_tracking,
361 EINA_INLIST_GET(cond->lock));
362 pthread_mutex_unlock(&_eina_tracking_lock);
363#endif
364
365 tv.tv_sec = t;
366 tv.tv_nsec = (t - (double) tv.tv_sec) * 1000000000;
367
368 r = pthread_cond_timedwait(&(cond->condition),
369 &(cond->lock->mutex),
370 &tv) == 0 ?
371 EINA_TRUE : EINA_FALSE;
372
373#ifdef EINA_HAVE_DEBUG_THREADS
374 pthread_mutex_lock(&_eina_tracking_lock);
375 _eina_tracking = eina_inlist_append(_eina_tracking,
376 EINA_INLIST_GET(cond->lock));
377 pthread_mutex_unlock(&_eina_tracking_lock);
378#endif
379
380 return r;
381}
382
383static inline Eina_Bool
384eina_condition_broadcast(Eina_Condition *cond)
385{
386#ifdef EINA_HAVE_DEBUG_THREADS
387 assert(cond->lock != NULL);
388#endif
389
390 return pthread_cond_broadcast(&(cond->condition)) == 0 ? EINA_TRUE : EINA_FALSE;
391}
392
393static inline Eina_Bool
394eina_condition_signal(Eina_Condition *cond)
395{
396#ifdef EINA_HAVE_DEBUG_THREADS
397 assert(cond->lock != NULL);
398#endif
399
400 return pthread_cond_signal(&(cond->condition)) == 0 ? EINA_TRUE : EINA_FALSE;
401}
402
403static inline Eina_Bool
404eina_rwlock_new(Eina_RWLock *mutex)
405{
406#ifdef EINA_HAVE_DEBUG_THREADS
407 if (!_eina_threads_activated)
408 assert(pthread_equal(_eina_main_loop, pthread_self()));
409#endif
410
411 if (pthread_rwlock_init(&(mutex->mutex), NULL) != 0)
412 return EINA_FALSE;
413 return EINA_TRUE;
414}
415
416static inline void
417eina_rwlock_free(Eina_RWLock *mutex)
418{
419#ifdef EINA_HAVE_DEBUG_THREADS
420 if (!_eina_threads_activated)
421 assert(pthread_equal(_eina_main_loop, pthread_self()));
422#endif
423
424 pthread_rwlock_destroy(&(mutex->mutex));
425}
426
427static inline Eina_Lock_Result
428eina_rwlock_take_read(Eina_RWLock *mutex)
429{
430#ifdef EINA_HAVE_ON_OFF_THREADS
431 if (!_eina_threads_activated)
432 {
433#ifdef EINA_HAVE_DEBUG_THREADS
434 assert(pthread_equal(_eina_main_loop, pthread_self()));
435#endif
436 return EINA_LOCK_SUCCEED;
437 }
438#endif
439
440 if (pthread_rwlock_rdlock(&(mutex->mutex)) != 0)
441 return EINA_LOCK_FAIL;
442 return EINA_LOCK_SUCCEED;
443}
444
445static inline Eina_Lock_Result
446eina_rwlock_take_write(Eina_RWLock *mutex)
447{
448#ifdef EINA_HAVE_ON_OFF_THREADS
449 if (!_eina_threads_activated)
450 {
451#ifdef EINA_HAVE_DEBUG_THREADS
452 assert(pthread_equal(_eina_main_loop, pthread_self()));
453#endif
454 return EINA_LOCK_SUCCEED;
455 }
456#endif
457
458 if (pthread_rwlock_wrlock(&(mutex->mutex)) != 0)
459 return EINA_LOCK_FAIL;
460 return EINA_LOCK_SUCCEED;
461}
462
463static inline Eina_Lock_Result
464eina_rwlock_release(Eina_RWLock *mutex)
465{
466#ifdef EINA_HAVE_ON_OFF_THREADS
467 if (!_eina_threads_activated)
468 {
469#ifdef EINA_HAVE_DEBUG_THREADS
470 assert(pthread_equal(_eina_main_loop, pthread_self()));
471#endif
472 return EINA_LOCK_SUCCEED;
473 }
474#endif
475
476 if (pthread_rwlock_unlock(&(mutex->mutex)) != 0)
477 return EINA_LOCK_FAIL;
478 return EINA_LOCK_SUCCEED;
479}
480
481static inline Eina_Bool
482eina_tls_new(Eina_TLS *key)
483{
484 if (pthread_key_create(key, NULL) != 0)
485 return EINA_FALSE;
486 return EINA_TRUE;
487}
488
489static inline void
490eina_tls_free(Eina_TLS key)
491{
492 pthread_key_delete(key);
493}
494
495static inline void *
496eina_tls_get(Eina_TLS key)
497{
498 return pthread_getspecific(key);
499}
500
501static inline Eina_Bool
502eina_tls_set(Eina_TLS key, const void *data)
503{
504 if (pthread_setspecific(key, data) != 0)
505 return EINA_FALSE;
506 return EINA_TRUE;
507}
508
509#endif
diff --git a/libraries/eina/src/include/eina_inline_lock_void.x b/libraries/eina/src/include/eina_inline_lock_void.x
new file mode 100644
index 0000000..8cb9a49
--- /dev/null
+++ b/libraries/eina/src/include/eina_inline_lock_void.x
@@ -0,0 +1,247 @@
1/* EINA - EFL data type library
2 * Copyright (C) 2011 Vincent Torri
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library;
16 * if not, see <http://www.gnu.org/licenses/>.
17 */
18
19#ifndef EINA_INLINE_LOCK_VOID_X_
20#define EINA_INLINE_LOCK_VOID_X_
21
22#ifdef EINA_UNUSED
23# undef EINA_UNUSED
24#endif
25#ifdef __GNUC__
26# define EINA_UNUSED __attribute__((unused))
27#else
28# define EINA_UNUSED
29#endif
30
31/**
32 * @addtogroup Eina_Lock_Group Lock
33 *
34 * @brief These functions provide Mutual Exclusion objects management.
35 *
36 * @note On Windows XP, critical sections are used, while on Windows
37 * CE, standard Mutex objects are used.
38 *
39 * @{
40 */
41
42/**
43 * @typedef Eina_Lock
44 * Abtract type for a mutual exclusive object.
45 */
46typedef void *Eina_Lock;
47typedef void *Eina_RWLock;
48typedef void *Eina_Condition;
49typedef void *Eina_TLS;
50
51/**
52 * @brief Create a new #Eina_Lock.
53 *
54 * @param mutex A pointer to the lock object.
55 * @return #EINA_TRUE on success, #EINA_FALSE otherwise.
56 *
57 * This function creates a new #Eina_Lock object and stores it in the
58 * @p mutex buffer. On success, this function returns #EINA_TRUE and
59 * #EINA_FALSE otherwise. To free the resources allocated by this
60 * function, use eina_lock_free(). For performance reasons, no check
61 * is done on @p mutex.
62 */
63static inline Eina_Bool
64eina_lock_new(Eina_Lock *mutex EINA_UNUSED)
65{
66 return EINA_FALSE;
67}
68
69/**
70 * @brief Free the ressources of the given lock object.
71 *
72 * @param mutex The lock object to free.
73 *
74 * This function frees the resources of @p mutex allocated by
75 * eina_lock_new(). For performance reasons, no check is done on
76 * @p mutex.
77 */
78static inline void
79eina_lock_free(Eina_Lock *mutex EINA_UNUSED)
80{
81}
82
83/**
84 * @brief Lock the given mutual exclusion object.
85 *
86 * @param mutex The lock object to lock.
87 * @return #EINA_TRUE on success, #EINA_FALSE otherwise.
88 *
89 * This function locks @p mutex. @p mutex must have been created by
90 * eina_lock_new(). On success, this function returns #EINA_TRUE and
91 * #EINA_FALSE otherwise. For performance reasons, no check is done on
92 * @p mutex.
93 */
94static inline Eina_Lock_Result
95eina_lock_take(Eina_Lock *mutex EINA_UNUSED)
96{
97 return EINA_LOCK_FAIL;
98}
99
100/**
101 * @brief Try to lock the given mutual exclusion object.
102 *
103 * @param mutex The lock object to try to lock.
104 * @return #EINA_TRUE on success, #EINA_FALSE otherwise.
105 *
106 * This function tries to lock @p mutex. @p mutex must have been created by
107 * eina_lock_new(). If @p mutex can be locked, this function returns
108 * #EINA_TRUE; if @p mutex can not be locked, or is already locked, it
109 * returns #EINA_FALSE. This function does not block and returns
110 * immediately. For performance reasons, no check is done on
111 * @p mutex.
112 *
113 * @note On Windows CE, this function is actually eina_lock_take().
114 */
115static inline Eina_Lock_Result
116eina_lock_take_try(Eina_Lock *mutex EINA_UNUSED)
117{
118 return EINA_LOCK_FAIL;
119}
120
121/**
122 * @brief Unlock the given mutual exclusion object.
123 *
124 * @param mutex The lock object to unlock.
125 * @return #EINA_TRUE on success, #EINA_FALSE otherwise.
126 *
127 * This function unlocks @p mutex. @p mutex must have been created by
128 * eina_lock_new(). On success, this function returns #EINA_TRUE and
129 * #EINA_FALSE otherwise. For performance reasons, no check is done on
130 * @p mutex.
131 */
132static inline Eina_Lock_Result
133eina_lock_release(Eina_Lock *mutex EINA_UNUSED)
134{
135 return EINA_LOCK_FAIL;
136}
137
138static inline void
139eina_lock_debug(const Eina_Lock *mutex EINA_UNUSED)
140{
141}
142
143static inline Eina_Bool
144eina_condition_new(Eina_Condition *cond EINA_UNUSED, Eina_Lock *mutex EINA_UNUSED)
145{
146 return EINA_FALSE;
147}
148
149static inline void
150eina_condition_free(Eina_Condition *cond EINA_UNUSED)
151{
152}
153
154static inline Eina_Bool
155eina_condition_wait(Eina_Condition *cond EINA_UNUSED)
156{
157 return EINA_FALSE;
158}
159
160static inline Eina_Bool
161eina_condition_timedwait(Eina_Condition *cond EINA_UNUSED, double val EINA_UNUSED)
162{
163 return EINA_FALSE;
164}
165
166static inline Eina_Bool
167eina_condition_broadcast(Eina_Condition *cond EINA_UNUSED)
168{
169 return EINA_FALSE;
170}
171
172static inline Eina_Bool
173eina_condition_signal(Eina_Condition *cond EINA_UNUSED)
174{
175 return EINA_FALSE;
176}
177
178static inline Eina_Bool
179eina_rwlock_new(Eina_RWLock *mutex EINA_UNUSED)
180{
181 return EINA_FALSE;
182}
183
184static inline void
185 eina_rwlock_free(Eina_RWLock *mutex EINA_UNUSED)
186{
187}
188
189static inline Eina_Lock_Result
190eina_rwlock_read_take(Eina_RWLock *mutex EINA_UNUSED)
191{
192 return EINA_LOCK_FAIL;
193}
194
195static inline Eina_Lock_Result
196eina_rwlock_write_take(Eina_RWLock *mutex EINA_UNUSED)
197{
198 return EINA_LOCK_FAIL;
199}
200
201static inline Eina_Lock_Result
202eina_rwlock_release(Eina_RWLock *mutex EINA_UNUSED)
203{
204 return EINA_LOCK_FAIL;
205}
206
207static inline Eina_Lock_Result
208eina_rwlock_take_read(Eina_RWLock *mutex EINA_UNUSED)
209{
210 return EINA_LOCK_FAIL;
211}
212
213static inline Eina_Lock_Result
214eina_rwlock_take_write(Eina_RWLock *mutex EINA_UNUSED)
215{
216 return EINA_LOCK_FAIL;
217}
218
219static inline Eina_Bool
220eina_tls_new(Eina_TLS *key EINA_UNUSED)
221{
222 return EINA_FALSE;
223}
224
225static inline void
226eina_tls_free(Eina_TLS key EINA_UNUSED)
227{
228}
229
230static inline void *
231eina_tls_get(Eina_TLS key EINA_UNUSED)
232{
233 return NULL;
234}
235
236static inline Eina_Bool
237eina_tls_set(Eina_TLS key EINA_UNUSED, const void *data EINA_UNUSED)
238{
239 return EINA_FALSE;
240}
241
242
243/**
244 * @}
245 */
246
247#endif
diff --git a/libraries/eina/src/include/eina_inline_lock_win32.x b/libraries/eina/src/include/eina_inline_lock_win32.x
new file mode 100644
index 0000000..072095c
--- /dev/null
+++ b/libraries/eina/src/include/eina_inline_lock_win32.x
@@ -0,0 +1,466 @@
1/* EINA - EFL data type library
2 * Copyright (C) 2011 Vincent Torri
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library;
16 * if not, see <http://www.gnu.org/licenses/>.
17 */
18
19#ifndef EINA_INLINE_LOCK_WIN32_X_
20#define EINA_INLINE_LOCK_WIN32_X_
21
22#include <windows.h>
23
24typedef CRITICAL_SECTION Eina_Lock;
25typedef struct _Eina_Condition Eina_Condition;
26
27#if _WIN32_WINNT >= 0x0600
28struct _Eina_Condition
29{
30 CRITICAL_SECTION *mutex;
31 CONDITION_VARIABLE condition;
32};
33#else
34struct _Eina_Condition
35{
36 int waiters_count;
37 CRITICAL_SECTION waiters_count_lock;
38 CRITICAL_SECTION *mutex;
39 HANDLE semaphore;
40 HANDLE waiters_done;
41 Eina_Bool was_broadcast;
42};
43#endif
44
45typedef struct _Eina_Win32_RWLock Eina_RWLock;
46
47struct _Eina_Win32_RWLock
48{
49 LONG readers_count;
50 LONG writers_count;
51 int readers;
52 int writers;
53
54 Eina_Lock mutex;
55 Eina_Condition cond_read;
56 Eina_Condition cond_write;
57};
58
59typedef DWORD Eina_TLS;
60
61EAPI extern Eina_Bool _eina_threads_activated;
62
63static inline Eina_Bool
64eina_lock_new(Eina_Lock *mutex)
65{
66 InitializeCriticalSection(mutex);
67
68 return EINA_TRUE;
69}
70
71static inline void
72eina_lock_free(Eina_Lock *mutex)
73{
74 DeleteCriticalSection(mutex);
75}
76
77static inline Eina_Lock_Result
78eina_lock_take(Eina_Lock *mutex)
79{
80#ifdef EINA_HAVE_ON_OFF_THREADS
81 if (!_eina_threads_activated) return EINA_LOCK_SUCCEED;
82#endif
83
84 EnterCriticalSection(mutex);
85
86 return EINA_LOCK_SUCCEED;
87}
88
89static inline Eina_Lock_Result
90eina_lock_take_try(Eina_Lock *mutex)
91{
92#ifdef EINA_HAVE_ON_OFF_THREADS
93 if (!_eina_threads_activated) return EINA_LOCK_SUCCEED;
94#endif
95
96 return TryEnterCriticalSection(mutex) == 0 ? EINA_LOCK_FAIL : EINA_LOCK_SUCCEED;
97}
98
99static inline Eina_Lock_Result
100eina_lock_release(Eina_Lock *mutex)
101{
102#ifdef EINA_HAVE_ON_OFF_THREADS
103 if (!_eina_threads_activated) return EINA_LOCK_SUCCEED;
104#endif
105
106 LeaveCriticalSection(mutex);
107
108 return EINA_LOCK_SUCCEED;
109}
110
111static inline void
112eina_lock_debug(const Eina_Lock *mutex)
113{
114 (void)mutex;
115}
116
117static inline Eina_Bool
118eina_condition_new(Eina_Condition *cond, Eina_Lock *mutex)
119{
120 cond->mutex = mutex;
121#if _WIN32_WINNT >= 0x0600
122 InitializeConditionVariable(&cond->condition);
123#else
124 cond->waiters_count = 0;
125 cond->was_broadcast = EINA_FALSE;
126 cond->semaphore = CreateSemaphore(NULL, // no security
127 0, // initially 0
128 0x7fffffff, // max count
129 NULL); // unnamed
130 if (!cond->semaphore)
131 return EINA_FALSE;
132
133 InitializeCriticalSection(&cond->waiters_count_lock);
134
135 cond->waiters_done = CreateEvent(NULL, // no security
136 FALSE, // auto-reset
137 FALSE, // non-signaled initially
138 NULL); // unnamed
139 if (!cond->waiters_done)
140 {
141 CloseHandle(cond->semaphore);
142 return EINA_FALSE;
143 }
144
145 return EINA_TRUE;
146#endif
147}
148
149static inline void
150eina_condition_free(Eina_Condition *cond)
151{
152#if _WIN32_WINNT >= 0x0600
153 /* Nothing to do */
154#else
155 CloseHandle(cond->waiters_done);
156 DeleteCriticalSection(&cond->waiters_count_lock);
157 CloseHandle(cond->semaphore);
158#endif
159}
160
161static inline Eina_Bool
162_eina_condition_internal_timedwait(Eina_Condition *cond, DWORD t)
163{
164#if _WIN32_WINNT >= 0x0600
165 SleepConditionVariableCS(&cond->condition, cond->mutex, t);
166#else
167 DWORD ret;
168 Eina_Bool last_waiter;
169
170 /* Avoid race conditions. */
171 EnterCriticalSection(&cond->waiters_count_lock);
172 cond->waiters_count++;
173 LeaveCriticalSection(&cond->waiters_count_lock);
174
175 /*
176 * This call atomically releases the mutex and waits on the
177 * semaphore until <pthread_cond_signal> or <pthread_cond_broadcast>
178 * are called by another thread.
179 */
180 ret = SignalObjectAndWait(cond->mutex, cond->semaphore, t, FALSE);
181 if (ret == WAIT_FAILED)
182 return EINA_FALSE;
183
184 /* Reacquire lock to avoid race conditions. */
185 EnterCriticalSection(&cond->waiters_count_lock);
186
187 /* We're no longer waiting... */
188 cond->waiters_count--;
189
190 /* Check to see if we're the last waiter after <pthread_cond_broadcast>. */
191 last_waiter = (cond->was_broadcast) && (cond->waiters_count == 0);
192
193 LeaveCriticalSection(&cond->waiters_count_lock);
194
195 /*
196 * If we're the last waiter thread during this particular broadcast
197 * then let all the other threads proceed.
198 */
199 if (last_waiter)
200 {
201 /*
202 * This call atomically signals the <waiters_done_> event and waits until
203 * it can acquire the <external_mutex>. This is required to ensure fairness.
204 */
205 ret = SignalObjectAndWait(cond->waiters_done, cond->mutex, t, FALSE);
206 if (ret == WAIT_FAILED)
207 return EINA_FALSE;
208 }
209 else
210 {
211 /*
212 * Always regain the external mutex since that's the guarantee we
213 * give to our callers.
214 */
215 ret = WaitForSingleObject(cond->mutex, t);
216 if (ret == WAIT_FAILED)
217 return EINA_FALSE;
218 }
219#endif
220
221 return EINA_TRUE;
222}
223
224static inline Eina_Bool
225eina_condition_timedwait(Eina_Condition *cond, double val)
226{
227 return _eina_condition_internal_timedwait(cond, (DWORD)(val * 1000));
228}
229
230static inline Eina_Bool
231eina_condition_wait(Eina_Condition *cond)
232{
233 return _eina_condition_internal_timedwait(cond, INFINITE);
234}
235
236static inline Eina_Bool
237eina_condition_broadcast(Eina_Condition *cond)
238{
239#if _WIN32_WINNT >= 0x0600
240 WakeAllConditionVariable(&cond->condition);
241 return EINA_TRUE;
242#else
243 Eina_Bool have_waiters;
244
245 /*
246 * This is needed to ensure that <waiters_count_> and <was_broadcast_> are
247 * consistent relative to each other.
248 */
249 EnterCriticalSection(&cond->waiters_count_lock);
250 have_waiters = EINA_FALSE;
251
252 if (cond->waiters_count > 0)
253 {
254 /*
255 * We are broadcasting, even if there is just one waiter...
256 * Record that we are broadcasting, which helps optimize
257 * <pthread_cond_wait> for the non-broadcast case.
258 */
259 cond->was_broadcast = EINA_TRUE;
260 have_waiters = EINA_TRUE;
261 }
262
263 if (have_waiters)
264 {
265 DWORD ret;
266
267 /* Wake up all the waiters atomically. */
268 ret = ReleaseSemaphore(cond->semaphore, cond->waiters_count, 0);
269 LeaveCriticalSection(&cond->waiters_count_lock);
270 if (!ret) return EINA_FALSE;
271
272 /*
273 * Wait for all the awakened threads to acquire the counting
274 * semaphore.
275 */
276 ret = WaitForSingleObject(cond->waiters_done, INFINITE);
277 if (ret == WAIT_FAILED)
278 return EINA_FALSE;
279 /*
280 * This assignment is okay, even without the <waiters_count_lock_> held
281 * because no other waiter threads can wake up to access it.
282 */
283 cond->was_broadcast = EINA_FALSE;
284 }
285 else
286 LeaveCriticalSection(&cond->waiters_count_lock);
287
288 return EINA_TRUE;
289#endif
290}
291
292static inline Eina_Bool
293eina_condition_signal(Eina_Condition *cond)
294{
295#if _WIN32_WINNT >= 0x0600
296 WakeConditionVariable(&cond->condition);
297#else
298 Eina_Bool have_waiters;
299
300 EnterCriticalSection(&cond->waiters_count_lock);
301 have_waiters = (cond->waiters_count > 0);
302 LeaveCriticalSection(&cond->waiters_count_lock);
303
304 /* If there aren't any waiters, then this is a no-op. */
305 if (have_waiters)
306 {
307 if (!ReleaseSemaphore(cond->semaphore, 1, 0))
308 return EINA_FALSE;
309 }
310
311 return EINA_TRUE;
312#endif
313}
314
315static inline Eina_Bool
316eina_rwlock_new(Eina_RWLock *mutex)
317{
318 if (!eina_lock_new(&(mutex->mutex))) return EINA_FALSE;
319 if (!eina_condition_new(&(mutex->cond_read), &(mutex->mutex)))
320 goto on_error1;
321 if (!eina_condition_new(&(mutex->cond_write), &(mutex->mutex)))
322 goto on_error2;
323
324 return EINA_TRUE;
325
326 on_error2:
327 eina_condition_free(&(mutex->cond_read));
328 on_error1:
329 eina_lock_free(&(mutex->mutex));
330 return EINA_FALSE;
331}
332
333static inline void
334eina_rwlock_free(Eina_RWLock *mutex)
335{
336 eina_condition_free(&(mutex->cond_read));
337 eina_condition_free(&(mutex->cond_write));
338 eina_lock_free(&(mutex->mutex));
339}
340
341static inline Eina_Lock_Result
342eina_rwlock_take_read(Eina_RWLock *mutex)
343{
344 DWORD res;
345
346 if (eina_lock_take(&(mutex->mutex)) == EINA_LOCK_FAIL)
347 return EINA_LOCK_FAIL;
348
349 if (mutex->writers)
350 {
351 mutex->readers_count++;
352 while (mutex->writers)
353 {
354 EnterCriticalSection(&mutex->cond_write.waiters_count_lock);
355 mutex->cond_read.waiters_count++;
356 LeaveCriticalSection(&mutex->cond_write.waiters_count_lock);
357 res = WaitForSingleObject(mutex->cond_write.semaphore, INFINITE);
358 if (res != WAIT_OBJECT_0) break;
359 }
360 mutex->readers_count--;
361 }
362 if (res == 0)
363 mutex->readers++;
364 eina_lock_release(&(mutex->mutex));
365
366 return EINA_LOCK_SUCCEED;
367}
368
369static inline Eina_Lock_Result
370eina_rwlock_take_write(Eina_RWLock *mutex)
371{
372 DWORD res;
373
374 if (eina_lock_take(&(mutex->mutex)) == EINA_LOCK_FAIL)
375 return EINA_LOCK_FAIL;
376
377 if (mutex->writers || mutex->readers > 0)
378 {
379 mutex->writers_count++;
380 while (mutex->writers || mutex->readers > 0)
381 {
382 EnterCriticalSection(&mutex->cond_write.waiters_count_lock);
383 mutex->cond_read.waiters_count++;
384 LeaveCriticalSection(&mutex->cond_write.waiters_count_lock);
385 res = WaitForSingleObject(mutex->cond_write.semaphore, INFINITE);
386 if (res != WAIT_OBJECT_0) break;
387 }
388 mutex->writers_count--;
389 }
390 if (res == 0) mutex->writers_count = 1;
391 eina_lock_release(&(mutex->mutex));
392
393 return EINA_LOCK_SUCCEED;
394}
395
396static inline Eina_Lock_Result
397eina_rwlock_release(Eina_RWLock *mutex)
398{
399 if (eina_lock_take(&(mutex->mutex)) == EINA_LOCK_FAIL)
400 return EINA_LOCK_FAIL;
401
402 if (mutex->writers)
403 {
404 mutex->writers = 0;
405 if (mutex->readers_count == 1)
406 {
407 EnterCriticalSection(&mutex->cond_read.waiters_count_lock);
408 if (mutex->cond_read.waiters_count > 0)
409 ReleaseSemaphore(mutex->cond_read.semaphore, 1, 0);
410 LeaveCriticalSection(&mutex->cond_read.waiters_count_lock);
411 }
412 else if (mutex->readers_count > 0)
413 eina_condition_broadcast(&(mutex->cond_read));
414 else if (mutex->writers_count > 0)
415 {
416 EnterCriticalSection (&mutex->cond_write.waiters_count_lock);
417 if (mutex->cond_write.waiters_count > 0)
418 ReleaseSemaphore(mutex->cond_write.semaphore, 1, 0);
419 LeaveCriticalSection (&mutex->cond_write.waiters_count_lock);
420 }
421 }
422 else if (mutex->readers > 0)
423 {
424 mutex->readers--;
425 if (mutex->readers == 0 && mutex->writers_count > 0)
426 {
427 EnterCriticalSection (&mutex->cond_write.waiters_count_lock);
428 if (mutex->cond_write.waiters_count > 0)
429 ReleaseSemaphore(mutex->cond_write.semaphore, 1, 0);
430 LeaveCriticalSection (&mutex->cond_write.waiters_count_lock);
431 }
432 }
433 eina_lock_release(&(mutex->mutex));
434
435 return EINA_LOCK_SUCCEED;
436}
437
438static inline Eina_Bool
439eina_tls_new(Eina_TLS *key)
440{
441 if ((*key = TlsAlloc()) == TLS_OUT_OF_INDEXES)
442 return EINA_FALSE;
443 return EINA_TRUE;
444}
445
446static inline void
447eina_tls_free(Eina_TLS key)
448{
449 TlsFree(key);
450}
451
452static inline void *
453eina_tls_get(Eina_TLS key)
454{
455 return (void*)TlsGetValue(key);
456}
457
458static inline Eina_Bool
459eina_tls_set(Eina_TLS key, const void *data)
460{
461 if (TlsSetValue(key, (LPVOID)data) == 0)
462 return EINA_FALSE;
463 return EINA_TRUE;
464}
465
466#endif
diff --git a/libraries/eina/src/include/eina_inline_lock_wince.x b/libraries/eina/src/include/eina_inline_lock_wince.x
new file mode 100644
index 0000000..965d475
--- /dev/null
+++ b/libraries/eina/src/include/eina_inline_lock_wince.x
@@ -0,0 +1,178 @@
1/* EINA - EFL data type library
2 * Copyright (C) 2011 Vincent Torri
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library;
16 * if not, see <http://www.gnu.org/licenses/>.
17 */
18
19#ifndef EINA_INLINE_LOCK_WIN32_X_
20#define EINA_INLINE_LOCK_WIN32_X_
21
22#include <windows.h>
23
24EAPI extern Eina_Bool _threads_activated;
25
26typedef HANDLE Eina_Lock;
27typedef Eina_Lock Eina_RWLock;
28typedef DWORD Eina_TLS;
29
30static inline Eina_Bool
31eina_lock_new(Eina_Lock *mutex)
32{
33 Eina_Lock m;
34
35 m = CreateMutex(NULL, FALSE, NULL);
36 if (m) *mutex = m;
37 return (m != NULL);
38}
39
40static inline void
41eina_lock_free(Eina_Lock *mutex)
42{
43 CloseHandle(*mutex);
44}
45
46static inline Eina_Lock_Result
47eina_lock_take(Eina_Lock *mutex)
48{
49 DWORD res;
50
51#ifdef EINA_HAVE_ON_OFF_THREADS
52 if (!_eina_threads_activated) return EINA_LOCK_FAIL;
53#endif
54
55 res = WaitForSingleObject(*mutex, INFINITE);
56 if ((res == WAIT_ABANDONED) || (res == WAIT_FAILED))
57 return EINA_LOCK_FAIL;
58
59 return EINA_LOCK_SUCCEED;
60}
61
62static inline Eina_Lock_Result
63eina_lock_take_try(Eina_Lock *mutex)
64{
65 return eina_lock_take(*mutex);
66}
67
68static inline Eina_Lock_Result
69eina_lock_release(Eina_Lock *mutex)
70{
71#ifdef EINA_HAVE_ON_OFF_THREADS
72 if (!_eina_threads_activated) return ;
73#endif
74
75 return ReleaseMutex(*mutex) ? EINA_LOCK_SUCCEED : EINA_LOCK_FAIL;
76}
77
78static inline void
79eina_lock_debug(const Eina_Lock *mutex)
80{
81}
82
83static inline Eina_Bool
84eina_condition_new(Eina_Condition *cond, Eina_Lock *mutex)
85{
86 return EINA_FALSE;
87}
88
89static inline void
90eina_condition_free(Eina_Condition *cond)
91{
92}
93
94static inline Eina_Bool
95eina_condition_wait(Eina_Condition *cond)
96{
97 return EINA_FALSE;
98}
99
100static inline Eina_Bool
101eina_condition_timedwait(Eina_Condition *cond, double t)
102{
103 return EINA_FALSE;
104}
105
106static inline Eina_Bool
107eina_condition_broadcast(Eina_Condition *cond)
108{
109 return EINA_FALSE;
110}
111
112static inline Eina_Bool
113eina_condition_signal(Eina_Condition *cond)
114{
115 return EINA_FALSE;
116}
117
118static inline Eina_Bool
119eina_rwlock_new(Eina_RWLock *mutex)
120{
121 return eina_lock_new(mutex);
122}
123
124static inline void
125eina_rwlock_free(Eina_RWLock *mutex)
126{
127 return eina_lock_free(mutex);
128}
129
130static inline Eina_Lock_Result
131eina_rwlock_take_read(Eina_RWLock *mutex)
132{
133 return eina_lock_take(mutex);
134}
135
136static inline Eina_Lock_Result
137eina_rwlock_take_write(Eina_RWLock *mutex)
138{
139 return eina_lock_take(mutex);
140}
141
142static inline Eina_Lock_Result
143eina_rwlock_release(Eina_RWLock *mutex)
144{
145 return eina_lock_release(mutex);
146}
147
148static inline Eina_Bool
149eina_tls_new(Eina_TLS *key)
150{
151 if (TlsAlloc() == TLS_OUT_OF_INDEXES)
152 return EINA_FALSE;
153 return EINA_TRUE;
154}
155
156static inline void
157eina_tls_free(Eina_TLS key)
158{
159 TlsFree(key);
160}
161
162static inline void *
163eina_tls_get(Eina_TLS key)
164{
165 return (void*)TlsGetValue(key);
166}
167
168static inline Eina_Bool
169eina_tls_set(Eina_TLS key, const void *data)
170{
171 if (TlsSetValue(key, (LPVOID)data) == 0)
172 return EINA_FALSE;
173 return EINA_TRUE;
174}
175
176
177
178#endif
diff --git a/libraries/eina/src/include/eina_inline_log.x b/libraries/eina/src/include/eina_inline_log.x
new file mode 100644
index 0000000..4cdd7d8
--- /dev/null
+++ b/libraries/eina/src/include/eina_inline_log.x
@@ -0,0 +1,197 @@
1/* EINA - EFL data type library
2 * Copyright (C) 2002-2008 Gustavo Sverzut Barbieri
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library;
16 * if not, see <http://www.gnu.org/licenses/>.
17 */
18
19#ifndef EINA_LOG_INLINE_H_
20#define EINA_LOG_INLINE_H_
21
22/**
23 * @addtogroup Eina_Log_Group Log
24 *
25 * @{
26 */
27
28/**
29 * Checks whenever the given level should be printed out.
30 *
31 * This is useful to enable certain blocks of code just when given
32 * level is to be used.
33 *
34 * @code
35 * #include <Eina.h>
36 *
37 * void my_func(void *data)
38 * {
39 * if (eina_log_level_check(EINA_LOG_LEVEL_WARN))
40 * expensive_debugging_code(data);
41 *
42 * my_func_code(data);
43 * }
44 * @endcode
45 *
46 * @return #EINA_TRUE if level is equal or smaller than the current global
47 * logging level.
48 */
49static inline Eina_Bool
50eina_log_level_check(int level)
51{
52 return eina_log_level_get() <= level;
53}
54
55/**
56 * Checks whenever the given level should be printed out.
57 *
58 * This is useful to enable certain blocks of code just when given
59 * level is to be used.
60 *
61 * @code
62 * #include <Eina.h>
63 *
64 * extern int _my_log_dom;
65 *
66 * void my_func(void *data)
67 * {
68 * if (eina_log_domain_level_check(_my_log_dom, EINA_LOG_LEVEL_WARN))
69 * expensive_debugging_code(data);
70 *
71 * my_func_code(data);
72 * }
73 * @endcode
74 *
75 * @return #EINA_TRUE if level is equal or smaller than the current
76 * domain logging level.
77 */
78static inline Eina_Bool
79eina_log_domain_level_check(int domain, int level)
80{
81 int dom_level = eina_log_domain_registered_level_get(domain);
82 if (EINA_UNLIKELY(dom_level == EINA_LOG_LEVEL_UNKNOWN))
83 return EINA_FALSE;
84 return dom_level <= level;
85}
86
87/**
88 * Function to format the level as a 3 character (+1 null byte) string.
89 *
90 * This function converts the given level to a known string name (CRI,
91 * ERR, WRN, INF or DBG) or a zero-padded 3-character string. In any
92 * case the last byte will contain a trailing null byte.
93 *
94 * If extreme level values are used (greater than 999 and smaller than
95 * -99), then the value will just consider the less significant
96 * part. This is so uncommon that users should handle this in their
97 * code.
98 *
99 * @param level what level value to use.
100 * @param name where to write the actual value.
101 *
102 * @return pointer to @p name.
103 */
104static inline const char *
105eina_log_level_name_get(int level, char name[4])
106{
107#define BCPY(A, B, C) \
108 do { name[0] = A; name[1] = B; name[2] = C; } while (0)
109
110 if (EINA_UNLIKELY(level < 0))
111 {
112 name[0] = '-';
113 name[1] = '0' + (-level / 10) % 10;
114 name[2] = '0' + (-level % 10);
115 }
116 else if (EINA_UNLIKELY(level >= EINA_LOG_LEVELS))
117 {
118 name[0] = '0' + (level / 100) % 10;
119 name[1] = '0' + (level / 10) % 10;
120 name[2] = '0' + level % 10;
121 }
122 else if (level == 0)
123 BCPY('C', 'R', 'I');
124 else if (level == 1)
125 BCPY('E', 'R', 'R');
126 else if (level == 2)
127 BCPY('W', 'R', 'N');
128 else if (level == 3)
129 BCPY('I', 'N', 'F');
130 else if (level == 4)
131 BCPY('D', 'B', 'G');
132 else
133 BCPY('?', '?', '?');
134
135 name[3] = '\0';
136
137 return name;
138}
139
140/**
141 * Function to get recommended color value for level.
142 *
143 * This function will not check if colors are enabled or not before
144 * returning the level color. If you desire such check, use
145 * eina_log_level_color_if_enabled_get().
146 *
147 * @param level what level value to use.
148 *
149 * @return pointer to null byte terminated ANSI color string to be
150 * used in virtual terminals supporting VT100 color codes.
151 *
152 * @see eina_log_level_color_if_enabled_get()
153 */
154static inline const char *
155eina_log_level_color_get(int level)
156{
157 if (level <= 0)
158 return EINA_COLOR_LIGHTRED;
159 else if (level == 1)
160 return EINA_COLOR_RED;
161 else if (level == 2)
162 return EINA_COLOR_YELLOW;
163 else if (level == 3)
164 return EINA_COLOR_GREEN;
165 else if (level == 4)
166 return EINA_COLOR_LIGHTBLUE;
167 else
168 return EINA_COLOR_BLUE;
169}
170
171/**
172 * Function to get recommended color value for level, if colors are
173 * enabled.
174 *
175 * This function will check if colors are enabled or not before
176 * returning the level color. If colors are disabled, then empty
177 * string is returned.
178 *
179 * @param level what level value to use.
180 *
181 * @return pointer to null byte terminated ANSI color string to be
182 * used in virtual terminals supporting VT100 color codes. If
183 * colors are disabled, the empty string is returned.
184 */
185static inline const char *
186eina_log_level_color_if_enabled_get(int level)
187{
188 if (eina_log_color_disable_get())
189 return "";
190 return eina_log_level_color_get(level);
191}
192
193/**
194 * @}
195 */
196
197#endif /* EINA_LOG_INLINE_H_ */
diff --git a/libraries/eina/src/include/eina_inline_mempool.x b/libraries/eina/src/include/eina_inline_mempool.x
new file mode 100644
index 0000000..a67ec3d
--- /dev/null
+++ b/libraries/eina/src/include/eina_inline_mempool.x
@@ -0,0 +1,127 @@
1/* EINA - EFL data type library
2 * Copyright (C) 2008 Cedric Bail
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library;
16 * if not, see <http://www.gnu.org/licenses/>.
17 */
18
19#ifndef EINA_INLINE_MEMPOOL_X_
20#define EINA_INLINE_MEMPOOL_X_
21
22/**
23 * @addtogroup Eina_Memory_Pool_Group Memory Pool
24 *
25 * @{
26 */
27
28/* Memory Pool */
29typedef struct _Eina_Mempool_Backend_ABI1 Eina_Mempool_Backend_ABI1;
30typedef struct _Eina_Mempool_Backend_ABI2 Eina_Mempool_Backend_ABI2;
31
32struct _Eina_Mempool_Backend
33{
34 const char *name;
35 void *(*init)(const char *context, const char *options, va_list args);
36 void (*free)(void *data, void *element);
37 void *(*alloc)(void *data, unsigned int size);
38 void *(*realloc)(void *data, void *element, unsigned int size);
39 void (*garbage_collect)(void *data);
40 void (*statistics)(void *data);
41 void (*shutdown)(void *data);
42 void (*repack)(void *data, Eina_Mempool_Repack_Cb cb, void *cb_data);
43};
44
45struct _Eina_Mempool_Backend_ABI1
46{
47 const char *name;
48 void *(*init)(const char *context, const char *options, va_list args);
49 void (*free)(void *data, void *element);
50 void *(*alloc)(void *data, unsigned int size);
51 void *(*realloc)(void *data, void *element, unsigned int size);
52 void (*garbage_collect)(void *data);
53 void (*statistics)(void *data);
54 void (*shutdown)(void *data);
55};
56
57struct _Eina_Mempool_Backend_ABI2
58{
59 void (*repack)(void *data, Eina_Mempool_Repack_Cb cb, void *cb_data);
60};
61
62struct _Eina_Mempool
63{
64 Eina_Mempool_Backend_ABI1 backend;
65 void *backend_data;
66 Eina_Mempool_Backend_ABI2 *backend2;
67};
68
69/**
70 * @brief Re-allocate a amount memory by the given mempool.
71 *
72 * @param mp The mempool.
73 * @param element The element to re-allocate.
74 * @param size The size in bytes to re-allocate.
75 * @return The newly re-allocated data.
76 *
77 * This function re-allocates @p element with @p size bytes, using the
78 * mempool @p mp and returns the allocated data. If not used anymore,
79 * the data must be freed with eina_mempool_free(). No check is done
80 * on @p mp, so it must be a valid mempool.
81 */
82static inline void *
83eina_mempool_realloc(Eina_Mempool *mp, void *element, unsigned int size)
84{
85 return mp->backend.realloc(mp->backend_data, element, size);
86}
87
88/**
89 * @brief Allocate a amount memory by the given mempool.
90 *
91 * @param mp The mempool.
92 * @param size The size in bytes to allocate.
93 * @return The newly allocated data.
94 *
95 * This function allocates @p size bytes, using the mempool @p mp and
96 * returns the allocated data. If not used anymore, the data must be
97 * freed with eina_mempool_free(). No check is done on @p mp, so it
98 * must be a valid mempool.
99 */
100static inline void *
101eina_mempool_malloc(Eina_Mempool *mp, unsigned int size)
102{
103 return mp->backend.alloc(mp->backend_data, size);
104}
105
106/**
107 * @brief Free the allocated ressources by the given mempool.
108 *
109 * @param mp The mempool.
110 * @param element The data to free.
111 *
112 * This function frees @p element allocated by @p mp. @p element must
113 * have been obtained by eina_mempool_malloc() or
114 * eina_mempool_realloc(). No check is done on @p mp, so it must be a
115 * valid mempool.
116 */
117static inline void
118eina_mempool_free(Eina_Mempool *mp, void *element)
119{
120 mp->backend.free(mp->backend_data, element);
121}
122
123/**
124 * @}
125 */
126
127#endif
diff --git a/libraries/eina/src/include/eina_inline_rbtree.x b/libraries/eina/src/include/eina_inline_rbtree.x
new file mode 100644
index 0000000..954774b
--- /dev/null
+++ b/libraries/eina/src/include/eina_inline_rbtree.x
@@ -0,0 +1,50 @@
1/* EINA - EFL data type library
2 * Copyright (C) 2002-2008 Cedric BAIL
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library;
16 * if not, see <http://www.gnu.org/licenses/>.
17 */
18
19#ifndef EINA_RBTREE_INLINE_H_
20#define EINA_RBTREE_INLINE_H_
21
22/**
23 * @addtogroup Eina_Rbtree_Group Red-Black tree
24 *
25 * @brief These functions provide Red-Black trees management.
26 *
27 * @{
28 */
29
30static inline Eina_Rbtree *
31eina_rbtree_inline_lookup(const Eina_Rbtree *root, const void *key, int length, Eina_Rbtree_Cmp_Key_Cb cmp, const void *data)
32{
33 int result;
34
35 while (root)
36 {
37 result = cmp(root, key, length, (void*) data);
38 if (result == 0) return (Eina_Rbtree*) root;
39
40 root = root->son[result < 0 ? 0 : 1];
41 }
42
43 return NULL;
44}
45
46/**
47 * @}
48 */
49
50#endif
diff --git a/libraries/eina/src/include/eina_inline_rectangle.x b/libraries/eina/src/include/eina_inline_rectangle.x
new file mode 100644
index 0000000..29ad24b
--- /dev/null
+++ b/libraries/eina/src/include/eina_inline_rectangle.x
@@ -0,0 +1,254 @@
1/* EINA - EFL data type library
2 * Copyright (C) 2007-2008 Jorge Luis Zapata Muga
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library;
16 * if not, see <http://www.gnu.org/licenses/>.
17 */
18
19#ifndef EINA_INLINE_RECTANGLE_H__
20#define EINA_INLINE_RECTANGLE_H__
21
22/**
23 * @addtogroup Eina_Rectangle_Group Rectangle
24 *
25 * @brief These functions provide rectangle management.
26 *
27 * @{
28 */
29
30/**
31 * @brief Check if the given spans intersect.
32 *
33 * @param c1 The column of the first span.
34 * @param l1 The length of the first span.
35 * @param c2 The column of the second span.
36 * @param l2 The length of the second span.
37 * @return #EINA_TRUE on success, #EINA_FALSE otherwise.
38 *
39 * This function returns #EINA_TRUE if the given spans intersect,
40 * #EINA_FALSE otherwise.
41 */
42static inline int
43eina_spans_intersect(int c1, int l1, int c2, int l2)
44{
45 return (!(((c2 + l2) <= c1) || (c2 >= (c1 + l1))));
46}
47
48/**
49 * @brief Check if the given rectangle is empty.
50 *
51 * @param r The rectangle to check.
52 * @return #EINA_TRUE if the rectangle is empty, #EINA_FALSE otherwise.
53 *
54 * This function returns #EINA_TRUE if @p r is empty, #EINA_FALSE
55 * otherwise. No check is done on @p r, so it must be a valid
56 * rectangle.
57 */
58static inline Eina_Bool
59eina_rectangle_is_empty(const Eina_Rectangle *r)
60{
61 return ((r->w < 1) || (r->h < 1)) ? EINA_TRUE : EINA_FALSE;
62}
63
64/**
65 * @brief Set the coordinates and size of the given rectangle.
66 *
67 * @param r The rectangle.
68 * @param x The top-left x coordinate of the rectangle.
69 * @param y The top-left y coordinate of the rectangle.
70 * @param w The width of the rectangle.
71 * @param h The height of the rectangle.
72 *
73 * This function sets its top-left x coordinate to @p x, its top-left
74 * y coordinate to @p y, its width to @p w and its height to @p h. No
75 * check is done on @p r, so it must be a valid rectangle.
76 */
77static inline void
78eina_rectangle_coords_from(Eina_Rectangle *r, int x, int y, int w, int h)
79{
80 r->x = x;
81 r->y = y;
82 r->w = w;
83 r->h = h;
84}
85
86/**
87 * @brief Check if the given rectangles intersect.
88 *
89 * @param r1 The first rectangle.
90 * @param r2 The second rectangle.
91 * @return #EINA_TRUE if the rectangles intersect, #EINA_FALSE otherwise.
92 *
93 * This function returns #EINA_TRUE if @p r1 and @p r2 intersect,
94 * #EINA_FALSE otherwise. No check is done on @p r1 and @p r2, so they
95 * must be valid rectangles.
96 */
97static inline Eina_Bool
98eina_rectangles_intersect(const Eina_Rectangle *r1, const Eina_Rectangle *r2)
99{
100 return (eina_spans_intersect(r1->x, r1->w, r2->x, r2->w) && eina_spans_intersect(r1->y, r1->h, r2->y, r2->h)) ? EINA_TRUE : EINA_FALSE;
101}
102
103/**
104 * @brief Check if the given x-coordinate is in the rectangle .
105 *
106 * @param r The rectangle.
107 * @param x The x coordinate.
108 * @return #EINA_TRUE on success, #EINA_FALSE otherwise.
109 *
110 * This function returns #EINA_TRUE if @p x is in @p r with respect to
111 * the horizontal direction, #EINA_FALSE otherwise. No check is done
112 * on @p r, so it must be a valid rectangle.
113 */
114static inline Eina_Bool
115eina_rectangle_xcoord_inside(const Eina_Rectangle *r, int x)
116{
117 return ((x >= r->x) && (x < (r->x + r->w))) ? EINA_TRUE : EINA_FALSE;
118}
119
120/**
121 * @brief Check if the given y-coordinate is in the rectangle .
122 *
123 * @param r The rectangle.
124 * @param y The y coordinate.
125 * @return #EINA_TRUE on success, #EINA_FALSE otherwise.
126 *
127 * This function returns #EINA_TRUE if @p y is in @p r with respect to
128 * the vertical direction, #EINA_FALSE otherwise. No check is done
129 * on @p r, so it must be a valid rectangle.
130 */
131static inline Eina_Bool
132eina_rectangle_ycoord_inside(const Eina_Rectangle *r, int y)
133{
134 return ((y >= r->y) && (y < (r->y + r->h))) ? EINA_TRUE : EINA_FALSE;
135}
136
137/**
138 * @brief Check if the given point is in the rectangle .
139 *
140 * @param r The rectangle.
141 * @param x The x coordinate of the point.
142 * @param y The y coordinate of the point.
143 * @return #EINA_TRUE on success, #EINA_FALSE otherwise.
144 *
145 * This function returns #EINA_TRUE if the point of coordinate (@p x,
146 * @p y) is in @p r, #EINA_FALSE otherwise. No check is done on @p r,
147 * so it must be a valid rectangle.
148 */
149static inline Eina_Bool
150eina_rectangle_coords_inside(const Eina_Rectangle *r, int x, int y)
151{
152 return (eina_rectangle_xcoord_inside(r, x) && eina_rectangle_ycoord_inside(r, y)) ? EINA_TRUE : EINA_FALSE;
153}
154
155/**
156 * @brief Get the union of two rectangles.
157 *
158 * @param dst The first rectangle.
159 * @param src The second rectangle.
160 *
161 * This function get the union of the rectangles @p dst and @p src. The
162 * result is stored in @p dst. No check is done on @p dst or @p src,
163 * so they must be valid rectangles.
164 */
165static inline void
166eina_rectangle_union(Eina_Rectangle *dst, const Eina_Rectangle *src)
167{
168 /* left */
169 if (dst->x > src->x)
170 {
171 dst->w += dst->x - src->x;
172 dst->x = src->x;
173 }
174 /* right */
175 if ((dst->x + dst->w) < (src->x + src->w))
176 dst->w = src->x + src->w;
177 /* top */
178 if (dst->y > src->y)
179 {
180 dst->h += dst->y - src->y;
181 dst->y = src->y;
182 }
183 /* bottom */
184 if ((dst->y + dst->h) < (src->y + src->h))
185 dst->h = src->y + src->h;
186}
187
188/**
189 * @brief Get the intersection of two rectangles.
190 *
191 * @param dst The first rectangle.
192 * @param src The second rectangle.
193 * @return #EINA_TRUE if the rectangles intersect, #EINA_FALSE
194 * otherwise.
195 *
196 * This function get the intersection of the rectangles @p dst and
197 * @p src. The result is stored in @p dst. No check is done on @p dst
198 * or @p src, so they must be valid rectangles.
199 */
200static inline Eina_Bool
201eina_rectangle_intersection(Eina_Rectangle *dst, const Eina_Rectangle *src)
202{
203 if (!(eina_rectangles_intersect(dst, src)))
204 return EINA_FALSE;
205
206 /* left */
207 if (dst->x < src->x)
208 {
209 dst->w += dst->x - src->x;
210 dst->x = src->x;
211 if (dst->w < 0)
212 dst->w = 0;
213 }
214 /* right */
215 if ((dst->x + dst->w) > (src->x + src->w))
216 dst->w = src->x + src->w - dst->x;
217 /* top */
218 if (dst->y < src->y)
219 {
220 dst->h += dst->y - src->y;
221 dst->y = src->y;
222 if (dst->h < 0)
223 dst->h = 0;
224 }
225 /* bottom */
226 if ((dst->y + dst->h) > (src->y + src->h))
227 dst->h = src->y + src->h - dst->y;
228
229 return EINA_TRUE;
230}
231
232static inline void
233eina_rectangle_rescale_in(const Eina_Rectangle *out, const Eina_Rectangle *in, Eina_Rectangle *res)
234{
235 res->x = in->x - out->x;
236 res->y = in->y - out->y;
237 res->w = in->w;
238 res->h = in->h;
239}
240
241static inline void
242eina_rectangle_rescale_out(const Eina_Rectangle *out, const Eina_Rectangle *in, Eina_Rectangle *res)
243{
244 res->x = out->x + in->x;
245 res->y = out->y + in->y;
246 res->w = out->w;
247 res->h = out->h;
248}
249
250/**
251 * @}
252 */
253
254#endif
diff --git a/libraries/eina/src/include/eina_inline_str.x b/libraries/eina/src/include/eina_inline_str.x
new file mode 100644
index 0000000..2daeb85
--- /dev/null
+++ b/libraries/eina/src/include/eina_inline_str.x
@@ -0,0 +1,76 @@
1/* EINA - EFL data type library
2 * Copyright (C) 2002-2008 Gustavo Sverzut Barbieri
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library;
16 * if not, see <http://www.gnu.org/licenses/>.
17 */
18
19#ifndef EINA_STR_INLINE_H_
20#define EINA_STR_INLINE_H_
21
22/**
23 * @addtogroup Eina_String_Group String
24 *
25 * @{
26 */
27
28/**
29 * @brief Count up to a given amount of bytes of the given string.
30 *
31 * @param str The string pointer.
32 * @param maxlen The maximum length to allow.
33 * @return the string size or (size_t)-1 if greater than @a maxlen.
34 *
35 * This function returns the size of @p str, up to @p maxlen
36 * characters. It avoid needless iterations after that size. @p str
37 * must be a valid pointer and MUST not be @c NULL, otherwise this
38 * function will crash. This function returns the string size, or
39 * (size_t)-1 if the size is greater than @a maxlen.
40 */
41static inline size_t
42eina_strlen_bounded(const char *str, size_t maxlen)
43{
44 const char *itr, *str_maxend = str + maxlen;
45 for (itr = str; *itr != '\0'; itr++)
46 if (itr == str_maxend) return (size_t)-1;
47 return itr - str;
48}
49
50/**
51 * @brief Join two strings of known length.
52 *
53 * @param dst The buffer to store the result.
54 * @param size Size (in byte) of the buffer.
55 * @param sep The separator character to use.
56 * @param a First string to use, before @p sep.
57 * @param b Second string to use, after @p sep.
58 * @return The number of characters printed.
59 *
60 * This function is similar to eina_str_join_len(), but will compute
61 * the length of @p a and @p b using strlen().
62 *
63 * @see eina_str_join_len()
64 * @see eina_str_join_static()
65 */
66static inline size_t
67eina_str_join(char *dst, size_t size, char sep, const char *a, const char *b)
68{
69 return eina_str_join_len(dst, size, sep, a, strlen(a), b, strlen(b));
70}
71
72/**
73 * @}
74 */
75
76#endif /* EINA_STR_INLINE_H_ */
diff --git a/libraries/eina/src/include/eina_inline_stringshare.x b/libraries/eina/src/include/eina_inline_stringshare.x
new file mode 100644
index 0000000..bfd7677
--- /dev/null
+++ b/libraries/eina/src/include/eina_inline_stringshare.x
@@ -0,0 +1,91 @@
1/* EINA - EFL data type library
2 * Copyright (C) 2002-2008 Gustavo Sverzut Barbieri
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library;
16 * if not, see <http://www.gnu.org/licenses/>.
17 */
18
19#ifndef EINA_STRINGSHARE_INLINE_H_
20#define EINA_STRINGSHARE_INLINE_H_
21
22#include <string.h>
23#include "eina_stringshare.h"
24/**
25 * @addtogroup Eina_Stringshare_Group Stringshare
26 *
27 * @{
28 */
29
30/**
31 * Replace the previously stringshared pointer with new content.
32 *
33 * The string pointed by @a p_str should be previously stringshared or
34 * @c NULL and it will be eina_stringshare_del(). The new string will
35 * be passed to eina_stringshare_add() and then assigned to @c *p_str.
36 *
37 * @param p_str pointer to the stringhare to be replaced. Must not be
38 * @c NULL, but @c *p_str may be @c NULL as it is a valid
39 * stringshare handle.
40 * @param news new string to be stringshared, may be @c NULL.
41 *
42 * @return #EINA_TRUE if the strings were different and thus replaced,
43 * #EINA_FALSE if the strings were the same after shared.
44 */
45static inline Eina_Bool
46eina_stringshare_replace(const char **p_str, const char *news)
47{
48 if (*p_str == news) return EINA_FALSE;
49
50 news = eina_stringshare_add(news);
51 eina_stringshare_del(*p_str);
52 if (*p_str == news)
53 return EINA_FALSE;
54 *p_str = news;
55 return EINA_TRUE;
56}
57
58/**
59 * Replace the previously stringshared pointer with a new content.
60 *
61 * The string pointed by @a p_str should be previously stringshared or
62 * @c NULL and it will be eina_stringshare_del(). The new string will
63 * be passed to eina_stringshare_add_length() and then assigned to @c *p_str.
64 *
65 * @param p_str pointer to the stringhare to be replaced. Must not be
66 * @c NULL, but @c *p_str may be @c NULL as it is a valid
67 * stringshare handle.
68 * @param news new string to be stringshared, may be @c NULL.
69 * @param slen The string size (<= strlen(str)).
70 *
71 * @return #EINA_TRUE if the strings were different and thus replaced,
72 * #EINA_FALSE if the strings were the same after shared.
73 */
74static inline Eina_Bool
75eina_stringshare_replace_length(const char **p_str, const char *news, unsigned int slen)
76{
77 if (*p_str == news) return EINA_FALSE;
78
79 news = eina_stringshare_add_length(news, slen);
80 eina_stringshare_del(*p_str);
81 if (*p_str == news)
82 return EINA_FALSE;
83 *p_str = news;
84 return EINA_TRUE;
85}
86
87/**
88 * @}
89 */
90
91#endif /* EINA_STRINGSHARE_INLINE_H_ */
diff --git a/libraries/eina/src/include/eina_inline_tiler.x b/libraries/eina/src/include/eina_inline_tiler.x
new file mode 100644
index 0000000..2a8b205
--- /dev/null
+++ b/libraries/eina/src/include/eina_inline_tiler.x
@@ -0,0 +1,151 @@
1/* EINA - EFL data type library
2 * Copyright (C) 2002-2009 Rafael Antognolli
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library;
16 * if not, see <http://www.gnu.org/licenses/>.
17 */
18
19#ifndef EINA_TILER_INLINE_H_
20#define EINA_TILER_INLINE_H_
21
22#include "eina_safety_checks.h"
23
24/**
25 * @cond LOCAL
26 * This struct should not be accessed directly, it is used by
27 * eina_tile_grid_slicer functions to maintain context and fill "info"
28 * member with correct values for given iteration.
29 */
30struct _Eina_Tile_Grid_Slicer
31{
32 unsigned long col1, col2, row1, row2; // initial and final col,row
33 int tile_w, tile_h; // tile width, height
34 int x_rel, y_rel; // starting x,y coordinates of the first col,row
35 int w1_rel, h1_rel; // width,height of the first col,row
36 int w2_rel, h2_rel; // width,height of the last col,row
37 struct Eina_Tile_Grid_Info info; // info about the current tile
38 Eina_Bool first;
39};
40
41/**
42 * @endcond
43 */
44
45static inline Eina_Bool
46eina_tile_grid_slicer_next(Eina_Tile_Grid_Slicer *slc, const Eina_Tile_Grid_Info **rect)
47{
48 EINA_SAFETY_ON_NULL_RETURN_VAL(slc, 0);
49
50 if (slc->first)
51 {
52 slc->first = 0;
53 *rect = &slc->info;
54 return EINA_TRUE;
55 }
56
57 slc->info.col++;
58
59 if (slc->info.col > slc->col2)
60 {
61 slc->info.row++;
62 if (slc->info.row > slc->row2)
63 return EINA_FALSE;
64 else if (slc->info.row < slc->row2)
65 slc->info.rect.h = slc->tile_h;
66 else
67 slc->info.rect.h = slc->h2_rel;
68 slc->info.rect.y = 0;
69 slc->info.col = slc->col1;
70 slc->info.rect.x = slc->x_rel;
71 slc->info.rect.w = slc->w1_rel;
72 }
73 else
74 {
75 slc->info.rect.x = 0;
76 if (slc->info.col < slc->col2)
77 slc->info.rect.w = slc->tile_w;
78 else
79 slc->info.rect.w = slc->w2_rel;
80 }
81
82 if (slc->info.rect.w == slc->tile_w && slc->info.rect.h == slc->tile_h)
83 slc->info.full = EINA_TRUE;
84 else
85 slc->info.full = EINA_FALSE;
86
87 *rect = &slc->info;
88
89 return EINA_TRUE;
90}
91
92static inline Eina_Bool
93eina_tile_grid_slicer_setup(Eina_Tile_Grid_Slicer *slc, int x, int y, int w, int h, int tile_w, int tile_h)
94{
95 int tx1, tx2, ty1, ty2;
96
97 EINA_SAFETY_ON_NULL_RETURN_VAL(slc, 0);
98
99 tx1 = x;
100 ty1 = y;
101 tx2 = x + w - 1;
102 ty2 = y + h - 1;
103
104 if (x < 0 || y < 0 || w <= 0 || h <= 0 || tile_w <= 0 || tile_h <= 0)
105 {
106 slc->first = 0;
107 slc->col1 = slc->row1 = 0;
108 slc->col2 = slc->row2 = 0;
109 slc->info.col = slc->col1;
110 slc->info.row = slc->row1;
111 return EINA_TRUE;
112 }
113
114 slc->col1 = tx1 / tile_w;
115 slc->row1 = ty1 / tile_h;
116 slc->col2 = (tx2 - 0) / tile_w;
117 slc->row2 = (ty2 - 0) / tile_h;
118 slc->x_rel = tx1 % tile_w;
119 slc->y_rel = ty1 % tile_h;
120 slc->w1_rel = tile_w - slc->x_rel;
121 slc->h1_rel = tile_h - slc->y_rel;
122 slc->w2_rel = tx2 % tile_w + 1;
123 slc->h2_rel = ty2 % tile_h + 1;
124
125 slc->tile_w = tile_w;
126 slc->tile_h = tile_h;
127
128 slc->first = 1;
129 slc->info.col = slc->col1;
130 slc->info.row = slc->row1;
131 slc->info.rect.x = slc->x_rel;
132 slc->info.rect.y = slc->y_rel;
133
134 if (slc->info.col == slc->col2)
135 slc->w1_rel = slc->w2_rel - slc->x_rel;
136
137 if (slc->info.row == slc->row2)
138 slc->h1_rel = slc->h2_rel - slc->y_rel;
139
140 slc->info.rect.w = slc->w1_rel;
141 slc->info.rect.h = slc->h1_rel;
142
143 if (slc->info.rect.w == slc->tile_w && slc->info.rect.h == slc->tile_h)
144 slc->info.full = EINA_TRUE;
145 else
146 slc->info.full = EINA_FALSE;
147
148 return EINA_TRUE;
149}
150
151#endif
diff --git a/libraries/eina/src/include/eina_inline_trash.x b/libraries/eina/src/include/eina_inline_trash.x
new file mode 100644
index 0000000..4a50611
--- /dev/null
+++ b/libraries/eina/src/include/eina_inline_trash.x
@@ -0,0 +1,90 @@
1/* EINA - EFL data type library
2 * Copyright (C) 2008 Cedric Bail
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library;
16 * if not, see <http://www.gnu.org/licenses/>.
17 */
18
19#ifndef EINA_INLINE_TRASH_X__
20#define EINA_INLINE_TRASH_X__
21
22/**
23 * @brief Initialize a trash before using it.
24 *
25 * @param trash The trash.
26 *
27 * This function just set to zero the trash to correctly
28 * initialize it.
29 *
30 * @note You can just set *trash to NULL and you will have
31 * the same result.
32 */
33static inline void
34eina_trash_init(Eina_Trash **trash)
35{
36 *trash = NULL;
37}
38
39/**
40 * @brief Push an unused pointer in the trash instead of freeing it.
41 *
42 * @param trash A pointer to an Eina_Trash.
43 * @param data An unused pointer big enougth to put a (void*).
44 *
45 * Instead of freeing a pointer and put pressure on malloc/free
46 * you can push it in a trash for a later use. This function just
47 * provide a fast way to push a now unused pointer into a trash.
48 *
49 * @note Do never use the pointer after insertion or bad things will
50 * happens.
51 *
52 * @note This trash will not resize, nor do anything with the size of
53 * the region pointed by @p data, so it's your duty to manage the size.
54 */
55static inline void
56eina_trash_push(Eina_Trash **trash, void *data)
57{
58 Eina_Trash *tmp;
59
60 tmp = (Eina_Trash *)data;
61 tmp->next = *trash;
62 *trash = tmp;
63}
64
65/**
66 * @brief Pop an available pointer from the trash if possible.
67 *
68 * @param trash A pointer to an Eina_Trash.
69 *
70 * Instead of calling malloc, and putting pressure on malloc/free
71 * you can recycle the content of the trash, if it's not empty.
72 *
73 * @note This trash will not resize, nor do anything with the size of
74 * the region pointed by pointer inside the trash, so it's your duty
75 * to manage the size of the returned pointer.
76 */
77static inline void*
78eina_trash_pop(Eina_Trash **trash)
79{
80 void *tmp;
81
82 tmp = *trash;
83
84 if (*trash)
85 *trash = (*trash)->next;
86
87 return tmp;
88}
89
90#endif
diff --git a/libraries/eina/src/include/eina_inline_ustringshare.x b/libraries/eina/src/include/eina_inline_ustringshare.x
new file mode 100644
index 0000000..ace6fdc
--- /dev/null
+++ b/libraries/eina/src/include/eina_inline_ustringshare.x
@@ -0,0 +1,93 @@
1/* EINA - EFL data type library
2 * Copyright (C) 2002-2008 Gustavo Sverzut Barbieri
3 Tom Hacohen
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library;
17 * if not, see <http://www.gnu.org/licenses/>.
18 */
19
20#ifndef EINA_USTRINGSHARE_INLINE_H_
21#define EINA_USTRINGSHARE_INLINE_H_
22
23#include "eina_unicode.h"
24#include "eina_ustringshare.h"
25
26/**
27 * @addtogroup Eina_UStringshare_Group Unicode Stringshare
28 *
29 * @{
30 */
31
32/**
33 * Replace the previously stringshared pointer with new content.
34 *
35 * The string pointed by @a p_str should be previously stringshared or
36 * @c NULL and it will be eina_ustringshare_del(). The new string will
37 * be passed to eina_ustringshare_add() and then assigned to @c *p_str.
38 *
39 * @param p_str pointer to the stringhare to be replaced. Must not be
40 * @c NULL, but @c *p_str may be @c NULL as it is a valid
41 * stringshare handle.
42 * @param news new string to be stringshared, may be @c NULL.
43 *
44 * @return #EINA_TRUE if the strings were different and thus replaced,
45 * #EINA_FALSE if the strings were the same after shared.
46 */
47static inline Eina_Bool
48eina_ustringshare_replace(const Eina_Unicode **p_str, const Eina_Unicode *news)
49{
50 if (*p_str == news) return EINA_FALSE;
51
52 news = eina_ustringshare_add(news);
53 eina_ustringshare_del(*p_str);
54 if (*p_str == news)
55 return EINA_FALSE;
56 *p_str = news;
57 return EINA_TRUE;
58}
59
60/**
61 * Replace the previously stringshared pointer with a new content.
62 *
63 * The string pointed by @a p_str should be previously stringshared or
64 * @c NULL and it will be eina_ustringshare_del(). The new string will
65 * be passed to eina_ustringshare_add_length() and then assigned to @c *p_str.
66 *
67 * @param p_str pointer to the stringhare to be replaced. Must not be
68 * @c NULL, but @c *p_str may be @c NULL as it is a valid
69 * stringshare handle.
70 * @param news new string to be stringshared, may be @c NULL.
71 * @param slen The string size (<= strlen(str)).
72 *
73 * @return #EINA_TRUE if the strings were different and thus replaced,
74 * #EINA_FALSE if the strings were the same after shared.
75 */
76static inline Eina_Bool
77eina_ustringshare_replace_length(const Eina_Unicode **p_str, const Eina_Unicode *news, unsigned int slen)
78{
79 if (*p_str == news) return EINA_FALSE;
80
81 news = eina_ustringshare_add_length(news, slen);
82 eina_ustringshare_del(*p_str);
83 if (*p_str == news)
84 return EINA_FALSE;
85 *p_str = news;
86 return EINA_TRUE;
87}
88
89/**
90 * @}
91 */
92
93#endif /* EINA_USTRINGSHARE_INLINE_H_ */
diff --git a/libraries/eina/src/include/eina_inlist.h b/libraries/eina/src/include/eina_inlist.h
new file mode 100644
index 0000000..1b3ab27
--- /dev/null
+++ b/libraries/eina/src/include/eina_inlist.h
@@ -0,0 +1,813 @@
1/* EINA - EFL data type library
2 * Copyright (C) 2002-2008 Carsten Haitzler, Vincent Torri
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library;
16 * if not, see <http://www.gnu.org/licenses/>.
17 */
18
19#ifndef EINA_INLIST_H_
20#define EINA_INLIST_H_
21
22#include "eina_types.h"
23#include "eina_iterator.h"
24#include "eina_accessor.h"
25#include <stddef.h>
26
27/**
28 * @page inlist_01_example_page Eina_Inlist basic usage
29 * @dontinclude eina_inlist_01.c
30 *
31 * To see the full source for this example, click here: @ref
32 * eina_inlist_01_c
33 *
34 * As explained before, inline lists mean its nodes pointers are part of same
35 * memory block/blob. This is done by using the macro @ref EINA_INLIST inside the
36 * data structure that will be used:
37 *
38 * @skip struct
39 * @until };
40 *
41 * The resulting node representing this struct can be exemplified by the
42 * following picture:
43 *
44 * @image html eina_inlist-node_eg1-my-struct.png
45 * @image rtf eina_inlist-node_eg1-my-struct.png
46 * @image latex eina_inlist-node_eg1-my-struct.eps
47 *
48 * Let's define a comparison function that will be used later during the
49 * sorting of the list:
50 *
51 * @skip int
52 * @until }
53 *
54 * The @ref Eina_Inlist can be used exactly the same way as @ref Eina_List when
55 * appending, prepending and removing items. But since we already have the node
56 * pointers inside the structure, they need to be retrieved with the macro @ref
57 * EINA_INLIST_GET :
58 *
59 * @skip malloc
60 * @until append
61 *
62 * Notice that @ref eina_inlist_append always receives the head of the list as
63 * first argument, and its return value should be used as the list pointer
64 * (head):
65 *
66 * @skip malloc
67 * @until append
68 *
69 * After appending 3 items, the list now should look similar to this:
70 *
71 * @image html eina_inlist-node_eg1-inlist.png
72 * @image rtf eina_inlist-node_eg1-inlist.png
73 * @image latex eina_inlist-node_eg1-inlist.eps width=\textwidth
74 *
75 * The macro @ref EINA_INLIST_FOREACH can be used to iterate over the list:
76 *
77 * @skip printf
78 * @until cur->a
79 *
80 * @ref eina_inlist_promote(), @ref eina_inlist_demote(), @ref
81 * eina_inlist_append_relative() and similar functions all work in the same way
82 * as the @ref Eina_List :
83 *
84 * @skip eina_inlist_promote
85 * @until eina_inlist_demote
86 *
87 * Now let's use the @c sort_cb function declared above to sort our list:
88 *
89 * @skipline eina_inlist_sort
90 *
91 * Removing an element from the inlist is also similar to @ref Eina_List :
92 *
93 * @skip inlist_remove
94 * @until free
95 *
96 * Another way of walking through the inlist.
97 *
98 * @skip for
99 * @until }
100 *
101 * Notice that in the previous piece of code, since we only have the pointers to
102 * the inlist nodes, we have to use the @ref EINA_INLIST_CONTAINER_GET macro
103 * that will return the pointer to the entire structure. Of course, in this case
104 * it is the same as the list pointer, since the @ref EINA_INLIST macro was used
105 * in the beginning of the structure.
106 *
107 * Now to finish this example, lets delete this list:
108 *
109 * @skip while
110 * @until }
111 */
112
113/**
114 * @page inlist_02_example_page Eina_Inlist advanced usage - lists and inlists
115 * @dontinclude eina_inlist_02.c
116 *
117 * This example describes the usage of @ref Eina_Inlist mixed with @ref
118 * Eina_List . We create and add elements to an inlist, and the even members
119 * are also added to a normal list. Later we remove the elements divisible by 3
120 * from this normal list.
121 *
122 * The struct that is going to be used is the same used in @ref
123 * inlist_01_example_page , since we still need the @ref EINA_INLIST macro to
124 * declare the inlist node info:
125 *
126 * @skip struct
127 * @until };
128 *
129 * The resulting node representing this struct can be exemplified by the
130 * following picture:
131 *
132 * @image html eina_inlist-node_eg2-my-struct.png
133 * @image rtf eina_inlist-node_eg2-my-struct.png
134 * @image latex eina_inlist-node_eg2-my-struct.eps
135 *
136 * Now we need some pointers and auxiliar variables that will help us iterate on
137 * the lists:
138 *
139 * @skip struct
140 * @until l_next;
141 *
142 * Allocating 100 elements and putting them into an inlist, and the even
143 * elements also go to the normal list:
144 *
145 * @skip for
146 * @until }
147 *
148 * After this point, what we have are two distinct lists that share some
149 * elements. The first list (inlist) is defined by the pointers inside the
150 * elements data structure, while the second list (normal list) has its own node
151 * data structure that is kept outside of the elements.
152 *
153 * The two lists, sharing some elements, can be represented by the following
154 * picture:
155 *
156 * @htmlonly
157 * <img src="eina_inlist-node_eg2-list-inlist.png" style="max-width: 100%;"/>
158 * @endhtmlonly
159 * @image rtf eina_inlist-node_eg2-list-inlist.png
160 * @image latex eina_inlist-node_eg2-list-inlist.eps width=\textwidth
161 *
162 * Accessing both lists is done normally, as if they didn't have any elements in
163 * common:
164 *
165 * @skip printf
166 * @until eina_list_count
167 *
168 * We can remove elements from the normal list, but we just don't free them
169 * because they are still stored in the inlist:
170 *
171 * @skip EINA_LIST_FOREACH_SAFE
172 * @until eina_list_count
173 *
174 * To finish this example, we want to free both lists, we can't just free all
175 * elements on the second list (normal list) because they are still being used
176 * in the inlist. So we first discard the normal list without freeing its
177 * elements, then we free all elements in the inlist (that contains all elements
178 * allocated until now):
179 *
180 * @skip eina_list_free
181 * @until }
182 *
183 * Here is the full source code for this example: @ref eina_inlist_02_c
184 */
185
186/**
187 * @page inlist_03_example_page Eina_Inlist advanced usage - multi-inlists
188 * @dontinclude eina_inlist_03.c
189 *
190 * This example describes the usage of multiple inlists storing the same data.
191 * It means that some data may appear in more than one inlist at the same time.
192 * We will demonstrate this by creating an inlist with 100 numbers, and adding
193 * the odd numbers to the second inlist, then remove the numbers divisible by 3
194 * from the second list.
195 *
196 * To accomplish this, it is necessary to have two inlist pointers in the struct
197 * that is going to be stored. We are using the default inlist member @ref
198 * EINA_INLIST, and adding another member @c even that is of type @ref
199 * Eina_Inlist too:
200 *
201 * @skip struct
202 * @until };
203 *
204 * The representation for this struct is:
205 *
206 * @image html eina_inlist-node_eg3-my-struct.png
207 * @image rtf eina_inlist-node_eg3-my-struct.png
208 * @image latex eina_inlist-node_eg3-my-struct.eps
209 *
210 * And we will define some convenience macros that are equivalent to @ref
211 * EINA_INLIST_GET and @ref EINA_INLIST_CONTAINER_GET :
212 *
213 * @skip define
214 * @until offsetof
215 *
216 * We need two pointers, one for each list, and a pointer that will be used as
217 * an iterator:
218 *
219 * @skipline Eina_Inlist
220 *
221 * Now we allocate and add to the first list every number from 0 to 99. These
222 * nodes data also have the @ref Eina_Inlist node info for the second list (@c
223 * even). We will use them to add just the even numbers to the second list, the
224 * @c list_even. Also notice that we are using our macro @c EVEN_INLIST_GET to
225 * get the pointer to the even list node info:
226 *
227 * @skip for
228 * @until }
229 *
230 * And the resulting lists will be as follow:
231 *
232 * @htmlonly
233 * <img src="eina_inlist-node_eg3-two-inlists.png" style="max-width: 100%;"/>
234 * @endhtmlonly
235 * @image rtf eina_inlist-node_eg3-two-inlists.png
236 * @image latex eina_inlist-node_eg3-two-inlists.eps width=\textwidth
237 *
238 * For the first list, we can use the macro @ref EINA_INLIST_FOREACH to iterate
239 * over its elements:
240 *
241 * @skip FOREACH
242 * @until printf
243 *
244 * But for the second list, we have to do it manually. Of course we could create
245 * a similar macro to @ref EINA_INLIST_FOREACH, but since this macro is more
246 * complex than the other two and we are using it only once, it's better to just
247 * do it manually:
248 *
249 * @skip for
250 * @until }
251 *
252 * Let's just check that the two lists have the expected number of elements:
253 *
254 * @skip list count
255 * @until list_even count
256 *
257 * And removing the numbers divisible by 3 only from the second list:
258 *
259 * @skip itr
260 * @until list_even count
261 *
262 * Now that we don't need the two lists anymore, we can just free all the items.
263 * Since all of the allocated data was put into the first list, and both lists
264 * are made of pointers to inside the data structures, we can free only the
265 * first list (that contains all the elements) and the second list will be gone
266 * with it:
267 *
268 * @skip while
269 * @until free
270 *
271 * To see the full source code for this example, click here: @ref
272 * eina_inlist_03_c
273 *
274 */
275
276/**
277 * @page eina_inlist_01_c eina_inlist_01.c Eina_Inlist basic usage source
278 * @include eina_inlist_01.c
279 */
280
281/**
282 * @page eina_inlist_02_c eina_inlist_02.c Eina_Inlist advanced usage - lists and inlists source
283 * @include eina_inlist_02.c
284 */
285
286/**
287 * @page eina_inlist_03_c eina_inlist_03.c Eina_Inlist advanced usage - multi-inlists source
288 * @include eina_inlist_03.c
289 */
290
291/**
292 * @addtogroup Eina_Inline_List_Group Inline List
293 *
294 * @brief These functions provide inline list management.
295 *
296 * Inline lists mean its nodes pointers are part of same memory as
297 * data. This has the benefit of fragmenting memory less and avoiding
298 * @c node->data indirection, but has the drawback of higher cost for some
299 * common operations like count and sort.
300 *
301 * It is possible to have inlist nodes to be part of regular lists, created with
302 * @ref eina_list_append() or @ref eina_list_prepend(). It's also possible to
303 * have a structure with two inlist pointers, thus be part of two different
304 * inlists at the same time, but the current convenience macros provided won't
305 * work for both of them. Consult @ref inlist_advanced for more info.
306 *
307 * Inline lists have their purposes, but if you don't know what those purposes are, go with
308 * regular lists instead.
309 *
310 * Tip: When using inlists in more than one place (that is, passing them around
311 * functions or keeping a pointer to them in a structure) it's more correct
312 * to keep a pointer to the first container, and not a pointer to the first
313 * inlist item (mostly they are the same, but that's not always correct).
314 * This lets the compiler to do type checking and let the programmer know
315 * exactly what type this list is.
316 *
317 * A simple example demonstrating the basic usage of an inlist can be found
318 * here: @ref inlist_01_example_page
319 *
320 * @section inlist_algo Algorithm
321 *
322 * The basic structure can be represented by the following picture:
323 *
324 * @image html eina_inlist-node.png
325 * @image rtf eina_inlist-node.png
326 * @image latex eina_inlist-node.eps
327 *
328 * One data structure will also have the node information, with three pointers:
329 * @a prev, @a next and @a last. The @a last pointer is just valid for the first
330 * element (the list head), otherwise each insertion in the list would have to
331 * be done updating every node with the correct pointer. This means that it's
332 * always very important to keep a pointer to the first element of the list,
333 * since it is the only one that has the correct information to allow a proper
334 * O(1) append to the list.
335 *
336 * @section inlist_perf Performance
337 *
338 * Due to the nature of the inlist, there's no accounting information, and no
339 * easy access to the last element from each list node. This means that @ref
340 * eina_inlist_count() is order-N, while @ref eina_list_count() is order-1 (constant
341 * time).
342 *
343 * For the same reasons, @ref eina_inlist_sort() is slower than @ref
344 * eina_list_sort() . If the list is intended to have faster access, be
345 * sorted/merged frequently, or needs to have other complex operations, consider
346 * using @ref Eina_List instead.
347 *
348 * @section inlist_advanced Advanced Usage
349 *
350 * The basic usage considers a struct that will have the user data, and also
351 * have an inlist node information (prev, next and last pointers) created with
352 * @ref EINA_INLIST during the struct declaration. This allows one to use the
353 * convenience macros @ref EINA_INLIST_GET(), @ref EINA_INLIST_CONTAINER_GET(),
354 * @ref EINA_INLIST_FOREACH() and so. This happens because the @ref EINA_INLIST
355 * macro declares a struct member with the name @a __inlist, and all the other
356 * macros assume that this struct member has this name.
357 *
358 * It may be the case that someone needs to have some inlist nodes added to a
359 * @ref Eina_List too. If this happens, the inlist nodes can be added to the
360 * @ref Eina_List without any problems. This example demonstrates this case:
361 * @ref inlist_02_example_page
362 *
363 * It's also possible to have some data that is part of two different inlists.
364 * If this is the case, then it won't be possible to use the convenience macros
365 * to both of the lists. It will be necessary to create a new set of macros that
366 * will allow access to the second list node info. An example for this usage can
367 * be found here:
368 * @ref inlist_03_example_page
369 *
370 * List of examples:
371 * @li @ref inlist_01_example_page
372 * @li @ref inlist_02_example_page
373 * @li @ref inlist_03_example_page
374 */
375
376/**
377 * @addtogroup Eina_Data_Types_Group Data Types
378 *
379 * @{
380 */
381
382/**
383 * @addtogroup Eina_Containers_Group Containers
384 *
385 * @{
386 */
387
388/**
389 * @defgroup Eina_Inline_List_Group Inline List
390 *
391 * @{
392 */
393
394/**
395 * @typedef Eina_Inlist
396 * Inlined list type.
397 */
398typedef struct _Eina_Inlist Eina_Inlist;
399
400/**
401 * @typedef Eina_Inlist_Sorted_State
402 * @since 1.1.0
403 * State of sorted Eina_Inlist
404 */
405typedef struct _Eina_Inlist_Sorted_State Eina_Inlist_Sorted_State;
406
407/**
408 * @struct _Eina_Inlist
409 * Inlined list type.
410 */
411struct _Eina_Inlist
412{
413 Eina_Inlist *next; /**< next node */
414 Eina_Inlist *prev; /**< previous node */
415 Eina_Inlist *last; /**< last node */
416};
417/** Used for declaring an inlist member in a struct */
418#define EINA_INLIST Eina_Inlist __in_list
419/** Utility macro to get the inlist object of a struct */
420#define EINA_INLIST_GET(Inlist) (& ((Inlist)->__in_list))
421/** Utility macro to get the container object of an inlist */
422#define EINA_INLIST_CONTAINER_GET(ptr, \
423 type) ((type *)((char *)ptr - \
424 offsetof(type, __in_list)))
425
426
427/**
428 * Add a new node to end of a list.
429 *
430 * @note this code is meant to be fast: appends are O(1) and do not
431 * walk @a list.
432 *
433 * @note @a new_l is considered to be in no list. If it was in another
434 * list before, eina_inlist_remove() it before adding. No
435 * check of @a new_l prev and next pointers is done, so it's safe
436 * to have them uninitialized.
437 *
438 * @param list existing list head or NULL to create a new list.
439 * @param new_l new list node, must not be NULL.
440 *
441 * @return the new list head. Use it and not @a list anymore.
442 */
443EAPI Eina_Inlist *eina_inlist_append(Eina_Inlist *in_list,
444 Eina_Inlist *in_item) EINA_ARG_NONNULL(2) EINA_WARN_UNUSED_RESULT;
445
446/**
447 * Add a new node to beginning of list.
448 *
449 * @note this code is meant to be fast: appends are O(1) and do not
450 * walk @a list.
451 *
452 * @note @a new_l is considered to be in no list. If it was in another
453 * list before, eina_inlist_remove() it before adding. No
454 * check of @a new_l prev and next pointers is done, so it's safe
455 * to have them uninitialized.
456 *
457 * @param list existing list head or NULL to create a new list.
458 * @param new_l new list node, must not be NULL.
459 *
460 * @return the new list head. Use it and not @a list anymore.
461 */
462EAPI Eina_Inlist *eina_inlist_prepend(Eina_Inlist *in_list,
463 Eina_Inlist *in_item) EINA_ARG_NONNULL(2) EINA_WARN_UNUSED_RESULT;
464
465/**
466 * Add a new node after the given relative item in list.
467 *
468 * @note this code is meant to be fast: appends are O(1) and do not
469 * walk @a list.
470 *
471 * @note @a new_l is considered to be in no list. If it was in another
472 * list before, eina_inlist_remove() it before adding. No
473 * check of @a new_l prev and next pointers is done, so it's safe
474 * to have them uninitialized.
475 *
476 * @note @a relative is considered to be inside @a list, no checks are
477 * done to confirm that and giving nodes from different lists
478 * will lead to problems. Giving NULL @a relative is the same as
479 * eina_list_append().
480 *
481 * @param list existing list head or NULL to create a new list.
482 * @param new_l new list node, must not be NULL.
483 * @param relative reference node, @a new_l will be added after it.
484 *
485 * @return the new list head. Use it and not @a list anymore.
486 */
487EAPI Eina_Inlist *eina_inlist_append_relative(Eina_Inlist *in_list,
488 Eina_Inlist *in_item,
489 Eina_Inlist *in_relative) EINA_ARG_NONNULL(2) EINA_WARN_UNUSED_RESULT;
490
491/**
492 * Add a new node before the given relative item in list.
493 *
494 * @note this code is meant to be fast: appends are O(1) and do not
495 * walk @a list.
496 *
497 * @note @a new_l is considered to be in no list. If it was in another
498 * list before, eina_inlist_remove() it before adding. No
499 * check of @a new_l prev and next pointers is done, so it's safe
500 * to have them uninitialized.
501 *
502 * @note @a relative is considered to be inside @a list, no checks are
503 * done to confirm that and giving nodes from different lists
504 * will lead to problems. Giving NULL @a relative is the same as
505 * eina_list_prepend().
506 *
507 * @param list existing list head or NULL to create a new list.
508 * @param new_l new list node, must not be NULL.
509 * @param relative reference node, @a new_l will be added before it.
510 *
511 * @return the new list head. Use it and not @a list anymore.
512 */
513EAPI Eina_Inlist *eina_inlist_prepend_relative(Eina_Inlist *in_list,
514 Eina_Inlist *in_item,
515 Eina_Inlist *in_relative) EINA_ARG_NONNULL(2) EINA_WARN_UNUSED_RESULT;
516
517/**
518 * Remove node from list.
519 *
520 * @note this code is meant to be fast: appends are O(1) and do not
521 * walk @a list.
522 *
523 * @note @a item is considered to be inside @a list, no checks are
524 * done to confirm that and giving nodes from different lists
525 * will lead to problems, especially if @a item is the head since
526 * it will be different from @a list and the wrong new head will
527 * be returned.
528 *
529 * @param list existing list head, must not be NULL.
530 * @param item existing list node, must not be NULL.
531 *
532 * @return the new list head. Use it and not @a list anymore.
533 */
534EAPI Eina_Inlist *eina_inlist_remove(Eina_Inlist *in_list,
535 Eina_Inlist *in_item) EINA_ARG_NONNULL(1, 2) EINA_WARN_UNUSED_RESULT;
536
537/**
538 * Find given node in list, returns itself if found, NULL if not.
539 *
540 * @warning this is an expensive call and has O(n) cost, possibly
541 * walking the whole list.
542 *
543 * @param list existing list to search @a item in, must not be NULL.
544 * @param item what to search for, must not be NULL.
545 *
546 * @return @a item if found, NULL if not.
547 */
548EAPI Eina_Inlist *eina_inlist_find(Eina_Inlist *in_list,
549 Eina_Inlist *in_item) EINA_ARG_NONNULL(2) EINA_WARN_UNUSED_RESULT;
550
551/**
552 * Move existing node to beginning of list.
553 *
554 * @note this code is meant to be fast: appends are O(1) and do not
555 * walk @a list.
556 *
557 * @note @a item is considered to be inside @a list. No checks are
558 * done to confirm this, and giving nodes from different lists
559 * will lead to problems.
560 *
561 * @param list existing list head or NULL to create a new list.
562 * @param item list node to move to beginning (head), must not be NULL.
563 *
564 * @return the new list head. Use it and not @a list anymore.
565 */
566EAPI Eina_Inlist *eina_inlist_promote(Eina_Inlist *list,
567 Eina_Inlist *item) EINA_ARG_NONNULL(1, 2) EINA_WARN_UNUSED_RESULT;
568
569/**
570 * Move existing node to end of list.
571 *
572 * @note this code is meant to be fast: appends are O(1) and do not
573 * walk @a list.
574 *
575 * @note @a item is considered to be inside @a list. No checks are
576 * done to confirm this, and giving nodes from different lists
577 * will lead to problems.
578 *
579 * @param list existing list head or NULL to create a new list.
580 * @param item list node to move to end (tail), must not be NULL.
581 *
582 * @return the new list head. Use it and not @a list anymore.
583 */
584EAPI Eina_Inlist *eina_inlist_demote(Eina_Inlist *list,
585 Eina_Inlist *item) EINA_ARG_NONNULL(1, 2) EINA_WARN_UNUSED_RESULT;
586
587/**
588 * @brief Get the count of the number of items in a list.
589 *
590 * @param list The list whose count to return.
591 * @return The number of members in the list.
592 *
593 * This function returns how many members @p list contains. If the
594 * list is @c NULL, 0 is returned.
595 *
596 * @warning This is an order-N operation and so the time will depend
597 * on the number of elements on the list, so, it might become
598 * slow for big lists!
599 */
600EAPI unsigned int eina_inlist_count(const Eina_Inlist *list) EINA_WARN_UNUSED_RESULT;
601
602
603/**
604 * @brief Returns a new iterator associated to @a list.
605 *
606 * @param list The list.
607 * @return A new iterator.
608 *
609 * This function returns a newly allocated iterator associated to @p
610 * list. If @p list is @c NULL or the count member of @p list is less
611 * or equal than 0, this function still returns a valid iterator that
612 * will always return false on eina_iterator_next(), thus keeping API
613 * sane.
614 *
615 * If the memory can not be allocated, NULL is returned and
616 * #EINA_ERROR_OUT_OF_MEMORY is set. Otherwise, a valid iterator is
617 * returned.
618 *
619 * @warning if the list structure changes then the iterator becomes
620 * invalid, and if you add or remove nodes iterator
621 * behavior is undefined, and your program may crash!
622 */
623EAPI Eina_Iterator *eina_inlist_iterator_new(const Eina_Inlist *in_list) EINA_MALLOC EINA_WARN_UNUSED_RESULT;
624
625/**
626 * @brief Returns a new accessor associated to a list.
627 *
628 * @param list The list.
629 * @return A new accessor.
630 *
631 * This function returns a newly allocated accessor associated to
632 * @p list. If @p list is @c NULL or the count member of @p list is
633 * less or equal than 0, this function returns NULL. If the memory can
634 * not be allocated, NULL is returned and #EINA_ERROR_OUT_OF_MEMORY is
635 * set. Otherwise, a valid accessor is returned.
636 */
637EAPI Eina_Accessor *eina_inlist_accessor_new(const Eina_Inlist *in_list) EINA_MALLOC EINA_WARN_UNUSED_RESULT;
638
639/**
640 * @brief Insert a new node into a sorted list.
641 *
642 * @param list The given linked list, @b must be sorted.
643 * @param item list node to insert, must not be NULL.
644 * @param func The function called for the sort.
645 * @return A list pointer.
646 * @since 1.1.0
647 *
648 * This function inserts item into a linked list assuming it was
649 * sorted and the result will be sorted. If @p list is @c NULLL, item
650 * is returned. On success, a new list pointer that should be
651 * used in place of the one given to this function is
652 * returned. Otherwise, the old pointer is returned. See eina_error_get().
653 *
654 * @note O(log2(n)) comparisons (calls to @p func) average/worst case
655 * performance. As said in eina_list_search_sorted_near_list(),
656 * lists do not have O(1) access time, so walking to the correct node
657 * can be costly, consider worst case to be almost O(n) pointer
658 * dereference (list walk).
659 */
660EAPI Eina_Inlist *eina_inlist_sorted_insert(Eina_Inlist *list, Eina_Inlist *item, Eina_Compare_Cb func) EINA_ARG_NONNULL(2, 3) EINA_WARN_UNUSED_RESULT;
661
662/**
663 * @brief Create state with valid data in it.
664 *
665 * @return A valid Eina_Inlist_Sorted_State.
666 * @since 1.1.0
667 *
668 * See eina_inlist_sorted_state_insert() for more information.
669 */
670EAPI Eina_Inlist_Sorted_State *eina_inlist_sorted_state_new(void);
671
672/**
673 * @brief Force an Eina_Inlist_Sorted_State to match the content of a list.
674 *
675 * @param state The state to update
676 * @param list The list to match
677 * @return The number of item in the actually in the list
678 * @since 1.1.0
679 *
680 * See eina_inlist_sorted_state_insert() for more information. This function is
681 * usefull if you didn't use eina_inlist_sorted_state_insert() at some point, but
682 * still think you have a sorted list. It will only correctly work on a sorted list.
683 */
684EAPI int eina_inlist_sorted_state_init(Eina_Inlist_Sorted_State *state, Eina_Inlist *list);
685
686/**
687 * @brief Free an Eina_Inlist_Sorted_State.
688 *
689 * @param state The state to destroy
690 * @since 1.1.0
691 *
692 * See eina_inlist_sorted_state_insert() for more information.
693 */
694EAPI void eina_inlist_sorted_state_free(Eina_Inlist_Sorted_State *state);
695
696/**
697 * @brief Insert a new node into a sorted list.
698 *
699 * @param list The given linked list, @b must be sorted.
700 * @param item list node to insert, must not be NULL.
701 * @param func The function called for the sort.
702 * @param state The current array for initial dichotomic search
703 * @return A list pointer.
704 * @since 1.1.0
705 *
706 * This function inserts item into a linked list assuming @p state match
707 * the exact content order of the list. It use @p state to do a fast
708 * first step dichotomic search before starting to walk the inlist itself.
709 * This make this code much faster than eina_inlist_sorted_insert() as it
710 * doesn't need to walk the list at all. The result is of course a sorted
711 * list with an updated state.. If @p list is @c NULLL, item
712 * is returned. On success, a new list pointer that should be
713 * used in place of the one given to this function is
714 * returned. Otherwise, the old pointer is returned. See eina_error_get().
715 *
716 * @note O(log2(n)) comparisons (calls to @p func) average/worst case
717 * performance. As said in eina_list_search_sorted_near_list(),
718 * lists do not have O(1) access time, so walking to the correct node
719 * can be costly, but this version try to minimize that by making it a
720 * O(log2(n)) for number small number. After n == 256, it start to add a
721 * linear cost again. Consider worst case to be almost O(n) pointer
722 * dereference (list walk).
723 */
724EAPI Eina_Inlist *eina_inlist_sorted_state_insert(Eina_Inlist *list,
725 Eina_Inlist *item,
726 Eina_Compare_Cb func,
727 Eina_Inlist_Sorted_State *state);
728/**
729 * @brief Sort a list according to the ordering func will return.
730 *
731 * @param list The list handle to sort.
732 * @param func A function pointer that can handle comparing the list data
733 * nodes.
734 * @return the new head of list.
735 *
736 * This function sorts all the elements of @p list. @p func is used to
737 * compare two elements of @p list. If @p list or @p func are @c NULL,
738 * this function returns @c NULL.
739 *
740 * @note @b in-place: this will change the given list, so you should
741 * now point to the new list head that is returned by this function.
742 *
743 * @note worst case is O(n * log2(n)) comparisons (calls to func()),
744 * O(n) comparisons average case. That means that for 1,000,000 list
745 * elements, sort will usually do 1,000,000 comparisons, but may do up
746 * to 20,000,000.
747 *
748 * Example:
749 * @code
750 * typedef struct _Sort_Ex Sort_Ex;
751 * struct _Sort_Ex
752 * {
753 * INLIST;
754 * const char *text;
755 * };
756 *
757 * int
758 * sort_cb(const Inlist *l1, const Inlist *l2)
759 * {
760 * const Sort_Ex *x1;
761 * const Sort_Ex *x2;
762 *
763 * x1 = EINA_INLIST_CONTAINER_GET(l1, Sort_Ex);
764 * x2 = EINA_INLIST_CONTAINER_GET(l2, Sort_Ex);
765 *
766 * return(strcmp(x1->text, x2->text));
767 * }
768 * extern Eina_Inlist *list;
769 *
770 * list = eina_inlist_sort(list, sort_cb);
771 * @endcode
772 */
773EAPI Eina_Inlist *eina_inlist_sort(Eina_Inlist *head, Eina_Compare_Cb func);
774
775/* This two macros are helpers for the _FOREACH ones, don't use them */
776#define _EINA_INLIST_OFFSET(ref) ((char *)&(ref)->__in_list - (char *)(ref))
777
778#if !defined(__cplusplus)
779#define _EINA_INLIST_CONTAINER(ref, ptr) (void *)((char *)(ptr) - \
780 _EINA_INLIST_OFFSET(ref))
781#else
782/*
783 * In C++ we can't assign a "type*" pointer to void* so we rely on GCC's typeof
784 * operator.
785 */
786#define _EINA_INLIST_CONTAINER(ref, ptr) (typeof(ref))((char *)(ptr) - \
787 _EINA_INLIST_OFFSET(ref))
788#endif
789
790#define EINA_INLIST_FOREACH(list, l) \
791 for (l = NULL, l = (list ? _EINA_INLIST_CONTAINER(l, list) : NULL); l; \
792 l = (EINA_INLIST_GET(l)->next ? _EINA_INLIST_CONTAINER(l, EINA_INLIST_GET(l)->next) : NULL))
793#define EINA_INLIST_FOREACH_SAFE(list, list2, l) \
794 for (l = (list ? _EINA_INLIST_CONTAINER(l, list) : NULL), list2 = l ? ((EINA_INLIST_GET(l) ? EINA_INLIST_GET(l)->next : NULL)) : NULL; \
795 l; \
796 l = _EINA_INLIST_CONTAINER(l, list2), list2 = list2 ? list2->next : NULL)
797#define EINA_INLIST_REVERSE_FOREACH(list, l) \
798 for (l = NULL, l = (list ? _EINA_INLIST_CONTAINER(l, list->last) : NULL); \
799 l; l = (EINA_INLIST_GET(l)->prev ? _EINA_INLIST_CONTAINER(l, EINA_INLIST_GET(l)->prev) : NULL))
800
801/**
802 * @}
803 */
804
805/**
806 * @}
807 */
808
809/**
810 * @}
811 */
812
813#endif /*EINA_INLIST_H_*/
diff --git a/libraries/eina/src/include/eina_iterator.h b/libraries/eina/src/include/eina_iterator.h
new file mode 100644
index 0000000..1c8e6ce
--- /dev/null
+++ b/libraries/eina/src/include/eina_iterator.h
@@ -0,0 +1,337 @@
1/* EINA - EFL data type library
2 * Copyright (C) 2008 Cedric Bail
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library;
16 * if not, see <http://www.gnu.org/licenses/>.
17 */
18
19#ifndef EINA_ITERATOR_H__
20#define EINA_ITERATOR_H__
21
22#include "eina_config.h"
23
24#include "eina_types.h"
25#include "eina_magic.h"
26
27/**
28 * @page eina_iterator_example Eina_Iterator usage
29 * @dontinclude eina_iterator_01.c
30 *
31 * As always when using eina we need to include it:
32 * @skip #include
33 * @until Eina.h
34 *
35 * Here we a declare an unimpressive @ref Eina_Each_Cb "function" that prints
36 * some data:
37 * @until }
38 * @note Returning EINA_TRUE is important so we don't stop iterating over the
39 * container.
40 *
41 * And here a more interesting function, it uses an iterator to print the
42 * contents of a container. What's interesting about it is that it doesn't care
43 * the type of container, it works for anything that can provide an iterator:
44 * @until }
45 *
46 * And on to our main function were we declare some variables and initialize
47 * eina, nothing too special:
48 * @until eina_init
49 *
50 * Next we populate both an array and a list with our strings, for more details
51 * see @ref eina_list_01_example and @ref eina_array_01_example:
52 * @until }
53 *
54 * And now we create an array and because the first element of the container
55 * doesn't interest us we skip it:
56 * @until iterator_next
57 *
58 * Having our iterator now pointing to interesting data we go ahead and print:
59 * @until print_eina_container
60 *
61 * As always once data with a structure we free it, but just because we can we
62 * do it by asking the iterator for it's container, and then of course free the
63 * iterator itself:
64 * @until eina_iterator_free
65 *
66 * But so far you're not impressed in @ref eina_array_01_example an array is
67 * also printed, so now we go to the cool stuff and use an iterator to do same
68 * stuff to a list:
69 * @until eina_iterator_free
70 * @note The only significant diference to the block above is in the
71 * function used to create the iterator.
72 *
73 * And now we free the list and shut eina down:
74 * @until }
75 */
76
77/**
78 * @page eina_iterator_01_c Eina_Iterator usage
79 * @page eina_iterator_01_c Eina_Iterator usage
80 *
81 * @include eina_iterator_01.c
82 * @example eina_iterator_01.c
83 */
84
85/**
86 * @addtogroup Eina_Iterator_Group Iterator Functions
87 *
88 * @brief These functions manage iterators on containers.
89 *
90 * These functions allow to access elements of a container in a
91 * generic way, without knowing which container is used (a bit like
92 * iterators in the C++ STL). Iterators only allows sequential access
93 * (that is, from an element to the next one). For random access, see
94 * @ref Eina_Accessor_Group.
95 *
96 * An iterator is created from container data types, so no creation
97 * function is available here. An iterator is deleted with
98 * eina_iterator_free(). To get the data and iterate, use
99 * eina_iterator_next(). To call a function on all the elements of a
100 * container, use eina_iterator_foreach().
101 *
102 * Here an @ref eina_iterator_example "example"
103 */
104
105/**
106 * @addtogroup Eina_Content_Access_Group Content Access
107 *
108 * @{
109 */
110
111/**
112 * @defgroup Eina_Iterator_Group Iterator Functions
113 *
114 * @{
115 */
116
117/**
118 * @typedef Eina_Iterator
119 * Abstract type for iterators.
120 */
121typedef struct _Eina_Iterator Eina_Iterator;
122
123/**
124 * @typedef Eina_Iterator_Next_Callback
125 * Type for a callback that returns the next element in a container.
126 */
127typedef Eina_Bool (*Eina_Iterator_Next_Callback)(Eina_Iterator *it, void **data);
128
129/**
130 * @typedef Eina_Iterator_Get_Container_Callback
131 * Type for a callback that returns the container.
132 */
133typedef void *(*Eina_Iterator_Get_Container_Callback)(Eina_Iterator *it);
134
135/**
136 * @typedef Eina_Iterator_Free_Callback
137 * Type for a callback that frees the container.
138 */
139typedef void (*Eina_Iterator_Free_Callback)(Eina_Iterator *it);
140
141/**
142 * @typedef Eina_Iterator_Lock_Callback
143 * Type for a callback that lock the container.
144 */
145typedef Eina_Bool (*Eina_Iterator_Lock_Callback)(Eina_Iterator *it);
146
147/**
148 * @struct _Eina_Iterator
149 * structure of an iterator
150 */
151struct _Eina_Iterator
152{
153#define EINA_ITERATOR_VERSION 1
154 int version; /**< Version of the Iterator API. */
155
156 Eina_Iterator_Next_Callback next EINA_ARG_NONNULL(1, 2) EINA_WARN_UNUSED_RESULT; /**< Callback called when a next element is requested. */
157 Eina_Iterator_Get_Container_Callback get_container EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT; /**< Callback called when the container is requested. */
158 Eina_Iterator_Free_Callback free EINA_ARG_NONNULL(1); /**< Callback called when the container is freed. */
159
160 Eina_Iterator_Lock_Callback lock EINA_WARN_UNUSED_RESULT; /**< Callback called when the container is locked. */
161 Eina_Iterator_Lock_Callback unlock EINA_WARN_UNUSED_RESULT; /**< Callback called when the container is unlocked. */
162
163#define EINA_MAGIC_ITERATOR 0x98761233
164 EINA_MAGIC
165};
166
167/**
168 * @def FUNC_ITERATOR_NEXT(Function)
169 * Helper macro to cast @p Function to a Eina_Iterator_Next_Callback.
170 */
171#define FUNC_ITERATOR_NEXT(Function) ((Eina_Iterator_Next_Callback)Function)
172
173/**
174 * @def FUNC_ITERATOR_GET_CONTAINER(Function)
175 * Helper macro to cast @p Function to a Eina_Iterator_Get_Container_Callback.
176 */
177#define FUNC_ITERATOR_GET_CONTAINER(Function) ((Eina_Iterator_Get_Container_Callback)Function)
178
179/**
180 * @def FUNC_ITERATOR_FREE(Function)
181 * Helper macro to cast @p Function to a Eina_Iterator_Free_Callback.
182 */
183#define FUNC_ITERATOR_FREE(Function) ((Eina_Iterator_Free_Callback)Function)
184
185/**
186 * @def FUNC_ITERATOR_LOCK(Function)
187 * Helper macro to cast @p Function to a Eina_Iterator_Lock_Callback.
188 */
189#define FUNC_ITERATOR_LOCK(Function) ((Eina_Iterator_Lock_Callback)Function)
190
191
192/**
193 * @brief Free an iterator.
194 *
195 * @param iterator The iterator to free.
196 *
197 * This function frees @p iterator if it is not @c NULL;
198 */
199EAPI void eina_iterator_free(Eina_Iterator *iterator) EINA_ARG_NONNULL(1);
200
201
202/**
203 * @brief Return the container of an iterator.
204 *
205 * @param iterator The iterator.
206 * @return The container which created the iterator.
207 *
208 * This function returns the container which created @p iterator. If
209 * @p iterator is @c NULL, this function returns @c NULL.
210 */
211EAPI void *eina_iterator_container_get(Eina_Iterator *iterator) EINA_ARG_NONNULL(1) EINA_PURE;
212
213/**
214 * @brief Return the value of the current element and go to the next one.
215 *
216 * @param iterator The iterator.
217 * @param data The data of the element.
218 * @return #EINA_TRUE on success, #EINA_FALSE otherwise.
219 *
220 * This function returns the value of the current element pointed by
221 * @p iterator in @p data, then goes to the next element. If @p
222 * iterator is @c NULL or if a problem occurred, #EINA_FALSE is
223 * returned, otherwise #EINA_TRUE is returned.
224 */
225EAPI Eina_Bool eina_iterator_next(Eina_Iterator *iterator,
226 void **data) EINA_ARG_NONNULL(1, 2) EINA_WARN_UNUSED_RESULT;
227
228
229/**
230 * @brief Iterate over the container and execute a callback on each element.
231 *
232 * @param iterator The iterator.
233 * @param callback The callback called on each iteration.
234 * @param fdata The data passed to the callback.
235 *
236 * This function iterates over the elements pointed by @p iterator,
237 * beginning from the current element. For Each element, the callback
238 * @p cb is called with the data @p fdata. If @p iterator is @c NULL,
239 * the function returns immediately. Also, if @p cb returns @c
240 * EINA_FALSE, the iteration stops at that point, if @p cb returns @c EINA_TRUE
241 * the iteration continues.
242 */
243EAPI void eina_iterator_foreach(Eina_Iterator *iterator,
244 Eina_Each_Cb callback,
245 const void *fdata) EINA_ARG_NONNULL(1, 2);
246
247
248/**
249 * @brief Lock the container of the iterator.
250 *
251 * @param iterator The iterator.
252 * @return #EINA_TRUE on success, #EINA_FALSE otherwise.
253 *
254 * If the container of the @p iterator permits it, it will be locked. When a
255 * container is locked calling eina_iterator_foreach() on it will return
256 * immediately. If @p iterator is @c NULL or if a problem occurred, #EINA_FALSE
257 * is returned, otherwise #EINA_TRUE is returned. If the container isn't
258 * lockable, it will return EINA_TRUE.
259 *
260 * @warning None of the existing eina data structures are lockable.
261 */
262EAPI Eina_Bool eina_iterator_lock(Eina_Iterator *iterator) EINA_ARG_NONNULL(1);
263
264/**
265 * @brief Unlock the container of the iterator.
266 *
267 * @param iterator The iterator.
268 * @return #EINA_TRUE on success, #EINA_FALSE otherwise.
269 *
270 * If the container of the @p iterator permits it and was previously
271 * locked, it will be unlocked. If @p iterator is @c NULL or if a
272 * problem occurred, #EINA_FALSE is returned, otherwise #EINA_TRUE
273 * is returned. If the container is not lockable, it will return
274 * EINA_TRUE.
275 *
276 * @warning None of the existing eina data structures are lockable.
277 */
278EAPI Eina_Bool eina_iterator_unlock(Eina_Iterator *iterator) EINA_ARG_NONNULL(1);
279
280/**
281 * @def EINA_ITERATOR_FOREACH
282 * @brief Macro to iterate over all elements easily.
283 *
284 * @param itr The iterator to use.
285 * @param data Where to store * data, must be a pointer support getting
286 * its address since * eina_iterator_next() requires a pointer
287 * to pointer!
288 *
289 * This macro is a convenient way to use iterators, very similar to
290 * EINA_LIST_FOREACH().
291 *
292 * This macro can be used for freeing the data of a list, like in the
293 * following example. It has the same goal as the one documented in
294 * EINA_LIST_FOREACH(), but using iterators:
295 *
296 * @code
297 * Eina_List *list;
298 * Eina_Iterator *itr;
299 * char *data;
300 *
301 * // list is already filled,
302 * // its elements are just duplicated strings
303 *
304 * itr = eina_list_iterator_new(list);
305 * EINA_ITERATOR_FOREACH(itr, data)
306 * free(data);
307 * eina_iterator_free(itr);
308 * eina_list_free(list);
309 * @endcode
310 *
311 * @note this example is not optimal algorithm to release a list since
312 * it will walk the list twice, but it serves as an example. For
313 * optimized version use EINA_LIST_FREE()
314 *
315 * @warning The order in which the elements will be traversed depends on the
316 * underlying container and @b shouldn't be relied upon.
317 *
318 * @warning unless explicitly stated in functions returning iterators,
319 * do not modify the iterated object while you walk it, in this
320 * example using lists, do not remove list nodes or you might
321 * crash! This is not a limitiation of iterators themselves,
322 * rather in the iterators implementations to keep them as simple
323 * and fast as possible.
324 */
325#define EINA_ITERATOR_FOREACH(itr, \
326 data) while (eina_iterator_next((itr), \
327 (void **)(void *)&(data)))
328
329/**
330 * @}
331 */
332
333/**
334 * @}
335 */
336
337#endif
diff --git a/libraries/eina/src/include/eina_lalloc.h b/libraries/eina/src/include/eina_lalloc.h
new file mode 100644
index 0000000..dcb8773
--- /dev/null
+++ b/libraries/eina/src/include/eina_lalloc.h
@@ -0,0 +1,60 @@
1/* EINA - EFL data type library
2 * Copyright (C) 2007-2008 Jorge Luis Zapata Muga
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library;
16 * if not, see <http://www.gnu.org/licenses/>.
17 */
18
19#ifndef EINA_LALLOC_H_
20#define EINA_LALLOC_H_
21
22#include "eina_types.h"
23
24/**
25 * @addtogroup Eina_Tools_Group Tools
26 *
27 * @{
28 */
29
30/**
31 * @defgroup Eina_Lalloc_Group Lazy allocator
32 *
33 * @{
34 */
35
36typedef Eina_Bool (*Eina_Lalloc_Alloc)(void *user_data, int num);
37#define EINA_LALLOC_ALLOC(function) ((Eina_Lalloc_Alloc)function)
38typedef void (*Eina_Lalloc_Free)(void *user_data);
39#define EINA_LALLOC_FREE(function) ((Eina_Lalloc_Free)function)
40
41typedef struct _Eina_Lalloc Eina_Lalloc;
42
43EAPI Eina_Lalloc *eina_lalloc_new(void *data,
44 Eina_Lalloc_Alloc alloc_cb,
45 Eina_Lalloc_Free free_cb,
46 int num_init) EINA_ARG_NONNULL(2, 3);
47EAPI void eina_lalloc_free(Eina_Lalloc *a) EINA_ARG_NONNULL(1);
48EAPI Eina_Bool eina_lalloc_elements_add(Eina_Lalloc *a,
49 int num) EINA_ARG_NONNULL(1);
50EAPI Eina_Bool eina_lalloc_element_add(Eina_Lalloc *a) EINA_ARG_NONNULL(1);
51
52/**
53 * @}
54 */
55
56/**
57 * @}
58 */
59
60#endif /* EINA_LALLOC_H_ */
diff --git a/libraries/eina/src/include/eina_list.h b/libraries/eina/src/include/eina_list.h
new file mode 100644
index 0000000..8a8f25e
--- /dev/null
+++ b/libraries/eina/src/include/eina_list.h
@@ -0,0 +1,1631 @@
1/* EINA - EFL data type library
2 * Copyright (C) 2002-2008 Carsten Haitzler, Vincent Torri, Jorge Luis Zapata Muga
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library;
16 * if not, see <http://www.gnu.org/licenses/>.
17 */
18
19#ifndef EINA_LIST_H_
20#define EINA_LIST_H_
21
22#include <stdlib.h>
23
24#include "eina_config.h"
25
26#include "eina_types.h"
27#include "eina_iterator.h"
28#include "eina_accessor.h"
29#include "eina_magic.h"
30
31/**
32 * @page list_01_example_page Adding elements to Eina_List
33 * @dontinclude eina_list_01.c
34 *
35 * Creating an @ref Eina_List and adding elements to it is very easy and can be
36 * understood from an example:
37 * First thing is always to include Eina.h, for this example we also
38 * include stdio.h so we can use printf.
39 * @skip #include
40 * @until Eina.h
41 *
42 * Just some boilerplate code, declaring some variable and initializing eina.
43 * @until eina_init
44 * Here we add a sequence of elements to our list. By using append we add
45 * elements to the end of the list, so the list will look like this:@n
46 * @htmlonly
47 * <img src="eina_list_example_01_a.png" style="max-width: 100%;" />
48 * <a href="eina_list_example_01_a.png">Full-size</a>
49 * @endhtmlonly
50 * @image rtf eina_list_example_01_a.png
51 * @image latex eina_list_example_01_a.eps width=\textwidth
52 * @until roslin
53 * There are a couple of interesting things happening here, first is that we are
54 * passing a NULL pointer to the first @ref eina_list_append() call, when this
55 * is done a list is created. The other @b very important detail to notice is
56 * that the return value is attributed to the @a list variable, this needs to
57 * be done every time we use a a function that alters the contents of the list.
58 *
59 * Now that we have a list we some elements in it we can look at it's contents.
60 * @until printf
61 *
62 * There are many ways of accessing elements in the list, including by it's
63 * index:
64 * @until nth
65 * @note It should be noted that the index starts at 0.
66 *
67 * @ref eina_list_append() is not the only way to add elements to a a list. A
68 * common requirement is to add an element in a specific position this can be
69 * accomplished using @ref eina_list_append_relative() and
70 * @ref eina_list_append_relative_list():
71 * @until zarek
72 * First @a "cain" is added after the second element(remember that indexes are
73 * 0 based) and then we add @a "zarek" after @a "cain".
74 *
75 * @ref Eina_List also has prepend analogs to append functions we have used so
76 * far:
77 * @until lampkin
78 * With this additions our list now looks like this:@n
79 * @htmlonly
80 * <img src="eina_list_example_01_b.png" style="max-width: 100%;" />
81 * <a href="eina_list_example_01_b.png">Full-size</a>
82 * @endhtmlonly
83 * @image rtf eina_list_example_01_b.png
84 * @image latex eina_list_example_01_b.eps width=\textwidth
85 *
86 * Once done using the list it needs to be freed, and since we are done with
87 * eina that also need to be shutdown:
88 * @until }
89 *
90 * The full source code can be found on the examples folder
91 * on the @ref eina_list_01_c "eina_list_01.c" file.
92 */
93
94/**
95 * @page eina_list_01_c Adding elements to Eina_List example
96 *
97 * @include eina_list_01.c
98 * @example eina_list_01.c
99 */
100
101/**
102 * @page list_02_example_page Sorting Eina_List elements
103 * @dontinclude eina_list_02.c
104 *
105 * If you don't know how to create lists see
106 * @ref list_01_example_page.
107 *
108 * @skip #include
109 * @until boomer
110 * This is the code we have already seen to create a list. Now if we need to
111 * search the list we can do it like this:
112 * @until return
113 *
114 * However if searching the list multiple times it probably is better to sort
115 * the list since the sorted_search functions are much faster:
116 * @until return
117 *
118 * Once the list is sorted it's not a good idea to use append/prepend functions
119 * since that would add the element in the wrong place, instead elements should
120 * be added with @ref eina_list_sorted_insert():
121 * @until sorted_insert
122 *
123 * A noteworthy use case is adding an element to a list only if it doesn't exist
124 * already, this can accomplished by searching for the element that is closest
125 * to what is being added, and if that doesn't match add:
126 * @until append
127 * @note @ref eina_list_search_sorted_near_list() will tell you not only the
128 * nearest node to what was searched for but how it compares to your term, this
129 * way it is easy to know if you have to add before or after that node.
130 *
131 * It is sometimes useful to get a portion of the list as another list, here we
132 * take every element that comes after "boomer" and split it into "other_list":
133 * @until split_list
134 *
135 * It is also possible to add entire lists of elements using
136 * @ref eina_list_sorted_merge():
137 * @until sorted_merge
138 *
139 * And as always release memory and shutdown eina before ending:
140 * @until }
141 *
142 * The full source code can be found on the examples folder
143 * on the @ref eina_list_02_c "eina_list_02.c" file.
144 */
145
146/**
147 * @page eina_list_02_c Sorting Eina_List elements example
148 *
149 * @include eina_list_02.c
150 * @example eina_list_02.c
151 */
152
153/**
154 * @page list_03_example_page Reordering Eina_List elments
155 * @dontinclude eina_list_03.c
156 *
157 * If you don't know how to create lists see
158 * @ref list_01_example_page.
159 *
160 * We start out with code that should be familiar by now:
161 * @skip #include
162 * @until gemenon
163 *
164 * You can move elements around in a list using @ref eina_list_move() or using
165 * @ref eina_list_promote_list() and @ref eina_list_demote_list() which move a
166 * list node to the head and end of the list respectevely:
167 * @until demote
168 *
169 * Removing elements from a list can be done with ease:
170 * @until sagitarius
171 *
172 * To replace an element in the list it is not necessary to remove it and then
173 * add with the new value, it is possible to just change the value of a node:
174 * @until aquarius
175 *
176 * We will now take a peek to see if the list still has the right number of
177 * elements:
178 * @until printf
179 *
180 * Now that the list is in alphabetical order let's create a copy of it in
181 * reverse order and print every element to see if worked as expected:
182 * @until iterator_free
183 * @note Always remember to free your iterators when done using them.
184 *
185 * And as always release memory and shutdown eina before ending:
186 * @until }
187 *
188 * The full source code can be found on the examples folder
189 * on the @ref eina_list_03_c "eina_list_03.c" file.
190 */
191
192/**
193 * @page eina_list_03_c Reordering Eina_List elments example
194 *
195 * @include eina_list_03.c
196 * @example eina_list_03.c
197 */
198
199/**
200 * @page list_04_example_page Eina_List and memory allocation
201 * @dontinclude eina_list_04.c
202 *
203 * If you don't know how to create lists see
204 * @ref list_01_example_page. In this example we also use
205 * @ref eina_stringshare, however it should be possible to understand the code
206 * regardless of previous knowledge about it.
207 *
208 * Here we have the usual list creation code with a twist, now we are using as
209 * data for the list memory that has to be freed later on.
210 * @skip #include
211 * @until Sharon
212 *
213 * This time we are going to iterate over our list in a different way:
214 * @until printf
215 *
216 * And now we are going to iterate over the list backwards:
217 * @until printf
218 *
219 * And now we need to free up the memory allocated during creation of the list:
220 * @until stringshare_del
221 * @note We don't need to use eina_list_free() since @ref EINA_LIST_FREE takes
222 * care of that.
223 *
224 * And shut everything down:
225 * @until }
226 *
227 * The full source code can be found on the examples folder
228 * on the @ref eina_list_04_c "eina_list_04.c" file.
229 */
230
231/**
232 * @page eina_list_04_c Eina_List and memory allocation example
233 *
234 * @include eina_list_04.c
235 * @example eina_list_04.c
236 */
237
238/**
239 * @addtogroup Eina_List_Group List
240 *
241 * @brief These functions provide double linked list management.
242 *
243 * Eina_List is a doubly linked list. It can store data of any type in the
244 * form of void pointers. It has convenience functions to do all the common
245 * operations which means it should rarely if ever be necessary to directly
246 * access the struct's fields. Nevertheless it can be useful to understand the
247 * inner workings of the data structure being used.
248 *
249 * @ref Eina_List nodes keep references to the previous node, the next node, its
250 * data and to an accounting structure.
251 *
252 * @htmlonly
253 * <img src="eina_list.png" style="max-width: 100%;" />
254 * <a href="eina_list.png">Full-size</a>
255 * @endhtmlonly
256 * @image rtf eina_list.png
257 * @image latex eina_list.eps width=5cm
258 *
259 * @ref Eina_List_Accounting is used to improve the performance of some
260 * functions. It is private and <b>should not</b> be modified. It contains a
261 * reference to the end of the list and the number of elements in the list.
262 *
263 * @note Every function that modifies the contents of the list returns a pointer
264 * to the head of the list and it is essential that this be pointer be used in
265 * any future references to the list.
266 *
267 * Most functions have two versions that have the same effect but operate on
268 * different arguments, the @a plain functions operate over data(eg.:
269 * @ref eina_list_append_relative, @ref eina_list_remove,
270 * @ref eina_list_data_find), the @a list versions of these functions operate
271 * on @ref Eina_List nodes.
272 *
273 * @warning You must @b always use the pointer to the first element of the list
274 * as the list!
275 * @warning You must @b never use a pointer to an element in the middle of the
276 * list as the list!
277 *
278 * Here are some examples of @ref Eina_List usage:
279 * @li @ref list_01_example_page
280 * @li @ref list_02_example_page
281 * @li @ref list_03_example_page
282 * @li @ref list_04_example_page
283 */
284
285/**
286 * @addtogroup Eina_Data_Types_Group Data Types
287 *
288 * @{
289 */
290
291/**
292 * @addtogroup Eina_Containers_Group Containers
293 *
294 * @{
295 */
296
297/**
298 * @defgroup Eina_List_Group List
299 *
300 * @{
301 */
302
303/**
304 * @typedef Eina_List
305 * Type for a generic double linked list.
306 */
307typedef struct _Eina_List Eina_List;
308
309/**
310 * @typedef Eina_List_Accounting
311 * Cache used to store the last element of a list and the number of
312 * elements, for fast access.
313 */
314typedef struct _Eina_List_Accounting Eina_List_Accounting;
315
316/**
317 * @struct _Eina_List
318 * Type for a generic double linked list.
319 */
320struct _Eina_List
321{
322 void *data; /**< Pointer to list element payload */
323 Eina_List *next; /**< Next member in the list */
324 Eina_List *prev; /**< Previous member in the list */
325 Eina_List_Accounting *accounting; /**< Private list accounting info - don't touch */
326
327 EINA_MAGIC
328};
329
330/**
331 * @struct _Eina_List_Accounting
332 * Cache used to store the last element of a list and the number of
333 * elements, for fast access. It is for private used and must not be
334 * touched.
335 */
336struct _Eina_List_Accounting
337{
338 Eina_List *last; /**< Pointer to the last element of the list - don't touch */
339 unsigned int count; /**< Number of elements of the list - don't touch */
340 EINA_MAGIC
341};
342
343
344/**
345 * @brief Append the given data to the given linked list.
346 *
347 * @param list The given list.
348 * @param data The data to append.
349 * @return A list pointer.
350 *
351 * This function appends @p data to @p list. If @p list is @c NULL, a
352 * new list is returned. On success, a new list pointer that should be
353 * used in place of the one given to this function is
354 * returned. Otherwise, the old pointer is returned.
355 *
356 * The following example code demonstrates how to ensure that the
357 * given data has been successfully appended.
358 *
359 * @code
360 * Eina_List *list = NULL;
361 * extern void *my_data;
362 *
363 * list = eina_list_append(list, my_data);
364 * if (eina_error_get())
365 * {
366 * fprintf(stderr, "ERROR: Memory is low. List allocation failed.\n");
367 * exit(-1);
368 * }
369 * @endcode
370 *
371 * @warning @p list must be a pointer to the first element of the list(or NULL).
372 */
373EAPI Eina_List *eina_list_append(Eina_List *list, const void *data) EINA_ARG_NONNULL(2) EINA_WARN_UNUSED_RESULT;
374
375
376/**
377 * @brief Prepends the given data to the given linked list.
378 *
379 * @param list The given list.
380 * @param data The data to prepend.
381 * @return A list pointer.
382 *
383 * This function prepends @p data to @p list. If @p list is @c NULL, a
384 * new list is returned. On success, a new list pointer that should be
385 * used in place of the one given to this function is
386 * returned. Otherwise, the old pointer is returned.
387 *
388 * The following example code demonstrates how to ensure that the
389 * given data has been successfully prepended.
390 *
391 * Example:
392 * @code
393 * Eina_List *list = NULL;
394 * extern void *my_data;
395 *
396 * list = eina_list_prepend(list, my_data);
397 * if (eina_error_get())
398 * {
399 * fprintf(stderr, "ERROR: Memory is low. List allocation failed.\n");
400 * exit(-1);
401 * }
402 * @endcode
403 *
404 * @warning @p list must be a pointer to the first element of the list.
405 */
406EAPI Eina_List *eina_list_prepend(Eina_List *list, const void *data) EINA_ARG_NONNULL(2) EINA_WARN_UNUSED_RESULT;
407
408
409/**
410 * @brief Insert the given data into the given linked list after the specified data.
411 *
412 * @param list The given linked list.
413 * @param data The data to insert.
414 * @param relative The data to insert after.
415 * @return A list pointer.
416 *
417 * This function inserts @p data to @p list after @p relative. If
418 * @p relative is not in the list, @p data is appended to the end of
419 * the list. If @p list is @c NULL, a new list is returned. If there
420 * are multiple instances of @p relative in the list, @p data is
421 * inserted after the first instance.On success, a new list pointer
422 * that should be used in place of the one given to this function is
423 * returned. Otherwise, the old pointer is returned.
424 *
425 * The following example code demonstrates how to ensure that the
426 * given data has been successfully inserted.
427 *
428 * @code
429 * Eina_List *list = NULL;
430 * extern void *my_data;
431 * extern void *relative_member;
432 *
433 * list = eina_list_append(list, relative_member);
434 * if (eina_error_get())
435 * {
436 * fprintf(stderr, "ERROR: Memory is low. List allocation failed.\n");
437 * exit(-1);
438 * }
439 * list = eina_list_append_relative(list, my_data, relative_member);
440 * if (eina_error_get())
441 * {
442 * fprintf(stderr, "ERROR: Memory is low. List allocation failed.\n");
443 * exit(-1);
444 * }
445 * @endcode
446 *
447 * @warning @p list must be a pointer to the first element of the list.
448 */
449EAPI Eina_List *eina_list_append_relative(Eina_List *list, const void *data, const void *relative) EINA_ARG_NONNULL(2) EINA_WARN_UNUSED_RESULT;
450
451
452/**
453 * @brief Append a list node to a linked list after the specified member
454 *
455 * @param list The given linked list.
456 * @param data The data to insert.
457 * @param relative The list node to insert after.
458 * @return A list pointer.
459 *
460 * This function inserts @p data to @p list after the list node
461 * @p relative. If @p list or @p relative are @c NULL, @p data is just
462 * appended to @p list using eina_list_append(). If @p list is
463 * @c NULL, a new list is returned. If there are multiple instances
464 * of @p relative in the list, @p data is inserted after the first
465 * instance. On success, a new list pointer that should be used in
466 * place of the one given to this function is returned. Otherwise, the
467 * old pointer is returned.
468 *
469 * @warning @p list must be a pointer to the first element of the list.
470 */
471EAPI Eina_List *eina_list_append_relative_list(Eina_List *list, const void *data, Eina_List *relative) EINA_ARG_NONNULL(2) EINA_WARN_UNUSED_RESULT;
472
473
474/**
475 * @brief Prepend a data pointer to a linked list before the specified member
476 *
477 * @param list The given linked list.
478 * @param data The data to insert.
479 * @param relative The data to insert before.
480 * @return A list pointer.
481 *
482 * This function inserts @p data to @p list before @p relative. If
483 * @p relative is not in the list, @p data is prepended to the list
484 * with eina_list_prepend(). If @p list is @c NULL, a new list is
485 * returned. If there are multiple instances of @p relative in the
486 * list, @p data is inserted before the first instance. On success, a
487 * new list pointer that should be used in place of the one given to
488 * this function is returned. Otherwise, the old pointer is returned.
489 *
490 * The following code example demonstrates how to ensure that the
491 * given data has been successfully inserted.
492 *
493 * @code
494 * Eina_List *list = NULL;
495 * extern void *my_data;
496 * extern void *relative_member;
497 *
498 * list = eina_list_append(list, relative_member);
499 * if (eina_error_get_error())
500 * {
501 * fprintf(stderr, "ERROR: Memory is low. List allocation failed.\n");
502 * exit(-1);
503 * }
504 * list = eina_list_prepend_relative(list, my_data, relative_member);
505 * if (eina_error_get())
506 * {
507 * fprintf(stderr, "ERROR: Memory is low. List allocation failed.\n");
508 * exit(-1);
509 * }
510 * @endcode
511 *
512 * @warning @p list must be a pointer to the first element of the list.
513 */
514EAPI Eina_List *eina_list_prepend_relative(Eina_List *list, const void *data, const void *relative) EINA_ARG_NONNULL(2) EINA_WARN_UNUSED_RESULT;
515
516
517/**
518 * @brief Prepend a list node to a linked list before the specified member
519 *
520 * @param list The given linked list.
521 * @param data The data to insert.
522 * @param relative The list node to insert before.
523 * @return A list pointer.
524 *
525 * This function inserts @p data to @p list before the list node
526 * @p relative. If @p list or @p relative are @c NULL, @p data is just
527 * prepended to @p list using eina_list_prepend(). If @p list is
528 * @c NULL, a new list is returned. If there are multiple instances
529 * of @p relative in the list, @p data is inserted before the first
530 * instance. On success, a new list pointer that should be used in
531 * place of the one given to this function is returned. Otherwise, the
532 * old pointer is returned.
533 *
534 * @warning @p list must be a pointer to the first element of the list.
535 */
536EAPI Eina_List *eina_list_prepend_relative_list(Eina_List *list, const void *data, Eina_List *relative) EINA_ARG_NONNULL(2) EINA_WARN_UNUSED_RESULT;
537
538
539/**
540 * @brief Insert a new node into a sorted list.
541 *
542 * @param list The given linked list, @b must be sorted.
543 * @param func The function called for the sort.
544 * @param data The data to insert sorted.
545 * @return A list pointer.
546 *
547 * This function inserts values into a linked list assuming it was
548 * sorted and the result will be sorted. If @p list is @c NULLL, a new
549 * list is returned. On success, a new list pointer that should be
550 * used in place of the one given to this function is
551 * returned. Otherwise, the old pointer is returned. See eina_error_get().
552 *
553 * @note O(log2(n)) comparisons (calls to @p func) average/worst case
554 * performance as it uses eina_list_search_sorted_near_list() and thus
555 * is bounded to that. As said in eina_list_search_sorted_near_list(),
556 * lists do not have O(1) access time, so walking to the correct node
557 * can be costly, consider worst case to be almost O(n) pointer
558 * dereference (list walk).
559 *
560 * @warning @p list must be a pointer to the first element of the list.
561 */
562EAPI Eina_List *eina_list_sorted_insert(Eina_List *list, Eina_Compare_Cb func, const void *data) EINA_ARG_NONNULL(2, 3) EINA_WARN_UNUSED_RESULT;
563
564
565/**
566 * @brief Remove the first instance of the specified data from the given list.
567 *
568 * @param list The given list.
569 * @param data The specified data.
570 * @return A list pointer.
571 *
572 * This function removes the first instance of @p data from
573 * @p list. If the specified data is not in the given list (tihis
574 * include the case where @p data is @c NULL), nothing is done. If
575 * @p list is @c NULL, @c NULL is returned, otherwise a new list
576 * pointer that should be used in place of the one passed to this
577 * function.
578 *
579 * @warning @p list must be a pointer to the first element of the list.
580 */
581EAPI Eina_List *eina_list_remove(Eina_List *list, const void *data) EINA_ARG_NONNULL(2) EINA_WARN_UNUSED_RESULT;
582
583
584/**
585 * @brief Remove the specified data.
586 *
587 * @param list The given linked list.
588 * @param remove_list The list node which is to be removed.
589 * @return A list pointer.
590 *
591 * This function removes the list node @p remove_list from @p list and
592 * frees the list node structure @p remove_list. If @p list is
593 * @c NULL, this function returns @c NULL. If @p remove_list is
594 * @c NULL, it returns @p list, otherwise, a new list pointer that
595 * should be used in place of the one passed to this function.
596 *
597 * The following code gives an example (notice we use EINA_LIST_FOREACH
598 * instead of EINA_LIST_FOREACH_SAFE because we stop the loop after
599 * removing the current node).
600 *
601 * @code
602 * extern Eina_List *list;
603 * Eina_List *l;
604 * extern void *my_data;
605 * void *data
606 *
607 * EINA_LIST_FOREACH(list, l, data)
608 * {
609 * if (data == my_data)
610 * {
611 * list = eina_list_remove_list(list, l);
612 * break;
613 * }
614 * }
615 * @endcode
616 *
617 * @warning @p list must be a pointer to the first element of the list.
618 */
619EAPI Eina_List *eina_list_remove_list(Eina_List *list, Eina_List *remove_list) EINA_ARG_NONNULL(2) EINA_WARN_UNUSED_RESULT;
620
621
622/**
623 * @brief Move the specified data to the head of the list.
624 *
625 * @param list The list handle to move the data.
626 * @param move_list The list node to move.
627 * @return A new list handle to replace the old one
628 *
629 * This function move @p move_list to the front of @p list. If list is
630 * @c NULL, @c NULL is returned. If @p move_list is @c NULL,
631 * @p list is returned. Otherwise, a new list pointer that should be
632 * used in place of the one passed to this function.
633 *
634 * Example:
635 * @code
636 * extern Eina_List *list;
637 * Eina_List *l;
638 * extern void *my_data;
639 * void *data;
640 *
641 * EINA_LIST_FOREACH(list, l, data)
642 * {
643 * if (data == my_data)
644 * {
645 * list = eina_list_promote_list(list, l);
646 * break;
647 * }
648 * }
649 * @endcode
650 *
651 * @warning @p list must be a pointer to the first element of the list.
652 */
653EAPI Eina_List *eina_list_promote_list(Eina_List *list, Eina_List *move_list) EINA_ARG_NONNULL(2) EINA_WARN_UNUSED_RESULT;
654
655
656/**
657 * @brief Move the specified data to the tail of the list.
658 *
659 * @param list The list handle to move the data.
660 * @param move_list The list node to move.
661 * @return A new list handle to replace the old one
662 *
663 * This function move @p move_list to the back of @p list. If list is
664 * @c NULL, @c NULL is returned. If @p move_list is @c NULL,
665 * @p list is returned. Otherwise, a new list pointer that should be
666 * used in place of the one passed to this function.
667 *
668 * Example:
669 * @code
670 * extern Eina_List *list;
671 * Eina_List *l;
672 * extern void *my_data;
673 * void *data;
674 *
675 * EINA_LIST_FOREACH(list, l, data)
676 * {
677 * if (data == my_data)
678 * {
679 * list = eina_list_demote_list(list, l);
680 * break;
681 * }
682 * }
683 * @endcode
684 *
685 * @warning @p list must be a pointer to the first element of the list.
686 */
687EAPI Eina_List *eina_list_demote_list(Eina_List *list, Eina_List *move_list);
688
689
690/**
691 * @brief Find a member of a list and return the member.
692 *
693 * @param list The list to search for a data.
694 * @param data The data pointer to find in the list.
695 * @return The found member data pointer if found, @c NULL otherwise.
696 *
697 * This function searches in @p list from beginning to end for the
698 * first member whose data pointer is @p data. If it is found, @p data
699 * will be returned, otherwise NULL will be returned.
700 *
701 * Example:
702 * @code
703 * extern Eina_List *list;
704 * extern void *my_data;
705 *
706 * if (eina_list_data_find(list, my_data) == my_data)
707 * {
708 * printf("Found member %p\n", my_data);
709 * }
710 * @endcode
711 *
712 * @warning @p list must be a pointer to the first element of the list.
713 */
714EAPI void *eina_list_data_find(const Eina_List *list, const void *data) EINA_PURE EINA_ARG_NONNULL(2) EINA_WARN_UNUSED_RESULT;
715
716/**
717 * @brief Find a member of a list and return the list node containing that member.
718 *
719 * @param list The list to search for data.
720 * @param data The data pointer to find in the list.
721 * @return The found members list node on success, @c NULL otherwise.
722 *
723 * This function searches in @p list from beginning to end for the
724 * first member whose data pointer is @p data. If it is found, the
725 * list node containing the specified member is returned, otherwise
726 * @c NULL is returned.
727 *
728 * @warning @p list must be a pointer to the first element of the list.
729 */
730EAPI Eina_List *eina_list_data_find_list(const Eina_List *list, const void *data) EINA_PURE EINA_ARG_NONNULL(2) EINA_WARN_UNUSED_RESULT;
731
732
733/**
734 * @brief Move a data pointer from one list to another
735 *
736 * @param to The list to move the data to
737 * @param from The list to move from
738 * @param data The data to move
739 * @return #EINA_TRUE on success, else #EINA_FALSE
740 *
741 * This function is a shortcut for doing the following:
742 * to = eina_list_append(to, data);
743 * from = eina_list_remove(from, data);
744 *
745 * @warning @p list must be a pointer to the first element of the list.
746 */
747EAPI Eina_Bool eina_list_move(Eina_List **to, Eina_List **from, void *data);
748
749/**
750 * @brief Move a list node from one list to another
751 *
752 * @param to The list to move the data to
753 * @param from The list to move from
754 * @param data The list node containing the data to move
755 * @return #EINA_TRUE on success, else #EINA_FALSE
756 *
757 * This function is a shortcut for doing the following:
758 * to = eina_list_append(to, data->data);
759 * from = eina_list_remove_list(from, data);
760 *
761 * @warning @p list must be a pointer to the first element of the list.
762 */
763EAPI Eina_Bool eina_list_move_list(Eina_List **to, Eina_List **from, Eina_List *data);
764
765
766/**
767 * @brief Free an entire list and all the nodes, ignoring the data contained.
768
769 * @param list The list to free
770 * @return A NULL pointer
771 *
772 * This function frees all the nodes of @p list. It does not free the
773 * data of the nodes. To free them, use #EINA_LIST_FREE.
774 */
775EAPI Eina_List *eina_list_free(Eina_List *list);
776
777
778/**
779 * @brief Get the nth member's data pointer in a list.
780 *
781 * @param list The list to get the specified member number from.
782 * @param n The number of the element (0 being the first).
783 * @return The data pointer stored in the specified element.
784 *
785 * This function returns the data pointer of element number @p n, in
786 * the @p list. The first element in the array is element number 0. If
787 * the element number @p n does not exist, @c NULL is
788 * returned. Otherwise, the data of the found element is returned.
789 *
790 * @note Worst case is O(n).
791 *
792 * @warning @p list must be a pointer to the first element of the list.
793 */
794EAPI void *eina_list_nth(const Eina_List *list, unsigned int n) EINA_PURE EINA_WARN_UNUSED_RESULT;
795
796
797/**
798 * @brief Get the nth member's list node in a list.
799 *
800 * @param list The list to get the specfied member number from.
801 * @param n The number of the element (0 being the first).
802 * @return The list node stored in the numbered element.
803 *
804 * This function returns the list node of element number @p n, in
805 * @p list. The first element in the array is element number 0. If the
806 * element number @p n does not exist or @p list is @c NULL or @p n is
807 * greater than the count of elements in @p list minus 1, @c NULL is
808 * returned. Otherwise the list node stored in the numbered element is
809 * returned.
810 *
811 * @note Worst case is O(n).
812 *
813 * @warning @p list must be a pointer to the first element of the list.
814 */
815EAPI Eina_List *eina_list_nth_list(const Eina_List *list, unsigned int n) EINA_PURE EINA_WARN_UNUSED_RESULT;
816
817
818/**
819 * @brief Reverse all the elements in the list.
820 *
821 * @param list The list to reverse.
822 * @return The list head after it has been reversed.
823 *
824 * This function reverses the order of all elements in @p list, so the
825 * last member is now first, and so on. If @p list is @c NULL, this
826 * functon returns @c NULL.
827 *
828 * @note @b in-place: this will change the given list, so you should
829 * now point to the new list head that is returned by this function.
830 *
831 * @warning @p list must be a pointer to the first element of the list.
832 *
833 * @see eina_list_reverse_clone()
834 * @see eina_list_iterator_reversed_new()
835 */
836EAPI Eina_List *eina_list_reverse(Eina_List *list) EINA_WARN_UNUSED_RESULT;
837
838
839/**
840 * @brief Clone (copy) all the elements in the list in reverse order.
841 *
842 * @param list The list to reverse.
843 * @return The new list that has been reversed.
844 *
845 * This function reverses the order of all elements in @p list, so the
846 * last member is now first, and so on. If @p list is @c NULL, this
847 * functon returns @c NULL. This returns a copy of the given list.
848 *
849 * @note @b copy: this will copy the list and you should then
850 * eina_list_free() when it is not required anymore.
851 *
852 * @warning @p list must be a pointer to the first element of the list.
853 *
854 * @see eina_list_reverse()
855 * @see eina_list_clone()
856 */
857EAPI Eina_List *eina_list_reverse_clone(const Eina_List *list) EINA_WARN_UNUSED_RESULT;
858
859
860/**
861 * @brief Clone (copy) all the elements in the list in exactly same order.
862 *
863 * @param list The list to clone.
864 * @return The new list that has been cloned.
865 *
866 * This function clone in order of all elements in @p list. If @p list
867 * is @c NULL, this functon returns @c NULL. This returns a copy of
868 * the given list.
869 *
870 * @note @b copy: this will copy the list and you should then
871 * eina_list_free() when it is not required anymore.
872 *
873 * @warning @p list must be a pointer to the first element of the list.
874 *
875 * @see eina_list_reverse_clone()
876 */
877EAPI Eina_List *eina_list_clone(const Eina_List *list) EINA_WARN_UNUSED_RESULT;
878
879
880/**
881 * @brief Sort a list according to the ordering func will return.
882 *
883 * @param list The list handle to sort.
884 * @param size The length of the list to sort.
885 * @param func A function pointer that can handle comparing the list data
886 * nodes.
887 * @return the new head of list.
888 *
889 * This function sorts @p list. @p size if the number of the first
890 * element to sort. If @p size is 0 or greater than the number of
891 * elements in @p list, all the elements are sorted. @p func is used to
892 * compare two elements of @p list. If @p list or @p func are @c NULL,
893 * this function returns @c NULL.
894 *
895 * @note @b in-place: this will change the given list, so you should
896 * now point to the new list head that is returned by this function.
897 *
898 * @note worst case is O(n * log2(n)) comparisons (calls to func()),
899 * O(n) comparisons average case. That means that for 1,000,000 list
900 * elements, sort will usually do 1,000,000 comparisons, but may do up
901 * to 20,000,000.
902 *
903 * Example:
904 * @code
905 * int
906 * sort_cb(const void *d1, const void *d2)
907 * {
908 * const char *txt = d1;
909 * const char *txt2 = d2;
910 *
911 * if(!txt) return(1);
912 * if(!txt2) return(-1);
913 *
914 * return(strcmp(txt, txt2));
915 * }
916 * extern Eina_List *list;
917 *
918 * list = eina_list_sort(list, eina_list_count(list), sort_cb);
919 * @endcode
920 *
921 * @warning @p list must be a pointer to the first element of the list.
922 */
923EAPI Eina_List *eina_list_sort(Eina_List *list, unsigned int size, Eina_Compare_Cb func) EINA_ARG_NONNULL(3) EINA_WARN_UNUSED_RESULT;
924
925
926/**
927 * @brief Merge two list.
928 *
929 * @param left Head list to merge.
930 * @param right Tail list to merge.
931 * @return A new merged list.
932 *
933 * This function puts right at the end of left and return the head.
934 *
935 * Both left and right does not exist anymore after the merge.
936 *
937 * @note merge cost is O(n), being @b n the size of the smallest
938 * list. This is due the need to fix accounting of that segment,
939 * making count and last access O(1).
940 *
941 * @warning @p list must be a pointer to the first element of the list.
942 */
943EAPI Eina_List *eina_list_merge(Eina_List *left, Eina_List *right) EINA_WARN_UNUSED_RESULT;
944
945
946/**
947 * @brief Merge two sorted list according to the ordering func will return.
948 *
949 * @param left First list to merge.
950 * @param right Second list to merge.
951 * @param func A function pointer that can handle comparing the list data
952 * nodes.
953 * @return A new sorted list.
954 *
955 * This function compares the head of @p left and @p right, and choose the
956 * smallest one to be head of the returned list. It will continue this process
957 * for all entry of both list.
958 *
959 * Both left and right does not exist anymore after the merge.
960 * If @p func is NULL, it will return NULL.
961 *
962 * Example:
963 * @code
964 * int
965 * sort_cb(void *d1, void *d2)
966 * {
967 * const char *txt = NULL;
968 * const char *txt2 = NULL;
969 *
970 * if(!d1) return(1);
971 * if(!d2) return(-1);
972 *
973 * return(strcmp((const char*)d1, (const char*)d2));
974 * }
975 * extern Eina_List *sorted1;
976 * extern Eina_List *sorted2;
977 *
978 * list = eina_list_sorted_merge(sorted1, sorted2, sort_cb);
979 * @endcode
980 *
981 * @warning @p list must be a pointer to the first element of the list.
982 */
983EAPI Eina_List *eina_list_sorted_merge(Eina_List *left, Eina_List *right, Eina_Compare_Cb func) EINA_ARG_NONNULL(3) EINA_WARN_UNUSED_RESULT;
984
985
986/**
987 * @brief Split a list into 2 lists.
988 *
989 * @param list List to split.
990 * @param relative The list will be split after @p relative.
991 * @param right The head of the new right list.
992 * @return The new left list
993 *
994 * This function splits @p list into two lists ( left and right ) after the node @p relative. @p Relative
995 * will become the last node of the left list. If @p list or @p right are NULL list is returns.
996 * If @p relative is NULL right is set to @p list and NULL is returns.
997 * If @p relative is the last node of @p list list is returns and @p right is set to NULL.
998 *
999 * list does not exist anymore after the split.
1000 *
1001 * @warning @p list must be a pointer to the first element of the list.
1002 */
1003EAPI Eina_List *eina_list_split_list(Eina_List *list, Eina_List *relative, Eina_List **right) EINA_WARN_UNUSED_RESULT;
1004
1005
1006/**
1007 * @brief Returns node nearest to data is in the sorted list.
1008 *
1009 * @param list The list to search for data, @b must be sorted.
1010 * @param func A function pointer that can handle comparing the list data nodes.
1011 * @param data reference value to search.
1012 * @param result_cmp if provided returns the result of
1013 * func(node->data, data) node being the last (returned) node. If node
1014 * was found (exact match), then it is 0. If returned node is smaller
1015 * than requested data, it is less than 0 and if it's bigger it's
1016 * greater than 0. It is the last value returned by func().
1017 * @return the nearest node, NULL if not found.
1018 *
1019 * This function searches for a node containing @p data as it's data in @p list,
1020 * if such a node exists it will be returned and @p result_cmp will be @p 0. If
1021 * the data of no node in @p list is equal to @p data, the node with the nearest
1022 * value to that will be returned and @p result_cmp will be the return value of
1023 * @p func with @p data and the returned node's data as arguments.
1024 *
1025 * This function is useful for inserting an element in the list only in case it
1026 * isn't already present in the list, the naive way of doing this would be:
1027 * @code
1028 * void *ptr = eina_list_data_find(list, "my data");
1029 * if (!ptr)
1030 * eina_list_sorted_insert(list, "my data");
1031 * @endcode
1032 *
1033 * However this has the downside of walking through the list twice, once to
1034 * check if the data is already present and another to insert the element in the
1035 * corret position. This can be done more eficiently:
1036 * @code
1037 * int cmp_result;
1038 * l = eina_list_search_sorted_near_list(list, cmp_func, "my data",
1039 * &cmp_result);
1040 * if (cmp_result > 0)
1041 * list = eina_list_prepend_relative_list(list, "my data", l);
1042 * else if (cmp_result < 0)
1043 * list = eina_list_append_relative_list(list, "my data", l);
1044 * @endcode
1045 *
1046 * If @a cmp_result is 0 the element is already in the list and we need not
1047 * insert it, if @a cmp_result is greater than zero @a "my @a data" needs to
1048 * come after @a l(the nearest node present), if less than zero before.
1049 *
1050 * @note O(log2(n)) average/worst case performance, for 1,000,000
1051 * elements it will do a maximum of 20 comparisons. This is much
1052 * faster than the 1,000,000 comparisons made naively walking the list
1053 * from head to tail, so depending on the number of searches and
1054 * insertions, it may be worth to eina_list_sort() the list and do the
1055 * searches later. As lists do not have O(1) access time, walking to
1056 * the correct node can be costly, consider worst case to be almost
1057 * O(n) pointer dereference (list walk).
1058 *
1059 * @warning @p list must be a pointer to the first element of the list.
1060 *
1061 * @see eina_list_search_sorted_list()
1062 * @see eina_list_sort()
1063 * @see eina_list_sorted_merge()
1064 */
1065EAPI Eina_List *eina_list_search_sorted_near_list(const Eina_List *list, Eina_Compare_Cb func, const void *data, int *result_cmp);
1066
1067
1068/**
1069 * @brief Returns node if data is in the sorted list.
1070 *
1071 * @param list The list to search for data, @b must be sorted.
1072 * @param func A function pointer that can handle comparing the list data nodes.
1073 * @param data reference value to search.
1074 * @return the node if func(node->data, data) == 0, NULL if not found.
1075 *
1076 * This can be used to check if some value is inside the list and get
1077 * the container node in this case. It should be used when list is
1078 * known to be sorted as it will do binary search for results.
1079 *
1080 * Example: imagine user gives a string, you check if it's in the list
1081 * before duplicating its contents.
1082 *
1083 * @note O(log2(n)) average/worst case performance, for 1,000,000
1084 * elements it will do a maximum of 20 comparisons. This is much
1085 * faster than the 1,000,000 comparisons made by
1086 * eina_list_search_unsorted_list(), so depending on the number of
1087 * searches and insertions, it may be worth to eina_list_sort() the
1088 * list and do the searches later. As said in
1089 * eina_list_search_sorted_near_list(), lists do not have O(1) access
1090 * time, so walking to the correct node can be costly, consider worst
1091 * case to be almost O(n) pointer dereference (list walk).
1092 *
1093 * @warning @p list must be a pointer to the first element of the list.
1094 *
1095 * @see eina_list_search_sorted()
1096 * @see eina_list_sort()
1097 * @see eina_list_sorted_merge()
1098 * @see eina_list_search_unsorted_list()
1099 * @see eina_list_search_sorted_near_list()
1100 */
1101EAPI Eina_List *eina_list_search_sorted_list(const Eina_List *list, Eina_Compare_Cb func, const void *data);
1102
1103
1104/**
1105 * @brief Returns node data if it is in the sorted list.
1106 *
1107 * @param list The list to search for data, @b must be sorted.
1108 * @param func A function pointer that can handle comparing the list data nodes.
1109 * @param data reference value to search.
1110 * @return the node value (@c node->data) if func(node->data, data) == 0,
1111 * NULL if not found.
1112 *
1113 * This can be used to check if some value is inside the list and get
1114 * the existing instance in this case. It should be used when list is
1115 * known to be sorted as it will do binary search for results.
1116 *
1117 * Example: imagine user gives a string, you check if it's in the list
1118 * before duplicating its contents.
1119 *
1120 * @note O(log2(n)) average/worst case performance, for 1,000,000
1121 * elements it will do a maximum of 20 comparisons. This is much
1122 * faster than the 1,000,000 comparisons made by
1123 * eina_list_search_unsorted(), so depending on the number of
1124 * searches and insertions, it may be worth to eina_list_sort() the
1125 * list and do the searches later. As said in
1126 * eina_list_search_sorted_near_list(), lists do not have O(1) access
1127 * time, so walking to the correct node can be costly, consider worst
1128 * case to be almost O(n) pointer dereference (list walk).
1129 *
1130 * @warning @p list must be a pointer to the first element of the list.
1131 *
1132 * @see eina_list_search_sorted_list()
1133 * @see eina_list_sort()
1134 * @see eina_list_sorted_merge()
1135 * @see eina_list_search_unsorted_list()
1136 */
1137EAPI void *eina_list_search_sorted(const Eina_List *list, Eina_Compare_Cb func, const void *data);
1138
1139
1140/**
1141 * @brief Returns node if data is in the unsorted list.
1142 *
1143 * @param list The list to search for data, may be unsorted.
1144 * @param func A function pointer that can handle comparing the list data nodes.
1145 * @param data reference value to search.
1146 * @return the node if func(node->data, data) == 0, NULL if not found.
1147 *
1148 * This can be used to check if some value is inside the list and get
1149 * the container node in this case.
1150 *
1151 * Example: imagine user gives a string, you check if it's in the list
1152 * before duplicating its contents.
1153 *
1154 * @note this is expensive and may walk the whole list, it's order-N,
1155 * that is for 1,000,000 elements list it may walk and compare
1156 * 1,000,000 nodes.
1157 *
1158 * @warning @p list must be a pointer to the first element of the list.
1159 *
1160 * @see eina_list_search_sorted_list()
1161 * @see eina_list_search_unsorted()
1162 */
1163EAPI Eina_List *eina_list_search_unsorted_list(const Eina_List *list, Eina_Compare_Cb func, const void *data);
1164
1165
1166/**
1167 * @brief Returns node data if it is in the unsorted list.
1168 *
1169 * @param list The list to search for data, may be unsorted.
1170 * @param func A function pointer that can handle comparing the list data nodes.
1171 * @param data reference value to search.
1172 * @return the node value (@c node->data) if func(node->data, data) == 0,
1173 * NULL if not found.
1174 *
1175 * This can be used to check if some value is inside the list and get
1176 * the existing instance in this case.
1177 *
1178 * Example: imagine user gives a string, you check if it's in the list
1179 * before duplicating its contents.
1180 *
1181 * @note this is expensive and may walk the whole list, it's order-N,
1182 * that is for 1,000,000 elements list it may walk and compare
1183 * 1,000,000 nodes.
1184 *
1185 * @warning @p list must be a pointer to the first element of the list.
1186 *
1187 * @see eina_list_search_sorted()
1188 * @see eina_list_search_unsorted_list()
1189 */
1190EAPI void *eina_list_search_unsorted(const Eina_List *list, Eina_Compare_Cb func, const void *data);
1191
1192/**
1193 * @brief Get the last list node in the list.
1194 *
1195 * @param list The list to get the last list node from.
1196 * @return The last list node in the list.
1197 *
1198 * This function returns the last list node in the list @p list. If
1199 * @p list is @c NULL or empty, @c NULL is returned.
1200 *
1201 * This is a order-1 operation (it takes the same short time
1202 * regardless of the length of the list).
1203 *
1204 * @warning @p list must be a pointer to the first element of the list.
1205 */
1206static inline Eina_List *eina_list_last(const Eina_List *list) EINA_PURE EINA_WARN_UNUSED_RESULT;
1207
1208/**
1209 * @brief Get the next list node after the specified list node.
1210 *
1211 * @param list The list node to get the next list node from
1212 * @return The next list node on success, @c NULL otherwise.
1213 *
1214 * This function returns the next list node after the current one in
1215 * @p list. It is equivalent to list->next. If @p list is @c NULL or
1216 * if no next list node exists, it returns @c NULL.
1217 *
1218 * @warning @p list must be a pointer to the first element of the list.
1219 */
1220static inline Eina_List *eina_list_next(const Eina_List *list) EINA_PURE EINA_WARN_UNUSED_RESULT;
1221
1222/**
1223 * @brief Get the previous list node before the specified list node.
1224 *
1225 * @param list The list node to get the previous list node from.
1226 * @return The previous list node o success, @c NULL otherwise.
1227 * if no previous list node exists
1228 *
1229 * This function returns the previous list node before the current one
1230 * in @p list. It is equivalent to list->prev. If @p list is @c NULL or
1231 * if no previous list node exists, it returns @c NULL.
1232 *
1233 * @warning @p list must be a pointer to the first element of the list.
1234 */
1235static inline Eina_List *eina_list_prev(const Eina_List *list) EINA_PURE EINA_WARN_UNUSED_RESULT;
1236
1237/**
1238 * @brief Get the list node data member.
1239 *
1240 * @param list The list node to get the data member of.
1241 * @return The data member from the list node.
1242 *
1243 * This function returns the data member of the specified list node @p
1244 * list. It is equivalent to list->data. If @p list is @c NULL, this
1245 * function returns @c NULL.
1246 *
1247 * @warning @p list must be a pointer to the first element of the list.
1248 */
1249static inline void *eina_list_data_get(const Eina_List *list) EINA_PURE EINA_WARN_UNUSED_RESULT;
1250
1251/**
1252 * @brief Set the list node data member.
1253 *
1254 * @param list The list node to get the data member of.
1255 * @param data The data member to the list node.
1256 * @return The previous data value.
1257 *
1258 * This function set the data member @p data of the specified list node
1259 * @p list. It returns the previous data of the node. If @p list is
1260 * @c NULL, this function returns @c NULL.
1261 *
1262 * @warning @p list must be a pointer to the first element of the list.
1263 */
1264static inline void *eina_list_data_set(Eina_List *list, const void *data);
1265
1266/**
1267 * @brief Get the count of the number of items in a list.
1268 *
1269 * @param list The list whose count to return.
1270 * @return The number of members in the list.
1271 *
1272 * This function returns how many members @p list contains. If the
1273 * list is @c NULL, 0 is returned.
1274 *
1275 * NB: This is an order-1 operation and takes the same time regardless
1276 * of the length of the list.
1277 *
1278 * @warning @p list must be a pointer to the first element of the list.
1279 */
1280static inline unsigned int eina_list_count(const Eina_List *list) EINA_PURE;
1281
1282
1283/**
1284 * @brief Returned a new iterator associated to a list.
1285 *
1286 * @param list The list.
1287 * @return A new iterator.
1288 *
1289 * This function returns a newly allocated iterator associated to @p
1290 * list. If @p list is @c NULL or the count member of @p list is less
1291 * or equal than 0, this function still returns a valid iterator that
1292 * will always return false on eina_iterator_next(), thus keeping API
1293 * sane.
1294 *
1295 * If the memory can not be allocated, NULL is returned and
1296 * #EINA_ERROR_OUT_OF_MEMORY is set. Otherwise, a valid iterator is
1297 * returned.
1298 *
1299 * @warning @p list must be a pointer to the first element of the list.
1300 *
1301 * @warning if the list structure changes then the iterator becomes
1302 * invalid! That is, if you add or remove nodes this iterator
1303 * behavior is undefined and your program may crash!
1304 */
1305EAPI Eina_Iterator *eina_list_iterator_new(const Eina_List *list) EINA_MALLOC EINA_WARN_UNUSED_RESULT;
1306
1307
1308/**
1309 * @brief Returned a new reversed iterator associated to a list.
1310 *
1311 * @param list The list.
1312 * @return A new iterator.
1313 *
1314 * This function returns a newly allocated iterator associated to @p
1315 * list. If @p list is @c NULL or the count member of @p list is less
1316 * or equal than 0, this function still returns a valid iterator that
1317 * will always return false on eina_iterator_next(), thus keeping API
1318 * sane.
1319 *
1320 * Unlike eina_list_iterator_new(), this will walk the list backwards.
1321 *
1322 * If the memory can not be allocated, NULL is returned and
1323 * #EINA_ERROR_OUT_OF_MEMORY is set. Otherwise, a valid iterator is
1324 * returned.
1325 *
1326 * @warning @p list must be a pointer to the first element of the list.
1327 *
1328 * @warning if the list structure changes then the iterator becomes
1329 * invalid! That is, if you add or remove nodes this iterator
1330 * behavior is undefined and your program may crash!
1331 */
1332EAPI Eina_Iterator *eina_list_iterator_reversed_new(const Eina_List *list) EINA_MALLOC EINA_WARN_UNUSED_RESULT;
1333
1334
1335/**
1336 * @brief Returned a new accessor associated to a list.
1337 *
1338 * @param list The list.
1339 * @return A new accessor.
1340 *
1341 * This function returns a newly allocated accessor associated to
1342 * @p list. If @p list is @c NULL or the count member of @p list is
1343 * less or equal than 0, this function returns NULL. If the memory can
1344 * not be allocated, NULL is returned and #EINA_ERROR_OUT_OF_MEMORY is
1345 * set. Otherwise, a valid accessor is returned.
1346 *
1347 * @warning @p list must be a pointer to the first element of the list.
1348 */
1349EAPI Eina_Accessor *eina_list_accessor_new(const Eina_List *list) EINA_MALLOC EINA_WARN_UNUSED_RESULT;
1350
1351/**
1352 * @def EINA_LIST_FOREACH
1353 * @brief Macro to iterate over a list.
1354 *
1355 * @param list The list to iterate over.
1356 * @param l A list that is used as an iterator and points to the current node.
1357 * @param data Current item's data.
1358 *
1359 * This macro iterates over @p list from the first element to
1360 * the last. @p data is the data related to the current element.
1361 * @p l is an #Eina_List used as the list iterator.
1362 *
1363 * The following diagram ilustrates this macro iterating over a list of four
1364 * elements("one", "two", "three" and "four"):
1365 * @htmlonly
1366 * <img src="eina-list-foreach.png" style="max-width: 100%;" />
1367 * <a href="eina-list-foreach.png">Full-size</a>
1368 * @endhtmlonly
1369 * @image latex eina-list-foreach.eps width=\textwidth
1370 *
1371 * It can be used to free list data, as in the following example:
1372 *
1373 * @code
1374 * Eina_List *list;
1375 * Eina_List *l;
1376 * char *data;
1377 *
1378 * // list is already filled,
1379 * // its elements are just duplicated strings,
1380 * // EINA_LIST_FOREACH will be used to free those strings
1381 *
1382 * EINA_LIST_FOREACH(list, l, data)
1383 * free(data);
1384 * eina_list_free(list);
1385 * @endcode
1386 *
1387 * @note This is not the optimal way to release memory allocated to
1388 * a list, since it iterates over the list twice.
1389 * For an optimized algorithm, use EINA_LIST_FREE().
1390 *
1391 * @warning @p list must be a pointer to the first element of the list.
1392 *
1393 * @warning Be careful when deleting list nodes.
1394 * If you remove the current node and continue iterating,
1395 * the code will fail because the macro will not be able
1396 * to get the next node. Notice that it's OK to remove any
1397 * node if you stop the loop after that.
1398 * For destructive operations such as this, consider
1399 * using EINA_LIST_FOREACH_SAFE().
1400 */
1401#define EINA_LIST_FOREACH(list, l, data) \
1402 for (l = list, \
1403 data = eina_list_data_get(l); \
1404 l; \
1405 l = eina_list_next(l), \
1406 data = eina_list_data_get(l))
1407
1408/**
1409 * @def EINA_LIST_REVERSE_FOREACH
1410 * @brief Macro to iterate over a list in the reverse order.
1411 *
1412 * @param list The list to iterate over.
1413 * @param l A list that is used as an iterator and points to the current node.
1414 * @param data Current item's data.
1415 *
1416 * This macro works like EINA_LIST_FOREACH, but iterates from the
1417 * last element of a list to the first.
1418 * @p data is the data related to the current element, while @p l
1419 * is an #Eina_List that is used as the list iterator.
1420 *
1421 * The following diagram ilustrates this macro iterating over a list of four
1422 * elements("one", "two", "three" and "four"):
1423 * @htmlonly
1424 * <img src="eina-list-reverse-foreach.png" style="max-width: 100%;" />
1425 * <a href="eina-list-reverse-foreach.png">Full-size</a>
1426 * @endhtmlonly
1427 * @image latex eina-list-reverse-foreach.eps width=\textwidth
1428 *
1429 * It can be used to free list data, as in the following example:
1430 *
1431 * @code
1432 * Eina_List *list;
1433 * Eina_List *l;
1434 * char *data;
1435 *
1436 * // list is already filled,
1437 * // its elements are just duplicated strings,
1438 * // EINA_LIST_REVERSE_FOREACH will be used to free those strings
1439 *
1440 * EINA_LIST_REVERSE_FOREACH(list, l, data)
1441 * free(data);
1442 * eina_list_free(list);
1443 * @endcode
1444 *
1445 * @note This is not the optimal way to release memory allocated to
1446 * a list, since it iterates over the list twice.
1447 * For an optimized algorithm, use EINA_LIST_FREE().
1448 *
1449 * @warning @p list must be a pointer to the first element of the list.
1450 *
1451 * @warning Be careful when deleting list nodes.
1452 * If you remove the current node and continue iterating,
1453 * the code will fail because the macro will not be able
1454 * to get the next node. Notice that it's OK to remove any
1455 * node if you stop the loop after that.
1456 * For destructive operations such as this, consider
1457 * using EINA_LIST_REVERSE_FOREACH_SAFE().
1458 */
1459#define EINA_LIST_REVERSE_FOREACH(list, l, data) \
1460 for (l = eina_list_last(list), \
1461 data = eina_list_data_get(l); \
1462 l; \
1463 l = eina_list_prev(l), \
1464 data = eina_list_data_get(l))
1465
1466/**
1467 * @def EINA_LIST_FOREACH_SAFE
1468 * @brief Macro to iterate over a list with support for node deletion.
1469 *
1470 * @param list The list to iterate over.
1471 * @param l A list that is used as an iterator and points to the current node.
1472 * @param l_next A list that is used as an iterator and points to the next node.
1473 * @param data Current item's data.
1474 *
1475 * This macro iterates over @p list from the first element to
1476 * the last. @p data is the data related to the current element.
1477 * @p l is an #Eina_List used as the list iterator.
1478 *
1479 * Since this macro stores a pointer to the next list node in @p l_next,
1480 * deleting the current node and continuing looping is safe.
1481 *
1482 * The following diagram ilustrates this macro iterating over a list of four
1483 * elements("one", "two", "three" and "four"):
1484 * @htmlonly
1485 * <img src="eina-list-foreach-safe.png" style="max-width: 100%;" />
1486 * <a href="eina-list-foreach-safe.png">Full-size</a>
1487 * @endhtmlonly
1488 * @image latex eina-list-foreach-safe.eps width=\textwidth
1489 *
1490 * This macro can be used to free list nodes, as in the following example:
1491 *
1492 * @code
1493 * Eina_List *list;
1494 * Eina_List *l;
1495 * Eina_List *l_next;
1496 * char *data;
1497 *
1498 * // list is already filled,
1499 * // its elements are just duplicated strings,
1500 * // EINA_LIST_FOREACH_SAFE will be used to free elements that match "key".
1501 *
1502 * EINA_LIST_FOREACH_SAFE(list, l, l_next, data)
1503 * if (strcmp(data, "key") == 0) {
1504 * free(data);
1505 * list = eina_list_remove_list(list, l);
1506 * }
1507 * @endcode
1508 *
1509 * @warning @p list must be a pointer to the first element of the list.
1510 */
1511#define EINA_LIST_FOREACH_SAFE(list, l, l_next, data) \
1512 for (l = list, \
1513 l_next = eina_list_next(l), \
1514 data = eina_list_data_get(l); \
1515 l; \
1516 l = l_next, \
1517 l_next = eina_list_next(l), \
1518 data = eina_list_data_get(l))
1519
1520/**
1521 * @def EINA_LIST_REVERSE_FOREACH_SAFE
1522 * @brief Macro to iterate over a list in the reverse order with support
1523 * for deletion.
1524 *
1525 * @param list The list to iterate over.
1526 * @param l A list that is used as an iterator and points to the current node.
1527 * @param l_prev A list that is used as an iterator and points to the previous node.
1528 * @param data Current item's data.
1529 *
1530 * This macro works like EINA_LIST_FOREACH_SAFE, but iterates from the
1531 * last element of a list to the first.
1532 * @p data is the data related to the current element, while @p l
1533 * is an #Eina_List that is used as the list iterator.
1534 *
1535 * Since this macro stores a pointer to the previous list node in @p l_prev,
1536 * deleting the current node and continuing looping is safe.
1537 *
1538 * The following diagram ilustrates this macro iterating over a list of four
1539 * elements("one", "two", "three" and "four"):
1540 * @htmlonly
1541 * <img src="eina-list-reverse-foreach-safe.png" style="max-width: 100%;" />
1542 * <a href="eina-list-reverse-foreach-safe.png">Full-size</a>
1543 * @endhtmlonly
1544 * @image latex eina-list-reverse-foreach-safe.eps width=\textwidth
1545 *
1546 * This macro can be used to free list nodes, as in the following example:
1547 *
1548 * @code
1549 * Eina_List *list;
1550 * Eina_List *l;
1551 * Eina_List *l_prev;
1552 * char *data;
1553 *
1554 * // list is already filled,
1555 * // its elements are just duplicated strings,
1556 * // EINA_LIST_REVERSE_FOREACH_SAFE will be used to free elements that match "key".
1557 *
1558 * EINA_LIST_REVERSE_FOREACH_SAFE(list, l, l_prev, data)
1559 * if (strcmp(data, "key") == 0) {
1560 * free(data);
1561 * list = eina_list_remove_list(list, l);
1562 * }
1563 * @endcode
1564 *
1565 * @warning @p list must be a pointer to the first element of the list.
1566 */
1567#define EINA_LIST_REVERSE_FOREACH_SAFE(list, l, l_prev, data) \
1568 for (l = eina_list_last(list), \
1569 l_prev = eina_list_prev(l), \
1570 data = eina_list_data_get(l); \
1571 l; \
1572 l = l_prev, \
1573 l_prev = eina_list_prev(l), \
1574 data = eina_list_data_get(l))
1575
1576/**
1577 * @def EINA_LIST_FREE
1578 * @brief Macro to remove each list node while having access to each node's data.
1579 *
1580 * @param list The list that will be cleared.
1581 * @param data Current node's data.
1582 *
1583 * This macro will call #eina_list_remove_list for each list node, and store
1584 * the data contained in the current node in @p data.
1585 *
1586 * The following diagram ilustrates this macro iterating over a list of four
1587 * elements("one", "two", "three" and "four"):
1588 * @htmlonly
1589 * <img src="eina-list-free.png" style="max-width: 100%;" />
1590 * <a href="eina-list-free.png">Full-size</a>
1591 * @endhtmlonly
1592 * @image latex eina-list-free.eps width=\textwidth
1593 *
1594 * If you do not need to release node data, it is easier to call #eina_list_free().
1595 *
1596 * @code
1597 * Eina_List *list;
1598 * char *data;
1599 *
1600 * // list is already filled,
1601 * // its elements are just duplicated strings,
1602 *
1603 * EINA_LIST_FREE(list, data)
1604 * free(data);
1605 * @endcode
1606 *
1607 * @warning @p list must be a pointer to the first element of the list.
1608 *
1609 * @see eina_list_free()
1610 */
1611#define EINA_LIST_FREE(list, data) \
1612 for (data = eina_list_data_get(list); \
1613 list; \
1614 list = eina_list_remove_list(list, list), \
1615 data = eina_list_data_get(list))
1616
1617#include "eina_inline_list.x"
1618
1619/**
1620 * @}
1621 */
1622
1623/**
1624 * @}
1625 */
1626
1627/**
1628 * @}
1629 */
1630
1631#endif /* EINA_LIST_H_ */
diff --git a/libraries/eina/src/include/eina_lock.h b/libraries/eina/src/include/eina_lock.h
new file mode 100644
index 0000000..7c26dc0
--- /dev/null
+++ b/libraries/eina/src/include/eina_lock.h
@@ -0,0 +1,125 @@
1/* EINA - EFL data type library
2 * Copyright (C) 2011 Vincent Torri
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library;
16 * if not, see <http://www.gnu.org/licenses/>.
17 */
18
19#ifndef EINA_LOCK_H_
20#define EINA_LOCK_H_
21
22#include "eina_config.h"
23#include "eina_types.h"
24#include "eina_error.h"
25
26/**
27 * @addtogroup Eina_Tools_Group Tools
28 *
29 * @{
30 */
31
32/**
33 * @defgroup Eina_Lock_Group Lock
34 *
35 * @{
36 */
37
38typedef enum
39{
40 EINA_LOCK_FAIL = EINA_FALSE,
41 EINA_LOCK_SUCCEED = EINA_TRUE,
42 EINA_LOCK_DEADLOCK
43} Eina_Lock_Result;
44
45#ifdef EINA_HAVE_THREADS
46# ifdef _WIN32_WCE
47# include "eina_inline_lock_wince.x"
48# elif defined(_WIN32)
49# include "eina_inline_lock_win32.x"
50# else
51# include "eina_inline_lock_posix.x"
52# endif
53#else
54# include "eina_inline_lock_void.x"
55#endif
56
57EAPI extern Eina_Error EINA_ERROR_NOT_MAIN_LOOP;
58
59static inline Eina_Bool eina_lock_new(Eina_Lock *mutex);
60static inline void eina_lock_free(Eina_Lock *mutex);
61static inline Eina_Lock_Result eina_lock_take(Eina_Lock *mutex);
62static inline Eina_Lock_Result eina_lock_take_try(Eina_Lock *mutex);
63static inline Eina_Lock_Result eina_lock_release(Eina_Lock *mutex);
64static inline void eina_lock_debug(const Eina_Lock *mutex);
65
66static inline Eina_Bool eina_condition_new(Eina_Condition *cond, Eina_Lock *mutex);
67static inline void eina_condition_free(Eina_Condition *cond);
68static inline Eina_Bool eina_condition_wait(Eina_Condition *cond);
69static inline Eina_Bool eina_condition_timedwait(Eina_Condition *cond, double t);
70static inline Eina_Bool eina_condition_broadcast(Eina_Condition *cond);
71static inline Eina_Bool eina_condition_signal(Eina_Condition *cond);
72
73static inline Eina_Bool eina_rwlock_new(Eina_RWLock *mutex);
74static inline void eina_rwlock_free(Eina_RWLock *mutex);
75static inline Eina_Lock_Result eina_rwlock_take_read(Eina_RWLock *mutex);
76static inline Eina_Lock_Result eina_rwlock_take_write(Eina_RWLock *mutex);
77static inline Eina_Lock_Result eina_rwlock_release(Eina_RWLock *mutex);
78
79static inline Eina_Bool eina_tls_new(Eina_TLS *key);
80static inline void eina_tls_free(Eina_TLS key);
81static inline void *eina_tls_get(Eina_TLS key);
82static inline Eina_Bool eina_tls_set(Eina_TLS key, const void *data);
83
84
85#ifdef EINA_HAVE_DEBUG_THREADS
86# define EINA_MAIN_LOOP_CHECK_RETURN_VAL(val) \
87 do { \
88 if (EINA_UNLIKELY(!eina_main_loop_is())) \
89 { \
90 eina_error_set(EINA_ERROR_NOT_MAIN_LOOP); \
91 EINA_LOG_ERR("You are calling %s from outside" \
92 "of the main loop threads in %s at line %i", \
93 __FUNCTION__, \
94 __FILE__, \
95 __LINE__); \
96 return val; \
97 } \
98 } while (0)
99# define EINA_MAIN_LOOP_CHECK_RETURN \
100 do { \
101 if (EINA_UNLIKELY(!eina_main_loop_is())) \
102 { \
103 eina_error_set(EINA_ERROR_NOT_MAIN_LOOP); \
104 EINA_LOG_ERR("You are calling %s from outside" \
105 "of the main loop threads in %s at line %i", \
106 __FUNCTION__, \
107 __FILE__, \
108 __LINE__); \
109 return ; \
110 } \
111 } while (0)
112#else
113# define EINA_MAIN_LOOP_CHECK_RETURN_VAL(val)
114# define EINA_MAIN_LOOP_CHECK_RETURN
115#endif
116
117/**
118 * @}
119 */
120
121/**
122 * @}
123 */
124
125#endif
diff --git a/libraries/eina/src/include/eina_log.h b/libraries/eina/src/include/eina_log.h
new file mode 100644
index 0000000..5cd7c59
--- /dev/null
+++ b/libraries/eina/src/include/eina_log.h
@@ -0,0 +1,888 @@
1/* EINA - EFL data type library
2 * Copyright (C) 2007-2008 Jorge Luis Zapata Muga, Cedric Bail
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library;
16 * if not, see <http://www.gnu.org/licenses/>.
17 */
18
19#ifndef EINA_LOG_H_
20#define EINA_LOG_H_
21
22#include <stdlib.h>
23#include <stdarg.h>
24
25#include "eina_types.h"
26
27#define EINA_COLOR_LIGHTRED "\033[31;1m"
28#define EINA_COLOR_RED "\033[31m"
29#define EINA_COLOR_LIGHTBLUE "\033[34;1m"
30#define EINA_COLOR_BLUE "\033[34m"
31#define EINA_COLOR_GREEN "\033[32;1m"
32#define EINA_COLOR_YELLOW "\033[33;1m"
33#define EINA_COLOR_ORANGE "\033[0;33m"
34#define EINA_COLOR_WHITE "\033[37;1m"
35#define EINA_COLOR_LIGHTCYAN "\033[36;1m"
36#define EINA_COLOR_CYAN "\033[36m"
37#define EINA_COLOR_RESET "\033[0m"
38#define EINA_COLOR_HIGH "\033[1m"
39
40
41/**
42 * @page tutorial_log_page Log Tutorial
43 *
44 * @section tutorial_log_introduction Introduction
45 *
46 * The Eina Log module provides logging facilities for libraries and
47 * applications. It provides colored logging, basic logging levels (error,
48 * warning, debug, info, critical) and loggers - called logging domains -
49 * which will be covered on next sections.
50 *
51 * @section tutorial_log_basic_usage Basic Usage
52 *
53 * Log messages can be displayed using the following macros:
54 *
55 * @li EINA_LOG_ERR(),
56 * @li EINA_LOG_INFO(),
57 * @li EINA_LOG_WARN(),
58 * @li EINA_LOG_DBG().
59 *
60 * Here is an example:
61 *
62 * @include eina_log_02.c
63 *
64 * If you compiled Eina without debug mode, execution will yield only one log
65 * message, which is "argument is negative".
66 *
67 * Here we introduce the concept of logging domains (or loggers), which might
68 * already be familiar to readers. It is basically a way to separate a set of
69 * log messages into a context (e.g. a module) and provide a way of controlling
70 * this set as a whole.
71 *
72 * For example, suppose you have 3 different modules on your application and you
73 * want to get logging only from one of them (e.g. create some sort of filter).
74 * For achieving that, all you need to do is create a logging domain for each
75 * module so that all logging inside a module can be considered as a whole.
76 *
77 * Logging domains are specified by a name, color applied to the name and the
78 * level. The first two (name and color) are set through code, that is, inside
79 * your application/module/library.
80 *
81 * The level is used for controlling which messages should appear. It
82 * specifies the lowest level that should be displayed (e.g. a message
83 * with level 11 being logged on a domain with level set to 10 would be
84 * displayed, while a message with level 9 wouldn't).
85 *
86 * The domain level is set during runtime (in contrast with the name and
87 * color) through the environment variable EINA_LOG_LEVELS. This variable
88 * expects a list in the form domain_name1:level1,domain_name2:level2,... . For
89 * example:
90 *
91 * @verbatim EINA_LOG_LEVELS=mymodule1:5,mymodule2:2,mymodule3:0 ./myapp@endverbatim
92 *
93 * This line would set mymodule1 level to 5, mymodule2 level to 2 and mymodule3
94 * level to 0.
95 *
96 * There's also a global logger to which EINA_LOG_(ERR, DBG, INFO, CRIT, WARN)
97 * macros do log on. It is a logger that is created internally by Eina Log with
98 * an empty name and can be used for general logging (where logging domains do
99 * not apply).
100 *
101 * Since this global logger doesn't have a name, you can't set its level through
102 * EINA_LOG_LEVELS variable. Here we introduce a second environment variable
103 * that is a bit more special: EINA_LOG_LEVEL.
104 *
105 * This variable specifies the level of the global logging domain and the level
106 * of domains that haven't been set through EINA_LOG_LEVELS. Here's an example:
107 *
108 * @verbatim EINA_LOG_LEVEL=3 EINA_LOG_LEVELS=module1:10,module3:2 ./myapp@endverbatim
109 *
110 * Supposing you have modules named "module1", "module2" and "module3", this
111 * line would result in module1 with level 10, module2 with level 3 and module3
112 * with level 2. Note that module2's level wasn't specified, so it's level is
113 * set to the global level. This way we can easily apply filters to multiple
114 * domains with only one parameter (EINA_LOG_LEVEL=num).
115 *
116 * The global level (EINA_LOG_LEVEL) can also be set through code, using
117 * eina_log_level_set() function.
118 *
119 * While developing your libraries or applications, you may notice that
120 * EINA_LOG_DOM_(ERR, DBG, INFO, CRIT, WARN) macros also print out
121 * messages from eina itself. Here we introduce another environment variable
122 * that is a bit more special: EINA_LOG_LEVELS_GLOB.
123 *
124 * This variable allows you to disable the logging of any/all code in eina itself.
125 * This is useful when developing your libraries or applications so that you can
126 * see your own domain's messages easier without having to sift through a lot of
127 * internal eina debug messages. Here's an example:
128 *
129 * @verbatim EINA_LOG_LEVEL=3 EINA_LOG_LEVELS_GLOB=eina_*:0 ./myapp@endverbatim
130 *
131 * This will disable eina_log output from all internal eina code thus allowing
132 * you to see your own domain messages easier.
133 *
134 * @section tutorial_log_advanced_display Advanced usage of print callbacks
135 *
136 * The log module allows the user to change the way
137 * eina_log_print() displays the messages. It suffices to pass to
138 * eina_log_print_cb_set() the function used to display the
139 * message. That function must be of type #Eina_Log_Print_Cb. As a
140 * custom data can be passed to that callback, powerful display
141 * messages can be displayed.
142 *
143 * It is suggested to not use __FILE__, __FUNCTION__ or __LINE__ when
144 * writing that callback, but when defining macros (like
145 * EINA_LOG_ERR() and other macros).
146 *
147 * Here is an example of custom callback, whose behavior can be
148 * changed at runtime:
149 *
150 * @include eina_log_03.c
151 * @example eina_log_02.c
152 * @example eina_log_03.c
153 */
154
155/**
156 * @addtogroup Eina_Log_Group Log
157 *
158 * @brief Full-featured logging system.
159 *
160 * Eina provides eina_log_print(), a standard function to manage all
161 * logging messages. This function may be called directly or using the
162 * helper macros such as EINA_LOG_DBG(), EINA_LOG_ERR() or those that
163 * take a specific domain as argument EINA_LOG_DOM_DBG(),
164 * EINA_LOG_DOM_ERR(). Internally, eina_log_print() will call the
165 * function defined with eina_log_print_cb_set(), that defaults to
166 * eina_log_print_cb_stderr(), but may be changed to do whatever you
167 * need, such as networking or syslog logging.
168 *
169 * The logging system is thread safe once initialized with
170 * eina_log_threads_enable(). The thread that calls this function
171 * first is considered "main thread" and other threads will have their
172 * thread id (pthread_self()) printed in the log message so it is easy
173 * to detect from where it is coming.
174 *
175 * Log domains is the Eina way to differentiate messages. There might
176 * be different domains to represent different modules, different
177 * feature-set, different categories and so on. Filtering can be
178 * applied to domain names by means of @c EINA_LOG_LEVELS environment
179 * variable or eina_log_domain_level_set().
180 *
181 * The different logging levels serve to customize the amount of
182 * debugging one want to take and may be used to automatically call
183 * abort() once some given level message is printed. This is
184 * controlled by environment variable @c EINA_LOG_ABORT and the level
185 * to be considered critical with @c EINA_LOG_ABORT_LEVEL. These can
186 * be changed with eina_log_abort_on_critical_set() and
187 * eina_log_abort_on_critical_level_set().
188 *
189 * The default maximum level to print is defined by environment
190 * variable @c EINA_LOG_LEVEL, but may be set per-domain with @c
191 * EINA_LOG_LEVELS. It will default to #EINA_LOG_ERR. This can be
192 * changed with eina_log_level_set().
193 *
194 * To use the log system Eina must be initialized with eina_init() and
195 * later shut down with eina_shutdown(). Here is a straightforward
196 * example:
197 *
198 * @include eina_log_01.c
199 *
200 * Compile this code with the following command:
201 *
202 * @verbatim gcc -Wall -o eina_log_01 eina_log_01.c `pkg-config --cflags --libs eina`@endverbatim
203 *
204 * Now execute the program with:
205 *
206 * @verbatim EINA_LOG_LEVEL=2 ./eina_log_01@endverbatim
207 *
208 * You should see a message displayed in the terminal.
209 *
210 * For more information, you can look at the @ref tutorial_log_page.
211 *
212 * @example eina_log_01.c
213 */
214
215/**
216 * @addtogroup Eina_Tools_Group Tools
217 *
218 * @{
219 */
220
221/**
222 * @defgroup Eina_Log_Group Log
223 *
224 * @{
225 */
226
227/**
228 * EINA_LOG_DOMAIN_GLOBAL is the general purpose log domain to be
229 * used, it is always registered and available everywhere.
230 */
231EAPI extern int EINA_LOG_DOMAIN_GLOBAL;
232
233#ifndef EINA_LOG_DOMAIN_DEFAULT
234
235/**
236 * @def EINA_LOG_DOMAIN_DEFAULT
237 * This macro defines the domain to use with the macros EINA_LOG_DOM_DBG(),
238 * EINA_LOG_DOM_INFO(), EINA_LOG_DOM_WARN(), EINA_LOG_DOM_ERR() and
239 * EINA_LOG_DOM_CRIT().
240 *
241 * If not defined prior to the inclusion of this header, then it
242 * defaults to #EINA_LOG_DOMAIN_GLOBAL.
243 *
244 * @note One may like to redefine this in its code to avoid typing too
245 * much. In this case the recommended way is:
246 *
247 * @code
248 * #include <Eina.h>
249 * #undef EINA_LOG_DOMAIN_DEFAULT
250 * #define EINA_LOG_DOMAIN_DEFAULT _log_dom
251 * static int _log_dom = -1;
252 *
253 * int main(void)
254 * {
255 * eina_init();
256 * _log_dom = eina_log_domain_register("mydom", EINA_COLOR_CYAN);
257 * EINA_LOG_ERR("using my own domain");
258 * return 0;
259 * }
260 * @endcode
261 *
262 * @warning If one defines the domain prior to inclusion of this
263 * header, the defined log domain symbol must be defined
264 * prior as well, otherwise the inlined functions defined by
265 * Eina will fail to find the symbol, causing build failure.
266 *
267 * @code
268 * #define EINA_LOG_DOMAIN_DEFAULT _log_dom
269 * static int _log_dom = -1; // must come before inclusion of Eina.h!
270 * #include <Eina.h>
271 *
272 * int main(void)
273 * {
274 * eina_init();
275 * _log_dom = eina_log_domain_register("mydom", EINA_COLOR_CYAN);
276 * EINA_LOG_ERR("using my own domain");
277 * return 0;
278 * }
279 * @endcode
280 *
281 */
282# define EINA_LOG_DOMAIN_DEFAULT EINA_LOG_DOMAIN_GLOBAL
283
284#endif /* EINA_LOG_DOMAIN_DEFAULT */
285
286/**
287 * @def EINA_LOG(DOM, LEVEL, fmt, ...)
288 * Logs a message on the specified domain, level and format.
289 *
290 * @note if @c EINA_LOG_LEVEL_MAXIMUM is defined, then messages larger
291 * than this value will be ignored regardless of current domain
292 * level, the eina_log_print() is not even called! Most
293 * compilers will just detect the two integers make the branch
294 * impossible and remove the branch and function call all
295 * together. Take this as optimization tip and possible remove
296 * debug messages from binaries to be deployed, saving on hot
297 * paths. Never define @c EINA_LOG_LEVEL_MAXIMUM on public
298 * header files.
299 */
300#ifdef EINA_LOG_LEVEL_MAXIMUM
301#define EINA_LOG(DOM, LEVEL, fmt, ...) \
302 do { \
303 if (LEVEL <= EINA_LOG_LEVEL_MAXIMUM) { \
304 eina_log_print(DOM, LEVEL, __FILE__, __FUNCTION__, __LINE__, \
305 fmt, ## __VA_ARGS__); } \
306 } while (0)
307#else
308#define EINA_LOG(DOM, LEVEL, fmt, ...) \
309 eina_log_print(DOM, \
310 LEVEL, \
311 __FILE__, \
312 __FUNCTION__, \
313 __LINE__, \
314 fmt, \
315 ## __VA_ARGS__)
316#endif
317
318/**
319 * @def EINA_LOG_DOM_CRIT(DOM, fmt, ...)
320 * Logs a message with level CRITICAL on the specified domain and format.
321 */
322#define EINA_LOG_DOM_CRIT(DOM, fmt, ...) \
323 EINA_LOG(DOM, EINA_LOG_LEVEL_CRITICAL, fmt, ## __VA_ARGS__)
324
325/**
326 * @def EINA_LOG_DOM_ERR(DOM, fmt, ...)
327 * Logs a message with level ERROR on the specified domain and format.
328 */
329#define EINA_LOG_DOM_ERR(DOM, fmt, ...) \
330 EINA_LOG(DOM, EINA_LOG_LEVEL_ERR, fmt, ## __VA_ARGS__)
331
332/**
333 * @def EINA_LOG_DOM_INFO(DOM, fmt, ...)
334 * Logs a message with level INFO on the specified domain and format.
335 */
336#define EINA_LOG_DOM_INFO(DOM, fmt, ...) \
337 EINA_LOG(DOM, EINA_LOG_LEVEL_INFO, fmt, ## __VA_ARGS__)
338
339/**
340 * @def EINA_LOG_DOM_DBG(DOM, fmt, ...)
341 * Logs a message with level DEBUG on the specified domain and format.
342 */
343#define EINA_LOG_DOM_DBG(DOM, fmt, ...) \
344 EINA_LOG(DOM, EINA_LOG_LEVEL_DBG, fmt, ## __VA_ARGS__)
345
346/**
347 * @def EINA_LOG_DOM_WARN(DOM, fmt, ...)
348 * Logs a message with level WARN on the specified domain and format.
349 */
350#define EINA_LOG_DOM_WARN(DOM, fmt, ...) \
351 EINA_LOG(DOM, EINA_LOG_LEVEL_WARN, fmt, ## __VA_ARGS__)
352
353/**
354 * @def EINA_LOG_CRIT(fmt, ...)
355 * Logs a message with level CRITICAL on the default domain with the specified
356 * format.
357 */
358#define EINA_LOG_CRIT(fmt, ...) \
359 EINA_LOG(EINA_LOG_DOMAIN_DEFAULT, \
360 EINA_LOG_LEVEL_CRITICAL, \
361 fmt, \
362 ## __VA_ARGS__)
363
364/**
365 * @def EINA_LOG_ERR(fmt, ...)
366 * Logs a message with level ERROR on the default domain with the specified
367 * format.
368 */
369#define EINA_LOG_ERR(fmt, ...) \
370 EINA_LOG(EINA_LOG_DOMAIN_DEFAULT, EINA_LOG_LEVEL_ERR, fmt, ## __VA_ARGS__)
371
372/**
373 * @def EINA_LOG_INFO(fmt, ...)
374 * Logs a message with level INFO on the default domain with the specified
375 * format.
376 */
377#define EINA_LOG_INFO(fmt, ...) \
378 EINA_LOG(EINA_LOG_DOMAIN_DEFAULT, EINA_LOG_LEVEL_INFO, fmt, ## __VA_ARGS__)
379
380/**
381 * @def EINA_LOG_WARN(fmt, ...)
382 * Logs a message with level WARN on the default domain with the specified
383 * format.
384 */
385#define EINA_LOG_WARN(fmt, ...) \
386 EINA_LOG(EINA_LOG_DOMAIN_DEFAULT, EINA_LOG_LEVEL_WARN, fmt, ## __VA_ARGS__)
387
388/**
389 * @def EINA_LOG_DBG(fmt, ...)
390 * Logs a message with level DEBUG on the default domain with the specified
391 * format.
392 */
393#define EINA_LOG_DBG(fmt, ...) \
394 EINA_LOG(EINA_LOG_DOMAIN_DEFAULT, EINA_LOG_LEVEL_DBG, fmt, ## __VA_ARGS__)
395
396/**
397 * @typedef Eina_Log_Domain
398 * The domain used for logging.
399 */
400typedef struct _Eina_Log_Domain Eina_Log_Domain;
401
402/**
403 * @struct _Eina_Log_Domain
404 * The domain used for logging.
405 */
406struct _Eina_Log_Domain
407{
408 int level; /**< Max level to log */
409 const char *domain_str; /**< Formatted string with color to print */
410 const char *name; /**< Domain name */
411 size_t namelen; /**< strlen(name) */
412
413 /* Private */
414 Eina_Bool deleted : 1; /**< Flags deletion of domain, a free slot */
415};
416
417/**
418 * Enable logging module to handle threads.
419 *
420 * There is no disable option on purpose, if it is enabled, there is
421 * no way back until you call the last eina_shutdown().
422 *
423 * There is no function to retrieve if threads are enabled as one is
424 * not supposed to know this from outside.
425 *
426 * After this call is executed at least once, if Eina was compiled
427 * with threads support then logging will lock around debug messages
428 * and threads that are not the main thread will have its identifier
429 * printed.
430 *
431 * The main thread is considered the thread where the first
432 * eina_init() was called.
433 */
434EAPI void eina_log_threads_enable(void);
435
436/**
437 * @enum _Eina_Log_Level
438 * List of available logging levels.
439 */
440typedef enum _Eina_Log_Level
441{
442 EINA_LOG_LEVEL_CRITICAL, /**< Critical log level */
443 EINA_LOG_LEVEL_ERR, /**< Error log level */
444 EINA_LOG_LEVEL_WARN, /**< Warning log level */
445 EINA_LOG_LEVEL_INFO, /**< Information log level */
446 EINA_LOG_LEVEL_DBG, /**< Debug log level */
447 EINA_LOG_LEVELS, /**< Count of default log levels */
448 EINA_LOG_LEVEL_UNKNOWN = (-2147483647 - 1) /**< Unknown level */
449} Eina_Log_Level;
450
451/**
452 * @typedef Eina_Log_Print_Cb
453 * Type for print callbacks.
454 */
455typedef void (*Eina_Log_Print_Cb)(const Eina_Log_Domain *d,
456 Eina_Log_Level level,
457 const char *file, const char *fnc, int line,
458 const char *fmt, void *data, va_list args);
459
460/*
461 * Customization
462 */
463
464/**
465 * Sets logging method to use.
466 *
467 * @param cb The callback to call when printing a log.
468 * @param data The data to pass to the callback.
469 *
470 * By default, eina_log_print_cb_stderr() is used.
471 *
472 * @note MT: safe to call from any thread.
473 *
474 * @note MT: given function @a cb will be called protected by mutex.
475 * This means you're safe from other calls but you should never
476 * call eina_log_print(), directly or indirectly.
477 */
478EAPI void eina_log_print_cb_set(Eina_Log_Print_Cb cb, void *data) EINA_ARG_NONNULL(1);
479
480
481/**
482 * @brief Set the default log level.
483 *
484 * @param level The log level.
485 *
486 * This function sets the log level @p level. It is used in
487 * eina_log_print().
488 *
489 * @note this is initially set to envvar EINA_LOG_LEVEL by eina_init().
490 *
491 * @see eina_log_level_get()
492 */
493EAPI void eina_log_level_set(int level);
494
495/**
496 * @brief Get the default log level.
497 *
498 * @return the log level that limits eina_log_print().
499 *
500 * @see eina_log_level_set()
501 */
502EAPI int eina_log_level_get(void) EINA_WARN_UNUSED_RESULT;
503
504static inline Eina_Bool eina_log_level_check(int level);
505
506/**
507 * Checks if current thread is the main thread.
508 *
509 * @return #EINA_TRUE if threads were enabled and the current thread
510 * is the one that called eina_log_threads_init(). If there is
511 * no thread support (compiled with --disable-pthreads) or
512 * they were not enabled, then #EINA_TRUE is also
513 * returned. The only case where #EINA_FALSE is returned is
514 * when threads were successfully enabled but the current
515 * thread is not the main (one that called
516 * eina_log_threads_init()).
517 */
518EAPI Eina_Bool eina_log_main_thread_check(void) EINA_CONST EINA_WARN_UNUSED_RESULT;
519
520
521/**
522 * @brief Set if color logging should be disabled.
523 *
524 * @param disabled if #EINA_TRUE, color logging should be disabled.
525 *
526 * @note this is initially set to envvar EINA_LOG_COLOR_DISABLE by eina_init().
527 *
528 * @see eina_log_color_disable_get()
529 */
530EAPI void eina_log_color_disable_set(Eina_Bool disabled);
531
532/**
533 * @brief Get if color logging should be disabled.
534 *
535 * @return if #EINA_TRUE, color logging should be disabled.
536 *
537 * @see eina_log_color_disable_set()
538 */
539EAPI Eina_Bool eina_log_color_disable_get(void) EINA_WARN_UNUSED_RESULT;
540
541/**
542 * @brief Set if originating file name logging should be disabled.
543 *
544 * @param disabled if #EINA_TRUE, file name logging should be disabled.
545 *
546 * @note this is initially set to envvar EINA_LOG_FILE_DISABLE by eina_init().
547 *
548 * @see eina_log_file_disable_get()
549 */
550EAPI void eina_log_file_disable_set(Eina_Bool disabled);
551
552/**
553 * @brief Get if originating file name logging should be disabled.
554 *
555 * @return if #EINA_TRUE, file name logging should be disabled.
556 *
557 * @see eina_log_file_disable_set()
558 */
559EAPI Eina_Bool eina_log_file_disable_get(void) EINA_WARN_UNUSED_RESULT;
560
561/**
562 * @brief Set if originating function name logging should be disabled.
563 *
564 * @param disabled if #EINA_TRUE, function name logging should be disabled.
565 *
566 * @note this is initially set to envvar EINA_LOG_FUNCTION_DISABLE by
567 * eina_init().
568 *
569 * @see eina_log_function_disable_get()
570 */
571EAPI void eina_log_function_disable_set(Eina_Bool disabled);
572
573/**
574 * @brief Get if originating function name logging should be disabled.
575 *
576 * @return if #EINA_TRUE, function name logging should be disabled.
577 *
578 * @see eina_log_function_disable_set()
579 */
580EAPI Eina_Bool eina_log_function_disable_get(void) EINA_WARN_UNUSED_RESULT;
581
582/**
583 * @brief Set if critical messages should abort the program.
584 *
585 * @param abort_on_critical if #EINA_TRUE, messages with level equal
586 * or smaller than eina_log_abort_on_critical_level_get() will
587 * abort the program.
588 *
589 * @note this is initially set to envvar EINA_LOG_ABORT by
590 * eina_init().
591 *
592 * @see eina_log_abort_on_critical_get()
593 * @see eina_log_abort_on_critical_level_set()
594 */
595EAPI void eina_log_abort_on_critical_set(Eina_Bool abort_on_critical);
596
597/**
598 * @brief Get if critical messages should abort the program.
599 *
600 * @return if #EINA_TRUE, any messages with level equal or smaller
601 * than eina_log_abort_on_critical_level_get() will abort the
602 * program.
603 *
604 * @see eina_log_abort_on_critical_set()
605 * @see eina_log_abort_on_critical_level_set()
606 */
607EAPI Eina_Bool eina_log_abort_on_critical_get(void) EINA_WARN_UNUSED_RESULT;
608
609/**
610 * @brief Set level that triggers abort if abort-on-critical is set.
611 *
612 * @param critical_level levels equal or smaller than the given value
613 * will trigger program abortion if
614 * eina_log_abort_on_critical_get() returns #EINA_TRUE.
615 *
616 * @note this is initially set to envvar EINA_LOG_ABORT_LEVEL by
617 * eina_init().
618 *
619 * @see eina_log_abort_on_critical_level_get()
620 * @see eina_log_abort_on_critical_get()
621 */
622EAPI void eina_log_abort_on_critical_level_set(int critical_level);
623
624/**
625 * @brief Get level that triggers abort if abort-on-critical is set.
626 *
627 * @return critical level equal or smaller than value will trigger
628 * program abortion if eina_log_abort_on_critical_get() returns
629 * #EINA_TRUE.
630 *
631 * @see eina_log_abort_on_critical_level_set()
632 * @see eina_log_abort_on_critical_get()
633 */
634EAPI int eina_log_abort_on_critical_level_get(void) EINA_WARN_UNUSED_RESULT;
635
636
637/**
638 * Set the domain level given its name.
639 *
640 * This call has the same effect as setting
641 * EINA_LOG_LEVELS=&lt;@p domain_name&gt;:&lt;@p level&gt;
642 *
643 * @param domain_name domain name to change the level. It may be of a
644 * still not registered domain. If the domain is not registered
645 * yet, it will be saved as a pending set and applied upon
646 * registration.
647 * @param level level to use to limit eina_log_print() for given domain.
648 */
649EAPI void eina_log_domain_level_set(const char *domain_name, int level) EINA_ARG_NONNULL(1);
650
651/**
652 * Get the domain level given its name.
653 *
654 * @param domain_name domain name to retrieve the level. It may be of
655 * a still not registered domain. If the domain is not
656 * registered yet, but there is a pending value, either from
657 * eina_log_domain_level_set(),EINA_LOG_LEVELS environment
658 * variable or from EINA_LOG_LEVELS_GLOB, these are
659 * returned. If nothing else was found, then the global/default
660 * level (eina_log_level_get()) is returned.
661 *
662 * @return level to use to limit eina_log_print() for given
663 * domain. On error (@p domain_name == NULL),
664 * EINA_LOG_LEVEL_UNKNOWN is returned.
665 *
666 * @see eina_log_domain_level_set()
667 * @see eina_log_domain_registered_level_get()
668 */
669EAPI int eina_log_domain_level_get(const char *domain_name) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1);
670
671/**
672 * Get the domain level given its identifier.
673 *
674 * @param domain identifier, so it must be previously registered with
675 * eina_log_domain_register(). It's a much faster version of
676 * eina_log_domain_level_get(), but relies on domain being
677 * present.
678 *
679 * @return level to use to limit eina_log_print() for given domain. On
680 * error EINA_LOG_LEVEL_UNKNOWN is returned.
681 */
682EAPI int eina_log_domain_registered_level_get(int domain) EINA_WARN_UNUSED_RESULT;
683
684static inline Eina_Bool eina_log_domain_level_check(int domain, int level);
685
686/*
687 * Logging domains
688 */
689
690/**
691 * @param name Domain name
692 * @param color Color of the domain name
693 *
694 * @return Domain index that will be used as the DOMAIN parameter on log
695 * macros. A negative return value means an log occurred.
696 *
697 * @note MT: safe to call from any thread.
698 */
699EAPI int eina_log_domain_register(const char *name, const char *color) EINA_ARG_NONNULL(1);
700
701/**
702 * Forget about a logging domain registered by eina_log_domain_register()
703 *
704 * @param domain domain identifier as reported by eina_log_domain_register(),
705 * must be >= 0.
706 *
707 * @note MT: safe to call from any thread.
708 */
709EAPI void eina_log_domain_unregister(int domain);
710
711/*
712 * Logging functions.
713 */
714
715/**
716 * Print out log message using given domain and level.
717 *
718 * @note Usually you'll not use this function directly but the helper
719 * macros EINA_LOG(), EINA_LOG_DOM_CRIT(), EINA_LOG_CRIT() and
720 * so on. See eina_log.h
721 *
722 * @param domain logging domain to use or @c EINA_LOG_DOMAIN_GLOBAL if
723 * you registered none. It is recommended that modules and
724 * applications have their own logging domain.
725 * @param level message level, those with level greater than user
726 * specified value (eina_log_level_set() or environment
727 * variables EINA_LOG_LEVEL, EINA_LOG_LEVELS) will be ignored.
728 * @param file filename that originated the call, must @b not be @c NULL.
729 * @param fnc function that originated the call, must @b not be @c NULL.
730 * @param line originating line in @a file.
731 * @param fmt printf-like format to use. Should not provide trailing
732 * '\n' as it is automatically included.
733 *
734 * @note MT: this function may be called from different threads if
735 * eina_log_threads_enable() was called before.
736 */
737EAPI void eina_log_print(int domain,
738 Eina_Log_Level level,
739 const char *file,
740 const char *function,
741 int line,
742 const char *fmt,
743 ...) EINA_ARG_NONNULL(3, 4, 6) EINA_PRINTF(6, 7) EINA_NOINSTRUMENT;
744
745/**
746 * Print out log message using given domain and level.
747 *
748 * @note Usually you'll not use this function directly but the helper
749 * macros EINA_LOG(), EINA_LOG_DOM_CRIT(), EINA_LOG_CRIT() and
750 * so on. See eina_log.h
751 *
752 * @param domain logging domain to use or @c EINA_LOG_DOMAIN_GLOBAL if
753 * you registered none. It is recommended that modules and
754 * applications have their own logging domain.
755 * @param level message level, those with level greater than user
756 * specified value (eina_log_level_set() or environment
757 * variables EINA_LOG_LEVEL, EINA_LOG_LEVELS) will be ignored.
758 * @param file filename that originated the call, must @b not be @c NULL.
759 * @param fnc function that originated the call, must @b not be @c NULL.
760 * @param line originating line in @a file.
761 * @param fmt printf-like format to use. Should not provide trailing
762 * '\n' as it is automatically included.
763 * @param args the arguments needed by the format.
764 *
765 * @note MT: this function may be called from different threads if
766 * eina_log_threads_enable() was called before.
767 *
768 * @see eina_log_print()
769 */
770EAPI void eina_log_vprint(int domain,
771 Eina_Log_Level level,
772 const char *file,
773 const char *fnc,
774 int line,
775 const char *fmt,
776 va_list args) EINA_ARG_NONNULL(3, 4, 6) EINA_NOINSTRUMENT;
777
778/*
779 * Logging methods (change how logging is done).
780 */
781
782/**
783 * Alternative logging method, this will output to standard output stream.
784 *
785 * @param d The domain.
786 * @param level The level.
787 * @param file The file which is logged.
788 * @param fnc The function which is logged.
789 * @param line The line which is logged.
790 * @param fmt The ouptut format to use.
791 * @param data Not used.
792 * @param args The arguments needed by the format.
793 *
794 * This method will colorize output based on domain provided color and
795 * message logging level. To disable color, set environment variable
796 * EINA_LOG_COLOR_DISABLE=1. Similarly, to disable file and line
797 * information, set EINA_LOG_FILE_DISABLE=1 or
798 * EINA_LOG_FUNCTION_DISABLE=1 to avoid function name in output. It is
799 * not acceptable to have both EINA_LOG_FILE_DISABLE and
800 * EINA_LOG_FUNCTION_DISABLE at the same time, in this case just
801 * EINA_LOG_FUNCTION_DISABLE will be considered and file information
802 * will be printed anyways.
803 *
804 * @note MT: if threads are enabled, this function is called within locks.
805 * @note MT: Threads different from main thread will have thread id
806 * appended to domain name.
807 */
808EAPI void eina_log_print_cb_stdout(const Eina_Log_Domain *d,
809 Eina_Log_Level level,
810 const char *file,
811 const char *fnc,
812 int line,
813 const char *fmt,
814 void *data,
815 va_list args);
816
817/**
818 * Default logging method, this will output to standard error stream.
819 *
820 * This method will colorize output based on domain provided color and
821 * message logging level.
822 *
823 * To disable color, set environment variable
824 * EINA_LOG_COLOR_DISABLE=1. To enable color, even if directing to a
825 * file or when using a non-supported color terminal, use
826 * EINA_LOG_COLOR_DISABLE=0. If EINA_LOG_COLOR_DISABLE is unset (or
827 * -1), then Eina will disable color if terminal ($TERM) is
828 * unsupported or if redirecting to a file.
829
830 . Similarly, to disable file and line
831 * information, set EINA_LOG_FILE_DISABLE=1 or
832 * EINA_LOG_FUNCTION_DISABLE=1 to avoid function name in output. It is
833 * not acceptable to have both EINA_LOG_FILE_DISABLE and
834 * EINA_LOG_FUNCTION_DISABLE at the same time, in this case just
835 * EINA_LOG_FUNCTION_DISABLE will be considered and file information
836 * will be printed anyways.
837 *
838 * @note MT: if threads are enabled, this function is called within locks.
839 * @note MT: Threads different from main thread will have thread id
840 * appended to domain name.
841 */
842EAPI void eina_log_print_cb_stderr(const Eina_Log_Domain *d,
843 Eina_Log_Level level,
844 const char *file,
845 const char *fnc,
846 int line,
847 const char *fmt,
848 void *data,
849 va_list args);
850
851/**
852 * Alternative logging method, this will output to given file stream.
853 *
854 * @param d The domain.
855 * @param level Not used.
856 * @param file The file which is logged.
857 * @param fnc The function which is logged.
858 * @param line The line which is logged.
859 * @param fmt The ouptut format to use.
860 * @param data The file which will store the output (as a FILE *).
861 * @param args The arguments needed by the format.
862 *
863 * This method will never output color.
864 *
865 * @note MT: if threads are enabled, this function is called within locks.
866 * @note MT: Threads different from main thread will have thread id
867 * appended to domain name.
868 */
869EAPI void eina_log_print_cb_file(const Eina_Log_Domain *d,
870 Eina_Log_Level level,
871 const char *file,
872 const char *fnc,
873 int line,
874 const char *fmt,
875 void *data,
876 va_list args);
877
878#include "eina_inline_log.x"
879
880/**
881 * @}
882 */
883
884/**
885 * @}
886 */
887
888#endif /* EINA_LOG_H_ */
diff --git a/libraries/eina/src/include/eina_magic.h b/libraries/eina/src/include/eina_magic.h
new file mode 100644
index 0000000..44cd4e9
--- /dev/null
+++ b/libraries/eina/src/include/eina_magic.h
@@ -0,0 +1,322 @@
1/* EINA - EFL data type library
2 * Copyright (C) 2008 Cedric Bail
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library;
16 * if not, see <http://www.gnu.org/licenses/>.
17 */
18
19#ifndef EINA_MAGIC_H_
20#define EINA_MAGIC_H_
21
22#include "eina_config.h"
23#include "eina_types.h"
24
25/**
26 * @page eina_magic_example_01_page
27 * @dontinclude eina_magic_01.c
28 *
29 * Whenever using Eina we must include it:
30 * @skipline #include
31 *
32 * For this example we are going to define two classes, person and pilot, and
33 * since every pilot is a person we use inheritance. To be type safe we are
34 * going to add EINA_MAGIC to our classes:
35 * @until struct _pilot pilot
36 * @note The values of BASETYPE_MAGIC and SUBTYPE_MAGIC have no meaning, the
37 * only important thing about them is that they be unique.
38 *
39 * Here we have a function to create a perso given a name, nothing too fancy:
40 * @until }
41 *
42 * And now the counterpart, a function the free a person.
43 * @until {
44 * Before we start releasing resources we check that the pointer we were given
45 * actually points to a person, and if not we will print an error message and
46 * quit:
47 * @until }
48 * @note EINA_MAGIC_FAIL is a macro that make's it easy to print an appropriate
49 * (and consistent) error message.
50 * Now knowing that ptr is indeed of type person we prooced to set EINA_MAGIC to
51 * EINA_MAGIC_NONE and free alocated memory:
52 * @until }
53 * @note Setting EINA_MAGIC to EINA_MAGIC_NONE is important to prevent the
54 * struct from being used after freed.
55 *
56 * Now we have our function to create a pilot, this one is a little more complex
57 * because we need to set EINA_MAGIC for the pilot and pilot->base, this is very
58 * important so that checking the EINA_MAGIC of (person*)my_pilot will work:
59 * @until }
60 *
61 * The function to free a pilot is not too different from the one that frees a
62 * person:
63 * @until }
64 * @until }
65 *
66 * We also create functions to print a person or a pilot that check the type of
67 * the pointers they receive:
68 * @until }
69 * @until }
70 *
71 * And on to our main function where we declare some variables and initialize
72 * Eina:
73 * @until eina_init
74 *
75 * For Eina to be able to provide more informative error messages we are going
76 * to give names to our EINA_MAGIC types:
77 * @until string_set
78 *
79 * Since our types won't live longer than the scope of the current function we
80 * can set the name without eina making a copy of the string:
81 * @until static_set
82 *
83 * Now we create a person, a pilot and print both as persons:
84 * @until person *
85 *
86 * Now we try to print both as pilots, which will obvisouly not work since base
87 * is not a pilot:
88 * @until pilot(sub
89 *
90 * That's all folks:
91 * @until }
92 *
93 * See full source @ref eina_magic_example_01_c "here".
94 */
95/**
96 * @page eina_magic_example_01_c Eina_Magic
97 * @include eina_magic_01.c
98 * @example eina_magic_01.c
99 */
100/**
101 * @addtogroup Eina_Tools_Group Tools
102 *
103 * @{
104 */
105/**
106 * @defgroup Eina_Magic_Group Magic
107 *
108 * @brief Eina_Magic provides run-time type-checking.
109 *
110 * C is a weak statically typed language, in other words, it will just check for
111 * types during compile time and any cast will make the compiler believe the
112 * type is correct.
113 *
114 * In real world code we often need to deal with casts, either explicit or
115 * implicit by means of @c void*. We also need to resort to casts when doing
116 * inheritance in C.
117 *
118 * Eina_Magic give us a way to do casts and still be certain of the type we are
119 * opearting on.
120 *
121 * @note It should be noted that it is considered good practice to @b disable
122 * Eina_Magic for production code. The reasoning is that any Eina_Magic errors
123 * should have been caught during testing and therefore there is no reason to
124 * incur the performance downside of Eina_Magic.
125 *
126 * An @ref eina_magic_example_01_page "example" should elucidate matters.
127 *
128 * @{
129 */
130
131/**
132 * An abstract type for a magic number.
133 */
134typedef unsigned int Eina_Magic;
135
136/**
137 * @brief Return the string associated to the given magic identifier.
138 *
139 * @param magic The magic identifier.
140 * @return The string associated to the identifier.
141 *
142 * This function returns the string associated to @p magic. Even if none are
143 * found this function still returns non @c NULL, in this case an identifier
144 * such as "(none)", "(undefined)" or "(unknown)".
145 *
146 * The following identifiers may be returned whenever magic is
147 * invalid, with their meanings:
148 *
149 * - (none): no magic was registered exists at all.
150 * - (undefined): magic was registered and found, but no string associated.
151 * - (unknown): magic was not found in the registry.
152 *
153 * @warning The returned value must not be freed.
154 */
155EAPI const char *eina_magic_string_get(Eina_Magic magic) EINA_WARN_UNUSED_RESULT;
156/**
157 * @brief Set the string associated to the given magic identifier.
158 *
159 * @param magic The magic identifier.
160 * @param magic_name The string associated to the identifier, must not
161 * be @c NULL.
162 *
163 * @return #EINA_TRUE on success, #EINA_FALSE on failure.
164 *
165 * This function sets the string @p magic_name to @p magic. It is not
166 * checked if number or string are already set, in which case you will end with
167 * duplicates. Internally, eina will make a copy of @p magic_name.
168 *
169 * @see eina_magic_string_static_set()
170 */
171EAPI Eina_Bool eina_magic_string_set(Eina_Magic magic,
172 const char *magic_name) EINA_ARG_NONNULL(2);
173
174/**
175 * @brief Set the string associated to the given magic identifier.
176 *
177 * @param magic The magic identifier.
178 * @param magic_name The string associated to the identifier, must not be
179 * @c NULL.
180 *
181 * @return #EINA_TRUE on success, #EINA_FALSE on failure.
182 *
183 * This function sets the string @p magic_name to @p magic. It is not checked if
184 * number or string are already set, in which case you might end with
185 * duplicates. Eina will @b not make a copy of @p magic_name, this means that
186 * @p magic_name has to be a valid pointer for as long as @p magic is used.
187 *
188 * @see eina_magic_string_set()
189 */
190EAPI Eina_Bool eina_magic_string_static_set(Eina_Magic magic,
191 const char *magic_name) EINA_ARG_NONNULL(2);
192
193/**
194 * @def EINA_MAGIC_NONE
195 * Random value for specifying that a structure using the magic
196 * feature has already been freed. It is used by eina_magic_fail().
197 *
198 * If the magic feature of Eina is disabled, #EINA_MAGIC_NONE is just
199 * @c 0.
200 */
201#define EINA_MAGIC_NONE 0x1234fedc
202
203#ifdef EINA_MAGIC_DEBUG
204
205/**
206 * @def EINA_MAGIC
207 * Declaration of a variable of type #Eina_Magic. To put in a structure
208 * when one wants to use the magic feature of Eina with the functions
209 * of that structure, like that:
210 *
211 * @code
212 * struct Foo
213 * {
214 * int i;
215 *
216 * EINA_MAGIC
217 * };
218 * @endcode
219 *
220 * If the magic feature of Eina is disabled, #EINA_MAGIC does nothing.
221 */
222#define EINA_MAGIC Eina_Magic __magic;
223
224/**
225 * @def EINA_MAGIC_SET(d, m)
226 * Set the magic number of @p d to @p m. @p d must be a valid pointer
227 * to a structure holding an Eina magic number declaration. Use
228 * #EINA_MAGIC to add such declaration.
229 *
230 * If the magic feature of Eina is disabled, #EINA_MAGIC_CHECK is just
231 * the value @c 0.
232 */
233#define EINA_MAGIC_SET(d, m) (d)->__magic = (m)
234
235/**
236 * @def EINA_MAGIC_CHECK(d, m)
237 * Test if @p d is @c NULL or not, and if not @c NULL, if
238 * @p d->__eina_magic is equal to @p m. @p d must be a structure that
239 * holds an Eina magic number declaration. Use #EINA_MAGIC to add such
240 * declaration.
241 *
242 * If the magic feature of Eina is disabled, #EINA_MAGIC_CHECK is just
243 * the value @c 1.
244 */
245#define EINA_MAGIC_CHECK(d, m) ((d) && ((d)->__magic == (m)))
246
247/**
248 * @def EINA_MAGIC_FAIL(d, m)
249 * Call eina_magic_fail() with the parameters @p d, @p d->__magic, @p
250 * m, __FILE__, __FUNCTION__ and __LINE__. @p d must be a structure that
251 * holds an Eina magic number declaration. Use #EINA_MAGIC to add such
252 * declaration.
253 *
254 * If the magic feature of Eina is disabled, #EINA_MAGIC_FAIL does
255 * nothing.
256 */
257#define EINA_MAGIC_FAIL(d, m) \
258 eina_magic_fail((void *)(d), \
259 (d) ? (d)->__magic : 0, \
260 (m), \
261 __FILE__, \
262 __FUNCTION__, \
263 __LINE__);
264
265/**
266 * @brief Display a message or abort if a magic check failed.
267 *
268 * @param d The checked data pointer.
269 * @param m The magic identifer to check.
270 * @param req_m The requested magic identifier to check.
271 * @param file The file in which the magic check failed.
272 * @param fnc The function in which the magic check failed.
273 * @param line The line at which the magic check failed.
274 *
275 * @warning You should @b strongly consider using @ref EINA_MAGIC_FAIL(d, m)
276 * instead.
277 *
278 * This function displays an error message if a magic check has
279 * failed, using the following logic in the following order:
280 * @li If @p d is @c NULL, a message warns about a @c NULL pointer.
281 * @li Otherwise, if @p m is equal to #EINA_MAGIC_NONE, a message
282 * warns about a handle that was already freed.
283 * @li Otherwise, if @p m is equal to @p req_m, a message warns about
284 * a handle that is of wrong type.
285 * @li Otherwise, a message warns you about ab-using that function...
286 *
287 * If the environment variable EINA_LOG_ABORT is set, abort() is
288 * called and the program stops. It is useful for debugging programs
289 * with gdb.
290 */
291EAPI void eina_magic_fail(void *d, Eina_Magic m, Eina_Magic req_m,
292 const char *file, const char *fnc,
293 int line) EINA_ARG_NONNULL(4, 5);
294
295#else
296
297/**
298 * @cond LOCAL
299 */
300
301#define EINA_MAGIC
302#define EINA_MAGIC_SET(d, m) ((void)0)
303#define EINA_MAGIC_CHECK(d, m) (1)
304#define EINA_MAGIC_FAIL(d, m) ((void)0)
305
306#define eina_magic_fail(d, m, req_m, file, fnx, line) ((void)0)
307
308/**
309 * @endcond
310 */
311
312#endif
313
314/**
315 * @}
316 */
317
318/**
319 * @}
320 */
321
322#endif /* EINA_MAGIC_H_ */
diff --git a/libraries/eina/src/include/eina_main.h b/libraries/eina/src/include/eina_main.h
new file mode 100644
index 0000000..fa34d59
--- /dev/null
+++ b/libraries/eina/src/include/eina_main.h
@@ -0,0 +1,162 @@
1/* EINA - EFL data type library
2 * Copyright (C) 2008 Cedric Bail
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library;
16 * if not, see <http://www.gnu.org/licenses/>.
17 */
18
19#ifndef EINA_MAIN_H_
20#define EINA_MAIN_H_
21
22#include "eina_types.h"
23
24/**
25 * @addtogroup Eina_Main_Group Main
26 *
27 * @brief These functions provide general initialisation and shut down
28 * functions.
29 */
30
31/**
32 * @addtogroup Eina_Core_Group Core
33 *
34 * @{
35 */
36
37/**
38 * @defgroup Eina_Main_Group Main
39 *
40 * @{
41 */
42
43/**
44 * @def EINA_VERSION_MAJOR
45 * @brief Major version of Eina
46 */
47#define EINA_VERSION_MAJOR 1
48
49/**
50 * @def EINA_VERSION_MINOR
51 * @brief Minor version of Eina
52 */
53#define EINA_VERSION_MINOR 0
54
55/**
56 * @typedef Eina_Version
57 * The version of Eina.
58 */
59typedef struct _Eina_Version
60{
61 int major; /**< Major component of the version */
62 int minor; /**< Minor component of the version */
63 int micro; /**< Micro component of the version */
64 int revision; /**< Revision component of the version */
65} Eina_Version;
66
67EAPI extern Eina_Version *eina_version;
68
69/**
70 * @brief Initialize the Eina library.
71 *
72 * @return 1 or greater on success, 0 on error.
73 *
74 * This function sets up all the eina modules. It returns 0 on
75 * failure (that is, when one of the module fails to initialize),
76 * otherwise it returns the number of times it has already been
77 * called.
78 *
79 * When Eina is not used anymore, call eina_shutdown() to shut down
80 * the Eina library.
81 */
82EAPI int eina_init(void);
83
84/**
85 * @brief Shut down the Eina library.
86 *
87 * @return 0 when all the modules is completely shut down, 1 or
88 * greater otherwise.
89 *
90 * This function shuts down the Eina library. It returns 0 when it has
91 * been called the same number of times than eina_init(). In that case
92 * it shut down all the Eina modules.
93 *
94 * Once this function succeeds (that is, @c 0 is returned), you must
95 * not call any of the Eina function anymore. You must call
96 * eina_init() again to use the Eina functions again.
97 */
98EAPI int eina_shutdown(void);
99
100/**
101 * @brief Initialize the mutexes of the Eina library.
102 *
103 * @return 1 or greater on success, 0 on error.
104 *
105 * This function sets up all the mutexes in all eina modules. It returns 0 on
106 * failure (that is, when one of the module fails to initialize),
107 * otherwise it returns the number of times it has already been
108 * called.
109 *
110 * When the mutexes are not used anymore, call eina_threads_shutdown() to shut down
111 * the mutexes.
112 *
113 * This function should never be called outside of the main loop.
114 */
115EAPI int eina_threads_init(void);
116
117/**
118 * @brief Shut down mutexes in the Eina library.
119 *
120 * @return 0 when all mutexes are completely shut down, 1 or
121 * greater otherwise.
122 *
123 * This function shuts down the mutexes in the Eina library. It returns 0 when it has
124 * been called the same number of times than eina_threads_init(). In that case
125 * it shut down all the mutexes.
126 *
127 * Once this function succeeds (that is, @c 0 is returned), you must
128 * not call any of the Eina function in a thread anymore. You must call
129 * eina_threads_init() again to use the Eina functions in a thread again.
130 *
131 * This function should never be called outside of the main loop.
132 */
133EAPI int eina_threads_shutdown(void);
134
135/**
136 * @brief Check if you are calling this function from the same thread Eina was initialized or not
137 * @since 1.1.0
138 *
139 * Most EFL function are not thread safe and all the call need to happen in
140 * the main loop. With this call you could know if you can call an EFL
141 * function or not.
142 */
143EAPI Eina_Bool eina_main_loop_is(void);
144
145/**
146 * @brief You should never use that function excpet if you really really know what your are doing.
147 * @since 1.1.0
148 *
149 * If you are reading this documentation, that certainly means you don't know what is the purpose of
150 * this call and you should just not use it.
151 */
152EAPI void eina_main_loop_define(void);
153
154/**
155 * @}
156 */
157
158/**
159 * @}
160 */
161
162#endif /* EINA_MAIN_H_ */
diff --git a/libraries/eina/src/include/eina_matrixsparse.h b/libraries/eina/src/include/eina_matrixsparse.h
new file mode 100644
index 0000000..97d1ca5
--- /dev/null
+++ b/libraries/eina/src/include/eina_matrixsparse.h
@@ -0,0 +1,399 @@
1/* EINA - EFL data type library
2 * Copyright (C) 2009 Gustavo Sverzut Barbieri
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library;
16 * if not, see <http://www.gnu.org/licenses/>.
17 */
18
19#ifndef EINA_MATRIXSPARSE_H_
20#define EINA_MATRIXSPARSE_H_
21
22#include <stdlib.h>
23
24#include "eina_config.h"
25
26#include "eina_types.h"
27#include "eina_iterator.h"
28#include "eina_accessor.h"
29
30/**
31 * @addtogroup Eina_Matrixsparse_Group Sparse Matrix
32 *
33 * @brief These functions provide matrix sparse management.
34 *
35 * For more information, you can look at the @ref tutorial_matrixsparse_page.
36 */
37
38/**
39 * @addtogroup Eina_Data_Types_Group Data Types
40 *
41 * @{
42 */
43
44/**
45 * @addtogroup Eina_Containers_Group Containers
46 *
47 * @{
48 */
49
50/**
51 * @defgroup Eina_Matrixsparse_Group Sparse Matrix
52 *
53 * @{
54 */
55
56/**
57 * @typedef Eina_Matrixsparse
58 * Type for a generic sparse matrix.
59 */
60typedef struct _Eina_Matrixsparse Eina_Matrixsparse;
61
62/**
63 * @typedef Eina_Matrixsparse_Row
64 * Type for a generic sparse matrix row, opaque for users.
65 */
66typedef struct _Eina_Matrixsparse_Row Eina_Matrixsparse_Row;
67
68/**
69 * @typedef Eina_Matrixsparse_Cell
70 * Type for a generic sparse matrix cell, opaque for users.
71 */
72typedef struct _Eina_Matrixsparse_Cell Eina_Matrixsparse_Cell;
73
74/* constructors and destructors */
75
76/**
77 * @brief Create a new Sparse Matrix.
78 *
79 * @param rows number of rows in matrix. Operations with rows greater than this
80 * value will fail.
81 * @param cols number of columns in matrix. Operations with columns greater
82 * than this value will fail.
83 * @param free_func used to delete cell data contents, used by
84 * eina_matrixsparse_free(), eina_matrixsparse_size_set(),
85 * eina_matrixsparse_row_idx_clear(),
86 * eina_matrixsparse_column_idx_clear(),
87 * eina_matrixsparse_cell_idx_clear() and possible others.
88 * @param user_data given to @a free_func as first parameter.
89 *
90 * @return newly allocated matrix or NULL if allocation failed and eina_error
91 * is set.
92 */
93EAPI Eina_Matrixsparse *eina_matrixsparse_new(unsigned long rows,
94 unsigned long cols,
95 void (*free_func)(void *user_data,
96 void *cell_data),
97 const void *user_data);
98
99/**
100 * @brief Free resources allocated to Sparse Matrix.
101 *
102 * @param m The Sparse Matrix instance to free, must @b not be @c NULL.
103 */
104EAPI void eina_matrixsparse_free(Eina_Matrixsparse *m);
105
106/* size manipulation */
107
108/**
109 * @brief Get the current size of Sparse Matrix.
110 *
111 * The given parameters are guaranteed to be set if they're not NULL,
112 * even if this function fails (ie: @a m is not a valid matrix instance).
113 *
114 * @param m the sparse matrix to operate on.
115 * @param rows returns the number of rows, may be NULL. If @a m is invalid,
116 * returned value is zero, otherwise it's a positive integer.
117 * @param cols returns the number of columns, may be NULL. If @a m is
118 * invalid, returned value is zero, otherwise it's a positive integer.
119 */
120EAPI void eina_matrixsparse_size_get(const Eina_Matrixsparse *m,
121 unsigned long *rows,
122 unsigned long *cols);
123
124/**
125 * @brief Resize the Sparse Matrix.
126 *
127 * This will resize the sparse matrix, possibly freeing cells on rows
128 * and columns that will cease to exist.
129 *
130 * @param m the sparse matrix to operate on.
131 * @param rows the new number of rows, must be greater than zero.
132 * @param cols the new number of columns, must be greater than zero.
133 * @return 1 on success, 0 on failure.
134 *
135 * @warning cells, rows or columns are not reference counted and thus
136 * after this call any reference might be invalid if instance were
137 * freed.
138 */
139EAPI Eina_Bool eina_matrixsparse_size_set(Eina_Matrixsparse *m,
140 unsigned long rows,
141 unsigned long cols);
142
143/* data getting */
144
145/**
146 * Get the cell reference inside Sparse Matrix.
147 *
148 * @param m the sparse matrix to operate on.
149 * @param row the new number of row to clear.
150 * @param col the new number of column to clear.
151 * @param cell pointer to return cell reference, if any exists.
152 *
153 * @return 1 on success, 0 on failure. It is considered success if did not
154 * exist but index is inside matrix size, in this case @c *cell == NULL
155 *
156 * @see eina_matrixsparse_cell_data_get()
157 * @see eina_matrixsparse_data_idx_get()
158 */
159EAPI Eina_Bool eina_matrixsparse_cell_idx_get(const Eina_Matrixsparse *m, unsigned long row, unsigned long col, Eina_Matrixsparse_Cell **cell);
160
161/**
162 * Get data associated with given cell reference.
163 *
164 * @param cell given cell reference, must @b not be @c NULL.
165 *
166 * @return data associated with given cell.
167 *
168 * @see eina_matrixsparse_cell_idx_get()
169 * @see eina_matrixsparse_data_idx_get()
170 */
171EAPI void *eina_matrixsparse_cell_data_get(const Eina_Matrixsparse_Cell *cell);
172
173/**
174 * Get data associated with given cell given its indexes.
175 *
176 * @param m the sparse matrix to operate on.
177 * @param row the new number of row to clear.
178 * @param col the new number of column to clear.
179 *
180 * @return data associated with given cell or NULL if nothing is associated.
181 *
182 * @see eina_matrixsparse_cell_idx_get()
183 * @see eina_matrixsparse_cell_data_get()
184 */
185EAPI void *eina_matrixsparse_data_idx_get(const Eina_Matrixsparse *m, unsigned long row, unsigned long col);
186
187/**
188 * Get position (indexes) of the given cell.
189 *
190 * @param cell the cell reference, must @b not be @c NULL.
191 * @param row where to store cell row number, may be @c NULL.
192 * @param col where to store cell column number, may be @c NULL.
193 *
194 * @return 1 on success, 0 otherwise (@c cell is @c NULL).
195 */
196EAPI Eina_Bool eina_matrixsparse_cell_position_get(const Eina_Matrixsparse_Cell *cell, unsigned long *row, unsigned long *col);
197
198/* data setting */
199
200/**
201 * Change cell reference value without freeing the possibly existing old value.
202 *
203 * @param cell the cell reference, must @b not be @c NULL.
204 * @param data new data to set.
205 * @param p_old returns the old value intact (not freed).
206 *
207 * @return 1 on success, 0 otherwise (@a cell is @c NULL).
208 *
209 * @see eina_matrixsparse_cell_data_set()
210 * @see eina_matrixsparse_data_idx_replace()
211 */
212EAPI Eina_Bool eina_matrixsparse_cell_data_replace(Eina_Matrixsparse_Cell *cell, const void *data, void **p_old);
213
214/**
215 * Change cell value freeing the possibly existing old value.
216 *
217 * In contrast to eina_matrixsparse_cell_data_replace(), this function will
218 * call @c free_func() on existing value.
219 *
220 * @param cell the cell reference, must @b not be @c NULL.
221 * @param data new data to set.
222 *
223 * @return 1 on success, 0 otherwise (@a cell is @c NULL).
224 *
225 * @see eina_matrixsparse_cell_data_replace()
226 * @see eina_matrixsparse_data_idx_set()
227 */
228EAPI Eina_Bool eina_matrixsparse_cell_data_set(Eina_Matrixsparse_Cell *cell, const void *data);
229
230/**
231 * Change cell value without freeing the possibly existing old value, using
232 * indexes.
233 *
234 * @param m the sparse matrix, must @b not be @c NULL.
235 * @param row the row number to set the value.
236 * @param col the column number to set the value.
237 * @param data new data to set.
238 * @param p_old returns the old value intact (not freed).
239 *
240 * @return 1 on success, 0 otherwise (@a m is @c NULL, indexes are not valid).
241 *
242 * @see eina_matrixsparse_cell_data_replace()
243 * @see eina_matrixsparse_data_idx_set()
244 */
245EAPI Eina_Bool eina_matrixsparse_data_idx_replace(Eina_Matrixsparse *m, unsigned long row, unsigned long col, const void *data, void **p_old);
246
247/**
248 * Change cell value freeing the possibly existing old value, using
249 * indexes.
250 *
251 * In contrast to eina_matrixsparse_data_idx_replace(), this function will
252 * call @c free_func() on existing value.
253 *
254 * @param m the sparse matrix, must @b not be @c NULL.
255 * @param row the row number to set the value.
256 * @param col the column number to set the value.
257 * @param data new data to set.
258 *
259 * @return 1 on success, 0 otherwise (@a m is @c NULL, indexes are not valid).
260 *
261 * @see eina_matrixsparse_cell_data_replace()
262 */
263EAPI Eina_Bool eina_matrixsparse_data_idx_set(Eina_Matrixsparse *m, unsigned long row, unsigned long col, const void *data);
264
265/* data deleting */
266
267/**
268 * Clear (erase all cells) of row given its index.
269 *
270 * Existing cells will be cleared with @c free_func() given to
271 * eina_matrixsparse_new().
272 *
273 * @param m the sparse matrix to operate on.
274 * @param row the new number of row to clear.
275 *
276 * @return 1 on success, 0 on failure. It is considered success if row
277 * had no cells filled. Failure is asking for clear row outside
278 * matrix size.
279 *
280 * @warning cells, rows or columns are not reference counted and thus
281 * after this call any reference might be invalid if instance were
282 * freed.
283 */
284EAPI Eina_Bool eina_matrixsparse_row_idx_clear(Eina_Matrixsparse *m, unsigned long row);
285
286/**
287 * Clear (erase all cells) of column given its index.
288 *
289 * Existing cells will be cleared with @c free_func() given to
290 * eina_matrixsparse_new().
291 *
292 * @param m the sparse matrix to operate on.
293 * @param col the new number of column to clear.
294 *
295 * @return 1 on success, 0 on failure. It is considered success if column
296 * had no cells filled. Failure is asking for clear column outside
297 * matrix size.
298 *
299 * @warning cells, rows or columns are not reference counted and thus
300 * after this call any reference might be invalid if instance were
301 * freed.
302 */
303EAPI Eina_Bool eina_matrixsparse_column_idx_clear(Eina_Matrixsparse *m, unsigned long col);
304
305/**
306 * Clear (erase) cell given its indexes.
307 *
308 * Existing cell will be cleared with @c free_func() given to
309 * eina_matrixsparse_new().
310 *
311 * @param m the sparse matrix to operate on.
312 * @param row the new number of row to clear.
313 * @param col the new number of column to clear.
314 *
315 * @return 1 on success, 0 on failure. It is considered success if did not
316 * exist but index is inside matrix size.
317 *
318 * @warning cells, rows or columns are not reference counted and thus
319 * after this call any reference might be invalid if instance were
320 * freed. Note that this call might delete container column and
321 * row if this cell was the last remainder.
322 */
323EAPI Eina_Bool eina_matrixsparse_cell_idx_clear(Eina_Matrixsparse *m, unsigned long row, unsigned long col);
324
325/**
326 * Clear (erase) cell given its reference.
327 *
328 * @param cell the cell reference, must @b not be @c NULL.
329 *
330 * @return 1 on success, 0 on failure.
331 *
332 * @warning cells, rows or columns are not reference counted and thus
333 * after this call any reference might be invalid if instance were
334 * freed. Note that this call might delete container column and
335 * row if this cell was the last remainder.
336 */
337EAPI Eina_Bool eina_matrixsparse_cell_clear(Eina_Matrixsparse_Cell *cell);
338
339/* iterators */
340
341/**
342 * Creates a new iterator over existing matrix cells.
343 *
344 * This is a cheap walk, it will just report existing cells and holes
345 * in the sparse matrix will be ignored. That means the reported
346 * indexes will not be sequential.
347 *
348 * The iterator data will be the cell reference, one may query current
349 * position with eina_matrixsparse_cell_position_get() and cell value
350 * with eina_matrixsparse_cell_data_get().
351 *
352 * @param m The Sparse Matrix reference, must @b not be @c NULL.
353 * @return A new iterator.
354 *
355 * @warning if the matrix structure changes then the iterator becomes
356 * invalid! That is, if you add or remove cells this iterator
357 * behavior is undefined and your program may crash!
358 */
359EAPI Eina_Iterator *eina_matrixsparse_iterator_new(const Eina_Matrixsparse *m);
360
361/**
362 * Creates a new iterator over all matrix cells.
363 *
364 * Unlike eina_matrixsparse_iterator_new() this one will report all
365 * matrix cells, even those that are still empty (holes). These will
366 * be reported as dummy cells that contains no data.
367 *
368 * Be aware that iterating a big matrix (1000x1000) will call your
369 * function that number of times (1000000 times in that case) even if
370 * your matrix have no elements at all!
371 *
372 * The iterator data will be the cell reference, one may query current
373 * position with eina_matrixsparse_cell_position_get() and cell value
374 * with eina_matrixsparse_cell_data_get(). If cell is empty then the
375 * reference will be a dummy/placeholder, thus setting value with
376 * eina_matrixsparse_cell_data_set() will leave pointer unreferenced.
377 *
378 * @param m The Sparse Matrix reference, must @b not be @c NULL.
379 * @return A new iterator.
380 *
381 * @warning if the matrix structure changes then the iterator becomes
382 * invalid! That is, if you add or remove cells this iterator
383 * behavior is undefined and your program may crash!
384 */
385EAPI Eina_Iterator *eina_matrixsparse_iterator_complete_new(const Eina_Matrixsparse *m);
386
387/**
388 * @}
389 */
390
391/**
392 * @}
393 */
394
395/**
396 * @}
397 */
398
399#endif /* EINA_MATRIXSPARSE_H_ */
diff --git a/libraries/eina/src/include/eina_mempool.h b/libraries/eina/src/include/eina_mempool.h
new file mode 100644
index 0000000..796bc9e
--- /dev/null
+++ b/libraries/eina/src/include/eina_mempool.h
@@ -0,0 +1,123 @@
1/* EINA - EFL data type library
2 * Copyright (C) 2007-2008 Jorge Luis Zapata Muga
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library;
16 * if not, see <http://www.gnu.org/licenses/>.
17 */
18
19#ifndef EINA_MEMPOOL_H_
20#define EINA_MEMPOOL_H_
21
22#include "eina_types.h"
23#include "eina_error.h"
24#include "eina_module.h"
25
26
27/**
28 * @addtogroup Eina_Memory_Pool_Group Memory Pool
29 *
30 * @brief These functions provide memory pool management.
31 *
32 * Several mempool are available:
33 *
34 * @li @c buddy: It uses the
35 * <a href="http://en.wikipedia.org/wiki/Buddy_memory_allocation">"buddy
36 * allocator" algorithm</a> but the Eina implementation differs in the
37 * sense that the chunk information is not stored on the chunk itself,
38 * but on another memory area. This is useful for cases where the
39 * memory to manage might be slower to access, or limited (like video
40 * memory).
41 * @li @c chained_pool: It is the default one. It allocates a big
42 * chunk of memory with malloc() and split the result in chunks of the
43 * requested size that are pushed inside a stack. When requested, it
44 * takes this pointer from the stack to give them to whoever wants
45 * them.
46 * @li @c ememoa_fixed and @c ememoa_unknown: experimental allocators
47 * which could be useful when a fixed amount of memory is needed.
48 * @li @c fixed_bitmap: It allocates with malloc) 32* the requested
49 * size and push the pool pointer in an rbtree. To find empty space in
50 * a pool, it will just search for the first bit set in an int (32
51 * bits). Then, when a pointer is freed, it will do a search inside
52 * the rbtree.
53 * @li @c pass_through: it just call malloc() and free(). It may be
54 * faster on some computers than using our own allocators (like having
55 * a huge L2 cache, over 4MB).
56 * @li @c one_big: It call just one time malloc for the requested number
57 * of items. Useful when you know in advance how many object of some
58 * type will live during the life of the mempool.
59 */
60
61/**
62 * @addtogroup Eina_Tools_Group Tools
63 *
64 * @{
65 */
66
67/**
68 * @defgroup Eina_Memory_Pool_Group Memory Pool
69 *
70 * @{
71 */
72
73/**
74 * @typedef Eina_Mempool
75 * Mempool type.
76 */
77typedef struct _Eina_Mempool Eina_Mempool;
78
79/**
80 * @typedef Eina_Mempool_Backend
81 * Mempool backend type.
82 */
83typedef struct _Eina_Mempool_Backend Eina_Mempool_Backend;
84
85
86/**
87 * @typedef Eina_Mempool_Repack_Cb
88 * Type for a callback who need to unreference an old object from a mempool
89 * and reference the new one instead. Memcpy is taken care by the mempool.
90 */
91typedef void (*Eina_Mempool_Repack_Cb)(void *dst, void *src, void *data);
92
93EAPI extern Eina_Error EINA_ERROR_NOT_MEMPOOL_MODULE;
94
95EAPI Eina_Mempool *eina_mempool_add(const char *module, const char *context, const char *options, ...) EINA_MALLOC EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1);
96EAPI void eina_mempool_del(Eina_Mempool *mp) EINA_ARG_NONNULL(1);
97
98static inline void *eina_mempool_realloc(Eina_Mempool *mp, void *element, unsigned int size) EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT;
99static inline void *eina_mempool_malloc(Eina_Mempool *mp, unsigned int size) EINA_MALLOC EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT;
100static inline void eina_mempool_free(Eina_Mempool *mp, void *element) EINA_ARG_NONNULL(1);
101
102EAPI void eina_mempool_repack(Eina_Mempool *mp,
103 Eina_Mempool_Repack_Cb cb,
104 void *data) EINA_ARG_NONNULL(1, 2);
105EAPI void eina_mempool_gc(Eina_Mempool *mp) EINA_ARG_NONNULL(1);
106EAPI void eina_mempool_statistics(Eina_Mempool *mp) EINA_ARG_NONNULL(1);
107
108EAPI Eina_Bool eina_mempool_register(Eina_Mempool_Backend *be) EINA_ARG_NONNULL(1);
109EAPI void eina_mempool_unregister(Eina_Mempool_Backend *be) EINA_ARG_NONNULL(1);
110
111EAPI unsigned int eina_mempool_alignof(unsigned int size);
112
113#include "eina_inline_mempool.x"
114
115/**
116 * @}
117 */
118
119/**
120 * @}
121 */
122
123#endif /* EINA_MEMPOOL_H_ */
diff --git a/libraries/eina/src/include/eina_mmap.h b/libraries/eina/src/include/eina_mmap.h
new file mode 100644
index 0000000..d7e3819
--- /dev/null
+++ b/libraries/eina/src/include/eina_mmap.h
@@ -0,0 +1,59 @@
1#ifndef EINA_MMAP_H_
2#define EINA_MMAP_H_
3
4/**
5 * @addtogroup Eina_Mmap_Group Mmap Group
6 *
7 * @brief These functions provide helpers for safe mmap handling
8 *
9 * @{
10 *
11 * @since 1.1.0
12 */
13
14/**
15 * @brief Enable or disable safe mmaped IO handling
16 *
17 * @param enabled The enabled state (to enable, pass EINA_TRUE)
18 *
19 * This enables (if possible on your platform) a signal handler for
20 * SIGBUS, that replaces the "bad page" with a pzge of 0's (from /dev/zero)
21 * if a SIGBUS occurs. This allows for safe mmap() of files that may truncate
22 * or from files on devices with IO errors. Normally these cases will result
23 * in a SIGBUS being delivered (and termination of yyour process), but
24 * when "mmap safety" is enabled, this will not occur. Instead a page of
25 * bytes of the value 0 will replace the "bad page", allowing the process
26 * to continue and allow its own parsing error detection to safely abort
27 * the operation without the process falling apart.
28 *
29 * If you disable mmap safety, the SIGBUS handler will be restored to its
30 * default handler. Note that eina_file_map_all() and eina_file_map_new()
31 * will automatically enable mmap safety as they provide an mmaped file IO
32 * layer, and rely on mmap to not fail for any part of the file.
33 *
34 * If you set up your own SIGBUS handler, then this will effectively disable
35 * the safe mmap handling and make you liable to crashes on IO to or from
36 * such "damaged files" that would take down your process.
37 *
38 * @since 1.1.0
39 */
40EAPI Eina_Bool
41eina_mmap_safety_enabled_set(Eina_Bool enabled);
42
43/**
44 * @brief Get the enabled state of mmap safety.
45 *
46 * @return The safety state (EINA_TRUE if enabled)
47 *
48 * This returns the mmap safety state set by eina_mmap_safety_enabled_set().
49 * See eina_mmap_safety_enabled_set() for more information.
50 *
51 * @since 1.1.0
52 */
53EAPI Eina_Bool
54eina_mmap_safety_enabled_get(void);
55
56/**
57 * @}
58 */
59#endif
diff --git a/libraries/eina/src/include/eina_module.h b/libraries/eina/src/include/eina_module.h
new file mode 100644
index 0000000..58e38f9
--- /dev/null
+++ b/libraries/eina/src/include/eina_module.h
@@ -0,0 +1,343 @@
1/* EINA - EFL data type library
2 * Copyright (C) 2007-2008 Jorge Luis Zapata Muga
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library;
16 * if not, see <http://www.gnu.org/licenses/>.
17 */
18
19#ifndef EINA_MODULE_H_
20#define EINA_MODULE_H_
21
22#include "eina_types.h"
23#include "eina_array.h"
24#include "eina_error.h"
25
26/**
27 * @addtogroup Eina_Module_Group Module
28 *
29 * @brief These functions provide module management.
30 */
31
32/**
33 * @addtogroup Eina_Tools_Group Tools
34 *
35 * @{
36 */
37
38/**
39 * @defgroup Eina_Module_Group Module
40 *
41 * Eina module provides some helpers over POSIX dlopen(). It is not
42 * meant to replace, abstract or make a "portable" version of the
43 * POSIX, but enhance its usage by defining some good practices.
44 *
45 * Modules are created with eina_module_new() and later loaded with
46 * eina_module_load(). Loads are reference counted and there must be
47 * the same number of eina_module_unload() in order to have it to call
48 * dlclose(). This makes simple to have different users for the same
49 * module.
50 *
51 * The loaded shared objects may have two visible functions that will
52 * be called and might provide initialization and shutdown
53 * proceedures. The symbols are @c __eina_module_init and
54 * @c __eina_module_shutdown and will be defined by the macros
55 * EINA_MODULE_INIT() and EINA_MODULE_SHUTDOWN().
56 *
57 * There are some helpers to automatically create modules based on
58 * directory listing. See eina_module_arch_list_get(),
59 * eina_module_list_get() and eina_module_find().
60 *
61 * @{
62 */
63
64/**
65 * @typedef Eina_Module
66 * Dynamic module loader handle.
67 */
68typedef struct _Eina_Module Eina_Module;
69
70typedef Eina_Bool (*Eina_Module_Cb)(Eina_Module *m, void *data);
71
72/**
73 * @typedef Eina_Module_Init
74 * If a function with such signature is exported by module as
75 * __eina_module_init, it will be called on the first load after
76 * dlopen() and if #EINA_FALSE is returned, load will fail, #EINA_TRUE
77 * means the module was successfully initialized.
78 * @see Eina_Module_Shutdown
79 */
80typedef Eina_Bool (*Eina_Module_Init)(void);
81
82/**
83 * @typedef Eina_Module_Shutdown
84 * If a function with such signature is exported by module as
85 * __eina_module_shutdown, it will be called before calling dlclose()
86 * @see Eina_Module_Init
87 */
88typedef void (*Eina_Module_Shutdown)(void);
89
90/**
91 * @def EINA_MODULE_INIT
92 * declares the given function as the module initializer (__eina_module_init).
93 * It must be of signature #Eina_Module_Init
94 */
95#define EINA_MODULE_INIT(f) EAPI Eina_Module_Init __eina_module_init = &f
96
97/**
98 * @def EINA_MODULE_SHUTDOWN
99 * declares the given function as the module shutdownializer
100 * (__eina_module_shutdown). It must be of signature
101 * #Eina_Module_Shutdown
102 */
103#define EINA_MODULE_SHUTDOWN(f) EAPI Eina_Module_Shutdown __eina_module_shutdown = &f
104
105/**
106 * @var EINA_ERROR_WRONG_MODULE
107 * Error identifier corresponding to a wrong module.
108 */
109extern EAPI Eina_Error EINA_ERROR_WRONG_MODULE;
110
111/**
112 * @var EINA_ERROR_MODULE_INIT_FAILED
113 * Error identifier corresponding to a failure during the initialisation of a module.
114 */
115extern EAPI Eina_Error EINA_ERROR_MODULE_INIT_FAILED;
116
117/**
118 * @brief Return a new module.
119 *
120 * @param file The name of the file module to load.
121 *
122 * This function returns a new module. If @p file is @c NULL, the
123 * function returns @c NULL, otherwise, it allocates an Eina_Module,
124 * stores a duplicate string of @p file, sets its reference to @c 0
125 * and its handle to @c NULL.
126 *
127 * When the new module is not needed anymore, use eina_module_free()
128 * to free the allocated memory.
129 *
130 * @see eina_module_load
131 */
132EAPI Eina_Module *
133 eina_module_new(const char *file) EINA_MALLOC EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1);
134
135/**
136 * @brief Delete a module.
137 *
138 * @param m The module to delete.
139 * @return EINA_TRUE on success, EINA_FALSE otherwise.
140 *
141 * This function calls eina_module_unload() if @p m has been previously
142 * loaded and frees the allocated memory. On success this function
143 * returns EINA_TRUE and EINA_FALSE otherwise. If @p m is @c NULL, the
144 * function returns immediately.
145 */
146EAPI Eina_Bool
147 eina_module_free(Eina_Module *m) EINA_ARG_NONNULL(1);
148
149/**
150 * @brief Load a module.
151 *
152 * @param m The module to load.
153 * @return EINA_TRUE on success, EINA_FALSE otherwise.
154 *
155 * This function load the shared file object passed in
156 * eina_module_new(). If it is a internal Eina module (like the
157 * mempools), it also initialize it. It the shared file object can not
158 * be loaded, the error #EINA_ERROR_WRONG_MODULE is set and
159 * #EINA_FALSE is returned. If it is a internal Eina module and the
160 * module can not be initialized, the error
161 * #EINA_ERROR_MODULE_INIT_FAILED is set and #EINA_FALSE is
162 * returned. If the module has already been loaded, it's refeence
163 * counter is increased by one and #EINA_TRUE is returned. If @p m is
164 * @c NULL, the function returns immediately #EINA_FALSE.
165 *
166 * When the symbols of the shared file objetcts are not needed
167 * anymore, call eina_module_unload() to unload the module.
168 */
169EAPI Eina_Bool
170 eina_module_load(Eina_Module *module) EINA_ARG_NONNULL(1);
171
172/**
173 * @brief Unload a module.
174 *
175 * @param m The module to load.
176 * @return EINA_TRUE on success, EINA_FALSE otherwise.
177 *
178 * This function unload the module @p m that has been previously
179 * loaded by eina_module_load(). If the reference counter of @p m is
180 * strictly greater than @c 1, #EINA_FALSE is returned. Otherwise, the
181 * shared object file is closed and if it is a internal Eina module, it
182 * is shutted down just before. In that case, #EINA_TRUE is
183 * returned. In all case, the reference counter is decreased. If @p m
184 * is @c NULL, the function returns immediately #EINA_FALSE.
185 */
186EAPI Eina_Bool
187 eina_module_unload(Eina_Module *m) EINA_ARG_NONNULL(1);
188
189/**
190 * @brief Retrive the data associated to a symbol.
191 *
192 * @param m The module.
193 * @param symbol The symbol.
194 * @return The data associated to the symbol, or @c NULL on failure.
195 *
196 * This function returns the data associated to @p symbol of @p m. @p
197 * m must have been loaded before with eina_module_load(). If @p m
198 * is @c NULL, or if it has not been correctly loaded before, the
199 * function returns immediately @c NULL.
200 */
201EAPI void *
202 eina_module_symbol_get(const Eina_Module *module, const char *symbol) EINA_PURE EINA_ARG_NONNULL(1, 2) EINA_WARN_UNUSED_RESULT;
203
204/**
205 * @brief Return the file name associated to the module.
206 *
207 * @param m The module.
208 * @return The file name.
209 *
210 * This function returns the file name passed in eina_module_new(). If
211 * @p m is @c NULL, the function returns immediately @c NULL. The
212 * returned value must no be freed.
213 */
214EAPI const char *
215 eina_module_file_get(const Eina_Module *m) EINA_PURE EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1);
216
217
218/**
219 * @brief Return the path built from the location of a library and a
220 * given sub directory.
221 *
222 * @param symbol The symbol to search for.
223 * @param sub_dir The subdirectory to append.
224 * @return The built path on success, @c NULL otherwise.
225 *
226 * This function returns the path built by concatenating the path of
227 * the library containing the symbol @p symbol and @p sub_dir. @p sub_dir
228 * can be @c NULL. The returned path must be freed when not used
229 * anymore. If the symbol is not found, or dl_addr() is not supported,
230 * or allocation fails, this function returns @c NULL.
231 */
232EAPI char *
233 eina_module_symbol_path_get(const void *symbol, const char *sub_dir) EINA_PURE EINA_MALLOC EINA_ARG_NONNULL(1, 2);
234
235/**
236 * @brief Return the path built from the value of an environment varialbe and a
237 * given sub directory.
238 *
239 * @param env The environment variable to expand.
240 * @param sub_dir The subdirectory to append.
241 * @return The built path on success, @c NULL otherwise.
242 *
243 * This function returns the path built by concatenating the value of
244 * the environment variable named @p env and @p sub_dir. @p sub_dir
245 * can be @c NULL. The returned path must be freed when not used
246 * anymore. If the symbol is not found, or @p env does not exist, or
247 * allocation fails, this function returns @c NULL.
248 */
249EAPI char *
250 eina_module_environment_path_get(const char *env, const char *sub_dir) EINA_PURE EINA_MALLOC EINA_ARG_NONNULL(1, 2);
251
252
253/**
254 * @brief Get an array of modules found on the directory path matching an arch type.
255 *
256 * @param array The array that stores the list of the modules.
257 * @param path The directory's path to search for modules.
258 * @param arch The architecture string.
259 *
260 * This function adds to @p array the module names found in @p path
261 * which match the cpu architecture @p arch. If @p path or @p arch is
262 * @c NULL, the function returns immediately @p array. @p array can be
263 * @c NULL. In that case, it is created with 4 elements.
264 */
265EAPI Eina_Array *
266 eina_module_arch_list_get(Eina_Array *array, const char *path, const char *arch);
267
268/**
269 * @brief Get a list of modules found on the directory path.
270 *
271 * @param array The array that stores the list of the modules.
272 * @param path The directory's path to search for modules.
273 * @param recursive Iterate recursively on the path.
274 * @param cb Callback function to call on each module.
275 * @param data Data passed to the callback function.
276 *
277 * This function adds to @p array the list of modules found in
278 * @p path. If @p recursive is #EINA_TRUE, then recursive search is
279 * done. The callback @p cb is called on each module found, and @p data
280 * is passed to @p cb. If @p path is @c NULL, the function returns
281 * immediately @p array. If the returned value of @p cb is 0, the
282 * module will not be added to the list, otherwise it will be added.
283 * @p array can be @c NULL. In that case, it is created with 4
284 * elements. @p cb can be @c NULL.
285 */
286EAPI Eina_Array *
287 eina_module_list_get(Eina_Array *array, const char *path, Eina_Bool recursive, Eina_Module_Cb cb, void *data) EINA_MALLOC EINA_WARN_UNUSED_RESULT;
288
289/**
290 * @brief Load every module on the list of modules.
291 *
292 * @param array The array of modules to load.
293 *
294 * This function calls eina_module_load() on each element found in
295 * @p array. If @p array is @c NULL, this function does nothing.
296 */
297EAPI void
298 eina_module_list_load(Eina_Array *list) EINA_ARG_NONNULL(1);
299
300/**
301 * @brief Unload every module on the list of modules.
302 *
303 * @param array The array of modules to unload.
304 *
305 * This function calls eina_module_unload() on each element found in
306 * @p array. If @p array is @c NULL, this function does nothing.
307 */
308EAPI void
309 eina_module_list_unload(Eina_Array *list) EINA_ARG_NONNULL(1);
310
311/**
312 * @p Free every module on the list of modules.
313 *
314 * @param array The array of modules to free.
315 *
316 * This function calls eina_module_free() on each element found in
317 * @p array. If @p array is @c NULL, this function does nothing.
318 */
319EAPI void
320 eina_module_list_free(Eina_Array *list) EINA_ARG_NONNULL(1);
321
322/**
323 * @brief Find an module in array.
324 *
325 * @param array The array to find the module.
326 * @param module The name of module to be searched.
327 *
328 * This function finds an @p module in @p array.
329 * If the element is found the function returns the module, else
330 * @c NULL is returned.
331 */
332EAPI Eina_Module *
333 eina_module_find(const Eina_Array *array, const char *module) EINA_ARG_NONNULL(1, 2);
334
335/**
336 * @}
337 */
338
339/**
340 * @}
341 */
342
343#endif /*EINA_MODULE_H_*/
diff --git a/libraries/eina/src/include/eina_prefix.h b/libraries/eina/src/include/eina_prefix.h
new file mode 100644
index 0000000..b59080b
--- /dev/null
+++ b/libraries/eina/src/include/eina_prefix.h
@@ -0,0 +1,228 @@
1#ifndef EINA_PREFIX_H_
2#define EINA_PREFIX_H_
3
4/**
5 * @addtogroup Eina_Prefix_Group Prefix Group
6 *
7 * @brief These functions provide the ability to determine the runtime
8 * location of a software package
9 *
10 * @{
11 *
12 * @since 1.1.0
13 */
14
15/**
16 * @typedef Eina_Prefix
17 * This is a prefix object that is returned by eina_prefix_new() when trying
18 * to determine the runtime location of the software in question so other
19 * data files such as images, sound files, other executable utilities,
20 * libraries, modules and locale files can be found.
21 *
22 * @since 1.1.0
23 */
24typedef struct _Eina_Prefix Eina_Prefix;
25
26/**
27 * @brief Create a new prefix handle given some input information
28 *
29 * @param argv0 If this is an executable this is argv[0] of the binary, or NULL if it is used from a shared library
30 * @param symbol This is a symbol (function for example) inside the binary or library to find the source location of. Provide NULL if not used
31 * @param envprefix This is the prefix to any environment variables that may override prefix detection and give the exact location of the software
32 * @param sharedir This is the directory inside the standard share or data dir where the software will store data files
33 * @param magicsharefile This is a magic file to check existence of to determine the prefix find was correct, and it must be located in the data dir under the share dir provided above, or NULL if the check is not to be done
34 * @param pkg_bin This is the compile-time binary install dir
35 * @param pkg_lib This is the compile-time library install dir
36 * @param pkg_data This is the compile-time share/data install dir
37 * @param pkg_locale This is the compile-time locale install dir
38 * @return The prefix handle, or NULL on failure
39 *
40 * Applications and libraries are most often not just single executables nor
41 * single shared library binares, but also come with extra modules they
42 * have to load, extra binary utilities they need to run, or have data files
43 * they need to load. A very primitve application ASSUMES a fixed install
44 * location at compile-time, but this disallows the ability to re-locate
45 * the application (or library) somewhere else after compilation (if you run
46 * out of space on a given disk, partition etc. for example), or necessitate
47 * the need for having to maintain environment variables for every piece of
48 * software to let it know its location, or have to use large sets of
49 * symlinks pointing from the compiled location to the new one.
50 *
51 * Being re-locatable at runtime allows much easier distribution and
52 * installation into places like the users own home directory, instead of
53 * on a system partition, if the developer wishes for easier distribution
54 * of pre-compiled binaries.
55 *
56 * The prefix system is designed to locate where the given software is
57 * installed (under a common prefix) at runtime and then report specific
58 * locations of this prefix and common directories inside this prefix like
59 * the binary, library, data and locale directories.
60 *
61 * To do this some information needs to be provided to eina_prefix_new(). If
62 * you have developed a binary executable, then provide argv[0] as the @p argv0
63 * argument. This plus the PATH environment variable help the prefix system
64 * to determine its location. Call eina_prefix_new() early on before you
65 * change working directory or anything about argv[0] so it gets accurate
66 * information. It will use the first argument, being the executable itself,
67 * to look in absolute directories, relative paths and PATH to see if it
68 * finds the right executable to determine just where the actual binary is
69 * installed and being run from. If you develop a share library, just pass
70 * NULL as argv0
71 *
72 * It would prefer to use the @p symbol function to determine location as
73 * that function will be unique inside the application and try and trace
74 * back which file this function comes from (be it a binary or shared library)
75 * as this avoids more expensive searches via @p argv0. It will use this
76 * symbol if given in preference to argv0.
77 *
78 * The @p envprefix parameter, provides a string prefix to prepend before
79 * environment variables to allow a fallback to specific environment variables
80 * to locate the software. For example if "MYAPP" is provided a the prefix,
81 * then it uses "MYAPP_PREFIX" as a master environment variable to specify
82 * the exact install prefix for the software, or more specific environment
83 * variables like "MYAPP_BIN_DIR", "MYAPP_LIB_DIR", "MYAPP_DATA_DIR" and
84 * "MYAPP_LOCALE_DIR" which can be set by the user or scripts before
85 * launching. If not provided (NULL) environment variables will not be
86 * used to override compiled-in defaults or auto detections.
87 *
88 * The @p sharedir string provides a subdirectory inside the system shared
89 * data dir for data files. For example, if the system dir is
90 * /usr/local/share then this dir name is appended, creating
91 * /usr/local/share/appname if this dir was the "appname" string. It is
92 * expected the application or library installs data files in this directory.
93 *
94 * The @p magicsharefile is a filename or path of something inside the share
95 * or data dir to be used to test that the prefix detection worked. For
96 * example, your app will install a wallpaper image as
97 * /usr/local/share/appname/images/wallpaper.jpg and so to check that this
98 * worked, provide "images/wallpaper.jpg" as the @p magicsharefile string
99 * so detection can know if it worked or not.
100 *
101 * The @p pkg_bin, @p pkg_lib, @p pkg_data and @p pkg_locale are compile-time
102 * strings (the kind standard autoconf/automake define) to be passed in
103 * so there can be a fallback to compiled-in defaults as well as use them
104 * to determine actual names of directories like libdirs maybe changing to
105 * be lib32 or lib64 instead of lib etc.
106 *
107 * Compile the following defining at compile time your prefixes like (example):
108 *
109 * gcc appname.c -o appname \
110 * -DPACKAGE_BIN_DIR=/usr/local/bin \
111 * -DPACKAGE_LIB_DIR=/usr/local/lib \
112 * -DPACKAGE_DATA_DIR=/usr/local/share/appname \
113 * -DLOCALE_DIR=/usr/local/share/locale
114 *
115 * (of course add appropriate compile flags to linking etc. etc. and note that
116 * locale dir is optional. if you don't need it provide data dir as the
117 * locale dir. also note that the magicsharefile is optional for testing and
118 * ensuring that the prefix check is correct. this file must be installed
119 * in the application data dir (eg /usr/local/share/appname) and be referred
120 * to using a unix-style relative path from that dir, eg directory/filename.png)
121 *
122 * @code
123 * static Eina_Prefix *pfx = NULL;
124 *
125 * int main(argc, char **argv)
126 * {
127 * pfx = eina_prefix_new(argv[0], main, "APPNAME", "appname", NULL,
128 * PACKAGE_BIN_DIR, PACKAGE_LIB_DIR,
129 * PACKAGE_DATA_DIR, LOCALE_DIR);
130 * if (!pfx) printf("ERROR: Critical error in finding prefix\n");
131 * printf("install prefix is: %s\n", eina_prefix_get(pfx));
132 * printf("binaries are in: %s\n", eina_prefix_bin_get(pfx));
133 * printf("libraries are in: %s\n", eina_prefix_lib_get(pfx));
134 * printf("data files are in: %s\n", eina_prefix_data_get(pfx));
135 * eina_prefix_free(pfx);
136 * }
137 * @endcode
138 *
139 * @since 1.1.0
140 */
141EAPI Eina_Prefix *
142eina_prefix_new(const char *argv0, void *symbol, const char *envprefix,
143 const char *sharedir, const char *magicsharefile,
144 const char *pkg_bin, const char *pkg_lib,
145 const char *pkg_data, const char *pkg_locale);
146
147/**
148 * @brief Free the prefix object and all its contents
149 *
150 * @param pfx The prefix object
151 *
152 * Free the prefix object and all its allocated content. It will be invalid
153 * to access the object after being freed.
154 *
155 * @since 1.1.0
156 */
157EAPI void
158eina_prefix_free(Eina_Prefix *pfx);
159
160/**
161 * @brief Get the prefix base directory
162 *
163 * @param pfx The prefix object
164 *
165 * This returns the base prefix (eg "/usr/local", "/usr", "/opt/appname" or
166 * "/home/user/myapps/appname" etc.) that the software resides in at runtime.
167 *
168 * @since 1.1.0
169 */
170EAPI const char *
171eina_prefix_get(Eina_Prefix *pfx);
172
173/**
174 * @brief Get the binary installation directory
175 *
176 * @param pfx The prefix object
177 *
178 * This returns the location of installed binaries (eg "/usr/local/bin",
179 * "/usr/bin", "/opt/appname/bin", "/home/user/myapps/appname/bin" etc.).
180 *
181 * @since 1.1.0
182 */
183EAPI const char *
184eina_prefix_bin_get(Eina_Prefix *pfx);
185
186/**
187 * @brief Get the library installation directory
188 *
189 * @param pfx The prefix object
190 *
191 * This returns the location of installed binaries (eg "/usr/local/lib",
192 * "/usr/lib32", "/opt/appname/lib64", "/home/user/myapps/appname/lib" etc.).
193 *
194 * @since 1.1.0
195 */
196EAPI const char *
197eina_prefix_lib_get(Eina_Prefix *pfx);
198
199/**
200 * @brief Get the data installation directory
201 *
202 * @param pfx The prefix object
203 *
204 * This returns the location of installed binaries (eg "/usr/local/share/appname",
205 * "/usr/share/appname", "/opt/appname/share/appname", "/home/user/myapps/appname/share/appname" etc.).
206 *
207 * @since 1.1.0
208 */
209EAPI const char *
210eina_prefix_data_get(Eina_Prefix *pfx);
211
212/**
213 * @brief Get the locale installation directory
214 *
215 * @param pfx The prefix object
216 *
217 * This returns the location of installed binaries (eg "/usr/local/share/locale",
218 * "/usr/share/locale", "/opt/appname/share/locale", "/home/user/myapps/appname/share/locale" etc.).
219 *
220 * @since 1.1.0
221 */
222EAPI const char *
223eina_prefix_locale_get(Eina_Prefix *pfx);
224
225/**
226 * @}
227 */
228#endif
diff --git a/libraries/eina/src/include/eina_quadtree.h b/libraries/eina/src/include/eina_quadtree.h
new file mode 100644
index 0000000..2638d8b
--- /dev/null
+++ b/libraries/eina/src/include/eina_quadtree.h
@@ -0,0 +1,53 @@
1/* EINA - EFL data type library
2 * Copyright (C) 2010 Cedric BAIL
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library;
16 * if not, see <http://www.gnu.org/licenses/>.
17 */
18
19#ifndef EINA_QUADTREE_H_
20#define EINA_QUADTREE_H_
21
22#include "eina_config.h"
23
24#include "eina_inlist.h"
25
26typedef struct _Eina_QuadTree Eina_QuadTree;
27typedef struct _Eina_QuadTree_Item Eina_QuadTree_Item;
28
29typedef enum {
30 EINA_QUAD_LEFT,
31 EINA_QUAD_RIGHT,
32 EINA_QUAD_BOTH
33} Eina_Quad_Direction;
34
35typedef Eina_Quad_Direction (*Eina_Quad_Callback)(const void *object, size_t middle);
36
37EAPI Eina_QuadTree *eina_quadtree_new(size_t w, size_t h, Eina_Quad_Callback vertical, Eina_Quad_Callback horizontal);
38EAPI void eina_quadtree_free(Eina_QuadTree *q);
39EAPI void eina_quadtree_resize(Eina_QuadTree *q, size_t w, size_t h);
40
41EAPI void eina_quadtree_cycle(Eina_QuadTree *q);
42EAPI void eina_quadtree_increase(Eina_QuadTree_Item *object);
43
44EAPI Eina_QuadTree_Item *eina_quadtree_add(Eina_QuadTree *q, const void *object);
45EAPI Eina_Bool eina_quadtree_del(Eina_QuadTree_Item *object);
46EAPI Eina_Bool eina_quadtree_change(Eina_QuadTree_Item *object);
47EAPI Eina_Bool eina_quadtree_hide(Eina_QuadTree_Item *object);
48EAPI Eina_Bool eina_quadtree_show(Eina_QuadTree_Item *object);
49
50EAPI Eina_Inlist *eina_quadtree_collide(Eina_QuadTree *q, int x, int y, int w, int h);
51EAPI void *eina_quadtree_object(Eina_Inlist *list);
52
53#endif
diff --git a/libraries/eina/src/include/eina_rbtree.h b/libraries/eina/src/include/eina_rbtree.h
new file mode 100644
index 0000000..8e5b730
--- /dev/null
+++ b/libraries/eina/src/include/eina_rbtree.h
@@ -0,0 +1,271 @@
1/* EINA - EFL data type library
2 * Copyright (C) 2008 Cedric Bail
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library;
16 * if not, see <http://www.gnu.org/licenses/>.
17 */
18
19#ifndef EINA_RBTREE_H__
20#define EINA_RBTREE_H__
21
22#include <stdlib.h>
23
24#include "eina_types.h"
25#include "eina_error.h"
26#include "eina_iterator.h"
27
28/**
29 * @addtogroup Eina_Rbtree_Group Red-Black tree
30 *
31 * @brief These functions provide Red-Black trees management.
32 *
33 * For a brief description look at http://en.wikipedia.org/wiki/Red-black_tree .
34 * This code is largely inspired from a tutorial written by Julienne Walker at :
35 * http://eternallyconfuzzled.com/tuts/datastructures/jsw_tut_rbtree.aspx . The
36 * main difference is that this set of function never allocate any data, making
37 * them particularly useful for memory management.
38 */
39
40/**
41 * @addtogroup Eina_Data_Types_Group Data Types
42 *
43 * @{
44 */
45
46/**
47 * @addtogroup Eina_Containers_Group Containers
48 *
49 * @{
50 */
51
52/**
53 * @defgroup Eina_Rbtree_Group Red-Black tree
54 *
55 * @{
56 */
57
58/**
59 * @typedef Eina_Rbtree_Color
60 * node color.
61 */
62typedef enum {
63 EINA_RBTREE_RED,
64 EINA_RBTREE_BLACK
65} Eina_Rbtree_Color;
66
67/**
68 * @typedef Eina_Rbtree_Direction
69 * walk direction.
70 */
71typedef enum {
72 EINA_RBTREE_LEFT = 0,
73 EINA_RBTREE_RIGHT = 1
74} Eina_Rbtree_Direction;
75
76/**
77 * @typedef Eina_Rbtree
78 * Type for a Red-Black tree node. It should be inlined into user's type.
79 */
80typedef struct _Eina_Rbtree Eina_Rbtree;
81struct _Eina_Rbtree
82{
83 Eina_Rbtree *son[2];
84
85 Eina_Rbtree_Color color : 1;
86};
87
88/**
89 * @def EINA_RBTREE
90 * recommended way to declare the inlined Eina_Rbtree in your type.
91 *
92 * @code
93 * struct my_type {
94 * EINA_RBTREE;
95 * int my_value;
96 * char *my_name;
97 * };
98 * @endcode
99 *
100 * @see EINA_RBTREE_GET()
101 */
102#define EINA_RBTREE Eina_Rbtree __rbtree
103
104/**
105 * @def EINA_RBTREE_GET
106 * access the inlined node if it was created with #EINA_RBTREE.
107 */
108#define EINA_RBTREE_GET(Rbtree) (&((Rbtree)->__rbtree))
109
110/**
111 * @def EINA_RBTREE_CONTAINER_GET
112 * find back the container of an red black tree.
113 */
114#define EINA_RBTREE_CONTAINER_GET(Ptr, Type) ((Type *)((char *)Ptr - offsetof(Type, __rbtree)))
115
116/**
117 * @typedef Eina_Rbtree_Cmp_Node_Cb
118 * Function used compare two nodes and see which direction to navigate.
119 */
120typedef Eina_Rbtree_Direction (*Eina_Rbtree_Cmp_Node_Cb)(const Eina_Rbtree *left, const Eina_Rbtree *right, void *data);
121
122/**
123 * @def EINA_RBTREE_CMP_NODE_CB
124 * Cast using #Eina_Rbtree_Cmp_Node_Cb
125 */
126#define EINA_RBTREE_CMP_NODE_CB(Function) ((Eina_Rbtree_Cmp_Node_Cb)Function)
127
128/**
129 * @typedef Eina_Rbtree_Cmp_Key_Cb
130 * Function used compare node with a given key of specified length.
131 */
132typedef int (*Eina_Rbtree_Cmp_Key_Cb)(const Eina_Rbtree *node, const void *key, int length, void *data);
133/**
134 * @def EINA_RBTREE_CMP_KEY_CB
135 * Cast using #Eina_Rbtree_Cmp_Key_Cb
136 */
137#define EINA_RBTREE_CMP_KEY_CB(Function) ((Eina_Rbtree_Cmp_Key_Cb)Function)
138
139/**
140 * @typedef Eina_Rbtree_Free_Cb
141 * Function used free a node.
142 */
143typedef void (*Eina_Rbtree_Free_Cb)(Eina_Rbtree *node, void *data);
144/**
145 * @def EINA_RBTREE_FREE_CB
146 * Cast using #Eina_Rbtree_Free_Cb
147 */
148#define EINA_RBTREE_FREE_CB(Function) ((Eina_Rbtree_Free_Cb)Function)
149
150
151/**
152 * @brief Insert a new node inside an existing red black tree.
153 *
154 * @param root The root of an exisiting valid red black tree.
155 * @param node The new node to insert.
156 * @param cmp The callback that is able to compare two nodes.
157 * @param data Private data to help the compare function.
158 * @return The new root of the red black tree.
159 *
160 * This function insert a new node in a valid red black tree. NULL is
161 * an empty valid red black tree. The resulting new tree is a valid red
162 * black tree. This function doesn't allocate any data.
163 */
164EAPI Eina_Rbtree *eina_rbtree_inline_insert(Eina_Rbtree *root, Eina_Rbtree *node, Eina_Rbtree_Cmp_Node_Cb cmp, const void *data) EINA_ARG_NONNULL(2, 3) EINA_WARN_UNUSED_RESULT;
165
166/**
167 * @brief Remove a node from an existing red black tree.
168 *
169 * @param root The root of a valid red black tree.
170 * @param node The node to remove from the tree.
171 * @param cmp The callback that is able to compare two nodes.
172 * @param data Private data to help the compare function.
173 * @return The new root of the red black tree.
174 *
175 * This function remove a new node in a valid red black tree that should
176 * contain the node that you are removing. This function will return NULL
177 * when the red black tree got empty. This function doesn't free any data.
178 */
179EAPI Eina_Rbtree *eina_rbtree_inline_remove(Eina_Rbtree *root, Eina_Rbtree *node, Eina_Rbtree_Cmp_Node_Cb cmp, const void *data) EINA_ARG_NONNULL(2, 3) EINA_WARN_UNUSED_RESULT;
180
181/**
182 * @brief Delete all nodes from a valid red black tree.
183 *
184 * @param root The root of a valid red black tree.
185 * @param func The callback that will free each node.
186 * @param data Private data to help the compare function.
187 *
188 */
189EAPI void eina_rbtree_delete(Eina_Rbtree *root, Eina_Rbtree_Free_Cb func, void *data) EINA_ARG_NONNULL(2);
190
191static inline Eina_Rbtree *eina_rbtree_inline_lookup(const Eina_Rbtree *root, const void *key, int length, Eina_Rbtree_Cmp_Key_Cb cmp, const void *data) EINA_PURE EINA_ARG_NONNULL(2, 4) EINA_WARN_UNUSED_RESULT;
192
193
194/**
195 * @brief Returned a new prefix iterator associated to a rbtree.
196 *
197 * @param root The root of rbtree.
198 * @return A new iterator.
199 *
200 * This function returns a newly allocated iterator associated to @p
201 * root. It will iterate the tree using prefix walk. If @p root is @c
202 * NULL, this function still returns a valid iterator that will always
203 * return false on eina_iterator_next(), thus keeping API sane.
204 *
205 * If the memory can not be allocated, NULL is returned and
206 * #EINA_ERROR_OUT_OF_MEMORY is set. Otherwise, a valid iterator is
207 * returned.
208 *
209 * @warning if the rbtree structure changes then the iterator becomes
210 * invalid! That is, if you add or remove nodes this iterator
211 * behavior is undefined and your program may crash!
212 */
213EAPI Eina_Iterator *eina_rbtree_iterator_prefix(const Eina_Rbtree *root) EINA_MALLOC EINA_WARN_UNUSED_RESULT;
214
215/**
216 * @brief Returned a new prefix iterator associated to a rbtree.
217 *
218 * @param root The root of rbtree.
219 * @return A new iterator.
220 *
221 * This function returns a newly allocated iterator associated to @p
222 * root. It will iterate the tree using infix walk. If @p root is @c
223 * NULL, this function still returns a valid iterator that will always
224 * return false on eina_iterator_next(), thus keeping API sane.
225 *
226 * If the memory can not be allocated, NULL is returned and
227 * #EINA_ERROR_OUT_OF_MEMORY is set. Otherwise, a valid iterator is
228 * returned.
229 *
230 * @warning if the rbtree structure changes then the iterator becomes
231 * invalid! That is, if you add or remove nodes this iterator
232 * behavior is undefined and your program may crash!
233 */
234EAPI Eina_Iterator *eina_rbtree_iterator_infix(const Eina_Rbtree *root) EINA_MALLOC EINA_WARN_UNUSED_RESULT;
235
236/**
237 * @brief Returned a new prefix iterator associated to a rbtree.
238 *
239 * @param root The root of rbtree.
240 * @return A new iterator.
241 *
242 * This function returns a newly allocated iterator associated to @p
243 * root. It will iterate the tree using postfix walk. If @p root is @c
244 * NULL, this function still returns a valid iterator that will always
245 * return false on eina_iterator_next(), thus keeping API sane.
246 *
247 * If the memory can not be allocated, NULL is returned and
248 * #EINA_ERROR_OUT_OF_MEMORY is set. Otherwise, a valid iterator is
249 * returned.
250 *
251 * @warning if the rbtree structure changes then the iterator becomes
252 * invalid! That is, if you add or remove nodes this iterator
253 * behavior is undefined and your program may crash!
254 */
255EAPI Eina_Iterator *eina_rbtree_iterator_postfix(const Eina_Rbtree *root) EINA_MALLOC EINA_WARN_UNUSED_RESULT;
256
257#include "eina_inline_rbtree.x"
258
259/**
260 * @}
261 */
262
263/**
264 * @}
265 */
266
267/**
268 * @}
269 */
270
271#endif
diff --git a/libraries/eina/src/include/eina_rectangle.h b/libraries/eina/src/include/eina_rectangle.h
new file mode 100644
index 0000000..57e562c
--- /dev/null
+++ b/libraries/eina/src/include/eina_rectangle.h
@@ -0,0 +1,239 @@
1/* EINA - EFL data type library
2 * Copyright (C) 2007-2008 Jorge Luis Zapata Muga
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library;
16 * if not, see <http://www.gnu.org/licenses/>.
17 */
18
19#ifndef EINA_RECTANGLE_H_
20#define EINA_RECTANGLE_H_
21
22#include "eina_types.h"
23
24/**
25 * @addtogroup Eina_Rectangle_Group Rectangle
26 *
27 * @brief These functions provide rectangle management.
28 */
29
30/**
31 * @addtogroup Eina_Tools_Group Tools
32 *
33 * @{
34 */
35
36/**
37 * @defgroup Eina_Rectangle_Group Rectangle
38 *
39 * @{
40 */
41
42/**
43 * @typedef Eina_Rectangle
44 * Simple rectangle structure.
45 */
46typedef struct _Eina_Rectangle
47{
48 int x; /**< top-left x co-ordinate of rectangle */
49 int y; /**< top-left y co-ordinate of rectangle */
50 int w; /**< width of rectangle */
51 int h; /**< height of rectangle */
52} Eina_Rectangle;
53
54/**
55 * @typedef Eina_Rectangle_Pool
56 * Type for an opaque pool of rectangle.
57 */
58typedef struct _Eina_Rectangle_Pool Eina_Rectangle_Pool;
59
60static inline int eina_spans_intersect(int c1, int l1, int c2, int l2) EINA_WARN_UNUSED_RESULT;
61static inline Eina_Bool eina_rectangle_is_empty(const Eina_Rectangle *r) EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT;
62static inline void eina_rectangle_coords_from(Eina_Rectangle *r, int x, int y, int w, int h) EINA_ARG_NONNULL(1);
63static inline Eina_Bool eina_rectangles_intersect(const Eina_Rectangle *r1, const Eina_Rectangle *r2) EINA_ARG_NONNULL(1, 2) EINA_WARN_UNUSED_RESULT;
64static inline Eina_Bool eina_rectangle_xcoord_inside(const Eina_Rectangle *r, int x) EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT;
65static inline Eina_Bool eina_rectangle_ycoord_inside(const Eina_Rectangle *r, int y) EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT;
66static inline Eina_Bool eina_rectangle_coords_inside(const Eina_Rectangle *r, int x, int y) EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT;
67static inline void eina_rectangle_union(Eina_Rectangle *dst, const Eina_Rectangle *src) EINA_ARG_NONNULL(1, 2);
68static inline Eina_Bool eina_rectangle_intersection(Eina_Rectangle *dst, const Eina_Rectangle *src) EINA_ARG_NONNULL(1, 2) EINA_WARN_UNUSED_RESULT;
69static inline void eina_rectangle_rescale_in(const Eina_Rectangle *out, const Eina_Rectangle *in, Eina_Rectangle *res) EINA_ARG_NONNULL(1, 2, 3);
70static inline void eina_rectangle_rescale_out(const Eina_Rectangle *out, const Eina_Rectangle *in, Eina_Rectangle *res) EINA_ARG_NONNULL(1, 2, 3);
71
72
73/**
74 * @brief Add a rectangle in a new pool.
75 *
76 * @param w The width of the rectangle.
77 * @param h The height of the rectangle.
78 * @return A newly allocated pool on success, @c NULL otherwise.
79 *
80 * This function adds the rectangle of size (@p width, @p height) to a
81 * new pool. If the pool can not be created, @c NULL is
82 * returned. Otherwise the newly allocated pool is returned.
83 */
84EAPI Eina_Rectangle_Pool *eina_rectangle_pool_new(int w, int h) EINA_MALLOC EINA_WARN_UNUSED_RESULT;
85
86/**
87 * @brief Return the pool of the given rectangle.
88 *
89 * @param rect The rectangle.
90 * @return The pool of the given rectangle.
91 *
92 * This function returns the pool in which @p rect is. If @p rect is
93 * @c NULL, @c NULL is returned.
94 */
95EAPI Eina_Rectangle_Pool *eina_rectangle_pool_get(Eina_Rectangle *rect) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1);
96
97/**
98 * @brief Return the width and height of the given pool.
99 *
100 * @param pool The pool.
101 * @param w The returned width.
102 * @param h The returned height.
103 * @return #EINA_TRUE on success, #EINA_FALSE otherwise.
104 *
105 * This function returns the width and height of @p pool and store
106 * them in respectively @p w and @p h if they are not @c NULL. If
107 * @p pool is @c NULL, #EINA_FALSE is returned. Otherwise #EINA_TRUE is
108 * returned.
109 */
110EAPI Eina_Bool eina_rectangle_pool_geometry_get(Eina_Rectangle_Pool *pool, int *w, int *h) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT;
111
112/**
113 * @brief Get the data from the given pool.
114 *
115 * @param pool The pool.
116 * @return The returned data.
117 *
118 * This function gets the data from @p pool set by
119 * eina_rectangle_pool_data_set(). If @p pool is @c NULL, this
120 * function returns @c NULL.
121 */
122EAPI void *eina_rectangle_pool_data_get(Eina_Rectangle_Pool *pool) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1);
123
124/**
125 * @brief Set the data to the given pool.
126 *
127 * @param pool The pool.
128 * @param data The data to set.
129 *
130 * This function sets @p data to @p pool. If @p pool is @c NULL, this
131 * function does nothing.
132 */
133EAPI void eina_rectangle_pool_data_set(Eina_Rectangle_Pool *pool, const void *data) EINA_ARG_NONNULL(1);
134
135/**
136 * @brief Free the given pool.
137 *
138 * @param pool The pool to free.
139 *
140 * This function frees the allocated data of @p pool. If @p pool is
141 * @c NULL, ths function returned immediately.
142 */
143EAPI void eina_rectangle_pool_free(Eina_Rectangle_Pool *pool) EINA_ARG_NONNULL(1);
144
145/**
146 * @brief Return the number of rectangles in the given pool.
147 *
148 * @param pool The pool.
149 * @return The number of rectangles in the pool.
150 *
151 * This function returns the number of rectangles in @p pool.
152 */
153EAPI int eina_rectangle_pool_count(Eina_Rectangle_Pool *pool) EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT;
154
155/**
156 * @brief Request a rectangle of given size in the given pool.
157 *
158 * @param pool The pool.
159 * @param w The width of the rectangle to request.
160 * @param h The height of the rectangle to request.
161 * @return The requested rectangle on success, @c NULL otherwise.
162 *
163 * This function retrieve from @p pool the rectangle of width @p w and
164 * height @p h. If @p pool is @c NULL, or @p w or @p h are non-positive,
165 * the function returns @c NULL. If @p w or @p h are greater than the
166 * pool size, the function returns @c NULL. On success, the function
167 * returns the rectangle which matches the size (@p w, @p h).
168 * Otherwise it returns @c NULL.
169 */
170EAPI Eina_Rectangle *eina_rectangle_pool_request(Eina_Rectangle_Pool *pool, int w, int h) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1);
171
172/**
173 * @brief Remove the given rectangle from the pool.
174 *
175 * @param rect The rectangle to remove from the pool.
176 *
177 * This function removes @p rect from the pool. If @p rect is
178 * @c NULL, the function returns immediately. Otherwise it remoes @p
179 * rect from the pool.
180 */
181EAPI void eina_rectangle_pool_release(Eina_Rectangle *rect) EINA_ARG_NONNULL(1);
182
183/**
184 * @def EINA_RECTANGLE_SET
185 * @brief Macro to set the values of a #Eina_Rectangle.
186 *
187 * @param Rectangle The rectangle to set the values.
188 * @param X The X coordinate of the top left corner of the rectangle.
189 * @param Y The Y coordinate of the top left corner of the rectangle.
190 * @param W The width of the rectangle.
191 * @param H The height of the rectangle.
192 *
193 * This macro set the values of @p Rectangle. (@p X, @p Y) is the
194 * coordinates of the top left corner of @p Rectangle, @p W is its
195 * width and @p H is its height.
196 */
197#define EINA_RECTANGLE_SET(Rectangle, X, Y, W, H) \
198 (Rectangle)->x = X; \
199 (Rectangle)->y = Y; \
200 (Rectangle)->w = W; \
201 (Rectangle)->h = H;
202
203
204/**
205 * @brief Create a new rectangle.
206 *
207 * @param x The X coordinate of the top left corner of the rectangle.
208 * @param y The Y coordinate of the top left corner of the rectangle.
209 * @param w The width of the rectangle.
210 * @param h The height of the rectangle.
211 * @return The new rectangle on success, @ NULL otherwise.
212 *
213 * This function creates a rectangle which top left corner has the
214 * coordinates (@p x, @p y), with height @p w and height @p h and adds
215 * it to the rectangles pool. No check is done on @p w and @p h. This
216 * function returns a new rectangle on success, @c NULL otherwhise.
217 */
218EAPI Eina_Rectangle *eina_rectangle_new(int x, int y, int w, int h) EINA_MALLOC EINA_WARN_UNUSED_RESULT;
219
220/**
221 * @brief Free the given rectangle.
222 *
223 * @param rect The rectangle to free.
224 *
225 * This function removes @p rect from the rectangles pool.
226 */
227EAPI void eina_rectangle_free(Eina_Rectangle *rect) EINA_ARG_NONNULL(1);
228
229#include "eina_inline_rectangle.x"
230
231/**
232 * @}
233 */
234
235/**
236 * @}
237 */
238
239#endif /*_EINA_RECTANGLE_H_*/
diff --git a/libraries/eina/src/include/eina_refcount.h b/libraries/eina/src/include/eina_refcount.h
new file mode 100644
index 0000000..6650b01
--- /dev/null
+++ b/libraries/eina/src/include/eina_refcount.h
@@ -0,0 +1,76 @@
1/* EINA - EFL data type library
2 * Copyright (C) 20011 Cedric Bail
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library;
16 * if not, see <http://www.gnu.org/licenses/>.
17 */
18
19#ifndef EINA_REFCOUNT_H_
20#define EINA_REFCOUNT_H_
21
22/**
23 * @addtogroup Eina_Refcount References counting
24 *
25 * @brief Small macro that simplify references counting.
26 *
27 * References counting is not a difficult task, but you must
28 * handle it correctly every where, and that the issue. This
29 * set of macro do provide helper that will force to use the
30 * correct code in most case and reduce the bug likeliness.
31 * Of course this without affecting speed !
32 */
33
34/**
35 * @addtogroup Eina_Data_Types_Group Data Types
36 *
37 * @{
38 */
39
40/**
41 * @defgroup Eina_Refcount References counting
42 *
43 * @{
44 */
45
46/**
47 * @typedef Eina_Refcount
48 * Inlined references counting type.
49 */
50typedef int Eina_Refcount;
51
52/** Used for declaring a reference counting member in a struct */
53#define EINA_REFCOUNT Eina_Refcount __refcount
54
55/** Used just after allocating a object */
56#define EINA_REFCOUNT_INIT(Variable) (Variable)->__refcount = 1
57
58/** Used when using referring to an object one more time */
59#define EINA_REFCOUNT_REF(Variable) (Variable)->__refcount++
60
61/** Used when removing a reference to an object. The code just after will automatically be called when necessary */
62#define EINA_REFCOUNT_UNREF(Variable) \
63 if (--((Variable)->__refcount) == 0)
64
65/** Get refcounting value */
66#define EINA_REFCOUNT_GET(Variable) (Variable)->__refcount
67
68/**
69 * @}
70 */
71
72/**
73 * @}
74 */
75
76#endif /* EINA_REFCOUNT_H_ */
diff --git a/libraries/eina/src/include/eina_safety_checks.h b/libraries/eina/src/include/eina_safety_checks.h
new file mode 100644
index 0000000..4751e5f
--- /dev/null
+++ b/libraries/eina/src/include/eina_safety_checks.h
@@ -0,0 +1,254 @@
1/* EINA - EFL data type library
2 * Copyright (C) 2008 Gustavo Sverzut Barbieri
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library;
16 * if not, see <http://www.gnu.org/licenses/>.
17 */
18
19#ifndef EINA_SAFETY_CHECKS_H_
20#define EINA_SAFETY_CHECKS_H_
21
22/**
23 * @addtogroup Eina_Tools_Group Tools
24 *
25 * @{
26 */
27
28/**
29 * @defgroup Eina_Safety_Checks_Group Safety Checks
30 *
31 * @warning @c eina_safety_checks.h should only be included by source
32 * files, after all other includes and before the source file
33 * specific includes. By source file specific includes we
34 * mean those that define the functions that are being
35 * checked. The reason for such complexity is the trick to
36 * avoid compiler optimizations. If compilers are told that
37 * some given function will never receive @c NULL
38 * (EINA_ARG_NONNULL(), then compiler will emit a warning if
39 * it detects so (good!) but will remove any checks for that
40 * condition as it believes it will never happen, removing
41 * all safety checks! By including @c eina_safety_checks.h it
42 * will redefine EINA_ARG_NONNULL() to void and compiler
43 * warning will not be emitted, but checks will be there. The
44 * files already processed with the old macro
45 * EINA_ARG_NONNULL() will still work and emit the warnings.
46 *
47 *
48 * @code
49 *
50 * // all these files will emit warning from EINA_ARG_NONNULL()
51 * #include <Evas.h> // third party headers
52 * #include <Ecore.h>
53 * #include <eina_error.h> // eina own header
54 *
55 * #include <eina_safety_checks.h>
56 * // all these files below will NOT emit warning from EINA_ARG_NONNULL(),
57 * // but this is required to have the functions defined there to be checked
58 * // for NULL pointers
59 * #include "my_functions1.h"
60 * #include "my_functions2.h"
61 *
62 * @endcode
63 */
64
65/**
66 * @addtogroup Eina_Safety_Checks_Group Safety Checks
67 *
68 * Safety checks are a set of macros to check for parameters or values
69 * that should never happen, it is similar in concept to assert(), but
70 * will log and return instead of abort() your program.
71 *
72 * Since these cases should never happen, one may wantto keep safety
73 * checks enabled during tests but disable then during deploy, not
74 * doing any checks at all. This is a common requirement for embedded
75 * systems. Whenever to check or not should be set during compile time
76 * by using @c --disable-safety-checks or @c --enable-safety-checks
77 * options to @c configure script.
78 *
79 * Whenever these macros capture an error, EINA_LOG_ERR() will be
80 * called and @c eina_error set to @c EINA_ERROR_SAFETY_FAILED and can
81 * be checked with eina_error_get() after call.
82 *
83 * @see EINA_SAFETY_ON_NULL_RETURN(), EINA_SAFETY_ON_NULL_RETURN_VAL()
84 * and other macros.
85 *
86 * @{
87 */
88
89#include "eina_config.h"
90#include "eina_error.h"
91
92/**
93 * @var EINA_ERROR_SAFETY_FAILED
94 * Error identifier corresponding to safety check failure.
95 */
96EAPI extern Eina_Error EINA_ERROR_SAFETY_FAILED;
97
98#ifdef EINA_SAFETY_CHECKS
99
100#include "eina_log.h"
101
102#define EINA_SAFETY_ON_NULL_RETURN(exp) \
103 do \
104 { \
105 if (EINA_UNLIKELY((exp) == NULL)) \
106 { \
107 eina_error_set(EINA_ERROR_SAFETY_FAILED); \
108 EINA_LOG_ERR("%s", "safety check failed: " # exp " == NULL"); \
109 return; \
110 } \
111 } \
112 while (0)
113
114#define EINA_SAFETY_ON_NULL_RETURN_VAL(exp, val) \
115 do \
116 { \
117 if (EINA_UNLIKELY((exp) == NULL)) \
118 { \
119 eina_error_set(EINA_ERROR_SAFETY_FAILED); \
120 EINA_LOG_ERR("%s", "safety check failed: " # exp " == NULL"); \
121 return (val); \
122 } \
123 } \
124 while (0)
125
126#define EINA_SAFETY_ON_NULL_GOTO(exp, label) \
127 do \
128 { \
129 if (EINA_UNLIKELY((exp) == NULL)) \
130 { \
131 eina_error_set(EINA_ERROR_SAFETY_FAILED); \
132 EINA_LOG_ERR("%s", "safety check failed: " # exp " == NULL"); \
133 goto label; \
134 } \
135 } \
136 while (0)
137
138#define EINA_SAFETY_ON_TRUE_RETURN(exp) \
139 do \
140 { \
141 if (EINA_UNLIKELY(exp)) \
142 { \
143 eina_error_set(EINA_ERROR_SAFETY_FAILED); \
144 EINA_LOG_ERR("%s", "safety check failed: " # exp " is true"); \
145 return; \
146 } \
147 } \
148 while (0)
149
150#define EINA_SAFETY_ON_TRUE_RETURN_VAL(exp, val) \
151 do \
152 { \
153 if (EINA_UNLIKELY(exp)) \
154 { \
155 eina_error_set(EINA_ERROR_SAFETY_FAILED); \
156 EINA_LOG_ERR("%s", "safety check failed: " # exp " is true"); \
157 return val; \
158 } \
159 } \
160 while (0)
161
162#define EINA_SAFETY_ON_TRUE_GOTO(exp, label) \
163 do \
164 { \
165 if (EINA_UNLIKELY(exp)) \
166 { \
167 eina_error_set(EINA_ERROR_SAFETY_FAILED); \
168 EINA_LOG_ERR("%s", "safety check failed: " # exp " is true"); \
169 goto label; \
170 } \
171 } \
172 while (0)
173
174#define EINA_SAFETY_ON_FALSE_RETURN(exp) \
175 do \
176 { \
177 if (EINA_UNLIKELY(!(exp))) \
178 { \
179 eina_error_set(EINA_ERROR_SAFETY_FAILED); \
180 EINA_LOG_ERR("%s", "safety check failed: " # exp " is false"); \
181 return; \
182 } \
183 } \
184 while (0)
185
186#define EINA_SAFETY_ON_FALSE_RETURN_VAL(exp, val) \
187 do \
188 { \
189 if (EINA_UNLIKELY(!(exp))) \
190 { \
191 eina_error_set(EINA_ERROR_SAFETY_FAILED); \
192 EINA_LOG_ERR("%s", "safety check failed: " # exp " is false"); \
193 return val; \
194 } \
195 } \
196 while (0)
197
198#define EINA_SAFETY_ON_FALSE_GOTO(exp, label) \
199 do \
200 { \
201 if (EINA_UNLIKELY(!(exp))) \
202 { \
203 eina_error_set(EINA_ERROR_SAFETY_FAILED); \
204 EINA_LOG_ERR("%s", "safety check failed: " # exp " is false"); \
205 goto label; \
206 } \
207 } \
208 while (0)
209
210#ifdef EINA_ARG_NONNULL
211/* make EINA_ARG_NONNULL void so GCC does not optimize safety checks */
212#undef EINA_ARG_NONNULL
213#define EINA_ARG_NONNULL(idx, ...)
214#endif
215
216#else /* no safety checks */
217
218#define EINA_SAFETY_ON_NULL_RETURN(exp) \
219 do { (void)(!(exp)); } while (0)
220
221#define EINA_SAFETY_ON_NULL_RETURN_VAL(exp, val) \
222 do { if (0 && !(exp)) { (void)val; } } while (0)
223
224#define EINA_SAFETY_ON_NULL_GOTO(exp, label) \
225 do { if (0 && (exp) == NULL) { goto label; } } while (0)
226
227#define EINA_SAFETY_ON_TRUE_RETURN(exp) \
228 do { (void)(exp); } while (0)
229
230#define EINA_SAFETY_ON_TRUE_RETURN_VAL(exp, val) \
231 do { if (0 && (exp)) { (void)val; } } while (0)
232
233#define EINA_SAFETY_ON_TRUE_GOTO(exp, label) \
234 do { if (0 && (exp)) { goto label; } } while (0)
235
236#define EINA_SAFETY_ON_FALSE_RETURN(exp) \
237 do { (void)(!(exp)); } while (0)
238
239#define EINA_SAFETY_ON_FALSE_RETURN_VAL(exp, val) \
240 do { if (0 && !(exp)) { (void)val; } } while (0)
241
242#define EINA_SAFETY_ON_FALSE_GOTO(exp, label) \
243 do { if (0 && !(exp)) { goto label; } } while (0)
244
245#endif /* safety checks macros */
246#endif /* EINA_SAFETY_CHECKS_H_ */
247
248/**
249 * @}
250 */
251
252/**
253 * @}
254 */
diff --git a/libraries/eina/src/include/eina_sched.h b/libraries/eina/src/include/eina_sched.h
new file mode 100644
index 0000000..43f32b9
--- /dev/null
+++ b/libraries/eina/src/include/eina_sched.h
@@ -0,0 +1,39 @@
1/* EINA - EFL data type library
2 * Copyright (C) 2010 ProFUSION embedded systems
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library;
16 * if not, see <http://www.gnu.org/licenses/>.
17 */
18
19#ifndef EINA_SCHED_H_
20#define EINA_SCHED_H_
21
22#include "eina_types.h"
23
24
25/**
26 * @brief Lower priority of current thread.
27 *
28 * It's used by worker threads so they use up background cpu and do not stall
29 * the main thread If current thread is running with real-time priority, we
30 * decrease our priority by @c RTNICENESS. This is done in a portable way.
31 *
32 * Otherwise (we are running with SCHED_OTHER policy) there's no portable way to
33 * set the nice level on current thread. In Linux, it does work and it's the
34 * only one that is implemented as of now. In this case the nice level is
35 * incremented on this thread by @c NICENESS.
36 */
37EAPI void eina_sched_prio_drop(void);
38
39#endif /* EINA_SCHED_H_ */
diff --git a/libraries/eina/src/include/eina_simple_xml_parser.h b/libraries/eina/src/include/eina_simple_xml_parser.h
new file mode 100644
index 0000000..db9a4e1
--- /dev/null
+++ b/libraries/eina/src/include/eina_simple_xml_parser.h
@@ -0,0 +1,386 @@
1/* EINA - EFL data type library
2 * Copyright (C) 2011 Gustavo Sverzut Barbieri
3 * Cedric Bail
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library;
17 * if not, see <http://www.gnu.org/licenses/>.
18 */
19
20#ifndef EINA_SIMPLE_XML_H_
21#define EINA_SIMPLE_XML_H_
22
23#include "eina_config.h"
24
25#include "eina_types.h"
26#include "eina_magic.h"
27#include "eina_inlist.h"
28
29/**
30 * @defgroup Eina_Simple_XML_Group Simple_XML
31 *
32 * Simplistic relaxed SAX-like XML parser.
33 *
34 * This parser is far from being compliant with XML standard, but will
35 * do for most XMLs out there. If you know that your format is simple
36 * and will not vary in future with strange corner cases, then you can
37 * use it safely.
38 *
39 * The parser is SAX like, that is, it will tokenize contents and call
40 * you back so you can take some action. No contents are allocated
41 * during this parser work and it's not recursive, so you can use it
42 * with a very large document without worries.
43 *
44 * It will not validate the document anyhow, neither it will create a
45 * tree hierarchy. That's up to you.
46 *
47 * Accordingly to XML, open tags may contain attributes. This parser
48 * will not tokenize this. If you want you can use
49 * eina_simple_xml_tag_attributes_find() and then
50 * eina_simple_xml_attributes_parse().
51 */
52
53/**
54 * @addtogroup Eina_Tools_Group Tools
55 *
56 * @{
57 */
58
59/**
60 * @defgroup Eina_Simple_XML_Group Simple_XML
61 *
62 * @{
63 */
64
65typedef struct _Eina_Simple_XML_Node Eina_Simple_XML_Node;
66typedef struct _Eina_Simple_XML_Node_Tag Eina_Simple_XML_Node_Root;
67typedef struct _Eina_Simple_XML_Node_Tag Eina_Simple_XML_Node_Tag;
68typedef struct _Eina_Simple_XML_Node_Data Eina_Simple_XML_Node_Data;
69typedef struct _Eina_Simple_XML_Node_Data Eina_Simple_XML_Node_CData;
70typedef struct _Eina_Simple_XML_Node_Data Eina_Simple_XML_Node_Processing;
71typedef struct _Eina_Simple_XML_Node_Data Eina_Simple_XML_Node_Doctype;
72typedef struct _Eina_Simple_XML_Node_Data Eina_Simple_XML_Node_Comment;
73typedef struct _Eina_Simple_XML_Attribute Eina_Simple_XML_Attribute;
74
75struct _Eina_Simple_XML_Attribute
76{
77 EINA_INLIST;
78 EINA_MAGIC;
79
80 Eina_Simple_XML_Node_Tag *parent;
81 const char *key;
82 const char *value;
83};
84
85typedef enum _Eina_Simple_XML_Node_Type
86{
87 EINA_SIMPLE_XML_NODE_ROOT = 0,
88 EINA_SIMPLE_XML_NODE_TAG,
89 EINA_SIMPLE_XML_NODE_DATA,
90 EINA_SIMPLE_XML_NODE_CDATA,
91 EINA_SIMPLE_XML_NODE_PROCESSING,
92 EINA_SIMPLE_XML_NODE_DOCTYPE,
93 EINA_SIMPLE_XML_NODE_COMMENT
94} Eina_Simple_XML_Node_Type;
95
96struct _Eina_Simple_XML_Node
97{
98 EINA_INLIST;
99 EINA_MAGIC;
100
101 Eina_Simple_XML_Node_Tag *parent;
102 Eina_Simple_XML_Node_Type type;
103};
104
105struct _Eina_Simple_XML_Node_Tag
106{
107 Eina_Simple_XML_Node base;
108 Eina_Inlist *children;
109 Eina_Inlist *attributes;
110 const char *name;
111};
112
113struct _Eina_Simple_XML_Node_Data
114{
115 Eina_Simple_XML_Node base;
116 size_t length;
117 char data[];
118};
119
120typedef enum _Eina_Simple_XML_Type
121{
122 EINA_SIMPLE_XML_OPEN = 0, /* <tag attribute="value"> */
123 EINA_SIMPLE_XML_OPEN_EMPTY, /* <tag attribute="value" /> */
124 EINA_SIMPLE_XML_CLOSE, /* </tag> */
125 EINA_SIMPLE_XML_DATA, /* tag text data */
126 EINA_SIMPLE_XML_CDATA, /* <![CDATA[something]]> */
127 EINA_SIMPLE_XML_ERROR, /* error contents */
128 EINA_SIMPLE_XML_PROCESSING, /* <?xml ... ?> <?php .. ?> */
129 EINA_SIMPLE_XML_DOCTYPE, /* <!DOCTYPE html */
130 EINA_SIMPLE_XML_COMMENT, /* <!-- something --> */
131 EINA_SIMPLE_XML_IGNORED /* whatever is ignored by parser, like whitespace */
132} Eina_Simple_XML_Type;
133
134typedef Eina_Bool (*Eina_Simple_XML_Cb)(void *data, Eina_Simple_XML_Type type, const char *content, unsigned offset, unsigned length);
135typedef Eina_Bool (*Eina_Simple_XML_Attribute_Cb)(void *data, const char *key, const char *value);
136
137
138/**
139 * Parse a section of XML string text
140 *
141 * @param buf the input string. May not contain \0 terminator.
142 * @param buflen the input string size.
143 * @param strip whenever this parser should strip leading and trailing
144 * whitespace. These whitespace will still be issued, but as type
145 * #EINA_SIMPLE_XML_IGNORED.
146 * @param func what to call back while parse to do some action. The
147 * first parameter is the given user @a data, the second is the
148 * token type, the third is the pointer to content start (it's
149 * not a NULL terminated string!), the forth is where this
150 * content is located inside @a buf (does not include tag
151 * start, for instance "<!DOCTYPE value>" the offset points at
152 * "value"), the fifth is the size of the content. Whenever this
153 * function return EINA_FALSE the parser will abort. @param
154 * data what to give as context to @a func.
155 *
156 * @return EINA_TRUE on success or EINA_FALSE if it was aborted by user or
157 * parsing error.
158 */
159EAPI Eina_Bool eina_simple_xml_parse(const char *buf, unsigned buflen,
160 Eina_Bool strip,
161 Eina_Simple_XML_Cb func, const void *data);
162
163
164/**
165 * Given the contents of a tag, find where the attributes start.
166 *
167 * The tag contents is returned by eina_simple_xml_parse() when
168 * type is #EINA_SIMPLE_XML_OPEN or #EINA_SIMPLE_XML_OPEN_EMPTY.
169 *
170 * @return pointer to the start of attributes, it can be used
171 * to feed eina_simple_xml_attributes_parse(). NULL is returned
172 * if no attributes were found.
173 */
174EAPI const char * eina_simple_xml_tag_attributes_find(const char *buf, unsigned buflen);
175
176/**
177 * Given a buffer with xml attributes, parse them to key=value pairs.
178 *
179 * @param buf the input string. May not contain \0 terminator.
180 * @param buflen the input string size.
181 * @param func what to call back while parse to do some action. The
182 * first parameter is the given user @a data, the second is the
183 * key (null-terminated) and the last is the value (null
184 * terminated). These strings should not be modified and
185 * reference is just valid until the function return.
186 *
187 * @return EINA_TRUE on success or EINA_FALSE if it was aborted by user or
188 * parsing error.
189 */
190EAPI Eina_Bool eina_simple_xml_attributes_parse(const char *buf, unsigned buflen,
191 Eina_Simple_XML_Attribute_Cb func, const void *data);
192
193/**
194 * Create (and append) new attribute to tag.
195 *
196 * @param parent if provided, will be set in the resulting structure
197 * as well as the attribute will be appended to attributes list.
198 * @param key null-terminated string. Must not be NULL.
199 * @param value null-terminated string. If NULL, the empty string will be used.
200 *
201 * @return newly allocated memory or NULL on error. This memory should be
202 * released with eina_simple_xml_attribute_free() or indirectly
203 * with eina_simple_xml_node_tag_free().
204 */
205EAPI Eina_Simple_XML_Attribute * eina_simple_xml_attribute_new(Eina_Simple_XML_Node_Tag *parent, const char *key, const char *value);
206
207/**
208 * Remove attribute from parent and delete it.
209 *
210 * @param attr attribute to release memory.
211 */
212EAPI void eina_simple_xml_attribute_free(Eina_Simple_XML_Attribute *attr);
213
214
215/**
216 * Create new tag. If parent is provided, it is automatically appended.
217 *
218 * @param parent if provided, will be set in the resulting structure
219 * as well as the tag will be appended to children list.
220 * @param name null-terminated string. Must not be NULL.
221 *
222 * @return newly allocated memory or NULL on error. This memory should be
223 * released with eina_simple_xml_node_tag_free() or indirectly
224 * with eina_simple_xml_node_tag_free() of the parent.
225 */
226EAPI Eina_Simple_XML_Node_Tag * eina_simple_xml_node_tag_new(Eina_Simple_XML_Node_Tag *parent, const char *name);
227
228/**
229 * Remove tag from parent and delete it.
230 *
231 * @param tag to release memory.
232 */
233EAPI void eina_simple_xml_node_tag_free(Eina_Simple_XML_Node_Tag *tag);
234
235
236/**
237 * Create new data. If parent is provided, it is automatically appended.
238 *
239 * @param parent if provided, will be set in the resulting structure
240 * as well as the data will be appended to children list.
241 * @param content string to be used. Must not be NULL.
242 * @param length size in bytes of @a content.
243 *
244 * @return newly allocated memory or NULL on error. This memory should be
245 * released with eina_simple_xml_node_data_free() or indirectly
246 * with eina_simple_xml_node_tag_free() of the parent.
247 */
248EAPI Eina_Simple_XML_Node_Data * eina_simple_xml_node_data_new(Eina_Simple_XML_Node_Tag *parent, const char *contents, size_t length);
249
250/**
251 * Remove data from parent and delete it.
252 *
253 * @param data to release memory.
254 */
255EAPI void eina_simple_xml_node_data_free(Eina_Simple_XML_Node_Data *node);
256
257
258/**
259 * Create new cdata. If parent is provided, it is automatically appended.
260 *
261 * @param parent if provided, will be set in the resulting structure
262 * as well as the cdata will be appended to children list.
263 * @param content string to be used. Must not be NULL.
264 * @param length size in bytes of @a content.
265 *
266 * @return newly allocated memory or NULL on error. This memory should be
267 * released with eina_simple_xml_node_cdata_free() or indirectly
268 * with eina_simple_xml_node_tag_free() of the parent.
269 */
270EAPI Eina_Simple_XML_Node_CData * eina_simple_xml_node_cdata_new(Eina_Simple_XML_Node_Tag *parent, const char *contents, size_t length);
271
272/**
273 * Remove cdata from parent and delete it.
274 *
275 * @param cdata to release memory.
276 */
277EAPI void eina_simple_xml_node_cdata_free(Eina_Simple_XML_Node_Data *node);
278
279
280/**
281 * Create new processing. If parent is provided, it is automatically appended.
282 *
283 * @param parent if provided, will be set in the resulting structure
284 * as well as the processing will be appended to children list.
285 * @param content string to be used. Must not be NULL.
286 * @param length size in bytes of @a content.
287 *
288 * @return newly allocated memory or NULL on error. This memory should be
289 * released with eina_simple_xml_node_processing_free() or indirectly
290 * with eina_simple_xml_node_tag_free() of the parent.
291 */
292EAPI Eina_Simple_XML_Node_Processing * eina_simple_xml_node_processing_new(Eina_Simple_XML_Node_Tag *parent, const char *contents, size_t length);
293
294/**
295 * Remove processing from parent and delete it.
296 *
297 * @param processing to release memory.
298 */
299EAPI void eina_simple_xml_node_processing_free(Eina_Simple_XML_Node_Data *node);
300
301
302/**
303 * Create new doctype. If parent is provided, it is automatically appended.
304 *
305 * @param parent if provided, will be set in the resulting structure
306 * as well as the doctype will be appended to children list.
307 * @param content string to be used. Must not be NULL.
308 * @param length size in bytes of @a content.
309 *
310 * @return newly allocated memory or NULL on error. This memory should be
311 * released with eina_simple_xml_node_doctype_free() or indirectly
312 * with eina_simple_xml_node_tag_free() of the parent.
313 */
314EAPI Eina_Simple_XML_Node_Doctype * eina_simple_xml_node_doctype_new(Eina_Simple_XML_Node_Tag *parent, const char *contents, size_t length);
315
316/**
317 * Remove doctype from parent and delete it.
318 *
319 * @param doctype to release memory.
320 */
321EAPI void eina_simple_xml_node_doctype_free(Eina_Simple_XML_Node_Data *node);
322
323
324/**
325 * Create new comment. If parent is provided, it is automatically appended.
326 *
327 * @param parent if provided, will be set in the resulting structure
328 * as well as the comment will be appended to children list.
329 * @param content string to be used. Must not be NULL.
330 * @param length size in bytes of @a content.
331 *
332 * @return newly allocated memory or NULL on error. This memory should be
333 * released with eina_simple_xml_node_comment_free() or indirectly
334 * with eina_simple_xml_node_tag_free() of the parent.
335 */
336EAPI Eina_Simple_XML_Node_Comment * eina_simple_xml_node_comment_new(Eina_Simple_XML_Node_Tag *parent, const char *contents, size_t length);
337
338/**
339 * Remove comment from parent and delete it.
340 *
341 * @param comment to release memory.
342 */
343EAPI void eina_simple_xml_node_comment_free(Eina_Simple_XML_Node_Data *node);
344
345
346/**
347 * Load a XML node tree based on the given string.
348 *
349 * @param buf the input string. May not contain \0 terminator.
350 * @param buflen the input string size.
351 * @param strip whenever this parser should strip leading and trailing
352 * whitespace.
353 *
354 * @return document root with children tags, or NULL on errors.
355 * Document with errors may return partial tree instead of NULL,
356 * we'll do our best to avoid returning nothing.
357 */
358EAPI Eina_Simple_XML_Node_Root * eina_simple_xml_node_load(const char *buf, unsigned buflen, Eina_Bool strip);
359
360/**
361 * Free node tree build with eina_simple_xml_node_load()
362 *
363 * @param root memory returned by eina_simple_xml_node_load()
364 */
365EAPI void eina_simple_xml_node_root_free(Eina_Simple_XML_Node_Root *root);
366
367/**
368 * Converts the node tree under the given element to a XML string.
369 *
370 * @param node the base node to convert.
371 * @param indent indentation string, or NULL to disable it.
372 *
373 * @param NULL on errors or a newly allocated string on success.
374 */
375EAPI char * eina_simple_xml_node_dump(Eina_Simple_XML_Node *node, const char *indent);
376
377
378/**
379 * @}
380 */
381
382/**
383 * @}
384 */
385
386#endif /* EINA_SIMPLE_XML_H_ */
diff --git a/libraries/eina/src/include/eina_str.h b/libraries/eina/src/include/eina_str.h
new file mode 100644
index 0000000..8b52ab2
--- /dev/null
+++ b/libraries/eina/src/include/eina_str.h
@@ -0,0 +1,325 @@
1#ifndef _EINA_STR_H
2#define _EINA_STR_H
3
4#include <stddef.h>
5#include <string.h>
6
7#include "eina_types.h"
8
9/**
10 * @page tutorial_eina_string Eina String example
11 * @dontinclude eina_str_01.c
12 *
13 * Whenever using eina we need to include it:
14 * @skipline #include
15 * @line #include
16 *
17 * In our main function we declare(and initialize) some variables and initialize
18 * eina:
19 * @until eina_init
20 *
21 * It's frequentely necessary to split a string into its constituent parts,
22 * eina_str_split() make's it easy to do so:
23 * @until printf
24 *
25 * Another common need is to make a string uppercase or lowercase, so let's
26 * create a string and make it uppercase and then make it lowercase again:
27 * @until printf
28 * @until printf
29 *
30 * Next we use eina to check if our @p names string starts or ends with some
31 * values:
32 * @until Has
33 *
34 * When strings will be used in a terminal(or a number of other places) it
35 * necessary to escape certain characters that appear in them:
36 * @until printf
37 *
38 * Much as we previously split a string we will now join two strings:
39 * @until printf
40 *
41 * With strlcpy() we can copy what portion of the @p prologue fits in @p str and
42 * be sure that it's still NULL terminated:
43 * @until printf
44 *
45 * Since we are done with @p prologue and @p str we should free them:
46 * @until free(str
47 *
48 * Finally we see strlcat in action:
49 * @until printf("
50 *
51 * And then shut eina down and exit:
52 * @until }
53 * @example eina_str_01.c
54 */
55/**
56 * @addtogroup Eina_String_Group String
57 *
58 * @brief Provide useful functions for C string manipulation.
59 *
60 * This group of functions allow you to more easily manipulate strings, they
61 * provide functionality not available through string.h.
62 *
63 * @warning Since these functions modify the strings they can't be used with
64 * shared strings(eina_stringshare).
65 *
66 * See an example @ref tutorial_eina_string "here".
67 */
68
69/**
70 * @addtogroup Eina_Tools_Group Tools
71 *
72 * For more information refer to the @ref tutorial_eina_string "string example".
73 *
74 * @{
75 */
76
77/**
78 * @defgroup Eina_String_Group String
79 *
80 * @{
81 */
82
83/* strlcpy implementation for libc's lacking it */
84
85/**
86 * @brief Copy a c-string to another.
87 *
88 * @param dst The destination string.
89 * @param src The source string.
90 * @param siz The size of the destination string.
91 * @return The length of the source string.
92 *
93 * This function copies up to @p siz - 1 characters from the
94 * NUL-terminated string @p src to @p dst, NUL-terminating the result
95 * (unless @p siz is equal to 0). The returned value is the length of
96 * @p src. If the returned value is greater than @p siz, truncation
97 * occurred.
98 *
99 * @note The main difference between eina_strlcpy and strncpy is that this
100 * ensures @p dst is NULL terminated even if no NULL byte is found in the first
101 * @p siz bytes of src.
102 */
103EAPI size_t eina_strlcpy(char *dst, const char *src, size_t siz) EINA_ARG_NONNULL(1, 2);
104
105/**
106 * @brief Append a c-string.
107 *
108 * @param dst The destination string.
109 * @param src The source string.
110 * @param siz The size of the destination string.
111 * @return The length of the source string plus MIN(siz, strlen(initial dst))
112 *
113 * This function appends @p src to @p dst of size @p siz (unlike
114 * strncat, @p siz is the full size of @p dst, not space left). At
115 * most @p siz - 1 characters will be copied. Always NUL terminates
116 * (unless @p siz <= strlen(dst)). This function returns strlen(src) +
117 * MIN(siz, strlen(initial dst)). If the returned value is greater or
118 * equal than @p siz, truncation occurred.
119 */
120EAPI size_t eina_strlcat(char *dst, const char *src, size_t siz) EINA_ARG_NONNULL(1, 2);
121
122
123/**
124 * @brief Check if the given string has the given prefix.
125 *
126 * @param str The string to work with.
127 * @param prefix The prefix to check for.
128 * @return #EINA_TRUE if the string has the given prefix, #EINA_FALSE otherwise.
129 *
130 * This function returns #EINA_TRUE if @p str has the prefix
131 * @p prefix, #EINA_FALSE otherwise. If the length of @p prefix is
132 * greater than @p str, #EINA_FALSE is returned.
133 */
134EAPI Eina_Bool eina_str_has_prefix(const char *str, const char *prefix) EINA_PURE EINA_ARG_NONNULL(1, 2) EINA_WARN_UNUSED_RESULT;
135
136/**
137 * @brief Check if the given string has the given suffix.
138 *
139 * @param str The string to work with.
140 * @param suffix The suffix to check for.
141 * @return #EINA_TRUE if the string has the given suffix, #EINA_FALSE otherwise.
142 *
143 * This function returns #EINA_TRUE if @p str has the suffix
144 * @p suffix, #EINA_FALSE otherwise. If the length of @p suffix is
145 * greater than @p str, #EINA_FALSE is returned.
146 */
147EAPI Eina_Bool eina_str_has_suffix(const char *str, const char *suffix) EINA_PURE EINA_ARG_NONNULL(1, 2) EINA_WARN_UNUSED_RESULT;
148
149/**
150 * @brief Check if the given string has the given extension.
151 *
152 * @param str The string to work with.
153 * @param ext The extension to check for.
154 * @return #EINA_TRUE if the string has the given extension, #EINA_FALSE otherwise.
155 *
156 * This function does the same as eina_str_has_suffix(), except it's case
157 * insensitive.
158 */
159EAPI Eina_Bool eina_str_has_extension(const char *str, const char *ext) EINA_PURE EINA_ARG_NONNULL(1, 2) EINA_WARN_UNUSED_RESULT;
160
161/**
162 * @brief Split a string using a delimiter.
163 *
164 * @param str The string to split.
165 * @param delim The string which specifies the places at which to split the string.
166 * @param max_tokens The maximum number of strings to split string into.
167 * @return A newly-allocated NULL-terminated array of strings or NULL if it
168 * fails to allocate the array.
169 *
170 * This functin splits @p str into a maximum of @p max_tokens pieces,
171 * using the given delimiter @p delim. @p delim is not included in any
172 * of the resulting strings, unless @p max_tokens is reached. If
173 * @p max_tokens is less than @c 1, the string is splitted completely. If
174 * @p max_tokens is reached, the last string in the returned string
175 * array contains the remainder of string. The returned value is a
176 * newly allocated NULL-terminated array of strings or NULL if it fails to
177 * allocate the array. To free it, free the first element of the array and the
178 * array itself.
179 *
180 * @note If you need the number of elements in the returned array see
181 * eina_str_split_full().
182 */
183EAPI char **eina_str_split(const char *string, const char *delimiter, int max_tokens) EINA_ARG_NONNULL(1, 2) EINA_MALLOC EINA_WARN_UNUSED_RESULT;
184
185/**
186 * @brief Split a string using a delimiter and returns number of elements.
187 *
188 * @param str The string to split.
189 * @param delim The string which specifies the places at which to split the string.
190 * @param max_tokens The maximum number of strings to split string into.
191 * @param elements Where to return the number of elements in returned
192 * array (not counting the terminating @c NULL). May be @c NULL.
193 * @return A newly-allocated NULL-terminated array of strings or NULL if it
194 * fails to allocate the array.
195 *
196 * This functin splits @p str into a maximum of @p max_tokens pieces,
197 * using the given delimiter @p delim. @p delim is not included in any
198 * of the resulting strings, unless @p max_tokens is reached. If
199 * @p max_tokens is less than @c 1, the string is splitted completely. If
200 * @p max_tokens is reached, the last string in the returned string
201 * array contains the remainder of string. The returned value is a
202 * newly allocated NULL-terminated array of strings or NULL if it fails to
203 * allocate the array. To free it, free the first element of the array and the
204 * array itself.
205 *
206 * @see eina_str_split()
207 */
208EAPI char **eina_str_split_full(const char *string, const char *delimiter, int max_tokens, unsigned int *elements) EINA_ARG_NONNULL(1, 2, 4) EINA_MALLOC EINA_WARN_UNUSED_RESULT;
209
210
211/**
212 * @brief Join two strings of known length.
213 *
214 * @param dst The buffer to store the result.
215 * @param size Size (in byte) of the buffer.
216 * @param sep The separator character to use.
217 * @param a First string to use, before @p sep.
218 * @param a_len length of @p a.
219 * @param b Second string to use, after @p sep.
220 * @param b_len length of @p b.
221 * @return The number of characters printed.
222 *
223 * This function joins the strings @p a and @p b (in that order) and
224 * separate them with @p sep. The result is stored in the buffer
225 * @p dst and at most @p size - 1 characters will be written and the
226 * string is NULL-terminated. @p a_len is the length of @p a (not
227 * including '\\0') and @p b_len is the length of @p b (not including
228 * '\\0'). This function returns the number of characters printed (not
229 * including the trailing '\\0' used to end output to strings). Just
230 * like snprintf(), it will not write more than @p size bytes, thus a
231 * returned value of @p size or more means that the output was
232 * truncated.
233 *
234 * @see eina_str_join()
235 * @see eina_str_join_static()
236 */
237EAPI size_t eina_str_join_len(char *dst, size_t size, char sep, const char *a, size_t a_len, const char *b, size_t b_len) EINA_ARG_NONNULL(1, 4, 6);
238
239
240/**
241 * @brief Use Iconv to convert a text string from one encoding to another.
242 *
243 * @param enc_from Encoding to convert from.
244 * @param enc_to Encoding to convert to.
245 * @param text The text to convert.
246 * @return The converted text.
247 *
248 * This function converts @p text, encoded in @p enc_from. On success,
249 * the converted text is returned and is encoded in @p enc_to. On
250 * failure, @c NULL is returned. Iconv is used to convert @p text. If
251 * Iconv is not available, @c NULL is returned. When not used anymore,
252 * the returned value must be freed.
253 */
254EAPI char *eina_str_convert(const char *enc_from, const char *enc_to, const char *text) EINA_WARN_UNUSED_RESULT EINA_MALLOC EINA_ARG_NONNULL(1, 2, 3);
255
256
257/**
258 * @brief Escape slashes, spaces and apostrophes in strings.
259 *
260 * @param str The string to escape.
261 * @return The escaped string.
262 *
263 * Escaping is done by adding a slash "\" before any occurrence of slashes "\",
264 * spaces " " or apostrophes "'". This function returns a newly allocated
265 * escaped string on success, @c NULL on failure. When not used anymore, the
266 * returned value must be freed.
267 */
268EAPI char *eina_str_escape(const char *str) EINA_WARN_UNUSED_RESULT EINA_MALLOC EINA_ARG_NONNULL(1);
269
270
271/**
272 * @brief Lowercase all the characters in range [A-Z] in the given string.
273 *
274 * @param str The string to lowercase.
275 *
276 * This function modifies the original string, changing all characters
277 * in [A-Z] to lowercase. If @p str is @c NULL or is an empty string,
278 * this function does nothing.
279 */
280EAPI void eina_str_tolower(char **str);
281
282/**
283 * @brief Uppercase all the characters in range [a-z] in the given string.
284 *
285 * @param str The string to uppercase.
286 *
287 * This function modifies the original string, changing all characters
288 * in [a-z] to uppercase. If @p str is @c NULL or is an empty string,
289 * this function does nothing.
290 */
291EAPI void eina_str_toupper(char **str);
292
293static inline size_t eina_str_join(char *dst, size_t size, char sep, const char *a, const char *b) EINA_ARG_NONNULL(1, 4, 5);
294
295/**
296 * @def eina_str_join_static(dst, sep, a, b)
297 * @brief Join two static strings and store the result in a static buffer.
298 *
299 * @param dst The buffer to store the result.
300 * @param sep The separator character to use.
301 * @param a First string to use, before @p sep.
302 * @param b Second string to use, after @p sep.
303 * @return The number of characters printed.
304 *
305 * This function is similar to eina_str_join_len(), but will assume
306 * string sizes are know using sizeof(X).
307 *
308 * @see eina_str_join()
309 * @see eina_str_join_static()
310 */
311#define eina_str_join_static(dst, sep, a, b) eina_str_join_len(dst, sizeof(dst), sep, a, (sizeof(a) > 0) ? sizeof(a) - 1 : 0, b, (sizeof(b) > 0) ? sizeof(b) - 1 : 0)
312
313static inline size_t eina_strlen_bounded(const char *str, size_t maxlen) EINA_PURE EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1);
314
315#include "eina_inline_str.x"
316
317/**
318 * @}
319 */
320
321/**
322 * @}
323 */
324
325#endif /* EINA_STR_H */
diff --git a/libraries/eina/src/include/eina_strbuf.h b/libraries/eina/src/include/eina_strbuf.h
new file mode 100644
index 0000000..7043575
--- /dev/null
+++ b/libraries/eina/src/include/eina_strbuf.h
@@ -0,0 +1,605 @@
1#ifndef EINA_STRBUF_H
2#define EINA_STRBUF_H
3
4#include <stddef.h>
5#include <stdarg.h>
6
7#include "eina_types.h"
8
9
10/**
11 * @page tutorial_strbuf Eina_Strbuf example
12 * @dontinclude eina_strbuf_01.c
13 *
14 * First thing always is including Eina:
15 * @skipline #include
16 * @until #include
17 *
18 * Next we initialize eina and create a string buffer to play with:
19 * @until strbuf_new
20 *
21 * Here you can see two different ways of creating a buffer with the same
22 * contents. We could create them in simpler ways, but this gives us an
23 * opportunity to demonstrate several functions in action:
24 * @until strbuf_reset
25 * @until strbuf_reset
26 *
27 * Next we use the printf family of functions to create a formated string,
28 * add, remove and replace some content:
29 * @until strbuf_string_get
30 * @until strbuf_string_get
31 * @until strbuf_string_get
32 *
33 * Once done we free our string buffer, shut down Eina and end the application:
34 * @until }
35 *
36 * @example eina_strbuf_01.c
37 */
38/**
39 * @addtogroup Eina_String_Buffer_Group String Buffer
40 *
41 * @brief These functions provide string buffers management.
42 *
43 * The String Buffer data type is designed to be a mutable string,
44 * allowing to append, prepend or insert a string to a buffer.
45 *
46 * For more information see @ref tutorial_strbuf "this example".
47 */
48
49/**
50 * @addtogroup Eina_Data_Types_Group Data Types
51 *
52 * @{
53 */
54
55/**
56 * @defgroup Eina_String_Buffer_Group String Buffer
57 *
58 * @{
59 */
60
61/**
62 * @typedef Eina_Strbuf
63 * Type for a string buffer.
64 */
65typedef struct _Eina_Strbuf Eina_Strbuf;
66
67/**
68 * @brief Create a new string buffer.
69 *
70 * @return Newly allocated string buffer instance.
71 *
72 * This function creates a new string buffer. On error, @c NULL is
73 * returned and Eina error is set to #EINA_ERROR_OUT_OF_MEMORY. To
74 * free the resources, use eina_strbuf_free().
75 *
76 * @see eina_strbuf_free()
77 * @see eina_strbuf_append()
78 * @see eina_strbuf_string_get()
79 */
80EAPI Eina_Strbuf *eina_strbuf_new(void) EINA_MALLOC EINA_WARN_UNUSED_RESULT;
81
82/**
83 * @brief Create a new string buffer using the passed string. The passed
84 * string is used directly as the buffer, it's somehow the opposite function of
85 * @ref eina_strbuf_string_steal . The passed string must be malloced.
86 *
87 * @param str the string to manage
88 * @return Newly allocated string buffer instance.
89 *
90 * This function creates a new string buffer. On error, @c NULL is
91 * returned and Eina error is set to #EINA_ERROR_OUT_OF_MEMORY. To
92 * free the resources, use eina_strbuf_free().
93 *
94 * @see eina_strbuf_free()
95 * @see eina_strbuf_append()
96 * @see eina_strbuf_string_get()
97 * @since 1.1.0
98 */
99EAPI Eina_Strbuf *eina_strbuf_manage_new(char *str) EINA_MALLOC EINA_WARN_UNUSED_RESULT;
100
101/**
102 * @brief Free a string buffer.
103 *
104 * @param buf The string buffer to free.
105 *
106 * This function frees the memory of @p buf. @p buf must have been
107 * created by eina_strbuf_new().
108 */
109EAPI void eina_strbuf_free(Eina_Strbuf *buf) EINA_ARG_NONNULL(1);
110
111/**
112 * @brief Reset a string buffer.
113 *
114 * @param buf The string buffer to reset.
115 *
116 * This function reset @p buf: the buffer len is set to 0, and the
117 * string is set to '\\0'. No memory is free'd.
118 */
119EAPI void eina_strbuf_reset(Eina_Strbuf *buf) EINA_ARG_NONNULL(1);
120
121/**
122 * @brief Append a string to a buffer, reallocating as necessary.
123 *
124 * @param buf The string buffer to append to.
125 * @param str The string to append.
126 * @return #EINA_TRUE on success, #EINA_FALSE on failure.
127 *
128 * This function appends @p str to @p buf. It computes the length of
129 * @p str, so is slightly slower than eina_strbuf_append_length(). If
130 * the length is known beforehand, consider using that variant. If
131 * @p buf can't append it, #EINA_FALSE is returned, otherwise
132 * #EINA_TRUE is returned.
133 *
134 * @see eina_strbuf_append()
135 * @see eina_strbuf_append_length()
136 */
137EAPI Eina_Bool eina_strbuf_append(Eina_Strbuf *buf, const char *str) EINA_ARG_NONNULL(1, 2);
138
139/**
140 * @brief Append an escaped string to a buffer, reallocating as necessary.
141 *
142 * @param buf The string buffer to append to.
143 * @param str The string to append.
144 * @return #EINA_TRUE on success, #EINA_FALSE on failure.
145 *
146 * This function escapes and then appends the string @p str to @p buf. If @p str
147 * can not be appended, #EINA_FALSE is returned, otherwise, #EINA_TRUE is
148 * returned.
149 */
150EAPI Eina_Bool eina_strbuf_append_escaped(Eina_Strbuf *buf, const char *str) EINA_ARG_NONNULL(1, 2);
151
152/**
153 * @brief Append a string to a buffer, reallocating as necessary,
154 * limited by the given length.
155 *
156 * @param buf The string buffer to append to.
157 * @param str The string to append.
158 * @param maxlen The maximum number of characters to append.
159 * @return #EINA_TRUE on success, #EINA_FALSE on failure.
160 *
161 * This function appends at most @p maxlen characters of @p str to
162 * @p buf. It can't append more than the length of @p str. It
163 * computes the length of @p str, so it is slightly slower than
164 * eina_strbuf_append_length(). If the length is known beforehand,
165 * consider using that variant (@p maxlen should then be checked so
166 * that it is greater than the size of @p str). If @p str can not be
167 * appended, #EINA_FALSE is returned, otherwise, #EINA_TRUE is
168 * returned.
169 *
170 * @see eina_strbuf_append()
171 * @see eina_strbuf_append_length()
172 */
173EAPI Eina_Bool eina_strbuf_append_n(Eina_Strbuf *buf, const char *str, size_t maxlen) EINA_ARG_NONNULL(1, 2);
174
175/**
176 * @brief Append a string of exact length to a buffer, reallocating as necessary.
177 *
178 * @param buf The string buffer to append to.
179 * @param str The string to append.
180 * @param length The exact length to use.
181 * @return #EINA_TRUE on success, #EINA_FALSE on failure.
182 *
183 * This function appends @p str to @p buf. @p str must be of size at
184 * most @p length. It is slightly faster than eina_strbuf_append() as
185 * it does not compute the size of @p str. It is useful when dealing
186 * with strings of known size, such as eina_stringshare. If @p buf
187 * can't append it, #EINA_FALSE is returned, otherwise #EINA_TRUE is
188 * returned.
189 *
190 * @see eina_stringshare_length()
191 * @see eina_strbuf_append()
192 * @see eina_strbuf_append_n()
193 */
194EAPI Eina_Bool eina_strbuf_append_length(Eina_Strbuf *buf, const char *str, size_t length) EINA_ARG_NONNULL(1, 2);
195
196/**
197 * @brief Append a character to a string buffer, reallocating as
198 * necessary.
199 *
200 * @param buf The string buffer to append to.
201 * @param c The char to append.
202 * @return #EINA_TRUE on success, #EINA_FALSE on failure.
203 *
204 * This function inserts @p c to @p buf. If it can not insert it,
205 * #EINA_FALSE is returned, otherwise #EINA_TRUE is returned.
206 */
207EAPI Eina_Bool eina_strbuf_append_char(Eina_Strbuf *buf, char c) EINA_ARG_NONNULL(1);
208
209/**
210 * @brief Append a string to a buffer, reallocating as necessary.
211 *
212 * @param buf The string buffer to append to.
213 * @param fmt The string to append.
214 * @return #EINA_TRUE on success, #EINA_FALSE on failure.
215 *
216 * This function appends the string defined by the format @p fmt to @p buf. @p
217 * fmt must be of a valid format for printf family of functions. If it can't
218 * insert it, #EINA_FALSE is returned, otherwise #EINA_TRUE is returned.
219 *
220 * @see eina_strbuf_append()
221 */
222EAPI Eina_Bool eina_strbuf_append_printf(Eina_Strbuf *buf, const char *fmt, ...) EINA_ARG_NONNULL(1, 2) EINA_PRINTF(2, 3);
223
224/**
225 * @brief Append a string to a buffer, reallocating as necessary.
226 *
227 * @param buf The string buffer to append to.
228 * @param fmt The string to append.
229 * @param args The variable arguments.
230 * @return #EINA_TRUE on success, #EINA_FALSE on failure.
231 *
232 * @see eina_strbuf_append_printf()
233 */
234EAPI Eina_Bool eina_strbuf_append_vprintf(Eina_Strbuf *buf, const char *fmt, va_list args) EINA_ARG_NONNULL(1, 2);
235
236/**
237 * @brief Insert a string to a buffer, reallocating as necessary.
238 *
239 * @param buf The string buffer to insert.
240 * @param str The string to insert.
241 * @param pos The position to insert the string.
242 * @return #EINA_TRUE on success, #EINA_FALSE on failure.
243 *
244 * This function inserts @p str to @p buf at position @p pos. It
245 * computes the length of @p str, so is slightly slower than
246 * eina_strbuf_insert_length(). If the length is known beforehand,
247 * consider using that variant. If @p buf can't insert it, #EINA_FALSE
248 * is returned, otherwise #EINA_TRUE is returned.
249 */
250EAPI Eina_Bool eina_strbuf_insert(Eina_Strbuf *buf, const char *str, size_t pos) EINA_ARG_NONNULL(1, 2);
251
252/**
253 * @brief Insert an escaped string to a buffer, reallocating as
254 * necessary.
255 *
256 * @param buf The string buffer to insert to.
257 * @param str The string to insert.
258 * @param pos The position to insert the string.
259 * @return #EINA_TRUE on success, #EINA_FALSE on failure.
260 *
261 * This function escapes and inserts the string @p str to @p buf at
262 * position @p pos. If @p buf can't insert @p str, #EINA_FALSE is
263 * returned, otherwise #EINA_TRUE is returned.
264 */
265EAPI Eina_Bool eina_strbuf_insert_escaped(Eina_Strbuf *buf, const char *str, size_t pos) EINA_ARG_NONNULL(1, 2);
266
267/**
268 * @brief Insert a string to a buffer, reallocating as necessary. Limited by maxlen.
269 *
270 * @param buf The string buffer to insert to.
271 * @param str The string to insert.
272 * @param maxlen The maximum number of chars to insert.
273 * @param pos The position to insert the string.
274 * @return #EINA_TRUE on success, #EINA_FALSE on failure.
275 *
276 * This function inserts @p str to @p buf at position @p pos, with at
277 * most @p maxlen bytes. The number of inserted characters can not be
278 * greater than the length of @p str. It computes the length of
279 * @p str, so is slightly slower than eina_strbuf_insert_length(). If the
280 * length is known beforehand, consider using that variant (@p maxlen
281 * should then be checked so that it is greater than the size of
282 * @p str). If @p str can not be inserted, #EINA_FALSE is returned,
283 * otherwise, #EINA_TRUE is returned.
284 */
285EAPI Eina_Bool eina_strbuf_insert_n(Eina_Strbuf *buf, const char *str, size_t maxlen, size_t pos) EINA_ARG_NONNULL(1, 2);
286
287/**
288 * @brief Insert a string of exact length to a buffer, reallocating as necessary.
289 *
290 * @param buf The string buffer to insert to.
291 * @param str The string to insert.
292 * @param length The exact length to use.
293 * @param pos The position to insert the string.
294 * @return #EINA_TRUE on success, #EINA_FALSE on failure.
295 *
296 * This function inserts @p str to @p buf. @p str must be of size at
297 * most @p length. It is slightly faster than eina_strbuf_insert() as
298 * it does not compute the size of @p str. It is useful when dealing
299 * with strings of known size, such as eina_strngshare. If @p buf
300 * can't insert it, #EINA_FALSE is returned, otherwise #EINA_TRUE is
301 * returned.
302 *
303 * @see eina_stringshare_length()
304 * @see eina_strbuf_insert()
305 * @see eina_strbuf_insert_n()
306 */
307EAPI Eina_Bool eina_strbuf_insert_length(Eina_Strbuf *buf, const char *str, size_t length, size_t pos) EINA_ARG_NONNULL(1, 2);
308
309/**
310 * @brief Insert a character to a string buffer, reallocating as
311 * necessary.
312 *
313 * @param buf The string buffer to insert to.
314 * @param c The char to insert.
315 * @param pos The position to insert the char.
316 * @return #EINA_TRUE on success, #EINA_FALSE on failure.
317 *
318 * This function inserts @p c to @p buf at position @p pos. If @p buf
319 * can't append it, #EINA_FALSE is returned, otherwise #EINA_TRUE is
320 * returned.
321 */
322EAPI Eina_Bool eina_strbuf_insert_char(Eina_Strbuf *buf, char c, size_t pos) EINA_ARG_NONNULL(1);
323
324/**
325 * @brief Insert a string to a buffer, reallocating as necessary.
326 *
327 * @param buf The string buffer to insert.
328 * @param fmt The string to insert.
329 * @param pos The position to insert the string.
330 * @return #EINA_TRUE on success, #EINA_FALSE on failure.
331 *
332 * This function insert a string as described by the format @p fmt to @p buf at
333 * the position @p pos. @p fmt must be of a valid format for printf family of
334 * functions. If it can't insert it, #EINA_FALSE is returned, otherwise
335 * #EINA_TRUE is returned.
336 */
337EAPI Eina_Bool eina_strbuf_insert_printf(Eina_Strbuf *buf, const char *fmt, size_t pos, ...) EINA_ARG_NONNULL(1, 2) EINA_PRINTF(2, 4);
338
339/**
340 * @brief Insert a string to a buffer, reallocating as necessary.
341 *
342 * @param buf The string buffer to insert.
343 * @param fmt The string to insert.
344 * @param pos The position to insert the string.
345 * @param args The variable arguments.
346 * @return #EINA_TRUE on success, #EINA_FALSE on failure.
347 *
348 * @see eina_strbuf_insert_printf
349 */
350EAPI Eina_Bool eina_strbuf_insert_vprintf(Eina_Strbuf *buf, const char *fmt, size_t pos, va_list args) EINA_ARG_NONNULL(1, 2);
351
352/**
353 * @def eina_strbuf_prepend(buf, str)
354 * @brief Prepend the given string to the given buffer
355 *
356 * @param buf The string buffer to prepend to.
357 * @param str The string to prepend.
358 * @return #EINA_TRUE on success, #EINA_FALSE on failure.
359 *
360 * This macro is calling eina_strbuf_insert() at position 0. If @p buf
361 * can't prepend it, #EINA_FALSE is returned, otherwise #EINA_TRUE is
362 * returned.
363 */
364#define eina_strbuf_prepend(buf, str) eina_strbuf_insert(buf, str, 0)
365
366/**
367 * @def eina_strbuf_prepend_escaped(buf, str)
368 * @brief Prepend the given escaped string to the given buffer
369 *
370 * @param buf The string buffer to prepend to.
371 * @param str The string to prepend.
372 * @return #EINA_TRUE on success, #EINA_FALSE on failure.
373 *
374 * This macro is calling eina_strbuf_insert_escaped() at position 0. If
375 * @p buf can't prepend it, #EINA_FALSE is returned, otherwise
376 * #EINA_TRUE is returned.
377 */
378#define eina_strbuf_prepend_escaped(buf, str) eina_strbuf_insert_escaped(buf, str, 0)
379
380/**
381 * @def eina_strbuf_prepend_n(buf, str)
382 * @brief Prepend the given escaped string to the given buffer
383 *
384 * @param buf The string buffer to prepend to.
385 * @param str The string to prepend.
386 * @param maxlen The maximum number of chars to prepend.
387 * @return #EINA_TRUE on success, #EINA_FALSE on failure.
388 *
389 * This macro is calling eina_strbuf_insert_n() at position 0. If
390 * @p buf can't prepend it, #EINA_FALSE is returned, otherwise
391 * #EINA_TRUE is returned.
392 */
393#define eina_strbuf_prepend_n(buf, str, maxlen) eina_strbuf_insert_n(buf, str, maxlen, 0)
394
395/**
396 * @def eina_strbuf_prepend_length(buf, str)
397 * @brief Prepend the given escaped string to the given buffer
398 *
399 * @param buf The string buffer to prepend to.
400 * @param str The string to prepend.
401 * @param length The exact length to use.
402 * @return #EINA_TRUE on success, #EINA_FALSE on failure.
403 *
404 * This macro is calling eina_strbuf_insert_length() at position 0. If
405 * @p buf can't prepend it, #EINA_FALSE is returned, otherwise
406 * #EINA_TRUE is returned.
407 */
408#define eina_strbuf_prepend_length(buf, str, length) eina_strbuf_insert_length(buf, str, length, 0)
409
410/**
411 * @def eina_strbuf_prepend_char(buf, str)
412 * @brief Prepend the given character to the given buffer
413 *
414 * @param buf The string buffer to prepend to.
415 * @param c The character to prepend.
416 * @return #EINA_TRUE on success, #EINA_FALSE on failure.
417 *
418 * This macro is calling eina_strbuf_insert_char() at position 0. If
419 * @p buf can't prepend it, #EINA_FALSE is returned, otherwise
420 * #EINA_TRUE is returned.
421 */
422#define eina_strbuf_prepend_char(buf, c) eina_strbuf_insert_char(buf, c, 0)
423
424/**
425 * @def eina_strbuf_prepend_printf(buf, fmt, ...)
426 * @brief Prepend the given string to the given buffer
427 *
428 * @param buf The string buffer to prepend to.
429 * @param fmt The string to prepend.
430 * @return #EINA_TRUE on success, #EINA_FALSE on failure.
431 *
432 * This macro is calling eina_strbuf_insert_printf() at position 0.If @p buf
433 * can't prepend it, #EINA_FALSE is returned, otherwise #EINA_TRUE is
434 * returned.
435 */
436#define eina_strbuf_prepend_printf(buf, fmt, ...) eina_strbuf_insert_printf(buf, fmt, 0, ## __VA_ARGS__)
437
438/**
439 * @def eina_strbuf_prepend_vprintf(buf, fmt, args)
440 * @brief Prepend the given string to the given buffer
441 *
442 * @param buf The string buffer to prepend to.
443 * @param fmt The string to prepend.
444 * @param args The variable arguments.
445 * @return #EINA_TRUE on success, #EINA_FALSE on failure.
446 *
447 * This macro is calling eina_strbuf_insert_vprintf() at position 0.If @p buf
448 * can't prepend it, #EINA_FALSE is returned, otherwise #EINA_TRUE is
449 * returned.
450 */
451#define eina_strbuf_prepend_vprintf(buf, fmt, args) eina_strbuf_insert_vprintf(buf, fmt, 0, args)
452
453/**
454 * @brief Remove a slice of the given string buffer.
455 *
456 * @param buf The string buffer to remove a slice.
457 * @param start The initial (inclusive) slice position to start
458 * removing, in bytes.
459 * @param end The final (non-inclusive) slice position to finish
460 * removing, in bytes.
461 * @return #EINA_TRUE on success, #EINA_FALSE on failure.
462 *
463 * This function removes a slice of @p buf, starting at @p start
464 * (inclusive) and ending at @p end (non-inclusive). Both values are
465 * in bytes. It returns #EINA_FALSE on failure, #EINA_TRUE otherwise.
466 */
467
468EAPI Eina_Bool eina_strbuf_remove(Eina_Strbuf *buf, size_t start, size_t end) EINA_ARG_NONNULL(1);
469
470/**
471 * @brief Retrieve a pointer to the contents of a string buffer
472 *
473 * @param buf The string buffer.
474 * @return The current string in the string buffer.
475 *
476 * This function returns the string contained in @p buf. The returned
477 * value must not be modified and will no longer be valid if @p buf is
478 * modified. In other words, any eina_strbuf_append() or similar will
479 * make that pointer invalid. The pointer returned by this function <b>must
480 * not</b> be freed.
481 *
482 * @see eina_strbuf_string_steal()
483 */
484EAPI const char *eina_strbuf_string_get(const Eina_Strbuf *buf) EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT;
485
486/**
487 * @brief Steal the contents of a string buffer.
488 *
489 * @param buf The string buffer to steal.
490 * @return The current string in the string buffer.
491 *
492 * This function returns the string contained in @p buf. @p buf is
493 * then initialized and does not own the returned string anymore. The
494 * caller must release the memory of the returned string by calling
495 * free().
496 *
497 * @see eina_strbuf_string_get()
498 */
499EAPI char *eina_strbuf_string_steal(Eina_Strbuf *buf) EINA_MALLOC EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1);
500
501/**
502 * @brief Free the contents of a string buffer but not the buffer.
503 *
504 * @param buf The string buffer to free the string of.
505 *
506 * This function frees the string contained in @p buf without freeing
507 * @p buf.
508 */
509EAPI void eina_strbuf_string_free(Eina_Strbuf *buf) EINA_ARG_NONNULL(1);
510
511/**
512 * @brief Retrieve the length of the string buffer content.
513 *
514 * @param buf The string buffer.
515 * @return The current length of the string, in bytes.
516 *
517 * This function returns the length of @p buf.
518 */
519EAPI size_t eina_strbuf_length_get(const Eina_Strbuf *buf) EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT;
520
521
522/**
523 * @brief Replace the n-th string with an other string.
524 *
525 * @param buf The string buffer to work with.
526 * @param str The string to replace.
527 * @param with The replaceing string.
528 * @param n The number of the fitting string.
529 * @return #EINA_TRUE on success, #EINA_FALSE on failure.
530 *
531 * This function replaces the n-th occurrence of @p str in @p buf with
532 * @p with. It returns #EINA_FALSE on failure, #EINA_TRUE otherwise.
533 */
534EAPI Eina_Bool eina_strbuf_replace(Eina_Strbuf *buf, const char *str, const char *with, unsigned int n) EINA_ARG_NONNULL(1, 2, 3);
535
536/**
537 * @def eina_strbuf_replace_first(buf, str, with)
538 * @brief Prepend the given character to the given buffer
539 *
540 * @param buf The string buffer to work with.
541 * @param str The string to replace.
542 * @param with The replaceing string.
543 * @return #EINA_TRUE on success, #EINA_FALSE on failure.
544 *
545 * This macro is calling eina_strbuf_replace() with the n-th occurrence
546 * equal to @c 1. If @p buf can't replace it, #EINA_FALSE is returned,
547 * otherwise #EINA_TRUE is returned.
548 */
549#define eina_strbuf_replace_first(buf, str, with) eina_strbuf_replace(buf, str, with, 1)
550
551
552/**
553 * @brief Replace all strings with an other string.
554
555 * @param buf the string buffer to work with.
556 * @param str The string to replace.
557 * @param with The replaceing string.
558 * @return How often the string was replaced.
559 *
560 * This function replaces all the occurrences of @p str in @p buf with
561 * the string @p with. This function returns the number of times @p str
562 * has been replaced. On failure, it returns 0.
563 */
564EAPI int eina_strbuf_replace_all(Eina_Strbuf *buf, const char *str, const char *with) EINA_ARG_NONNULL(1, 2, 3);
565
566/**
567 * @brief Trim the string buffer
568
569 * @param buf the string buffer to work with.
570 *
571 * This function skips whitespaces in the beginning and the end of the buffer.
572 */
573EAPI void eina_strbuf_trim(Eina_Strbuf *buf) EINA_ARG_NONNULL(1);
574
575/**
576 * @brief Left trim the string buffer
577
578 * @param buf the string buffer to work with.
579 *
580 * This function skips whitespaces in the beginning of the buffer.
581 */
582EAPI void eina_strbuf_ltrim(Eina_Strbuf *buf) EINA_ARG_NONNULL(1);
583
584/**
585 * @brief Right trim the string buffer
586
587 * @param buf the string buffer to work with.
588 *
589 * This function skips whitespaces in the end of the buffer.
590 */
591EAPI void eina_strbuf_rtrim(Eina_Strbuf *buf) EINA_ARG_NONNULL(1);
592
593/**
594 * @}
595 */
596
597/**
598 * @}
599 */
600
601/**
602 * @}
603 */
604
605#endif /* EINA_STRBUF_H */
diff --git a/libraries/eina/src/include/eina_stringshare.h b/libraries/eina/src/include/eina_stringshare.h
new file mode 100644
index 0000000..af58add
--- /dev/null
+++ b/libraries/eina/src/include/eina_stringshare.h
@@ -0,0 +1,321 @@
1/* EINA - EFL data type library
2 * Copyright (C) 2002-2008 Carsten Haitzler, Jorge Luis Zapata Muga, Cedric Bail
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library;
16 * if not, see <http://www.gnu.org/licenses/>.
17 *
18 * This file incorporates work covered by the following copyright and
19 * permission notice:
20 *
21 * Copyright (C) 2008 Peter Wehrfritz
22 *
23 * Permission is hereby granted, free of charge, to any person obtaining a copy
24 * of this software and associated documentation files (the "Software"), to
25 * deal in the Software without restriction, including without limitation the
26 * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
27 * sell copies of the Software, and to permit persons to whom the Software is
28 * furnished to do so, subject to the following conditions:
29 *
30 * The above copyright notice and this permission notice shall be included in
31 * all copies of the Software and its Copyright notices. In addition publicly
32 * documented acknowledgment must be given that this software has been used if no
33 * source code of this software is made available publicly. This includes
34 * acknowledgments in either Copyright notices, Manuals, Publicity and Marketing
35 * documents or any documentation provided with any product containing this
36 * software. This License does not apply to any software that links to the
37 * libraries provided by this software (statically or dynamically), but only to
38 * the software provided.
39 *
40 * Please see the OLD-COPYING.PLAIN for a plain-english explanation of this notice
41 * and it's intent.
42 *
43 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
44 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
45 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
46 * THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
47 * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
48 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
49 */
50
51#ifndef EINA_STRINGSHARE_H_
52#define EINA_STRINGSHARE_H_
53
54#include <stdarg.h>
55
56#include "eina_types.h"
57
58/**
59 * @page eina_stringshare_example_01_page
60 * @dontinclude eina_stringshare_01.c
61 *
62 * Like all examples we start by including Eina:
63 * @skip #include
64 * @line #include
65 *
66 * Here we declare some variables and initialize eina:
67 * @until eina_init
68 *
69 * We start the substantive part of the example by showing how to make a part
70 * of a string shared and how to get the length of a shared string:
71 * @until stringshare_strlen
72 * As we add shared strings we also need to delete them when done using them:
73 * @line del
74 *
75 * There are many ways of creating shared strings including an equivalent to
76 * sprintf:
77 * @until del
78 *
79 * An equivalent to snprintf:
80 * @until printf
81 *
82 * But the simplest way of creating a shared string is through
83 * eina_stringshare_add():
84 * @until printf
85 *
86 * Sometimes you already have a pointer to a shared string and want to use it,
87 * so to make sure the provider of the pointer won't free it while you're using
88 * it you can increase the shared string's ref count:
89 * @until printf
90 *
91 * Whenever you have a pointer to a shared string and would like to change it's
92 * value you should use eina_stringshare_replace():
93 * @until printf
94 * @warning @b Don't use eina_stringshare_del() followed by
95 * eina_share_common_add(), under some circunstances you might end up deleting
96 * a shared string some other piece of code is using.
97 *
98 * We created str but haven't deleted it yet, and while we called
99 * eina_stringshare_del() on str2, we created it and then increased the ref
100 * count so it's still alive:
101 * @until str2
102 *
103 * You can see the full source code @ref eina_stringshare_example_01 "here".
104 */
105/**
106 * @page eina_stringshare_example_01
107 * @include eina_stringshare_01.c
108 * @example eina_stringshare_01.c
109 */
110/**
111 * @addtogroup Eina_Stringshare_Group Stringshare
112 *
113 * These functions allow you to store a single copy of a string, and use in
114 * multiple places throughout your program.
115 *
116 * This is a method to reduce the number of duplicated strings kept in
117 * memory. It's pretty common for the same strings to be dynamically
118 * allocated repeatedly between applications and libraries, especially in
119 * circumstances where you could have multiple copies of a structure that
120 * allocates the string. So rather than duplicating and freeing these
121 * strings, you request a read-only pointer to an existing string and
122 * only incur the overhead of a hash lookup.
123 *
124 * It sounds like micro-optimizing, but profiling has shown this can have
125 * a significant impact as you scale the number of copies up. It improves
126 * string creation/destruction speed, reduces memory use and decreases
127 * memory fragmentation, so a win all-around.
128 *
129 * The following diagram gives an idea of what happens as you create strings
130 * with eina_stringshare_add():
131 *
132 * @image html eina_stringshare.png
133 * @image latex eina_stringshare.eps height=\textheight
134 *
135 * For more information, see @ref eina_stringshare_example_01_page
136 * "this example".
137 */
138
139/**
140 * @addtogroup Eina_Data_Types_Group Data Types
141 *
142 * @{
143 */
144
145/**
146 * @defgroup Eina_Stringshare_Group Stringshare
147 *
148 * @{
149 */
150
151
152/**
153 * @brief Retrieve an instance of a string for use in a program.
154 *
155 * @param str The string to retrieve an instance of.
156 * @param slen The string size (<= strlen(str)).
157 * @return A pointer to an instance of the string on success.
158 * @c NULL on failure.
159 *
160 * This function retrieves an instance of @p str. If @p str is
161 * @c NULL, then @c NULL is returned. If @p str is already stored, it
162 * is just returned and its reference counter is increased. Otherwise
163 * a duplicated string of @p str is returned.
164 *
165 * This function does not check string size, but uses the
166 * exact given size. This can be used to share_common part of a larger
167 * buffer or substring.
168 *
169 * @see eina_share_common_add()
170 */
171EAPI const char *eina_stringshare_add_length(const char *str, unsigned int slen) EINA_WARN_UNUSED_RESULT;
172
173/**
174 * @brief Retrieve an instance of a string for use in a program.
175 *
176 * @param str The NULL terminated string to retrieve an instance of.
177 * @return A pointer to an instance of the string on success.
178 * @c NULL on failure.
179 *
180 * This function retrieves an instance of @p str. If @p str is
181 * @c NULL, then @c NULL is returned. If @p str is already stored, it
182 * is just returned and its reference counter is increased. Otherwise
183 * a duplicated string of @p str is returned.
184 *
185 * The string @p str must be NULL terminated ('@\0') and its full
186 * length will be used. To use part of the string or non-null
187 * terminated, use eina_stringshare_add_length() instead.
188 *
189 * @see eina_stringshare_add_length()
190 */
191EAPI const char *eina_stringshare_add(const char *str) EINA_WARN_UNUSED_RESULT;
192
193/**
194 * @brief Retrieve an instance of a string for use in a program
195 * from a format string.
196 *
197 * @param fmt The NULL terminated format string to retrieve an instance of.
198 * @return A pointer to an instance of the string on success.
199 * @c NULL on failure.
200 *
201 * This function retrieves an instance of @p fmt. If @p fmt is
202 * @c NULL, then @c NULL is returned. If @p fmt is already stored, it
203 * is just returned and its reference counter is increased. Otherwise
204 * a duplicated string is returned.
205 *
206 * The format string @p fmt must be NULL terminated ('@\0') and its full
207 * length will be used. To use part of the format string or non-null
208 * terminated, use eina_stringshare_nprintf() instead.
209 *
210 * @see eina_stringshare_nprintf()
211 */
212EAPI const char *eina_stringshare_printf(const char *fmt, ...) EINA_WARN_UNUSED_RESULT EINA_PRINTF(1, 2);
213
214/**
215 * @brief Retrieve an instance of a string for use in a program
216 * from a format string.
217 *
218 * @param fmt The NULL terminated format string to retrieve an instance of.
219 * @param args The va_args for @p fmt
220 * @return A pointer to an instance of the string on success.
221 * @c NULL on failure.
222 *
223 * This function retrieves an instance of @p fmt with @p args. If @p fmt is
224 * @c NULL, then @c NULL is returned. If @p fmt with @p args is already stored, it
225 * is just returned and its reference counter is increased. Otherwise
226 * a duplicated string is returned.
227 *
228 * The format string @p fmt must be NULL terminated ('@\0') and its full
229 * length will be used. To use part of the format string or non-null
230 * terminated, use eina_stringshare_nprintf() instead.
231 *
232 * @see eina_stringshare_nprintf()
233 */
234EAPI const char *eina_stringshare_vprintf(const char *fmt, va_list args) EINA_WARN_UNUSED_RESULT;
235
236/**
237 * @brief Retrieve an instance of a string for use in a program
238 * from a format string with size limitation.
239 * @param len The length of the format string to use
240 * @param fmt The format string to retrieve an instance of.
241 * @return A pointer to an instance of the string on success.
242 * @c NULL on failure.
243 *
244 * This function retrieves an instance of @p fmt limited by @p len. If @p fmt is
245 * @c NULL or @p len is < 1, then @c NULL is returned. If the resulting string
246 * is already stored, it is returned and its reference counter is increased.
247 * Otherwise a duplicated string is returned.
248 *
249 * @p len length of the format string will be used. To use the
250 * entire format string, use eina_stringshare_printf() instead.
251 *
252 * @see eina_stringshare_printf()
253 */
254EAPI const char *eina_stringshare_nprintf(unsigned int len, const char *fmt, ...) EINA_WARN_UNUSED_RESULT EINA_PRINTF(2, 3);
255
256/**
257 * Increment references of the given shared string.
258 *
259 * @param str The shared string.
260 * @return A pointer to an instance of the string on success.
261 * @c NULL on failure.
262 *
263 * This is similar to eina_share_common_add(), but it's faster since it will
264 * avoid lookups if possible, but on the down side it requires the parameter
265 * to be shared string. In other words, it must be the return of a previous
266 * call to one of the stringshare functions.
267 *
268 * There is no unref since this is the work of eina_share_common_del().
269 */
270EAPI const char *eina_stringshare_ref(const char *str);
271
272/**
273 * @brief Note that the given string has lost an instance.
274 *
275 * @param str string The given string.
276 *
277 * This function decreases the reference counter associated to @p str
278 * if it exists. If that counter reaches 0, the memory associated to
279 * @p str is freed. If @p str is NULL, the function returns
280 * immediately.
281 *
282 * Note that if the given pointer is not shared or NULL, bad things
283 * will happen, likely a segmentation fault.
284 */
285EAPI void eina_stringshare_del(const char *str);
286
287/**
288 * @brief Note that the given string @b must be shared.
289 *
290 * @param str the shared string to know the length. It is safe to
291 * give NULL, in that case -1 is returned.
292 *
293 * This function is a cheap way to known the length of a shared
294 * string. Note that if the given pointer is not shared, bad
295 * things will happen, likely a segmentation fault. If in doubt, try
296 * strlen().
297 */
298EAPI int eina_stringshare_strlen(const char *str) EINA_PURE EINA_WARN_UNUSED_RESULT;
299
300/**
301 * @brief Dump the contents of the share_common.
302 *
303 * This function dumps all strings in the share_common to stdout with a
304 * DDD: prefix per line and a memory usage summary.
305 */
306EAPI void eina_stringshare_dump(void);
307
308static inline Eina_Bool eina_stringshare_replace(const char **p_str, const char *news) EINA_ARG_NONNULL(1);
309static inline Eina_Bool eina_stringshare_replace_length(const char **p_str, const char *news, unsigned int slen) EINA_ARG_NONNULL(1);
310
311#include "eina_inline_stringshare.x"
312
313/**
314 * @}
315 */
316
317/**
318 * @}
319 */
320
321#endif /* EINA_STRINGSHARE_H_ */
diff --git a/libraries/eina/src/include/eina_tiler.h b/libraries/eina/src/include/eina_tiler.h
new file mode 100644
index 0000000..5272099
--- /dev/null
+++ b/libraries/eina/src/include/eina_tiler.h
@@ -0,0 +1,310 @@
1/* EINA - EFL data type library
2 * Copyright (C) 2007-2008 Jorge Luis Zapata Muga
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library;
16 * if not, see <http://www.gnu.org/licenses/>.
17 */
18
19#ifndef EINA_TILER_H_
20#define EINA_TILER_H_
21
22#include "eina_types.h"
23#include "eina_iterator.h"
24#include "eina_rectangle.h"
25
26/**
27 * @page eina_tiler_example_01
28 * @dontinclude eina_tiler_01.c
29 *
30 * This is an example that illustrates how Eina_Tiler works for a given set of
31 * rectangles. The rectangles must be given in the command line in the form:
32 * <width>x<height>+<x offset>+<y offset>
33 * The example will show two panels, the first(input) will show the given
34 * rectangles(in different colors) and in the seconds(output) it will show the
35 * rectangles given by the tiler. The rectangles will be added one by one every
36 * two seconds. A lot of the example deals with actually painting the rectangles
37 * so we'll skip over quite a bit of code, but you can see all of it in @ref
38 * eina_tiler_01.c "eina_tiler_01.c".
39 *
40 * The first thing of note in our example is the creation of the tiler:
41 * @skipline eina_tiler_new
42 * @note @p maxw and @p maxh are calculated such that the tiler's size will
43 * fully encompass all given rectangles.
44 *
45 * We'll now look at the function that actually adds rectangles to our tiler. It
46 * first checks if we added all rectangles already and if so stops right there:
47 * @dontinclude eina_tiler_01.c
48 * @skip static Eina_Bool
49 * @until }
50 *
51 * Our function then clears all rectangles given to us by tiler from the last
52 * execution. It does this because each rectangle we add may change everything
53 * about the output of eina_tiler:
54 * @until output_rects_reset
55 *
56 * Next we get another rectangle, print it and show it in the input panel:
57 * @until add_input_rect
58 *
59 * We now come to the tiler stuff, we add our new rectangle to it and get a new
60 * iterator for the tiler:
61 * @until itr
62 *
63 * We now iterate over our tiler printing every rect it gives us and sowing it
64 * in the output panel:
65 * @until }
66 *
67 * We of course must remember to free our iterator and that's it for this
68 * function:
69 * @until }
70 *
71 * You should try many different inputs to see how the tiler works, here are a
72 * few suggestions:
73 * @li 100x100+0+0 100x100+200+200
74 * @li 100x100+0+0 100x100+5+5 100x100+10+10 100x100+15+15 100x100+20+20
75 * @li 100x100+0+0 100x100+100+100 100x100+200+0 100x100+0+200 100x100+200+200
76 * @li 10x10+0+0 10x10+10+10 10x10+20+0 10x10+0+20 10x10+20+20
77 *
78 * @example eina_tiler_01.c
79 */
80/**
81 * @addtogroup Eina_Data_Types_Group Data Types
82 *
83 * @{
84 */
85
86/**
87 * @defgroup Eina_Tiler_Group Tiler
88 *
89 * @warning This is a very low level tool, in most situations(for example if
90 * you're using evas) you won't need this.
91 *
92 * @section basic Basic usage
93 *
94 * Eina_Tiler is a tool to facilitate calculations of which areas are damaged
95 * and thus need to be re-rendered. The basic usage of Eina_Tiler is to give it
96 * the size of your canvas and a set of rectangular areas that need
97 * re-rendering, from that and using heuristics it'll tell you an efficient way
98 * to re-render in the form of a set of non-overlapping rectangles that covers
99 * the whole area that needs re-rendering.
100 *
101 * The following is pseudo-code showing some simple use of Eina_Tiler:
102 * @code
103 * tiler = eina_tiler_new(MY_CANVAS_WIDTH, MY_CANVAS_HEIGHT);
104 * EINA_LIST_FOREACH(list_of_areas_that_need_re_rendering, l, rect)
105 * eina_tiler_add(tiler, rect);
106 * itr = eina_tiler_iterator_new(tiler);
107 * EINA_ITERATOR_FOREACH(itr, rect)
108 * my_function_that_repaints_areas_of_the_canvas(rect);
109 * @endcode
110 *
111 * @see eina_tiler_new()
112 * @see eina_tiler_rect_add()
113 * @see eina_tiler_iterator_new()
114 *
115 * @warning There are no guarantees that this will be the most efficient way to
116 * re-render for any particular case.
117 *
118 * @section grid_slicer Grid Slicer
119 *
120 * Grid slicer and Eina_Tiler are usually used together, that is however @b not
121 * nescessary, they can be used independently. Grid slicer provides an easy API
122 * to divide an area in tiles which is usefull in certain applications to divide
123 * the area that will be rendered into tiles. It's customary to, then create one
124 * Eina_Tiler for each tile.
125 *
126 * The following is pseudo-code showing a very simplified use of grid slicer
127 * together with Eina_Tiler:
128 * @code
129 * itr = eina_tile_grid_slicer_iterator_new(0, 0, MY_CANVAS_WIDTH, MY_CANVAS_HEIGHT, TILE_WIDTH, TILE_HEIGHT);
130 * EINA_ITERATOR_FOREACH(itr, grid_info)
131 * {
132 * tiler = eina_tiler_new(grid_info->rect.w, grid_info->rect.w);
133 * EINA_LIST_FOREACH(list_of_areas_that_need_re_rendering_in_this_tile, l, rect)
134 * eina_tiler_add(tiler, rect);
135 * itr = eina_tiler_iterator_new(tiler);
136 * EINA_ITERATOR_FOREACH(itr, rect)
137 * my_function_that_repaints_areas_of_the_canvas(rect);
138 * }
139 * @endcode
140 *
141 * @see eina_tiler_new()
142 * @see eina_tiler_rect_add()
143 * @see eina_tile_grid_slicer_setup()
144 * @see eina_tile_grid_slicer_next()
145 * @see eina_tile_grid_slicer_iterator_new()
146 *
147 * @{
148 */
149
150/**
151 * @typedef Eina_Tiler
152 * Tiler type.
153 */
154typedef struct _Eina_Tiler Eina_Tiler;
155
156/**
157 * @typedef Eina_Tile_Grid_Info
158 * Grid type of a tiler.
159 */
160typedef struct Eina_Tile_Grid_Info Eina_Tile_Grid_Info;
161
162/**
163 * @struct Eina_Tile_Grid_Info
164 * Grid type of a tiler.
165 */
166struct Eina_Tile_Grid_Info
167{
168 unsigned long col; /**< column of the tile grid */
169 unsigned long row; /**< row of the tile grid*/
170 Eina_Rectangle rect; /**< rectangle of the tile grid, coordinates are
171 relative to tile*/
172 Eina_Bool full; /**< whether the grid is full or not */
173};
174
175typedef struct _Eina_Tile_Grid_Slicer Eina_Tile_Grid_Slicer;
176
177/**
178 * @brief Creates a new tiler with @p w width and @p h height.
179 *
180 * @param w Width of the tiler
181 * @param h Height of the tiler
182 * @return The newly created tiler
183 *
184 * @see eina_tiler_free()
185 */
186EAPI Eina_Tiler *eina_tiler_new(int w, int h);
187/**
188 * @brief Frees a tiler.
189 *
190 * @param t The tiler to free.
191 *
192 * This function frees @p t. It does not free the memory allocated for the
193 * elements of @p t.
194 */
195EAPI void eina_tiler_free(Eina_Tiler *t);
196/**
197 * @brief Sets the size of tiles for a tiler.
198 *
199 * @param t The tiler whose tile size will be set.
200 * @param w Width of the tiles.
201 * @param h Height of the tiles.
202 *
203 * @warning @p w and @p h @b must be greater than zero, otherwise tile size
204 * won't be changed.
205 * @warning Tile size is not used!
206 */
207EAPI void eina_tiler_tile_size_set(Eina_Tiler *t, int w, int h);
208/**
209 * @brief Adds a rectangle to a tiler.
210 *
211 * @param t The tiler in which to add a container.
212 * @param r The rectangle to be added.
213 *
214 * @see eina_tiler_rect_del()
215 */
216EAPI Eina_Bool eina_tiler_rect_add(Eina_Tiler *t, const Eina_Rectangle *r);
217/**
218 * @brief Removes a rectangle from a tiler.
219 *
220 * @param t The tiler in which to add a container.
221 * @param r The rectangle to be removed.
222 *
223 * @see eina_tiler_rect_add()
224 * @see eina_tiler_clear()
225 */
226EAPI void eina_tiler_rect_del(Eina_Tiler *t, const Eina_Rectangle *r);
227/**
228 * @brief Removes all rectangles from tiles.
229 *
230 * @param t The tiler to clear.
231 *
232 * @see eina_tiler_rect_del()
233 */
234EAPI void eina_tiler_clear(Eina_Tiler *t);
235/**
236 * @brief Create a iterator to access the tilers calculated rectangles.
237 *
238 * @param t The tiler to iterate over.
239 * @return A iterator containing Eina_Rectangle.
240 */
241EAPI Eina_Iterator *eina_tiler_iterator_new(const Eina_Tiler *t);
242
243/**
244 * @brief Creates a new Eina_Iterator that iterates over a list of tiles.
245 *
246 * @param x X axis coordinate.
247 * @param y Y axis coordinate.
248 * @param w width.
249 * @param h height.
250 * @param tile_w tile width.
251 * @param tile_h tile height.
252 * @return A pointer to the Eina_Iterator. @c NULL on failure.
253 *
254 * The region defined by @a x, @a y, @a w, @a h will be divided in to a grid of
255 * tiles of width @a tile_w and height @p tile_h, the returned iterator will
256 * iterate over every tile in the grid having as its data a
257 * #Eina_Tile_Grid_Info.
258 *
259 * @note This is a convinience function, iterating over the returned iterator is
260 * equivalent to calling eina_tile_grid_slicer_setup() and calling
261 * eina_tile_grid_slicer_next() untill it returns EINA_FALSE.
262 */
263EAPI Eina_Iterator *eina_tile_grid_slicer_iterator_new(int x, int y, int w, int h, int tile_w, int tile_h);
264/**
265 * @brief Iterates over the tiles set by eina_tile_grid_slicer_setup().
266 *
267 * @param slc Pointer to an Eina_Tile_Grid_Slicer struct.
268 * @param rect Pointer to a struct Eina_Tile_Grid_Info *.
269 * @return @c EINA_TRUE if the current rect is valid.
270 * @c EINA_FALSE if there is no more rects to iterate over (and
271 * thus the current one isn't valid).
272 *
273 * This functions iterates over each Eina_Tile_Grid_Info *rect of the grid.
274 * eina_tile_grid_slicer_setup() must be called first, and *rect is only valid
275 * if this function returns EINA_TRUE. Its content shouldn't be modified.
276 *
277 * @note Consider using eina_tile_grid_slicer_iterator_new() instead.
278 */
279static inline Eina_Bool eina_tile_grid_slicer_next(Eina_Tile_Grid_Slicer *slc, const Eina_Tile_Grid_Info **rect);
280/**
281 * @brief Setup an Eina_Tile_Grid_Slicer struct.
282 *
283 * @param slc Pointer to an Eina_Tile_Grid_Slicer struct.
284 * @param x X axis coordinate.
285 * @param y Y axis coordinate.
286 * @param w width.
287 * @param h height.
288 * @param tile_w tile width.
289 * @param tile_h tile height.
290 * @return A pointer to the Eina_Iterator. @c NULL on failure.
291 *
292 * The region defined by @a x, @a y, @a w, @a h will be divided in to a grid of
293 * tiles of width @a tile_w and height @p tile_h, @p slc can then be used with
294 * eina_tile_grid_slicer_next() to access each tile.
295 *
296 * @note Consider using eina_tile_grid_slicer_iterator_new() instead.
297 */
298static inline Eina_Bool eina_tile_grid_slicer_setup(Eina_Tile_Grid_Slicer *slc, int x, int y, int w, int h, int tile_w, int tile_h);
299
300#include "eina_inline_tiler.x"
301
302/**
303 * @}
304 */
305
306/**
307 * @}
308 */
309
310#endif /* EINA_TILER_H_ */
diff --git a/libraries/eina/src/include/eina_trash.h b/libraries/eina/src/include/eina_trash.h
new file mode 100644
index 0000000..f53d99e
--- /dev/null
+++ b/libraries/eina/src/include/eina_trash.h
@@ -0,0 +1,100 @@
1/* EINA - EFL data type library
2 * Copyright (C) 2002-2008 Carsten Haitzler, Vincent Torri, Jorge Luis Zapata Muga
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library;
16 * if not, see <http://www.gnu.org/licenses/>.
17 */
18
19#ifndef EINA_TRASH_H__
20#define EINA_TRASH_H__
21
22/**
23 * @addtogroup Eina_Data_Types_Group Data Types
24 *
25 * @{
26 */
27
28/**
29 * @addtogroup Eina_Containers_Group Containers
30 *
31 * @{
32 */
33
34/**
35 * @defgroup Eina_Trash_Group Trash
36 *
37 * @{
38 */
39
40/**
41 * @typedef Eina_Trash
42 * Type for a generic container of unused allocated pointer.
43 */
44typedef struct _Eina_Trash Eina_Trash;
45
46/**
47 * @struct _Eina_Trash
48 * Type for a generic container of unused allocated pointer.
49 */
50struct _Eina_Trash
51{
52 Eina_Trash *next; /**< next item in trash. */
53};
54
55static inline void eina_trash_init(Eina_Trash **trash) EINA_ARG_NONNULL(1);
56static inline void eina_trash_push(Eina_Trash **trash, void *data) EINA_ARG_NONNULL(1);
57static inline void *eina_trash_pop(Eina_Trash **trash) EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT;
58
59/**
60 * @def EINA_TRASH_CLEAN
61 * @brief Macro to remove all pointer from the trash.
62 *
63 * @param trash The trash to clean.
64 * @param data The pointer extracted from the trash.
65 *
66 * This macro allow the cleaning of @p trash in an easy way. It will
67 * remove all pointers from @p trash until it's empty.
68 *
69 * This macro can be used for freeing the data in the trash, like in
70 * the following example:
71 *
72 * @code
73 * Eina_Trash *trash = NULL;
74 * char *data;
75 *
76 * // trash is filled with pointer to some duped strings.
77 *
78 * EINA_TRASH_CLEAN(&trash, data)
79 * free(data);
80 * @endcode
81 *
82 * @note this macro is useful when you implement some memory pool.
83 */
84#define EINA_TRASH_CLEAN(trash, data) while ((data = eina_trash_pop(trash)))
85
86#include "eina_inline_trash.x"
87
88/**
89 * @}
90 */
91
92/**
93 * @}
94 */
95
96/**
97 * @}
98 */
99
100#endif /* EINA_TRASH_H_ */
diff --git a/libraries/eina/src/include/eina_types.h b/libraries/eina/src/include/eina_types.h
new file mode 100644
index 0000000..8c77cdf
--- /dev/null
+++ b/libraries/eina/src/include/eina_types.h
@@ -0,0 +1,282 @@
1/* EINA - EFL data type library
2 * Copyright (C) 2007-2008 Carsten Haitzler, Vincent Torri, Jorge Luis Zapata Muga
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library;
16 * if not, see <http://www.gnu.org/licenses/>.
17 */
18
19#ifndef EINA_TYPES_H_
20#define EINA_TYPES_H_
21
22/**
23 * @addtogroup Eina_Core_Group Core
24 *
25 * @{
26 */
27
28/**
29 * @defgroup Eina_Types_Group Types
30 *
31 * @{
32 */
33
34#ifdef EAPI
35# undef EAPI
36#endif
37
38#ifdef _WIN32
39# ifdef EFL_EINA_BUILD
40# ifdef DLL_EXPORT
41# define EAPI __declspec(dllexport)
42# else
43# define EAPI
44# endif /* ! DLL_EXPORT */
45# else
46# define EAPI __declspec(dllimport)
47# endif /* ! EFL_EINA_BUILD */
48#else
49# ifdef __GNUC__
50# if __GNUC__ >= 4
51# define EAPI __attribute__ ((visibility("default")))
52# else
53# define EAPI
54# endif
55# else
56# define EAPI
57# endif
58#endif
59
60#include "eina_config.h"
61
62#ifdef EINA_WARN_UNUSED_RESULT
63# undef EINA_WARN_UNUSED_RESULT
64#endif
65#ifdef EINA_ARG_NONNULL
66# undef EINA_ARG_NONNULL
67#endif
68#ifdef EINA_DEPRECATED
69# undef EINA_DEPRECATED
70#endif
71#ifdef EINA_MALLOC
72# undef EINA_MALLOC
73#endif
74#ifdef EINA_PURE
75# undef EINA_PURE
76#endif
77#ifdef EINA_PRINTF
78# undef EINA_PRINTF
79#endif
80#ifdef EINA_SCANF
81# undef EINA_SCANF
82#endif
83#ifdef EINA_FORMAT
84# undef EINA_FORMAT
85#endif
86#ifdef EINA_CONST
87# undef EINA_CONST
88#endif
89#ifdef EINA_NOINSTRUMENT
90# undef EINA_NOINSTRUMENT
91#endif
92#ifdef EINA_UNLIKELY
93# undef EINA_UNLIKELY
94#endif
95#ifdef EINA_LIKELY
96# undef EINA_LIKELY
97#endif
98
99#ifdef __GNUC__
100# if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)
101# define EINA_WARN_UNUSED_RESULT __attribute__ ((warn_unused_result))
102# else
103# define EINA_WARN_UNUSED_RESULT
104# endif
105
106# if (!defined(EINA_SAFETY_CHECKS)) && (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 3))
107# define EINA_ARG_NONNULL(idx, ...) __attribute__ ((nonnull(idx, ## __VA_ARGS__)))
108# else
109# define EINA_ARG_NONNULL(idx, ...)
110# endif
111
112# if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1)
113# define EINA_DEPRECATED __attribute__ ((__deprecated__))
114# else
115# define EINA_DEPRECATED
116# endif
117
118# if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96)
119# define EINA_MALLOC __attribute__ ((malloc))
120# define EINA_PURE __attribute__ ((pure))
121# else
122# define EINA_MALLOC
123# define EINA_PURE
124# endif
125
126# if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ > 4)
127# define EINA_PRINTF(fmt, arg) __attribute__((format (printf, fmt, arg)))
128# define EINA_SCANF(fmt, arg) __attribute__((format (scanf, fmt, arg)))
129# define EINA_FORMAT(fmt) __attribute__((format_arg(fmt)))
130# define EINA_CONST __attribute__((const))
131# define EINA_NOINSTRUMENT __attribute__((no_instrument_function))
132# define EINA_UNLIKELY(exp) __builtin_expect((exp), 0)
133# define EINA_LIKELY(exp) __builtin_expect((exp), 1)
134# else
135# define EINA_PRINTF(fmt, arg)
136# define EINA_SCANF(fmt, arg)
137# define EINA_FORMAT(fmt)
138# define EINA_CONST
139# define EINA_NOINSTRUMENT
140# define EINA_UNLIKELY(exp) exp
141# define EINA_LIKELY(exp) exp
142# endif
143
144#elif defined(_WIN32)
145# define EINA_WARN_UNUSED_RESULT
146# define EINA_ARG_NONNULL(idx, ...)
147# if defined(_MSC_VER) && _MSC_VER >= 1300
148# define EINA_DEPRECATED __declspec(deprecated)
149# else
150# define EINA_DEPRECATED
151# endif
152# define EINA_MALLOC
153# define EINA_PURE
154# define EINA_PRINTF(fmt, arg)
155# define EINA_SCANF(fmt, arg)
156# define EINA_FORMAT(fmt)
157# define EINA_CONST
158# define EINA_NOINSTRUMENT
159# define EINA_UNLIKELY(exp) exp
160# define EINA_LIKELY(exp) exp
161
162#elif defined(__SUNPRO_C)
163# define EINA_WARN_UNUSED_RESULT
164# define EINA_ARG_NONNULL(...)
165# define EINA_DEPRECATED
166# if __SUNPRO_C >= 0x590
167# define EINA_MALLOC __attribute__ ((malloc))
168# define EINA_PURE __attribute__ ((pure))
169# else
170# define EINA_MALLOC
171# define EINA_PURE
172# endif
173# define EINA_PRINTF(fmt, arg)
174# define EINA_SCANF(fmt, arg)
175# define EINA_FORMAT(fmt)
176# if __SUNPRO_C >= 0x590
177# define EINA_CONST __attribute__ ((const))
178# else
179# define EINA_CONST
180# endif
181# define EINA_NOINSTRUMENT
182# define EINA_UNLIKELY(exp) exp
183# define EINA_LIKELY(exp) exp
184
185#else /* ! __GNUC__ && ! _WIN32 && ! __SUNPRO_C */
186
187/**
188 * @def EINA_WARN_UNUSED_RESULT
189 * Used to warn when the returned value of the function is not used.
190 */
191# define EINA_WARN_UNUSED_RESULT
192
193/**
194 * @def EINA_ARG_NONNULL
195 * Used to warn when the specified arguments of the function are @c NULL.
196 */
197# define EINA_ARG_NONNULL(idx, ...)
198
199/**
200 * @def EINA_DEPRECATED
201 * Used to warn when the function is considered as deprecated.
202 */
203# define EINA_DEPRECATED
204# define EINA_MALLOC
205# define EINA_PURE
206# define EINA_PRINTF(fmt, arg)
207# define EINA_SCANF(fmt, arg)
208# define EINA_FORMAT(fmt)
209# define EINA_CONST
210# define EINA_NOINSTRUMENT
211# define EINA_UNLIKELY(exp) exp
212# define EINA_LIKELY(exp) exp
213#endif /* ! __GNUC__ && ! _WIN32 && ! __SUNPRO_C */
214
215/**
216 * @typedef Eina_Bool
217 * Type to mimic a boolean.
218 *
219 * @note it differs from stdbool.h as this is defined as an unsigned
220 * char to make it usable by bitfields (Eina_Bool name:1) and
221 * also take as few bytes as possible.
222 */
223typedef unsigned char Eina_Bool;
224
225/**
226 * @def EINA_FALSE
227 * boolean value FALSE (numerical value 0)
228 */
229#define EINA_FALSE ((Eina_Bool)0)
230
231/**
232 * @def EINA_TRUE
233 * boolean value TRUE (numerical value 1)
234 */
235#define EINA_TRUE ((Eina_Bool)1)
236
237EAPI extern const unsigned int eina_prime_table[];
238
239/**
240 * @typedef Eina_Compare_Cb
241 * Function used in functions using sorting. It compares @p data1 and
242 * @p data2. If @p data1 is 'less' than @p data2, -1 must be returned,
243 * if it is 'greater', 1 must be returned, and if they are equal, 0
244 * must be returned.
245 */
246typedef int (*Eina_Compare_Cb)(const void *data1, const void *data2);
247
248/**
249 * @def EINA_COMPARE_CB
250 * Macro to cast to Eina_Compare_Cb.
251 */
252#define EINA_COMPARE_CB(function) ((Eina_Compare_Cb)function)
253
254typedef Eina_Bool (*Eina_Each_Cb)(const void *container, void *data, void *fdata);
255
256/**
257 * @def EINA_EACH_CB
258 * Macro to cast to Eina_Each.
259 */
260#define EINA_EACH_CB(Function) ((Eina_Each_Cb)Function)
261
262/**
263 * @typedef Eina_Free_Cb
264 * A callback type used to free data when iterating over a container.
265 */
266typedef void (*Eina_Free_Cb)(void *data);
267
268/**
269 * @def EINA_FREE_CB
270 * Macro to cast to Eina_Free_Cb.
271 */
272#define EINA_FREE_CB(Function) ((Eina_Free_Cb)Function)
273
274/**
275 * @}
276 */
277
278/**
279 * @}
280 */
281
282#endif /* EINA_TYPES_H_ */
diff --git a/libraries/eina/src/include/eina_unicode.h b/libraries/eina/src/include/eina_unicode.h
new file mode 100644
index 0000000..aed59af
--- /dev/null
+++ b/libraries/eina/src/include/eina_unicode.h
@@ -0,0 +1,177 @@
1#ifndef EINA_UNICODE_H
2#define EINA_UNICODE_H
3
4#include <stdlib.h>
5
6#include "eina_config.h"
7#include "eina_types.h"
8
9/**
10 * @addtogroup Eina_Data_Types_Group Data Types
11 *
12 * @{
13 */
14/**
15 * @addtogroup Eina_Unicode_String Unicode String
16 *
17 * @brief These functions provide basic unicode string handling
18 *
19 * Eina_Unicode is a type that holds unicode codepoints.
20 *
21 * @{
22 */
23
24/**
25 * @typedef Eina_Unicode
26 * A type that holds Unicode codepoints.
27 */
28#if EINA_SIZEOF_WCHAR_T >= 4
29# include <wchar.h>
30typedef wchar_t Eina_Unicode;
31#elif defined(EINA_HAVE_INTTYPES_H)
32# include <inttypes.h>
33typedef uint32_t Eina_Unicode;
34#elif defined(EINA_HAVE_STDINT_H)
35# include <stdint.h>
36typedef uint32_t Eina_Unicode;
37#else
38/* Hope that int is big enough */
39typedef unsigned int Eina_Unicode;
40#endif
41
42
43/**
44 * @brief Same as the standard strlen just with Eina_Unicode instead of char.
45 */
46EAPI extern const Eina_Unicode *EINA_UNICODE_EMPTY_STRING;
47
48EAPI size_t eina_unicode_strlen(const Eina_Unicode *ustr) EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT EINA_PURE;
49
50/**
51 * @brief Returns the length of a Eina_Unicode string, up to a limit.
52 *
53 * This function returns the number of characters in string, up to a maximum
54 * of n. If the terminating character is not found in the string, it returns
55 * n.
56 *
57 * @param ustr String to search
58 * @param n Max length to search
59 * @return Number of characters or n.
60 */
61EAPI size_t eina_unicode_strnlen(const Eina_Unicode *ustr, int n) EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT EINA_PURE;
62
63
64/**
65 * @brief Same as the standard strdup just with Eina_Unicode instead of char.
66 */
67EAPI Eina_Unicode *eina_unicode_strdup(const Eina_Unicode *text) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1) EINA_MALLOC;
68
69
70/**
71 * @brief Same as strdup but cuts on n. Assumes n < len
72 * @since 1.1.0
73 */
74EAPI Eina_Unicode *eina_unicode_strndup(const Eina_Unicode *text, size_t n) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1) EINA_MALLOC;
75
76
77/**
78 * @brief Same as the standard strcmp just with Eina_Unicode instead of char.
79 */
80EAPI int eina_unicode_strcmp(const Eina_Unicode *a, const Eina_Unicode *b) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1, 2) EINA_PURE;
81
82
83/**
84 * @brief Same as the standard strcpy just with Eina_Unicode instead of char.
85 */
86EAPI Eina_Unicode *eina_unicode_strcpy(Eina_Unicode *dest, const Eina_Unicode *source) EINA_ARG_NONNULL(1, 2);
87
88
89/**
90 * @brief Same as the standard strstr just with Eina_Unicode instead of char.
91 */
92EAPI Eina_Unicode *eina_unicode_strstr(const Eina_Unicode *haystack, const Eina_Unicode *needle) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1, 2) EINA_PURE;
93
94
95/**
96 * @brief Same as the standard strncpy just with Eina_Unicode instead of char.
97 */
98EAPI Eina_Unicode *eina_unicode_strncpy(Eina_Unicode *dest, const Eina_Unicode *source, size_t n) EINA_ARG_NONNULL(1, 2);
99
100
101/**
102 * @see eina_str_escape()
103 */
104EAPI Eina_Unicode *eina_unicode_escape(const Eina_Unicode *str) EINA_ARG_NONNULL(1) EINA_MALLOC EINA_WARN_UNUSED_RESULT;
105
106/* UTF-8 Handling */
107
108
109/**
110 * Reads UTF8 bytes from @buf, starting at *@index and returns
111 * the decoded code point at iindex offset, and advances iindex
112 * to the next code point after this. iindex is always advanced,
113 * unless if the advancement is after the NULL.
114 * On error: return a codepoint between DC80 to DCFF where the low 8 bits
115 * are the byte's value.
116 *
117 * @param buf the string
118 * @param iindex the index to look at and return by.
119 * @return the codepoint found.
120 * @since 1.1.0
121 */
122EAPI Eina_Unicode eina_unicode_utf8_get_next(const char *buf, int *iindex) EINA_ARG_NONNULL(1, 2);
123
124/**
125 * Reads UTF8 bytes from @buf, starting at *@iindex and returns
126 * the decoded code point at iindex offset, and moves iindex
127 * to the previous code point. iindex is always moved, as long
128 * as it's not past the start of the string.
129 * On error: return a codepoint between DC80 to DCFF where the low 8 bits
130 * are the byte's value.
131 *
132 * @param buf the string
133 * @param iindex the index to look at and return by.
134 * @return the codepoint found.
135 * @since 1.1.0
136 */
137EAPI Eina_Unicode eina_unicode_utf8_get_prev(const char *buf, int *iindex) EINA_ARG_NONNULL(1, 2);
138
139/**
140 * Returns the number of unicode characters in the string. That is,
141 * the number of Eina_Unicodes it'll take to store this string in
142 * an Eina_Unicode string.
143 *
144 * @param buf the string
145 * @return the number of unicode characters (not bytes) in the string
146 * @since 1.1.0
147 */
148EAPI int eina_unicode_utf8_get_len(const char *buf) EINA_ARG_NONNULL(1);
149
150/**
151 * Converts a utf-8 string to a newly allocated Eina_Unicode string.
152 *
153 * @param utf the string in utf-8
154 * @param _len the length of the returned Eina_Unicode string.
155 * @return the newly allocated Eina_Unicode string.
156 * @since 1.1.0
157 */
158EAPI Eina_Unicode *eina_unicode_utf8_to_unicode(const char *utf, int *_len) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1) EINA_MALLOC;
159
160/**
161 * Converts an Eina_Unicode string to a newly allocated utf-8 string.
162 *
163 * @param uni the Eina_Unicode string
164 * @param _len the length byte length of the return utf8 string.
165 * @return the newly allocated utf-8 string.
166 * @since 1.1.0
167 */
168EAPI char * eina_unicode_unicode_to_utf8(const Eina_Unicode *uni, int *_len) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1) EINA_MALLOC;
169
170/**
171 * @}
172 */
173/**
174 * @}
175 */
176
177#endif
diff --git a/libraries/eina/src/include/eina_ustrbuf.h b/libraries/eina/src/include/eina_ustrbuf.h
new file mode 100644
index 0000000..f68cb7b
--- /dev/null
+++ b/libraries/eina/src/include/eina_ustrbuf.h
@@ -0,0 +1,446 @@
1#ifndef EINA_USTRBUF_H
2#define EINA_USTRBUF_H
3
4#include <stddef.h>
5
6#include "eina_types.h"
7#include "eina_unicode.h"
8
9/**
10 * @addtogroup Eina_Unicode_String_Buffer_Group Unicode String Buffer
11 *
12 * @brief These functions provide unicode string buffers management.
13 *
14 * The Unicode String Buffer data type is designed to be a mutable string,
15 * allowing to append, prepend or insert a string to a buffer.
16 */
17
18/**
19 * @addtogroup Eina_Data_Types_Group Data Types
20 *
21 * @{
22 */
23
24/**
25 * @defgroup Eina_Unicode_String_Buffer_Group Unicode String Buffer
26 *
27 * @{
28 */
29
30/**
31 * @typedef Eina_UStrbuf
32 * Type for a string buffer.
33 */
34typedef struct _Eina_Strbuf Eina_UStrbuf;
35
36/**
37 * @brief Create a new string buffer.
38 *
39 * @return Newly allocated string buffer instance.
40 *
41 * This function creates a new string buffer. On error, @c NULL is
42 * returned and Eina error is set to #EINA_ERROR_OUT_OF_MEMORY. To
43 * free the resources, use eina_ustrbuf_free().
44 *
45 * @see eina_ustrbuf_free()
46 * @see eina_ustrbuf_append()
47 * @see eina_ustrbuf_string_get()
48 */
49EAPI Eina_UStrbuf *eina_ustrbuf_new(void) EINA_MALLOC EINA_WARN_UNUSED_RESULT;
50
51/**
52 * @brief Create a new string buffer using the passed string. The passed
53 * string is used directly as the buffer, it's somehow the opposite function of
54 * @ref eina_ustrbuf_string_steal . The passed string must be malloced.
55 *
56 * @param str the string to manage
57 * @return Newly allocated string buffer instance.
58 *
59 * This function creates a new string buffer. On error, @c NULL is
60 * returned and Eina error is set to #EINA_ERROR_OUT_OF_MEMORY. To
61 * free the resources, use eina_strbuf_free().
62 *
63 * @see eina_ustrbuf_free()
64 * @see eina_ustrbuf_append()
65 * @see eina_ustrbuf_string_get()
66 * @since 1.1.0
67 */
68EAPI Eina_Strbuf *eina_ustrbuf_manage_new(Eina_Unicode *str) EINA_MALLOC EINA_WARN_UNUSED_RESULT;
69
70/**
71 * @brief Free a string buffer.
72 *
73 * @param buf The string buffer to free.
74 *
75 * This function frees the memory of @p buf. @p buf must have been
76 * created by eina_ustrbuf_new().
77 */
78EAPI void eina_ustrbuf_free(Eina_UStrbuf *buf) EINA_ARG_NONNULL(1);
79
80/**
81 * @brief Reset a string buffer.
82 *
83 * @param buf The string buffer to reset.
84 *
85 * This function reset @p buf: the buffer len is set to 0, and the
86 * string is set to '\\0'. No memory is free'd.
87 */
88EAPI void eina_ustrbuf_reset(Eina_UStrbuf *buf) EINA_ARG_NONNULL(1);
89
90/**
91 * @brief Append a string to a buffer, reallocating as necessary.
92 *
93 * @param buf The string buffer to append to.
94 * @param str The string to append.
95 * @return #EINA_TRUE on success, #EINA_FALSE on failure.
96 *
97 * This function appends @p str to @p buf. It computes the length of
98 * @p str, so is slightly slower than eina_ustrbuf_append_length(). If
99 * the length is known beforehand, consider using that variant. If
100 * @p buf can't append it, #EINA_FALSE is returned, otherwise
101 * #EINA_TRUE is returned.
102 *
103 * @see eina_ustrbuf_append()
104 * @see eina_ustrbuf_append_length()
105 */
106EAPI Eina_Bool eina_ustrbuf_append(Eina_UStrbuf *buf, const Eina_Unicode *str) EINA_ARG_NONNULL(1, 2);
107
108/**
109 * @brief Append an escaped string to a buffer, reallocating as necessary.
110 *
111 * @param buf The string buffer to append to.
112 * @param str The string to append.
113 * @return #EINA_TRUE on success, #EINA_FALSE on failure.
114 *
115 * This function appends the escaped string @p str to @p buf. If @p
116 * str can not be appended, #EINA_FALSE is returned, otherwise,
117 * #EINA_TRUE is returned.
118 */
119EAPI Eina_Bool eina_ustrbuf_append_escaped(Eina_UStrbuf *buf, const Eina_Unicode *str) EINA_ARG_NONNULL(1, 2);
120
121/**
122 * @brief Append a string to a buffer, reallocating as necessary,
123 * limited by the given length.
124 *
125 * @param buf The string buffer to append to.
126 * @param str The string to append.
127 * @param maxlen The maximum number of characters to append.
128 * @return #EINA_TRUE on success, #EINA_FALSE on failure.
129 *
130 * This function appends at most @p maxlen characters of @p str to
131 * @p buf. It can't appends more than the length of @p str. It
132 * computes the length of @p str, so is slightly slower than
133 * eina_ustrbuf_append_length(). If the length is known beforehand,
134 * consider using that variant (@p maxlen should then be checked so
135 * that it is greater than the size of @p str). If @p str can not be
136 * appended, #EINA_FALSE is returned, otherwise, #EINA_TRUE is
137 * returned.
138 *
139 * @see eina_ustrbuf_append()
140 * @see eina_ustrbuf_append_length()
141 */
142EAPI Eina_Bool eina_ustrbuf_append_n(Eina_UStrbuf *buf, const Eina_Unicode *str, size_t maxlen) EINA_ARG_NONNULL(1, 2);
143
144/**
145 * @brief Append a string of exact length to a buffer, reallocating as necessary.
146 *
147 * @param buf The string buffer to append to.
148 * @param str The string to append.
149 * @param length The exact length to use.
150 * @return #EINA_TRUE on success, #EINA_FALSE on failure.
151 *
152 * This function appends @p str to @p buf. @p str must be of size at
153 * most @p length. It is slightly faster than eina_ustrbuf_append() as
154 * it does not compute the size of @p str. It is useful when dealing
155 * with strings of known size, such as eina_strngshare. If @p buf
156 * can't append it, #EINA_FALSE is returned, otherwise #EINA_TRUE is
157 * returned.
158 *
159 * @see eina_stringshare_length()
160 * @see eina_ustrbuf_append()
161 * @see eina_ustrbuf_append_n()
162 */
163EAPI Eina_Bool eina_ustrbuf_append_length(Eina_UStrbuf *buf, const Eina_Unicode *str, size_t length) EINA_ARG_NONNULL(1, 2);
164
165/**
166 * @brief Append a character to a string buffer, reallocating as
167 * necessary.
168 *
169 * @param buf The string buffer to append to.
170 * @param c The char to append.
171 * @return #EINA_TRUE on success, #EINA_FALSE on failure.
172 *
173 * This function inserts @p c to @p buf. If it can not insert it,
174 * #EINA_FALSE is returned, otherwise #EINA_TRUE is returned.
175 */
176EAPI Eina_Bool eina_ustrbuf_append_char(Eina_UStrbuf *buf, Eina_Unicode c) EINA_ARG_NONNULL(1);
177
178/**
179 * @brief Insert a string to a buffer, reallocating as necessary.
180 *
181 * @param buf The string buffer to insert.
182 * @param str The string to insert.
183 * @param pos The position to insert the string.
184 * @return #EINA_TRUE on success, #EINA_FALSE on failure.
185 *
186 * This function inserts @p str to @p buf at position @p pos. It
187 * computes the length of @p str, so is slightly slower than
188 * eina_ustrbuf_insert_length(). If the length is known beforehand,
189 * consider using that variant. If @p buf can't insert it, #EINA_FALSE
190 * is returned, otherwise #EINA_TRUE is returned.
191 */
192EAPI Eina_Bool eina_ustrbuf_insert(Eina_UStrbuf *buf, const Eina_Unicode *str, size_t pos) EINA_ARG_NONNULL(1, 2);
193
194/**
195 * @brief Insert an escaped string to a buffer, reallocating as
196 * necessary.
197 *
198 * @param buf The string buffer to insert to.
199 * @param str The string to insert.
200 * @param pos The position to insert the string.
201 * @return #EINA_TRUE on success, #EINA_FALSE on failure.
202 *
203 * This function inserts the escaped string @p str to @p buf at
204 * position @p pos. If @p buf can't insert @p str, #EINA_FALSE is
205 * returned, otherwise #EINA_TRUE is returned.
206 */
207EAPI Eina_Bool eina_ustrbuf_insert_escaped(Eina_UStrbuf *buf, const Eina_Unicode *str, size_t pos) EINA_ARG_NONNULL(1, 2);
208
209/**
210 * @brief Insert a string to a buffer, reallocating as necessary. Limited by maxlen.
211 *
212 * @param buf The string buffer to insert to.
213 * @param str The string to insert.
214 * @param maxlen The maximum number of chars to insert.
215 * @param pos The position to insert the string.
216 * @return #EINA_TRUE on success, #EINA_FALSE on failure.
217 *
218 * This function inserts @p str ot @p buf at position @p pos, with at
219 * most @p maxlen bytes. The number of inserted characters can not be
220 * greater than the length of @p str. It computes the length of
221 * @p str, so is slightly slower than eina_ustrbuf_insert_length(). If the
222 * length is known beforehand, consider using that variant (@p maxlen
223 * should then be checked so that it is greater than the size of
224 * @p str). If @p str can not be inserted, #EINA_FALSE is returned,
225 * otherwise, #EINA_TRUE is returned.
226 */
227EAPI Eina_Bool eina_ustrbuf_insert_n(Eina_UStrbuf *buf, const Eina_Unicode *str, size_t maxlen, size_t pos) EINA_ARG_NONNULL(1, 2);
228
229/**
230 * @brief Insert a string of exact length to a buffer, reallocating as necessary.
231 *
232 * @param buf The string buffer to insert to.
233 * @param str The string to insert.
234 * @param length The exact length to use.
235 * @param pos The position to insert the string.
236 * @return #EINA_TRUE on success, #EINA_FALSE on failure.
237 *
238 * This function inserts @p str to @p buf. @p str must be of size at
239 * most @p length. It is slightly faster than eina_ustrbuf_insert() as
240 * it does not compute the size of @p str. It is useful when dealing
241 * with strings of known size, such as eina_strngshare. If @p buf
242 * can't insert it, #EINA_FALSE is returned, otherwise #EINA_TRUE is
243 * returned.
244 *
245 * @see eina_stringshare_length()
246 * @see eina_ustrbuf_insert()
247 * @see eina_ustrbuf_insert_n()
248 */
249EAPI Eina_Bool eina_ustrbuf_insert_length(Eina_UStrbuf *buf, const Eina_Unicode *str, size_t length, size_t pos) EINA_ARG_NONNULL(1, 2);
250
251/**
252 * @brief Insert a character to a string buffer, reallocating as
253 * necessary.
254 *
255 * @param buf The string buffer to insert to.
256 * @param c The char to insert.
257 * @param pos The position to insert the char.
258 * @return #EINA_TRUE on success, #EINA_FALSE on failure.
259 *
260 * This function inserts @p c to @p buf at position @p pos. If @p buf
261 * can't append it, #EINA_FALSE is returned, otherwise #EINA_TRUE is
262 * returned.
263 */
264EAPI Eina_Bool eina_ustrbuf_insert_char(Eina_UStrbuf *buf, Eina_Unicode c, size_t pos) EINA_ARG_NONNULL(1);
265
266/**
267 * @def eina_ustrbuf_prepend(buf, str)
268 * @brief Prepend the given string to the given buffer
269 *
270 * @param buf The string buffer to prepend to.
271 * @param str The string to prepend.
272 * @return #EINA_TRUE on success, #EINA_FALSE on failure.
273 *
274 * This macro is calling eina_ustrbuf_insert() at position 0.If @p buf
275 * can't prepend it, #EINA_FALSE is returned, otherwise #EINA_TRUE is
276 * returned.
277 */
278#define eina_ustrbuf_prepend(buf, str) eina_ustrbuf_insert(buf, str, 0)
279
280/**
281 * @def eina_ustrbuf_prepend_escaped(buf, str)
282 * @brief Prepend the given escaped string to the given buffer
283 *
284 * @param buf The string buffer to prepend to.
285 * @param str The string to prepend.
286 * @return #EINA_TRUE on success, #EINA_FALSE on failure.
287 *
288 * This macro is calling eina_ustrbuf_insert_escaped() at position 0. If
289 * @p buf can't prepend it, #EINA_FALSE is returned, otherwise
290 * #EINA_TRUE is returned.
291 */
292#define eina_ustrbuf_prepend_escaped(buf, str) eina_ustrbuf_insert_escaped(buf, str, 0)
293
294/**
295 * @def eina_ustrbuf_prepend_n(buf, str)
296 * @brief Prepend the given escaped string to the given buffer
297 *
298 * @param buf The string buffer to prepend to.
299 * @param str The string to prepend.
300 * @param maxlen The maximum number of Eina_Unicode *s to prepend.
301 * @return #EINA_TRUE on success, #EINA_FALSE on failure.
302 *
303 * This macro is calling eina_ustrbuf_insert_n() at position 0. If
304 * @p buf can't prepend it, #EINA_FALSE is returned, otherwise
305 * #EINA_TRUE is returned.
306 */
307#define eina_ustrbuf_prepend_n(buf, str, maxlen) eina_ustrbuf_insert_n(buf, str, maxlen, 0)
308
309/**
310 * @def eina_ustrbuf_prepend_length(buf, str)
311 * @brief Prepend the given escaped string to the given buffer
312 *
313 * @param buf The string buffer to prepend to.
314 * @param str The string to prepend.
315 * @param length The exact length to use.
316 * @return #EINA_TRUE on success, #EINA_FALSE on failure.
317 *
318 * This macro is calling eina_ustrbuf_insert_length() at position 0. If
319 * @p buf can't prepend it, #EINA_FALSE is returned, otherwise
320 * #EINA_TRUE is returned.
321 */
322#define eina_ustrbuf_prepend_length(buf, str, length) eina_ustrbuf_insert_length(buf, str, length, 0)
323
324/**
325 * @def eina_ustrbuf_prepend_char(buf, c)
326 * @brief Prepend the given unicode character to the given buffer
327 *
328 * @param buf The string buffer to prepend to.
329 * @param c The Eina_Unicode character to prepend.
330 * @return #EINA_TRUE on success, #EINA_FALSE on failure.
331 *
332 * This macro is calling eina_ustrbuf_insert_Eina_Unicode *() at position 0. If
333 * @p buf can't prepend it, #EINA_FALSE is returned, otherwise
334 * #EINA_TRUE is returned.
335 */
336#define eina_ustrbuf_prepend_char(buf, c) eina_ustrbuf_insert_char(buf, c, 0)
337
338/**
339 * @def eina_ustrbuf_prepend_printf(buf, fmt, ...)
340 * @brief Prepend the given string to the given buffer
341 *
342 * @param buf The string buffer to prepend to.
343 * @param fmt The string to prepend.
344 * @return #EINA_TRUE on success, #EINA_FALSE on failure.
345 *
346 * This macro is calling eina_ustrbuf_insert_printf() at position 0.If @p buf
347 * can't prepend it, #EINA_FALSE is returned, otherwise #EINA_TRUE is
348 * returned.
349 */
350#define eina_ustrbuf_prepend_printf(buf, fmt, ...) eina_ustrbuf_insert_printf(buf, fmt, 0, ## __VA_ARGS__)
351
352/**
353 * @def eina_ustrbuf_prepend_vprintf(buf, fmt, args)
354 * @brief Prepend the given string to the given buffer
355 *
356 * @param buf The string buffer to prepend to.
357 * @param fmt The string to prepend.
358 * @param args The variable arguments.
359 * @return #EINA_TRUE on success, #EINA_FALSE on failure.
360 *
361 * This macro is calling eina_ustrbuf_insert_vprintf() at position 0.If @p buf
362 * can't prepend it, #EINA_FALSE is returned, otherwise #EINA_TRUE is
363 * returned.
364 */
365#define eina_ustrbuf_prepend_vprintf(buf, fmt, args) eina_ustrbuf_insert_vprintf(buf, fmt, 0, args)
366
367/**
368 * @brief Remove a slice of the given string buffer.
369 *
370 * @param buf The string buffer to remove a slice.
371 * @param start The initial (inclusive) slice position to start
372 * removing, in bytes.
373 * @param end The final (non-inclusive) slice position to finish
374 * removing, in bytes.
375 * @return #EINA_TRUE on success, #EINA_FALSE on failure.
376 *
377 * This function removes a slice of @p buf, starting at @p start
378 * (inclusive) and ending at @p end (non-inclusive). Both values are
379 * in bytes. It returns #EINA_FALSE on failure, #EINA_TRUE otherwise.
380 */
381EAPI Eina_Bool
382eina_ustrbuf_remove(Eina_UStrbuf *buf, size_t start, size_t end) EINA_ARG_NONNULL(1);
383
384/**
385 * @brief Retrieve a pointer to the contents of a string buffer
386 *
387 * @param buf The string buffer.
388 * @return The current string in the string buffer.
389 *
390 * This function returns the string contained in @p buf. The returned
391 * value must not be modified and will no longer be valid if @p buf is
392 * modified. In other words, any eina_ustrbuf_append() or similar will
393 * make that pointer invalid.
394 *
395 * @see eina_ustrbuf_string_steal()
396 */
397EAPI const Eina_Unicode *
398eina_ustrbuf_string_get(const Eina_UStrbuf *buf) EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT;
399
400/**
401 * @brief Steal the contents of a string buffer.
402 *
403 * @param buf The string buffer to steal.
404 * @return The current string in the string buffer.
405 *
406 * This function returns the string contained in @p buf. @p buf is
407 * then initialized and does not own the returned string anymore. The
408 * caller must release the memory of the returned string by calling
409 * free().
410 *
411 * @see eina_ustrbuf_string_get()
412 */
413EAPI Eina_Unicode *
414eina_ustrbuf_string_steal(Eina_UStrbuf *buf) EINA_MALLOC EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1);
415
416/**
417 * @brief Free the contents of a string buffer but not the buffer.
418 *
419 * @param buf The string buffer to free the string of.
420 *
421 * This function frees the string contained in @p buf without freeing
422 * @p buf.
423 */
424EAPI void
425eina_ustrbuf_string_free(Eina_UStrbuf *buf) EINA_ARG_NONNULL(1);
426
427/**
428 * @brief Retrieve the length of the string buffer content.
429 *
430 * @param buf The string buffer.
431 * @return The current length of the string, in bytes.
432 *
433 * This function returns the length of @p buf.
434 */
435EAPI size_t
436eina_ustrbuf_length_get(const Eina_UStrbuf *buf) EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT;
437
438/**
439 * @}
440 */
441
442/**
443 * @}
444 */
445
446#endif /* EINA_STRBUF_H */
diff --git a/libraries/eina/src/include/eina_ustringshare.h b/libraries/eina/src/include/eina_ustringshare.h
new file mode 100644
index 0000000..1036573
--- /dev/null
+++ b/libraries/eina/src/include/eina_ustringshare.h
@@ -0,0 +1,200 @@
1/* EINA - EFL data type library
2 * Copyright (C) 2002-2008 Carsten Haitzler, Jorge Luis Zapata Muga, Cedric Bail
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library;
16 * if not, see <http://www.gnu.org/licenses/>.
17 *
18 * This file incorporates work covered by the following copyright and
19 * permission notice:
20 *
21 * Copyright (C) 2008 Peter Wehrfritz
22 *
23 * Permission is hereby granted, free of charge, to any person obtaining a copy
24 * of this software and associated documentation files (the "Software"), to
25 * deal in the Software without restriction, including without limitation the
26 * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
27 * sell copies of the Software, and to permit persons to whom the Software is
28 * furnished to do so, subject to the following conditions:
29 *
30 * The above copyright notice and this permission notice shall be included in
31 * all copies of the Software and its Copyright notices. In addition publicly
32 * documented acknowledgment must be given that this software has been used if no
33 * source code of this software is made available publicly. This includes
34 * acknowledgments in either Copyright notices, Manuals, Publicity and Marketing
35 * documents or any documentation provided with any product containing this
36 * software. This License does not apply to any software that links to the
37 * libraries provided by this software (statically or dynamically), but only to
38 * the software provided.
39 *
40 * Please see the OLD-COPYING.PLAIN for a plain-english explanation of this notice
41 * and it's intent.
42 *
43 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
44 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
45 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
46 * THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
47 * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
48 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
49 */
50
51#ifndef EINA_USTRINGSHARE_H_
52#define EINA_USTRINGSHARE_H_
53
54#include "eina_types.h"
55#include "eina_unicode.h"
56
57/**
58 * @addtogroup Eina_UStringshare_Group Unicode Stringshare
59 *
60 * These functions allow you to store one copy of a string, and use it
61 * throughout your program.
62 *
63 * This is a method to reduce the number of duplicated strings kept in
64 * memory. It's pretty common for the same strings to be dynamically
65 * allocated repeatedly between applications and libraries, especially in
66 * circumstances where you could have multiple copies of a structure that
67 * allocates the string. So rather than duplicating and freeing these
68 * strings, you request a read-only pointer to an existing string and
69 * only incur the overhead of a hash lookup.
70 *
71 * It sounds like micro-optimizing, but profiling has shown this can have
72 * a significant impact as you scale the number of copies up. It improves
73 * string creation/destruction speed, reduces memory use and decreases
74 * memory fragmentation, so a win all-around.
75 *
76 * For more information, you can look at the @ref tutorial_ustringshare_page.
77 */
78
79/**
80 * @addtogroup Eina_Data_Types_Group Data Types
81 *
82 * @{
83 */
84
85/**
86 * @defgroup Eina_UStringshare_Group Unicode Stringshare
87 *
88 * @{
89 */
90
91
92/**
93 * @brief Retrieve an instance of a string for use in a program.
94 *
95 * @param str The string to retrieve an instance of.
96 * @param slen The string size (<= strlen(str)).
97 * @return A pointer to an instance of the string on success.
98 * @c NULL on failure.
99 *
100 * This function retrieves an instance of @p str. If @p str is
101 * @c NULL, then @c NULL is returned. If @p str is already stored, it
102 * is just returned and its reference counter is increased. Otherwise
103 * it is added to the strings to be searched and a duplicated string
104 * of @p str is returned.
105 *
106 * This function does not check string size, but uses the
107 * exact given size. This can be used to share_common part of a larger
108 * buffer or substring.
109 *
110 * @see eina_ustringshare_add()
111 */
112EAPI const Eina_Unicode *eina_ustringshare_add_length(const Eina_Unicode *str, unsigned int slen) EINA_WARN_UNUSED_RESULT;
113
114/**
115 * @brief Retrieve an instance of a string for use in a program.
116 *
117 * @param str The NULL terminated string to retrieve an instance of.
118 * @return A pointer to an instance of the string on success.
119 * @c NULL on failure.
120 *
121 * This function retrieves an instance of @p str. If @p str is
122 * @c NULL, then @c NULL is returned. If @p str is already stored, it
123 * is just returned and its reference counter is increased. Otherwise
124 * it is added to the strings to be searched and a duplicated string
125 * of @p str is returned.
126 *
127 * The string @p str must be NULL terminated ('@\0') and its full
128 * length will be used. To use part of the string or non-null
129 * terminated, use eina_stringshare_add_length() instead.
130 *
131 * @see eina_ustringshare_add_length()
132 */
133EAPI const Eina_Unicode *eina_ustringshare_add(const Eina_Unicode *str) EINA_WARN_UNUSED_RESULT;
134
135/**
136 * Increment references of the given shared string.
137 *
138 * @param str The shared string.
139 * @return A pointer to an instance of the string on success.
140 * @c NULL on failure.
141 *
142 * This is similar to eina_share_common_add(), but it's faster since it will
143 * avoid lookups if possible, but on the down side it requires the parameter
144 * to be shared before, in other words, it must be the return of a previous
145 * eina_ustringshare_add().
146 *
147 * There is no unref since this is the work of eina_ustringshare_del().
148 */
149EAPI const Eina_Unicode *eina_ustringshare_ref(const Eina_Unicode *str);
150
151/**
152 * @brief Note that the given string has lost an instance.
153 *
154 * @param str string The given string.
155 *
156 * This function decreases the reference counter associated to @p str
157 * if it exists. If that counter reaches 0, the memory associated to
158 * @p str is freed. If @p str is NULL, the function returns
159 * immediately.
160 *
161 * Note that if the given pointer is not shared or NULL, bad things
162 * will happen, likely a segmentation fault.
163 */
164EAPI void eina_ustringshare_del(const Eina_Unicode *str);
165
166/**
167 * @brief Note that the given string @b must be shared.
168 *
169 * @param str the shared string to know the length. It is safe to
170 * give NULL, in that case -1 is returned.
171 *
172 * This function is a cheap way to known the length of a shared
173 * string. Note that if the given pointer is not shared, bad
174 * things will happen, likely a segmentation fault. If in doubt, try
175 * strlen().
176 */
177EAPI int eina_ustringshare_strlen(const Eina_Unicode *str) EINA_PURE EINA_WARN_UNUSED_RESULT;
178
179/**
180 * @brief Dump the contents of the share_common.
181 *
182 * This function dumps all strings in the share_common to stdout with a
183 * DDD: prefix per line and a memory usage summary.
184 */
185EAPI void eina_ustringshare_dump(void);
186
187static inline Eina_Bool eina_ustringshare_replace(const Eina_Unicode **p_str, const Eina_Unicode *news) EINA_ARG_NONNULL(1);
188static inline Eina_Bool eina_ustringshare_replace_length(const Eina_Unicode **p_str, const Eina_Unicode *news, unsigned int slen) EINA_ARG_NONNULL(1);
189
190#include "eina_inline_ustringshare.x"
191
192/**
193 * @}
194 */
195
196/**
197 * @}
198 */
199
200#endif /* EINA_STRINGSHARE_H_ */
diff --git a/libraries/eina/src/include/eina_xattr.h b/libraries/eina/src/include/eina_xattr.h
new file mode 100644
index 0000000..8ddb30a
--- /dev/null
+++ b/libraries/eina/src/include/eina_xattr.h
@@ -0,0 +1,168 @@
1/* EINA - EFL data type library
2 * Copyright (C) 2011 Cedric Bail
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library;
16 * if not, see <http://www.gnu.org/licenses/>.
17 */
18
19#ifndef EINA_XATTR_H_
20#define EINA_XATTR_H_
21
22#include "eina_types.h"
23
24/**
25 * @addtogroup Eina_Tools_Group Tools
26 *
27 * @{
28 */
29
30/**
31 * @typedef Eina_Xattr_Flags
32 * define extended attribute creation
33 *
34 * @since 1.1
35 */
36typedef enum {
37 EINA_XATTR_INSERT, /**< This is the default behaviour, it will either create or replace the extended attribute */
38 EINA_XATTR_REPLACE, /**< This will only succeed if the extended attribute previously existed */
39 EINA_XATTR_CREATED /**< This will only succeed if the extended attribute wasn't previously set */
40} Eina_Xattr_Flags;
41
42
43/**
44 * @brief Get an iterator that list all extended attribute of a file.
45 *
46 * @param file The filename to retrieve the extended attribute list from.
47 * @return an iterator.
48 *
49 * The iterator will not allocate any data during the iteration step, so you need to copy them yourself
50 * if you need.
51 *
52 * @since 1.1
53 */
54EAPI Eina_Iterator *eina_xattr_ls(const char *file);
55
56/**
57 * @brief Retrieve an extended attribute from a file.
58 *
59 * @param file The file to retrieve the extended attribute from.
60 * @param atttribute The extended attribute name to retrieve.
61 * @param size The size of the retrieved extended attribute.
62 * @return the allocated data that hold the extended attribute value.
63 *
64 * It will return NULL and *size will be @c 0 if it fails.
65 *
66 * @since 1.1
67 */
68EAPI void *eina_xattr_get(const char *file, const char *attribute, ssize_t *size);
69
70/**
71 * @brief Set an extended attribute on a file.
72 *
73 * @param file The file to set the extended attribute to.
74 * @param attribute The attribute to set.
75 * @param data The data to set.
76 * @param length The length of the data to set.
77 * @param flags Define the set policy.
78 * @return EINA_TRUE on success, EINA_FALSE otherwise.
79 *
80 * @since 1.1
81 */
82EAPI Eina_Bool eina_xattr_set(const char *file, const char *attribute, const void *data, ssize_t length, Eina_Xattr_Flags flags);
83
84/**
85 * @brief Set a string as a extended attribute properties.
86 *
87 * @param file The file to set the string to.
88 * @param attribute The attribute to set.
89 * @param data The NULL terminated string to set.
90 * @param flags Define the set policy.
91 * @return EINA_TRUE on success, EINA_FALSE otherwise.
92 *
93 * @since 1.1
94 */
95EAPI Eina_Bool eina_xattr_string_set(const char *file, const char *attribute, const char *data, Eina_Xattr_Flags flags);
96
97/**
98 * @brief Get a string from an extended attribute properties.
99 *
100 * @param file The file to get the string from.
101 * @param attribute The attribute to get.
102 * @return a valid string on success, NULL otherwise.
103 *
104 * This call check that the string is properly NULL-terminated before returning it.
105 *
106 * @since 1.1
107 */
108EAPI char *eina_xattr_string_get(const char *file, const char *attribute);
109
110/**
111 * @brief Set a double as a extended attribute properties.
112 *
113 * @param file The file to set the double to.
114 * @param attribute The attribute to set.
115 * @param data The NULL terminated double to set.
116 * @param flags Define the set policy.
117 * @return EINA_TRUE on success, EINA_FALSE otherwise.
118 *
119 * @since 1.1
120 */
121EAPI Eina_Bool eina_xattr_double_set(const char *file, const char *attribute, double value, Eina_Xattr_Flags flags);
122
123/**
124 * @brief Get a double from an extended attribute properties.
125 *
126 * @param file The file to get the string from.
127 * @param attribute The attribute to get.
128 * @param value Where to put the extracted value
129 * @return EINA_TRUE on success, EINA_FALSE otherwise.
130 *
131 * This call check that the double is correctly set.
132 *
133 * @since 1.1
134 */
135EAPI Eina_Bool eina_xattr_double_get(const char *file, const char *attribute, double *value);
136
137/**
138 * @brief Set an int as a extended attribute properties.
139 *
140 * @param file The file to set the int to.
141 * @param attribute The attribute to set.
142 * @param data The NULL terminated int to set.
143 * @param flags Define the set policy.
144 * @return EINA_TRUE on success, EINA_FALSE otherwise.
145 *
146 * @since 1.1
147 */
148EAPI Eina_Bool eina_xattr_int_set(const char *file, const char *attribute, int value, Eina_Xattr_Flags flags);
149
150/**
151 * @brief Get a int from an extended attribute properties.
152 *
153 * @param file The file to get the string from.
154 * @param attribute The attribute to get.
155 * @param value Where to put the extracted value
156 * @return EINA_TRUE on success, EINA_FALSE otherwise.
157 *
158 * This call check that the int is correctly set.
159 *
160 * @since 1.1
161 */
162EAPI Eina_Bool eina_xattr_int_get(const char *file, const char *attribute, int *value);
163
164/**
165 * @}
166 */
167
168#endif