aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/libraries/eet/src
diff options
context:
space:
mode:
Diffstat (limited to 'libraries/eet/src')
-rw-r--r--libraries/eet/src/Makefile.am3
-rw-r--r--libraries/eet/src/Makefile.in608
-rw-r--r--libraries/eet/src/bin/Makefile.am21
-rw-r--r--libraries/eet/src/bin/Makefile.in607
-rw-r--r--libraries/eet/src/bin/eet_main.c507
-rw-r--r--libraries/eet/src/examples/Makefile.am50
-rw-r--r--libraries/eet/src/examples/Makefile.in732
-rw-r--r--libraries/eet/src/examples/eet-basic.c40
-rw-r--r--libraries/eet/src/examples/eet-data-cipher_decipher.c119
-rw-r--r--libraries/eet/src/examples/eet-data-file_descriptor_01.c529
-rw-r--r--libraries/eet/src/examples/eet-data-file_descriptor_02.c944
-rw-r--r--libraries/eet/src/examples/eet-data-nested.c272
-rw-r--r--libraries/eet/src/examples/eet-data-simple.c224
-rw-r--r--libraries/eet/src/examples/eet-file.c127
-rw-r--r--libraries/eet/src/lib/Eet.h4180
-rw-r--r--libraries/eet/src/lib/Eet_private.h326
-rw-r--r--libraries/eet/src/lib/Makefile.am163
-rw-r--r--libraries/eet/src/lib/Makefile.in859
-rw-r--r--libraries/eet/src/lib/eet_alloc.c93
-rw-r--r--libraries/eet/src/lib/eet_cipher.c1387
-rw-r--r--libraries/eet/src/lib/eet_connection.c222
-rw-r--r--libraries/eet/src/lib/eet_data.c4986
-rw-r--r--libraries/eet/src/lib/eet_dictionary.c444
-rw-r--r--libraries/eet/src/lib/eet_image.c1825
-rw-r--r--libraries/eet/src/lib/eet_lib.c2533
-rw-r--r--libraries/eet/src/lib/eet_node.c797
-rw-r--r--libraries/eet/src/lib/eet_utils.c36
-rw-r--r--libraries/eet/src/tests/Makefile.am18
-rw-r--r--libraries/eet/src/tests/Makefile.in547
-rw-r--r--libraries/eet/src/tests/TODO3
-rw-r--r--libraries/eet/src/tests/cert.pem22
-rw-r--r--libraries/eet/src/tests/eet_data_suite.c73
-rw-r--r--libraries/eet/src/tests/eet_suite.c2779
-rw-r--r--libraries/eet/src/tests/eet_suite.h9
-rw-r--r--libraries/eet/src/tests/key.pem15
-rw-r--r--libraries/eet/src/tests/key_enc.pem17
-rw-r--r--libraries/eet/src/tests/key_enc_none.pem16
37 files changed, 0 insertions, 26133 deletions
diff --git a/libraries/eet/src/Makefile.am b/libraries/eet/src/Makefile.am
deleted file mode 100644
index d98d3b6..0000000
--- a/libraries/eet/src/Makefile.am
+++ /dev/null
@@ -1,3 +0,0 @@
1MAINTAINERCLEANFILES = Makefile.in
2
3SUBDIRS = lib bin tests examples
diff --git a/libraries/eet/src/Makefile.in b/libraries/eet/src/Makefile.in
deleted file mode 100644
index bfdc4f6..0000000
--- a/libraries/eet/src/Makefile.in
+++ /dev/null
@@ -1,608 +0,0 @@
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@
17VPATH = @srcdir@
18pkgdatadir = $(datadir)/@PACKAGE@
19pkgincludedir = $(includedir)/@PACKAGE@
20pkglibdir = $(libdir)/@PACKAGE@
21pkglibexecdir = $(libexecdir)/@PACKAGE@
22am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
23install_sh_DATA = $(install_sh) -c -m 644
24install_sh_PROGRAM = $(install_sh) -c
25install_sh_SCRIPT = $(install_sh) -c
26INSTALL_HEADER = $(INSTALL_DATA)
27transform = $(program_transform_name)
28NORMAL_INSTALL = :
29PRE_INSTALL = :
30POST_INSTALL = :
31NORMAL_UNINSTALL = :
32PRE_UNINSTALL = :
33POST_UNINSTALL = :
34build_triplet = @build@
35host_triplet = @host@
36subdir = src
37DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
38ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
39am__aclocal_m4_deps = $(top_srcdir)/m4/ac_attribute.m4 \
40 $(top_srcdir)/m4/ac_path_generic.m4 \
41 $(top_srcdir)/m4/efl_binary.m4 \
42 $(top_srcdir)/m4/efl_compiler_flag.m4 \
43 $(top_srcdir)/m4/efl_coverage.m4 \
44 $(top_srcdir)/m4/efl_doxygen.m4 \
45 $(top_srcdir)/m4/efl_fnmatch.m4 \
46 $(top_srcdir)/m4/efl_path_max.m4 $(top_srcdir)/m4/efl_tests.m4 \
47 $(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
48 $(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \
49 $(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/configure.ac
50am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
51 $(ACLOCAL_M4)
52mkinstalldirs = $(install_sh) -d
53CONFIG_HEADER = $(top_builddir)/config.h
54CONFIG_CLEAN_FILES =
55CONFIG_CLEAN_VPATH_FILES =
56AM_V_GEN = $(am__v_GEN_$(V))
57am__v_GEN_ = $(am__v_GEN_$(AM_DEFAULT_VERBOSITY))
58am__v_GEN_0 = @echo " GEN " $@;
59AM_V_at = $(am__v_at_$(V))
60am__v_at_ = $(am__v_at_$(AM_DEFAULT_VERBOSITY))
61am__v_at_0 = @
62SOURCES =
63DIST_SOURCES =
64RECURSIVE_TARGETS = all-recursive check-recursive dvi-recursive \
65 html-recursive info-recursive install-data-recursive \
66 install-dvi-recursive install-exec-recursive \
67 install-html-recursive install-info-recursive \
68 install-pdf-recursive install-ps-recursive install-recursive \
69 installcheck-recursive installdirs-recursive pdf-recursive \
70 ps-recursive uninstall-recursive
71RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \
72 distclean-recursive maintainer-clean-recursive
73AM_RECURSIVE_TARGETS = $(RECURSIVE_TARGETS:-recursive=) \
74 $(RECURSIVE_CLEAN_TARGETS:-recursive=) tags TAGS ctags CTAGS \
75 distdir
76ETAGS = etags
77CTAGS = ctags
78DIST_SUBDIRS = $(SUBDIRS)
79DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
80am__relativize = \
81 dir0=`pwd`; \
82 sed_first='s,^\([^/]*\)/.*$$,\1,'; \
83 sed_rest='s,^[^/]*/*,,'; \
84 sed_last='s,^.*/\([^/]*\)$$,\1,'; \
85 sed_butlast='s,/*[^/]*$$,,'; \
86 while test -n "$$dir1"; do \
87 first=`echo "$$dir1" | sed -e "$$sed_first"`; \
88 if test "$$first" != "."; then \
89 if test "$$first" = ".."; then \
90 dir2=`echo "$$dir0" | sed -e "$$sed_last"`/"$$dir2"; \
91 dir0=`echo "$$dir0" | sed -e "$$sed_butlast"`; \
92 else \
93 first2=`echo "$$dir2" | sed -e "$$sed_first"`; \
94 if test "$$first2" = "$$first"; then \
95 dir2=`echo "$$dir2" | sed -e "$$sed_rest"`; \
96 else \
97 dir2="../$$dir2"; \
98 fi; \
99 dir0="$$dir0"/"$$first"; \
100 fi; \
101 fi; \
102 dir1=`echo "$$dir1" | sed -e "$$sed_rest"`; \
103 done; \
104 reldir="$$dir2"
105ACLOCAL = @ACLOCAL@
106ALLOCA = @ALLOCA@
107AMTAR = @AMTAR@
108AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
109AR = @AR@
110AS = @AS@
111AUTOCONF = @AUTOCONF@
112AUTOHEADER = @AUTOHEADER@
113AUTOMAKE = @AUTOMAKE@
114AWK = @AWK@
115CC = @CC@
116CCDEPMODE = @CCDEPMODE@
117CFLAGS = @CFLAGS@
118CHECK_CFLAGS = @CHECK_CFLAGS@
119CHECK_LIBS = @CHECK_LIBS@
120CPP = @CPP@
121CPPFLAGS = @CPPFLAGS@
122CYGPATH_W = @CYGPATH_W@
123DEBUG_CFLAGS = @DEBUG_CFLAGS@
124DEFS = @DEFS@
125DEPDIR = @DEPDIR@
126DLLTOOL = @DLLTOOL@
127DSYMUTIL = @DSYMUTIL@
128DUMPBIN = @DUMPBIN@
129ECHO_C = @ECHO_C@
130ECHO_N = @ECHO_N@
131ECHO_T = @ECHO_T@
132EET_CFLAGS = @EET_CFLAGS@
133EET_CPPFLAGS = @EET_CPPFLAGS@
134EET_LIBS = @EET_LIBS@
135EET_PRG = @EET_PRG@
136EFL_COVERAGE_CFLAGS = @EFL_COVERAGE_CFLAGS@
137EFL_COVERAGE_LIBS = @EFL_COVERAGE_LIBS@
138EFL_EET_BUILD = @EFL_EET_BUILD@
139EFL_FNMATCH_LIBS = @EFL_FNMATCH_LIBS@
140EGREP = @EGREP@
141EINA_CFLAGS = @EINA_CFLAGS@
142EINA_LIBS = @EINA_LIBS@
143EVIL_CFLAGS = @EVIL_CFLAGS@
144EVIL_LIBS = @EVIL_LIBS@
145EXEEXT = @EXEEXT@
146EXOTIC_CFLAGS = @EXOTIC_CFLAGS@
147EXOTIC_LIBS = @EXOTIC_LIBS@
148FGREP = @FGREP@
149GNUTLS_CFLAGS = @GNUTLS_CFLAGS@
150GNUTLS_LIBS = @GNUTLS_LIBS@
151GREP = @GREP@
152INSTALL = @INSTALL@
153INSTALL_DATA = @INSTALL_DATA@
154INSTALL_PROGRAM = @INSTALL_PROGRAM@
155INSTALL_SCRIPT = @INSTALL_SCRIPT@
156INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
157LD = @LD@
158LDFLAGS = @LDFLAGS@
159LIBGCRYPT_CFLAGS = @LIBGCRYPT_CFLAGS@
160LIBGCRYPT_CONFIG = @LIBGCRYPT_CONFIG@
161LIBGCRYPT_LIBS = @LIBGCRYPT_LIBS@
162LIBOBJS = @LIBOBJS@
163LIBS = @LIBS@
164LIBTOOL = @LIBTOOL@
165LIPO = @LIPO@
166LN_S = @LN_S@
167LTLIBOBJS = @LTLIBOBJS@
168MAKEINFO = @MAKEINFO@
169MKDIR_P = @MKDIR_P@
170NM = @NM@
171NMEDIT = @NMEDIT@
172OBJDUMP = @OBJDUMP@
173OBJEXT = @OBJEXT@
174OPENSSL_CFLAGS = @OPENSSL_CFLAGS@
175OPENSSL_LIBS = @OPENSSL_LIBS@
176OTOOL = @OTOOL@
177OTOOL64 = @OTOOL64@
178PACKAGE = @PACKAGE@
179PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
180PACKAGE_NAME = @PACKAGE_NAME@
181PACKAGE_STRING = @PACKAGE_STRING@
182PACKAGE_TARNAME = @PACKAGE_TARNAME@
183PACKAGE_URL = @PACKAGE_URL@
184PACKAGE_VERSION = @PACKAGE_VERSION@
185PATH_SEPARATOR = @PATH_SEPARATOR@
186PKG_CONFIG = @PKG_CONFIG@
187PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@
188PKG_CONFIG_PATH = @PKG_CONFIG_PATH@
189RANLIB = @RANLIB@
190SED = @SED@
191SET_MAKE = @SET_MAKE@
192SHELL = @SHELL@
193STRIP = @STRIP@
194VERSION = @VERSION@
195VMAJ = @VMAJ@
196abs_builddir = @abs_builddir@
197abs_srcdir = @abs_srcdir@
198abs_top_builddir = @abs_top_builddir@
199abs_top_srcdir = @abs_top_srcdir@
200ac_ct_CC = @ac_ct_CC@
201ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
202am__include = @am__include@
203am__leading_dot = @am__leading_dot@
204am__quote = @am__quote@
205am__tar = @am__tar@
206am__untar = @am__untar@
207bindir = @bindir@
208build = @build@
209build_alias = @build_alias@
210build_cpu = @build_cpu@
211build_os = @build_os@
212build_vendor = @build_vendor@
213builddir = @builddir@
214datadir = @datadir@
215datarootdir = @datarootdir@
216docdir = @docdir@
217dvidir = @dvidir@
218efl_doxygen = @efl_doxygen@
219efl_have_doxygen = @efl_have_doxygen@
220exec_prefix = @exec_prefix@
221have_lcov = @have_lcov@
222host = @host@
223host_alias = @host_alias@
224host_cpu = @host_cpu@
225host_os = @host_os@
226host_vendor = @host_vendor@
227htmldir = @htmldir@
228includedir = @includedir@
229infodir = @infodir@
230install_sh = @install_sh@
231libdir = @libdir@
232libexecdir = @libexecdir@
233localedir = @localedir@
234localstatedir = @localstatedir@
235lt_ECHO = @lt_ECHO@
236lt_enable_auto_import = @lt_enable_auto_import@
237mandir = @mandir@
238mkdir_p = @mkdir_p@
239oldincludedir = @oldincludedir@
240pdfdir = @pdfdir@
241pkgconfig_requires_private = @pkgconfig_requires_private@
242prefix = @prefix@
243program_transform_name = @program_transform_name@
244psdir = @psdir@
245release_info = @release_info@
246requirement_eet = @requirement_eet@
247sbindir = @sbindir@
248sharedstatedir = @sharedstatedir@
249srcdir = @srcdir@
250sysconfdir = @sysconfdir@
251target_alias = @target_alias@
252top_build_prefix = @top_build_prefix@
253top_builddir = @top_builddir@
254top_srcdir = @top_srcdir@
255version_info = @version_info@
256MAINTAINERCLEANFILES = Makefile.in
257SUBDIRS = lib bin tests examples
258all: all-recursive
259
260.SUFFIXES:
261$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
262 @for dep in $?; do \
263 case '$(am__configure_deps)' in \
264 *$$dep*) \
265 ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
266 && { if test -f $@; then exit 0; else break; fi; }; \
267 exit 1;; \
268 esac; \
269 done; \
270 echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu src/Makefile'; \
271 $(am__cd) $(top_srcdir) && \
272 $(AUTOMAKE) --gnu src/Makefile
273.PRECIOUS: Makefile
274Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
275 @case '$?' in \
276 *config.status*) \
277 cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
278 *) \
279 echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
280 cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
281 esac;
282
283$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
284 cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
285
286$(top_srcdir)/configure: $(am__configure_deps)
287 cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
288$(ACLOCAL_M4): $(am__aclocal_m4_deps)
289 cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
290$(am__aclocal_m4_deps):
291
292mostlyclean-libtool:
293 -rm -f *.lo
294
295clean-libtool:
296 -rm -rf .libs _libs
297
298# This directory's subdirectories are mostly independent; you can cd
299# into them and run `make' without going through this Makefile.
300# To change the values of `make' variables: instead of editing Makefiles,
301# (1) if the variable is set in `config.status', edit `config.status'
302# (which will cause the Makefiles to be regenerated when you run `make');
303# (2) otherwise, pass the desired values on the `make' command line.
304$(RECURSIVE_TARGETS):
305 @fail= failcom='exit 1'; \
306 for f in x $$MAKEFLAGS; do \
307 case $$f in \
308 *=* | --[!k]*);; \
309 *k*) failcom='fail=yes';; \
310 esac; \
311 done; \
312 dot_seen=no; \
313 target=`echo $@ | sed s/-recursive//`; \
314 list='$(SUBDIRS)'; for subdir in $$list; do \
315 echo "Making $$target in $$subdir"; \
316 if test "$$subdir" = "."; then \
317 dot_seen=yes; \
318 local_target="$$target-am"; \
319 else \
320 local_target="$$target"; \
321 fi; \
322 ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
323 || eval $$failcom; \
324 done; \
325 if test "$$dot_seen" = "no"; then \
326 $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \
327 fi; test -z "$$fail"
328
329$(RECURSIVE_CLEAN_TARGETS):
330 @fail= failcom='exit 1'; \
331 for f in x $$MAKEFLAGS; do \
332 case $$f in \
333 *=* | --[!k]*);; \
334 *k*) failcom='fail=yes';; \
335 esac; \
336 done; \
337 dot_seen=no; \
338 case "$@" in \
339 distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \
340 *) list='$(SUBDIRS)' ;; \
341 esac; \
342 rev=''; for subdir in $$list; do \
343 if test "$$subdir" = "."; then :; else \
344 rev="$$subdir $$rev"; \
345 fi; \
346 done; \
347 rev="$$rev ."; \
348 target=`echo $@ | sed s/-recursive//`; \
349 for subdir in $$rev; do \
350 echo "Making $$target in $$subdir"; \
351 if test "$$subdir" = "."; then \
352 local_target="$$target-am"; \
353 else \
354 local_target="$$target"; \
355 fi; \
356 ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
357 || eval $$failcom; \
358 done && test -z "$$fail"
359tags-recursive:
360 list='$(SUBDIRS)'; for subdir in $$list; do \
361 test "$$subdir" = . || ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) tags); \
362 done
363ctags-recursive:
364 list='$(SUBDIRS)'; for subdir in $$list; do \
365 test "$$subdir" = . || ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) ctags); \
366 done
367
368ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
369 list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
370 unique=`for i in $$list; do \
371 if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
372 done | \
373 $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
374 END { if (nonempty) { for (i in files) print i; }; }'`; \
375 mkid -fID $$unique
376tags: TAGS
377
378TAGS: tags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
379 $(TAGS_FILES) $(LISP)
380 set x; \
381 here=`pwd`; \
382 if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \
383 include_option=--etags-include; \
384 empty_fix=.; \
385 else \
386 include_option=--include; \
387 empty_fix=; \
388 fi; \
389 list='$(SUBDIRS)'; for subdir in $$list; do \
390 if test "$$subdir" = .; then :; else \
391 test ! -f $$subdir/TAGS || \
392 set "$$@" "$$include_option=$$here/$$subdir/TAGS"; \
393 fi; \
394 done; \
395 list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
396 unique=`for i in $$list; do \
397 if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
398 done | \
399 $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
400 END { if (nonempty) { for (i in files) print i; }; }'`; \
401 shift; \
402 if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
403 test -n "$$unique" || unique=$$empty_fix; \
404 if test $$# -gt 0; then \
405 $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
406 "$$@" $$unique; \
407 else \
408 $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
409 $$unique; \
410 fi; \
411 fi
412ctags: CTAGS
413CTAGS: ctags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
414 $(TAGS_FILES) $(LISP)
415 list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
416 unique=`for i in $$list; do \
417 if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
418 done | \
419 $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
420 END { if (nonempty) { for (i in files) print i; }; }'`; \
421 test -z "$(CTAGS_ARGS)$$unique" \
422 || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
423 $$unique
424
425GTAGS:
426 here=`$(am__cd) $(top_builddir) && pwd` \
427 && $(am__cd) $(top_srcdir) \
428 && gtags -i $(GTAGS_ARGS) "$$here"
429
430distclean-tags:
431 -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
432
433distdir: $(DISTFILES)
434 @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
435 topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
436 list='$(DISTFILES)'; \
437 dist_files=`for file in $$list; do echo $$file; done | \
438 sed -e "s|^$$srcdirstrip/||;t" \
439 -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
440 case $$dist_files in \
441 */*) $(MKDIR_P) `echo "$$dist_files" | \
442 sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
443 sort -u` ;; \
444 esac; \
445 for file in $$dist_files; do \
446 if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
447 if test -d $$d/$$file; then \
448 dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
449 if test -d "$(distdir)/$$file"; then \
450 find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
451 fi; \
452 if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
453 cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
454 find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
455 fi; \
456 cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
457 else \
458 test -f "$(distdir)/$$file" \
459 || cp -p $$d/$$file "$(distdir)/$$file" \
460 || exit 1; \
461 fi; \
462 done
463 @list='$(DIST_SUBDIRS)'; for subdir in $$list; do \
464 if test "$$subdir" = .; then :; else \
465 test -d "$(distdir)/$$subdir" \
466 || $(MKDIR_P) "$(distdir)/$$subdir" \
467 || exit 1; \
468 fi; \
469 done
470 @list='$(DIST_SUBDIRS)'; for subdir in $$list; do \
471 if test "$$subdir" = .; then :; else \
472 dir1=$$subdir; dir2="$(distdir)/$$subdir"; \
473 $(am__relativize); \
474 new_distdir=$$reldir; \
475 dir1=$$subdir; dir2="$(top_distdir)"; \
476 $(am__relativize); \
477 new_top_distdir=$$reldir; \
478 echo " (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) top_distdir="$$new_top_distdir" distdir="$$new_distdir" \\"; \
479 echo " am__remove_distdir=: am__skip_length_check=: am__skip_mode_fix=: distdir)"; \
480 ($(am__cd) $$subdir && \
481 $(MAKE) $(AM_MAKEFLAGS) \
482 top_distdir="$$new_top_distdir" \
483 distdir="$$new_distdir" \
484 am__remove_distdir=: \
485 am__skip_length_check=: \
486 am__skip_mode_fix=: \
487 distdir) \
488 || exit 1; \
489 fi; \
490 done
491check-am: all-am
492check: check-recursive
493all-am: Makefile
494installdirs: installdirs-recursive
495installdirs-am:
496install: install-recursive
497install-exec: install-exec-recursive
498install-data: install-data-recursive
499uninstall: uninstall-recursive
500
501install-am: all-am
502 @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
503
504installcheck: installcheck-recursive
505install-strip:
506 $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
507 install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
508 `test -z '$(STRIP)' || \
509 echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
510mostlyclean-generic:
511
512clean-generic:
513
514distclean-generic:
515 -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
516 -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
517
518maintainer-clean-generic:
519 @echo "This command is intended for maintainers to use"
520 @echo "it deletes files that may require special tools to rebuild."
521 -test -z "$(MAINTAINERCLEANFILES)" || rm -f $(MAINTAINERCLEANFILES)
522clean: clean-recursive
523
524clean-am: clean-generic clean-libtool mostlyclean-am
525
526distclean: distclean-recursive
527 -rm -f Makefile
528distclean-am: clean-am distclean-generic distclean-tags
529
530dvi: dvi-recursive
531
532dvi-am:
533
534html: html-recursive
535
536html-am:
537
538info: info-recursive
539
540info-am:
541
542install-data-am:
543
544install-dvi: install-dvi-recursive
545
546install-dvi-am:
547
548install-exec-am:
549
550install-html: install-html-recursive
551
552install-html-am:
553
554install-info: install-info-recursive
555
556install-info-am:
557
558install-man:
559
560install-pdf: install-pdf-recursive
561
562install-pdf-am:
563
564install-ps: install-ps-recursive
565
566install-ps-am:
567
568installcheck-am:
569
570maintainer-clean: maintainer-clean-recursive
571 -rm -f Makefile
572maintainer-clean-am: distclean-am maintainer-clean-generic
573
574mostlyclean: mostlyclean-recursive
575
576mostlyclean-am: mostlyclean-generic mostlyclean-libtool
577
578pdf: pdf-recursive
579
580pdf-am:
581
582ps: ps-recursive
583
584ps-am:
585
586uninstall-am:
587
588.MAKE: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) ctags-recursive \
589 install-am install-strip tags-recursive
590
591.PHONY: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) CTAGS GTAGS \
592 all all-am check check-am clean clean-generic clean-libtool \
593 ctags ctags-recursive distclean distclean-generic \
594 distclean-libtool distclean-tags distdir dvi dvi-am html \
595 html-am info info-am install install-am install-data \
596 install-data-am install-dvi install-dvi-am install-exec \
597 install-exec-am install-html install-html-am install-info \
598 install-info-am install-man install-pdf install-pdf-am \
599 install-ps install-ps-am install-strip installcheck \
600 installcheck-am installdirs installdirs-am maintainer-clean \
601 maintainer-clean-generic mostlyclean mostlyclean-generic \
602 mostlyclean-libtool pdf pdf-am ps ps-am tags tags-recursive \
603 uninstall uninstall-am
604
605
606# Tell versions [3.59,3.63) of GNU make to not export all variables.
607# Otherwise a system limit (for SysV at least) may be exceeded.
608.NOEXPORT:
diff --git a/libraries/eet/src/bin/Makefile.am b/libraries/eet/src/bin/Makefile.am
deleted file mode 100644
index 89c68f1..0000000
--- a/libraries/eet/src/bin/Makefile.am
+++ /dev/null
@@ -1,21 +0,0 @@
1
2MAINTAINERCLEANFILES = Makefile.in
3
4AM_CPPFLAGS = \
5-I$(top_srcdir) \
6-I$(top_srcdir)/bin \
7-I$(top_srcdir)/src/lib \
8-DPACKAGE_BIN_DIR=\"$(bindir)\" \
9-DPACKAGE_LIB_DIR=\"$(libdir)\" \
10-DPACKAGE_DATA_DIR=\"$(datadir)/$(PACKAGE)\" \
11@EET_CPPFLAGS@ \
12@EINA_CFLAGS@ \
13@EVIL_CFLAGS@
14
15bin_PROGRAMS = @EET_PRG@
16EXTRA_PROGRAMS = eet
17
18eet_SOURCES = eet_main.c
19eet_CFLAGS = @EET_CFLAGS@
20eet_LDADD = $(top_builddir)/src/lib/libeet.la @EINA_LIBS@ @EVIL_LIBS@ @EXOTIC_LIBS@
21eet_LDFLAGS = @lt_enable_auto_import@
diff --git a/libraries/eet/src/bin/Makefile.in b/libraries/eet/src/bin/Makefile.in
deleted file mode 100644
index a7e94cb..0000000
--- a/libraries/eet/src/bin/Makefile.in
+++ /dev/null
@@ -1,607 +0,0 @@
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@
37EXTRA_PROGRAMS = eet$(EXEEXT)
38subdir = src/bin
39DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
40ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
41am__aclocal_m4_deps = $(top_srcdir)/m4/ac_attribute.m4 \
42 $(top_srcdir)/m4/ac_path_generic.m4 \
43 $(top_srcdir)/m4/efl_binary.m4 \
44 $(top_srcdir)/m4/efl_compiler_flag.m4 \
45 $(top_srcdir)/m4/efl_coverage.m4 \
46 $(top_srcdir)/m4/efl_doxygen.m4 \
47 $(top_srcdir)/m4/efl_fnmatch.m4 \
48 $(top_srcdir)/m4/efl_path_max.m4 $(top_srcdir)/m4/efl_tests.m4 \
49 $(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
50 $(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \
51 $(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/configure.ac
52am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
53 $(ACLOCAL_M4)
54mkinstalldirs = $(install_sh) -d
55CONFIG_HEADER = $(top_builddir)/config.h
56CONFIG_CLEAN_FILES =
57CONFIG_CLEAN_VPATH_FILES =
58am__installdirs = "$(DESTDIR)$(bindir)"
59PROGRAMS = $(bin_PROGRAMS)
60am_eet_OBJECTS = eet-eet_main.$(OBJEXT)
61eet_OBJECTS = $(am_eet_OBJECTS)
62eet_DEPENDENCIES = $(top_builddir)/src/lib/libeet.la
63AM_V_lt = $(am__v_lt_$(V))
64am__v_lt_ = $(am__v_lt_$(AM_DEFAULT_VERBOSITY))
65am__v_lt_0 = --silent
66eet_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
67 $(LIBTOOLFLAGS) --mode=link $(CCLD) $(eet_CFLAGS) $(CFLAGS) \
68 $(eet_LDFLAGS) $(LDFLAGS) -o $@
69DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)
70depcomp = $(SHELL) $(top_srcdir)/depcomp
71am__depfiles_maybe = depfiles
72am__mv = mv -f
73COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
74 $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
75LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
76 $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \
77 $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
78 $(AM_CFLAGS) $(CFLAGS)
79AM_V_CC = $(am__v_CC_$(V))
80am__v_CC_ = $(am__v_CC_$(AM_DEFAULT_VERBOSITY))
81am__v_CC_0 = @echo " CC " $@;
82AM_V_at = $(am__v_at_$(V))
83am__v_at_ = $(am__v_at_$(AM_DEFAULT_VERBOSITY))
84am__v_at_0 = @
85CCLD = $(CC)
86LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
87 $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
88 $(AM_LDFLAGS) $(LDFLAGS) -o $@
89AM_V_CCLD = $(am__v_CCLD_$(V))
90am__v_CCLD_ = $(am__v_CCLD_$(AM_DEFAULT_VERBOSITY))
91am__v_CCLD_0 = @echo " CCLD " $@;
92AM_V_GEN = $(am__v_GEN_$(V))
93am__v_GEN_ = $(am__v_GEN_$(AM_DEFAULT_VERBOSITY))
94am__v_GEN_0 = @echo " GEN " $@;
95SOURCES = $(eet_SOURCES)
96DIST_SOURCES = $(eet_SOURCES)
97ETAGS = etags
98CTAGS = ctags
99DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
100ACLOCAL = @ACLOCAL@
101ALLOCA = @ALLOCA@
102AMTAR = @AMTAR@
103AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
104AR = @AR@
105AS = @AS@
106AUTOCONF = @AUTOCONF@
107AUTOHEADER = @AUTOHEADER@
108AUTOMAKE = @AUTOMAKE@
109AWK = @AWK@
110CC = @CC@
111CCDEPMODE = @CCDEPMODE@
112CFLAGS = @CFLAGS@
113CHECK_CFLAGS = @CHECK_CFLAGS@
114CHECK_LIBS = @CHECK_LIBS@
115CPP = @CPP@
116CPPFLAGS = @CPPFLAGS@
117CYGPATH_W = @CYGPATH_W@
118DEBUG_CFLAGS = @DEBUG_CFLAGS@
119DEFS = @DEFS@
120DEPDIR = @DEPDIR@
121DLLTOOL = @DLLTOOL@
122DSYMUTIL = @DSYMUTIL@
123DUMPBIN = @DUMPBIN@
124ECHO_C = @ECHO_C@
125ECHO_N = @ECHO_N@
126ECHO_T = @ECHO_T@
127EET_CFLAGS = @EET_CFLAGS@
128EET_CPPFLAGS = @EET_CPPFLAGS@
129EET_LIBS = @EET_LIBS@
130EET_PRG = @EET_PRG@
131EFL_COVERAGE_CFLAGS = @EFL_COVERAGE_CFLAGS@
132EFL_COVERAGE_LIBS = @EFL_COVERAGE_LIBS@
133EFL_EET_BUILD = @EFL_EET_BUILD@
134EFL_FNMATCH_LIBS = @EFL_FNMATCH_LIBS@
135EGREP = @EGREP@
136EINA_CFLAGS = @EINA_CFLAGS@
137EINA_LIBS = @EINA_LIBS@
138EVIL_CFLAGS = @EVIL_CFLAGS@
139EVIL_LIBS = @EVIL_LIBS@
140EXEEXT = @EXEEXT@
141EXOTIC_CFLAGS = @EXOTIC_CFLAGS@
142EXOTIC_LIBS = @EXOTIC_LIBS@
143FGREP = @FGREP@
144GNUTLS_CFLAGS = @GNUTLS_CFLAGS@
145GNUTLS_LIBS = @GNUTLS_LIBS@
146GREP = @GREP@
147INSTALL = @INSTALL@
148INSTALL_DATA = @INSTALL_DATA@
149INSTALL_PROGRAM = @INSTALL_PROGRAM@
150INSTALL_SCRIPT = @INSTALL_SCRIPT@
151INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
152LD = @LD@
153LDFLAGS = @LDFLAGS@
154LIBGCRYPT_CFLAGS = @LIBGCRYPT_CFLAGS@
155LIBGCRYPT_CONFIG = @LIBGCRYPT_CONFIG@
156LIBGCRYPT_LIBS = @LIBGCRYPT_LIBS@
157LIBOBJS = @LIBOBJS@
158LIBS = @LIBS@
159LIBTOOL = @LIBTOOL@
160LIPO = @LIPO@
161LN_S = @LN_S@
162LTLIBOBJS = @LTLIBOBJS@
163MAKEINFO = @MAKEINFO@
164MKDIR_P = @MKDIR_P@
165NM = @NM@
166NMEDIT = @NMEDIT@
167OBJDUMP = @OBJDUMP@
168OBJEXT = @OBJEXT@
169OPENSSL_CFLAGS = @OPENSSL_CFLAGS@
170OPENSSL_LIBS = @OPENSSL_LIBS@
171OTOOL = @OTOOL@
172OTOOL64 = @OTOOL64@
173PACKAGE = @PACKAGE@
174PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
175PACKAGE_NAME = @PACKAGE_NAME@
176PACKAGE_STRING = @PACKAGE_STRING@
177PACKAGE_TARNAME = @PACKAGE_TARNAME@
178PACKAGE_URL = @PACKAGE_URL@
179PACKAGE_VERSION = @PACKAGE_VERSION@
180PATH_SEPARATOR = @PATH_SEPARATOR@
181PKG_CONFIG = @PKG_CONFIG@
182PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@
183PKG_CONFIG_PATH = @PKG_CONFIG_PATH@
184RANLIB = @RANLIB@
185SED = @SED@
186SET_MAKE = @SET_MAKE@
187SHELL = @SHELL@
188STRIP = @STRIP@
189VERSION = @VERSION@
190VMAJ = @VMAJ@
191abs_builddir = @abs_builddir@
192abs_srcdir = @abs_srcdir@
193abs_top_builddir = @abs_top_builddir@
194abs_top_srcdir = @abs_top_srcdir@
195ac_ct_CC = @ac_ct_CC@
196ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
197am__include = @am__include@
198am__leading_dot = @am__leading_dot@
199am__quote = @am__quote@
200am__tar = @am__tar@
201am__untar = @am__untar@
202bindir = @bindir@
203build = @build@
204build_alias = @build_alias@
205build_cpu = @build_cpu@
206build_os = @build_os@
207build_vendor = @build_vendor@
208builddir = @builddir@
209datadir = @datadir@
210datarootdir = @datarootdir@
211docdir = @docdir@
212dvidir = @dvidir@
213efl_doxygen = @efl_doxygen@
214efl_have_doxygen = @efl_have_doxygen@
215exec_prefix = @exec_prefix@
216have_lcov = @have_lcov@
217host = @host@
218host_alias = @host_alias@
219host_cpu = @host_cpu@
220host_os = @host_os@
221host_vendor = @host_vendor@
222htmldir = @htmldir@
223includedir = @includedir@
224infodir = @infodir@
225install_sh = @install_sh@
226libdir = @libdir@
227libexecdir = @libexecdir@
228localedir = @localedir@
229localstatedir = @localstatedir@
230lt_ECHO = @lt_ECHO@
231lt_enable_auto_import = @lt_enable_auto_import@
232mandir = @mandir@
233mkdir_p = @mkdir_p@
234oldincludedir = @oldincludedir@
235pdfdir = @pdfdir@
236pkgconfig_requires_private = @pkgconfig_requires_private@
237prefix = @prefix@
238program_transform_name = @program_transform_name@
239psdir = @psdir@
240release_info = @release_info@
241requirement_eet = @requirement_eet@
242sbindir = @sbindir@
243sharedstatedir = @sharedstatedir@
244srcdir = @srcdir@
245sysconfdir = @sysconfdir@
246target_alias = @target_alias@
247top_build_prefix = @top_build_prefix@
248top_builddir = @top_builddir@
249top_srcdir = @top_srcdir@
250version_info = @version_info@
251MAINTAINERCLEANFILES = Makefile.in
252AM_CPPFLAGS = \
253-I$(top_srcdir) \
254-I$(top_srcdir)/bin \
255-I$(top_srcdir)/src/lib \
256-DPACKAGE_BIN_DIR=\"$(bindir)\" \
257-DPACKAGE_LIB_DIR=\"$(libdir)\" \
258-DPACKAGE_DATA_DIR=\"$(datadir)/$(PACKAGE)\" \
259@EET_CPPFLAGS@ \
260@EINA_CFLAGS@ \
261@EVIL_CFLAGS@
262
263bin_PROGRAMS = @EET_PRG@
264eet_SOURCES = eet_main.c
265eet_CFLAGS = @EET_CFLAGS@
266eet_LDADD = $(top_builddir)/src/lib/libeet.la @EINA_LIBS@ @EVIL_LIBS@ @EXOTIC_LIBS@
267eet_LDFLAGS = @lt_enable_auto_import@
268all: all-am
269
270.SUFFIXES:
271.SUFFIXES: .c .lo .o .obj
272$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
273 @for dep in $?; do \
274 case '$(am__configure_deps)' in \
275 *$$dep*) \
276 ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
277 && { if test -f $@; then exit 0; else break; fi; }; \
278 exit 1;; \
279 esac; \
280 done; \
281 echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu src/bin/Makefile'; \
282 $(am__cd) $(top_srcdir) && \
283 $(AUTOMAKE) --gnu src/bin/Makefile
284.PRECIOUS: Makefile
285Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
286 @case '$?' in \
287 *config.status*) \
288 cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
289 *) \
290 echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
291 cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
292 esac;
293
294$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
295 cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
296
297$(top_srcdir)/configure: $(am__configure_deps)
298 cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
299$(ACLOCAL_M4): $(am__aclocal_m4_deps)
300 cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
301$(am__aclocal_m4_deps):
302install-binPROGRAMS: $(bin_PROGRAMS)
303 @$(NORMAL_INSTALL)
304 test -z "$(bindir)" || $(MKDIR_P) "$(DESTDIR)$(bindir)"
305 @list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \
306 for p in $$list; do echo "$$p $$p"; done | \
307 sed 's/$(EXEEXT)$$//' | \
308 while read p p1; do if test -f $$p || test -f $$p1; \
309 then echo "$$p"; echo "$$p"; else :; fi; \
310 done | \
311 sed -e 'p;s,.*/,,;n;h' -e 's|.*|.|' \
312 -e 'p;x;s,.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/' | \
313 sed 'N;N;N;s,\n, ,g' | \
314 $(AWK) 'BEGIN { files["."] = ""; dirs["."] = 1 } \
315 { d=$$3; if (dirs[d] != 1) { print "d", d; dirs[d] = 1 } \
316 if ($$2 == $$4) files[d] = files[d] " " $$1; \
317 else { print "f", $$3 "/" $$4, $$1; } } \
318 END { for (d in files) print "f", d, files[d] }' | \
319 while read type dir files; do \
320 if test "$$dir" = .; then dir=; else dir=/$$dir; fi; \
321 test -z "$$files" || { \
322 echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL_PROGRAM) $$files '$(DESTDIR)$(bindir)$$dir'"; \
323 $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL_PROGRAM) $$files "$(DESTDIR)$(bindir)$$dir" || exit $$?; \
324 } \
325 ; done
326
327uninstall-binPROGRAMS:
328 @$(NORMAL_UNINSTALL)
329 @list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \
330 files=`for p in $$list; do echo "$$p"; done | \
331 sed -e 'h;s,^.*/,,;s/$(EXEEXT)$$//;$(transform)' \
332 -e 's/$$/$(EXEEXT)/' `; \
333 test -n "$$list" || exit 0; \
334 echo " ( cd '$(DESTDIR)$(bindir)' && rm -f" $$files ")"; \
335 cd "$(DESTDIR)$(bindir)" && rm -f $$files
336
337clean-binPROGRAMS:
338 @list='$(bin_PROGRAMS)'; test -n "$$list" || exit 0; \
339 echo " rm -f" $$list; \
340 rm -f $$list || exit $$?; \
341 test -n "$(EXEEXT)" || exit 0; \
342 list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \
343 echo " rm -f" $$list; \
344 rm -f $$list
345eet$(EXEEXT): $(eet_OBJECTS) $(eet_DEPENDENCIES)
346 @rm -f eet$(EXEEXT)
347 $(AM_V_CCLD)$(eet_LINK) $(eet_OBJECTS) $(eet_LDADD) $(LIBS)
348
349mostlyclean-compile:
350 -rm -f *.$(OBJEXT)
351
352distclean-compile:
353 -rm -f *.tab.c
354
355@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eet-eet_main.Po@am__quote@
356
357.c.o:
358@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
359@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
360@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@
361@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
362@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
363@am__fastdepCC_FALSE@ $(COMPILE) -c $<
364
365.c.obj:
366@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
367@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
368@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@
369@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
370@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
371@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'`
372
373.c.lo:
374@am__fastdepCC_TRUE@ $(AM_V_CC)$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
375@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
376@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@
377@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
378@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
379@am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $<
380
381eet-eet_main.o: eet_main.c
382@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(eet_CFLAGS) $(CFLAGS) -MT eet-eet_main.o -MD -MP -MF $(DEPDIR)/eet-eet_main.Tpo -c -o eet-eet_main.o `test -f 'eet_main.c' || echo '$(srcdir)/'`eet_main.c
383@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/eet-eet_main.Tpo $(DEPDIR)/eet-eet_main.Po
384@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@
385@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='eet_main.c' object='eet-eet_main.o' libtool=no @AMDEPBACKSLASH@
386@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
387@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(eet_CFLAGS) $(CFLAGS) -c -o eet-eet_main.o `test -f 'eet_main.c' || echo '$(srcdir)/'`eet_main.c
388
389eet-eet_main.obj: eet_main.c
390@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(eet_CFLAGS) $(CFLAGS) -MT eet-eet_main.obj -MD -MP -MF $(DEPDIR)/eet-eet_main.Tpo -c -o eet-eet_main.obj `if test -f 'eet_main.c'; then $(CYGPATH_W) 'eet_main.c'; else $(CYGPATH_W) '$(srcdir)/eet_main.c'; fi`
391@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/eet-eet_main.Tpo $(DEPDIR)/eet-eet_main.Po
392@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@
393@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='eet_main.c' object='eet-eet_main.obj' libtool=no @AMDEPBACKSLASH@
394@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
395@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(eet_CFLAGS) $(CFLAGS) -c -o eet-eet_main.obj `if test -f 'eet_main.c'; then $(CYGPATH_W) 'eet_main.c'; else $(CYGPATH_W) '$(srcdir)/eet_main.c'; fi`
396
397mostlyclean-libtool:
398 -rm -f *.lo
399
400clean-libtool:
401 -rm -rf .libs _libs
402
403ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
404 list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
405 unique=`for i in $$list; do \
406 if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
407 done | \
408 $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
409 END { if (nonempty) { for (i in files) print i; }; }'`; \
410 mkid -fID $$unique
411tags: TAGS
412
413TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
414 $(TAGS_FILES) $(LISP)
415 set x; \
416 here=`pwd`; \
417 list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
418 unique=`for i in $$list; do \
419 if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
420 done | \
421 $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
422 END { if (nonempty) { for (i in files) print i; }; }'`; \
423 shift; \
424 if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
425 test -n "$$unique" || unique=$$empty_fix; \
426 if test $$# -gt 0; then \
427 $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
428 "$$@" $$unique; \
429 else \
430 $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
431 $$unique; \
432 fi; \
433 fi
434ctags: CTAGS
435CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
436 $(TAGS_FILES) $(LISP)
437 list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
438 unique=`for i in $$list; do \
439 if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
440 done | \
441 $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
442 END { if (nonempty) { for (i in files) print i; }; }'`; \
443 test -z "$(CTAGS_ARGS)$$unique" \
444 || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
445 $$unique
446
447GTAGS:
448 here=`$(am__cd) $(top_builddir) && pwd` \
449 && $(am__cd) $(top_srcdir) \
450 && gtags -i $(GTAGS_ARGS) "$$here"
451
452distclean-tags:
453 -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
454
455distdir: $(DISTFILES)
456 @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
457 topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
458 list='$(DISTFILES)'; \
459 dist_files=`for file in $$list; do echo $$file; done | \
460 sed -e "s|^$$srcdirstrip/||;t" \
461 -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
462 case $$dist_files in \
463 */*) $(MKDIR_P) `echo "$$dist_files" | \
464 sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
465 sort -u` ;; \
466 esac; \
467 for file in $$dist_files; do \
468 if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
469 if test -d $$d/$$file; then \
470 dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
471 if test -d "$(distdir)/$$file"; then \
472 find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
473 fi; \
474 if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
475 cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
476 find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
477 fi; \
478 cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
479 else \
480 test -f "$(distdir)/$$file" \
481 || cp -p $$d/$$file "$(distdir)/$$file" \
482 || exit 1; \
483 fi; \
484 done
485check-am: all-am
486check: check-am
487all-am: Makefile $(PROGRAMS)
488installdirs:
489 for dir in "$(DESTDIR)$(bindir)"; do \
490 test -z "$$dir" || $(MKDIR_P) "$$dir"; \
491 done
492install: install-am
493install-exec: install-exec-am
494install-data: install-data-am
495uninstall: uninstall-am
496
497install-am: all-am
498 @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
499
500installcheck: installcheck-am
501install-strip:
502 $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
503 install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
504 `test -z '$(STRIP)' || \
505 echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
506mostlyclean-generic:
507
508clean-generic:
509
510distclean-generic:
511 -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
512 -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
513
514maintainer-clean-generic:
515 @echo "This command is intended for maintainers to use"
516 @echo "it deletes files that may require special tools to rebuild."
517 -test -z "$(MAINTAINERCLEANFILES)" || rm -f $(MAINTAINERCLEANFILES)
518clean: clean-am
519
520clean-am: clean-binPROGRAMS clean-generic clean-libtool mostlyclean-am
521
522distclean: distclean-am
523 -rm -rf ./$(DEPDIR)
524 -rm -f Makefile
525distclean-am: clean-am distclean-compile distclean-generic \
526 distclean-tags
527
528dvi: dvi-am
529
530dvi-am:
531
532html: html-am
533
534html-am:
535
536info: info-am
537
538info-am:
539
540install-data-am:
541
542install-dvi: install-dvi-am
543
544install-dvi-am:
545
546install-exec-am: install-binPROGRAMS
547
548install-html: install-html-am
549
550install-html-am:
551
552install-info: install-info-am
553
554install-info-am:
555
556install-man:
557
558install-pdf: install-pdf-am
559
560install-pdf-am:
561
562install-ps: install-ps-am
563
564install-ps-am:
565
566installcheck-am:
567
568maintainer-clean: maintainer-clean-am
569 -rm -rf ./$(DEPDIR)
570 -rm -f Makefile
571maintainer-clean-am: distclean-am maintainer-clean-generic
572
573mostlyclean: mostlyclean-am
574
575mostlyclean-am: mostlyclean-compile mostlyclean-generic \
576 mostlyclean-libtool
577
578pdf: pdf-am
579
580pdf-am:
581
582ps: ps-am
583
584ps-am:
585
586uninstall-am: uninstall-binPROGRAMS
587
588.MAKE: install-am install-strip
589
590.PHONY: CTAGS GTAGS all all-am check check-am clean clean-binPROGRAMS \
591 clean-generic clean-libtool ctags distclean distclean-compile \
592 distclean-generic distclean-libtool distclean-tags distdir dvi \
593 dvi-am html html-am info info-am install install-am \
594 install-binPROGRAMS install-data install-data-am install-dvi \
595 install-dvi-am install-exec install-exec-am install-html \
596 install-html-am install-info install-info-am install-man \
597 install-pdf install-pdf-am install-ps install-ps-am \
598 install-strip installcheck installcheck-am installdirs \
599 maintainer-clean maintainer-clean-generic mostlyclean \
600 mostlyclean-compile mostlyclean-generic mostlyclean-libtool \
601 pdf pdf-am ps ps-am tags uninstall uninstall-am \
602 uninstall-binPROGRAMS
603
604
605# Tell versions [3.59,3.63) of GNU make to not export all variables.
606# Otherwise a system limit (for SysV at least) may be exceeded.
607.NOEXPORT:
diff --git a/libraries/eet/src/bin/eet_main.c b/libraries/eet/src/bin/eet_main.c
deleted file mode 100644
index 8a93d11..0000000
--- a/libraries/eet/src/bin/eet_main.c
+++ /dev/null
@@ -1,507 +0,0 @@
1#ifdef HAVE_CONFIG_H
2# include <config.h>
3#endif /* ifdef HAVE_CONFIG_H */
4
5#include <stdio.h>
6#include <stdlib.h>
7#include <string.h>
8
9#ifdef HAVE_UNISTD_H
10# include <unistd.h>
11#endif /* ifdef HAVE_UNISTD_H */
12
13#ifdef HAVE_EVIL
14# include <Evil.h>
15#endif /* ifdef HAVE_EVIL */
16
17#include <Eet.h>
18
19static int _eet_main_log_dom = -1;
20
21#ifdef EET_DEFAULT_LOG_COLOR
22#undef EET_DEFAULT_LOG_COLOR
23#endif /* ifdef EET_DEFAULT_LOG_COLOR */
24#define EET_DEFAULT_LOG_COLOR EINA_COLOR_CYAN
25#ifdef ERR
26#undef ERR
27#endif /* ifdef ERR */
28#define ERR(...) EINA_LOG_DOM_ERR(_eet_main_log_dom, __VA_ARGS__)
29#ifdef DBG
30#undef DBG
31#endif /* ifdef DBG */
32#define DBG(...) EINA_LOG_DOM_DBG(_eet_main_log_dom, __VA_ARGS__)
33#ifdef INF
34#undef INF
35#endif /* ifdef INF */
36#define INF(...) EINA_LOG_DOM_INFO(_eet_main_log_dom, __VA_ARGS__)
37#ifdef WRN
38#undef WRN
39#endif /* ifdef WRN */
40#define WRN(...) EINA_LOG_DOM_WARN(_eet_main_log_dom, __VA_ARGS__)
41#ifdef CRIT
42#undef CRIT
43#endif /* ifdef CRIT */
44#define CRIT(...) EINA_LOG_DOM_CRIT(_eet_main_log_dom, __VA_ARGS__)
45
46static void
47do_eet_list(const char *file)
48{
49 int i, num;
50 char **list;
51 Eet_File *ef;
52
53 ef = eet_open(file, EET_FILE_MODE_READ);
54 if (!ef)
55 {
56 ERR("cannot open for reading: %s", file);
57 exit(-1);
58 }
59
60 list = eet_list(ef, "*", &num);
61 if (list)
62 {
63 for (i = 0; i < num; i++)
64 printf("%s\n", list[i]);
65 free(list);
66 }
67
68 eet_close(ef);
69} /* do_eet_list */
70
71static void
72do_eet_stats(const char *file)
73{
74 int i, num;
75 int count[2] = { 0, 0 };
76 int size[2] = { 0, 0 };
77 char **list;
78 Eet_File *ef;
79 Eet_Dictionary *ed;
80
81 ef = eet_open(file, EET_FILE_MODE_READ);
82 if (!ef)
83 {
84 ERR("cannot open for reading: %s", file);
85 exit(-1);
86 }
87
88 printf("*** sections stats ***\n");
89 list = eet_list(ef, "*", &num);
90 if (list)
91 {
92 for (i = 0; i < num; i++)
93 {
94 const void *ro = NULL;
95 void *rw = NULL;
96 int tsize;
97
98 ro = eet_read_direct(ef, list[i], &tsize);
99 if (!ro) rw = eet_read(ef, list[i], &tsize);
100 printf(rw ? "%s of size %i is compressed.\n" : "%s of size %i is not compressed.\n", list[i], tsize);
101 count[rw ? 0 : 1]++;
102 size[rw ? 0 : 1] += tsize;
103 free(rw);
104 }
105 free(list);
106 }
107
108 printf("*** dictionary ***\n");
109 ed = eet_dictionary_get(ef);
110 if (ed)
111 {
112 printf("%i strings inside the dictionary.\n", eet_dictionary_count(ed));
113 }
114 else
115 {
116 printf("no dictionary in this file.\n");
117 }
118 printf("*** global ***\n");
119 printf("%i sections\n", num);
120 printf("- %i of them are compressed (%02.2f%%) expanding in %i bytes.\n",
121 count[0], (float) count[0] * 100 / (float) num, size[0]);
122 printf("- %i of them are directly mappable in memory (%02.2f%%) representing %i bytes.\n",
123 count[1], (float) count[1] * 100 / (float) num, size[1]);
124
125 eet_close(ef);
126}
127
128static void
129do_eet_extract(const char *file,
130 const char *key,
131 const char *out,
132 const char *crypto_key)
133{
134 Eet_File *ef;
135 void *data;
136 int size = 0;
137 FILE *f = stdout;
138
139 ef = eet_open(file, EET_FILE_MODE_READ);
140 if (!ef)
141 {
142 ERR("cannot open for reading: %s", file);
143 exit(-1);
144 }
145
146 data = eet_read_cipher(ef, key, &size, crypto_key);
147 if (!data)
148 {
149 ERR("cannot read key %s", key);
150 exit(-1);
151 }
152
153 if (out)
154 {
155 f = fopen(out, "wb");
156 if (!f)
157 {
158 ERR("cannot open %s", out);
159 exit(-1);
160 }
161 }
162
163 if (fwrite(data, size, 1, f) != 1)
164 {
165 ERR("cannot write to %s", out ? out : "standard output");
166 exit(-1);
167 }
168
169 if (out) fclose(f);
170 free(data);
171 eet_close(ef);
172} /* do_eet_extract */
173
174static void
175do_eet_decode_dump(void *data,
176 const char *str)
177{
178 fputs(str, (FILE *)data);
179} /* do_eet_decode_dump */
180
181static void
182do_eet_decode(const char *file,
183 const char *key,
184 const char *out,
185 const char *crypto_key)
186{
187 Eet_File *ef;
188 FILE *f = stdout;
189
190 ef = eet_open(file, EET_FILE_MODE_READ);
191 if (!ef)
192 {
193 ERR("cannot open for reading: %s", file);
194 exit(-1);
195 }
196
197 if (out)
198 {
199 f = fopen(out, "wb");
200 if (!f)
201 {
202 ERR("cannot open %s", out);
203 exit(-1);
204 }
205 }
206
207 if (!eet_data_dump_cipher(ef, key, crypto_key, do_eet_decode_dump, f))
208 {
209 ERR("cannot write to %s", out ? out : "standard output");
210 exit(-1);
211 }
212
213 if (out) fclose(f);
214 eet_close(ef);
215} /* do_eet_decode */
216
217static void
218do_eet_insert(const char *file,
219 const char *key,
220 const char *out,
221 int compress,
222 const char *crypto_key)
223{
224 Eet_File *ef;
225 void *data;
226 int size = 0;
227 FILE *f;
228
229 ef = eet_open(file, EET_FILE_MODE_READ_WRITE);
230 if (!ef)
231 ef = eet_open(file, EET_FILE_MODE_WRITE);
232
233 if (!ef)
234 {
235 ERR("cannot open for read+write: %s", file);
236 exit(-1);
237 }
238
239 f = fopen(out, "rb");
240 if (!f)
241 {
242 ERR("cannot open %s", out);
243 exit(-1);
244 }
245
246 fseek(f, 0, SEEK_END);
247 size = ftell(f);
248 rewind(f);
249 data = malloc(size);
250 if (!data)
251 {
252 ERR("cannot allocate %i bytes", size);
253 exit(-1);
254 }
255
256 if (fread(data, size, 1, f) != 1)
257 {
258 ERR("cannot read file %s", out);
259 exit(-1);
260 }
261
262 fclose(f);
263 eet_write_cipher(ef, key, data, size, compress, crypto_key);
264 free(data);
265 eet_close(ef);
266} /* do_eet_insert */
267
268static void
269do_eet_encode(const char *file,
270 const char *key,
271 const char *out,
272 int compress,
273 const char *crypto_key)
274{
275 Eet_File *ef;
276 char *text;
277 int textlen = 0;
278 int size = 0;
279 FILE *f;
280
281 ef = eet_open(file, EET_FILE_MODE_READ_WRITE);
282 if (!ef)
283 ef = eet_open(file, EET_FILE_MODE_WRITE);
284
285 if (!ef)
286 {
287 ERR("cannot open for read+write: %s", file);
288 exit(-1);
289 }
290
291 f = fopen(out, "rb");
292 if (!f)
293 {
294 ERR("cannot open %s", out);
295 exit(-1);
296 }
297
298 fseek(f, 0, SEEK_END);
299 textlen = ftell(f);
300 rewind(f);
301 text = malloc(textlen);
302 if (!text)
303 {
304 ERR("cannot allocate %i bytes", size);
305 exit(-1);
306 }
307
308 if (fread(text, textlen, 1, f) != 1)
309 {
310 ERR("cannot read file %s", out);
311 exit(-1);
312 }
313
314 fclose(f);
315 if (!eet_data_undump_cipher(ef, key, crypto_key, text, textlen, compress))
316 {
317 ERR("cannot parse %s", out);
318 exit(-1);
319 }
320
321 free(text);
322 eet_close(ef);
323} /* do_eet_encode */
324
325static void
326do_eet_remove(const char *file,
327 const char *key)
328{
329 Eet_File *ef;
330
331 ef = eet_open(file, EET_FILE_MODE_READ_WRITE);
332 if (!ef)
333 {
334 ERR("cannot open for read+write: %s", file);
335 exit(-1);
336 }
337
338 eet_delete(ef, key);
339 eet_close(ef);
340} /* do_eet_remove */
341
342static void
343do_eet_check(const char *file)
344{
345 Eet_File *ef;
346 const void *der;
347 int der_length;
348 int sign_length;
349
350 ef = eet_open(file, EET_FILE_MODE_READ);
351 if (!ef)
352 {
353 ERR("checking signature of `%s` failed", file);
354 exit(-1);
355 }
356
357 der = eet_identity_x509(ef, &der_length);
358
359 fprintf(stdout, "Certificate length %i.\n", der_length);
360 eet_identity_certificate_print(der, der_length, stdout);
361
362 eet_identity_signature(ef, &sign_length);
363 fprintf(stdout, "Signature length %i.\n", sign_length);
364
365 eet_close(ef);
366} /* do_eet_check */
367
368static void
369do_eet_sign(const char *file,
370 const char *private_key,
371 const char *public_key)
372{
373 Eet_File *ef;
374 Eet_Key *key;
375
376 ef = eet_open(file, EET_FILE_MODE_READ_WRITE);
377 if (!ef)
378 {
379 ERR("cannot open for read+write: %s.", file);
380 exit(-1);
381 }
382
383 key = eet_identity_open(public_key, private_key, NULL);
384 if (!key)
385 {
386 ERR("cannot open key '%s:%s'.", public_key, private_key);
387 exit(-1);
388 }
389
390 fprintf(stdout, "Using the following key to sign `%s`.\n", file);
391 eet_identity_print(key, stdout);
392
393 eet_identity_set(ef, key);
394
395 eet_close(ef);
396} /* do_eet_sign */
397
398int
399main(int argc,
400 char **argv)
401{
402 if (!eet_init())
403 return -1;
404
405 _eet_main_log_dom = eina_log_domain_register("eet_main", EINA_COLOR_CYAN);
406 if(_eet_main_log_dom < -1)
407 {
408 EINA_LOG_ERR("Impossible to create a log domain for eet_main.");
409 eet_shutdown();
410 return -1;
411 }
412
413 if (argc < 2)
414 {
415help:
416 printf(
417 "Usage:\n"
418 " eet -l FILE.EET list all keys in FILE.EET\n"
419 " eet -x FILE.EET KEY [OUT-FILE] [CRYPTO_KEY] extract data stored in KEY in FILE.EET and write to OUT-FILE or standard output\n"
420 " eet -d FILE.EET KEY [OUT-FILE] [CRYPTO_KEY] extract and decode data stored in KEY in FILE.EET and write to OUT-FILE or standard output\n"
421 " eet -i FILE.EET KEY IN-FILE COMPRESS [CRYPTO_KEY] insert data to KEY in FILE.EET from IN-FILE and if COMPRESS is 1, compress it\n"
422 " eet -e FILE.EET KEY IN-FILE COMPRESS [CRYPTO_KEY] insert and encode to KEY in FILE.EET from IN-FILE and if COMPRESS is 1, compress it\n"
423 " eet -r FILE.EET KEY remove KEY in FILE.EET\n"
424 " eet -c FILE.EET report and check the signature information of an eet file\n"
425 " eet -s FILE.EET PRIVATE_KEY PUBLIC_KEY sign FILE.EET with PRIVATE_KEY and attach PUBLIC_KEY as it's certificate\n"
426 " eet -t FILE.EET give some statistic about a file\n"
427 );
428 eet_shutdown();
429 return -1;
430 }
431
432 if ((!strncmp(argv[1], "-h", 2)))
433 goto help;
434 else if ((!strcmp(argv[1], "-l")) && (argc > 2))
435 do_eet_list(argv[2]);
436 else if ((!strcmp(argv[1], "-x")) && (argc > 3))
437 {
438 switch (argc)
439 {
440 case 4:
441 {
442 do_eet_extract(argv[2], argv[3], NULL, NULL);
443 break;
444 }
445 case 5:
446 {
447 do_eet_extract(argv[2], argv[3], argv[4], NULL);
448 break;
449 }
450 default:
451 {
452 do_eet_extract(argv[2], argv[3], argv[4], argv[5]);
453 break;
454 }
455 }
456 }
457 else if ((!strcmp(argv[1], "-d")) && (argc > 3))
458 {
459 switch (argc)
460 {
461 case 4:
462 {
463 do_eet_decode(argv[2], argv[3], NULL, NULL);
464 break;
465 }
466 case 5:
467 {
468 do_eet_decode(argv[2], argv[3], argv[4], NULL);
469 break;
470 }
471 default:
472 {
473 do_eet_decode(argv[2], argv[3], argv[4], argv[5]);
474 break;
475 }
476 }
477 }
478 else if ((!strcmp(argv[1], "-i")) && (argc > 5))
479 {
480 if (argc > 6)
481 do_eet_insert(argv[2], argv[3], argv[4], atoi(argv[5]), argv[6]);
482 else
483 do_eet_insert(argv[2], argv[3], argv[4], atoi(argv[5]), NULL);
484 }
485 else if ((!strcmp(argv[1], "-e")) && (argc > 5))
486 {
487 if (argc > 6)
488 do_eet_encode(argv[2], argv[3], argv[4], atoi(argv[5]), argv[6]);
489 else
490 do_eet_encode(argv[2], argv[3], argv[4], atoi(argv[5]), NULL);
491 }
492 else if ((!strcmp(argv[1], "-r")) && (argc > 3))
493 do_eet_remove(argv[2], argv[3]);
494 else if ((!strcmp(argv[1], "-c")) && (argc > 2))
495 do_eet_check(argv[2]);
496 else if ((!strcmp(argv[1], "-s")) && (argc > 4))
497 do_eet_sign(argv[2], argv[3], argv[4]);
498 else if ((!strcmp(argv[1], "-t")) && (argc > 2))
499 do_eet_stats(argv[2]);
500 else
501 goto help;
502
503 eina_log_domain_unregister(_eet_main_log_dom);
504 eet_shutdown();
505 return 0;
506} /* main */
507
diff --git a/libraries/eet/src/examples/Makefile.am b/libraries/eet/src/examples/Makefile.am
deleted file mode 100644
index 6c5a324..0000000
--- a/libraries/eet/src/examples/Makefile.am
+++ /dev/null
@@ -1,50 +0,0 @@
1MAINTAINERCLEANFILES = Makefile.in
2
3examplesdir = $(datadir)/$(PACKAGE)/examples
4
5if BUILD_EXAMPLES
6AM_CPPFLAGS = \
7-I. \
8-I$(top_srcdir)/src/lib \
9@EINA_CFLAGS@
10
11examples_PROGRAMS = eet_basic eet_file eet_data_simple eet_data_nested eet_data_file_descriptor_01 eet_data_file_descriptor_02 eet_data_cipher_decipher
12
13eet_basic_SOURCES = eet-basic.c
14eet_basic_LDADD = $(top_builddir)/src/lib/libeet.la @EINA_LIBS@
15
16eet_file_SOURCES = eet-file.c
17eet_file_LDADD = $(top_builddir)/src/lib/libeet.la @EINA_LIBS@
18
19eet_data_simple_SOURCES = eet-data-simple.c
20eet_data_simple_LDADD = $(top_builddir)/src/lib/libeet.la @EINA_LIBS@
21
22eet_data_nested_SOURCES = eet-data-nested.c
23eet_data_nested_LDADD = $(top_builddir)/src/lib/libeet.la @EINA_LIBS@
24
25eet_data_file_descriptor_01_SOURCES = eet-data-file_descriptor_01.c
26eet_data_file_descriptor_01_LDADD = $(top_builddir)/src/lib/libeet.la @EINA_LIBS@
27
28eet_data_file_descriptor_02_SOURCES = eet-data-file_descriptor_02.c
29eet_data_file_descriptor_02_LDADD = $(top_builddir)/src/lib/libeet.la @EINA_LIBS@
30
31eet_data_cipher_decipher_SOURCES = eet-data-cipher_decipher.c
32eet_data_cipher_decipher_LDADD = $(top_builddir)/src/lib/libeet.la @EINA_LIBS@
33
34endif
35
36filesdir = $(datadir)/$(PACKAGE)/examples
37files_DATA =
38
39if INSTALL_EXAMPLES
40
41files_DATA += \
42eet-basic.c \
43eet-file.c \
44eet-data-simple.c \
45eet-data-nested.c \
46eet-data-file_descriptor_01.c \
47eet-data-file_descriptor_02.c \
48eet-data-cipher_decipher.c
49
50endif
diff --git a/libraries/eet/src/examples/Makefile.in b/libraries/eet/src/examples/Makefile.in
deleted file mode 100644
index 1e979ab..0000000
--- a/libraries/eet/src/examples/Makefile.in
+++ /dev/null
@@ -1,732 +0,0 @@
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
18
19VPATH = @srcdir@
20pkgdatadir = $(datadir)/@PACKAGE@
21pkgincludedir = $(includedir)/@PACKAGE@
22pkglibdir = $(libdir)/@PACKAGE@
23pkglibexecdir = $(libexecdir)/@PACKAGE@
24am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
25install_sh_DATA = $(install_sh) -c -m 644
26install_sh_PROGRAM = $(install_sh) -c
27install_sh_SCRIPT = $(install_sh) -c
28INSTALL_HEADER = $(INSTALL_DATA)
29transform = $(program_transform_name)
30NORMAL_INSTALL = :
31PRE_INSTALL = :
32POST_INSTALL = :
33NORMAL_UNINSTALL = :
34PRE_UNINSTALL = :
35POST_UNINSTALL = :
36build_triplet = @build@
37host_triplet = @host@
38@BUILD_EXAMPLES_TRUE@examples_PROGRAMS = eet_basic$(EXEEXT) \
39@BUILD_EXAMPLES_TRUE@ eet_file$(EXEEXT) \
40@BUILD_EXAMPLES_TRUE@ eet_data_simple$(EXEEXT) \
41@BUILD_EXAMPLES_TRUE@ eet_data_nested$(EXEEXT) \
42@BUILD_EXAMPLES_TRUE@ eet_data_file_descriptor_01$(EXEEXT) \
43@BUILD_EXAMPLES_TRUE@ eet_data_file_descriptor_02$(EXEEXT) \
44@BUILD_EXAMPLES_TRUE@ eet_data_cipher_decipher$(EXEEXT)
45@INSTALL_EXAMPLES_TRUE@am__append_1 = \
46@INSTALL_EXAMPLES_TRUE@eet-basic.c \
47@INSTALL_EXAMPLES_TRUE@eet-file.c \
48@INSTALL_EXAMPLES_TRUE@eet-data-simple.c \
49@INSTALL_EXAMPLES_TRUE@eet-data-nested.c \
50@INSTALL_EXAMPLES_TRUE@eet-data-file_descriptor_01.c \
51@INSTALL_EXAMPLES_TRUE@eet-data-file_descriptor_02.c \
52@INSTALL_EXAMPLES_TRUE@eet-data-cipher_decipher.c
53
54subdir = src/examples
55DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
56ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
57am__aclocal_m4_deps = $(top_srcdir)/m4/ac_attribute.m4 \
58 $(top_srcdir)/m4/ac_path_generic.m4 \
59 $(top_srcdir)/m4/efl_binary.m4 \
60 $(top_srcdir)/m4/efl_compiler_flag.m4 \
61 $(top_srcdir)/m4/efl_coverage.m4 \
62 $(top_srcdir)/m4/efl_doxygen.m4 \
63 $(top_srcdir)/m4/efl_fnmatch.m4 \
64 $(top_srcdir)/m4/efl_path_max.m4 $(top_srcdir)/m4/efl_tests.m4 \
65 $(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
66 $(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \
67 $(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/configure.ac
68am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
69 $(ACLOCAL_M4)
70mkinstalldirs = $(install_sh) -d
71CONFIG_HEADER = $(top_builddir)/config.h
72CONFIG_CLEAN_FILES =
73CONFIG_CLEAN_VPATH_FILES =
74am__installdirs = "$(DESTDIR)$(examplesdir)" "$(DESTDIR)$(filesdir)"
75PROGRAMS = $(examples_PROGRAMS)
76am__eet_basic_SOURCES_DIST = eet-basic.c
77@BUILD_EXAMPLES_TRUE@am_eet_basic_OBJECTS = eet-basic.$(OBJEXT)
78eet_basic_OBJECTS = $(am_eet_basic_OBJECTS)
79@BUILD_EXAMPLES_TRUE@eet_basic_DEPENDENCIES = \
80@BUILD_EXAMPLES_TRUE@ $(top_builddir)/src/lib/libeet.la
81AM_V_lt = $(am__v_lt_$(V))
82am__v_lt_ = $(am__v_lt_$(AM_DEFAULT_VERBOSITY))
83am__v_lt_0 = --silent
84am__eet_data_cipher_decipher_SOURCES_DIST = \
85 eet-data-cipher_decipher.c
86@BUILD_EXAMPLES_TRUE@am_eet_data_cipher_decipher_OBJECTS = \
87@BUILD_EXAMPLES_TRUE@ eet-data-cipher_decipher.$(OBJEXT)
88eet_data_cipher_decipher_OBJECTS = \
89 $(am_eet_data_cipher_decipher_OBJECTS)
90@BUILD_EXAMPLES_TRUE@eet_data_cipher_decipher_DEPENDENCIES = \
91@BUILD_EXAMPLES_TRUE@ $(top_builddir)/src/lib/libeet.la
92am__eet_data_file_descriptor_01_SOURCES_DIST = \
93 eet-data-file_descriptor_01.c
94@BUILD_EXAMPLES_TRUE@am_eet_data_file_descriptor_01_OBJECTS = \
95@BUILD_EXAMPLES_TRUE@ eet-data-file_descriptor_01.$(OBJEXT)
96eet_data_file_descriptor_01_OBJECTS = \
97 $(am_eet_data_file_descriptor_01_OBJECTS)
98@BUILD_EXAMPLES_TRUE@eet_data_file_descriptor_01_DEPENDENCIES = \
99@BUILD_EXAMPLES_TRUE@ $(top_builddir)/src/lib/libeet.la
100am__eet_data_file_descriptor_02_SOURCES_DIST = \
101 eet-data-file_descriptor_02.c
102@BUILD_EXAMPLES_TRUE@am_eet_data_file_descriptor_02_OBJECTS = \
103@BUILD_EXAMPLES_TRUE@ eet-data-file_descriptor_02.$(OBJEXT)
104eet_data_file_descriptor_02_OBJECTS = \
105 $(am_eet_data_file_descriptor_02_OBJECTS)
106@BUILD_EXAMPLES_TRUE@eet_data_file_descriptor_02_DEPENDENCIES = \
107@BUILD_EXAMPLES_TRUE@ $(top_builddir)/src/lib/libeet.la
108am__eet_data_nested_SOURCES_DIST = eet-data-nested.c
109@BUILD_EXAMPLES_TRUE@am_eet_data_nested_OBJECTS = \
110@BUILD_EXAMPLES_TRUE@ eet-data-nested.$(OBJEXT)
111eet_data_nested_OBJECTS = $(am_eet_data_nested_OBJECTS)
112@BUILD_EXAMPLES_TRUE@eet_data_nested_DEPENDENCIES = \
113@BUILD_EXAMPLES_TRUE@ $(top_builddir)/src/lib/libeet.la
114am__eet_data_simple_SOURCES_DIST = eet-data-simple.c
115@BUILD_EXAMPLES_TRUE@am_eet_data_simple_OBJECTS = \
116@BUILD_EXAMPLES_TRUE@ eet-data-simple.$(OBJEXT)
117eet_data_simple_OBJECTS = $(am_eet_data_simple_OBJECTS)
118@BUILD_EXAMPLES_TRUE@eet_data_simple_DEPENDENCIES = \
119@BUILD_EXAMPLES_TRUE@ $(top_builddir)/src/lib/libeet.la
120am__eet_file_SOURCES_DIST = eet-file.c
121@BUILD_EXAMPLES_TRUE@am_eet_file_OBJECTS = eet-file.$(OBJEXT)
122eet_file_OBJECTS = $(am_eet_file_OBJECTS)
123@BUILD_EXAMPLES_TRUE@eet_file_DEPENDENCIES = \
124@BUILD_EXAMPLES_TRUE@ $(top_builddir)/src/lib/libeet.la
125DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)
126depcomp = $(SHELL) $(top_srcdir)/depcomp
127am__depfiles_maybe = depfiles
128am__mv = mv -f
129COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
130 $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
131LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
132 $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \
133 $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
134 $(AM_CFLAGS) $(CFLAGS)
135AM_V_CC = $(am__v_CC_$(V))
136am__v_CC_ = $(am__v_CC_$(AM_DEFAULT_VERBOSITY))
137am__v_CC_0 = @echo " CC " $@;
138AM_V_at = $(am__v_at_$(V))
139am__v_at_ = $(am__v_at_$(AM_DEFAULT_VERBOSITY))
140am__v_at_0 = @
141CCLD = $(CC)
142LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
143 $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
144 $(AM_LDFLAGS) $(LDFLAGS) -o $@
145AM_V_CCLD = $(am__v_CCLD_$(V))
146am__v_CCLD_ = $(am__v_CCLD_$(AM_DEFAULT_VERBOSITY))
147am__v_CCLD_0 = @echo " CCLD " $@;
148AM_V_GEN = $(am__v_GEN_$(V))
149am__v_GEN_ = $(am__v_GEN_$(AM_DEFAULT_VERBOSITY))
150am__v_GEN_0 = @echo " GEN " $@;
151SOURCES = $(eet_basic_SOURCES) $(eet_data_cipher_decipher_SOURCES) \
152 $(eet_data_file_descriptor_01_SOURCES) \
153 $(eet_data_file_descriptor_02_SOURCES) \
154 $(eet_data_nested_SOURCES) $(eet_data_simple_SOURCES) \
155 $(eet_file_SOURCES)
156DIST_SOURCES = $(am__eet_basic_SOURCES_DIST) \
157 $(am__eet_data_cipher_decipher_SOURCES_DIST) \
158 $(am__eet_data_file_descriptor_01_SOURCES_DIST) \
159 $(am__eet_data_file_descriptor_02_SOURCES_DIST) \
160 $(am__eet_data_nested_SOURCES_DIST) \
161 $(am__eet_data_simple_SOURCES_DIST) \
162 $(am__eet_file_SOURCES_DIST)
163am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
164am__vpath_adj = case $$p in \
165 $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
166 *) f=$$p;; \
167 esac;
168am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`;
169am__install_max = 40
170am__nobase_strip_setup = \
171 srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'`
172am__nobase_strip = \
173 for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||"
174am__nobase_list = $(am__nobase_strip_setup); \
175 for p in $$list; do echo "$$p $$p"; done | \
176 sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \
177 $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \
178 if (++n[$$2] == $(am__install_max)) \
179 { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \
180 END { for (dir in files) print dir, files[dir] }'
181am__base_list = \
182 sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \
183 sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g'
184DATA = $(files_DATA)
185ETAGS = etags
186CTAGS = ctags
187DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
188ACLOCAL = @ACLOCAL@
189ALLOCA = @ALLOCA@
190AMTAR = @AMTAR@
191AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
192AR = @AR@
193AS = @AS@
194AUTOCONF = @AUTOCONF@
195AUTOHEADER = @AUTOHEADER@
196AUTOMAKE = @AUTOMAKE@
197AWK = @AWK@
198CC = @CC@
199CCDEPMODE = @CCDEPMODE@
200CFLAGS = @CFLAGS@
201CHECK_CFLAGS = @CHECK_CFLAGS@
202CHECK_LIBS = @CHECK_LIBS@
203CPP = @CPP@
204CPPFLAGS = @CPPFLAGS@
205CYGPATH_W = @CYGPATH_W@
206DEBUG_CFLAGS = @DEBUG_CFLAGS@
207DEFS = @DEFS@
208DEPDIR = @DEPDIR@
209DLLTOOL = @DLLTOOL@
210DSYMUTIL = @DSYMUTIL@
211DUMPBIN = @DUMPBIN@
212ECHO_C = @ECHO_C@
213ECHO_N = @ECHO_N@
214ECHO_T = @ECHO_T@
215EET_CFLAGS = @EET_CFLAGS@
216EET_CPPFLAGS = @EET_CPPFLAGS@
217EET_LIBS = @EET_LIBS@
218EET_PRG = @EET_PRG@
219EFL_COVERAGE_CFLAGS = @EFL_COVERAGE_CFLAGS@
220EFL_COVERAGE_LIBS = @EFL_COVERAGE_LIBS@
221EFL_EET_BUILD = @EFL_EET_BUILD@
222EFL_FNMATCH_LIBS = @EFL_FNMATCH_LIBS@
223EGREP = @EGREP@
224EINA_CFLAGS = @EINA_CFLAGS@
225EINA_LIBS = @EINA_LIBS@
226EVIL_CFLAGS = @EVIL_CFLAGS@
227EVIL_LIBS = @EVIL_LIBS@
228EXEEXT = @EXEEXT@
229EXOTIC_CFLAGS = @EXOTIC_CFLAGS@
230EXOTIC_LIBS = @EXOTIC_LIBS@
231FGREP = @FGREP@
232GNUTLS_CFLAGS = @GNUTLS_CFLAGS@
233GNUTLS_LIBS = @GNUTLS_LIBS@
234GREP = @GREP@
235INSTALL = @INSTALL@
236INSTALL_DATA = @INSTALL_DATA@
237INSTALL_PROGRAM = @INSTALL_PROGRAM@
238INSTALL_SCRIPT = @INSTALL_SCRIPT@
239INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
240LD = @LD@
241LDFLAGS = @LDFLAGS@
242LIBGCRYPT_CFLAGS = @LIBGCRYPT_CFLAGS@
243LIBGCRYPT_CONFIG = @LIBGCRYPT_CONFIG@
244LIBGCRYPT_LIBS = @LIBGCRYPT_LIBS@
245LIBOBJS = @LIBOBJS@
246LIBS = @LIBS@
247LIBTOOL = @LIBTOOL@
248LIPO = @LIPO@
249LN_S = @LN_S@
250LTLIBOBJS = @LTLIBOBJS@
251MAKEINFO = @MAKEINFO@
252MKDIR_P = @MKDIR_P@
253NM = @NM@
254NMEDIT = @NMEDIT@
255OBJDUMP = @OBJDUMP@
256OBJEXT = @OBJEXT@
257OPENSSL_CFLAGS = @OPENSSL_CFLAGS@
258OPENSSL_LIBS = @OPENSSL_LIBS@
259OTOOL = @OTOOL@
260OTOOL64 = @OTOOL64@
261PACKAGE = @PACKAGE@
262PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
263PACKAGE_NAME = @PACKAGE_NAME@
264PACKAGE_STRING = @PACKAGE_STRING@
265PACKAGE_TARNAME = @PACKAGE_TARNAME@
266PACKAGE_URL = @PACKAGE_URL@
267PACKAGE_VERSION = @PACKAGE_VERSION@
268PATH_SEPARATOR = @PATH_SEPARATOR@
269PKG_CONFIG = @PKG_CONFIG@
270PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@
271PKG_CONFIG_PATH = @PKG_CONFIG_PATH@
272RANLIB = @RANLIB@
273SED = @SED@
274SET_MAKE = @SET_MAKE@
275SHELL = @SHELL@
276STRIP = @STRIP@
277VERSION = @VERSION@
278VMAJ = @VMAJ@
279abs_builddir = @abs_builddir@
280abs_srcdir = @abs_srcdir@
281abs_top_builddir = @abs_top_builddir@
282abs_top_srcdir = @abs_top_srcdir@
283ac_ct_CC = @ac_ct_CC@
284ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
285am__include = @am__include@
286am__leading_dot = @am__leading_dot@
287am__quote = @am__quote@
288am__tar = @am__tar@
289am__untar = @am__untar@
290bindir = @bindir@
291build = @build@
292build_alias = @build_alias@
293build_cpu = @build_cpu@
294build_os = @build_os@
295build_vendor = @build_vendor@
296builddir = @builddir@
297datadir = @datadir@
298datarootdir = @datarootdir@
299docdir = @docdir@
300dvidir = @dvidir@
301efl_doxygen = @efl_doxygen@
302efl_have_doxygen = @efl_have_doxygen@
303exec_prefix = @exec_prefix@
304have_lcov = @have_lcov@
305host = @host@
306host_alias = @host_alias@
307host_cpu = @host_cpu@
308host_os = @host_os@
309host_vendor = @host_vendor@
310htmldir = @htmldir@
311includedir = @includedir@
312infodir = @infodir@
313install_sh = @install_sh@
314libdir = @libdir@
315libexecdir = @libexecdir@
316localedir = @localedir@
317localstatedir = @localstatedir@
318lt_ECHO = @lt_ECHO@
319lt_enable_auto_import = @lt_enable_auto_import@
320mandir = @mandir@
321mkdir_p = @mkdir_p@
322oldincludedir = @oldincludedir@
323pdfdir = @pdfdir@
324pkgconfig_requires_private = @pkgconfig_requires_private@
325prefix = @prefix@
326program_transform_name = @program_transform_name@
327psdir = @psdir@
328release_info = @release_info@
329requirement_eet = @requirement_eet@
330sbindir = @sbindir@
331sharedstatedir = @sharedstatedir@
332srcdir = @srcdir@
333sysconfdir = @sysconfdir@
334target_alias = @target_alias@
335top_build_prefix = @top_build_prefix@
336top_builddir = @top_builddir@
337top_srcdir = @top_srcdir@
338version_info = @version_info@
339MAINTAINERCLEANFILES = Makefile.in
340examplesdir = $(datadir)/$(PACKAGE)/examples
341@BUILD_EXAMPLES_TRUE@AM_CPPFLAGS = \
342@BUILD_EXAMPLES_TRUE@-I. \
343@BUILD_EXAMPLES_TRUE@-I$(top_srcdir)/src/lib \
344@BUILD_EXAMPLES_TRUE@@EINA_CFLAGS@
345
346@BUILD_EXAMPLES_TRUE@eet_basic_SOURCES = eet-basic.c
347@BUILD_EXAMPLES_TRUE@eet_basic_LDADD = $(top_builddir)/src/lib/libeet.la @EINA_LIBS@
348@BUILD_EXAMPLES_TRUE@eet_file_SOURCES = eet-file.c
349@BUILD_EXAMPLES_TRUE@eet_file_LDADD = $(top_builddir)/src/lib/libeet.la @EINA_LIBS@
350@BUILD_EXAMPLES_TRUE@eet_data_simple_SOURCES = eet-data-simple.c
351@BUILD_EXAMPLES_TRUE@eet_data_simple_LDADD = $(top_builddir)/src/lib/libeet.la @EINA_LIBS@
352@BUILD_EXAMPLES_TRUE@eet_data_nested_SOURCES = eet-data-nested.c
353@BUILD_EXAMPLES_TRUE@eet_data_nested_LDADD = $(top_builddir)/src/lib/libeet.la @EINA_LIBS@
354@BUILD_EXAMPLES_TRUE@eet_data_file_descriptor_01_SOURCES = eet-data-file_descriptor_01.c
355@BUILD_EXAMPLES_TRUE@eet_data_file_descriptor_01_LDADD = $(top_builddir)/src/lib/libeet.la @EINA_LIBS@
356@BUILD_EXAMPLES_TRUE@eet_data_file_descriptor_02_SOURCES = eet-data-file_descriptor_02.c
357@BUILD_EXAMPLES_TRUE@eet_data_file_descriptor_02_LDADD = $(top_builddir)/src/lib/libeet.la @EINA_LIBS@
358@BUILD_EXAMPLES_TRUE@eet_data_cipher_decipher_SOURCES = eet-data-cipher_decipher.c
359@BUILD_EXAMPLES_TRUE@eet_data_cipher_decipher_LDADD = $(top_builddir)/src/lib/libeet.la @EINA_LIBS@
360filesdir = $(datadir)/$(PACKAGE)/examples
361files_DATA = $(am__append_1)
362all: all-am
363
364.SUFFIXES:
365.SUFFIXES: .c .lo .o .obj
366$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
367 @for dep in $?; do \
368 case '$(am__configure_deps)' in \
369 *$$dep*) \
370 ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
371 && { if test -f $@; then exit 0; else break; fi; }; \
372 exit 1;; \
373 esac; \
374 done; \
375 echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu src/examples/Makefile'; \
376 $(am__cd) $(top_srcdir) && \
377 $(AUTOMAKE) --gnu src/examples/Makefile
378.PRECIOUS: Makefile
379Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
380 @case '$?' in \
381 *config.status*) \
382 cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
383 *) \
384 echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
385 cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
386 esac;
387
388$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
389 cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
390
391$(top_srcdir)/configure: $(am__configure_deps)
392 cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
393$(ACLOCAL_M4): $(am__aclocal_m4_deps)
394 cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
395$(am__aclocal_m4_deps):
396install-examplesPROGRAMS: $(examples_PROGRAMS)
397 @$(NORMAL_INSTALL)
398 test -z "$(examplesdir)" || $(MKDIR_P) "$(DESTDIR)$(examplesdir)"
399 @list='$(examples_PROGRAMS)'; test -n "$(examplesdir)" || list=; \
400 for p in $$list; do echo "$$p $$p"; done | \
401 sed 's/$(EXEEXT)$$//' | \
402 while read p p1; do if test -f $$p || test -f $$p1; \
403 then echo "$$p"; echo "$$p"; else :; fi; \
404 done | \
405 sed -e 'p;s,.*/,,;n;h' -e 's|.*|.|' \
406 -e 'p;x;s,.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/' | \
407 sed 'N;N;N;s,\n, ,g' | \
408 $(AWK) 'BEGIN { files["."] = ""; dirs["."] = 1 } \
409 { d=$$3; if (dirs[d] != 1) { print "d", d; dirs[d] = 1 } \
410 if ($$2 == $$4) files[d] = files[d] " " $$1; \
411 else { print "f", $$3 "/" $$4, $$1; } } \
412 END { for (d in files) print "f", d, files[d] }' | \
413 while read type dir files; do \
414 if test "$$dir" = .; then dir=; else dir=/$$dir; fi; \
415 test -z "$$files" || { \
416 echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL_PROGRAM) $$files '$(DESTDIR)$(examplesdir)$$dir'"; \
417 $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL_PROGRAM) $$files "$(DESTDIR)$(examplesdir)$$dir" || exit $$?; \
418 } \
419 ; done
420
421uninstall-examplesPROGRAMS:
422 @$(NORMAL_UNINSTALL)
423 @list='$(examples_PROGRAMS)'; test -n "$(examplesdir)" || list=; \
424 files=`for p in $$list; do echo "$$p"; done | \
425 sed -e 'h;s,^.*/,,;s/$(EXEEXT)$$//;$(transform)' \
426 -e 's/$$/$(EXEEXT)/' `; \
427 test -n "$$list" || exit 0; \
428 echo " ( cd '$(DESTDIR)$(examplesdir)' && rm -f" $$files ")"; \
429 cd "$(DESTDIR)$(examplesdir)" && rm -f $$files
430
431clean-examplesPROGRAMS:
432 @list='$(examples_PROGRAMS)'; test -n "$$list" || exit 0; \
433 echo " rm -f" $$list; \
434 rm -f $$list || exit $$?; \
435 test -n "$(EXEEXT)" || exit 0; \
436 list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \
437 echo " rm -f" $$list; \
438 rm -f $$list
439eet_basic$(EXEEXT): $(eet_basic_OBJECTS) $(eet_basic_DEPENDENCIES)
440 @rm -f eet_basic$(EXEEXT)
441 $(AM_V_CCLD)$(LINK) $(eet_basic_OBJECTS) $(eet_basic_LDADD) $(LIBS)
442eet_data_cipher_decipher$(EXEEXT): $(eet_data_cipher_decipher_OBJECTS) $(eet_data_cipher_decipher_DEPENDENCIES)
443 @rm -f eet_data_cipher_decipher$(EXEEXT)
444 $(AM_V_CCLD)$(LINK) $(eet_data_cipher_decipher_OBJECTS) $(eet_data_cipher_decipher_LDADD) $(LIBS)
445eet_data_file_descriptor_01$(EXEEXT): $(eet_data_file_descriptor_01_OBJECTS) $(eet_data_file_descriptor_01_DEPENDENCIES)
446 @rm -f eet_data_file_descriptor_01$(EXEEXT)
447 $(AM_V_CCLD)$(LINK) $(eet_data_file_descriptor_01_OBJECTS) $(eet_data_file_descriptor_01_LDADD) $(LIBS)
448eet_data_file_descriptor_02$(EXEEXT): $(eet_data_file_descriptor_02_OBJECTS) $(eet_data_file_descriptor_02_DEPENDENCIES)
449 @rm -f eet_data_file_descriptor_02$(EXEEXT)
450 $(AM_V_CCLD)$(LINK) $(eet_data_file_descriptor_02_OBJECTS) $(eet_data_file_descriptor_02_LDADD) $(LIBS)
451eet_data_nested$(EXEEXT): $(eet_data_nested_OBJECTS) $(eet_data_nested_DEPENDENCIES)
452 @rm -f eet_data_nested$(EXEEXT)
453 $(AM_V_CCLD)$(LINK) $(eet_data_nested_OBJECTS) $(eet_data_nested_LDADD) $(LIBS)
454eet_data_simple$(EXEEXT): $(eet_data_simple_OBJECTS) $(eet_data_simple_DEPENDENCIES)
455 @rm -f eet_data_simple$(EXEEXT)
456 $(AM_V_CCLD)$(LINK) $(eet_data_simple_OBJECTS) $(eet_data_simple_LDADD) $(LIBS)
457eet_file$(EXEEXT): $(eet_file_OBJECTS) $(eet_file_DEPENDENCIES)
458 @rm -f eet_file$(EXEEXT)
459 $(AM_V_CCLD)$(LINK) $(eet_file_OBJECTS) $(eet_file_LDADD) $(LIBS)
460
461mostlyclean-compile:
462 -rm -f *.$(OBJEXT)
463
464distclean-compile:
465 -rm -f *.tab.c
466
467@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eet-basic.Po@am__quote@
468@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eet-data-cipher_decipher.Po@am__quote@
469@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eet-data-file_descriptor_01.Po@am__quote@
470@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eet-data-file_descriptor_02.Po@am__quote@
471@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eet-data-nested.Po@am__quote@
472@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eet-data-simple.Po@am__quote@
473@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eet-file.Po@am__quote@
474
475.c.o:
476@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
477@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
478@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@
479@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
480@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
481@am__fastdepCC_FALSE@ $(COMPILE) -c $<
482
483.c.obj:
484@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
485@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
486@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@
487@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
488@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
489@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'`
490
491.c.lo:
492@am__fastdepCC_TRUE@ $(AM_V_CC)$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
493@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
494@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@
495@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
496@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
497@am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $<
498
499mostlyclean-libtool:
500 -rm -f *.lo
501
502clean-libtool:
503 -rm -rf .libs _libs
504install-filesDATA: $(files_DATA)
505 @$(NORMAL_INSTALL)
506 test -z "$(filesdir)" || $(MKDIR_P) "$(DESTDIR)$(filesdir)"
507 @list='$(files_DATA)'; test -n "$(filesdir)" || list=; \
508 for p in $$list; do \
509 if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
510 echo "$$d$$p"; \
511 done | $(am__base_list) | \
512 while read files; do \
513 echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(filesdir)'"; \
514 $(INSTALL_DATA) $$files "$(DESTDIR)$(filesdir)" || exit $$?; \
515 done
516
517uninstall-filesDATA:
518 @$(NORMAL_UNINSTALL)
519 @list='$(files_DATA)'; test -n "$(filesdir)" || list=; \
520 files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \
521 test -n "$$files" || exit 0; \
522 echo " ( cd '$(DESTDIR)$(filesdir)' && rm -f" $$files ")"; \
523 cd "$(DESTDIR)$(filesdir)" && rm -f $$files
524
525ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
526 list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
527 unique=`for i in $$list; do \
528 if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
529 done | \
530 $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
531 END { if (nonempty) { for (i in files) print i; }; }'`; \
532 mkid -fID $$unique
533tags: TAGS
534
535TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
536 $(TAGS_FILES) $(LISP)
537 set x; \
538 here=`pwd`; \
539 list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
540 unique=`for i in $$list; do \
541 if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
542 done | \
543 $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
544 END { if (nonempty) { for (i in files) print i; }; }'`; \
545 shift; \
546 if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
547 test -n "$$unique" || unique=$$empty_fix; \
548 if test $$# -gt 0; then \
549 $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
550 "$$@" $$unique; \
551 else \
552 $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
553 $$unique; \
554 fi; \
555 fi
556ctags: CTAGS
557CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
558 $(TAGS_FILES) $(LISP)
559 list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
560 unique=`for i in $$list; do \
561 if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
562 done | \
563 $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
564 END { if (nonempty) { for (i in files) print i; }; }'`; \
565 test -z "$(CTAGS_ARGS)$$unique" \
566 || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
567 $$unique
568
569GTAGS:
570 here=`$(am__cd) $(top_builddir) && pwd` \
571 && $(am__cd) $(top_srcdir) \
572 && gtags -i $(GTAGS_ARGS) "$$here"
573
574distclean-tags:
575 -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
576
577distdir: $(DISTFILES)
578 @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
579 topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
580 list='$(DISTFILES)'; \
581 dist_files=`for file in $$list; do echo $$file; done | \
582 sed -e "s|^$$srcdirstrip/||;t" \
583 -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
584 case $$dist_files in \
585 */*) $(MKDIR_P) `echo "$$dist_files" | \
586 sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
587 sort -u` ;; \
588 esac; \
589 for file in $$dist_files; do \
590 if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
591 if test -d $$d/$$file; then \
592 dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
593 if test -d "$(distdir)/$$file"; then \
594 find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
595 fi; \
596 if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
597 cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
598 find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
599 fi; \
600 cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
601 else \
602 test -f "$(distdir)/$$file" \
603 || cp -p $$d/$$file "$(distdir)/$$file" \
604 || exit 1; \
605 fi; \
606 done
607check-am: all-am
608check: check-am
609all-am: Makefile $(PROGRAMS) $(DATA)
610installdirs:
611 for dir in "$(DESTDIR)$(examplesdir)" "$(DESTDIR)$(filesdir)"; do \
612 test -z "$$dir" || $(MKDIR_P) "$$dir"; \
613 done
614install: install-am
615install-exec: install-exec-am
616install-data: install-data-am
617uninstall: uninstall-am
618
619install-am: all-am
620 @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
621
622installcheck: installcheck-am
623install-strip:
624 $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
625 install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
626 `test -z '$(STRIP)' || \
627 echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
628mostlyclean-generic:
629
630clean-generic:
631
632distclean-generic:
633 -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
634 -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
635
636maintainer-clean-generic:
637 @echo "This command is intended for maintainers to use"
638 @echo "it deletes files that may require special tools to rebuild."
639 -test -z "$(MAINTAINERCLEANFILES)" || rm -f $(MAINTAINERCLEANFILES)
640clean: clean-am
641
642clean-am: clean-examplesPROGRAMS clean-generic clean-libtool \
643 mostlyclean-am
644
645distclean: distclean-am
646 -rm -rf ./$(DEPDIR)
647 -rm -f Makefile
648distclean-am: clean-am distclean-compile distclean-generic \
649 distclean-tags
650
651dvi: dvi-am
652
653dvi-am:
654
655html: html-am
656
657html-am:
658
659info: info-am
660
661info-am:
662
663install-data-am: install-examplesPROGRAMS install-filesDATA
664
665install-dvi: install-dvi-am
666
667install-dvi-am:
668
669install-exec-am:
670
671install-html: install-html-am
672
673install-html-am:
674
675install-info: install-info-am
676
677install-info-am:
678
679install-man:
680
681install-pdf: install-pdf-am
682
683install-pdf-am:
684
685install-ps: install-ps-am
686
687install-ps-am:
688
689installcheck-am:
690
691maintainer-clean: maintainer-clean-am
692 -rm -rf ./$(DEPDIR)
693 -rm -f Makefile
694maintainer-clean-am: distclean-am maintainer-clean-generic
695
696mostlyclean: mostlyclean-am
697
698mostlyclean-am: mostlyclean-compile mostlyclean-generic \
699 mostlyclean-libtool
700
701pdf: pdf-am
702
703pdf-am:
704
705ps: ps-am
706
707ps-am:
708
709uninstall-am: uninstall-examplesPROGRAMS uninstall-filesDATA
710
711.MAKE: install-am install-strip
712
713.PHONY: CTAGS GTAGS all all-am check check-am clean \
714 clean-examplesPROGRAMS clean-generic clean-libtool ctags \
715 distclean distclean-compile distclean-generic \
716 distclean-libtool distclean-tags distdir dvi dvi-am html \
717 html-am info info-am install install-am install-data \
718 install-data-am install-dvi install-dvi-am \
719 install-examplesPROGRAMS install-exec install-exec-am \
720 install-filesDATA install-html install-html-am install-info \
721 install-info-am install-man install-pdf install-pdf-am \
722 install-ps install-ps-am install-strip installcheck \
723 installcheck-am installdirs maintainer-clean \
724 maintainer-clean-generic mostlyclean mostlyclean-compile \
725 mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
726 tags uninstall uninstall-am uninstall-examplesPROGRAMS \
727 uninstall-filesDATA
728
729
730# Tell versions [3.59,3.63) of GNU make to not export all variables.
731# Otherwise a system limit (for SysV at least) may be exceeded.
732.NOEXPORT:
diff --git a/libraries/eet/src/examples/eet-basic.c b/libraries/eet/src/examples/eet-basic.c
deleted file mode 100644
index 05ff397..0000000
--- a/libraries/eet/src/examples/eet-basic.c
+++ /dev/null
@@ -1,40 +0,0 @@
1#include <Eet.h>
2
3int
4main(void)
5{
6 Eet_File *ef;
7 char *ret;
8 int size;
9 char *entries[] =
10 {
11 "Entry 1",
12 "Big text string here compared to others",
13 "Eet is cool"
14 };
15
16 eet_init();
17
18 // blindly open an file for output and write strings with their NUL char
19 ef = eet_open("test.eet", EET_FILE_MODE_WRITE);
20 eet_write(ef, "Entry 1", entries[0], strlen(entries[0]) + 1, 0);
21 eet_write(ef, "Entry 2", entries[1], strlen(entries[1]) + 1, 1);
22 eet_write(ef, "Entry 3", entries[2], strlen(entries[2]) + 1, 0);
23 eet_close(ef);
24
25 // open the file again and blindly get the entries we wrote
26 ef = eet_open("test.eet", EET_FILE_MODE_READ);
27 ret = eet_read(ef, "Entry 1", &size);
28 printf("%s\n", ret);
29 free(ret);
30 ret = eet_read(ef, "Entry 2", &size);
31 printf("%s\n", ret);
32 free(ret);
33 ret = eet_read(ef, "Entry 3", &size);
34 printf("%s\n", ret);
35 free(ret);
36 eet_close(ef);
37
38 eet_shutdown();
39}
40
diff --git a/libraries/eet/src/examples/eet-data-cipher_decipher.c b/libraries/eet/src/examples/eet-data-cipher_decipher.c
deleted file mode 100644
index 2ef965c..0000000
--- a/libraries/eet/src/examples/eet-data-cipher_decipher.c
+++ /dev/null
@@ -1,119 +0,0 @@
1/*
2 * build: gcc -o eet_data_file_cipher_decipher eet-data-file_cipher_decipher.c `pkg-config --cflags --libs eet eina`
3 */
4
5#include <Eina.h>
6#include <Eet.h>
7#include <stdio.h>
8#include <limits.h>
9#include <sys/types.h>
10#include <sys/stat.h>
11#include <unistd.h>
12
13int
14main(void)
15{
16 const char *buffer = "Here is a string of data to save !";
17 const char *key = "This is a crypto key";
18 const char *key_bad = "This is another crypto key";
19
20 char *file = strdup("/tmp/eet_cipher_example_XXXXX");
21 Eet_File *ef;
22 char *test;
23 int size;
24
25 eet_init();
26
27 if (!(file = tmpnam(file)))
28 {
29 fprintf(
30 stderr, "ERROR: could not create temporary file (%s).\n", file);
31 goto panic;
32 }
33
34 /* Crypt an eet file. */
35 ef = eet_open(file, EET_FILE_MODE_WRITE);
36 if (!ef)
37 {
38 fprintf(
39 stderr, "ERROR: could not access file (%s).\n", file);
40 goto error;
41 }
42
43 if (!eet_write_cipher(ef, "keys/tests", buffer, strlen(buffer) + 1, 0, key))
44 {
45 fprintf(
46 stderr, "ERROR: could not access file (%s).\n", file);
47 goto error;
48 }
49
50 eet_close(ef);
51
52 /* Decrypt an eet file. */
53 ef = eet_open(file, EET_FILE_MODE_READ);
54 if (!ef)
55 {
56 fprintf(
57 stderr, "ERROR: could not access file (%s).\n", file);
58 goto error;
59 }
60
61 test = eet_read_cipher(ef, "keys/tests", &size, key);
62 if (!test)
63 {
64 fprintf(
65 stderr, "ERROR: could decript contents on file %s, with key %s.\n",
66 file, key);
67 goto error;
68 }
69
70 if (size != (int)strlen(buffer) + 1)
71 {
72 fprintf(
73 stderr, "ERROR: something is wrong with the decripted data\n");
74 goto error;
75 }
76
77 if (memcmp(test, buffer, strlen(buffer) + 1) != 0)
78 {
79 fprintf(
80 stderr, "ERROR: something is wrong with the decripted data\n");
81 goto error;
82 }
83
84 eet_close(ef);
85
86 /* Decrypt an eet file, now using our BAD key!! */
87 ef = eet_open(file, EET_FILE_MODE_READ);
88 if (!ef)
89 {
90 fprintf(
91 stderr, "ERROR: could not access file (%s).\n", file);
92 goto error;
93 }
94
95 test = eet_read_cipher(ef, "keys/tests", &size, key_bad);
96
97 if (size == (int)strlen(buffer) + 1)
98 if (memcmp(test, buffer, strlen(buffer) + 1) == 0)
99 {
100 fprintf(
101 stderr, "ERROR: something is wrong with the contents of %s, as"
102 " we accessed it with a different key and it decripted our"
103 " information right.\n", file);
104 goto error;
105 }
106
107 eet_close(ef);
108
109error:
110 if (unlink(file) != 0)
111 {
112 fprintf(
113 stderr, "ERROR: could not unlink file (%s).\n", file);
114 }
115
116panic:
117 eet_shutdown();
118}
119
diff --git a/libraries/eet/src/examples/eet-data-file_descriptor_01.c b/libraries/eet/src/examples/eet-data-file_descriptor_01.c
deleted file mode 100644
index 4b5b75f..0000000
--- a/libraries/eet/src/examples/eet-data-file_descriptor_01.c
+++ /dev/null
@@ -1,529 +0,0 @@
1/*
2 * build: gcc -o eet_data_file_descriptor eet-data-file_descriptor.c `pkg-config --cflags --libs eet eina`
3 */
4#include <Eina.h>
5#include <Eet.h>
6#include <stdio.h>
7#include <limits.h>
8#include <sys/types.h>
9#include <sys/stat.h>
10#include <unistd.h>
11
12// complex real-world structures based on elmdentica database
13typedef struct
14{
15 const char *screen_name;
16 const char *name;
17 const char *message;
18 unsigned int id;
19 unsigned int status_id;
20 unsigned int date;
21 unsigned int timeline;
22} My_Message;
23
24typedef struct
25{
26 const char *dm_to;
27 const char *message;
28} My_Post;
29
30typedef struct
31{
32 unsigned int id;
33 const char *name;
34 Eina_List *messages;
35 My_Post *posts;
36 int posts_count;
37} My_Account;
38
39typedef struct
40{
41 unsigned int version; // it is recommended to use versioned configuration!
42 Eina_Hash *accounts;
43} My_Cache;
44
45// string that represents the entry in eet file, you might like to have
46// different profiles or so in the same file, this is possible with
47// different strings
48static const char MY_CACHE_FILE_ENTRY[] = "cache";
49
50// keep the descriptor static global, so it can be
51// shared by different functions (load/save) of this and only this
52// file.
53static Eet_Data_Descriptor *_my_cache_descriptor;
54static Eet_Data_Descriptor *_my_account_descriptor;
55static Eet_Data_Descriptor *_my_message_descriptor;
56static Eet_Data_Descriptor *_my_post_descriptor;
57
58// keep file handle alive, so mmap()ed strings are all alive as well
59static Eet_File *_my_cache_file = NULL;
60static Eet_Dictionary *_my_cache_dict = NULL;
61
62static void
63_my_cache_descriptor_init(void)
64{
65 Eet_Data_Descriptor_Class eddc;
66
67 // The FILE variant is good for caches and things that are just
68 // appended, but needs to take care when changing strings and files must
69 // be kept open so mmap()ed strings will be kept alive.
70 EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(&eddc, My_Cache);
71 _my_cache_descriptor = eet_data_descriptor_file_new(&eddc);
72
73 EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(&eddc, My_Account);
74 _my_account_descriptor = eet_data_descriptor_file_new(&eddc);
75
76 EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(&eddc, My_Message);
77 _my_message_descriptor = eet_data_descriptor_file_new(&eddc);
78
79 EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(&eddc, My_Post);
80 _my_post_descriptor = eet_data_descriptor_file_new(&eddc);
81
82 // Describe the members to be saved:
83 // Use a temporary macro so we don't type a lot, also avoid errors:
84
85#define ADD_BASIC(member, eet_type) \
86 EET_DATA_DESCRIPTOR_ADD_BASIC \
87 (_my_message_descriptor, My_Message, # member, member, eet_type)
88 ADD_BASIC(screen_name, EET_T_STRING);
89 ADD_BASIC(name, EET_T_STRING);
90 ADD_BASIC(message, EET_T_STRING);
91 ADD_BASIC(id, EET_T_UINT);
92 ADD_BASIC(status_id, EET_T_UINT);
93 ADD_BASIC(date, EET_T_UINT);
94 ADD_BASIC(timeline, EET_T_UINT);
95#undef ADD_BASIC
96
97#define ADD_BASIC(member, eet_type) \
98 EET_DATA_DESCRIPTOR_ADD_BASIC \
99 (_my_post_descriptor, My_Post, # member, member, eet_type)
100 ADD_BASIC(dm_to, EET_T_STRING);
101 ADD_BASIC(message, EET_T_STRING);
102#undef ADD_BASIC
103
104#define ADD_BASIC(member, eet_type) \
105 EET_DATA_DESCRIPTOR_ADD_BASIC \
106 (_my_account_descriptor, My_Account, # member, member, eet_type)
107 ADD_BASIC(name, EET_T_STRING);
108 ADD_BASIC(id, EET_T_UINT);
109#undef ADD_BASIC
110
111 EET_DATA_DESCRIPTOR_ADD_LIST
112 (_my_account_descriptor, My_Account, "messages", messages,
113 _my_message_descriptor);
114 EET_DATA_DESCRIPTOR_ADD_VAR_ARRAY
115 (_my_account_descriptor, My_Account, "posts", posts,
116 _my_post_descriptor);
117
118#define ADD_BASIC(member, eet_type) \
119 EET_DATA_DESCRIPTOR_ADD_BASIC \
120 (_my_cache_descriptor, My_Cache, # member, member, eet_type)
121 ADD_BASIC(version, EET_T_UINT);
122#undef ADD_BASIC
123
124 EET_DATA_DESCRIPTOR_ADD_HASH
125 (_my_cache_descriptor, My_Cache, "accounts", accounts,
126 _my_account_descriptor);
127} /* _my_cache_descriptor_init */
128
129static void
130_my_cache_descriptor_shutdown(void)
131{
132 eet_data_descriptor_free(_my_cache_descriptor);
133 eet_data_descriptor_free(_my_account_descriptor);
134 eet_data_descriptor_free(_my_message_descriptor);
135 eet_data_descriptor_free(_my_post_descriptor);
136} /* _my_cache_descriptor_shutdown */
137
138// need to check if the pointer came from mmaped area in eet_dictionary
139// or it was allocated with eina_stringshare_add()
140static void
141_eet_string_free(const char *str)
142{
143 if (!str)
144 return;
145
146 if ((_my_cache_dict) && (eet_dictionary_string_check(_my_cache_dict, str)))
147 return;
148
149 eina_stringshare_del(str);
150} /* _eet_string_free */
151
152static My_Message *
153_my_message_new(const char *message)
154{
155 My_Message *msg = calloc(1, sizeof(My_Message));
156 if (!msg)
157 {
158 fprintf(stderr, "ERROR: could not calloc My_Message\n");
159 return NULL;
160 }
161
162 msg->message = eina_stringshare_add(message);
163 return msg;
164} /* _my_message_new */
165
166static void
167_my_message_free(My_Message *msg)
168{
169 _eet_string_free(msg->screen_name);
170 _eet_string_free(msg->name);
171 _eet_string_free(msg->message);
172 free(msg);
173} /* _my_message_free */
174
175static Eina_Bool
176_my_post_add(My_Account *acc,
177 const char *message)
178{
179 int new_count = acc->posts_count + 1;
180 My_Post *post = realloc(acc->posts, new_count * sizeof(My_Post));
181 if (!post)
182 {
183 fprintf(stderr, "ERROR: could add My_Post\n");
184 return EINA_FALSE;
185 }
186
187 post[acc->posts_count].message = eina_stringshare_add(message);
188 post[acc->posts_count].dm_to = NULL;
189 acc->posts_count = new_count;
190 acc->posts = post;
191 return EINA_TRUE;
192} /* _my_post_new */
193
194static void
195_my_post_free(My_Post *post)
196{
197 _eet_string_free(post->dm_to);
198 _eet_string_free(post->message);
199} /* _my_post_free */
200
201static My_Account *
202_my_account_new(const char *name)
203{
204 My_Account *acc = calloc(1, sizeof(My_Account));
205 if (!acc)
206 {
207 fprintf(stderr, "ERROR: could not calloc My_Account\n");
208 return NULL;
209 }
210
211 acc->name = eina_stringshare_add(name);
212 return acc;
213} /* _my_account_new */
214
215static void
216_my_account_free(My_Account *acc)
217{
218 My_Message *m;
219 int i;
220
221 _eet_string_free(acc->name);
222
223 EINA_LIST_FREE(acc->messages, m)
224 _my_message_free(m);
225
226 for (i = 0; i < acc->posts_count; i++)
227 _my_post_free(&acc->posts[i]);
228 free(acc->posts);
229
230 free(acc);
231} /* _my_account_free */
232
233static My_Cache *
234_my_cache_new(void)
235{
236 My_Cache *my_cache = calloc(1, sizeof(My_Cache));
237 if (!my_cache)
238 {
239 fprintf(stderr, "ERROR: could not calloc My_Cache\n");
240 return NULL;
241 }
242
243 my_cache->accounts = eina_hash_string_small_new(NULL);
244
245 my_cache->version = 1;
246 return my_cache;
247} /* _my_cache_new */
248
249static Eina_Bool
250_my_cache_account_free_cb(const Eina_Hash *hash,
251 const void *key,
252 void *data,
253 void *fdata)
254{
255 _my_account_free(data);
256 return EINA_TRUE;
257}
258
259static void
260_my_cache_free(My_Cache *my_cache)
261{
262 My_Account *acc;
263 eina_hash_foreach(my_cache->accounts, _my_cache_account_free_cb, NULL);
264 eina_hash_free(my_cache->accounts);
265 free(my_cache);
266} /* _my_cache_free */
267
268static My_Account *
269_my_cache_account_find(My_Cache *my_cache,
270 const char *name)
271{
272 return eina_hash_find(my_cache->accounts, name);
273} /* _my_cache_account_find */
274
275static My_Cache *
276_my_cache_load(const char *filename)
277{
278 My_Cache *my_cache;
279 Eet_File *ef = eet_open(filename, EET_FILE_MODE_READ);
280 if (!ef)
281 {
282 fprintf(stderr, "ERROR: could not open '%s' for read\n", filename);
283 return NULL;
284 }
285
286 my_cache = eet_data_read(ef, _my_cache_descriptor, MY_CACHE_FILE_ENTRY);
287 if (!my_cache)
288 {
289 eet_close(ef);
290 return NULL;
291 }
292
293 if (my_cache->version < 1)
294 {
295 fprintf(stderr,
296 "WARNING: version %#x was too old, upgrading it to %#x\n",
297 my_cache->version, 1);
298
299 my_cache->version = 1;
300 }
301
302 if (_my_cache_file)
303 eet_close(_my_cache_file);
304
305 _my_cache_file = ef;
306 _my_cache_dict = eet_dictionary_get(ef);
307
308 return my_cache;
309} /* _my_cache_load */
310
311static Eina_Bool
312_my_cache_save(const My_Cache *my_cache,
313 const char *filename)
314{
315 char tmp[PATH_MAX];
316 Eet_File *ef;
317 Eina_Bool ret;
318 unsigned int i, len;
319 struct stat st;
320
321 len = eina_strlcpy(tmp, filename, sizeof(tmp));
322 if (len + 12 >= (int)sizeof(tmp))
323 {
324 fprintf(stderr, "ERROR: file name is too big: %s\n", filename);
325 return EINA_FALSE;
326 }
327
328 i = 0;
329 do
330 {
331 snprintf(tmp + len, 12, ".%u", i);
332 i++;
333 }
334 while (stat(tmp, &st) == 0);
335
336 ef = eet_open(tmp, EET_FILE_MODE_WRITE);
337 if (!ef)
338 {
339 fprintf(stderr, "ERROR: could not open '%s' for write\n", tmp);
340 return EINA_FALSE;
341 }
342
343 ret = eet_data_write
344 (ef, _my_cache_descriptor, MY_CACHE_FILE_ENTRY, my_cache, EINA_TRUE);
345
346 // VERY IMPORTANT NOTE:
347 // after eet_close(), all strings mmaped from file will be GONE, invalid!
348 // you'll need to free the old cache and open the new one.
349 // For cache this is okay, as you should be saving not so often or just
350 // at end.
351 //
352 // This is a trade off, you save memory by using mmap()ed strings, but
353 // you have to care about this.
354 eet_close(ef);
355
356 if (ret)
357 {
358 unlink(filename);
359 rename(tmp, filename);
360 }
361
362 return ret;
363} /* _my_cache_save */
364
365int
366main(int argc,
367 char *argv[])
368{
369 My_Cache *my_cache;
370 const Eina_List *l_acc;
371 Eina_Iterator *it;
372 My_Account *acc;
373 int ret = 0;
374
375 if (argc < 3)
376 {
377 fprintf(stderr,
378 "Usage:\n\t%s <input> <output> [action] [action-params]\n\n"
379 "Where actions and their parameters:\n"
380 "\tacc <name>\n"
381 "\tpost <account-name> <message>\n"
382 "\tmessage <account-name> <message>\n"
383 "\n",
384 argv[0]);
385 return -1;
386 }
387
388 eina_init();
389 eet_init();
390 _my_cache_descriptor_init();
391
392 my_cache = _my_cache_load(argv[1]);
393 if (!my_cache)
394 {
395 printf("creating new cache.\n");
396 my_cache = _my_cache_new();
397 if (!my_cache)
398 {
399 ret = -2;
400 goto end;
401 }
402 }
403
404 if (argc > 3)
405 {
406 if (strcmp(argv[3], "acc") == 0)
407 {
408 if (argc == 5)
409 {
410 My_Account *acc = _my_cache_account_find(my_cache, argv[4]);
411 if (!acc)
412 {
413 acc = _my_account_new(argv[4]);
414 eina_hash_direct_add(my_cache->accounts, acc->name, acc);
415 }
416 else
417 fprintf(stderr, "ERROR: account '%s' already exists.\n",
418 argv[4]);
419 }
420 else
421 fprintf(stderr,
422 "ERROR: wrong number of parameters (%d).\n",
423 argc);
424 }
425 else if (strcmp(argv[3], "post") == 0)
426 {
427 if (argc == 6)
428 {
429 My_Account *acc = _my_cache_account_find(my_cache, argv[4]);
430 if (acc)
431 {
432 _my_post_add(acc, argv[5]);
433 }
434 else
435 fprintf(stderr, "ERROR: unknown account: '%s'\n", argv[4]);
436 }
437 else
438 fprintf(stderr,
439 "ERROR: wrong number of parameters (%d).\n",
440 argc);
441 }
442 else if (strcmp(argv[3], "message") == 0)
443 {
444 if (argc == 6)
445 {
446 My_Account *acc = _my_cache_account_find(my_cache, argv[4]);
447 if (acc)
448 {
449 My_Message *msg = _my_message_new(argv[5]);
450 acc->messages = eina_list_append(acc->messages, msg);
451 }
452 else
453 fprintf(stderr, "ERROR: unknown account: '%s'\n", argv[4]);
454 }
455 else
456 fprintf(stderr,
457 "ERROR: wrong number of parameters (%d).\n",
458 argc);
459 }
460 else
461 fprintf(stderr, "ERROR: unknown action '%s'\n", argv[2]);
462 }
463
464 printf("My_Cache:\n"
465 "\tversion.: %#x\n"
466 "\taccounts: %u\n",
467 my_cache->version,
468 eina_hash_population(my_cache->accounts));
469 it = eina_hash_iterator_data_new(my_cache->accounts);
470 EINA_ITERATOR_FOREACH(it, acc)
471 {
472 const My_Post *post;
473
474 printf("\t > %-#8x '%.20s' stats: m=%u, p=%u\n",
475 acc->id, acc->name ? acc->name : "",
476 eina_list_count(acc->messages),
477 acc->posts_count);
478
479 if (eina_list_count(acc->messages))
480 {
481 const Eina_List *l;
482 const My_Message *msg;
483 printf("\t |messages:\n");
484
485 EINA_LIST_FOREACH(acc->messages, l, msg)
486 {
487 printf("\t | %-8x '%s' [%s]: '%.20s'\n",
488 msg->id,
489 msg->name ? msg->name : "",
490 msg->screen_name ? msg->screen_name : "",
491 msg->message ? msg->message : "");
492 }
493 }
494
495 if (acc->posts_count)
496 {
497 const My_Post *post;
498 int i;
499 printf("\t |posts:\n");
500
501 for (i = 0; i < acc->posts_count; i++)
502 {
503 post = &acc->posts[i];
504 if (post->dm_to)
505 printf("\t | @%s: '%.20s'\n", post->dm_to, post->message);
506 else
507 printf("\t | '%.20s'\n", post->message);
508 }
509 }
510
511 printf("\n");
512 }
513 eina_iterator_free(it);
514
515 if (!_my_cache_save(my_cache, argv[2]))
516 ret = -3;
517
518 _my_cache_free(my_cache);
519
520end:
521 if (_my_cache_file)
522 eet_close(_my_cache_file);
523 _my_cache_descriptor_shutdown();
524 eet_shutdown();
525 eina_shutdown();
526
527 return ret;
528} /* main */
529
diff --git a/libraries/eet/src/examples/eet-data-file_descriptor_02.c b/libraries/eet/src/examples/eet-data-file_descriptor_02.c
deleted file mode 100644
index 65ba79e..0000000
--- a/libraries/eet/src/examples/eet-data-file_descriptor_02.c
+++ /dev/null
@@ -1,944 +0,0 @@
1/*
2 * build: gcc -o eet_data_file_descriptor_02 eet-data-file_descriptor_02.c `pkg-config --cflags --libs eet eina`
3 */
4
5#include <Eina.h>
6#include <Eet.h>
7#include <stdio.h>
8#include <limits.h>
9#include <sys/types.h>
10#include <sys/stat.h>
11#include <unistd.h>
12
13typedef enum _Example_Data_Type Example_Data_Type;
14typedef struct _Example_Variant_Type Example_Variant_Type;
15typedef struct _Example_Variant Example_Variant;
16typedef struct _Example_Union Example_Union;
17typedef struct _Example_Struct1 Example_Struct1;
18typedef struct _Example_Struct2 Example_Struct2;
19typedef struct _Example_Struct3 Example_Struct3;
20typedef struct _Example_Lists Example_Lists;
21
22enum _Example_Data_Type
23{
24 EET_UNKNOWN = 0,
25 EET_STRUCT1,
26 EET_STRUCT2,
27 EET_STRUCT3
28};
29
30struct
31{
32 Example_Data_Type u;
33 const char *name;
34} eet_mapping[] = {
35 { EET_STRUCT1, "ST1" },
36 { EET_STRUCT2, "ST2" },
37 { EET_STRUCT3, "ST3" },
38 { EET_UNKNOWN, NULL }
39};
40
41struct _Example_Struct1
42{
43 double val1;
44 int stuff;
45 const char *s1;
46};
47
48struct _Example_Struct2
49{
50 Eina_Bool b1;
51 unsigned long long v1;
52};
53
54struct _Example_Struct3
55{
56 int body;
57};
58
59struct _Example_Union
60{
61 Example_Data_Type type;
62
63 union {
64 Example_Struct1 st1;
65 Example_Struct2 st2;
66 Example_Struct3 st3;
67 } u;
68};
69
70struct _Example_Variant_Type
71{
72 const char *type;
73 Eina_Bool unknow : 1;
74};
75
76struct _Example_Variant
77{
78 Example_Variant_Type t;
79
80 void *data; /* differently than the union type, we
81 * don't need to pre-allocate the memory
82 * for the field*/
83};
84
85struct _Example_Lists
86{
87 Eina_List *union_list;
88 Eina_List *variant_list;
89};
90
91static void
92_st1_set(Example_Struct1 *st1,
93 double v1,
94 int v2,
95 const char *v3)
96{
97 st1->val1 = v1;
98 st1->stuff = v2;
99 st1->s1 = v3;
100} /* _st1_set */
101
102static void
103_st2_set(Example_Struct2 *st2,
104 Eina_Bool v1,
105 unsigned long long v2)
106{
107 st2->b1 = v1;
108 st2->v1 = v2;
109} /* _st2_set */
110
111static void
112_st3_set(Example_Struct3 *st3,
113 int v1)
114{
115 st3->body = v1;
116} /* _st3_set */
117
118static const char *
119/* union
120 type_get() */
121_union_type_get(const void *data,
122 Eina_Bool *unknow)
123{
124 const Example_Data_Type *u = data;
125 int i;
126
127 if (unknow)
128 *unknow = EINA_FALSE;
129
130 for (i = 0; eet_mapping[i].name != NULL; ++i)
131 if (*u == eet_mapping[i].u)
132 return eet_mapping[i].name;
133
134 if (unknow)
135 *unknow = EINA_TRUE;
136
137 return NULL;
138} /* _union_type_get */
139
140static Eina_Bool
141_union_type_set(const char *type,
142 void *data,
143 Eina_Bool unknow)
144{
145 Example_Data_Type *u = data;
146 int i;
147
148 if (unknow)
149 return EINA_FALSE;
150
151 for (i = 0; eet_mapping[i].name != NULL; ++i)
152 if (strcmp(eet_mapping[i].name, type) == 0)
153 {
154 *u = eet_mapping[i].u;
155 return EINA_TRUE;
156 }
157
158 return EINA_FALSE;
159} /* _union_type_set */
160
161static const char *
162_variant_type_get(const void *data,
163 Eina_Bool *unknow)
164{
165 const Example_Variant_Type *type = data;
166 int i;
167
168 if (unknow)
169 *unknow = type->unknow;
170
171 for (i = 0; eet_mapping[i].name != NULL; ++i)
172 if (strcmp(type->type, eet_mapping[i].name) == 0)
173 return eet_mapping[i].name;
174
175 if (unknow)
176 *unknow = EINA_FALSE;
177
178 return type->type;
179} /* _variant_type_get */
180
181static Eina_Bool
182_variant_type_set(const char *type,
183 void *data,
184 Eina_Bool unknow)
185{
186 Example_Variant_Type *vt = data;
187
188 vt->type = type;
189 vt->unknow = unknow;
190 return EINA_TRUE;
191} /* _variant_type_set */
192
193static Eet_Data_Descriptor *
194_st1_dd(void)
195{
196 Eet_Data_Descriptor_Class eddc;
197 Eet_Data_Descriptor *res;
198
199 EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(&eddc, Example_Struct1);
200 res = eet_data_descriptor_file_new(&eddc);
201 EET_DATA_DESCRIPTOR_ADD_BASIC(
202 res, Example_Struct1, "val1", val1, EET_T_DOUBLE);
203 EET_DATA_DESCRIPTOR_ADD_BASIC(
204 res, Example_Struct1, "stuff", stuff, EET_T_INT);
205 EET_DATA_DESCRIPTOR_ADD_BASIC(
206 res, Example_Struct1, "s1", s1, EET_T_STRING);
207
208 return res;
209} /* _st1_dd */
210
211static Eet_Data_Descriptor *
212_st2_dd(void)
213{
214 Eet_Data_Descriptor_Class eddc;
215 Eet_Data_Descriptor *res;
216
217 EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(&eddc, Example_Struct2);
218 res = eet_data_descriptor_file_new(&eddc);
219 EET_DATA_DESCRIPTOR_ADD_BASIC(
220 res, Example_Struct2, "b1", b1, EET_T_UCHAR);
221 EET_DATA_DESCRIPTOR_ADD_BASIC(
222 res, Example_Struct2, "v1", v1, EET_T_ULONG_LONG);
223
224 return res;
225} /* _st2_dd */
226
227static Eet_Data_Descriptor *
228_st3_dd(void)
229{
230 Eet_Data_Descriptor_Class eddc;
231 Eet_Data_Descriptor *res;
232
233 EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(&eddc, Example_Struct3);
234 res = eet_data_descriptor_file_new(&eddc);
235 EET_DATA_DESCRIPTOR_ADD_BASIC(
236 res, Example_Struct3, "body", body, EET_T_INT);
237
238 return res;
239} /* _st3_dd */
240
241/* string that represents the entry in the eet file. you might like to
242 * have different profiles or so in the same file, this is possible
243 * with different strings
244 */
245static const char CACHE_FILE_ENTRY[] = "cache";
246
247/* keep the descriptor static global, so it can be shared by different
248 * functions (load/save) of this and only this file.
249 */
250static Eet_Data_Descriptor *_lists_descriptor;
251static Eet_Data_Descriptor *_struct_1_descriptor;
252static Eet_Data_Descriptor *_struct_2_descriptor;
253static Eet_Data_Descriptor *_struct_3_descriptor;
254static Eet_Data_Descriptor *_union_descriptor;
255static Eet_Data_Descriptor *_variant_descriptor;
256static Eet_Data_Descriptor *_union_unified_descriptor;
257static Eet_Data_Descriptor *_variant_unified_descriptor;
258
259/* keep file handle alive, so mmap()ed strings are all alive as
260 * well */
261static Eet_File *_cache_file = NULL;
262static Eet_Dictionary *_cache_dict = NULL;
263
264static void
265/* declaring types */
266_data_descriptors_init(void)
267{
268 Eet_Data_Descriptor_Class eddc;
269
270 EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(&eddc, Example_Lists);
271 _lists_descriptor = eet_data_descriptor_file_new(&eddc);
272
273 _struct_1_descriptor = _st1_dd();
274 _struct_2_descriptor = _st2_dd();
275 _struct_3_descriptor = _st3_dd();
276
277 /* for union */
278 EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(&eddc, Example_Union);
279 _union_descriptor = eet_data_descriptor_file_new(&eddc);
280
281 eddc.version = EET_DATA_DESCRIPTOR_CLASS_VERSION;
282 eddc.func.type_get = _union_type_get;
283 eddc.func.type_set = _union_type_set;
284 _union_unified_descriptor = eet_data_descriptor_file_new(&eddc);
285
286 EET_DATA_DESCRIPTOR_ADD_MAPPING(
287 _union_unified_descriptor, "ST1", _struct_1_descriptor);
288 EET_DATA_DESCRIPTOR_ADD_MAPPING(
289 _union_unified_descriptor, "ST2", _struct_2_descriptor);
290 EET_DATA_DESCRIPTOR_ADD_MAPPING(
291 _union_unified_descriptor, "ST3", _struct_3_descriptor);
292
293 EET_DATA_DESCRIPTOR_ADD_UNION(
294 _union_descriptor, Example_Union, "u", u, type,
295 _union_unified_descriptor);
296
297 EET_DATA_DESCRIPTOR_ADD_LIST(
298 _lists_descriptor, Example_Lists, "union_list", union_list,
299 _union_descriptor);
300
301 /* for variant */
302 EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(&eddc, Example_Variant);
303 _variant_descriptor = eet_data_descriptor_file_new(&eddc);
304
305 eddc.version = EET_DATA_DESCRIPTOR_CLASS_VERSION;
306 eddc.func.type_get = _variant_type_get;
307 eddc.func.type_set = _variant_type_set;
308 _variant_unified_descriptor = eet_data_descriptor_stream_new(&eddc);
309
310 EET_DATA_DESCRIPTOR_ADD_MAPPING(
311 _variant_unified_descriptor, "ST1", _struct_1_descriptor);
312 EET_DATA_DESCRIPTOR_ADD_MAPPING(
313 _variant_unified_descriptor, "ST2", _struct_2_descriptor);
314 EET_DATA_DESCRIPTOR_ADD_MAPPING(
315 _variant_unified_descriptor, "ST3", _struct_3_descriptor);
316
317 EET_DATA_DESCRIPTOR_ADD_VARIANT(
318 _variant_descriptor, Example_Variant, "data", data, t,
319 _variant_unified_descriptor);
320
321 EET_DATA_DESCRIPTOR_ADD_LIST(
322 _lists_descriptor, Example_Lists, "variant_list", variant_list,
323 _variant_descriptor);
324} /* _data_descriptors_init */
325
326static void
327_data_descriptors_shutdown(void)
328{
329 eet_data_descriptor_free(_lists_descriptor);
330 eet_data_descriptor_free(_struct_1_descriptor);
331 eet_data_descriptor_free(_struct_2_descriptor);
332 eet_data_descriptor_free(_struct_3_descriptor);
333 eet_data_descriptor_free(_union_descriptor);
334 eet_data_descriptor_free(_variant_descriptor);
335 eet_data_descriptor_free(_union_unified_descriptor);
336 eet_data_descriptor_free(_variant_unified_descriptor);
337} /* _data_descriptors_shutdown */
338
339/* need to check if the pointer came from mmap()ed area in
340 * eet_dictionary or it was allocated with eina_stringshare_add()
341 */
342static void
343_string_free(const char *str)
344{
345 if (!str)
346 return;
347
348 if ((_cache_dict) && (eet_dictionary_string_check(_cache_dict, str)))
349 return;
350
351 eina_stringshare_del(str);
352} /* _string_free */
353
354static Example_Union *
355_union_1_new(const char *v1,
356 const char *v2,
357 const char *v3)
358{
359 Example_Union *un = calloc(1, sizeof(Example_Union));
360 if (!un)
361 {
362 fprintf(
363 stderr, "ERROR: could not allocate an Example_Union struct.\n");
364 return NULL;
365 }
366
367 un->type = EET_STRUCT1;
368 _st1_set(&(un->u.st1), atof(v1), atoi(v2), eina_stringshare_add(v3));
369
370 return un;
371}
372
373static Example_Union *
374_union_2_new(const char *v1,
375 const char *v2)
376{
377 Example_Union *un = calloc(1, sizeof(Example_Union));
378 if (!un)
379 {
380 fprintf(
381 stderr, "ERROR: could not allocate an Example_Union struct.\n");
382 return NULL;
383 }
384
385 un->type = EET_STRUCT2;
386 _st2_set(&(un->u.st2), atoi(v1), atoi(v2));
387
388 return un;
389}
390
391static Example_Union *
392_union_3_new(const char *v1)
393{
394 Example_Union *un = calloc(1, sizeof(Example_Union));
395 if (!un)
396 {
397 fprintf(
398 stderr, "ERROR: could not allocate an Example_Union struct.\n");
399 return NULL;
400 }
401
402 un->type = EET_STRUCT3;
403 _st3_set(&(un->u.st3), atoi(v1));
404
405 return un;
406}
407
408static Example_Variant *
409_variant_1_new(const char *v1,
410 const char *v2,
411 const char *v3)
412{
413 Example_Struct1 *st1;
414 Example_Variant *va = calloc(1, sizeof(Example_Variant));
415 if (!va)
416 {
417 fprintf(
418 stderr, "ERROR: could not allocate an Example_Variant struct.\n");
419 return NULL;
420 }
421
422 va = calloc(1, sizeof (Example_Variant));
423 va->t.type = eet_mapping[0].name;
424 st1 = calloc(1, sizeof (Example_Struct1));
425 _st1_set(st1, atof(v1), atoi(v2), eina_stringshare_add(v3));
426 va->data = st1;
427
428 return va;
429}
430
431static Example_Variant *
432_variant_2_new(const char *v1,
433 const char *v2)
434{
435 printf("varinant 2 new\n");
436
437 Example_Struct2 *st2;
438 Example_Variant *va = calloc(1, sizeof(Example_Variant));
439 if (!va)
440 {
441 fprintf(
442 stderr, "ERROR: could not allocate an Example_Variant struct.\n");
443 return NULL;
444 }
445
446 va = calloc(1, sizeof (Example_Variant));
447
448 va->t.type = eet_mapping[1].name;
449
450 printf("type gets %s\n", va->t.type);
451
452 st2 = calloc(1, sizeof (Example_Struct2));
453 _st2_set(st2, atoi(v1), atoi(v2));
454 va->data = st2;
455
456 return va;
457}
458
459static Example_Variant *
460_variant_3_new(const char *v1)
461{
462 Example_Struct3 *st3;
463 Example_Variant *va = calloc(1, sizeof(Example_Variant));
464 if (!va)
465 {
466 fprintf(
467 stderr, "ERROR: could not allocate an Example_Variant struct.\n");
468 return NULL;
469 }
470
471 va = calloc(1, sizeof (Example_Variant));
472 va->t.type = eet_mapping[2].name;
473 st3 = calloc(1, sizeof (Example_Struct3));
474 _st3_set(st3, atoi(v1));
475 va->data = st3;
476
477 return va;
478}
479
480static Example_Lists *
481_data_new(void)
482{
483 Example_Lists *example_lists = calloc(1, sizeof(Example_Lists));
484 if (!example_lists)
485 {
486 fprintf(stderr, "ERROR: could not allocate a Example_Lists struct.\n");
487 return NULL;
488 }
489
490 return example_lists;
491} /* _data_new */
492
493static void
494_union_free(Example_Union *un)
495{
496 if (un->type == EET_STRUCT1)
497 {
498 Example_Struct1 *st1 = &(un->u.st1);
499 _string_free(st1->s1);
500 }
501
502 free(un);
503}
504
505static void
506_variant_free(Example_Variant *va)
507{
508 if (!strcmp(va->t.type, eet_mapping[0].name))
509 {
510 Example_Struct1 *st1 = va->data;
511 _string_free(st1->s1);
512 }
513
514 free(va->data);
515 free(va);
516}
517
518static void
519_data_free(Example_Lists *cache)
520{
521 Example_Union *un;
522 Example_Variant *va;
523
524 EINA_LIST_FREE(cache->union_list, un)
525 _union_free(un);
526
527 EINA_LIST_FREE(cache->variant_list, va)
528 _variant_free(va);
529
530 free(cache);
531} /* _data_free */
532
533static Example_Lists *
534_data_load(const char *filename)
535{
536 Example_Lists *data;
537 Eet_File *ef = eet_open(filename, EET_FILE_MODE_READ);
538 if (!ef)
539 {
540 fprintf(stderr, "ERROR: could not open '%s' for read\n", filename);
541 return NULL;
542 }
543
544 data = eet_data_read(ef, _lists_descriptor, CACHE_FILE_ENTRY);
545 if (!data)
546 {
547 eet_close(ef);
548 return NULL;
549 }
550
551 if (_cache_file)
552 eet_close(_cache_file);
553
554 _cache_file = ef;
555 _cache_dict = eet_dictionary_get(ef);
556
557 return data;
558} /* _data_load */
559
560static Eina_Bool
561_data_save(const Example_Lists *cache,
562 const char *filename)
563{
564 char tmp[PATH_MAX];
565 Eet_File *ef;
566 Eina_Bool ret;
567 unsigned int i, len;
568 struct stat st;
569
570 len = eina_strlcpy(tmp, filename, sizeof(tmp));
571 if (len + 12 >= (int)sizeof(tmp))
572 {
573 fprintf(stderr, "ERROR: file name is too big: %s\n", filename);
574 return EINA_FALSE;
575 }
576
577 i = 0;
578 do
579 {
580 snprintf(tmp + len, 12, ".%u", i);
581 i++;
582 }
583 while (stat(tmp, &st) == 0);
584
585 ef = eet_open(tmp, EET_FILE_MODE_WRITE);
586 if (!ef)
587 {
588 fprintf(stderr, "ERROR: could not open '%s' for write\n", tmp);
589 return EINA_FALSE;
590 }
591
592 ret = eet_data_write
593 (ef, _lists_descriptor, CACHE_FILE_ENTRY, cache, EINA_TRUE);
594
595 eet_close(ef);
596
597 if (ret)
598 {
599 unlink(filename);
600 rename(tmp, filename);
601 }
602
603 return ret;
604} /* _data_save */
605
606static void
607_print_union(const Example_Union *un)
608{
609 printf("\t | type: %s'\n", eet_mapping[un->type - 1].name);
610
611 switch (un->type)
612 {
613 case EET_STRUCT1:
614 printf("\t\t val1: %f\n", un->u.st1.val1);
615 printf("\t\t stuff: %d\n", un->u.st1.stuff);
616 printf("\t\t s1: %s\n", un->u.st1.s1);
617 break;
618
619 case EET_STRUCT2:
620 printf("\t\t val1: %i\n", un->u.st2.b1);
621 printf("\t\t stuff: %lli\n", un->u.st2.v1);
622 break;
623
624 case EET_STRUCT3:
625 printf("\t\t val1: %i\n", un->u.st3.body);
626 break;
627
628 default:
629 return;
630 }
631}
632
633static void
634_print_variant(const Example_Variant *va)
635{
636 printf("\t | type: %s'\n", va->t.type);
637
638 switch (va->t.type[2])
639 {
640 case '1':
641 {
642 Example_Struct1 *st1 = va->data;
643
644 printf("\t\t val1: %f\n", st1->val1);
645 printf("\t\t stuff: %d\n", st1->stuff);
646 printf("\t\t s1: %s\n", st1->s1);
647 }
648 break;
649
650 case '2':
651 {
652 Example_Struct2 *st2 = va->data;
653
654 printf("\t\t val1: %i\n", st2->b1);
655 printf("\t\t stuff: %lli\n", st2->v1);
656 }
657 break;
658
659 case '3':
660 {
661 Example_Struct3 *st3 = va->data;
662
663 printf("\t\t val1: %i\n", st3->body);
664 }
665 break;
666
667 default:
668 return;
669 }
670}
671
672int
673main(int argc,
674 char *argv[])
675{
676 Example_Lists *data_lists;
677 int ret = 0;
678
679 if (argc < 3)
680 {
681 fprintf(stderr,
682 "Usage:\n\t%s <input> <output> [action action-params]\n\n"
683 "where actions and their parameters are:\n"
684 "\tunion <type> [fields]\n"
685 "\tvariant <type> [fields]\n"
686 "\n",
687 argv[0]);
688 return -1;
689 }
690
691 eina_init();
692 eet_init();
693 _data_descriptors_init();
694
695 data_lists = _data_load(argv[1]);
696 if (!data_lists)
697 {
698 printf("Creating new data lists.\n");
699 data_lists = _data_new();
700 if (!data_lists)
701 {
702 ret = -2;
703 goto end;
704 }
705 }
706
707 if (argc > 3)
708 {
709 if (strcmp(argv[3], "union") == 0)
710 {
711 if (argc > 4)
712 {
713 int type = atoi(argv[4]);
714 Example_Union *un;
715
716 if (type < EET_STRUCT1 || type > EET_STRUCT3)
717 {
718 fprintf(stderr,
719 "ERROR: invalid type parameter (%s).\n",
720 argv[4]);
721 goto cont;
722 }
723
724 switch (type)
725 {
726 case 1:
727 if (argc != 8)
728 {
729 fprintf(
730 stderr, "ERROR: wrong number of parameters"
731 " (%d).\n", argc);
732 goto cont;
733 }
734
735 un = _union_1_new(
736 argv[5], argv[6], argv[7]);
737 if (!un)
738 {
739 fprintf(
740 stderr, "ERROR: could not create the "
741 "requested union.\n");
742 goto cont;
743 }
744 data_lists->union_list =
745 eina_list_append(data_lists->union_list, un);
746 break;
747
748 case 2:
749 if (argc != 7)
750 {
751 fprintf(
752 stderr, "ERROR: wrong number of parameters"
753 " (%d).\n", argc);
754 goto cont;
755 }
756
757 un = _union_2_new(argv[5], argv[6]);
758 if (!un)
759 {
760 fprintf(
761 stderr, "ERROR: could not create the "
762 "requested union.\n");
763 goto cont;
764 }
765 data_lists->union_list =
766 eina_list_append(data_lists->union_list, un);
767 break;
768
769 case 3:
770 if (argc != 6)
771 {
772 fprintf(
773 stderr, "ERROR: wrong number of parameters"
774 " (%d).\n", argc);
775 goto cont;
776 }
777
778 un = _union_3_new(argv[5]);
779 if (!un)
780 {
781 fprintf(
782 stderr, "ERROR: could not create the "
783 "requested union.\n");
784 goto cont;
785 }
786 data_lists->union_list =
787 eina_list_append(data_lists->union_list, un);
788 break;
789
790 default:
791 fprintf(
792 stderr, "ERROR: bad type of of struct passed\n");
793 goto cont;
794 }
795 }
796 else
797 fprintf(stderr,
798 "ERROR: wrong number of parameters (%d).\n",
799 argc);
800 }
801 else if (strcmp(argv[3], "variant") == 0)
802 {
803 if (argc > 4)
804 {
805 int type = atoi(argv[4]);
806 Example_Variant *va;
807
808 if (type < EET_STRUCT1 || type > EET_STRUCT3)
809 {
810 fprintf(stderr,
811 "ERROR: invalid type parameter (%s).\n",
812 argv[4]);
813 goto cont;
814 }
815
816 switch (type)
817 {
818 case 1:
819 if (argc != 8)
820 {
821 fprintf(
822 stderr, "ERROR: wrong number of parameters"
823 " (%d).\n", argc);
824 goto cont;
825 }
826
827 va = _variant_1_new(
828 argv[5], argv[6], argv[7]);
829 if (!va)
830 {
831 fprintf(
832 stderr, "ERROR: could not create the "
833 "requested variant.\n");
834 goto cont;
835 }
836 data_lists->variant_list =
837 eina_list_append(data_lists->variant_list, va);
838 break;
839
840 case 2:
841 if (argc != 7)
842 {
843 fprintf(
844 stderr, "ERROR: wrong number of parameters"
845 " (%d).\n", argc);
846 goto cont;
847 }
848
849 va = _variant_2_new(argv[5], argv[6]);
850 if (!va)
851 {
852 fprintf(
853 stderr, "ERROR: could not create the "
854 "requested variant.\n");
855 goto cont;
856 }
857 data_lists->variant_list =
858 eina_list_append(data_lists->variant_list, va);
859 break;
860
861 case 3:
862 if (argc != 6)
863 {
864 fprintf(
865 stderr, "ERROR: wrong number of parameters"
866 " (%d).\n", argc);
867 goto cont;
868 }
869
870 va = _variant_3_new(argv[5]);
871 if (!va)
872 {
873 fprintf(
874 stderr, "ERROR: could not create the "
875 "requested variant.\n");
876 goto cont;
877 }
878 data_lists->variant_list =
879 eina_list_append(data_lists->variant_list, va);
880 break;
881
882 default:
883 fprintf(
884 stderr, "ERROR: bad type of of struct passed\n");
885 goto cont;
886 }
887 }
888 else
889 fprintf(stderr,
890 "ERROR: wrong number of parameters (%d).\n",
891 argc);
892 }
893 else
894 fprintf(stderr, "ERROR: unknown action '%s'\n", argv[3]);
895 }
896
897cont:
898 printf("Cached data:\n");
899
900 printf("\tstats: unions=%u, variants=%u\n",
901 eina_list_count(data_lists->union_list),
902 eina_list_count(data_lists->variant_list));
903
904 if (eina_list_count(data_lists->union_list))
905 {
906 const Eina_List *l;
907 const Example_Union *un;
908 printf("\t * union list:\n");
909
910 EINA_LIST_FOREACH(data_lists->union_list, l, un)
911 {
912 _print_union(un);
913 }
914 }
915
916 if (eina_list_count(data_lists->variant_list))
917 {
918 const Eina_List *l;
919 const Example_Variant *un;
920 printf("\t * variant list:\n");
921
922 EINA_LIST_FOREACH(data_lists->variant_list, l, un)
923 {
924 _print_variant(un);
925 }
926 }
927
928 printf("\n");
929
930 if (!_data_save(data_lists, argv[2]))
931 ret = -3;
932
933 _data_free(data_lists);
934
935end:
936 if (_cache_file)
937 eet_close(_cache_file);
938 _data_descriptors_shutdown();
939 eet_shutdown();
940 eina_shutdown();
941
942 return ret;
943} /* main */
944
diff --git a/libraries/eet/src/examples/eet-data-nested.c b/libraries/eet/src/examples/eet-data-nested.c
deleted file mode 100644
index a6b0e12..0000000
--- a/libraries/eet/src/examples/eet-data-nested.c
+++ /dev/null
@@ -1,272 +0,0 @@
1/*
2 * build: gcc -o eet_data_nested eet-data-nested.c `pkg-config --cflags --libs eet eina`
3 */
4#include <Eina.h>
5#include <Eet.h>
6#include <stdio.h>
7#include <limits.h>
8#include <sys/types.h>
9#include <sys/stat.h>
10#include <unistd.h>
11
12// The struct that will be loaded and saved.
13// note that only the members described in the eet_data_descriptor
14// will be automatically handled. The other members will have their
15// space reserved and zeroed (as it uses calloc()), but not
16// saved or loaded from eet files.
17typedef struct
18{
19 unsigned int version; // it is recommended to use versioned configuration!
20 const char *name;
21 int id;
22 int not_saved_value; // example of not saved data inside!
23 Eina_Bool enabled;
24 Eina_List *subs;
25} My_Conf_Type;
26
27typedef struct
28{
29 const char *server;
30 int port;
31} My_Conf_Subtype;
32
33// string that represents the entry in eet file, you might like to have
34// different profiles or so in the same file, this is possible with
35// different strings
36static const char MY_CONF_FILE_ENTRY[] = "config";
37
38// keep the descriptor static global, so it can be
39// shared by different functions (load/save) of this and only this
40// file.
41static Eet_Data_Descriptor *_my_conf_descriptor;
42static Eet_Data_Descriptor *_my_conf_sub_descriptor;
43
44static void
45_my_conf_descriptor_init(void)
46{
47 Eet_Data_Descriptor_Class eddc;
48
49 // The class describe the functions to use to create the type and its
50 // full allocated size.
51 //
52 // Eina types are very convenient, so use them to create the descriptor,
53 // so we get eina_list, eina_hash and eina_stringshare automatically!
54 //
55 // The STREAM variant is better for configuration files as the values
56 // will likely change a lot.
57 //
58 // The other variant, FILE, is good for caches and things that are just
59 // appended, but needs to take care when changing strings and files must
60 // be kept open so mmap()ed strings will be kept alive.
61 EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eddc, My_Conf_Type);
62 _my_conf_descriptor = eet_data_descriptor_stream_new(&eddc);
63
64 EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eddc, My_Conf_Subtype);
65 _my_conf_sub_descriptor = eet_data_descriptor_stream_new(&eddc);
66
67 // Describe the members to be saved:
68 // Use a temporary macro so we don't type a lot, also avoid errors:
69#define MY_CONF_ADD_BASIC(member, eet_type) \
70 EET_DATA_DESCRIPTOR_ADD_BASIC \
71 (_my_conf_descriptor, My_Conf_Type, # member, member, eet_type)
72#define MY_CONF_SUB_ADD_BASIC(member, eet_type) \
73 EET_DATA_DESCRIPTOR_ADD_BASIC \
74 (_my_conf_sub_descriptor, My_Conf_Subtype, # member, member, eet_type)
75
76 MY_CONF_SUB_ADD_BASIC(server, EET_T_STRING);
77 MY_CONF_SUB_ADD_BASIC(port, EET_T_INT);
78
79 MY_CONF_ADD_BASIC(version, EET_T_UINT);
80 MY_CONF_ADD_BASIC(name, EET_T_STRING);
81 MY_CONF_ADD_BASIC(id, EET_T_INT);
82 MY_CONF_ADD_BASIC(enabled, EET_T_UCHAR);
83
84 // And add the sub descriptor as a linked list at 'subs' in the main struct
85 EET_DATA_DESCRIPTOR_ADD_LIST
86 (_my_conf_descriptor, My_Conf_Type, "subs", subs, _my_conf_sub_descriptor);
87
88#undef MY_CONF_ADD_BASIC
89#undef MY_CONF_SUB_ADD_BASIC
90} /* _my_conf_descriptor_init */
91
92static void
93_my_conf_descriptor_shutdown(void)
94{
95 eet_data_descriptor_free(_my_conf_sub_descriptor);
96 eet_data_descriptor_free(_my_conf_descriptor);
97} /* _my_conf_descriptor_shutdown */
98
99static My_Conf_Type *
100_my_conf_new(void)
101{
102 My_Conf_Type *my_conf = calloc(1, sizeof(My_Conf_Type));
103 My_Conf_Subtype *sub;
104 if (!my_conf)
105 {
106 fprintf(stderr, "ERROR: could not calloc My_Conf_Type\n");
107 return NULL;
108 }
109
110 my_conf->version = 0x112233;
111 my_conf->enabled = EINA_TRUE;
112
113 sub = calloc(1, sizeof(My_Conf_Subtype));
114 if (sub)
115 {
116 sub->server = eina_stringshare_add("my-server.com");
117 sub->port = 1234;
118 my_conf->subs = eina_list_append(my_conf->subs, sub);
119 }
120
121 return my_conf;
122} /* _my_conf_new */
123
124static void
125_my_conf_free(My_Conf_Type *my_conf)
126{
127 My_Conf_Subtype *sub;
128 EINA_LIST_FREE(my_conf->subs, sub)
129 {
130 eina_stringshare_del(sub->server);
131 free(sub);
132 }
133
134 eina_stringshare_del(my_conf->name);
135 free(my_conf);
136} /* _my_conf_free */
137
138static My_Conf_Type *
139_my_conf_load(const char *filename)
140{
141 My_Conf_Type *my_conf;
142 Eet_File *ef = eet_open(filename, EET_FILE_MODE_READ);
143 if (!ef)
144 {
145 fprintf(stderr, "ERROR: could not open '%s' for read\n", filename);
146 return NULL;
147 }
148
149 my_conf = eet_data_read(ef, _my_conf_descriptor, MY_CONF_FILE_ENTRY);
150 if (!my_conf)
151 goto end;
152
153 if (my_conf->version < 0x112233)
154 {
155 fprintf(stderr,
156 "WARNING: version %#x was too old, upgrading it to %#x\n",
157 my_conf->version, 0x112233);
158
159 my_conf->version = 0x112233;
160 my_conf->enabled = EINA_TRUE;
161 }
162
163end:
164 eet_close(ef);
165 return my_conf;
166} /* _my_conf_load */
167
168static Eina_Bool
169_my_conf_save(const My_Conf_Type *my_conf,
170 const char *filename)
171{
172 char tmp[PATH_MAX];
173 Eet_File *ef;
174 Eina_Bool ret;
175 unsigned int i, len;
176 struct stat st;
177
178 len = eina_strlcpy(tmp, filename, sizeof(tmp));
179 if (len + 12 >= (int)sizeof(tmp))
180 {
181 fprintf(stderr, "ERROR: file name is too big: %s\n", filename);
182 return EINA_FALSE;
183 }
184
185 i = 0;
186 do
187 {
188 snprintf(tmp + len, 12, ".%u", i);
189 i++;
190 }
191 while (stat(tmp, &st) == 0);
192
193 ef = eet_open(tmp, EET_FILE_MODE_WRITE);
194 if (!ef)
195 {
196 fprintf(stderr, "ERROR: could not open '%s' for write\n", tmp);
197 return EINA_FALSE;
198 }
199
200 ret = eet_data_write
201 (ef, _my_conf_descriptor, MY_CONF_FILE_ENTRY, my_conf, EINA_TRUE);
202 eet_close(ef);
203
204 if (ret)
205 {
206 unlink(filename);
207 rename(tmp, filename);
208 }
209
210 return ret;
211} /* _my_conf_save */
212
213int
214main(int argc,
215 char *argv[])
216{
217 My_Conf_Type *my_conf;
218 const My_Conf_Subtype *sub;
219 const Eina_List *l;
220 int ret = 0;
221
222 if (argc != 3)
223 {
224 fprintf(stderr, "Usage:\n\t%s <input> <output>\n\n", argv[0]);
225 return -1;
226 }
227
228 eina_init();
229 eet_init();
230 _my_conf_descriptor_init();
231
232 my_conf = _my_conf_load(argv[1]);
233 if (!my_conf)
234 {
235 printf("creating new configuration.\n");
236 my_conf = _my_conf_new();
237 if (!my_conf)
238 {
239 ret = -2;
240 goto end;
241 }
242 }
243
244 printf("My_Conf_Type:\n"
245 "\tversion: %#x\n"
246 "\tname...: '%s'\n"
247 "\tid.....: %d\n"
248 "\tenabled: %hhu\n"
249 "\tsubs...:\n",
250 my_conf->version,
251 my_conf->name ? my_conf->name : "",
252 my_conf->id,
253 my_conf->enabled);
254
255 EINA_LIST_FOREACH(my_conf->subs, l, sub)
256 printf("\t\tserver: '%s', port: %d\n",
257 sub->server ? sub->server : "",
258 sub->port);
259
260 if (!_my_conf_save(my_conf, argv[2]))
261 ret = -3;
262
263 _my_conf_free(my_conf);
264
265end:
266 _my_conf_descriptor_shutdown();
267 eet_shutdown();
268 eina_shutdown();
269
270 return ret;
271} /* main */
272
diff --git a/libraries/eet/src/examples/eet-data-simple.c b/libraries/eet/src/examples/eet-data-simple.c
deleted file mode 100644
index 1951fc0..0000000
--- a/libraries/eet/src/examples/eet-data-simple.c
+++ /dev/null
@@ -1,224 +0,0 @@
1/*
2 * build: gcc -o eet_data_simple eet-data-simple.c `pkg-config --cflags --libs eet eina`
3 */
4#include <Eina.h>
5#include <Eet.h>
6#include <stdio.h>
7#include <limits.h>
8#include <sys/types.h>
9#include <sys/stat.h>
10#include <unistd.h>
11
12// The struct that will be loaded and saved.
13// note that only the members described in the eet_data_descriptor
14// will be automatically handled. The other members will have their
15// space reserved and zeroed (as it uses calloc()), but not
16// saved or loaded from eet files.
17typedef struct
18{
19 unsigned int version; // it is recommended to use versioned configuration!
20 const char *name;
21 int id;
22 int not_saved_value; // example of not saved data inside!
23 Eina_Bool enabled;
24} My_Conf_Type;
25
26// string that represents the entry in eet file, you might like to have
27// different profiles or so in the same file, this is possible with
28// different strings
29static const char MY_CONF_FILE_ENTRY[] = "config";
30
31// keep the descriptor static global, so it can be
32// shared by different functions (load/save) of this and only this
33// file.
34static Eet_Data_Descriptor *_my_conf_descriptor;
35
36static void
37_my_conf_descriptor_init(void)
38{
39 Eet_Data_Descriptor_Class eddc;
40
41 // The class describe the functions to use to create the type and its
42 // full allocated size.
43 //
44 // Eina types are very convenient, so use them to create the descriptor,
45 // so we get eina_list, eina_hash and eina_stringshare automatically!
46 //
47 // The STREAM variant is better for configuration files as the values
48 // will likely change a lot.
49 //
50 // The other variant, FILE, is good for caches and things that are just
51 // appended, but needs to take care when changing strings and files must
52 // be kept open so mmap()ed strings will be kept alive.
53 EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eddc, My_Conf_Type);
54 _my_conf_descriptor = eet_data_descriptor_stream_new(&eddc);
55
56 // Describe the members to be saved:
57 // Use a temporary macro so we don't type a lot, also avoid errors:
58#define MY_CONF_ADD_BASIC(member, eet_type) \
59 EET_DATA_DESCRIPTOR_ADD_BASIC \
60 (_my_conf_descriptor, My_Conf_Type, # member, member, eet_type)
61
62 MY_CONF_ADD_BASIC(version, EET_T_UINT);
63 MY_CONF_ADD_BASIC(name, EET_T_STRING);
64 MY_CONF_ADD_BASIC(id, EET_T_INT);
65 MY_CONF_ADD_BASIC(enabled, EET_T_UCHAR);
66
67#undef MY_CONF_ADD_BASIC
68} /* _my_conf_descriptor_init */
69
70static void
71_my_conf_descriptor_shutdown(void)
72{
73 eet_data_descriptor_free(_my_conf_descriptor);
74} /* _my_conf_descriptor_shutdown */
75
76static My_Conf_Type *
77_my_conf_new(void)
78{
79 My_Conf_Type *my_conf = calloc(1, sizeof(My_Conf_Type));
80 if (!my_conf)
81 {
82 fprintf(stderr, "ERROR: could not calloc My_Conf_Type\n");
83 return NULL;
84 }
85
86 my_conf->version = 0x112233;
87 my_conf->enabled = EINA_TRUE;
88 return my_conf;
89} /* _my_conf_new */
90
91static void
92_my_conf_free(My_Conf_Type *my_conf)
93{
94 eina_stringshare_del(my_conf->name);
95 free(my_conf);
96} /* _my_conf_free */
97
98static My_Conf_Type *
99_my_conf_load(const char *filename)
100{
101 My_Conf_Type *my_conf;
102 Eet_File *ef = eet_open(filename, EET_FILE_MODE_READ);
103 if (!ef)
104 {
105 fprintf(stderr, "ERROR: could not open '%s' for read\n", filename);
106 return NULL;
107 }
108
109 my_conf = eet_data_read(ef, _my_conf_descriptor, MY_CONF_FILE_ENTRY);
110 if (!my_conf)
111 goto end;
112
113 if (my_conf->version < 0x112233)
114 {
115 fprintf(stderr,
116 "WARNING: version %#x was too old, upgrading it to %#x\n",
117 my_conf->version, 0x112233);
118
119 my_conf->version = 0x112233;
120 my_conf->enabled = EINA_TRUE;
121 }
122
123end:
124 eet_close(ef);
125 return my_conf;
126} /* _my_conf_load */
127
128static Eina_Bool
129_my_conf_save(const My_Conf_Type *my_conf,
130 const char *filename)
131{
132 char tmp[PATH_MAX];
133 Eet_File *ef;
134 Eina_Bool ret;
135 unsigned int i, len;
136 struct stat st;
137
138 len = eina_strlcpy(tmp, filename, sizeof(tmp));
139 if (len + 12 >= (int)sizeof(tmp))
140 {
141 fprintf(stderr, "ERROR: file name is too big: %s\n", filename);
142 return EINA_FALSE;
143 }
144
145 i = 0;
146 do
147 {
148 snprintf(tmp + len, 12, ".%u", i);
149 i++;
150 }
151 while (stat(tmp, &st) == 0);
152
153 ef = eet_open(tmp, EET_FILE_MODE_WRITE);
154 if (!ef)
155 {
156 fprintf(stderr, "ERROR: could not open '%s' for write\n", tmp);
157 return EINA_FALSE;
158 }
159
160 ret = eet_data_write
161 (ef, _my_conf_descriptor, MY_CONF_FILE_ENTRY, my_conf, EINA_TRUE);
162 eet_close(ef);
163
164 if (ret)
165 {
166 unlink(filename);
167 rename(tmp, filename);
168 }
169
170 return ret;
171} /* _my_conf_save */
172
173int
174main(int argc,
175 char *argv[])
176{
177 My_Conf_Type *my_conf;
178 int ret = 0;
179
180 if (argc != 3)
181 {
182 fprintf(stderr, "Usage:\n\t%s <input> <output>\n\n", argv[0]);
183 return -1;
184 }
185
186 eina_init();
187 eet_init();
188 _my_conf_descriptor_init();
189
190 my_conf = _my_conf_load(argv[1]);
191 if (!my_conf)
192 {
193 printf("creating new configuration.\n");
194 my_conf = _my_conf_new();
195 if (!my_conf)
196 {
197 ret = -2;
198 goto end;
199 }
200 }
201
202 printf("My_Conf_Type:\n"
203 "\tversion: %#x\n"
204 "\tname...: '%s'\n"
205 "\tid.....: %d\n"
206 "\tenabled: %hhu\n",
207 my_conf->version,
208 my_conf->name ? my_conf->name : "",
209 my_conf->id,
210 my_conf->enabled);
211
212 if (!_my_conf_save(my_conf, argv[2]))
213 ret = -3;
214
215 _my_conf_free(my_conf);
216
217end:
218 _my_conf_descriptor_shutdown();
219 eet_shutdown();
220 eina_shutdown();
221
222 return ret;
223} /* main */
224
diff --git a/libraries/eet/src/examples/eet-file.c b/libraries/eet/src/examples/eet-file.c
deleted file mode 100644
index 740c179..0000000
--- a/libraries/eet/src/examples/eet-file.c
+++ /dev/null
@@ -1,127 +0,0 @@
1/*
2 * build: gcc -o eet_file eet-file.c `pkg-config --cflags --libs eet`
3 */
4#include <Eet.h>
5#include <stdio.h>
6#include <string.h>
7
8static int
9create_eet_file(void)
10{
11 Eet_File *ef;
12 char buf[1024], *ptr;
13 int size, len, i;
14 const char *some_strings[] = {
15 "And some more strings",
16 "spread across several",
17 "elements of an array!"
18 };
19 const char some_data[] =
20 "\x1e\xe7\x0f\x42\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x35"
21 "\x00\x00\x00\xa0\x00\x00\x00\xa0\x00\x00\x00\x24\x00\x00\x00\x11"
22 "\x00\x00\x00\x00\x2f\x6d\x69\x73\x74\x65\x72\x69\x6f\x75\x73\x2f"
23 "\x64\x61\x74\x61\x00\x41\x6e\x20\x45\x45\x54\x20\x69\x6e\x73\x69"
24 "\x64\x65\x20\x6f\x66\x20\x61\x6e\x20\x45\x45\x54\x21\x0a\x54\x68"
25 "\x69\x73\x20\x77\x61\x73\x6e\x27\x74\x20\x72\x65\x61\x6c\x6c\x79"
26 "\x20\x75\x73\x65\x66\x75\x6c\x20\x62\x75\x74\x20\x69\x74\x20\x68"
27 "\x65\x6c\x70\x65\x64\x20\x74\x6f\x20\x73\x68\x6f\x77\x20\x68\x6f"
28 "\x77\x0a\x74\x6f\x20\x75\x73\x65\x20\x65\x65\x74\x5f\x6d\x65\x6d"
29 "\x6f\x70\x65\x6e\x5f\x72\x65\x61\x64\x28\x29\x20\x74\x6f\x20\x6f"
30 "\x70\x65\x6e\x20\x61\x6e\x20\x65\x65\x74\x20\x66\x69\x6c\x65\x20"
31 "\x66\x72\x6f\x6d\x0a\x64\x61\x74\x61\x20\x61\x6c\x72\x65\x61\x64"
32 "\x79\x20\x6c\x6f\x61\x64\x65\x64\x20\x69\x6e\x20\x6d\x65\x6d\x6f"
33 "\x72\x79\x2e\x0a\x00";
34
35 ef = eet_open("/tmp/my_file.eet", EET_FILE_MODE_WRITE);
36 if (!ef) return 0;
37
38 strcpy(buf, "Here is a string of data to save!");
39 size = eet_write(ef, "/key/to_store/at", buf, sizeof(buf), 1);
40 if (!size)
41 {
42 fprintf(stderr, "Error writing data!\n");
43 eet_close(ef);
44 return 0;
45 }
46 len = strlen(buf);
47 printf("strlen() = %d, eet_write() = %d\n", len, size);
48
49 ptr = buf;
50 for (i = 0; i < 3; i++)
51 {
52 len = strlen(some_strings[i]) + 1;
53 memcpy(ptr, some_strings[i], len);
54 ptr += len;
55 }
56 eet_write(ef, "/several/strings", buf, sizeof(buf), 1);
57 eet_sync(ef);
58
59 eet_write(ef, "/some/mysterious/data", some_data, sizeof(some_data) - 1, 1);
60
61 eet_delete(ef, "/several/strings");
62
63 return eet_close(ef) == EET_ERROR_NONE;
64}
65
66int
67main(void)
68{
69 Eet_File *ef;
70 char *ret, **list;
71 int size, num, i;
72
73 eet_init();
74
75 if (!create_eet_file())
76 return -1;
77
78 ef = eet_open("/tmp/my_file.eet", EET_FILE_MODE_READ);
79 if (!ef) return -1;
80
81 list = eet_list(ef, "*", &num);
82 if (list)
83 {
84 for (i = 0; i < num; i++)
85 printf("Key stored: %s\n", list[i]);
86 free(list);
87 }
88
89 ret = eet_read(ef, "/key/to_store/at", &size);
90 if (ret)
91 {
92 printf("Data read (%i bytes):\n%s\n", size, ret);
93 free(ret);
94 }
95
96 ret = eet_read(ef, "/several/strings", &size);
97 if (ret)
98 {
99 printf("More data read (%i bytes):\n%s\n", size, ret);
100 free(ret);
101 }
102
103 ret = eet_read(ef, "/some/mysterious/data", &size);
104 if (ret)
105 {
106 Eet_File *ef2;
107
108 ef2 = eet_memopen_read(ret, size);
109
110 num = eet_num_entries(ef2);
111 printf("Mysterious data has %d entries\n", num);
112
113 printf("Mysterious data:\n%s\n",
114 (char *)eet_read_direct(ef2, "/mysterious/data", NULL));
115
116 eet_close(ef2);
117
118 free(ret);
119 }
120
121 eet_close(ef);
122
123 eet_shutdown();
124
125 return 0;
126}
127
diff --git a/libraries/eet/src/lib/Eet.h b/libraries/eet/src/lib/Eet.h
deleted file mode 100644
index 7495090..0000000
--- a/libraries/eet/src/lib/Eet.h
+++ /dev/null
@@ -1,4180 +0,0 @@
1/**
2 @brief Eet Data Handling Library Public API Calls
3
4 These routines are used for Eet Library interaction
5
6 @mainpage Eet Library Documentation
7
8 @version 1.5.0
9 @date 2000-2012
10
11 Please see the @ref authors page for contact details.
12
13 @section toc Table of Contents
14
15 @li @ref intro
16 @li @ref example
17 @li @ref compiling
18 @li @ref install
19 @li @ref next_steps
20 @li @ref intro_example
21
22 @section intro What is Eet?
23
24 It is a tiny library designed to write an arbitrary set of chunks of data
25 to a file and optionally compress each chunk (very much like a zip file)
26 and allow fast random-access reading of the file later on. It does not
27 do zip as a zip itself has more complexity than is needed, and it was much
28 simpler to implement this once here.
29
30 Eet is extremely fast, small and simple. Eet files can be very small and
31 highly compressed, making them very optimal for just sending across the
32 internet without having to archive, compress or decompress and install them.
33 They allow for lightning-fast random-access reads once created, making them
34 perfect for storing data that is written once (or rarely) and read many
35 times, but the program does not want to have to read it all in at once.
36
37 It also can encode and decode data structures in memory, as well as image
38 data for saving to Eet files or sending across the network to other
39 machines, or just writing to arbitrary files on the system. All data is
40 encoded in a platform independent way and can be written and read by any
41 architecture.
42
43 @section example A simple example on using Eet
44
45 Here is a simple example on how to use Eet to save a series of strings to a
46 file and load them again. The advantage of using Eet over just
47 fprintf() and
48 fscanf() is that not only can these entries be strings, they need no special
49 parsing to handle delimiter characters or escaping, they can be binary data,
50 image data, data structures containing integers, strings, other data
51 structures, linked lists and much more, without the programmer having to
52 worry about parsing, and best of all, Eet is very fast.
53
54 This is just a very simple example that doesn't show all of the capabilities
55 of Eet, but it serves to illustrate its simplicity.
56
57 @include eet-basic.c
58
59 @section compiling How to compile using Eet ?
60
61 Eet is a library your application links to. The procedure for this is very
62 simple. You simply have to compile your application with the appropriate
63 compiler flags that the @p pkg-config script outputs. For example:
64
65 Compiling C or C++ files into object files:
66
67 @verbatim
68 gcc -c -o main.o main.c `pkg-config --cflags eet`
69 @endverbatim
70
71 Linking object files into a binary executable:
72
73 @verbatim
74 gcc -o my_application main.o `pkg-config --libs eet`
75 @endverbatim
76
77 You simply have to make sure that pkg-config is in your shell's PATH (see
78 the manual page for your appropriate shell) and eet.pc in /usr/lib/pkgconfig
79 or its path is in the PKG_CONFIG_PATH environment variable. It's that simple
80 to link and use Eet once you have written your code to use it.
81
82 Since the program is linked to Eet, it is now able to use any advertised
83 API calls to serialize your data.
84
85 You should make sure you add any extra compile and link flags to your
86 compile commands that your application may need as well. The above example
87 is only guaranteed to make Eet add it's own requirements.
88
89
90 @section install How is it installed?
91
92 Simple:
93
94 @verbatim
95 ./configure
96 make
97 su -
98 ...
99 make install
100 @endverbatim
101
102 @section next_steps Next Steps
103
104 After you understood what Eet is and installed it in your system you
105 should proceed understanding the programming interface. We'd recommend
106 you to take a while to learn Eina
107 (http://docs.enlightenment.org/auto/eina/) as it is very convenient
108 and optimized, and Eet provides integration with it.
109
110 Recommended reading:
111
112 @li @ref Eet_File_Group to know the basics to open and save files.
113 @li @ref Eet_Data_Group to know the convenient way to serialize and
114 parse your data structures automatically. Just create your
115 descriptors and let Eet do the work for you.
116
117 @section intro_example Introductory Examples
118
119 @ref Examples
120
121 @todo Document data format for images and data structures.
122
123 */
124
125/**
126 @page authors Authors
127 @author Carsten Haitzler <raster@@rasterman.com>
128 @author David Goodlad <dgoodlad@@gmail.com>
129 @author Cedric Bail <cedric.bail@@free.fr>
130 @author Arnaud de Turckheim <quarium@@gmail.com>
131 @author Luis Felipe Strano Moraes <lfelipe@@profusion.mobi>
132 @author Chidambar Zinnoury <illogict@@online.fr>
133 @author Vincent Torri <vtorri@@univ-evry.fr>
134 @author Gustavo Sverzut Barbieri <barbieri@@profusion.mobi>
135 @author Raphael Kubo da Costa <kubo@@profusion.mobi>
136 @author Mathieu Taillefumier <mathieu.taillefumier@@free.fr>
137 @author Albin "Lutin" Tonnerre <albin.tonnerre@@gmail.com>
138 @author Adam Simpkins <adam@@adamsimpkins.net>
139 @author Mike Blumenkrantz <michael.blumenkrantz@gmail.com>
140
141 Please contact <enlightenment-devel@lists.sourceforge.net> to get in
142 contact with the developers and maintainers.
143 */
144
145#ifndef _EET_H
146#define _EET_H
147
148#include <stdlib.h>
149#include <stdio.h>
150#include <Eina.h>
151
152#ifdef EAPI
153# undef EAPI
154#endif /* ifdef EAPI */
155
156#ifdef _WIN32
157# ifdef EFL_EET_BUILD
158# ifdef DLL_EXPORT
159# define EAPI __declspec(dllexport)
160# else /* ifdef DLL_EXPORT */
161# define EAPI
162# endif /* ! DLL_EXPORT */
163# else /* ifdef EFL_EET_BUILD */
164# define EAPI __declspec(dllimport)
165# endif /* ! EFL_EET_BUILD */
166#else /* ifdef _WIN32 */
167# ifdef __GNUC__
168# if __GNUC__ >= 4
169# define EAPI __attribute__ ((visibility("default")))
170# else /* if __GNUC__ >= 4 */
171# define EAPI
172# endif /* if __GNUC__ >= 4 */
173# else /* ifdef __GNUC__ */
174# define EAPI
175# endif /* ifdef __GNUC__ */
176#endif /* ! _WIN32 */
177
178#ifdef __cplusplus
179extern "C" {
180#endif /* ifdef __cplusplus */
181
182/**
183 * @file Eet.h
184 * @brief The file that provides the eet functions.
185 *
186 * This header provides the Eet management functions.
187 *
188 */
189
190#define EET_VERSION_MAJOR 1
191#define EET_VERSION_MINOR 6
192/**
193 * @typedef Eet_Version
194 *
195 * This is the Eet version information structure that can be used at
196 * runtime to detect which version of eet is being used and adapt
197 * appropriately as follows for example:
198 *
199 * @code
200 * #if defined(EET_VERSION_MAJOR) && (EET_VERSION_MAJOR >= 1) && defined(EET_VERSION_MINOR) && (EET_VERSION_MINOR > 2)
201 * printf("Eet version: %i.%i.%i\n",
202 * eet_version->major,
203 * eet_version->minor,
204 * eet_version->micro);
205 * if (eet_version->revision > 0)
206 * {
207 * printf(" Built from SVN revision # %i\n", eet_version->revision);
208 * }
209 * #endif
210 * @endcode
211 *
212 * Note the #if check can be dropped if your program refuses to compile or
213 * work with an Eet version less than 1.3.0.
214 */
215typedef struct _Eet_Version
216{
217 int major; /** < major (binary or source incompatible changes) */
218 int minor; /** < minor (new features, bugfixes, major improvements version) */
219 int micro; /** < micro (bugfix, internal improvements, no new features version) */
220 int revision; /** < svn revision (0 if a proper rlease or the svn revsion number Eet is built from) */
221} Eet_Version;
222
223EAPI extern Eet_Version *eet_version;
224
225/**
226 * @defgroup Eet_Group Top level functions
227 * Functions that affect Eet as a whole.
228 *
229 * @{
230 */
231
232/**
233 * @enum _Eet_Error
234 * All the error identifiers known by Eet.
235 */
236typedef enum _Eet_Error
237{
238 EET_ERROR_NONE, /**< No error, it's all fine! */
239 EET_ERROR_BAD_OBJECT, /**< Given object or handle is NULL or invalid */
240 EET_ERROR_EMPTY, /**< There was nothing to do */
241 EET_ERROR_NOT_WRITABLE, /**< Could not write to file or file is #EET_FILE_MODE_READ */
242 EET_ERROR_OUT_OF_MEMORY, /**< Could not allocate memory */
243 EET_ERROR_WRITE_ERROR, /**< Failed to write data to destination */
244 EET_ERROR_WRITE_ERROR_FILE_TOO_BIG, /**< Failed to write file since it is too big */
245 EET_ERROR_WRITE_ERROR_IO_ERROR, /**< Failed to write due a generic Input/Output error */
246 EET_ERROR_WRITE_ERROR_OUT_OF_SPACE, /**< Failed to write due out of space */
247 EET_ERROR_WRITE_ERROR_FILE_CLOSED, /**< Failed to write because file was closed */
248 EET_ERROR_MMAP_FAILED, /**< Could not mmap file */
249 EET_ERROR_X509_ENCODING_FAILED, /**< Could not encode using X509 */
250 EET_ERROR_SIGNATURE_FAILED, /**< Could not validate signature */
251 EET_ERROR_INVALID_SIGNATURE, /**< Signature is invalid */
252 EET_ERROR_NOT_SIGNED, /**< File or contents are not signed */
253 EET_ERROR_NOT_IMPLEMENTED, /**< Function is not implemented */
254 EET_ERROR_PRNG_NOT_SEEDED, /**< Could not introduce random seed */
255 EET_ERROR_ENCRYPT_FAILED, /**< Could not encrypt contents */
256 EET_ERROR_DECRYPT_FAILED /**< Could not decrypt contents */
257} Eet_Error; /**< Eet error identifiers */
258
259/**
260 * @}
261 */
262
263/**
264 * Initialize the EET library.
265 *
266 * The first time this function is called, it will perform all the internal
267 * initialization required for the library to function properly and incrememnt
268 * the initializiation counter. Any subsequent call only increment this counter
269 * and return its new value, so it's safe to call this function more than once.
270 *
271 * @return The new init count. Will be 0 if initialization failed.
272 *
273 * @since 1.0.0
274 * @ingroup Eet_Group
275 */
276EAPI int
277eet_init(void);
278
279/**
280 * Shut down the EET library.
281 *
282 * If eet_init() was called more than once for the running application,
283 * eet_shutdown() will decrement the initialization counter and return its
284 * new value, without doing anything else. When the counter reaches 0, all
285 * of the internal elements will be shutdown and any memory used freed.
286 *
287 * @return The new init count.
288 *
289 * @since 1.0.0
290 * @ingroup Eet_Group
291 */
292EAPI int
293eet_shutdown(void);
294
295/**
296 * Clear eet cache
297 *
298 * For a faster access to previously accessed data, Eet keeps an internal
299 * cache of files. These files will be freed automatically only when
300 * they are unused and the cache gets full, in order based on the last time
301 * they were used.
302 * On systems with little memory this may present an unnecessary constraint,
303 * so eet_clearcache() is available for users to reclaim the memory used by
304 * files that are no longer needed. Those that were open using
305 * ::EET_FILE_MODE_WRITE or ::EET_FILE_MODE_READ_WRITE and have modifications,
306 * will be written down to disk before flushing them from memory.
307 *
308 * @since 1.0.0
309 * @ingroup Eet_Group
310 */
311EAPI void
312eet_clearcache(void);
313
314/**
315 * @defgroup Eet_File_Group Eet File Main Functions
316 *
317 * Functions to create, destroy and do basic manipulation of
318 * #Eet_File handles.
319 *
320 * This sections explains how to use the most basic Eet functions, which
321 * are used to work with eet files, read data from them, store it back in or
322 * take a look at what entries it contains, without making use of the
323 * serialization capabilities explained in @ref Eet_Data_Group.
324 *
325 * The following example will serve as an introduction to most, if not all,
326 * of these functions.
327 *
328 * If you are only using Eet, this is the only header you need to include.
329 * @dontinclude eet-file.c
330 * @skipline Eet.h
331 *
332 * Now let's create ourselves an eet file to play with. The following function
333 * shows step by step how to open a file and write some data in it.
334 * First, we define our file handler and some other things we'll put in it.
335 * @line static int
336 * @skip Eet_File
337 * @until ";
338 * @skip eet_open
339 *
340 * We open a new file in write mode, and if it fails, we just return, since
341 * there's not much more we can do about it..
342 * @until return
343 *
344 * Now, we need to write some data in our file. For now, strings will suffice,
345 * so let's just dump a bunch of them in there.
346 * @until }
347 *
348 * As you can see, we copied a string into our static buffer, which is a bit
349 * bigger than the full length of the string, and then told Eet to write it
350 * into the file, compressed, returning the size of the data written into the
351 * file.
352 * This is all to show that Eet treats data as just data. It doesn't matter
353 * what that data represents (for now), it's all just bytes for it. As running
354 * the following code will show, we took a string of around 30 bytes and put it
355 * in a buffer of 1024 bytes, but the returned size won't be any of those.
356 * @until printf
357 *
358 * Next, we copy into our buffer our set of strings, including their null
359 * terminators and write them into the file. No error checking for the sake
360 * of brevitiy. And a call to eet_sync() to make sure all out data is
361 * properly written down to disk, even though we haven't yet closed the file.
362 * @until eet_sync
363 *
364 * One more write, this time our large array of binary data and... well, I
365 * couldn't come up with a valid use of the last set of strings we stored,
366 * so let's take it out from the file with eet_delete().
367 * @until eet_delete
368 *
369 * Finally, we close the file, saving any changes back to disk and return.
370 * Notice how, if there's any error closing the file or saving its contents,
371 * the return value from the function will be a false one, which later on
372 * will make the program exit with an error code.
373 * @until return
374 *
375 * Moving onto our main function, we will open the same file and read it back.
376 * Trivial, but it'll show how we can do so in more than one way. We'll skip
377 * the variable declarations, as they aren't very different from what we've
378 * seen already.
379 *
380 * We start from the beginning by initializing Eet so things in general work.
381 * Forgetting to do so will result in weird results or crashes when calling
382 * any eet function, so if you experience something like that, the first thing
383 * to look at is whether eet_init() is missing.
384 * Then we call our @p create_eet_file function, described above, to make
385 * sure we have something to work with. If the function fails it will return
386 * 0 and we just exit, since nothing from here onwards will work anyway.
387 * @skip eet_init
388 * @until return
389 *
390 * Let's take a look now at what entries our file has. For this, we use
391 * eet_list(), which will return a list of strings, each being the name of
392 * one entry. Since we skipped before, it may be worth noting that @p list
393 * is declared as a @p char **.
394 * The @p num parameter will, of course, have the number of entries contained
395 * in our file.
396 * If everything's fine, we'll get our list and print it to the screen, and
397 * once done with it, we free the list. That's just the list, not its contents,
398 * as they are internal strings used by Eet and trying to free them will surely
399 * break things.
400 * @until }
401 *
402 * Reading back plain data is simple. Just a call to eet_read() with the file
403 * to read from, and the name of the entry we are interested in. We get back
404 * our data and the passed @p size parameter will contain the size of it. If
405 * the data was stored compressed, it will decompressed first.
406 * @until }
407 *
408 * Another simple read for the set of strings from before, except those were
409 * deleted, so we should get a NULL return and continue normally.
410 * @until }
411 *
412 * Finally, we'll get our binary data in the same way we got the strings. Once
413 * again, it makes no difference for Eet what the data is, it's up to us to
414 * know how to handle it.
415 * @until {
416 *
417 * Now some cheating, we know that this data is an Eet file because, well...
418 * we just know it. So we are going to open it and take a look at its insides.
419 * For this, eet_open() won't work, as it needs to have a file on disk to read
420 * from and all we have is some data in RAM.
421 *
422 * So how do we do? One way would be to create a normal file and write down
423 * our data, then open it with eet_open(). Another, faster and more efficient
424 * if all we want to do is read the file, is to use eet_memopen_read().
425 * @until memopen
426 *
427 * As you can see, the size we got from our previous read was put to good use
428 * this time. Unlike the first one where all we had were strings, the size
429 * of the data read only serves to demonstrate that we are reading back the
430 * entire size of our original @p buf variable.
431 *
432 * A little peeking to see how many entries the file has and to make an
433 * example of eet_num_entries() to get that number when we don't care about
434 * their names.
435 * @until printf
436 *
437 * More cheating follows. Just like we knew this was an Eet file, we also know
438 * what key to read from, and ontop of that we know that the data in it is not
439 * compressed.
440 * Knowing all this allows us to take some shortcuts.
441 * @until read_direct
442 *
443 * That's a direct print of our data, whatever that data is. We don't want
444 * to worry about having to free it later, so we just used eet_direct_read()
445 * to tell Eet to gives a pointer to the internal data in the file, without
446 * duplicating it. Since we said that data was not compressed, we shouldn't
447 * worry about printing garbage to the screen (and yes, we also know the data
448 * is yet another string).
449 * We also don't care about the size of the data as it was stored in the file,
450 * so we passed NULL as the size parameter.
451 * One very important note about this, however, is that we don't care about
452 * the size parameter because the data in the file contains the null
453 * terminator for the string. So when using Eet to store strings this way,
454 * it's very important to consider whether you will keep that final null
455 * byte, or to always get the size read and do the necessary checks and copies.
456 * It's up to the user and the particular use cases to decide how this will
457 * be done.
458 *
459 * With everything done, close this second file and free the data used to open
460 * it. And this is important, we can't free that data until we are done with
461 * the file, as Eet is using it. When opening with eet_memopen_read(), the data
462 * passed to it must be available for as long as the the file is open.
463 * @until }
464 *
465 * Finally, we close the first file, shutdown all internal resources used by
466 * Eet and leave our main function, thus terminating our program.
467 * @until return
468 *
469 * You can look at the full code of the example @ref eet-file.c "here".
470 * @{
471 */
472
473/**
474 * @enum _Eet_File_Mode
475 * Modes that a file can be opened.
476 */
477typedef enum _Eet_File_Mode
478{
479 EET_FILE_MODE_INVALID = -1,
480 EET_FILE_MODE_READ, /**< File is read-only. */
481 EET_FILE_MODE_WRITE, /**< File is write-only. */
482 EET_FILE_MODE_READ_WRITE /**< File is for both read and write */
483} Eet_File_Mode; /**< Modes that a file can be opened. */
484
485/**
486 * @typedef Eet_File
487 * Opaque handle that defines an Eet file (or memory).
488 *
489 * This handle will be returned by the functions eet_open() and
490 * eet_memopen_read() and is used by every other function that affects the
491 * file in any way. When you are done with it, call eet_close() to clsoe it
492 * and, if the file was open for writing, write down to disk any changes made
493 * to it.
494 *
495 * @see eet_open()
496 * @see eet_memopen_read()
497 * @see eet_close()
498 */
499typedef struct _Eet_File Eet_File;
500
501/**
502 * @typedef Eet_Dictionary
503 * Opaque handle that defines a file-backed (mmaped) dictionary of strings.
504 */
505typedef struct _Eet_Dictionary Eet_Dictionary;
506
507/**
508 * @}
509 */
510
511/**
512 * Open an eet file on disk, and returns a handle to it.
513 * @param file The file path to the eet file. eg: @c "/tmp/file.eet".
514 * @param mode The mode for opening. Either #EET_FILE_MODE_READ,
515 * #EET_FILE_MODE_WRITE or #EET_FILE_MODE_READ_WRITE.
516 * @return An opened eet file handle.
517 * @ingroup Eet_File_Group
518 *
519 * This function will open an exiting eet file for reading, and build
520 * the directory table in memory and return a handle to the file, if it
521 * exists and can be read, and no memory errors occur on the way, otherwise
522 * NULL will be returned.
523 *
524 * It will also open an eet file for writing. This will, if successful,
525 * delete the original file and replace it with a new empty file, till
526 * the eet file handle is closed or flushed. If it cannot be opened for
527 * writing or a memory error occurs, NULL is returned.
528 *
529 * You can also open the file for read/write. If you then write a key that
530 * does not exist it will be created, if the key exists it will be replaced
531 * by the new data.
532 *
533 * If the same file is opened multiple times, then the same file handle will
534 * be returned as eet maintains an internal list of all currently open
535 * files. Note that it considers files opened for read only and those opened
536 * for read/write and write only as 2 separate sets. Those that do not write
537 * to the file and those that do. Eet will allow 2 handles to the same file
538 * if they are in the 2 separate lists/groups. That means opening a file for
539 * read only looks in the read only set, and returns a handle to that file
540 * handle and increments its reference count. If you open a file for read/write
541 * or write only it looks in the write set and returns a handle after
542 * incrementing the reference count. You need to close an eet file handle
543 * as many times as it has been opened to maintain correct reference counts.
544 * Files whose modified timestamp or size do not match those of the existing
545 * referenced file handles will not be returned and a new handle will be
546 * returned instead.
547 *
548 * @since 1.0.0
549 */
550EAPI Eet_File *
551eet_open(const char *file,
552 Eet_File_Mode mode);
553
554/**
555 * Open an eet file directly from a memory location. The data is not copied,
556 * so you must keep it around as long as the eet file is open. There is
557 * currently no cache for this kind of Eet_File, so it's reopened every time
558 * you use eet_memopen_read.
559 * Files opened this way will always be in read-only mode.
560 *
561 * @since 1.1.0
562 * @ingroup Eet_File_Group
563 */
564EAPI Eet_File *
565eet_memopen_read(const void *data,
566 size_t size);
567
568/**
569 * Get the mode an Eet_File was opened with.
570 * @param ef A valid eet file handle.
571 * @return The mode ef was opened with.
572 *
573 * @since 1.0.0
574 * @ingroup Eet_File_Group
575 */
576EAPI Eet_File_Mode
577eet_mode_get(Eet_File *ef);
578
579/**
580 * Close an eet file handle and flush pending writes.
581 * @param ef A valid eet file handle.
582 *
583 * This function will flush any pending writes to disk if the eet file
584 * was opened for write, and free all data associated with the file handle
585 * and file, and close the file.
586 *
587 * If the eet file handle is not valid nothing will be done.
588 *
589 * @since 1.0.0
590 * @ingroup Eet_File_Group
591 */
592EAPI Eet_Error
593eet_close(Eet_File *ef);
594
595/**
596 * Sync content of an eet file handle, flushing pending writes.
597 * @param ef A valid eet file handle.
598 *
599 * This function will flush any pending writes to disk. The eet file must
600 * be opened for write.
601 *
602 * If the eet file handle is not valid nothing will be done.
603 *
604 * @since 1.2.4
605 * @ingroup Eet_File_Group
606 */
607EAPI Eet_Error
608eet_sync(Eet_File *ef);
609
610/**
611 * Return a handle to the shared string dictionary of the Eet file
612 * @param ef A valid eet file handle.
613 * @return A handle to the dictionary of the file
614 *
615 * This function returns a handle to the dictionary of an Eet file whose
616 * handle is @p ef, if a dictionary exists. NULL is returned otherwise or
617 * if the file handle is known to be invalid.
618 *
619 * @see eet_dictionary_string_check() to know if given string came
620 * from the dictionary or it was dynamically allocated using
621 * the #Eet_Data_Descriptor_Class instructrions.
622 *
623 * @since 1.0.0
624 * @ingroup Eet_File_Group
625 */
626EAPI Eet_Dictionary *
627eet_dictionary_get(Eet_File *ef);
628
629/**
630 * Check if a given string comes from a given dictionary
631 * @param ed A valid dictionary handle
632 * @param string A valid 0 byte terminated C string
633 * @return 1 if it is in the dictionary, 0 otherwise
634 *
635 * This checks the given dictionary to see if the given string is actually
636 * inside that dictionary (i.e. comes from it) and returns 1 if it does.
637 * If the dictionary handle is invalid, the string is NULL or the string is
638 * not in the dictionary, 0 is returned.
639 *
640 * @since 1.0.0
641 * @ingroup Eet_File_Group
642 */
643EAPI int
644eet_dictionary_string_check(Eet_Dictionary *ed,
645 const char *string);
646
647/**
648 * Return the number of strings inside a dictionary
649 * @param ed A valid dictionary handle
650 * @return the number of strings inside a dictionary
651 *
652 * @since 1.6.0
653 * @ingroup Eet_File_Group
654 */
655EAPI int
656eet_dictionary_count(const Eet_Dictionary *ed);
657
658/**
659 * Read a specified entry from an eet file and return data
660 * @param ef A valid eet file handle opened for reading.
661 * @param name Name of the entry. eg: "/base/file_i_want".
662 * @param size_ret Number of bytes read from entry and returned.
663 * @return The data stored in that entry in the eet file.
664 *
665 * This function finds an entry in the eet file that is stored under the
666 * name specified, and returns that data, decompressed, if successful.
667 * NULL is returned if the lookup fails or if memory errors are
668 * encountered. It is the job of the calling program to call free() on
669 * the returned data. The number of bytes in the returned data chunk are
670 * placed in size_ret.
671 *
672 * If the eet file handle is not valid NULL is returned and size_ret is
673 * filled with 0.
674 *
675 * @see eet_read_cipher()
676 *
677 * @since 1.0.0
678 * @ingroup Eet_File_Group
679 */
680EAPI void *
681eet_read(Eet_File *ef,
682 const char *name,
683 int *size_ret);
684
685/**
686 * Read a specified entry from an eet file and return data
687 * @param ef A valid eet file handle opened for reading.
688 * @param name Name of the entry. eg: "/base/file_i_want".
689 * @param size_ret Number of bytes read from entry and returned.
690 * @return The data stored in that entry in the eet file.
691 *
692 * This function finds an entry in the eet file that is stored under the
693 * name specified, and returns that data if not compressed and successful.
694 * NULL is returned if the lookup fails or if memory errors are
695 * encountered or if the data is comrpessed. The calling program must never
696 * call free() on the returned data. The number of bytes in the returned
697 * data chunk are placed in size_ret.
698 *
699 * If the eet file handle is not valid NULL is returned and size_ret is
700 * filled with 0.
701 *
702 * @since 1.0.0
703 * @ingroup Eet_File_Group
704 */
705EAPI const void *
706eet_read_direct(Eet_File *ef,
707 const char *name,
708 int *size_ret);
709
710/**
711 * Write a specified entry to an eet file handle
712 * @param ef A valid eet file handle opened for writing.
713 * @param name Name of the entry. eg: "/base/file_i_want".
714 * @param data Pointer to the data to be stored.
715 * @param size Length in bytes in the data to be stored.
716 * @param compress Compression flags (1 == compress, 0 = don't compress).
717 * @return bytes written on successful write, 0 on failure.
718 *
719 * This function will write the specified chunk of data to the eet file
720 * and return greater than 0 on success. 0 will be returned on failure.
721 *
722 * The eet file handle must be a valid file handle for an eet file opened
723 * for writing. If it is not, 0 will be returned and no action will be
724 * performed.
725 *
726 * Name, and data must not be NULL, and size must be > 0. If these
727 * conditions are not met, 0 will be returned.
728 *
729 * The data will be copied (and optionally compressed) in ram, pending
730 * a flush to disk (it will stay in ram till the eet file handle is
731 * closed though).
732 *
733 * @see eet_write_cipher()
734 *
735 * @since 1.0.0
736 * @ingroup Eet_File_Group
737 */
738EAPI int
739eet_write(Eet_File *ef,
740 const char *name,
741 const void *data,
742 int size,
743 int compress);
744
745/**
746 * Delete a specified entry from an Eet file being written or re-written
747 * @param ef A valid eet file handle opened for writing.
748 * @param name Name of the entry. eg: "/base/file_i_want".
749 * @return Success or failure of the delete.
750 *
751 * This function will delete the specified chunk of data from the eet file
752 * and return greater than 0 on success. 0 will be returned on failure.
753 *
754 * The eet file handle must be a valid file handle for an eet file opened
755 * for writing. If it is not, 0 will be returned and no action will be
756 * performed.
757 *
758 * Name, must not be NULL, otherwise 0 will be returned.
759 *
760 * @since 1.0.0
761 * @ingroup Eet_File_Group
762 */
763EAPI int
764eet_delete(Eet_File *ef,
765 const char *name);
766
767/**
768 * Alias a specific section to another one. Destination may exist or not,
769 * no checks are done.
770 * @param ef A valid eet file handle opened for writing.
771 * @param name Name of the new entry. eg: "/base/file_i_want".
772 * @param destination Actual source of the aliased entry eg: "/base/the_real_stuff_i_want".
773 * @param compress Compression flags (1 == compress, 0 = don't compress).
774 * @return EINA_TRUE on success, EINA_FALSE on failure.
775 *
776 * Name and Destination must not be NULL, otherwise EINA_FALSE will be returned.
777 * The equivalent of this would be calling 'ln -s destination name'
778 *
779 * @since 1.3.3
780 * @ingroup Eet_File_Group
781 */
782EAPI Eina_Bool
783eet_alias(Eet_File *ef,
784 const char *name,
785 const char *destination,
786 int compress);
787
788/**
789 * Retrieve the filename of an Eet_File
790 * @param ef A valid eet file handle opened for writing.
791 * @return The stringshared file string opened with eet_open(), or NULL on error
792 *
793 * @note This function will return NULL for files opened with eet_memopen_read()
794 *
795 * @since 1.6
796 * @ingroup Eet_File_Group
797 */
798EAPI const char *
799eet_file_get(Eet_File *ef);
800
801/**
802 * Retrieve the destination name of an alias
803 * @param ef A valid eet file handle opened for writing
804 * @param name Name of the entry. eg: "/base/file_i_want"
805 * @return Destination of the alias. eg: "/base/the_real_stuff_i_want", NULL on failure
806 *
807 * Name must not be NULL, otherwise NULL will be returned.
808 *
809 * @since 1.5
810 * @ingroup Eet_File_Group
811 */
812EAPI const char *
813eet_alias_get(Eet_File *ef,
814 const char *name);
815
816/**
817 * List all entries in eet file matching shell glob.
818 * @param ef A valid eet file handle.
819 * @param glob A shell glob to match against.
820 * @param count_ret Number of entries found to match.
821 * @return Pointer to an array of strings.
822 *
823 * This function will list all entries in the eet file matching the
824 * supplied shell glob and return an allocated list of their names, if
825 * there are any, and if no memory errors occur.
826 *
827 * The eet file handle must be valid and glob must not be NULL, or NULL
828 * will be returned and count_ret will be filled with 0.
829 *
830 * The calling program must call free() on the array returned, but NOT
831 * on the string pointers in the array. They are taken as read-only
832 * internals from the eet file handle. They are only valid as long as
833 * the file handle is not closed. When it is closed those pointers in the
834 * array are now not valid and should not be used.
835 *
836 * On success the array returned will have a list of string pointers
837 * that are the names of the entries that matched, and count_ret will have
838 * the number of entries in this array placed in it.
839 *
840 * Hint: an easy way to list all entries in an eet file is to use a glob
841 * value of "*".
842 *
843 * @since 1.0.0
844 * @ingroup Eet_File_Group
845 */
846EAPI char **
847eet_list(Eet_File *ef,
848 const char *glob,
849 int *count_ret);
850
851/**
852 * Return the number of entries in the specified eet file.
853 * @param ef A valid eet file handle.
854 * @return Number of entries in ef or -1 if the number of entries
855 * cannot be read due to open mode restrictions.
856 *
857 * @since 1.0.0
858 * @ingroup Eet_File_Group
859 */
860EAPI int
861eet_num_entries(Eet_File *ef);
862
863/**
864 * @defgroup Eet_File_Cipher_Group Eet File Ciphered Main Functions
865 *
866 * Most of the @ref Eet_File_Group have alternative versions that
867 * accounts for ciphers to protect their content.
868 *
869 * @see @ref Eet_Cipher_Group
870 *
871 * @ingroup Eet_File_Group
872 */
873
874/**
875 * Read a specified entry from an eet file and return data using a cipher.
876 * @param ef A valid eet file handle opened for reading.
877 * @param name Name of the entry. eg: "/base/file_i_want".
878 * @param size_ret Number of bytes read from entry and returned.
879 * @param cipher_key The key to use as cipher.
880 * @return The data stored in that entry in the eet file.
881 *
882 * This function finds an entry in the eet file that is stored under the
883 * name specified, and returns that data, decompressed, if successful.
884 * NULL is returned if the lookup fails or if memory errors are
885 * encountered. It is the job of the calling program to call free() on
886 * the returned data. The number of bytes in the returned data chunk are
887 * placed in size_ret.
888 *
889 * If the eet file handle is not valid NULL is returned and size_ret is
890 * filled with 0.
891 *
892 * @see eet_read()
893 *
894 * @since 1.0.0
895 * @ingroup Eet_File_Cipher_Group
896 */
897EAPI void *
898eet_read_cipher(Eet_File *ef,
899 const char *name,
900 int *size_ret,
901 const char *cipher_key);
902
903/**
904 * Write a specified entry to an eet file handle using a cipher.
905 * @param ef A valid eet file handle opened for writing.
906 * @param name Name of the entry. eg: "/base/file_i_want".
907 * @param data Pointer to the data to be stored.
908 * @param size Length in bytes in the data to be stored.
909 * @param compress Compression flags (1 == compress, 0 = don't compress).
910 * @param cipher_key The key to use as cipher.
911 * @return bytes written on successful write, 0 on failure.
912 *
913 * This function will write the specified chunk of data to the eet file
914 * and return greater than 0 on success. 0 will be returned on failure.
915 *
916 * The eet file handle must be a valid file handle for an eet file opened
917 * for writing. If it is not, 0 will be returned and no action will be
918 * performed.
919 *
920 * Name, and data must not be NULL, and size must be > 0. If these
921 * conditions are not met, 0 will be returned.
922 *
923 * The data will be copied (and optionally compressed) in ram, pending
924 * a flush to disk (it will stay in ram till the eet file handle is
925 * closed though).
926 *
927 * @see eet_write()
928 *
929 * @since 1.0.0
930 * @ingroup Eet_File_Cipher_Group
931 */
932EAPI int
933eet_write_cipher(Eet_File *ef,
934 const char *name,
935 const void *data,
936 int size,
937 int compress,
938 const char *cipher_key);
939
940/**
941 * @defgroup Eet_File_Image_Group Image Store and Load
942 *
943 * Eet efficiently stores and loads images, including alpha
944 * channels and lossy compressions.
945 *
946 * Eet can handle both lossy compression with different levels of quality and
947 * non-lossy compression with different compression levels. It's also possible,
948 * given an image data, to only read its header to get the image information
949 * without decoding the entire content for it.
950 *
951 * The encode family of functions will take an image raw buffer and its
952 * parameters and compress it in memory, returning the new buffer.
953 * Likewise, the decode functions will read from the given location in memory
954 * and return the uncompressed image.
955 *
956 * The read and write functions will, respectively, encode and decode to or
957 * from an Eet file, under the specified key.
958 *
959 * These functions are fairly low level and the same functionality can be
960 * achieved using Evas and Edje, making it much easier to work with images
961 * as well as not needing to worry about things like scaling them.
962 */
963
964/**
965 * Read just the header data for an image and dont decode the pixels.
966 * @param ef A valid eet file handle opened for reading.
967 * @param name Name of the entry. eg: "/base/file_i_want".
968 * @param w A pointer to the unsigned int to hold the width in pixels.
969 * @param h A pointer to the unsigned int to hold the height in pixels.
970 * @param alpha A pointer to the int to hold the alpha flag.
971 * @param compress A pointer to the int to hold the compression amount.
972 * @param quality A pointer to the int to hold the quality amount.
973 * @param lossy A pointer to the int to hold the lossiness flag.
974 * @return 1 on successful decode, 0 otherwise
975 *
976 * Reads and decodes the image header data stored under the given key and
977 * Eet file.
978 *
979 * The information decoded is placed in each of the parameters, which must be
980 * provided. The width and height, measured in pixels, will be stored under
981 * the variables pointed by @p w and @p h, respectively. If the read or
982 * decode of the header fails, this values will be 0. The @p alpha parameter
983 * will be 1 or 0, denoting if the alpha channel of the image is used or not.
984 * If the image was losslessly compressed, the @p compress parameter will hold
985 * the compression amount used, ranging from 0 to 9 and @p lossy will be 0.
986 * In the case of lossy compression, @p lossy will be 1, and the compression
987 * quality will be placed under @p quality, with a value ranging from 0 to 100.
988 *
989 * @see eet_data_image_header_decode()
990 * @see eet_data_image_header_read_cipher()
991 *
992 * @since 1.0.0
993 * @ingroup Eet_File_Image_Group
994 */
995EAPI int
996eet_data_image_header_read(Eet_File *ef,
997 const char *name,
998 unsigned int *w,
999 unsigned int *h,
1000 int *alpha,
1001 int *compress,
1002 int *quality,
1003 int *lossy);
1004
1005/**
1006 * Read image data from the named key in the eet file.
1007 * @param ef A valid eet file handle opened for reading.
1008 * @param name Name of the entry. eg: "/base/file_i_want".
1009 * @param w A pointer to the unsigned int to hold the width in pixels.
1010 * @param h A pointer to the unsigned int to hold the height in pixels.
1011 * @param alpha A pointer to the int to hold the alpha flag.
1012 * @param compress A pointer to the int to hold the compression amount.
1013 * @param quality A pointer to the int to hold the quality amount.
1014 * @param lossy A pointer to the int to hold the lossiness flag.
1015 * @return The image pixel data decoded
1016 *
1017 * Reads and decodes the image stored in the given Eet file under the named
1018 * key.
1019 *
1020 * The returned pixel data is a linear array of pixels starting from the
1021 * top-left of the image, scanning row by row from left to right. Each pile
1022 * is a 32bit value, with the high byte being the alpha channel, the next being
1023 * red, then green, and the low byte being blue.
1024 *
1025 * The rest of the parameters are the same as in eet_data_image_header_read().
1026 *
1027 * On success the function returns a pointer to the image data decoded. The
1028 * calling application is responsible for calling free() on the image data
1029 * when it is done with it. On failure NULL is returned and the parameter
1030 * values may not contain any sensible data.
1031 *
1032 * @see eet_data_image_header_read()
1033 * @see eet_data_image_decode()
1034 * @see eet_data_image_read_cipher()
1035 * @see eet_data_image_read_to_surface()
1036 *
1037 * @since 1.0.0
1038 * @ingroup Eet_File_Image_Group
1039 */
1040EAPI void *
1041eet_data_image_read(Eet_File *ef,
1042 const char *name,
1043 unsigned int *w,
1044 unsigned int *h,
1045 int *alpha,
1046 int *compress,
1047 int *quality,
1048 int *lossy);
1049
1050/**
1051 * Read image data from the named key in the eet file and store it in the given buffer.
1052 * @param ef A valid eet file handle opened for reading.
1053 * @param name Name of the entry. eg: "/base/file_i_want".
1054 * @param src_x The starting x coordinate from where to dump the stream.
1055 * @param src_y The starting y coordinate from where to dump the stream.
1056 * @param d A pointer to the pixel surface.
1057 * @param w The expected width in pixels of the pixel surface to decode.
1058 * @param h The expected height in pixels of the pixel surface to decode.
1059 * @param row_stride The length of a pixels line in the destination surface.
1060 * @param alpha A pointer to the int to hold the alpha flag.
1061 * @param compress A pointer to the int to hold the compression amount.
1062 * @param quality A pointer to the int to hold the quality amount.
1063 * @param lossy A pointer to the int to hold the lossiness flag.
1064 * @return 1 on success, 0 otherwise.
1065 *
1066 * Reads and decodes the image stored in the given Eet file, placing the
1067 * resulting pixel data in the buffer pointed by the user.
1068 *
1069 * Like eet_data_image_read(), it takes the image data stored under the
1070 * @p name key in the @p ef file, but instead of returning a new buffer with
1071 * the pixel data, it places the result in the buffer pointed by @p d, which
1072 * must be provided by the user and of sufficient size to hold the requested
1073 * portion of the image.
1074 *
1075 * The @p src_x and @p src_y parameters indicate the top-left corner of the
1076 * section of the image to decode. These have to be higher or equal than 0 and
1077 * less than the respective total width and height of the image. The width
1078 * and height of the section of the image to decode are given in @p w and @p h
1079 * and also can't be higher than the total width and height of the image.
1080 *
1081 * The @p row_stride parameter indicates the length in bytes of each line in
1082 * the destination buffer and it has to be at least @p w * 4.
1083 *
1084 * All the other parameters are the same as in eet_data_image_read().
1085 *
1086 * On success the function returns 1, and 0 on failure. On failure the
1087 * parameter values may not contain any sensible data.
1088 *
1089 * @see eet_data_image_read()
1090 * @see eet_data_image_decode()
1091 * @see eet_data_image_decode_to_surface()
1092 * @see eet_data_image_read_to_surface_cipher()
1093 *
1094 * @since 1.0.2
1095 * @ingroup Eet_File_Image_Group
1096 */
1097EAPI int
1098eet_data_image_read_to_surface(Eet_File *ef,
1099 const char *name,
1100 unsigned int src_x,
1101 unsigned int src_y,
1102 unsigned int *d,
1103 unsigned int w,
1104 unsigned int h,
1105 unsigned int row_stride,
1106 int *alpha,
1107 int *compress,
1108 int *quality,
1109 int *lossy);
1110
1111/**
1112 * Write image data to the named key in an eet file.
1113 * @param ef A valid eet file handle opened for writing.
1114 * @param name Name of the entry. eg: "/base/file_i_want".
1115 * @param data A pointer to the image pixel data.
1116 * @param w The width of the image in pixels.
1117 * @param h The height of the image in pixels.
1118 * @param alpha The alpha channel flag.
1119 * @param compress The compression amount.
1120 * @param quality The quality encoding amount.
1121 * @param lossy The lossiness flag.
1122 * @return Success if the data was encoded and written or not.
1123 *
1124 * This function takes image pixel data and encodes it in an eet file
1125 * stored under the supplied name key, and returns how many bytes were
1126 * actually written to encode the image data.
1127 *
1128 * The data expected is the same format as returned by eet_data_image_read.
1129 * If this is not the case weird things may happen. Width and height must
1130 * be between 1 and 8000 pixels. The alpha flags can be 0 or 1 (0 meaning
1131 * the alpha values are not useful and 1 meaning they are). Compress can
1132 * be from 0 to 9 (0 meaning no compression, 9 meaning full compression).
1133 * This is only used if the image is not lossily encoded. Quality is used on
1134 * lossy compression and should be a value from 0 to 100. The lossy flag
1135 * can be 0 or 1. 0 means encode losslessly and 1 means to encode with
1136 * image quality loss (but then have a much smaller encoding).
1137 *
1138 * On success this function returns the number of bytes that were required
1139 * to encode the image data, or on failure it returns 0.
1140 *
1141 * @see eet_data_image_read()
1142 * @see eet_data_image_encode()
1143 * @see eet_data_image_write_cipher()
1144 *
1145 * @since 1.0.0
1146 * @ingroup Eet_File_Image_Group
1147 */
1148EAPI int
1149eet_data_image_write(Eet_File *ef,
1150 const char *name,
1151 const void *data,
1152 unsigned int w,
1153 unsigned int h,
1154 int alpha,
1155 int compress,
1156 int quality,
1157 int lossy);
1158
1159/**
1160 * Decode Image data header only to get information.
1161 * @param data The encoded pixel data.
1162 * @param size The size, in bytes, of the encoded pixel data.
1163 * @param w A pointer to the unsigned int to hold the width in pixels.
1164 * @param h A pointer to the unsigned int to hold the height in pixels.
1165 * @param alpha A pointer to the int to hold the alpha flag.
1166 * @param compress A pointer to the int to hold the compression amount.
1167 * @param quality A pointer to the int to hold the quality amount.
1168 * @param lossy A pointer to the int to hold the lossiness flag.
1169 * @return 1 on success, 0 on failure.
1170 *
1171 * This function works exactly like eet_data_image_header_read(), but instead
1172 * of reading from an Eet file, it takes the buffer of size @p size pointed
1173 * by @p data, which must be a valid Eet encoded image.
1174 *
1175 * On success the function returns 1 indicating the header was read and
1176 * decoded properly, or 0 on failure.
1177 *
1178 * @see eet_data_image_header_read()
1179 * @see eet_data_image_header_decode_cipher()
1180 *
1181 * @since 1.0.0
1182 * @ingroup Eet_File_Image_Group
1183 */
1184EAPI int
1185eet_data_image_header_decode(const void *data,
1186 int size,
1187 unsigned int *w,
1188 unsigned int *h,
1189 int *alpha,
1190 int *compress,
1191 int *quality,
1192 int *lossy);
1193
1194/**
1195 * Decode Image data into pixel data.
1196 * @param data The encoded pixel data.
1197 * @param size The size, in bytes, of the encoded pixel data.
1198 * @param w A pointer to the unsigned int to hold the width in pixels.
1199 * @param h A pointer to the unsigned int to hold the height in pixels.
1200 * @param alpha A pointer to the int to hold the alpha flag.
1201 * @param compress A pointer to the int to hold the compression amount.
1202 * @param quality A pointer to the int to hold the quality amount.
1203 * @param lossy A pointer to the int to hold the lossiness flag.
1204 * @return The image pixel data decoded
1205 *
1206 * This function takes encoded pixel data and decodes it into raw RGBA
1207 * pixels on success.
1208 *
1209 * It works exactly like eet_data_image_read(), but it takes the encoded
1210 * data in the @p data buffer of size @p size, instead of reading from a file.
1211 * All the others parameters are also the same.
1212 *
1213 * On success the function returns a pointer to the image data decoded. The
1214 * calling application is responsible for calling free() on the image data
1215 * when it is done with it. On failure NULL is returned and the parameter
1216 * values may not contain any sensible data.
1217 *
1218 * @see eet_data_image_read()
1219 * @see eet_data_image_decode_cipher()
1220 *
1221 * @since 1.0.0
1222 * @ingroup Eet_File_Image_Group
1223 */
1224EAPI void *
1225eet_data_image_decode(const void *data,
1226 int size,
1227 unsigned int *w,
1228 unsigned int *h,
1229 int *alpha,
1230 int *compress,
1231 int *quality,
1232 int *lossy);
1233
1234/**
1235 * Decode Image data into pixel data and stores in the given buffer.
1236 * @param data The encoded pixel data.
1237 * @param size The size, in bytes, of the encoded pixel data.
1238 * @param src_x The starting x coordinate from where to dump the stream.
1239 * @param src_y The starting y coordinate from where to dump the stream.
1240 * @param d A pointer to the pixel surface.
1241 * @param w The expected width in pixels of the pixel surface to decode.
1242 * @param h The expected height in pixels of the pixel surface to decode.
1243 * @param row_stride The length of a pixels line in the destination surface.
1244 * @param alpha A pointer to the int to hold the alpha flag.
1245 * @param compress A pointer to the int to hold the compression amount.
1246 * @param quality A pointer to the int to hold the quality amount.
1247 * @param lossy A pointer to the int to hold the lossiness flag.
1248 * @return 1 on success, 0 otherwise.
1249 *
1250 * Like eet_data_image_read_to_surface(), but reading the given @p data buffer
1251 * instead of a file.
1252 *
1253 * On success the function returns 1, and 0 on failure. On failure the
1254 * parameter values may not contain any sensible data.
1255 *
1256 * @see eet_data_image_read_to_surface()
1257 * @see eet_data_image_decode_to_surface_cipher()
1258 *
1259 * @since 1.0.2
1260 * @ingroup Eet_File_Image_Group
1261 */
1262EAPI int
1263eet_data_image_decode_to_surface(const void *data,
1264 int size,
1265 unsigned int src_x,
1266 unsigned int src_y,
1267 unsigned int *d,
1268 unsigned int w,
1269 unsigned int h,
1270 unsigned int row_stride,
1271 int *alpha,
1272 int *compress,
1273 int *quality,
1274 int *lossy);
1275
1276/**
1277 * Encode image data for storage or transmission.
1278 * @param data A pointer to the image pixel data.
1279 * @param size_ret A pointer to an int to hold the size of the returned data.
1280 * @param w The width of the image in pixels.
1281 * @param h The height of the image in pixels.
1282 * @param alpha The alpha channel flag.
1283 * @param compress The compression amount.
1284 * @param quality The quality encoding amount.
1285 * @param lossy The lossiness flag.
1286 * @return The encoded image data.
1287 *
1288 * This function stakes image pixel data and encodes it with compression and
1289 * possible loss of quality (as a trade off for size) for storage or
1290 * transmission to another system.
1291 *
1292 * It works like eet_data_image_write(), but instead of writing the encoded
1293 * image into an Eet file, it allocates a new buffer of the size required and
1294 * returns the encoded data in it.
1295 *
1296 * On success this function returns a pointer to the encoded data that you
1297 * can free with free() when no longer needed.
1298 *
1299 * @see eet_data_image_write()
1300 * @see eet_data_image_read()
1301 * @see eet_data_image_encode_cipher()
1302 *
1303 * @since 1.0.0
1304 * @ingroup Eet_File_Image_Group
1305 */
1306EAPI void *
1307eet_data_image_encode(const void *data,
1308 int *size_ret,
1309 unsigned int w,
1310 unsigned int h,
1311 int alpha,
1312 int compress,
1313 int quality,
1314 int lossy);
1315
1316/**
1317 * @defgroup Eet_File_Image_Cipher_Group Image Store and Load using a Cipher
1318 *
1319 * Most of the @ref Eet_File_Image_Group have alternative versions
1320 * that accounts for ciphers to protect their content.
1321 *
1322 * @see @ref Eet_Cipher_Group
1323 *
1324 * @ingroup Eet_File_Image_Group
1325 */
1326
1327/**
1328 * Read just the header data for an image and dont decode the pixels using a cipher.
1329 * @param ef A valid eet file handle opened for reading.
1330 * @param name Name of the entry. eg: "/base/file_i_want".
1331 * @param cipher_key The key to use as cipher.
1332 * @param w A pointer to the unsigned int to hold the width in pixels.
1333 * @param h A pointer to the unsigned int to hold the height in pixels.
1334 * @param alpha A pointer to the int to hold the alpha flag.
1335 * @param compress A pointer to the int to hold the compression amount.
1336 * @param quality A pointer to the int to hold the quality amount.
1337 * @param lossy A pointer to the int to hold the lossiness flag.
1338 * @return 1 on successful decode, 0 otherwise
1339 *
1340 * This function reads an image from an eet file stored under the named
1341 * key in the eet file and return a pointer to the decompressed pixel data.
1342 *
1343 * The other parameters of the image (width, height etc.) are placed into
1344 * the values pointed to (they must be supplied). The pixel data is a linear
1345 * array of pixels starting from the top-left of the image scanning row by
1346 * row from left to right. Each pixel is a 32bit value, with the high byte
1347 * being the alpha channel, the next being red, then green, and the low byte
1348 * being blue. The width and height are measured in pixels and will be
1349 * greater than 0 when returned. The alpha flag is either 0 or 1. 0 denotes
1350 * that the alpha channel is not used. 1 denotes that it is significant.
1351 * Compress is filled with the compression value/amount the image was
1352 * stored with. The quality value is filled with the quality encoding of
1353 * the image file (0 - 100). The lossy flags is either 0 or 1 as to if
1354 * the image was encoded lossily or not.
1355 *
1356 * On success the function returns 1 indicating the header was read and
1357 * decoded properly, or 0 on failure.
1358 *
1359 * @see eet_data_image_header_read()
1360 *
1361 * @since 1.0.0
1362 * @ingroup Eet_File_Image_Cipher_Group
1363 */
1364EAPI int
1365eet_data_image_header_read_cipher(Eet_File *ef,
1366 const char *name,
1367 const char *cipher_key,
1368 unsigned int *w,
1369 unsigned int *h,
1370 int *alpha,
1371 int *compress,
1372 int *quality,
1373 int *lossy);
1374
1375/**
1376 * Read image data from the named key in the eet file using a cipher.
1377 * @param ef A valid eet file handle opened for reading.
1378 * @param name Name of the entry. eg: "/base/file_i_want".
1379 * @param cipher_key The key to use as cipher.
1380 * @param w A pointer to the unsigned int to hold the width in pixels.
1381 * @param h A pointer to the unsigned int to hold the height in pixels.
1382 * @param alpha A pointer to the int to hold the alpha flag.
1383 * @param compress A pointer to the int to hold the compression amount.
1384 * @param quality A pointer to the int to hold the quality amount.
1385 * @param lossy A pointer to the int to hold the lossiness flag.
1386 * @return The image pixel data decoded
1387 *
1388 * This function reads an image from an eet file stored under the named
1389 * key in the eet file and return a pointer to the decompressed pixel data.
1390 *
1391 * The other parameters of the image (width, height etc.) are placed into
1392 * the values pointed to (they must be supplied). The pixel data is a linear
1393 * array of pixels starting from the top-left of the image scanning row by
1394 * row from left to right. Each pixel is a 32bit value, with the high byte
1395 * being the alpha channel, the next being red, then green, and the low byte
1396 * being blue. The width and height are measured in pixels and will be
1397 * greater than 0 when returned. The alpha flag is either 0 or 1. 0 denotes
1398 * that the alpha channel is not used. 1 denotes that it is significant.
1399 * Compress is filled with the compression value/amount the image was
1400 * stored with. The quality value is filled with the quality encoding of
1401 * the image file (0 - 100). The lossy flags is either 0 or 1 as to if
1402 * the image was encoded lossily or not.
1403 *
1404 * On success the function returns a pointer to the image data decoded. The
1405 * calling application is responsible for calling free() on the image data
1406 * when it is done with it. On failure NULL is returned and the parameter
1407 * values may not contain any sensible data.
1408 *
1409 * @see eet_data_image_read()
1410 *
1411 * @since 1.0.0
1412 * @ingroup Eet_File_Image_Cipher_Group
1413 */
1414EAPI void *
1415eet_data_image_read_cipher(Eet_File *ef,
1416 const char *name,
1417 const char *cipher_key,
1418 unsigned int *w,
1419 unsigned int *h,
1420 int *alpha,
1421 int *compress,
1422 int *quality,
1423 int *lossy);
1424
1425/**
1426 * Read image data from the named key in the eet file using a cipher.
1427 * @param ef A valid eet file handle opened for reading.
1428 * @param name Name of the entry. eg: "/base/file_i_want".
1429 * @param cipher_key The key to use as cipher.
1430 * @param src_x The starting x coordinate from where to dump the stream.
1431 * @param src_y The starting y coordinate from where to dump the stream.
1432 * @param d A pointer to the pixel surface.
1433 * @param w The expected width in pixels of the pixel surface to decode.
1434 * @param h The expected height in pixels of the pixel surface to decode.
1435 * @param row_stride The length of a pixels line in the destination surface.
1436 * @param alpha A pointer to the int to hold the alpha flag.
1437 * @param compress A pointer to the int to hold the compression amount.
1438 * @param quality A pointer to the int to hold the quality amount.
1439 * @param lossy A pointer to the int to hold the lossiness flag.
1440 * @return 1 on success, 0 otherwise.
1441 *
1442 * This function reads an image from an eet file stored under the named
1443 * key in the eet file and return a pointer to the decompressed pixel data.
1444 *
1445 * The other parameters of the image (width, height etc.) are placed into
1446 * the values pointed to (they must be supplied). The pixel data is a linear
1447 * array of pixels starting from the top-left of the image scanning row by
1448 * row from left to right. Each pixel is a 32bit value, with the high byte
1449 * being the alpha channel, the next being red, then green, and the low byte
1450 * being blue. The width and height are measured in pixels and will be
1451 * greater than 0 when returned. The alpha flag is either 0 or 1. 0 denotes
1452 * that the alpha channel is not used. 1 denotes that it is significant.
1453 * Compress is filled with the compression value/amount the image was
1454 * stored with. The quality value is filled with the quality encoding of
1455 * the image file (0 - 100). The lossy flags is either 0 or 1 as to if
1456 * the image was encoded lossily or not.
1457 *
1458 * On success the function returns 1, and 0 on failure. On failure the
1459 * parameter values may not contain any sensible data.
1460 *
1461 * @see eet_data_image_read_to_surface()
1462 *
1463 * @since 1.0.2
1464 * @ingroup Eet_File_Image_Cipher_Group
1465 */
1466EAPI int
1467eet_data_image_read_to_surface_cipher(Eet_File *ef,
1468 const char *name,
1469 const char *cipher_key,
1470 unsigned int src_x,
1471 unsigned int src_y,
1472 unsigned int *d,
1473 unsigned int w,
1474 unsigned int h,
1475 unsigned int row_stride,
1476 int *alpha,
1477 int *compress,
1478 int *quality,
1479 int *lossy);
1480
1481/**
1482 * Write image data to the named key in an eet file using a cipher.
1483 * @param ef A valid eet file handle opened for writing.
1484 * @param name Name of the entry. eg: "/base/file_i_want".
1485 * @param cipher_key The key to use as cipher.
1486 * @param data A pointer to the image pixel data.
1487 * @param w The width of the image in pixels.
1488 * @param h The height of the image in pixels.
1489 * @param alpha The alpha channel flag.
1490 * @param compress The compression amount.
1491 * @param quality The quality encoding amount.
1492 * @param lossy The lossiness flag.
1493 * @return Success if the data was encoded and written or not.
1494 *
1495 * This function takes image pixel data and encodes it in an eet file
1496 * stored under the supplied name key, and returns how many bytes were
1497 * actually written to encode the image data.
1498 *
1499 * The data expected is the same format as returned by eet_data_image_read.
1500 * If this is not the case weird things may happen. Width and height must
1501 * be between 1 and 8000 pixels. The alpha flags can be 0 or 1 (0 meaning
1502 * the alpha values are not useful and 1 meaning they are). Compress can
1503 * be from 0 to 9 (0 meaning no compression, 9 meaning full compression).
1504 * This is only used if the image is not lossily encoded. Quality is used on
1505 * lossy compression and should be a value from 0 to 100. The lossy flag
1506 * can be 0 or 1. 0 means encode losslessly and 1 means to encode with
1507 * image quality loss (but then have a much smaller encoding).
1508 *
1509 * On success this function returns the number of bytes that were required
1510 * to encode the image data, or on failure it returns 0.
1511 *
1512 * @see eet_data_image_write()
1513 *
1514 * @since 1.0.0
1515 * @ingroup Eet_File_Image_Cipher_Group
1516 */
1517EAPI int
1518eet_data_image_write_cipher(Eet_File *ef,
1519 const char *name,
1520 const char *cipher_key,
1521 const void *data,
1522 unsigned int w,
1523 unsigned int h,
1524 int alpha,
1525 int compress,
1526 int quality,
1527 int lossy);
1528
1529/**
1530 * Decode Image data header only to get information using a cipher.
1531 * @param data The encoded pixel data.
1532 * @param cipher_key The key to use as cipher.
1533 * @param size The size, in bytes, of the encoded pixel data.
1534 * @param w A pointer to the unsigned int to hold the width in pixels.
1535 * @param h A pointer to the unsigned int to hold the height in pixels.
1536 * @param alpha A pointer to the int to hold the alpha flag.
1537 * @param compress A pointer to the int to hold the compression amount.
1538 * @param quality A pointer to the int to hold the quality amount.
1539 * @param lossy A pointer to the int to hold the lossiness flag.
1540 * @return 1 on success, 0 on failure.
1541 *
1542 * This function takes encoded pixel data and decodes it into raw RGBA
1543 * pixels on success.
1544 *
1545 * The other parameters of the image (width, height etc.) are placed into
1546 * the values pointed to (they must be supplied). The pixel data is a linear
1547 * array of pixels starting from the top-left of the image scanning row by
1548 * row from left to right. Each pixel is a 32bit value, with the high byte
1549 * being the alpha channel, the next being red, then green, and the low byte
1550 * being blue. The width and height are measured in pixels and will be
1551 * greater than 0 when returned. The alpha flag is either 0 or 1. 0 denotes
1552 * that the alpha channel is not used. 1 denotes that it is significant.
1553 * Compress is filled with the compression value/amount the image was
1554 * stored with. The quality value is filled with the quality encoding of
1555 * the image file (0 - 100). The lossy flags is either 0 or 1 as to if
1556 * the image was encoded lossily or not.
1557 *
1558 * On success the function returns 1 indicating the header was read and
1559 * decoded properly, or 0 on failure.
1560 *
1561 * @see eet_data_image_header_decode()
1562 *
1563 * @since 1.0.0
1564 * @ingroup Eet_File_Image_Cipher_Group
1565 */
1566EAPI int
1567eet_data_image_header_decode_cipher(const void *data,
1568 const char *cipher_key,
1569 int size,
1570 unsigned int *w,
1571 unsigned int *h,
1572 int *alpha,
1573 int *compress,
1574 int *quality,
1575 int *lossy);
1576
1577/**
1578 * Decode Image data into pixel data using a cipher.
1579 * @param data The encoded pixel data.
1580 * @param cipher_key The key to use as cipher.
1581 * @param size The size, in bytes, of the encoded pixel data.
1582 * @param w A pointer to the unsigned int to hold the width in pixels.
1583 * @param h A pointer to the unsigned int to hold the height in pixels.
1584 * @param alpha A pointer to the int to hold the alpha flag.
1585 * @param compress A pointer to the int to hold the compression amount.
1586 * @param quality A pointer to the int to hold the quality amount.
1587 * @param lossy A pointer to the int to hold the lossiness flag.
1588 * @return The image pixel data decoded
1589 *
1590 * This function takes encoded pixel data and decodes it into raw RGBA
1591 * pixels on success.
1592 *
1593 * The other parameters of the image (width, height etc.) are placed into
1594 * the values pointed to (they must be supplied). The pixel data is a linear
1595 * array of pixels starting from the top-left of the image scanning row by
1596 * row from left to right. Each pixel is a 32bit value, with the high byte
1597 * being the alpha channel, the next being red, then green, and the low byte
1598 * being blue. The width and height are measured in pixels and will be
1599 * greater than 0 when returned. The alpha flag is either 0 or 1. 0 denotes
1600 * that the alpha channel is not used. 1 denotes that it is significant.
1601 * Compress is filled with the compression value/amount the image was
1602 * stored with. The quality value is filled with the quality encoding of
1603 * the image file (0 - 100). The lossy flags is either 0 or 1 as to if
1604 * the image was encoded lossily or not.
1605 *
1606 * On success the function returns a pointer to the image data decoded. The
1607 * calling application is responsible for calling free() on the image data
1608 * when it is done with it. On failure NULL is returned and the parameter
1609 * values may not contain any sensible data.
1610 *
1611 * @see eet_data_image_decode()
1612 *
1613 * @since 1.0.0
1614 * @ingroup Eet_File_Image_Cipher_Group
1615 */
1616EAPI void *
1617eet_data_image_decode_cipher(const void *data,
1618 const char *cipher_key,
1619 int size,
1620 unsigned int *w,
1621 unsigned int *h,
1622 int *alpha,
1623 int *compress,
1624 int *quality,
1625 int *lossy);
1626
1627/**
1628 * Decode Image data into pixel data using a cipher.
1629 * @param data The encoded pixel data.
1630 * @param cipher_key The key to use as cipher.
1631 * @param size The size, in bytes, of the encoded pixel data.
1632 * @param src_x The starting x coordinate from where to dump the stream.
1633 * @param src_y The starting y coordinate from where to dump the stream.
1634 * @param d A pointer to the pixel surface.
1635 * @param w The expected width in pixels of the pixel surface to decode.
1636 * @param h The expected height in pixels of the pixel surface to decode.
1637 * @param row_stride The length of a pixels line in the destination surface.
1638 * @param alpha A pointer to the int to hold the alpha flag.
1639 * @param compress A pointer to the int to hold the compression amount.
1640 * @param quality A pointer to the int to hold the quality amount.
1641 * @param lossy A pointer to the int to hold the lossiness flag.
1642 * @return 1 on success, 0 otherwise.
1643 *
1644 * This function takes encoded pixel data and decodes it into raw RGBA
1645 * pixels on success.
1646 *
1647 * The other parameters of the image (alpha, compress etc.) are placed into
1648 * the values pointed to (they must be supplied). The pixel data is a linear
1649 * array of pixels starting from the top-left of the image scanning row by
1650 * row from left to right. Each pixel is a 32bit value, with the high byte
1651 * being the alpha channel, the next being red, then green, and the low byte
1652 * being blue. The width and height are measured in pixels and will be
1653 * greater than 0 when returned. The alpha flag is either 0 or 1. 0 denotes
1654 * that the alpha channel is not used. 1 denotes that it is significant.
1655 * Compress is filled with the compression value/amount the image was
1656 * stored with. The quality value is filled with the quality encoding of
1657 * the image file (0 - 100). The lossy flags is either 0 or 1 as to if
1658 * the image was encoded lossily or not.
1659 *
1660 * On success the function returns 1, and 0 on failure. On failure the
1661 * parameter values may not contain any sensible data.
1662 *
1663 * @see eet_data_image_decode_to_surface()
1664 *
1665 * @since 1.0.2
1666 * @ingroup Eet_File_Image_Cipher_Group
1667 */
1668EAPI int
1669eet_data_image_decode_to_surface_cipher(const void *data,
1670 const char *cipher_key,
1671 int size,
1672 unsigned int src_x,
1673 unsigned int src_y,
1674 unsigned int *d,
1675 unsigned int w,
1676 unsigned int h,
1677 unsigned int row_stride,
1678 int *alpha,
1679 int *compress,
1680 int *quality,
1681 int *lossy);
1682
1683/**
1684 * Encode image data for storage or transmission using a cipher.
1685 * @param data A pointer to the image pixel data.
1686 * @param cipher_key The key to use as cipher.
1687 * @param size_ret A pointer to an int to hold the size of the returned data.
1688 * @param w The width of the image in pixels.
1689 * @param h The height of the image in pixels.
1690 * @param alpha The alpha channel flag.
1691 * @param compress The compression amount.
1692 * @param quality The quality encoding amount.
1693 * @param lossy The lossiness flag.
1694 * @return The encoded image data.
1695 *
1696 * This function stakes image pixel data and encodes it with compression and
1697 * possible loss of quality (as a trade off for size) for storage or
1698 * transmission to another system.
1699 *
1700 * The data expected is the same format as returned by eet_data_image_read.
1701 * If this is not the case weird things may happen. Width and height must
1702 * be between 1 and 8000 pixels. The alpha flags can be 0 or 1 (0 meaning
1703 * the alpha values are not useful and 1 meaning they are). Compress can
1704 * be from 0 to 9 (0 meaning no compression, 9 meaning full compression).
1705 * This is only used if the image is not lossily encoded. Quality is used on
1706 * lossy compression and should be a value from 0 to 100. The lossy flag
1707 * can be 0 or 1. 0 means encode losslessly and 1 means to encode with
1708 * image quality loss (but then have a much smaller encoding).
1709 *
1710 * On success this function returns a pointer to the encoded data that you
1711 * can free with free() when no longer needed.
1712 *
1713 * @see eet_data_image_encode()
1714 *
1715 * @since 1.0.0
1716 * @ingroup Eet_File_Image_Cipher_Group
1717 */
1718EAPI void *
1719eet_data_image_encode_cipher(const void *data,
1720 const char *cipher_key,
1721 unsigned int w,
1722 unsigned int h,
1723 int alpha,
1724 int compress,
1725 int quality,
1726 int lossy,
1727 int *size_ret);
1728
1729/**
1730 * @defgroup Eet_Cipher_Group Cipher, Identity and Protection Mechanisms
1731 *
1732 * Eet allows one to protect entries of an #Eet_File
1733 * individually. This may be used to ensure data was not tampered or
1734 * that third party does not read your data.
1735 *
1736 * @see @ref Eet_File_Cipher_Group
1737 * @see @ref Eet_File_Image_Cipher_Group
1738 *
1739 * @{
1740 */
1741
1742/**
1743 * @typedef Eet_Key
1744 * Opaque handle that defines an identity (also known as key)
1745 * in Eet's cipher system.
1746 */
1747typedef struct _Eet_Key Eet_Key;
1748
1749/**
1750 * @}
1751 */
1752
1753/**
1754 * Callback used to request if needed the password of a private key.
1755 *
1756 * @param buffer the buffer where to store the password.
1757 * @param size the maximum password size (size of buffer, including '@\0').
1758 * @param rwflag if the buffer is also readable or just writable.
1759 * @param data currently unused, may contain some context in future.
1760 * @return 1 on success and password was set to @p buffer, 0 on failure.
1761 *
1762 * @since 1.2.0
1763 * @ingroup Eet_Cipher_Group
1764 */
1765typedef int (*Eet_Key_Password_Callback)(char *buffer, int size, int rwflag, void *data);
1766
1767/**
1768 * Create an Eet_Key needed for signing an eet file.
1769 *
1770 * The certificate should provide the public that match the private key.
1771 * No verification is done to ensure that.
1772 *
1773 * @param certificate_file The file where to find the certificate.
1774 * @param private_key_file The file that contains the private key.
1775 * @param cb Function to callback if password is required to unlock
1776 * private key.
1777 * @return A key handle to use, or @c NULL on failure.
1778 *
1779 * @see eet_identity_close()
1780 *
1781 * @since 1.2.0
1782 * @ingroup Eet_Cipher_Group
1783 */
1784EAPI Eet_Key *
1785eet_identity_open(const char *certificate_file,
1786 const char *private_key_file,
1787 Eet_Key_Password_Callback cb);
1788
1789/**
1790 * Close and release all ressource used by an Eet_Key. An
1791 * reference counter prevent it from being freed until all file
1792 * using it are also closed.
1793 *
1794 * @param key the key handle to close and free resources.
1795 *
1796 * @since 1.2.0
1797 * @ingroup Eet_Cipher_Group
1798 */
1799EAPI void
1800eet_identity_close(Eet_Key *key);
1801
1802/**
1803 * Set a key to sign a file
1804 *
1805 * @param ef the file to set the identity.
1806 * @param key the key handle to set as identity.
1807 * @return #EET_ERROR_BAD_OBJECT if @p ef is invalid or
1808 * #EET_ERROR_NONE on success.
1809 *
1810 * @since 1.2.0
1811 * @ingroup Eet_Cipher_Group
1812 */
1813EAPI Eet_Error
1814eet_identity_set(Eet_File *ef,
1815 Eet_Key *key);
1816
1817/**
1818 * Display both private and public key of an Eet_Key.
1819 *
1820 * @param key the handle to print.
1821 * @param out where to print.
1822 *
1823 * @since 1.2.0
1824 * @ingroup Eet_Cipher_Group
1825 */
1826EAPI void
1827eet_identity_print(Eet_Key *key,
1828 FILE *out);
1829
1830/**
1831 * Get the x509 der certificate associated with an Eet_File. Will return NULL
1832 * if the file is not signed.
1833 *
1834 * @param ef The file handle to query.
1835 * @param der_length The length of returned data, may be @c NULL.
1836 * @return the x509 certificate or @c NULL on error.
1837 *
1838 * @since 1.2.0
1839 * @ingroup Eet_Cipher_Group
1840 */
1841EAPI const void *
1842eet_identity_x509(Eet_File *ef,
1843 int *der_length);
1844
1845/**
1846 * Get the raw signature associated with an Eet_File. Will return NULL
1847 * if the file is not signed.
1848 *
1849 * @param ef The file handle to query.
1850 * @param signature_length The length of returned data, may be @c NULL.
1851 * @return the raw signature or @c NULL on error.
1852 *
1853 * @ingroup Eet_Cipher_Group
1854 */
1855EAPI const void *
1856eet_identity_signature(Eet_File *ef,
1857 int *signature_length);
1858
1859/**
1860 * Get the SHA1 associated with a file. Could be the one used to
1861 * sign the data or if the data where not signed, it will be the
1862 * SHA1 of the file.
1863 *
1864 * @param ef The file handle to query.
1865 * @param sha1_length The length of returned data, may be @c NULL.
1866 * @return the associated SHA1 or @c NULL on error.
1867 *
1868 * @since 1.2.0
1869 * @ingroup Eet_Cipher_Group
1870 */
1871EAPI const void *
1872eet_identity_sha1(Eet_File *ef,
1873 int *sha1_length);
1874
1875/**
1876 * Display the x509 der certificate to out.
1877 *
1878 * @param certificate the x509 certificate to print
1879 * @param der_length The length the certificate.
1880 * @param out where to print.
1881 *
1882 * @since 1.2.0
1883 * @ingroup Eet_Cipher_Group
1884 */
1885EAPI void
1886eet_identity_certificate_print(const unsigned char *certificate,
1887 int der_length,
1888 FILE *out);
1889
1890/**
1891 * @defgroup Eet_Data_Group Eet Data Serialization
1892 *
1893 * Convenience functions to serialize and parse complex data
1894 * structures to binary blobs.
1895 *
1896 * While Eet core just handles binary blobs, it is often required
1897 * to save some structured data of different types, such as
1898 * strings, integers, lists, hashes and so on.
1899 *
1900 * Eet can serialize and then parse data types given some
1901 * construction instructions. These are defined in two levels:
1902 *
1903 * - #Eet_Data_Descriptor_Class to tell generic memory handling,
1904 * such as the size of the type, how to allocate memory, strings,
1905 * lists, hashes and so on.
1906 *
1907 * - #Eet_Data_Descriptor to tell inside such type, the members and
1908 * their offsets inside the memory blob, their types and
1909 * names. These members can be simple types or other
1910 * #Eet_Data_Descriptor, allowing hierarchical types to be
1911 * defined.
1912 *
1913 * Given that C provides no introspection, this process can be
1914 * quite cumbersome, so we provide lots of macros and convenience
1915 * functions to aid creating the types.
1916 *
1917 * We make now a quick overview of some of the most commonly used elements
1918 * of this part of the library. A simple example of a configuration system
1919 * will work as a somewhat real life example that is still simple enough to
1920 * follow.
1921 * Only the relevant sections will be shown here, but you can get the full
1922 * code @ref eet-data-simple.c "here".
1923 *
1924 * Ignoring the included headers, we'll begin by defining our configuration
1925 * struct.
1926 * @dontinclude eet-data-simple.c
1927 * @skip typedef
1928 * @until }
1929 *
1930 * When using Eet, you don't think in matters of what data the program needs
1931 * to run and which you would like to store. It's all the same and if it makes
1932 * more sense to keep them together, it's perfectly fine to do so. At the time
1933 * of telling Eet how your data is comprised you can leave out the things
1934 * that are runtime only and let Eet take care of the rest for you.
1935 *
1936 * The key used to store the config follows, as well as the variable used to
1937 * store our data descriptor.
1938 * This last one is very important. It's the one thing that Eet will use to
1939 * identify your data, both at the time of writing it to the file and when
1940 * loading from it.
1941 * @skipline MY_CONF
1942 * @skipline Eet_Data_Descriptor
1943 *
1944 * Now we'll see how to create this descriptor, so Eet knows how to handle
1945 * our data later on.
1946 * Begin our function by declaring an Eet_Data_Descriptor_Class, which is
1947 * used to create the actual descriptor. This class contains the name of
1948 * our data type, its size and several functions that dictate how Eet should
1949 * handle memory to allocate the necessary bits to bring our data to life.
1950 * You, as a user, will very hardly set this class' contents directly. The
1951 * most common scenario is to use one of the provided macros that set it using
1952 * the Eina data types, so that's what we'll be doing across all our examples.
1953 * @skip static void
1954 * @until eet_data_descriptor_stream_new
1955 *
1956 * Now that we have our descriptor, we need to make it describe something.
1957 * We do so by telling it which members of our struct we want it to know about
1958 * and their types.
1959 * The eet_data_descriptor_element_add() function takes care of this, but it's
1960 * too cumbersome for normal use, so several macros are provided that make
1961 * it easier to handle. Even with them, however, code can get very repetitive
1962 * and it's not uncommon to define custom macros using them to save on typing.
1963 * @skip #define
1964 * @until }
1965 *
1966 * Now our descriptor knows about the parts of our structure that we are
1967 * interesting in saving. You can see that not all of them are there, yet Eet
1968 * will find those that need saving and do the right thing. When loading our
1969 * data, any non-described fields in the structure will be zeroed, so there's
1970 * no need to worry about garbage memory in them.
1971 * Refer to the documentation of #EET_DATA_DESCRIPTOR_ADD_BASIC to understand
1972 * what our macro does.
1973 *
1974 * We are done with our descriptor init function and it's proper to have the
1975 * relevant shutdown. Proper coding guidelines indiciate that all memory
1976 * allocated should be freed when the program ends, and since you will most
1977 * likely keep your descriptor around for the life or your application, it's
1978 * only right to free it at the end.
1979 * @skip static void
1980 * @until }
1981 *
1982 * Not listed here, but included in the full example are functions to create
1983 * a blank configuration and free it. The first one will only be used when
1984 * no file exists to load from, or nothing is found in it, but the latter is
1985 * used regardless of where our data comes from. Unless you are reading direct
1986 * data from the Eet file, you will be in charge of freeing anything loaded
1987 * from it.
1988 *
1989 * Now it's time to look at how we can load our config from some file.
1990 * Begin by opening the Eet file normally.
1991 * @skip static My_Conf_Type
1992 * @until }
1993 *
1994 * And now we need to read the data from the file and decode it using our
1995 * descriptor. Fortunately, that's all done in one single step.
1996 * @until goto
1997 *
1998 * And that's it for all Eet cares about. But since we are dealing with a
1999 * common case, as is save and load of user configurations, the next fragment
2000 * of code shows why we have a version field in our struct, and how you can
2001 * use it to load older configuration files and update them as needed.
2002 * @until }
2003 *
2004 * Finally, clsoe the file and return the newly loaded config data.
2005 * @until }
2006 *
2007 * Saving data is just as easy. The full version of the following function
2008 * includes code to save to a temporary file first, so you can be sure not
2009 * to lose all your data in the case of a failure mid-writing. You can look
2010 * at it @ref eet-data-simple.c "here".
2011 * @skip static Eina_Bool
2012 * @until {
2013 * @skipline Eina_Bool ret
2014 * @skip eet_open
2015 * @until eet_close
2016 * @skip return
2017 * @until }
2018 *
2019 * To close, our main function, which doesn't do much. Just take some arguments
2020 * from the command line with the name of the file to load and another one
2021 * where to save again. If input file doesn't exist, a new config structure
2022 * will be created and saved to our output file.
2023 * @skip int main
2024 * @until return ret
2025 * @until }
2026 *
2027 * The following is a list of more advanced and detailed examples.
2028 * @li @ref eet_data_nested_example
2029 * @li @ref eet_data_file_descriptor
2030 * @li @ref Example_Eet_Data_File_Descriptor_02
2031 * @li @ref Example_Eet_Data_Cipher_Decipher
2032 */
2033
2034/**
2035 * @page eet_data_nested_example Nested structures and Eet Data Descriptors
2036 *
2037 * We've seen already a simple example of how to use Eet Data Descriptors
2038 * to handle our structures, but it didn't show how this works when you
2039 * have structures inside other structures.
2040 *
2041 * Now, there's a very simple case of this, for when you have inline structs
2042 * to keep your big structure more organized, you don't need anything else
2043 * besides what @ref eet-data-simple.c "this simple example does".
2044 * Just use something like @p some_struct.sub_struct.member when adding the
2045 * member to the descriptor and it will work.
2046 *
2047 * For example:
2048 * @code
2049 * typedef struct
2050 * {
2051 * int a_number;
2052 * char *a_string;
2053 * struct {
2054 * int other_num;
2055 * int one_more;
2056 * } sub;
2057 * } some_struct;
2058 *
2059 * void some_function()
2060 * {
2061 * ...
2062 * my_desc = eet_data_descriptor_stream_new(&eddc);
2063 * EET_DATA_DESCRIPTOR_ADD_BASIC(my_desc, some_struct, "a_number",
2064 * a_number, EET_T_INT);
2065 * EET_DATA_DESCRIPTOR_ADD_BASIC(my_desc, some_struct, "a_string",
2066 * a_string, EET_T_STRING);
2067 * EET_DATA_DESCRIPTOR_ADD_BASIC(my_desc, some_struct, "sub.other_num",
2068 * sub.other_num, EET_T_INT);
2069 * EET_DATA_DESCRIPTOR_ADD_BASIC(my_desc, some_struct, "sub.one_more",
2070 * sub.one_more", EET_T_INT);
2071 * ...
2072 * }
2073 * @endcode
2074 *
2075 * But this is not what we are here for today. When we talk about nested
2076 * structures, what we really want are things like lists and hashes to be
2077 * taken into consideration automatically, and all their contents saved and
2078 * loaded just like ordinary integers and strings are.
2079 *
2080 * And of course, Eet can do that, and considering the work it saves you as a
2081 * programmer, we could say it's even easier to do than handling just integers.
2082 *
2083 * Let's begin with our example then, which is not all too different from the
2084 * simple one introduced earlier.
2085 *
2086 * We won't ignore the headers this time to show how easy it is to use Eina
2087 * data types with Eet, but we'll still skip most of the code that is not
2088 * pertinent to what we want to show now, but as usual, you can get it full
2089 * by follwing @ref eet-data-nested.c "this link".
2090 *
2091 * @dontinclude eet-data-nested.c
2092 * @skipline Eina.h
2093 * @skipline Eet.h
2094 * @skip typedef struct
2095 * @until } My_Conf_Subtype
2096 *
2097 * Extremely similar to our previous example. Just a new struct in there, and
2098 * a pointer to a list in the one we already had. Handling a list of subtypes
2099 * is easy on our program, but now we'll see what Eet needs to work with them
2100 * (Hint: it's easy too).
2101 * @skip _my_conf_descriptor
2102 * @until _my_conf_sub_descriptor
2103 *
2104 * Since we have two structures now, it's only natural that we'll need two
2105 * descriptors. One for each, which will be defined exactly as before.
2106 * @skip static void
2107 * @until eddc
2108 * @skip EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET
2109 * @until _my_conf_sub_descriptor
2110 *
2111 * We create our descriptors, each for one type, and as before, we are going to
2112 * use a simple macro to set their contents, to save on typing.
2113 * @skip #define
2114 * @until EET_T_UCHAR
2115 *
2116 * So far, nothing new. We have our descriptors and we know already how to
2117 * save them separately. But what we want is to link them together, and even
2118 * more so, we want our main type to hold a list of more than one of the new
2119 * sub type. So how do we do that?
2120 *
2121 * Simple enough, we tell Eet that our main descriptor will hold a list, of
2122 * which each node will point to some type described by our new descriptor.
2123 * @skip EET_DATA_DESCRIPTOR_ADD_LIST
2124 * @until _my_conf_sub_descriptor
2125 *
2126 * And that's all. We are closing the function now so as to not leave dangling
2127 * curly braces, but there's nothing more to show in this example. Only other
2128 * additions are the necessary code to free our new data, but you can see it
2129 * in the full code listing.
2130 * @until }
2131 */
2132
2133/**
2134 * @page eet_data_file_descriptor Advanced use of Eet Data Descriptors
2135 *
2136 * A real life example is usually the best way to see how things are used,
2137 * but they also involve a lot more code than what needs to be shown, so
2138 * instead of going that way, we'll be borrowing some pieces from one in
2139 * the following example. It's been slightly modified from the original
2140 * source to show more of the varied ways in which Eet can handle our data.
2141 *
2142 * @ref eet-data-file_descriptor_01.c "This example" shows a cache of user
2143 * accounts and messages received, and it's a bit more interactive than
2144 * previous examples.
2145 *
2146 * Let's begin by looking at the structures we'll be using. First we have
2147 * one to define the messages the user receives and one for the one he posts.
2148 * Straight forward and nothing new here.
2149 * @dontinclude eet-data-file_descriptor_01.c
2150 * @skip typedef
2151 * @until My_Post
2152 *
2153 * One more to declare the account itself. This one will contain a list of
2154 * all messages received, and the posts we make ourselves will be kept in an
2155 * array. No special reason other than to show how to use arrays with Eet.
2156 * @until My_Account
2157 *
2158 * Finally, the main structure to hold our cache of accounts. We'll be looking
2159 * for these accounts by their names, so let's keep them in a hash, using
2160 * that name as the key.
2161 * @until My_Cache
2162 *
2163 * As explained before, we need one descriptor for each struct we want Eet
2164 * to handle, but this time we also want to keep around our Eet file and its
2165 * string dictionary. You will see why in a moment.
2166 * @skip Eet_Data_Descriptor
2167 * @until _my_post_descriptor
2168 * @skip Eet_File
2169 * @until Eet_Dictionary
2170 *
2171 * The differences begin now. They aren't much, but we'll be creating our
2172 * descriptors differently. Things can be added to our cache, but we won't
2173 * be modifying the current contents, so we can consider the data read from
2174 * it to be read-only, and thus allow Eet to save time and memory by not
2175 * duplicating thins unnecessary.
2176 * @skip static void
2177 * @until _my_post_descriptor
2178 *
2179 * As the comment in the code explains, we are asking Eet to give us strings
2180 * directly from the mapped file, which avoids having to load it in memory
2181 * and data duplication.
2182 * Of course, there are things to take into account when doing things this
2183 * way, and they will be mentioned as we encounter those special cases.
2184 *
2185 * Next comes the actual description of our data, just like we did in the
2186 * previous examples.
2187 * @skip #define
2188 * @until #undef
2189 * @until #define
2190 * @until #undef
2191 *
2192 * And the account struct's description doesn't add much new, but it's worth
2193 * commenting on it.
2194 * @skip #define
2195 * @until _my_post_descriptor
2196 *
2197 * How to add a list we've seen before, but now we are also adding an array.
2198 * There's nothing really special about it, but it's important to note that
2199 * the EET_DATA_DESCRIPTOR_ADD_VAR_ARRAY is used to add arrays of variable
2200 * length to a descriptor. That is, arrays just like the one we defined.
2201 * Since there's no way in C to know how long they are, we need to keep
2202 * track of the count ourselves and Eet needs to know how to do so as well.
2203 * That's what the @p posts_count member of our struct is for. When adding
2204 * our array member, this macro will look for another variable in the struct
2205 * named just like the array, but with @p _count attached to the end.
2206 * When saving our data, Eet will know how many elements the array contains
2207 * by looking into this count variable. When loading back from a file, this
2208 * variable will be set to the right number of elements.
2209 *
2210 * Another option for arrays is to use EET_DATA_DESCRIPTOR_ADD_ARRAY, which
2211 * takes care of fixed sized arrays.
2212 * For example, let's suppose that we want to keep track of only the last
2213 * ten posts the user sent, and we declare our account struct as follows
2214 * @code
2215 * typedef struct
2216 * {
2217 * unsigned int id;
2218 * const char *name;
2219 * Eina_List *messages;
2220 * My_Post posts[10];
2221 * } My_Account;
2222 * @endcode
2223 * Then we would add the array to our descriptor with
2224 * @code
2225 * EET_DATA_DESCRIPTOR_ADD_ARRAY(_my_account_descriptor, My_Account, "posts",
2226 * posts, _my_post_descriptor);
2227 * @endcode
2228 *
2229 * Notice how this time we don't have a @p posts_count variable in our struct.
2230 * We could have it for the program to keep track of how many posts the
2231 * array actually contains, but Eet no longer needs it. Being defined that
2232 * way the array is already taking up all the memory needed for the ten
2233 * elements, and it is possible in C to determine how much it is in code.
2234 * When saving our data, Eet will just dump the entire memory blob into the
2235 * file, regardless of how much of it is really used. So it's important to
2236 * take into consideration this kind of things when defining your data types.
2237 * Each has its uses, its advantages and disadvantages and it's up to you
2238 * to decide which to use.
2239 *
2240 * Now, going back to our example, we have to finish adding our data to the
2241 * descriptors. We are only missing the main one for the cache, which
2242 * contains our hash of accounts.
2243 * Unless you are using your own hash functions when setting the descriptor
2244 * class, always use hashes with string type keys.
2245 * @skip #define
2246 * @until }
2247 *
2248 * If you remember, we told Eet not to duplicate memory when possible at the
2249 * time of loading back our data. But this doesn't mean everything will be
2250 * loaded straight from disk and we don't have to worry about freeing it.
2251 * Data in the Eet file is compressed and encoded, so it still needs to be
2252 * decoded and memory will be allocated to convert it back into something we
2253 * can use. We also need to take care of anything we add in the current
2254 * instance of the program.
2255 * To summarize, any string we get from Eet is likely to be a pointer to the
2256 * internal dictionary, and trying to free it will, in the best case, crash
2257 * our application right away.
2258 *
2259 * So how do we know if we have to free a string? We check if it's part of
2260 * the dictionary, and if it's not there we can be sure it's safe to get
2261 * rid of it.
2262 * @skip static void
2263 * @skip }
2264 * @skip static void
2265 * @until }
2266 *
2267 * See how this is used when adding a new message to our cache.
2268 * @skip static My_Message
2269 * @until return msg
2270 * @until free(msg)
2271 * @until }
2272 *
2273 * Skipping all the utility functions used by our program (remember you can
2274 * look at the full example @ref eet-data-file_descriptor_01.c "here") we get to
2275 * our cache loading code. Nothing out of the ordinary at first, just the
2276 * same old open file, read data using our main descriptor to decode it
2277 * into something we can use and check version of loaded data and if it doesn't
2278 * match, do something accordingly.
2279 * @skip static My_Cache
2280 * @until }
2281 * @until }
2282 * @until }
2283 *
2284 * Then comes the interesting part. Remember how we kept two more global
2285 * variables with our descriptors? One of them we already used to check if
2286 * it was right to free a string or not, but we didn't know where it came from.
2287 * Loading our data straight from the mmapped file means that we can't close
2288 * it until we are done using it, so we need to keep its handler around until
2289 * then. It also means that any changes done to the file can, and will,
2290 * invalidate all our pointers to the file backed data, so if we add something
2291 * and save the file, we need to reload our cache.
2292 *
2293 * Thus our load function checks if we had an open file, if there is it gets
2294 * closed and our variable is updated to the new handler. Then we get the
2295 * string dictionary we use to check if a string is part of it or not.
2296 * Updating any references to the cache data is up you as a programmer to
2297 * handle properly, there's nothing Eet can do in this situation.
2298 * @until }
2299 *
2300 * The save function doesn't have anything new, and all that's left after it
2301 * is the main program, which doesn't really have anything of interest within
2302 * the scope of what we are learning.
2303 */
2304
2305/**
2306 * @addtogroup Eet_Data_Group
2307 * @{
2308 */
2309#define EET_T_UNKNOW 0 /**< Unknown data encoding type */
2310#define EET_T_CHAR 1 /**< Data type: char */
2311#define EET_T_SHORT 2 /**< Data type: short */
2312#define EET_T_INT 3 /**< Data type: int */
2313#define EET_T_LONG_LONG 4 /**< Data type: long long */
2314#define EET_T_FLOAT 5 /**< Data type: float */
2315#define EET_T_DOUBLE 6 /**< Data type: double */
2316#define EET_T_UCHAR 7 /**< Data type: unsigned char */
2317#define EET_T_USHORT 8 /**< Data type: unsigned short */
2318#define EET_T_UINT 9 /**< Data type: unsigned int */
2319#define EET_T_ULONG_LONG 10 /**< Data type: unsigned long long */
2320#define EET_T_STRING 11 /**< Data type: char * */
2321#define EET_T_INLINED_STRING 12 /**< Data type: char * (but compressed inside the resulting eet) */
2322#define EET_T_NULL 13 /**< Data type: (void *) (only use it if you know why) */
2323#define EET_T_F32P32 14 /**< Data type: fixed point 32.32 */
2324#define EET_T_F16P16 15 /**< Data type: fixed point 16.16 */
2325#define EET_T_F8P24 16 /**< Data type: fixed point 8.24 */
2326#define EET_T_LAST 18 /**< Last data type */
2327
2328#define EET_G_UNKNOWN 100 /**< Unknown group data encoding type */
2329#define EET_G_ARRAY 101 /**< Fixed size array group type */
2330#define EET_G_VAR_ARRAY 102 /**< Variable size array group type */
2331#define EET_G_LIST 103 /**< Linked list group type */
2332#define EET_G_HASH 104 /**< Hash table group type */
2333#define EET_G_UNION 105 /**< Union group type */
2334#define EET_G_VARIANT 106 /**< Selectable subtype group */
2335#define EET_G_LAST 107 /**< Last group type */
2336
2337#define EET_I_LIMIT 128 /**< Other type exist but are reserved for internal purpose. */
2338
2339/**
2340 * @typedef Eet_Data_Descriptor
2341 *
2342 * Opaque handle that have information on a type members.
2343 *
2344 * Descriptors are created using an #Eet_Data_Descriptor_Class, and they
2345 * describe the contents of the structure that will be serialized by Eet.
2346 * Not all members need be described by it, just those that should be handled
2347 * by Eet. This way it's possible to have one structure with both data to be
2348 * saved to a file, like application configuration, and runtime information
2349 * that would be meaningless to store, but is appropriate to keep together
2350 * during the program execution.
2351 * The members are added by means of
2352 * EET_DATA_DESCRIPTOR_ADD_BASIC(), EET_DATA_DESCRIPTOR_ADD_SUB(),
2353 * EET_DATA_DESCRIPTOR_ADD_LIST(), EET_DATA_DESCRIPTOR_ADD_HASH()
2354 * or eet_data_descriptor_element_add().
2355 *
2356 * @see eet_data_descriptor_stream_new()
2357 * @see eet_data_descriptor_file_new()
2358 * @see eet_data_descriptor_free()
2359 */
2360typedef struct _Eet_Data_Descriptor Eet_Data_Descriptor;
2361
2362/**
2363 * @def EET_DATA_DESCRIPTOR_CLASS_VERSION
2364 * The version of #Eet_Data_Descriptor_Class at the time of the
2365 * distribution of the sources. One should define this to its
2366 * version member so it is compatible with abi changes, or at least
2367 * will not crash with them.
2368 */
2369#define EET_DATA_DESCRIPTOR_CLASS_VERSION 4
2370
2371/**
2372 * @typedef Eet_Data_Descriptor_Class
2373 *
2374 * Instructs Eet about memory management for different needs under
2375 * serialization and parse process.
2376 */
2377typedef struct _Eet_Data_Descriptor_Class Eet_Data_Descriptor_Class;
2378
2379typedef int (*Eet_Descriptor_Hash_Foreach_Callback_Callback)(void *h, const char *k, void *dt, void *fdt);
2380
2381typedef void * (*Eet_Descriptor_Mem_Alloc_Callback)(size_t size);
2382typedef void (*Eet_Descriptor_Mem_Free_Callback)(void *mem);
2383typedef char * (*Eet_Descriptor_Str_Alloc_Callback)(const char *str);
2384typedef void (*Eet_Descriptor_Str_Free_Callback)(const char *str);
2385typedef void * (*Eet_Descriptor_List_Next_Callback)(void *l);
2386typedef void * (*Eet_Descriptor_List_Append_Callback)(void *l, void *d);
2387typedef void * (*Eet_Descriptor_List_Data_Callback)(void *l);
2388typedef void * (*Eet_Descriptor_List_Free_Callback)(void *l);
2389typedef void (*Eet_Descriptor_Hash_Foreach_Callback)(void *h, Eet_Descriptor_Hash_Foreach_Callback_Callback func, void *fdt);
2390typedef void * (*Eet_Descriptor_Hash_Add_Callback)(void *h, const char *k, void *d);
2391typedef void (*Eet_Descriptor_Hash_Free_Callback)(void *h);
2392typedef char * (*Eet_Descriptor_Str_Direct_Alloc_Callback)(const char *str);
2393typedef void (*Eet_Descriptor_Str_Direct_Free_Callback)(const char *str);
2394typedef const char * (*Eet_Descriptor_Type_Get_Callback)(const void *data, Eina_Bool *unknow);
2395typedef Eina_Bool (*Eet_Descriptor_Type_Set_Callback)(const char *type, void *data, Eina_Bool unknow);
2396typedef void * (*Eet_Descriptor_Array_Alloc_Callback)(size_t size);
2397typedef void (*Eet_Descriptor_Array_Free_Callback)(void *mem);
2398/**
2399 * @struct _Eet_Data_Descriptor_Class
2400 *
2401 * Instructs Eet about memory management for different needs under
2402 * serialization and parse process.
2403 *
2404 * The list and hash methods match the Eina API, so for a more detalied
2405 * reference on them, look at the Eina_List and Eina_Hash documentation,
2406 * respectively.
2407 * For the most part these will be used with the standard Eina functions,
2408 * so using EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET() and
2409 * EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET() will set up everything
2410 * accordingly.
2411 */
2412struct _Eet_Data_Descriptor_Class
2413{
2414 int version; /**< ABI version. Should always be set to #EET_DATA_DESCRIPTOR_CLASS_VERSION */
2415 const char *name; /**< Name of the user data type to be serialized */
2416 int size; /**< Size in bytes of the user data type to be serialized */
2417 struct
2418 {
2419 Eet_Descriptor_Mem_Alloc_Callback mem_alloc; /**< how to allocate memory (usually malloc()) */
2420 Eet_Descriptor_Mem_Free_Callback mem_free; /**< how to free memory (usually free()) */
2421 Eet_Descriptor_Str_Alloc_Callback str_alloc; /**< how to allocate a string */
2422 Eet_Descriptor_Str_Free_Callback str_free; /**< how to free a string */
2423 Eet_Descriptor_List_Next_Callback list_next; /**< how to iterate to the next element of a list. Receives and should return the list node. */
2424 Eet_Descriptor_List_Append_Callback list_append; /**< how to append data @p d to list which head node is @p l */
2425 Eet_Descriptor_List_Data_Callback list_data; /**< retrieves the data from node @p l */
2426 Eet_Descriptor_List_Free_Callback list_free; /**< free all the nodes from the list which head node is @p l */
2427 Eet_Descriptor_Hash_Foreach_Callback hash_foreach; /**< iterates over all elements in the hash @p h in no specific order */
2428 Eet_Descriptor_Hash_Add_Callback hash_add; /**< add a new data @p d with key @p k in hash @p h */
2429 Eet_Descriptor_Hash_Free_Callback hash_free; /**< free all entries from the hash @p h */
2430 Eet_Descriptor_Str_Direct_Alloc_Callback str_direct_alloc; /**< how to allocate a string directly from file backed/mmaped region pointed by @p str */
2431 Eet_Descriptor_Str_Direct_Free_Callback str_direct_free; /**< how to free a string returned by str_direct_alloc */
2432 Eet_Descriptor_Type_Get_Callback type_get; /**< get the type, as used in the union or variant mapping, that should be used to store the given data into the eet file. */
2433 Eet_Descriptor_Type_Set_Callback type_set; /**< called when loading a mapped type with the given @p type used to describe the type in the descriptor */
2434 Eet_Descriptor_Array_Alloc_Callback array_alloc; /**< how to allocate memory for array (usually malloc()) */
2435 Eet_Descriptor_Array_Free_Callback array_free; /**< how to free memory for array (usually free()) */
2436 } func;
2437};
2438
2439/**
2440 * @}
2441 */
2442
2443/**
2444 * Create a new empty data structure descriptor.
2445 * @param name The string name of this data structure (most be a
2446 * global constant and never change).
2447 * @param size The size of the struct (in bytes).
2448 * @param func_list_next The function to get the next list node.
2449 * @param func_list_append The function to append a member to a list.
2450 * @param func_list_data The function to get the data from a list node.
2451 * @param func_list_free The function to free an entire linked list.
2452 * @param func_hash_foreach The function to iterate through all
2453 * hash table entries.
2454 * @param func_hash_add The function to add a member to a hash table.
2455 * @param func_hash_free The function to free an entire hash table.
2456 * @return A new empty data descriptor.
2457 *
2458 * This function creates a new data descriptore and returns a handle to the
2459 * new data descriptor. On creation it will be empty, containing no contents
2460 * describing anything other than the shell of the data structure.
2461 *
2462 * You add structure members to the data descriptor using the macros
2463 * EET_DATA_DESCRIPTOR_ADD_BASIC(), EET_DATA_DESCRIPTOR_ADD_SUB() and
2464 * EET_DATA_DESCRIPTOR_ADD_LIST(), depending on what type of member you are
2465 * adding to the description.
2466 *
2467 * Once you have described all the members of a struct you want loaded, or
2468 * saved eet can load and save those members for you, encode them into
2469 * endian-independent serialised data chunks for transmission across a
2470 * a network or more.
2471 *
2472 * The function pointers to the list and hash table functions are only
2473 * needed if you use those data types, else you can pass NULL instead.
2474 *
2475 * @since 1.0.0
2476 * @ingroup Eet_Data_Group
2477 *
2478 * @deprecated use eet_data_descriptor_stream_new() or
2479 * eet_data_descriptor_file_new()
2480 */
2481EINA_DEPRECATED EAPI Eet_Data_Descriptor *
2482eet_data_descriptor_new(const char *name,
2483 int size,
2484 Eet_Descriptor_List_Next_Callback func_list_next,
2485 Eet_Descriptor_List_Append_Callback func_list_append,
2486 Eet_Descriptor_List_Data_Callback func_list_data,
2487 Eet_Descriptor_List_Free_Callback func_list_free,
2488 Eet_Descriptor_Hash_Foreach_Callback func_hash_foreach,
2489 Eet_Descriptor_Hash_Add_Callback func_hash_add,
2490 Eet_Descriptor_Hash_Free_Callback func_hash_free);
2491/*
2492 * FIXME:
2493 *
2494 * moving to this api from the old above. this will break things when the
2495 * move happens - but be warned
2496 */
2497EINA_DEPRECATED EAPI Eet_Data_Descriptor *
2498 eet_data_descriptor2_new(const Eet_Data_Descriptor_Class *eddc);
2499EINA_DEPRECATED EAPI Eet_Data_Descriptor *
2500 eet_data_descriptor3_new(const Eet_Data_Descriptor_Class *eddc);
2501
2502/**
2503 * This function creates a new data descriptor and returns a handle to the
2504 * new data descriptor. On creation it will be empty, containing no contents
2505 * describing anything other than the shell of the data structure.
2506 * @param eddc The class from where to create the data descriptor.
2507 *
2508 * You add structure members to the data descriptor using the macros
2509 * EET_DATA_DESCRIPTOR_ADD_BASIC(), EET_DATA_DESCRIPTOR_ADD_SUB() and
2510 * EET_DATA_DESCRIPTOR_ADD_LIST(), depending on what type of member you are
2511 * adding to the description.
2512 *
2513 * Once you have described all the members of a struct you want loaded or
2514 * savedi, eet can load and save those members for you, encode them into
2515 * endian-independent serialised data chunks for transmission across a
2516 * a network or more.
2517 *
2518 * This function specially ignores str_direct_alloc and str_direct_free. It
2519 * is useful when the eet_data you are reading doesn't have a dictionary,
2520 * like network stream or IPC. It also mean that all string will be allocated
2521 * and duplicated in memory.
2522 *
2523 * @since 1.2.3
2524 * @ingroup Eet_Data_Group
2525 */
2526EAPI Eet_Data_Descriptor *
2527eet_data_descriptor_stream_new(const Eet_Data_Descriptor_Class *eddc);
2528
2529/**
2530 * This function creates a new data descriptor and returns a handle to the
2531 * new data descriptor. On creation it will be empty, containing no contents
2532 * describing anything other than the shell of the data structure.
2533 * @param eddc The class from where to create the data descriptor.
2534 *
2535 * You add structure members to the data descriptor using the macros
2536 * EET_DATA_DESCRIPTOR_ADD_BASIC(), EET_DATA_DESCRIPTOR_ADD_SUB() and
2537 * EET_DATA_DESCRIPTOR_ADD_LIST(), depending on what type of member you are
2538 * adding to the description.
2539 *
2540 * Once you have described all the members of a struct you want loaded or
2541 * savedi, eet can load and save those members for you, encode them into
2542 * endian-independent serialised data chunks for transmission across a
2543 * a network or more.
2544 *
2545 * This function uses str_direct_alloc and str_direct_free. It is
2546 * useful when the eet_data you are reading come from a file and
2547 * have a dictionary. This will reduce memory use and improve the
2548 * possibility for the OS to page this string out.
2549 * However, the load speed and memory saving comes with some drawbacks to keep
2550 * in mind. If you never modify the contents of the structures loaded from
2551 * the file, all you need to remember is that closing the eet file will make
2552 * the strings go away. On the other hand, should you need to free a string,
2553 * before doing so you have to verify that it's not part of the eet dictionary.
2554 * You can do this in the following way, assuming @p ef is a valid Eet_File
2555 * and @p str is a string loaded from said file.
2556 *
2557 * @code
2558 * void eet_string_free(Eet_File *ef, const char *str)
2559 * {
2560 * Eet_Dictionary *dict = eet_dictionary_get(ef);
2561 * if (dict && eet_dictionary_string_check(dict, str))
2562 * {
2563 * // The file contains a dictionary and the given string is a part of
2564 * // of it, so we can't free it, just return.
2565 * return;
2566 * }
2567 * // We assume eina_stringshare was used on the descriptor
2568 * eina_stringshare_del(str);
2569 * }
2570 * @endcode
2571 *
2572 * @since 1.2.3
2573 * @ingroup Eet_Data_Group
2574 */
2575EAPI Eet_Data_Descriptor *
2576eet_data_descriptor_file_new(const Eet_Data_Descriptor_Class *eddc);
2577
2578/**
2579 * This function is an helper that set all the parameters of an
2580 * Eet_Data_Descriptor_Class correctly when you use Eina data type
2581 * with a stream.
2582 * @param eddc The Eet_Data_Descriptor_Class you want to set.
2583 * @param eddc_size The size of the Eet_Data_Descriptor_Class at the compilation time.
2584 * @param name The name of the structure described by this class.
2585 * @param size The size of the structure described by this class.
2586 * @return EINA_TRUE if the structure was correctly set (The only
2587 * reason that could make it fail is if you did give wrong
2588 * parameter).
2589 *
2590 * @note Unless there's a very specific reason to use this function directly,
2591 * the EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET macro is recommended.
2592 *
2593 * @since 1.2.3
2594 * @ingroup Eet_Data_Group
2595 */
2596EAPI Eina_Bool
2597eet_eina_stream_data_descriptor_class_set(Eet_Data_Descriptor_Class *eddc,
2598 unsigned int eddc_size,
2599 const char *name,
2600 int size);
2601
2602/**
2603 * This macro is an helper that set all the parameter of an
2604 * Eet_Data_Descriptor_Class correctly when you use Eina data type
2605 * with stream.
2606 * @param clas The Eet_Data_Descriptor_Class you want to set.
2607 * @param type The type of the structure described by this class.
2608 * @return EINA_TRUE if the structure was correctly set (The only
2609 * reason that could make it fail is if you did give wrong
2610 * parameter).
2611 *
2612 * @see eet_data_descriptor_stream_new
2613 * @since 1.2.3
2614 * @ingroup Eet_Data_Group
2615 */
2616#define EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(clas, type) \
2617 (eet_eina_stream_data_descriptor_class_set(clas, sizeof (*(clas)), # type, sizeof(type)))
2618
2619/**
2620 * This function is an helper that set all the parameter of an
2621 * Eet_Data_Descriptor_Class correctly when you use Eina data type
2622 * with a file.
2623 * @param eddc The Eet_Data_Descriptor_Class you want to set.
2624 * @param eddc_size The size of the Eet_Data_Descriptor_Class at the compilation time.
2625 * @param name The name of the structure described by this class.
2626 * @param size The size of the structure described by this class.
2627 * @return EINA_TRUE if the structure was correctly set (The only
2628 * reason that could make it fail is if you did give wrong
2629 * parameter).
2630 *
2631 * @note Unless there's a very specific reason to use this function directly,
2632 * the EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET macro is recommended.
2633 *
2634 * @since 1.2.3
2635 * @ingroup Eet_Data_Group
2636 */
2637EAPI Eina_Bool
2638eet_eina_file_data_descriptor_class_set(Eet_Data_Descriptor_Class *eddc,
2639 unsigned int eddc_size,
2640 const char *name,
2641 int size);
2642
2643/**
2644 * This macro is an helper that set all the parameter of an
2645 * Eet_Data_Descriptor_Class correctly when you use Eina data type
2646 * with file.
2647 * @param clas The Eet_Data_Descriptor_Class you want to set.
2648 * @param type The type of the structure described by this class.
2649 * @return EINA_TRUE if the structure was correctly set (The only
2650 * reason that could make it fail is if you did give wrong
2651 * parameter).
2652 *
2653 * @see eet_data_descriptor_file_new
2654 * @since 1.2.3
2655 * @ingroup Eet_Data_Group
2656 */
2657#define EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(clas, type) \
2658 (eet_eina_file_data_descriptor_class_set(clas, sizeof (*(clas)), # type, sizeof(type)))
2659
2660/**
2661 * This function frees a data descriptor when it is not needed anymore.
2662 * @param edd The data descriptor to free.
2663 *
2664 * This function takes a data descriptor handle as a parameter and frees all
2665 * data allocated for the data descriptor and the handle itself. After this
2666 * call the descriptor is no longer valid.
2667 *
2668 * @since 1.0.0
2669 * @ingroup Eet_Data_Group
2670 */
2671EAPI void
2672eet_data_descriptor_free(Eet_Data_Descriptor *edd);
2673
2674/**
2675 * This function is an internal used by macros.
2676 *
2677 * This function is used by macros EET_DATA_DESCRIPTOR_ADD_BASIC(),
2678 * EET_DATA_DESCRIPTOR_ADD_SUB() and EET_DATA_DESCRIPTOR_ADD_LIST(). It is
2679 * complex to use by hand and should be left to be used by the macros, and
2680 * thus is not documented.
2681 *
2682 * @param edd The data descriptor handle to add element (member).
2683 * @param name The name of element to be serialized.
2684 * @param type The type of element to be serialized, like
2685 * #EET_T_INT. If #EET_T_UNKNOW, then it is considered to be a
2686 * group, list or hash.
2687 * @param group_type If element type is #EET_T_UNKNOW, then the @p
2688 * group_type will speficy if it is a list (#EET_G_LIST),
2689 * array (#EET_G_ARRAY) and so on. If #EET_G_UNKNOWN, then
2690 * the member is a subtype (pointer to another type defined by
2691 * another #Eet_Data_Descriptor).
2692 * @param offset byte offset inside the source memory to be serialized.
2693 * @param count number of elements (if #EET_G_ARRAY or #EET_G_VAR_ARRAY).
2694 * @param counter_name variable that defines the name of number of elements.
2695 * @param subtype If contains a subtype, then its data descriptor.
2696 *
2697 * @since 1.0.0
2698 * @ingroup Eet_Data_Group
2699 */
2700EAPI void
2701eet_data_descriptor_element_add(Eet_Data_Descriptor *edd,
2702 const char *name,
2703 int type,
2704 int group_type,
2705 int offset,
2706 /* int count_offset, */
2707 int count,
2708 const char *counter_name,
2709 Eet_Data_Descriptor *subtype);
2710
2711/**
2712 * Read a data structure from an eet file and decodes it.
2713 * @param ef The eet file handle to read from.
2714 * @param edd The data descriptor handle to use when decoding.
2715 * @param name The key the data is stored under in the eet file.
2716 * @return A pointer to the decoded data structure.
2717 *
2718 * This function decodes a data structure stored in an eet file, returning
2719 * a pointer to it if it decoded successfully, or NULL on failure. This
2720 * can save a programmer dozens of hours of work in writing configuration
2721 * file parsing and writing code, as eet does all that work for the program
2722 * and presents a program-friendly data structure, just as the programmer
2723 * likes. Eet can handle members being added or deleted from the data in
2724 * storage and safely zero-fills unfilled members if they were not found
2725 * in the data. It checks sizes and headers whenever it reads data, allowing
2726 * the programmer to not worry about corrupt data.
2727 *
2728 * Once a data structure has been described by the programmer with the
2729 * fields they wish to save or load, storing or retrieving a data structure
2730 * from an eet file, or from a chunk of memory is as simple as a single
2731 * function call.
2732 *
2733 * @see eet_data_read_cipher()
2734 *
2735 * @since 1.0.0
2736 * @ingroup Eet_Data_Group
2737 */
2738EAPI void *
2739eet_data_read(Eet_File *ef,
2740 Eet_Data_Descriptor *edd,
2741 const char *name);
2742
2743/**
2744 * Write a data structure from memory and store in an eet file.
2745 * @param ef The eet file handle to write to.
2746 * @param edd The data descriptor to use when encoding.
2747 * @param name The key to store the data under in the eet file.
2748 * @param data A pointer to the data structure to ssave and encode.
2749 * @param compress Compression flags for storage.
2750 * @return bytes written on successful write, 0 on failure.
2751 *
2752 * This function is the reverse of eet_data_read(), saving a data structure
2753 * to an eet file. The file must have been opening in write mode and the data
2754 * will be kept in memory until the file is either closed or eet_sync() is
2755 * called to flush any unwritten changes.
2756 *
2757 * @see eet_data_write_cipher()
2758 *
2759 * @since 1.0.0
2760 * @ingroup Eet_Data_Group
2761 */
2762EAPI int
2763eet_data_write(Eet_File *ef,
2764 Eet_Data_Descriptor *edd,
2765 const char *name,
2766 const void *data,
2767 int compress);
2768
2769typedef void (*Eet_Dump_Callback)(void *data, const char *str);
2770
2771/**
2772 * Dump an eet encoded data structure into ascii text
2773 * @param data_in The pointer to the data to decode into a struct.
2774 * @param size_in The size of the data pointed to in bytes.
2775 * @param dumpfunc The function to call passed a string when new
2776 * data is converted to text
2777 * @param dumpdata The data to pass to the @p dumpfunc callback.
2778 * @return 1 on success, 0 on failure
2779 *
2780 * This function will take a chunk of data encoded by
2781 * eet_data_descriptor_encode() and convert it into human readable
2782 * ascii text. It does this by calling the @p dumpfunc callback
2783 * for all new text that is generated. This callback should append
2784 * to any existing text buffer and will be passed the pointer @p
2785 * dumpdata as a parameter as well as a string with new text to be
2786 * appended.
2787 *
2788 * Example:
2789 *
2790 * @code
2791 * void output(void *data, const char *string)
2792 * {
2793 * printf("%s", string);
2794 * }
2795 *
2796 * void dump(const char *file)
2797 * {
2798 * FILE *f;
2799 * int len;
2800 * void *data;
2801 *
2802 * f = fopen(file, "r");
2803 * fseek(f, 0, SEEK_END);
2804 * len = ftell(f);
2805 * rewind(f);
2806 * data = malloc(len);
2807 * fread(data, len, 1, f);
2808 * fclose(f);
2809 * eet_data_text_dump(data, len, output, NULL);
2810 * }
2811 * @endcode
2812 *
2813 * @see eet_data_text_dump_cipher()
2814 *
2815 * @since 1.0.0
2816 * @ingroup Eet_Data_Group
2817 */
2818EAPI int
2819eet_data_text_dump(const void *data_in,
2820 int size_in,
2821 Eet_Dump_Callback dumpfunc,
2822 void *dumpdata);
2823
2824/**
2825 * Take an ascii encoding from eet_data_text_dump() and re-encode in binary.
2826 * @param text The pointer to the string data to parse and encode.
2827 * @param textlen The size of the string in bytes (not including 0
2828 * byte terminator).
2829 * @param size_ret This gets filled in with the encoded data blob
2830 * size in bytes.
2831 * @return The encoded data on success, NULL on failure.
2832 *
2833 * This function will parse the string pointed to by @p text and return
2834 * an encoded data lump the same way eet_data_descriptor_encode() takes an
2835 * in-memory data struct and encodes into a binary blob. @p text is a normal
2836 * C string.
2837 *
2838 * @see eet_data_text_undump_cipher()
2839 *
2840 * @since 1.0.0
2841 * @ingroup Eet_Data_Group
2842 */
2843EAPI void *
2844eet_data_text_undump(const char *text,
2845 int textlen,
2846 int *size_ret);
2847
2848/**
2849 * Dump an eet encoded data structure from an eet file into ascii text
2850 * @param ef A valid eet file handle.
2851 * @param name Name of the entry. eg: "/base/file_i_want".
2852 * @param dumpfunc The function to call passed a string when new
2853 * data is converted to text
2854 * @param dumpdata The data to pass to the @p dumpfunc callback.
2855 * @return 1 on success, 0 on failure
2856 *
2857 * This function will take an open and valid eet file from
2858 * eet_open() request the data encoded by
2859 * eet_data_descriptor_encode() corresponding to the key @p name
2860 * and convert it into human readable ascii text. It does this by
2861 * calling the @p dumpfunc callback for all new text that is
2862 * generated. This callback should append to any existing text
2863 * buffer and will be passed the pointer @p dumpdata as a parameter
2864 * as well as a string with new text to be appended.
2865 *
2866 * @see eet_data_dump_cipher()
2867 *
2868 * @since 1.0.0
2869 * @ingroup Eet_Data_Group
2870 */
2871EAPI int
2872eet_data_dump(Eet_File *ef,
2873 const char *name,
2874 Eet_Dump_Callback dumpfunc,
2875 void *dumpdata);
2876
2877/**
2878 * Take an ascii encoding from eet_data_dump() and re-encode in binary.
2879 * @param ef A valid eet file handle.
2880 * @param name Name of the entry. eg: "/base/file_i_want".
2881 * @param text The pointer to the string data to parse and encode.
2882 * @param textlen The size of the string in bytes (not including 0
2883 * byte terminator).
2884 * @param compress Compression flags (1 == compress, 0 = don't compress).
2885 * @return 1 on success, 0 on failure
2886 *
2887 * This function will parse the string pointed to by @p text,
2888 * encode it the same way eet_data_descriptor_encode() takes an
2889 * in-memory data struct and encodes into a binary blob.
2890 *
2891 * The data (optionally compressed) will be in ram, pending a flush to
2892 * disk (it will stay in ram till the eet file handle is closed though).
2893 *
2894 * @see eet_data_undump_cipher()
2895 *
2896 * @since 1.0.0
2897 * @ingroup Eet_Data_Group
2898 */
2899EAPI int
2900eet_data_undump(Eet_File *ef,
2901 const char *name,
2902 const char *text,
2903 int textlen,
2904 int compress);
2905
2906/**
2907 * Decode a data structure from an arbitrary location in memory.
2908 * @param edd The data descriptor to use when decoding.
2909 * @param data_in The pointer to the data to decode into a struct.
2910 * @param size_in The size of the data pointed to in bytes.
2911 * @return NULL on failure, or a valid decoded struct pointer on success.
2912 *
2913 * This function will decode a data structure that has been encoded using
2914 * eet_data_descriptor_encode(), and return a data structure with all its
2915 * elements filled out, if successful, or NULL on failure.
2916 *
2917 * The data to be decoded is stored at the memory pointed to by @p data_in,
2918 * and is described by the descriptor pointed to by @p edd. The data size is
2919 * passed in as the value to @p size_in, ande must be greater than 0 to
2920 * succeed.
2921 *
2922 * This function is useful for decoding data structures delivered to the
2923 * application by means other than an eet file, such as an IPC or socket
2924 * connection, raw files, shared memory etc.
2925 *
2926 * Please see eet_data_read() for more information.
2927 *
2928 * @see eet_data_descriptor_decode_cipher()
2929 *
2930 * @since 1.0.0
2931 * @ingroup Eet_Data_Group
2932 */
2933EAPI void *
2934eet_data_descriptor_decode(Eet_Data_Descriptor *edd,
2935 const void *data_in,
2936 int size_in);
2937
2938/**
2939 * Encode a dsata struct to memory and return that encoded data.
2940 * @param edd The data descriptor to use when encoding.
2941 * @param data_in The pointer to the struct to encode into data.
2942 * @param size_ret pointer to the an int to be filled with the decoded size.
2943 * @return NULL on failure, or a valid encoded data chunk on success.
2944 *
2945 * This function takes a data structutre in memory and encodes it into a
2946 * serialised chunk of data that can be decoded again by
2947 * eet_data_descriptor_decode(). This is useful for being able to transmit
2948 * data structures across sockets, pipes, IPC or shared file mechanisms,
2949 * without having to worry about memory space, machine type, endianess etc.
2950 *
2951 * The parameter @p edd must point to a valid data descriptor, and
2952 * @p data_in must point to the right data structure to encode. If not, the
2953 * encoding may fail.
2954 *
2955 * On success a non NULL valid pointer is returned and what @p size_ret
2956 * points to is set to the size of this decoded data, in bytes. When the
2957 * encoded data is no longer needed, call free() on it. On failure NULL is
2958 * returned and what @p size_ret points to is set to 0.
2959 *
2960 * Please see eet_data_write() for more information.
2961 *
2962 * @see eet_data_descriptor_encode_cipher()
2963 *
2964 * @since 1.0.0
2965 * @ingroup Eet_Data_Group
2966 */
2967EAPI void *
2968eet_data_descriptor_encode(Eet_Data_Descriptor *edd,
2969 const void *data_in,
2970 int *size_ret);
2971
2972/**
2973 * Add a basic data element to a data descriptor.
2974 * @param edd The data descriptor to add the type to.
2975 * @param struct_type The type of the struct.
2976 * @param name The string name to use to encode/decode this member
2977 * (must be a constant global and never change).
2978 * @param member The struct member itself to be encoded.
2979 * @param type The type of the member to encode.
2980 *
2981 * This macro is a convenience macro provided to add a member to
2982 * the data descriptor @p edd. The type of the structure is
2983 * provided as the @p struct_type parameter (for example: struct
2984 * my_struct). The @p name parameter defines a string that will be
2985 * used to uniquely name that member of the struct (it is suggested
2986 * to use the struct member itself). The @p member parameter is
2987 * the actual struct member itself (for example: values), and @p type is the
2988 * basic data type of the member which must be one of: EET_T_CHAR, EET_T_SHORT,
2989 * EET_T_INT, EET_T_LONG_LONG, EET_T_FLOAT, EET_T_DOUBLE, EET_T_UCHAR,
2990 * EET_T_USHORT, EET_T_UINT, EET_T_ULONG_LONG or EET_T_STRING.
2991 *
2992 * @since 1.0.0
2993 * @ingroup Eet_Data_Group
2994 */
2995#define EET_DATA_DESCRIPTOR_ADD_BASIC(edd, struct_type, name, member, type) \
2996 do { \
2997 struct_type ___ett; \
2998 eet_data_descriptor_element_add(edd, name, type, EET_G_UNKNOWN, \
2999 (char *)(& (___ett.member)) - \
3000 (char *)(& (___ett)), \
3001 0, /* 0, */ NULL, NULL); \
3002 } while(0)
3003
3004/**
3005 * Add a sub-element type to a data descriptor
3006 * @param edd The data descriptor to add the type to.
3007 * @param struct_type The type of the struct.
3008 * @param name The string name to use to encode/decode this member
3009 * (must be a constant global and never change).
3010 * @param member The struct member itself to be encoded.
3011 * @param subtype The type of sub-type struct to add.
3012 *
3013 * This macro lets you easily add a sub-type (a struct that's pointed to
3014 * by this one). All the parameters are the same as for
3015 * EET_DATA_DESCRIPTOR_ADD_BASIC(), with the @p subtype being the exception.
3016 * This must be the data descriptor of the struct that is pointed to by
3017 * this element.
3018 *
3019 * @since 1.0.0
3020 * @ingroup Eet_Data_Group
3021 */
3022#define EET_DATA_DESCRIPTOR_ADD_SUB(edd, struct_type, name, member, subtype) \
3023 do { \
3024 struct_type ___ett; \
3025 eet_data_descriptor_element_add(edd, name, EET_T_UNKNOW, EET_G_UNKNOWN, \
3026 (char *)(& (___ett.member)) - \
3027 (char *)(& (___ett)), \
3028 0, /* 0, */ NULL, subtype); \
3029 } while (0)
3030
3031/**
3032 * Add a linked list type to a data descriptor
3033 * @param edd The data descriptor to add the type to.
3034 * @param struct_type The type of the struct.
3035 * @param name The string name to use to encode/decode this member
3036 * (must be a constant global and never change).
3037 * @param member The struct member itself to be encoded.
3038 * @param subtype The type of linked list member to add.
3039 *
3040 * This macro lets you easily add a linked list of other data types. All the
3041 * parameters are the same as for EET_DATA_DESCRIPTOR_ADD_BASIC(), with the
3042 * @p subtype being the exception. This must be the data descriptor of the
3043 * element that is in each member of the linked list to be stored.
3044 *
3045 * @since 1.0.0
3046 * @ingroup Eet_Data_Group
3047 */
3048#define EET_DATA_DESCRIPTOR_ADD_LIST(edd, struct_type, name, member, subtype) \
3049 do { \
3050 struct_type ___ett; \
3051 eet_data_descriptor_element_add(edd, name, EET_T_UNKNOW, EET_G_LIST, \
3052 (char *)(& (___ett.member)) - \
3053 (char *)(& (___ett)), \
3054 0, /* 0, */ NULL, subtype); \
3055 } while (0)
3056
3057/**
3058 * Add a linked list of string to a data descriptor
3059 * @param edd The data descriptor to add the type to.
3060 * @param struct_type The type of the struct.
3061 * @param name The string name to use to encode/decode this member
3062 * (must be a constant global and never change).
3063 * @param member The struct member itself to be encoded.
3064 *
3065 * This macro lets you easily add a linked list of char *. All the
3066 * parameters are the same as for EET_DATA_DESCRIPTOR_ADD_BASIC().
3067 *
3068 * @since 1.5.0
3069 * @ingroup Eet_Data_Group
3070 */
3071#define EET_DATA_DESCRIPTOR_ADD_LIST_STRING(edd, struct_type, name, member) \
3072 do { \
3073 struct_type ___ett; \
3074 eet_data_descriptor_element_add(edd, name, EET_T_STRING, EET_G_LIST, \
3075 (char *)(& (___ett.member)) - \
3076 (char *)(& (___ett)), \
3077 0, /* 0, */ NULL, NULL); \
3078 } while (0)
3079
3080/**
3081 * Add a hash type to a data descriptor
3082 * @param edd The data descriptor to add the type to.
3083 * @param struct_type The type of the struct.
3084 * @param name The string name to use to encode/decode this member
3085 * (must be a constant global and never change).
3086 * @param member The struct member itself to be encoded.
3087 * @param subtype The type of hash member to add.
3088 *
3089 * This macro lets you easily add a hash of other data types. All the
3090 * parameters are the same as for EET_DATA_DESCRIPTOR_ADD_BASIC(), with the
3091 * @p subtype being the exception. This must be the data descriptor of the
3092 * element that is in each member of the hash to be stored.
3093 * The hash keys must be strings.
3094 *
3095 * @since 1.0.0
3096 * @ingroup Eet_Data_Group
3097 */
3098#define EET_DATA_DESCRIPTOR_ADD_HASH(edd, struct_type, name, member, subtype) \
3099 do { \
3100 struct_type ___ett; \
3101 eet_data_descriptor_element_add(edd, name, EET_T_UNKNOW, EET_G_HASH, \
3102 (char *)(& (___ett.member)) - \
3103 (char *)(& (___ett)), \
3104 0, /* 0, */ NULL, subtype); \
3105 } while (0)
3106
3107/**
3108 * Add a hash of string to a data descriptor
3109 * @param edd The data descriptor to add the type to.
3110 * @param struct_type The type of the struct.
3111 * @param name The string name to use to encode/decode this member
3112 * (must be a constant global and never change).
3113 * @param member The struct member itself to be encoded.
3114 *
3115 * This macro lets you easily add a hash of string elements. All the
3116 * parameters are the same as for EET_DATA_DESCRIPTOR_ADD_HASH().
3117 *
3118 * @since 1.3.4
3119 * @ingroup Eet_Data_Group
3120 */
3121#define EET_DATA_DESCRIPTOR_ADD_HASH_STRING(edd, struct_type, name, member) \
3122 do { \
3123 struct_type ___ett; \
3124 eet_data_descriptor_element_add(edd, name, EET_T_STRING, EET_G_HASH, \
3125 (char *)(& (___ett.member)) - \
3126 (char *)(& (___ett)), \
3127 0, /* 0, */ NULL, NULL); \
3128 } while (0)
3129
3130/**
3131 * Add an array of basic data elements to a data descriptor.
3132 * @param edd The data descriptor to add the type to.
3133 * @param struct_type The type of the struct.
3134 * @param name The string name to use to encode/decode this member
3135 * (must be a constant global and never change).
3136 * @param member The struct member itself to be encoded.
3137 * @param type The type of the member to encode.
3138 *
3139 * This macro lets you easily add a fixed size array of basic data
3140 * types. All the parameters are the same as for
3141 * EET_DATA_DESCRIPTOR_ADD_BASIC().
3142 * The array must be defined with a fixed size in the declaration of the
3143 * struct containing it.
3144 *
3145 * @since 1.5.0
3146 * @ingroup Eet_Data_Group
3147 */
3148#define EET_DATA_DESCRIPTOR_ADD_BASIC_ARRAY(edd, struct_type, name, member, type) \
3149 do { \
3150 struct_type ___ett; \
3151 eet_data_descriptor_element_add(edd, name, type, EET_G_ARRAY, \
3152 (char *)(& (___ett.member)) - \
3153 (char *)(& (___ett)), \
3154 sizeof(___ett.member) / \
3155 sizeof(___ett.member[0]), \
3156 NULL, NULL); \
3157 } while(0)
3158
3159/**
3160 * Add a fixed size array type to a data descriptor
3161 * @param edd The data descriptor to add the type to.
3162 * @param struct_type The type of the struct.
3163 * @param name The string name to use to encode/decode this member
3164 * (must be a constant global and never change).
3165 * @param member The struct member itself to be encoded.
3166 * @param subtype The type of hash member to add.
3167 *
3168 * This macro lets you easily add a fixed size array of other data
3169 * types. All the parameters are the same as for
3170 * EET_DATA_DESCRIPTOR_ADD_BASIC(), with the @p subtype being the
3171 * exception. This must be the data descriptor of the element that
3172 * is in each member of the array to be stored.
3173 * The array must be defined with a fixed size in the declaration of the
3174 * struct containing it.
3175 *
3176 * @since 1.0.2
3177 * @ingroup Eet_Data_Group
3178 */
3179#define EET_DATA_DESCRIPTOR_ADD_ARRAY(edd, struct_type, name, member, subtype) \
3180 do { \
3181 struct_type ___ett; \
3182 eet_data_descriptor_element_add(edd, name, EET_T_UNKNOW, EET_G_ARRAY, \
3183 (char *)(& (___ett.member)) - \
3184 (char *)(& (___ett)), \
3185 /* 0, */ sizeof(___ett.member) / \
3186 sizeof(___ett.member[0]), NULL, subtype); \
3187 } while (0)
3188
3189/**
3190 * Add a variable size array type to a data descriptor
3191 * @param edd The data descriptor to add the type to.
3192 * @param struct_type The type of the struct.
3193 * @param name The string name to use to encode/decode this member
3194 * (must be a constant global and never change).
3195 * @param member The struct member itself to be encoded.
3196 * @param subtype The type of hash member to add.
3197 *
3198 * This macro lets you easily add a variable size array of other data
3199 * types. All the parameters are the same as for
3200 * EET_DATA_DESCRIPTOR_ADD_BASIC(), with the @p subtype being the
3201 * exception. This must be the data descriptor of the element that
3202 * is in each member of the array to be stored. This assumes you have
3203 * a struct member (of type EET_T_INT) called member_count (note the
3204 * _count appended to the member) that holds the number of items in
3205 * the array. This array will be allocated separately to the struct it
3206 * is in.
3207 *
3208 * @since 1.0.2
3209 * @ingroup Eet_Data_Group
3210 */
3211#define EET_DATA_DESCRIPTOR_ADD_VAR_ARRAY(edd, struct_type, name, member, subtype) \
3212 do { \
3213 struct_type ___ett; \
3214 eet_data_descriptor_element_add(edd, \
3215 name, \
3216 EET_T_UNKNOW, \
3217 EET_G_VAR_ARRAY, \
3218 (char *)(& (___ett.member)) - \
3219 (char *)(& (___ett)), \
3220 (char *)(& (___ett.member ## _count)) - \
3221 (char *)(& (___ett)), \
3222 /* 0, */ NULL, \
3223 subtype); \
3224 } while (0)
3225
3226/**
3227 * Add a variable size array type to a data descriptor
3228 * @param edd The data descriptor to add the type to.
3229 * @param struct_type The type of the struct.
3230 * @param name The string name to use to encode/decode this member
3231 * (must be a constant global and never change).
3232 * @param member The struct member itself to be encoded.
3233 *
3234 * This macro lets you easily add a variable size array of strings. All
3235 * the parameters are the same as for EET_DATA_DESCRIPTOR_ADD_BASIC().
3236 *
3237 * @since 1.4.0
3238 * @ingroup Eet_Data_Group
3239 */
3240#define EET_DATA_DESCRIPTOR_ADD_VAR_ARRAY_STRING(edd, struct_type, name, member) \
3241 do { \
3242 struct_type ___ett; \
3243 eet_data_descriptor_element_add(edd, \
3244 name, \
3245 EET_T_STRING, \
3246 EET_G_VAR_ARRAY, \
3247 (char *)(& (___ett.member)) - \
3248 (char *)(& (___ett)), \
3249 (char *)(& (___ett.member ## _count)) - \
3250 (char *)(& (___ett)), \
3251 /* 0, */ NULL, \
3252 NULL); \
3253 } while (0)
3254
3255/**
3256 * Add an union type to a data descriptor
3257 * @param edd The data descriptor to add the type to.
3258 * @param struct_type The type of the struct.
3259 * @param name The string name to use to encode/decode this member
3260 * (must be a constant global and never change).
3261 * @param member The struct member itself to be encoded.
3262 * @param type_member The member that give hints on what is in the union.
3263 * @param unified_type Describe all possible type the union could handle.
3264 *
3265 * This macro lets you easily add an union with a member that specify what is inside.
3266 * The @p unified_type is an Eet_Data_Descriptor, but only the entry that match the name
3267 * returned by type_get will be used for each serialized data. The type_get and type_set
3268 * callback of unified_type should be defined.
3269 *
3270 * @since 1.2.4
3271 * @ingroup Eet_Data_Group
3272 * @see Eet_Data_Descriptor_Class
3273 */
3274#define EET_DATA_DESCRIPTOR_ADD_UNION(edd, struct_type, name, member, type_member, unified_type) \
3275 do { \
3276 struct_type ___ett; \
3277 eet_data_descriptor_element_add(edd, name, EET_T_UNKNOW, EET_G_UNION, \
3278 (char *)(& (___ett.member)) - \
3279 (char *)(& (___ett)), \
3280 (char *)(& (___ett.type_member)) - \
3281 (char *)(& (___ett)), \
3282 NULL, unified_type); \
3283 } while (0)
3284
3285/**
3286 * Add a automatically selectable type to a data descriptor
3287 * @param edd The data descriptor to add the type to.
3288 * @param struct_type The type of the struct.
3289 * @param name The string name to use to encode/decode this member
3290 * (must be a constant global and never change).
3291 * @param member The struct member itself to be encoded.
3292 * @param type_member The member that give hints on what is in the union.
3293 * @param unified_type Describe all possible type the union could handle.
3294 *
3295 * This macro lets you easily define what the content of @p member points to depending of
3296 * the content of @p type_member. The type_get and type_set callback of unified_type should
3297 * be defined. If the the type is not know at the time of restoring it, eet will still call
3298 * type_set of @p unified_type but the pointer will be set to a serialized binary representation
3299 * of what eet know. This make it possible, to save this pointer again by just returning the string
3300 * given previously and telling it by setting unknow to EINA_TRUE.
3301 *
3302 * @since 1.2.4
3303 * @ingroup Eet_Data_Group
3304 * @see Eet_Data_Descriptor_Class
3305 */
3306#define EET_DATA_DESCRIPTOR_ADD_VARIANT(edd, struct_type, name, member, type_member, unified_type) \
3307 do { \
3308 struct_type ___ett; \
3309 eet_data_descriptor_element_add(edd, name, EET_T_UNKNOW, EET_G_VARIANT, \
3310 (char *)(& (___ett.member)) - \
3311 (char *)(& (___ett)), \
3312 (char *)(& (___ett.type_member)) - \
3313 (char *)(& (___ett)), \
3314 NULL, unified_type); \
3315 } while (0)
3316
3317/**
3318 * Add a mapping to a data descriptor that will be used by union, variant or inherited type
3319 * @param unified_type The data descriptor to add the mapping to.
3320 * @param name The string name to get/set type.
3321 * @param subtype The matching data descriptor.
3322 *
3323 * @since 1.2.4
3324 * @ingroup Eet_Data_Group
3325 * @see Eet_Data_Descriptor_Class
3326 */
3327#define EET_DATA_DESCRIPTOR_ADD_MAPPING(unified_type, name, subtype) \
3328 eet_data_descriptor_element_add(unified_type, \
3329 name, \
3330 EET_T_UNKNOW, \
3331 EET_G_UNKNOWN, \
3332 0, \
3333 0, \
3334 NULL, \
3335 subtype)
3336
3337/**
3338 * @defgroup Eet_Data_Cipher_Group Eet Data Serialization using A Ciphers
3339 *
3340 * Most of the @ref Eet_Data_Group have alternative versions that
3341 * accounts for ciphers to protect their content.
3342 *
3343 * @see @ref Eet_Cipher_Group
3344 *
3345 * @ingroup Eet_Data_Group
3346 */
3347
3348/**
3349 * Read a data structure from an eet file and decodes it using a cipher.
3350 * @param ef The eet file handle to read from.
3351 * @param edd The data descriptor handle to use when decoding.
3352 * @param name The key the data is stored under in the eet file.
3353 * @param cipher_key The key to use as cipher.
3354 * @return A pointer to the decoded data structure.
3355 *
3356 * This function decodes a data structure stored in an eet file, returning
3357 * a pointer to it if it decoded successfully, or NULL on failure. This
3358 * can save a programmer dozens of hours of work in writing configuration
3359 * file parsing and writing code, as eet does all that work for the program
3360 * and presents a program-friendly data structure, just as the programmer
3361 * likes. Eet can handle members being added or deleted from the data in
3362 * storage and safely zero-fills unfilled members if they were not found
3363 * in the data. It checks sizes and headers whenever it reads data, allowing
3364 * the programmer to not worry about corrupt data.
3365 *
3366 * Once a data structure has been described by the programmer with the
3367 * fields they wish to save or load, storing or retrieving a data structure
3368 * from an eet file, or from a chunk of memory is as simple as a single
3369 * function call.
3370 *
3371 * @see eet_data_read()
3372 *
3373 * @since 1.0.0
3374 * @ingroup Eet_Data_Cipher_Group
3375 */
3376EAPI void *
3377eet_data_read_cipher(Eet_File *ef,
3378 Eet_Data_Descriptor *edd,
3379 const char *name,
3380 const char *cipher_key);
3381
3382/**
3383 * Read a data structure from an eet extended attribute and decodes it using a cipher.
3384 * @param filename The file to extract the extended attribute from.
3385 * @param attribute The attribute to get the data from.
3386 * @param edd The data descriptor handle to use when decoding.
3387 * @param cipher_key The key to use as cipher.
3388 * @return A pointer to the decoded data structure.
3389 *
3390 * This function decodes a data structure stored in an eet extended attribute,
3391 * returning a pointer to it if it decoded successfully, or NULL on failure.
3392 * Eet can handle members being added or deleted from the data in
3393 * storage and safely zero-fills unfilled members if they were not found
3394 * in the data. It checks sizes and headers whenever it reads data, allowing
3395 * the programmer to not worry about corrupt data.
3396 *
3397 * Once a data structure has been described by the programmer with the
3398 * fields they wish to save or load, storing or retrieving a data structure
3399 * from an eet file, from a chunk of memory or from an extended attribute
3400 * is as simple as a single function call.
3401 *
3402 * @since 1.5.0
3403 * @ingroup Eet_Data_Cipher_Group
3404 */
3405EAPI void *
3406eet_data_xattr_cipher_get(const char *filename,
3407 const char *attribute,
3408 Eet_Data_Descriptor *edd,
3409 const char *cipher_key);
3410
3411/**
3412 * Write a data structure from memory and store in an eet file
3413 * using a cipher.
3414 * @param ef The eet file handle to write to.
3415 * @param edd The data descriptor to use when encoding.
3416 * @param name The key to store the data under in the eet file.
3417 * @param cipher_key The key to use as cipher.
3418 * @param data A pointer to the data structure to ssave and encode.
3419 * @param compress Compression flags for storage.
3420 * @return bytes written on successful write, 0 on failure.
3421 *
3422 * This function is the reverse of eet_data_read_cipher(), saving a data structure
3423 * to an eet file.
3424 *
3425 * @since 1.0.0
3426 * @ingroup Eet_Data_Cipher_Group
3427 */
3428EAPI int
3429eet_data_write_cipher(Eet_File *ef,
3430 Eet_Data_Descriptor *edd,
3431 const char *name,
3432 const char *cipher_key,
3433 const void *data,
3434 int compress);
3435
3436/**
3437 * Write a data structure from memory and store in an eet extended attribute
3438 * using a cipher.
3439 * @param filename The file to write the extended attribute to.
3440 * @param attribute The attribute to store the data to.
3441 * @param edd The data descriptor to use when encoding.
3442 * @param cipher_key The key to use as cipher.
3443 * @param data A pointer to the data structure to ssave and encode.
3444 * @param flags The policy to use when setting the data.
3445 * @return EINA_TRUE on success, EINA_FALSE on failure.
3446 *
3447 * This function is the reverse of eet_data_xattr_cipher_get(), saving a data structure
3448 * to an eet extended attribute.
3449 *
3450 * @since 1.5.0
3451 * @ingroup Eet_Data_Cipher_Group
3452 */
3453EAPI Eina_Bool
3454eet_data_xattr_cipher_set(const char *filename,
3455 const char *attribute,
3456 Eet_Data_Descriptor *edd,
3457 const char *cipher_key,
3458 const void *data,
3459 Eina_Xattr_Flags flags);
3460
3461/**
3462 * Dump an eet encoded data structure into ascii text using a cipher.
3463 * @param data_in The pointer to the data to decode into a struct.
3464 * @param cipher_key The key to use as cipher.
3465 * @param size_in The size of the data pointed to in bytes.
3466 * @param dumpfunc The function to call passed a string when new
3467 * data is converted to text
3468 * @param dumpdata The data to pass to the @p dumpfunc callback.
3469 * @return 1 on success, 0 on failure
3470 *
3471 * This function will take a chunk of data encoded by
3472 * eet_data_descriptor_encode() and convert it into human readable
3473 * ascii text. It does this by calling the @p dumpfunc callback
3474 * for all new text that is generated. This callback should append
3475 * to any existing text buffer and will be passed the pointer @p
3476 * dumpdata as a parameter as well as a string with new text to be
3477 * appended.
3478 *
3479 * Example:
3480 *
3481 * @code
3482 * void output(void *data, const char *string)
3483 * {
3484 * printf("%s", string);
3485 * }
3486 *
3487 * void dump(const char *file)
3488 * {
3489 * FILE *f;
3490 * int len;
3491 * void *data;
3492 *
3493 * f = fopen(file, "r");
3494 * fseek(f, 0, SEEK_END);
3495 * len = ftell(f);
3496 * rewind(f);
3497 * data = malloc(len);
3498 * fread(data, len, 1, f);
3499 * fclose(f);
3500 * eet_data_text_dump_cipher(data, cipher_key, len, output, NULL);
3501 * }
3502 * @endcode
3503 *
3504 * @see eet_data_text_dump()
3505 *
3506 * @since 1.0.0
3507 * @ingroup Eet_Data_Cipher_Group
3508 */
3509EAPI int
3510eet_data_text_dump_cipher(const void *data_in,
3511 const char *cipher_key,
3512 int size_in,
3513 Eet_Dump_Callback dumpfunc,
3514 void *dumpdata);
3515
3516/**
3517 * Take an ascii encoding from eet_data_text_dump() and re-encode
3518 * in binary using a cipher.
3519 * @param text The pointer to the string data to parse and encode.
3520 * @param cipher_key The key to use as cipher.
3521 * @param textlen The size of the string in bytes (not including 0
3522 * byte terminator).
3523 * @param size_ret This gets filled in with the encoded data blob
3524 * size in bytes.
3525 * @return The encoded data on success, NULL on failure.
3526 *
3527 * This function will parse the string pointed to by @p text and return
3528 * an encoded data lump the same way eet_data_descriptor_encode() takes an
3529 * in-memory data struct and encodes into a binary blob. @p text is a normal
3530 * C string.
3531 *
3532 * @see eet_data_text_undump()
3533 *
3534 * @since 1.0.0
3535 * @ingroup Eet_Data_Cipher_Group
3536 */
3537EAPI void *
3538eet_data_text_undump_cipher(const char *text,
3539 const char *cipher_key,
3540 int textlen,
3541 int *size_ret);
3542
3543/**
3544 * Dump an eet encoded data structure from an eet file into ascii
3545 * text using a cipher.
3546 * @param ef A valid eet file handle.
3547 * @param name Name of the entry. eg: "/base/file_i_want".
3548 * @param cipher_key The key to use as cipher.
3549 * @param dumpfunc The function to call passed a string when new
3550 * data is converted to text
3551 * @param dumpdata The data to pass to the @p dumpfunc callback.
3552 * @return 1 on success, 0 on failure
3553 *
3554 * This function will take an open and valid eet file from
3555 * eet_open() request the data encoded by
3556 * eet_data_descriptor_encode() corresponding to the key @p name
3557 * and convert it into human readable ascii text. It does this by
3558 * calling the @p dumpfunc callback for all new text that is
3559 * generated. This callback should append to any existing text
3560 * buffer and will be passed the pointer @p dumpdata as a parameter
3561 * as well as a string with new text to be appended.
3562 *
3563 * @see eet_data_dump()
3564 *
3565 * @since 1.0.0
3566 * @ingroup Eet_Data_Cipher_Group
3567 */
3568EAPI int
3569eet_data_dump_cipher(Eet_File *ef,
3570 const char *name,
3571 const char *cipher_key,
3572 Eet_Dump_Callback dumpfunc,
3573 void *dumpdata);
3574
3575/**
3576 * Take an ascii encoding from eet_data_dump() and re-encode in
3577 * binary using a cipher.
3578 * @param ef A valid eet file handle.
3579 * @param name Name of the entry. eg: "/base/file_i_want".
3580 * @param cipher_key The key to use as cipher.
3581 * @param text The pointer to the string data to parse and encode.
3582 * @param textlen The size of the string in bytes (not including 0
3583 * byte terminator).
3584 * @param compress Compression flags (1 == compress, 0 = don't compress).
3585 * @return 1 on success, 0 on failure
3586 *
3587 * This function will parse the string pointed to by @p text,
3588 * encode it the same way eet_data_descriptor_encode() takes an
3589 * in-memory data struct and encodes into a binary blob.
3590 *
3591 * The data (optionally compressed) will be in ram, pending a flush to
3592 * disk (it will stay in ram till the eet file handle is closed though).
3593 *
3594 * @see eet_data_undump()
3595 *
3596 * @since 1.0.0
3597 * @ingroup Eet_Data_Cipher_Group
3598 */
3599EAPI int
3600eet_data_undump_cipher(Eet_File *ef,
3601 const char *name,
3602 const char *cipher_key,
3603 const char *text,
3604 int textlen,
3605 int compress);
3606
3607/**
3608 * Decode a data structure from an arbitrary location in memory
3609 * using a cipher.
3610 * @param edd The data descriptor to use when decoding.
3611 * @param data_in The pointer to the data to decode into a struct.
3612 * @param cipher_key The key to use as cipher.
3613 * @param size_in The size of the data pointed to in bytes.
3614 * @return NULL on failure, or a valid decoded struct pointer on success.
3615 *
3616 * This function will decode a data structure that has been encoded using
3617 * eet_data_descriptor_encode(), and return a data structure with all its
3618 * elements filled out, if successful, or NULL on failure.
3619 *
3620 * The data to be decoded is stored at the memory pointed to by @p data_in,
3621 * and is described by the descriptor pointed to by @p edd. The data size is
3622 * passed in as the value to @p size_in, ande must be greater than 0 to
3623 * succeed.
3624 *
3625 * This function is useful for decoding data structures delivered to the
3626 * application by means other than an eet file, such as an IPC or socket
3627 * connection, raw files, shared memory etc.
3628 *
3629 * Please see eet_data_read() for more information.
3630 *
3631 * @see eet_data_descriptor_decode()
3632 *
3633 * @since 1.0.0
3634 * @ingroup Eet_Data_Cipher_Group
3635 */
3636EAPI void *
3637eet_data_descriptor_decode_cipher(Eet_Data_Descriptor *edd,
3638 const void *data_in,
3639 const char *cipher_key,
3640 int size_in);
3641
3642/**
3643 * Encode a data struct to memory and return that encoded data
3644 * using a cipher.
3645 * @param edd The data descriptor to use when encoding.
3646 * @param data_in The pointer to the struct to encode into data.
3647 * @param cipher_key The key to use as cipher.
3648 * @param size_ret pointer to the an int to be filled with the decoded size.
3649 * @return NULL on failure, or a valid encoded data chunk on success.
3650 *
3651 * This function takes a data structutre in memory and encodes it into a
3652 * serialised chunk of data that can be decoded again by
3653 * eet_data_descriptor_decode(). This is useful for being able to transmit
3654 * data structures across sockets, pipes, IPC or shared file mechanisms,
3655 * without having to worry about memory space, machine type, endianess etc.
3656 *
3657 * The parameter @p edd must point to a valid data descriptor, and
3658 * @p data_in must point to the right data structure to encode. If not, the
3659 * encoding may fail.
3660 *
3661 * On success a non NULL valid pointer is returned and what @p size_ret
3662 * points to is set to the size of this decoded data, in bytes. When the
3663 * encoded data is no longer needed, call free() on it. On failure NULL is
3664 * returned and what @p size_ret points to is set to 0.
3665 *
3666 * Please see eet_data_write() for more information.
3667 *
3668 * @see eet_data_descriptor_encode()
3669 *
3670 * @since 1.0.0
3671 * @ingroup Eet_Data_Cipher_Group
3672 */
3673EAPI void *
3674eet_data_descriptor_encode_cipher(Eet_Data_Descriptor *edd,
3675 const void *data_in,
3676 const char *cipher_key,
3677 int *size_ret);
3678
3679/**
3680 * @defgroup Eet_Node_Group Low-level Serialization Structures.
3681 *
3682 * Functions that create, destroy and manipulate serialization nodes
3683 * used by @ref Eet_Data_Group.
3684 *
3685 * @{
3686 */
3687
3688/**
3689 * @typedef Eet_Node
3690 * Opaque handle to manage serialization node.
3691 */
3692typedef struct _Eet_Node Eet_Node;
3693
3694/**
3695 * @typedef Eet_Node_Data
3696 * Contains an union that can fit any kind of node.
3697 */
3698typedef struct _Eet_Node_Data Eet_Node_Data;
3699
3700/**
3701 * @struct _Eet_Node_Data
3702 * Contains an union that can fit any kind of node.
3703 */
3704struct _Eet_Node_Data
3705{
3706 union {
3707 char c;
3708 short s;
3709 int i;
3710 long long l;
3711 float f;
3712 double d;
3713 unsigned char uc;
3714 unsigned short us;
3715 unsigned int ui;
3716 unsigned long long ul;
3717 const char *str;
3718 } value;
3719};
3720
3721/**
3722 * @}
3723 */
3724
3725/**
3726 * TODO FIX ME
3727 * @ingroup Eet_Node_Group
3728 */
3729EAPI Eet_Node *
3730eet_node_char_new(const char *name,
3731 char c);
3732
3733/**
3734 * TODO FIX ME
3735 * @ingroup Eet_Node_Group
3736 */
3737EAPI Eet_Node *
3738eet_node_short_new(const char *name,
3739 short s);
3740
3741/**
3742 * TODO FIX ME
3743 * @ingroup Eet_Node_Group
3744 */
3745EAPI Eet_Node *
3746eet_node_int_new(const char *name,
3747 int i);
3748
3749/**
3750 * TODO FIX ME
3751 * @ingroup Eet_Node_Group
3752 */
3753EAPI Eet_Node *
3754eet_node_long_long_new(const char *name,
3755 long long l);
3756
3757/**
3758 * TODO FIX ME
3759 * @ingroup Eet_Node_Group
3760 */
3761EAPI Eet_Node *
3762eet_node_float_new(const char *name,
3763 float f);
3764
3765/**
3766 * TODO FIX ME
3767 * @ingroup Eet_Node_Group
3768 */
3769EAPI Eet_Node *
3770eet_node_double_new(const char *name,
3771 double d);
3772
3773/**
3774 * TODO FIX ME
3775 * @ingroup Eet_Node_Group
3776 */
3777EAPI Eet_Node *
3778eet_node_unsigned_char_new(const char *name,
3779 unsigned char uc);
3780
3781/**
3782 * TODO FIX ME
3783 * @ingroup Eet_Node_Group
3784 */
3785EAPI Eet_Node *
3786eet_node_unsigned_short_new(const char *name,
3787 unsigned short us);
3788
3789/**
3790 * TODO FIX ME
3791 * @ingroup Eet_Node_Group
3792 */
3793EAPI Eet_Node *
3794eet_node_unsigned_int_new(const char *name,
3795 unsigned int ui);
3796
3797/**
3798 * TODO FIX ME
3799 * @ingroup Eet_Node_Group
3800 */
3801EAPI Eet_Node *
3802eet_node_unsigned_long_long_new(const char *name,
3803 unsigned long long l);
3804
3805/**
3806 * TODO FIX ME
3807 * @ingroup Eet_Node_Group
3808 */
3809EAPI Eet_Node *
3810eet_node_string_new(const char *name,
3811 const char *str);
3812
3813/**
3814 * TODO FIX ME
3815 * @ingroup Eet_Node_Group
3816 */
3817EAPI Eet_Node *
3818eet_node_inlined_string_new(const char *name,
3819 const char *str);
3820
3821/**
3822 * TODO FIX ME
3823 * @ingroup Eet_Node_Group
3824 */
3825EAPI Eet_Node *
3826eet_node_null_new(const char *name);
3827
3828/**
3829 * TODO FIX ME
3830 * @ingroup Eet_Node_Group
3831 */
3832EAPI Eet_Node *
3833eet_node_list_new(const char *name,
3834 Eina_List *nodes);
3835
3836/**
3837 * TODO FIX ME
3838 * @ingroup Eet_Node_Group
3839 */
3840EAPI Eet_Node *
3841eet_node_array_new(const char *name,
3842 int count,
3843 Eina_List *nodes);
3844
3845/**
3846 * TODO FIX ME
3847 * @ingroup Eet_Node_Group
3848 */
3849EAPI Eet_Node *
3850eet_node_var_array_new(const char *name,
3851 Eina_List *nodes);
3852
3853/**
3854 * TODO FIX ME
3855 * @ingroup Eet_Node_Group
3856 */
3857EAPI Eet_Node *
3858eet_node_hash_new(const char *name,
3859 const char *key,
3860 Eet_Node *node);
3861
3862/**
3863 * TODO FIX ME
3864 * @ingroup Eet_Node_Group
3865 */
3866EAPI Eet_Node *
3867eet_node_struct_new(const char *name,
3868 Eina_List *nodes);
3869
3870/**
3871 * TODO FIX ME
3872 * @ingroup Eet_Node_Group
3873 */
3874EAPI Eet_Node *
3875eet_node_struct_child_new(const char *parent,
3876 Eet_Node *child);
3877
3878/**
3879 * @brief Get a node's child nodes
3880 * @param node The node
3881 * @return The first child node which contains a pointer to the
3882 * next child node and the parent.
3883 * @since 1.5
3884 */
3885EAPI Eet_Node *
3886eet_node_children_get(Eet_Node *node);
3887
3888/**
3889 * @brief Get the next node in a list of nodes
3890 * @param node The node
3891 * @return A node which contains a pointer to the
3892 * next child node and the parent.
3893 * @since 1.5
3894 */
3895EAPI Eet_Node *
3896eet_node_next_get(Eet_Node *node);
3897
3898/**
3899 * @brief Get the parent node of a node
3900 * @param node The node
3901 * @return The parent node of @p node
3902 * @since 1.5
3903 */
3904EAPI Eet_Node *
3905eet_node_parent_get(Eet_Node *node);
3906
3907/**
3908 * TODO FIX ME
3909 * @ingroup Eet_Node_Group
3910 */
3911EAPI void
3912eet_node_list_append(Eet_Node *parent,
3913 const char *name,
3914 Eet_Node *child);
3915
3916/**
3917 * TODO FIX ME
3918 * @ingroup Eet_Node_Group
3919 */
3920EAPI void
3921eet_node_struct_append(Eet_Node *parent,
3922 const char *name,
3923 Eet_Node *child);
3924
3925/**
3926 * TODO FIX ME
3927 * @ingroup Eet_Node_Group
3928 */
3929EAPI void
3930eet_node_hash_add(Eet_Node *parent,
3931 const char *name,
3932 const char *key,
3933 Eet_Node *child);
3934
3935/**
3936 * TODO FIX ME
3937 * @ingroup Eet_Node_Group
3938 */
3939EAPI void
3940eet_node_dump(Eet_Node *n,
3941 int dumplevel,
3942 Eet_Dump_Callback dumpfunc,
3943 void *dumpdata);
3944
3945/**
3946 * @brief Return the type of a node
3947 * @param node The node
3948 * @return The node's type (EET_T_$TYPE)
3949 * @since 1.5
3950 */
3951EAPI int
3952eet_node_type_get(Eet_Node *node);
3953
3954/**
3955 * @brief Return the node's data
3956 * @param node The node
3957 * @return The data contained in the node
3958 * @since 1.5
3959 */
3960EAPI Eet_Node_Data *
3961eet_node_value_get(Eet_Node *node);
3962
3963/**
3964 * TODO FIX ME
3965 * @ingroup Eet_Node_Group
3966 */
3967EAPI void
3968eet_node_del(Eet_Node *n);
3969
3970/**
3971 * TODO FIX ME
3972 * @ingroup Eet_Node_Group
3973 */
3974EAPI void *
3975eet_data_node_encode_cipher(Eet_Node *node,
3976 const char *cipher_key,
3977 int *size_ret);
3978
3979/**
3980 * TODO FIX ME
3981 * @ingroup Eet_Node_Group
3982 */
3983EAPI Eet_Node *
3984eet_data_node_decode_cipher(const void *data_in,
3985 const char *cipher_key,
3986 int size_in);
3987
3988/**
3989 * TODO FIX ME
3990 * @ingroup Eet_Node_Group
3991 */
3992EAPI Eet_Node *
3993eet_data_node_read_cipher(Eet_File *ef,
3994 const char *name,
3995 const char *cipher_key);
3996
3997/**
3998 * TODO FIX ME
3999 * @ingroup Eet_Node_Group
4000 */
4001EAPI int
4002eet_data_node_write_cipher(Eet_File *ef,
4003 const char *name,
4004 const char *cipher_key,
4005 Eet_Node *node,
4006 int compress);
4007
4008/* EXPERIMENTAL: THIS API MAY CHANGE IN THE FUTURE, USE IT ONLY IF YOU KNOW WHAT YOU ARE DOING. */
4009
4010/**
4011 * @typedef Eet_Node_Walk
4012 * Describes how to walk trees of #Eet_Node.
4013 */
4014typedef struct _Eet_Node_Walk Eet_Node_Walk;
4015
4016typedef void * (*Eet_Node_Walk_Struct_Alloc_Callback)(const char *type, void *user_data);
4017typedef void (*Eet_Node_Walk_Struct_Add_Callback)(void *parent, const char *name, void *child, void *user_data);
4018typedef void * (*Eet_Node_Walk_Array_Callback)(Eina_Bool variable, const char *name, int count, void *user_data);
4019typedef void (*Eet_Node_Walk_Insert_Callback)(void *array, int index, void *child, void *user_data);
4020typedef void * (*Eet_Node_Walk_List_Callback)(const char *name, void *user_data);
4021typedef void (*Eet_Node_Walk_Append_Callback)(void *list, void *child, void *user_data);
4022typedef void * (*Eet_Node_Walk_Hash_Callback)(void *parent, const char *name, const char *key, void *value, void *user_data);
4023typedef void * (*Eet_Node_Walk_Simple_Callback)(int type, Eet_Node_Data *data, void *user_data);
4024
4025/**
4026 * @struct _Eet_Node_Walk
4027 * Describes how to walk trees of #Eet_Node.
4028 */
4029struct _Eet_Node_Walk
4030{
4031 Eet_Node_Walk_Struct_Alloc_Callback struct_alloc;
4032 Eet_Node_Walk_Struct_Add_Callback struct_add;
4033 Eet_Node_Walk_Array_Callback array;
4034 Eet_Node_Walk_Insert_Callback insert;
4035 Eet_Node_Walk_List_Callback list;
4036 Eet_Node_Walk_Append_Callback append;
4037 Eet_Node_Walk_Hash_Callback hash;
4038 Eet_Node_Walk_Simple_Callback simple;
4039};
4040
4041EAPI void *
4042eet_node_walk(void *parent,
4043 const char *name,
4044 Eet_Node *root,
4045 Eet_Node_Walk *cb,
4046 void *user_data);
4047
4048/*******/
4049
4050/**
4051 * @defgroup Eet_Connection_Group Helper function to use eet over a network link
4052 *
4053 * Function that reconstruct and prepare packet of @ref Eet_Data_Group to be send.
4054 *
4055 */
4056
4057/**
4058 * @typedef Eet_Connection
4059 * Opaque handle to track paquet for a specific connection.
4060 *
4061 * @ingroup Eet_Connection_Group
4062 */
4063typedef struct _Eet_Connection Eet_Connection;
4064
4065/**
4066 * @typedef Eet_Read_Cb
4067 * Called back when an @ref Eet_Data_Group has been received completly and could be used.
4068 *
4069 * @ingroup Eet_Connection_Group
4070 */
4071typedef Eina_Bool Eet_Read_Cb (const void *eet_data, size_t size, void *user_data);
4072
4073/**
4074 * @typedef Eet_Write_Cb
4075 * Called back when a packet containing @ref Eet_Data_Group data is ready to be send.
4076 *
4077 * @ingroup Eet_Connection_Group
4078 */
4079typedef Eina_Bool Eet_Write_Cb (const void *data, size_t size, void *user_data);
4080
4081/**
4082 * Instanciate a new connection to track.
4083 * @param eet_read_cb Function to call when one Eet_Data packet has been fully assemble.
4084 * @param eet_write_cb Function to call when one Eet_Data packet is ready to be send over the wire.
4085 * @param user_data Pointer provided to both functions to be used as a context handler.
4086 * @return NULL on failure, or a valid Eet_Connection handler.
4087 *
4088 * For every connection to track you will need a separate Eet_Connection provider.
4089 *
4090 * @since 1.2.4
4091 * @ingroup Eet_Connection_Group
4092 */
4093EAPI Eet_Connection *
4094eet_connection_new(Eet_Read_Cb *eet_read_cb,
4095 Eet_Write_Cb *eet_write_cb,
4096 const void *user_data);
4097
4098/**
4099 * Process a raw packet received over the link
4100 * @param conn Connection handler to track.
4101 * @param data Raw data packet.
4102 * @param size The size of that packet.
4103 * @return 0 on complete success, any other value indicate where in the stream it got wrong (It could be before that packet).
4104 *
4105 * Every time you receive a packet related to your connection, you should pass
4106 * it to that function so that it could process and assemble packet has you
4107 * receive it. It will automatically call Eet_Read_Cb when one is fully received.
4108 *
4109 * @since 1.2.4
4110 * @ingroup Eet_Connection_Group
4111 */
4112EAPI int
4113eet_connection_received(Eet_Connection *conn,
4114 const void *data,
4115 size_t size);
4116
4117/**
4118 * Convert a complex structure and prepare it to be send.
4119 * @param conn Connection handler to track.
4120 * @param edd The data descriptor to use when encoding.
4121 * @param data_in The pointer to the struct to encode into data.
4122 * @param cipher_key The key to use as cipher.
4123 * @return EINA_TRUE if the data where correctly send, EINA_FALSE if they don't.
4124 *
4125 * This function serialize data_in with edd, assemble the packet and call
4126 * Eet_Write_Cb when ready. The data passed Eet_Write_Cb are temporary allocated
4127 * and will vanish just after the return of the callback.
4128 *
4129 * @see eet_data_descriptor_encode_cipher
4130 *
4131 * @since 1.2.4
4132 * @ingroup Eet_Connection_Group
4133 */
4134EAPI Eina_Bool
4135eet_connection_send(Eet_Connection *conn,
4136 Eet_Data_Descriptor *edd,
4137 const void *data_in,
4138 const char *cipher_key);
4139
4140/**
4141 * Convert a Eet_Node tree and prepare it to be send.
4142 * @param conn Connection handler to track.
4143 * @param node The data tree to use when encoding.
4144 * @param cipher_key The key to use as cipher.
4145 * @return EINA_TRUE if the data where correctly send, EINA_FALSE if they don't.
4146 *
4147 * This function serialize node, assemble the packet and call
4148 * Eet_Write_Cb when ready. The data passed Eet_Write_Cb are temporary allocated
4149 * and will vanish just after the return of the callback.
4150 *
4151 * @see eet_data_node_encode_cipher
4152 *
4153 * @since 1.2.4
4154 * @ingroup Eet_Connection_Group
4155 */
4156EAPI Eina_Bool
4157eet_connection_node_send(Eet_Connection *conn,
4158 Eet_Node *node,
4159 const char *cipher_key);
4160
4161/**
4162 * Close a connection and lost its track.
4163 * @param conn Connection handler to close.
4164 * @param on_going Signal if a partial packet wasn't completed.
4165 * @return the user_data passed to both callback.
4166 *
4167 * @since 1.2.4
4168 * @ingroup Eet_Connection_Group
4169 */
4170EAPI void *
4171eet_connection_close(Eet_Connection *conn,
4172 Eina_Bool *on_going);
4173
4174/***************************************************************************/
4175
4176#ifdef __cplusplus
4177}
4178#endif /* ifdef __cplusplus */
4179
4180#endif /* ifndef _EET_H */
diff --git a/libraries/eet/src/lib/Eet_private.h b/libraries/eet/src/lib/Eet_private.h
deleted file mode 100644
index c04daf0..0000000
--- a/libraries/eet/src/lib/Eet_private.h
+++ /dev/null
@@ -1,326 +0,0 @@
1#ifndef _EET_PRIVATE_H
2#define _EET_PRIVATE_H
3
4#include <Eina.h>
5
6typedef enum _Eet_Convert_Type Eet_Convert_Type;
7
8enum _Eet_Convert_Type
9{
10 EET_D_NOTHING = 0,
11 EET_D_FLOAT = 1 << 1,
12 EET_D_DOUBLE = 1 << 2,
13 EET_D_FIXED_POINT = 1 << 4
14};
15
16typedef struct _Eet_String Eet_String;
17typedef struct _Eet_Convert Eet_Convert;
18
19struct _Eet_Convert
20{
21 float f;
22 double d;
23 Eina_F32p32 fp;
24
25 Eet_Convert_Type type;
26};
27
28struct _Eet_String
29{
30 const char *str;
31
32 int len;
33
34 int next;
35 int prev;
36
37 unsigned char hash;
38 unsigned char allocated : 1;
39};
40struct _Eet_Dictionary
41{
42 Eet_String *all;
43 Eina_Hash *converts;
44
45 int size;
46 int offset;
47
48 int hash[256];
49
50 int count;
51 int total;
52
53 const char *start;
54 const char *end;
55};
56
57struct _Eet_Node
58{
59 int type;
60 int count;
61 const char *name;
62 const char *key;
63 Eet_Node *values;
64 Eet_Node *next;
65 Eet_Node *parent;
66 Eet_Node_Data data;
67};
68
69typedef struct _Eet_File_Header Eet_File_Header;
70typedef struct _Eet_File_Node Eet_File_Node;
71typedef struct _Eet_File_Directory Eet_File_Directory;
72
73struct _Eet_File
74{
75 const char *path;
76 Eina_File *readfp;
77 Eet_File_Header *header;
78 Eet_Dictionary *ed;
79 Eet_Key *key;
80 const unsigned char *data;
81 const void *x509_der;
82 const void *signature;
83 void *sha1;
84
85 Eet_File_Mode mode;
86
87 int magic;
88 int references;
89
90 unsigned long int data_size;
91 int x509_length;
92 unsigned int signature_length;
93 int sha1_length;
94
95 Eina_Lock file_lock;
96
97 unsigned char writes_pending : 1;
98 unsigned char delete_me_now : 1;
99};
100
101struct _Eet_File_Header
102{
103 int magic;
104 Eet_File_Directory *directory;
105};
106
107struct _Eet_File_Directory
108{
109 int size;
110 Eet_File_Node **nodes;
111};
112
113struct _Eet_File_Node
114{
115 char *name;
116 void *data;
117 Eet_File_Node *next; /* FIXME: make buckets linked lists */
118
119 unsigned long int offset;
120 unsigned long int dictionary_offset;
121 unsigned long int name_offset;
122
123 unsigned int name_size;
124 unsigned int size;
125 unsigned int data_size;
126
127 unsigned char free_name : 1;
128 unsigned char compression : 1;
129 unsigned char ciphered : 1;
130 unsigned char alias : 1;
131};
132
133#if 0
134/* Version 2 */
135/* NB: all int's are stored in network byte order on disk */
136/* file format: */
137int magic; /* magic number ie 0x1ee7ff00 */
138int num_directory_entries; /* number of directory entries to follow */
139int bytes_directory_entries; /* bytes of directory entries to follow */
140struct
141{
142 int offset; /* bytes offset into file for data chunk */
143 int flags; /* flags - for now 0 = uncompressed and clear, 1 = compressed and clear, 2 = uncompressed and ciphered, 3 = compressed and ciphered */
144 int size; /* size of the data chunk */
145 int data_size; /* size of the (uncompressed) data chunk */
146 int name_size; /* length in bytes of the name field */
147 char name[name_size]; /* name string (variable length) and \0 terminated */
148} directory[num_directory_entries];
149/* and now startes the data stream... */
150#endif /* if 0 */
151
152#if 0
153/* Version 3 */
154/* NB: all int's are stored in network byte order on disk */
155/* file format: */
156int magic; /* magic number ie 0x1ee70f42 */
157int num_directory_entries; /* number of directory entries to follow */
158int num_dictionary_entries; /* number of dictionary entries to follow */
159struct
160{
161 int data_offset; /* bytes offset into file for data chunk */
162 int size; /* size of the data chunk */
163 int data_size; /* size of the (uncompressed) data chunk */
164 int name_offset; /* bytes offset into file for name string */
165 int name_size; /* length in bytes of the name field */
166 int flags; /* bit flags - for now:
167 bit 0 => compresion on/off
168 bit 1 => ciphered on/off
169 bit 2 => alias
170 */
171} directory[num_directory_entries];
172struct
173{
174 int hash;
175 int offset;
176 int size;
177 int prev;
178 int next;
179} dictionary[num_dictionary_entries];
180/* now start the string stream. */
181/* and right after them the data stream. */
182int magic_sign; /* Optional, only if the eet file is signed. */
183int signature_length; /* Signature length. */
184int x509_length; /* Public certificate that signed the file. */
185char signature[signature_length]; /* The signature. */
186char x509[x509_length]; /* The public certificate. */
187#endif /* if 0 */
188
189/*
190 * variable and macros used for the eina_log module
191 */
192extern int _eet_log_dom_global;
193
194/*
195 * Macros that are used everywhere
196 *
197 * the first four macros are the general macros for the lib
198 */
199#ifdef EET_DEFAULT_LOG_COLOR
200# undef EET_DEFAULT_LOG_COLOR
201#endif /* ifdef EET_DEFAULT_LOG_COLOR */
202#define EET_DEFAULT_LOG_COLOR EINA_COLOR_CYAN
203#ifdef ERR
204# undef ERR
205#endif /* ifdef ERR */
206#define ERR(...) EINA_LOG_DOM_ERR(_eet_log_dom_global, __VA_ARGS__)
207#ifdef DBG
208# undef DBG
209#endif /* ifdef DBG */
210#define DBG(...) EINA_LOG_DOM_DBG(_eet_log_dom_global, __VA_ARGS__)
211#ifdef INF
212# undef INF
213#endif /* ifdef INF */
214#define INF(...) EINA_LOG_DOM_INFO(_eet_log_dom_global, __VA_ARGS__)
215#ifdef WRN
216# undef WRN
217#endif /* ifdef WRN */
218#define WRN(...) EINA_LOG_DOM_WARN(_eet_log_dom_global, __VA_ARGS__)
219#ifdef CRIT
220# undef CRIT
221#endif /* ifdef CRIT */
222#define CRIT(...) EINA_LOG_DOM_CRIT(_eet_log_dom_global, __VA_ARGS__)
223
224Eet_Dictionary *
225 eet_dictionary_add(void);
226void
227 eet_dictionary_free(Eet_Dictionary *ed);
228int
229 eet_dictionary_string_add(Eet_Dictionary *ed,
230 const char *string);
231int
232eet_dictionary_string_get_size(const Eet_Dictionary *ed,
233 int index);
234const char *
235eet_dictionary_string_get_char(const Eet_Dictionary *ed,
236 int index);
237Eina_Bool
238eet_dictionary_string_get_float(const Eet_Dictionary *ed,
239 int index,
240 float *result);
241Eina_Bool
242eet_dictionary_string_get_double(const Eet_Dictionary *ed,
243 int index,
244 double *result);
245Eina_Bool
246eet_dictionary_string_get_fp(const Eet_Dictionary *ed,
247 int index,
248 Eina_F32p32 *result);
249int
250eet_dictionary_string_get_hash(const Eet_Dictionary *ed,
251 int index);
252
253int _eet_hash_gen(const char *key,
254 int hash_size);
255
256const void *
257eet_identity_check(const void *data_base,
258 unsigned int data_length,
259 void **sha1,
260 int *sha1_length,
261 const void *signature_base,
262 unsigned int signature_length,
263 const void **raw_signature_base,
264 unsigned int *raw_signature_length,
265 int *x509_length);
266void *
267eet_identity_compute_sha1(const void *data_base,
268 unsigned int data_length,
269 int *sha1_length);
270Eet_Error
271eet_cipher(const void *data,
272 unsigned int size,
273 const char *key,
274 unsigned int length,
275 void **result,
276 unsigned int *result_length);
277Eet_Error
278eet_decipher(const void *data,
279 unsigned int size,
280 const char *key,
281 unsigned int length,
282 void **result,
283 unsigned int *result_length);
284Eet_Error
285eet_identity_sign(FILE *fp,
286 Eet_Key *key);
287void
288 eet_identity_unref(Eet_Key *key);
289void
290 eet_identity_ref(Eet_Key *key);
291
292void
293 eet_node_shutdown(void);
294int
295 eet_node_init(void);
296Eet_Node *
297 eet_node_new(void);
298void
299 eet_node_free(Eet_Node *node);
300
301
302#define GENERIC_ALLOC_FREE_HEADER(TYPE, Type) \
303 TYPE *Type##_malloc(unsigned int); \
304 TYPE *Type##_calloc(unsigned int); \
305 void Type##_mp_free(TYPE *e);
306
307GENERIC_ALLOC_FREE_HEADER(Eet_File_Directory, eet_file_directory);
308GENERIC_ALLOC_FREE_HEADER(Eet_File_Node, eet_file_node);
309GENERIC_ALLOC_FREE_HEADER(Eet_File_Header, eet_file_header);
310GENERIC_ALLOC_FREE_HEADER(Eet_Dictionary, eet_dictionary);
311GENERIC_ALLOC_FREE_HEADER(Eet_File, eet_file);
312
313Eina_Bool eet_mempool_init(void);
314void eet_mempool_shutdown(void);
315
316#ifndef PATH_MAX
317# define PATH_MAX 4096
318#endif /* ifndef PATH_MAX */
319
320#ifdef DNDEBUG
321# define EET_ASSERT(Test, Do) if (Test == 0) {Do; }
322#else /* ifdef DNDEBUG */
323# define EET_ASSERT(Test, Do) if (Test == 0) {abort(); }
324#endif /* ifdef DNDEBUG */
325
326#endif /* ifndef _EET_PRIVATE_H */
diff --git a/libraries/eet/src/lib/Makefile.am b/libraries/eet/src/lib/Makefile.am
deleted file mode 100644
index ae60168..0000000
--- a/libraries/eet/src/lib/Makefile.am
+++ /dev/null
@@ -1,163 +0,0 @@
1
2MAINTAINERCLEANFILES = Makefile.in
3
4AM_CPPFLAGS = \
5-I. \
6-I$(top_srcdir)/src/lib \
7-I$(top_builddir)/src/lib \
8-DPACKAGE_BIN_DIR=\"$(bindir)\" \
9-DPACKAGE_LIB_DIR=\"$(libdir)\" \
10-DPACKAGE_DATA_DIR=\"$(datadir)/$(PACKAGE)\" \
11@EVIL_CFLAGS@ \
12@EINA_CFLAGS@ \
13@EET_CPPFLAGS@ \
14@EFL_EET_BUILD@ \
15@EFL_COVERAGE_CFLAGS@ \
16@OPENSSL_CFLAGS@ \
17@GNUTLS_CFLAGS@
18
19includes_HEADERS = Eet.h
20includesdir = $(includedir)/eet-@VMAJ@
21
22lib_LTLIBRARIES = libeet.la
23
24base_sources = \
25eet_alloc.c \
26eet_lib.c \
27eet_data.c \
28eet_image.c \
29eet_cipher.c \
30eet_dictionary.c \
31eet_node.c \
32eet_utils.c \
33eet_connection.c
34
35if EET_AMALGAMATION
36nodist_libeet_la_SOURCES = eet_amalgamation.c
37
38eet_amalgamation.c: $(base_sources) Makefile
39 -rm -f eet_amalgamation.c
40
41 @echo "#ifdef HAVE_CONFIG_H" >> eet_amalgamation.c
42 @echo "# include \"config.h\"" >> eet_amalgamation.c
43 @echo "#endif" >> eet_amalgamation.c
44
45 @echo "#ifdef HAVE_ALLOCA_H" >> eet_amalgamation.c
46 @echo "# include <alloca.h>" >> eet_amalgamation.c
47 @echo "#elif defined __GNUC__" >> eet_amalgamation.c
48 @echo "# define alloca __builtin_alloca" >> eet_amalgamation.c
49 @echo "#elif defined _AIX" >> eet_amalgamation.c
50 @echo "# define alloca __alloca" >> eet_amalgamation.c
51 @echo "#elif defined _MSC_VER" >> eet_amalgamation.c
52 @echo "# include <malloc.h>" >> eet_amalgamation.c
53 @echo "# define alloca _alloca" >> eet_amalgamation.c
54 @echo "#else" >> eet_amalgamation.c
55 @echo "# include <stddef.h>" >> eet_amalgamation.c
56 @echo "# ifdef __cplusplus" >> eet_amalgamation.c
57 @echo "#extern \"C\"" >> eet_amalgamation.c
58 @echo "# endif" >> eet_amalgamation.c
59 @echo "#void *alloca (size_t);" >> eet_amalgamation.c
60 @echo "#endif" >> eet_amalgamation.c
61
62 @echo "#include <stdio.h>" >> eet_amalgamation.c
63 @echo "#include <string.h>" >> eet_amalgamation.c
64 @echo "#include <math.h>" >> eet_amalgamation.c
65 @echo "#include <ctype.h>" >> eet_amalgamation.c
66 @echo "#include <limits.h>" >> eet_amalgamation.c
67 @echo "#include <sys/types.h>" >> eet_amalgamation.c
68 @echo "#include <sys/stat.h>" >> eet_amalgamation.c
69 @echo "#ifdef HAVE_SIGNATURE" >> eet_amalgamation.c
70 @echo "# include <sys/mman.h>" >> eet_amalgamation.c
71 @echo "#endif" >> eet_amalgamation.c
72 @echo "#include <setjmp.h>" >> eet_amalgamation.c
73 @echo "#include <errno.h>" >> eet_amalgamation.c
74 @echo "#include <time.h>" >> eet_amalgamation.c
75 @echo "#include <fnmatch.h>" >> eet_amalgamation.c
76 @echo "#include <fcntl.h>" >> eet_amalgamation.c
77
78 @echo "#ifdef _WIN32" >> eet_amalgamation.c
79 @echo "# include <winsock2.h>" >> eet_amalgamation.c
80 @echo "#endif" >> eet_amalgamation.c
81
82 @echo "#ifndef _MSC_VER" >> eet_amalgamation.c
83 @echo "# include <unistd.h>" >> eet_amalgamation.c
84 @echo "#endif" >> eet_amalgamation.c
85
86 @echo "#ifdef HAVE_NETINET_IN_H" >> eet_amalgamation.c
87 @echo "# include <netinet/in.h>" >> eet_amalgamation.c
88 @echo "#endif" >> eet_amalgamation.c
89
90 @echo "#ifdef HAVE_GNUTLS" >> eet_amalgamation.c
91 @echo "# include <gnutls/gnutls.h>" >> eet_amalgamation.c
92 @echo "# include <gcrypt.h>" >> eet_amalgamation.c
93 @echo "#endif" >> eet_amalgamation.c
94
95 @echo "#ifdef HAVE_OPENSSL" >> eet_amalgamation.c
96 @echo "# include <openssl/err.h>" >> eet_amalgamation.c
97 @echo "# include <openssl/evp.h>" >> eet_amalgamation.c
98 @echo "# include <openssl/sha.h>" >> eet_amalgamation.c
99 @echo "#endif" >> eet_amalgamation.c
100
101 @echo "#ifdef HAVE_SIGNATURE" >> eet_amalgamation.c
102 @echo "# ifdef HAVE_GNUTLS" >> eet_amalgamation.c
103 @echo "# include <gnutls/gnutls.h>" >> eet_amalgamation.c
104 @echo "# include <gnutls/x509.h>" >> eet_amalgamation.c
105 @echo "# else" >> eet_amalgamation.c
106 @echo "# include <openssl/rsa.h>" >> eet_amalgamation.c
107 @echo "# include <openssl/objects.h>" >> eet_amalgamation.c
108 @echo "# include <openssl/err.h>" >> eet_amalgamation.c
109 @echo "# include <openssl/ssl.h>" >> eet_amalgamation.c
110 @echo "# include <openssl/dh.h>" >> eet_amalgamation.c
111 @echo "# include <openssl/dsa.h>" >> eet_amalgamation.c
112 @echo "# include <openssl/evp.h>" >> eet_amalgamation.c
113 @echo "# include <openssl/x509.h>" >> eet_amalgamation.c
114 @echo "# include <openssl/pem.h>" >> eet_amalgamation.c
115 @echo "# endif" >> eet_amalgamation.c
116 @echo "#endif" >> eet_amalgamation.c
117
118 @echo "#ifdef HAVE_CIPHER" >> eet_amalgamation.c
119 @echo "# ifdef HAVE_GNUTLS" >> eet_amalgamation.c
120 @echo "# include <gnutls/x509.h>" >> eet_amalgamation.c
121 @echo "# include <gcrypt.h>" >> eet_amalgamation.c
122 @echo "# else" >> eet_amalgamation.c
123 @echo "# include <openssl/evp.h>" >> eet_amalgamation.c
124 @echo "# include <openssl/hmac.h>" >> eet_amalgamation.c
125 @echo "# include <openssl/rand.h>" >> eet_amalgamation.c
126 @echo "# endif" >> eet_amalgamation.c
127 @echo "#endif" >> eet_amalgamation.c
128
129 @echo "#include <zlib.h>" >> eet_amalgamation.c
130 @echo "#include <jpeglib.h>" >> eet_amalgamation.c
131
132 @echo "#ifdef HAVE_EVIL" >> eet_amalgamation.c
133 @echo "# include <Evil.h>" >> eet_amalgamation.c
134 @echo "#endif" >> eet_amalgamation.c
135
136 @echo "#include <Eet.h>" >> eet_amalgamation.c
137
138 @echo "#include \"Eet_private.h\"" >> eet_amalgamation.c
139 @echo "#include \"Eet.h\"" >> eet_amalgamation.c
140
141 @for f in $(base_sources); do \
142 if [ `echo $$f | sed -e 's/^...\(.\).*/\1/'` != '/' ]; then \
143 file="$(srcdir)/$$f" ; \
144 else \
145 file="$$f" ; \
146 fi ; \
147 echo "/* file: $$file */" >> eet_amalgamation.c; \
148 grep -v -e '^# *include \+.\(config\|\|Evil\|Eina\|stdio\|string\|math\|ctype\|limits\|sys/types\|sys/stat\|sys/mman\|setjmp\|errno\|time\|fnmatch\|fcntl\|winsock2\|unistd\|netinet/in\|gnutls/gnutls\|gcrypt\|gnutls/x509\|openssl/rsa\|openssl/objects\|openssl/err\|openssl/ssl\|openssl/dh\|openssl/dsa\|openssl/evp\|openssl/pem\|openssl/sha\|openssl/hmac\|openssl/x509\|openssl/rand\|zlib\|jpeglib\|Eet_private\|Eet\)[.]h.*' $$file >> eet_amalgamation.c; \
149 done
150 @echo "eet_amalgamation.c generated"
151
152else
153libeet_la_SOURCES = $(base_sources)
154endif
155
156libeet_la_CFLAGS = @EET_CFLAGS@ @DEBUG_CFLAGS@
157libeet_la_LIBADD = @GNUTLS_LIBS@ @OPENSSL_LIBS@ @EFL_COVERAGE_LIBS@ @EET_LIBS@ @EINA_LIBS@ @EVIL_LIBS@ -lz -ljpeg -lm
158libeet_la_LDFLAGS = -no-undefined @lt_enable_auto_import@ -version-info @version_info@ @release_info@
159
160EXTRA_DIST = Eet_private.h
161
162clean-local:
163 @rm -rf *.gcno eet_amalgamation.c
diff --git a/libraries/eet/src/lib/Makefile.in b/libraries/eet/src/lib/Makefile.in
deleted file mode 100644
index c0367b3..0000000
--- a/libraries/eet/src/lib/Makefile.in
+++ /dev/null
@@ -1,859 +0,0 @@
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
18
19VPATH = @srcdir@
20pkgdatadir = $(datadir)/@PACKAGE@
21pkgincludedir = $(includedir)/@PACKAGE@
22pkglibdir = $(libdir)/@PACKAGE@
23pkglibexecdir = $(libexecdir)/@PACKAGE@
24am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
25install_sh_DATA = $(install_sh) -c -m 644
26install_sh_PROGRAM = $(install_sh) -c
27install_sh_SCRIPT = $(install_sh) -c
28INSTALL_HEADER = $(INSTALL_DATA)
29transform = $(program_transform_name)
30NORMAL_INSTALL = :
31PRE_INSTALL = :
32POST_INSTALL = :
33NORMAL_UNINSTALL = :
34PRE_UNINSTALL = :
35POST_UNINSTALL = :
36build_triplet = @build@
37host_triplet = @host@
38subdir = src/lib
39DIST_COMMON = $(includes_HEADERS) $(srcdir)/Makefile.am \
40 $(srcdir)/Makefile.in
41ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
42am__aclocal_m4_deps = $(top_srcdir)/m4/ac_attribute.m4 \
43 $(top_srcdir)/m4/ac_path_generic.m4 \
44 $(top_srcdir)/m4/efl_binary.m4 \
45 $(top_srcdir)/m4/efl_compiler_flag.m4 \
46 $(top_srcdir)/m4/efl_coverage.m4 \
47 $(top_srcdir)/m4/efl_doxygen.m4 \
48 $(top_srcdir)/m4/efl_fnmatch.m4 \
49 $(top_srcdir)/m4/efl_path_max.m4 $(top_srcdir)/m4/efl_tests.m4 \
50 $(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
51 $(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \
52 $(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/configure.ac
53am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
54 $(ACLOCAL_M4)
55mkinstalldirs = $(install_sh) -d
56CONFIG_HEADER = $(top_builddir)/config.h
57CONFIG_CLEAN_FILES =
58CONFIG_CLEAN_VPATH_FILES =
59am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
60am__vpath_adj = case $$p in \
61 $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
62 *) f=$$p;; \
63 esac;
64am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`;
65am__install_max = 40
66am__nobase_strip_setup = \
67 srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'`
68am__nobase_strip = \
69 for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||"
70am__nobase_list = $(am__nobase_strip_setup); \
71 for p in $$list; do echo "$$p $$p"; done | \
72 sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \
73 $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \
74 if (++n[$$2] == $(am__install_max)) \
75 { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \
76 END { for (dir in files) print dir, files[dir] }'
77am__base_list = \
78 sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \
79 sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g'
80am__installdirs = "$(DESTDIR)$(libdir)" "$(DESTDIR)$(includesdir)"
81LTLIBRARIES = $(lib_LTLIBRARIES)
82libeet_la_DEPENDENCIES =
83am__libeet_la_SOURCES_DIST = eet_alloc.c eet_lib.c eet_data.c \
84 eet_image.c eet_cipher.c eet_dictionary.c eet_node.c \
85 eet_utils.c eet_connection.c
86am__objects_1 = libeet_la-eet_alloc.lo libeet_la-eet_lib.lo \
87 libeet_la-eet_data.lo libeet_la-eet_image.lo \
88 libeet_la-eet_cipher.lo libeet_la-eet_dictionary.lo \
89 libeet_la-eet_node.lo libeet_la-eet_utils.lo \
90 libeet_la-eet_connection.lo
91@EET_AMALGAMATION_FALSE@am_libeet_la_OBJECTS = $(am__objects_1)
92@EET_AMALGAMATION_TRUE@nodist_libeet_la_OBJECTS = \
93@EET_AMALGAMATION_TRUE@ libeet_la-eet_amalgamation.lo
94libeet_la_OBJECTS = $(am_libeet_la_OBJECTS) \
95 $(nodist_libeet_la_OBJECTS)
96AM_V_lt = $(am__v_lt_$(V))
97am__v_lt_ = $(am__v_lt_$(AM_DEFAULT_VERBOSITY))
98am__v_lt_0 = --silent
99libeet_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
100 $(LIBTOOLFLAGS) --mode=link $(CCLD) $(libeet_la_CFLAGS) \
101 $(CFLAGS) $(libeet_la_LDFLAGS) $(LDFLAGS) -o $@
102DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)
103depcomp = $(SHELL) $(top_srcdir)/depcomp
104am__depfiles_maybe = depfiles
105am__mv = mv -f
106COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
107 $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
108LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
109 $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \
110 $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
111 $(AM_CFLAGS) $(CFLAGS)
112AM_V_CC = $(am__v_CC_$(V))
113am__v_CC_ = $(am__v_CC_$(AM_DEFAULT_VERBOSITY))
114am__v_CC_0 = @echo " CC " $@;
115AM_V_at = $(am__v_at_$(V))
116am__v_at_ = $(am__v_at_$(AM_DEFAULT_VERBOSITY))
117am__v_at_0 = @
118CCLD = $(CC)
119LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
120 $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
121 $(AM_LDFLAGS) $(LDFLAGS) -o $@
122AM_V_CCLD = $(am__v_CCLD_$(V))
123am__v_CCLD_ = $(am__v_CCLD_$(AM_DEFAULT_VERBOSITY))
124am__v_CCLD_0 = @echo " CCLD " $@;
125AM_V_GEN = $(am__v_GEN_$(V))
126am__v_GEN_ = $(am__v_GEN_$(AM_DEFAULT_VERBOSITY))
127am__v_GEN_0 = @echo " GEN " $@;
128SOURCES = $(libeet_la_SOURCES) $(nodist_libeet_la_SOURCES)
129DIST_SOURCES = $(am__libeet_la_SOURCES_DIST)
130HEADERS = $(includes_HEADERS)
131ETAGS = etags
132CTAGS = ctags
133DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
134ACLOCAL = @ACLOCAL@
135ALLOCA = @ALLOCA@
136AMTAR = @AMTAR@
137AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
138AR = @AR@
139AS = @AS@
140AUTOCONF = @AUTOCONF@
141AUTOHEADER = @AUTOHEADER@
142AUTOMAKE = @AUTOMAKE@
143AWK = @AWK@
144CC = @CC@
145CCDEPMODE = @CCDEPMODE@
146CFLAGS = @CFLAGS@
147CHECK_CFLAGS = @CHECK_CFLAGS@
148CHECK_LIBS = @CHECK_LIBS@
149CPP = @CPP@
150CPPFLAGS = @CPPFLAGS@
151CYGPATH_W = @CYGPATH_W@
152DEBUG_CFLAGS = @DEBUG_CFLAGS@
153DEFS = @DEFS@
154DEPDIR = @DEPDIR@
155DLLTOOL = @DLLTOOL@
156DSYMUTIL = @DSYMUTIL@
157DUMPBIN = @DUMPBIN@
158ECHO_C = @ECHO_C@
159ECHO_N = @ECHO_N@
160ECHO_T = @ECHO_T@
161EET_CFLAGS = @EET_CFLAGS@
162EET_CPPFLAGS = @EET_CPPFLAGS@
163EET_LIBS = @EET_LIBS@
164EET_PRG = @EET_PRG@
165EFL_COVERAGE_CFLAGS = @EFL_COVERAGE_CFLAGS@
166EFL_COVERAGE_LIBS = @EFL_COVERAGE_LIBS@
167EFL_EET_BUILD = @EFL_EET_BUILD@
168EFL_FNMATCH_LIBS = @EFL_FNMATCH_LIBS@
169EGREP = @EGREP@
170EINA_CFLAGS = @EINA_CFLAGS@
171EINA_LIBS = @EINA_LIBS@
172EVIL_CFLAGS = @EVIL_CFLAGS@
173EVIL_LIBS = @EVIL_LIBS@
174EXEEXT = @EXEEXT@
175EXOTIC_CFLAGS = @EXOTIC_CFLAGS@
176EXOTIC_LIBS = @EXOTIC_LIBS@
177FGREP = @FGREP@
178GNUTLS_CFLAGS = @GNUTLS_CFLAGS@
179GNUTLS_LIBS = @GNUTLS_LIBS@
180GREP = @GREP@
181INSTALL = @INSTALL@
182INSTALL_DATA = @INSTALL_DATA@
183INSTALL_PROGRAM = @INSTALL_PROGRAM@
184INSTALL_SCRIPT = @INSTALL_SCRIPT@
185INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
186LD = @LD@
187LDFLAGS = @LDFLAGS@
188LIBGCRYPT_CFLAGS = @LIBGCRYPT_CFLAGS@
189LIBGCRYPT_CONFIG = @LIBGCRYPT_CONFIG@
190LIBGCRYPT_LIBS = @LIBGCRYPT_LIBS@
191LIBOBJS = @LIBOBJS@
192LIBS = @LIBS@
193LIBTOOL = @LIBTOOL@
194LIPO = @LIPO@
195LN_S = @LN_S@
196LTLIBOBJS = @LTLIBOBJS@
197MAKEINFO = @MAKEINFO@
198MKDIR_P = @MKDIR_P@
199NM = @NM@
200NMEDIT = @NMEDIT@
201OBJDUMP = @OBJDUMP@
202OBJEXT = @OBJEXT@
203OPENSSL_CFLAGS = @OPENSSL_CFLAGS@
204OPENSSL_LIBS = @OPENSSL_LIBS@
205OTOOL = @OTOOL@
206OTOOL64 = @OTOOL64@
207PACKAGE = @PACKAGE@
208PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
209PACKAGE_NAME = @PACKAGE_NAME@
210PACKAGE_STRING = @PACKAGE_STRING@
211PACKAGE_TARNAME = @PACKAGE_TARNAME@
212PACKAGE_URL = @PACKAGE_URL@
213PACKAGE_VERSION = @PACKAGE_VERSION@
214PATH_SEPARATOR = @PATH_SEPARATOR@
215PKG_CONFIG = @PKG_CONFIG@
216PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@
217PKG_CONFIG_PATH = @PKG_CONFIG_PATH@
218RANLIB = @RANLIB@
219SED = @SED@
220SET_MAKE = @SET_MAKE@
221SHELL = @SHELL@
222STRIP = @STRIP@
223VERSION = @VERSION@
224VMAJ = @VMAJ@
225abs_builddir = @abs_builddir@
226abs_srcdir = @abs_srcdir@
227abs_top_builddir = @abs_top_builddir@
228abs_top_srcdir = @abs_top_srcdir@
229ac_ct_CC = @ac_ct_CC@
230ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
231am__include = @am__include@
232am__leading_dot = @am__leading_dot@
233am__quote = @am__quote@
234am__tar = @am__tar@
235am__untar = @am__untar@
236bindir = @bindir@
237build = @build@
238build_alias = @build_alias@
239build_cpu = @build_cpu@
240build_os = @build_os@
241build_vendor = @build_vendor@
242builddir = @builddir@
243datadir = @datadir@
244datarootdir = @datarootdir@
245docdir = @docdir@
246dvidir = @dvidir@
247efl_doxygen = @efl_doxygen@
248efl_have_doxygen = @efl_have_doxygen@
249exec_prefix = @exec_prefix@
250have_lcov = @have_lcov@
251host = @host@
252host_alias = @host_alias@
253host_cpu = @host_cpu@
254host_os = @host_os@
255host_vendor = @host_vendor@
256htmldir = @htmldir@
257includedir = @includedir@
258infodir = @infodir@
259install_sh = @install_sh@
260libdir = @libdir@
261libexecdir = @libexecdir@
262localedir = @localedir@
263localstatedir = @localstatedir@
264lt_ECHO = @lt_ECHO@
265lt_enable_auto_import = @lt_enable_auto_import@
266mandir = @mandir@
267mkdir_p = @mkdir_p@
268oldincludedir = @oldincludedir@
269pdfdir = @pdfdir@
270pkgconfig_requires_private = @pkgconfig_requires_private@
271prefix = @prefix@
272program_transform_name = @program_transform_name@
273psdir = @psdir@
274release_info = @release_info@
275requirement_eet = @requirement_eet@
276sbindir = @sbindir@
277sharedstatedir = @sharedstatedir@
278srcdir = @srcdir@
279sysconfdir = @sysconfdir@
280target_alias = @target_alias@
281top_build_prefix = @top_build_prefix@
282top_builddir = @top_builddir@
283top_srcdir = @top_srcdir@
284version_info = @version_info@
285MAINTAINERCLEANFILES = Makefile.in
286AM_CPPFLAGS = \
287-I. \
288-I$(top_srcdir)/src/lib \
289-I$(top_builddir)/src/lib \
290-DPACKAGE_BIN_DIR=\"$(bindir)\" \
291-DPACKAGE_LIB_DIR=\"$(libdir)\" \
292-DPACKAGE_DATA_DIR=\"$(datadir)/$(PACKAGE)\" \
293@EVIL_CFLAGS@ \
294@EINA_CFLAGS@ \
295@EET_CPPFLAGS@ \
296@EFL_EET_BUILD@ \
297@EFL_COVERAGE_CFLAGS@ \
298@OPENSSL_CFLAGS@ \
299@GNUTLS_CFLAGS@
300
301includes_HEADERS = Eet.h
302includesdir = $(includedir)/eet-@VMAJ@
303lib_LTLIBRARIES = libeet.la
304base_sources = \
305eet_alloc.c \
306eet_lib.c \
307eet_data.c \
308eet_image.c \
309eet_cipher.c \
310eet_dictionary.c \
311eet_node.c \
312eet_utils.c \
313eet_connection.c
314
315@EET_AMALGAMATION_TRUE@nodist_libeet_la_SOURCES = eet_amalgamation.c
316@EET_AMALGAMATION_FALSE@libeet_la_SOURCES = $(base_sources)
317libeet_la_CFLAGS = @EET_CFLAGS@ @DEBUG_CFLAGS@
318libeet_la_LIBADD = @GNUTLS_LIBS@ @OPENSSL_LIBS@ @EFL_COVERAGE_LIBS@ @EET_LIBS@ @EINA_LIBS@ @EVIL_LIBS@ -lz -ljpeg -lm
319libeet_la_LDFLAGS = -no-undefined @lt_enable_auto_import@ -version-info @version_info@ @release_info@
320EXTRA_DIST = Eet_private.h
321all: all-am
322
323.SUFFIXES:
324.SUFFIXES: .c .lo .o .obj
325$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
326 @for dep in $?; do \
327 case '$(am__configure_deps)' in \
328 *$$dep*) \
329 ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
330 && { if test -f $@; then exit 0; else break; fi; }; \
331 exit 1;; \
332 esac; \
333 done; \
334 echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu src/lib/Makefile'; \
335 $(am__cd) $(top_srcdir) && \
336 $(AUTOMAKE) --gnu src/lib/Makefile
337.PRECIOUS: Makefile
338Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
339 @case '$?' in \
340 *config.status*) \
341 cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
342 *) \
343 echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
344 cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
345 esac;
346
347$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
348 cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
349
350$(top_srcdir)/configure: $(am__configure_deps)
351 cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
352$(ACLOCAL_M4): $(am__aclocal_m4_deps)
353 cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
354$(am__aclocal_m4_deps):
355install-libLTLIBRARIES: $(lib_LTLIBRARIES)
356 @$(NORMAL_INSTALL)
357 test -z "$(libdir)" || $(MKDIR_P) "$(DESTDIR)$(libdir)"
358 @list='$(lib_LTLIBRARIES)'; test -n "$(libdir)" || list=; \
359 list2=; for p in $$list; do \
360 if test -f $$p; then \
361 list2="$$list2 $$p"; \
362 else :; fi; \
363 done; \
364 test -z "$$list2" || { \
365 echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 '$(DESTDIR)$(libdir)'"; \
366 $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 "$(DESTDIR)$(libdir)"; \
367 }
368
369uninstall-libLTLIBRARIES:
370 @$(NORMAL_UNINSTALL)
371 @list='$(lib_LTLIBRARIES)'; test -n "$(libdir)" || list=; \
372 for p in $$list; do \
373 $(am__strip_dir) \
374 echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(libdir)/$$f'"; \
375 $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(libdir)/$$f"; \
376 done
377
378clean-libLTLIBRARIES:
379 -test -z "$(lib_LTLIBRARIES)" || rm -f $(lib_LTLIBRARIES)
380 @list='$(lib_LTLIBRARIES)'; for p in $$list; do \
381 dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \
382 test "$$dir" != "$$p" || dir=.; \
383 echo "rm -f \"$${dir}/so_locations\""; \
384 rm -f "$${dir}/so_locations"; \
385 done
386libeet.la: $(libeet_la_OBJECTS) $(libeet_la_DEPENDENCIES)
387 $(AM_V_CCLD)$(libeet_la_LINK) -rpath $(libdir) $(libeet_la_OBJECTS) $(libeet_la_LIBADD) $(LIBS)
388
389mostlyclean-compile:
390 -rm -f *.$(OBJEXT)
391
392distclean-compile:
393 -rm -f *.tab.c
394
395@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libeet_la-eet_alloc.Plo@am__quote@
396@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libeet_la-eet_amalgamation.Plo@am__quote@
397@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libeet_la-eet_cipher.Plo@am__quote@
398@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libeet_la-eet_connection.Plo@am__quote@
399@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libeet_la-eet_data.Plo@am__quote@
400@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libeet_la-eet_dictionary.Plo@am__quote@
401@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libeet_la-eet_image.Plo@am__quote@
402@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libeet_la-eet_lib.Plo@am__quote@
403@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libeet_la-eet_node.Plo@am__quote@
404@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libeet_la-eet_utils.Plo@am__quote@
405
406.c.o:
407@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
408@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
409@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@
410@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
411@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
412@am__fastdepCC_FALSE@ $(COMPILE) -c $<
413
414.c.obj:
415@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
416@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
417@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@
418@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
419@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
420@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'`
421
422.c.lo:
423@am__fastdepCC_TRUE@ $(AM_V_CC)$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
424@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
425@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@
426@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
427@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
428@am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $<
429
430libeet_la-eet_alloc.lo: eet_alloc.c
431@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libeet_la_CFLAGS) $(CFLAGS) -MT libeet_la-eet_alloc.lo -MD -MP -MF $(DEPDIR)/libeet_la-eet_alloc.Tpo -c -o libeet_la-eet_alloc.lo `test -f 'eet_alloc.c' || echo '$(srcdir)/'`eet_alloc.c
432@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libeet_la-eet_alloc.Tpo $(DEPDIR)/libeet_la-eet_alloc.Plo
433@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@
434@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='eet_alloc.c' object='libeet_la-eet_alloc.lo' libtool=yes @AMDEPBACKSLASH@
435@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
436@am__fastdepCC_FALSE@ $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libeet_la_CFLAGS) $(CFLAGS) -c -o libeet_la-eet_alloc.lo `test -f 'eet_alloc.c' || echo '$(srcdir)/'`eet_alloc.c
437
438libeet_la-eet_lib.lo: eet_lib.c
439@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libeet_la_CFLAGS) $(CFLAGS) -MT libeet_la-eet_lib.lo -MD -MP -MF $(DEPDIR)/libeet_la-eet_lib.Tpo -c -o libeet_la-eet_lib.lo `test -f 'eet_lib.c' || echo '$(srcdir)/'`eet_lib.c
440@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libeet_la-eet_lib.Tpo $(DEPDIR)/libeet_la-eet_lib.Plo
441@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@
442@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='eet_lib.c' object='libeet_la-eet_lib.lo' libtool=yes @AMDEPBACKSLASH@
443@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
444@am__fastdepCC_FALSE@ $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libeet_la_CFLAGS) $(CFLAGS) -c -o libeet_la-eet_lib.lo `test -f 'eet_lib.c' || echo '$(srcdir)/'`eet_lib.c
445
446libeet_la-eet_data.lo: eet_data.c
447@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libeet_la_CFLAGS) $(CFLAGS) -MT libeet_la-eet_data.lo -MD -MP -MF $(DEPDIR)/libeet_la-eet_data.Tpo -c -o libeet_la-eet_data.lo `test -f 'eet_data.c' || echo '$(srcdir)/'`eet_data.c
448@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libeet_la-eet_data.Tpo $(DEPDIR)/libeet_la-eet_data.Plo
449@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@
450@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='eet_data.c' object='libeet_la-eet_data.lo' libtool=yes @AMDEPBACKSLASH@
451@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
452@am__fastdepCC_FALSE@ $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libeet_la_CFLAGS) $(CFLAGS) -c -o libeet_la-eet_data.lo `test -f 'eet_data.c' || echo '$(srcdir)/'`eet_data.c
453
454libeet_la-eet_image.lo: eet_image.c
455@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libeet_la_CFLAGS) $(CFLAGS) -MT libeet_la-eet_image.lo -MD -MP -MF $(DEPDIR)/libeet_la-eet_image.Tpo -c -o libeet_la-eet_image.lo `test -f 'eet_image.c' || echo '$(srcdir)/'`eet_image.c
456@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libeet_la-eet_image.Tpo $(DEPDIR)/libeet_la-eet_image.Plo
457@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@
458@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='eet_image.c' object='libeet_la-eet_image.lo' libtool=yes @AMDEPBACKSLASH@
459@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
460@am__fastdepCC_FALSE@ $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libeet_la_CFLAGS) $(CFLAGS) -c -o libeet_la-eet_image.lo `test -f 'eet_image.c' || echo '$(srcdir)/'`eet_image.c
461
462libeet_la-eet_cipher.lo: eet_cipher.c
463@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libeet_la_CFLAGS) $(CFLAGS) -MT libeet_la-eet_cipher.lo -MD -MP -MF $(DEPDIR)/libeet_la-eet_cipher.Tpo -c -o libeet_la-eet_cipher.lo `test -f 'eet_cipher.c' || echo '$(srcdir)/'`eet_cipher.c
464@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libeet_la-eet_cipher.Tpo $(DEPDIR)/libeet_la-eet_cipher.Plo
465@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@
466@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='eet_cipher.c' object='libeet_la-eet_cipher.lo' libtool=yes @AMDEPBACKSLASH@
467@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
468@am__fastdepCC_FALSE@ $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libeet_la_CFLAGS) $(CFLAGS) -c -o libeet_la-eet_cipher.lo `test -f 'eet_cipher.c' || echo '$(srcdir)/'`eet_cipher.c
469
470libeet_la-eet_dictionary.lo: eet_dictionary.c
471@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libeet_la_CFLAGS) $(CFLAGS) -MT libeet_la-eet_dictionary.lo -MD -MP -MF $(DEPDIR)/libeet_la-eet_dictionary.Tpo -c -o libeet_la-eet_dictionary.lo `test -f 'eet_dictionary.c' || echo '$(srcdir)/'`eet_dictionary.c
472@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libeet_la-eet_dictionary.Tpo $(DEPDIR)/libeet_la-eet_dictionary.Plo
473@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@
474@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='eet_dictionary.c' object='libeet_la-eet_dictionary.lo' libtool=yes @AMDEPBACKSLASH@
475@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
476@am__fastdepCC_FALSE@ $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libeet_la_CFLAGS) $(CFLAGS) -c -o libeet_la-eet_dictionary.lo `test -f 'eet_dictionary.c' || echo '$(srcdir)/'`eet_dictionary.c
477
478libeet_la-eet_node.lo: eet_node.c
479@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libeet_la_CFLAGS) $(CFLAGS) -MT libeet_la-eet_node.lo -MD -MP -MF $(DEPDIR)/libeet_la-eet_node.Tpo -c -o libeet_la-eet_node.lo `test -f 'eet_node.c' || echo '$(srcdir)/'`eet_node.c
480@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libeet_la-eet_node.Tpo $(DEPDIR)/libeet_la-eet_node.Plo
481@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@
482@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='eet_node.c' object='libeet_la-eet_node.lo' libtool=yes @AMDEPBACKSLASH@
483@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
484@am__fastdepCC_FALSE@ $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libeet_la_CFLAGS) $(CFLAGS) -c -o libeet_la-eet_node.lo `test -f 'eet_node.c' || echo '$(srcdir)/'`eet_node.c
485
486libeet_la-eet_utils.lo: eet_utils.c
487@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libeet_la_CFLAGS) $(CFLAGS) -MT libeet_la-eet_utils.lo -MD -MP -MF $(DEPDIR)/libeet_la-eet_utils.Tpo -c -o libeet_la-eet_utils.lo `test -f 'eet_utils.c' || echo '$(srcdir)/'`eet_utils.c
488@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libeet_la-eet_utils.Tpo $(DEPDIR)/libeet_la-eet_utils.Plo
489@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@
490@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='eet_utils.c' object='libeet_la-eet_utils.lo' libtool=yes @AMDEPBACKSLASH@
491@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
492@am__fastdepCC_FALSE@ $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libeet_la_CFLAGS) $(CFLAGS) -c -o libeet_la-eet_utils.lo `test -f 'eet_utils.c' || echo '$(srcdir)/'`eet_utils.c
493
494libeet_la-eet_connection.lo: eet_connection.c
495@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libeet_la_CFLAGS) $(CFLAGS) -MT libeet_la-eet_connection.lo -MD -MP -MF $(DEPDIR)/libeet_la-eet_connection.Tpo -c -o libeet_la-eet_connection.lo `test -f 'eet_connection.c' || echo '$(srcdir)/'`eet_connection.c
496@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libeet_la-eet_connection.Tpo $(DEPDIR)/libeet_la-eet_connection.Plo
497@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@
498@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='eet_connection.c' object='libeet_la-eet_connection.lo' libtool=yes @AMDEPBACKSLASH@
499@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
500@am__fastdepCC_FALSE@ $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libeet_la_CFLAGS) $(CFLAGS) -c -o libeet_la-eet_connection.lo `test -f 'eet_connection.c' || echo '$(srcdir)/'`eet_connection.c
501
502libeet_la-eet_amalgamation.lo: eet_amalgamation.c
503@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libeet_la_CFLAGS) $(CFLAGS) -MT libeet_la-eet_amalgamation.lo -MD -MP -MF $(DEPDIR)/libeet_la-eet_amalgamation.Tpo -c -o libeet_la-eet_amalgamation.lo `test -f 'eet_amalgamation.c' || echo '$(srcdir)/'`eet_amalgamation.c
504@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libeet_la-eet_amalgamation.Tpo $(DEPDIR)/libeet_la-eet_amalgamation.Plo
505@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@
506@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='eet_amalgamation.c' object='libeet_la-eet_amalgamation.lo' libtool=yes @AMDEPBACKSLASH@
507@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
508@am__fastdepCC_FALSE@ $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libeet_la_CFLAGS) $(CFLAGS) -c -o libeet_la-eet_amalgamation.lo `test -f 'eet_amalgamation.c' || echo '$(srcdir)/'`eet_amalgamation.c
509
510mostlyclean-libtool:
511 -rm -f *.lo
512
513clean-libtool:
514 -rm -rf .libs _libs
515install-includesHEADERS: $(includes_HEADERS)
516 @$(NORMAL_INSTALL)
517 test -z "$(includesdir)" || $(MKDIR_P) "$(DESTDIR)$(includesdir)"
518 @list='$(includes_HEADERS)'; test -n "$(includesdir)" || list=; \
519 for p in $$list; do \
520 if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
521 echo "$$d$$p"; \
522 done | $(am__base_list) | \
523 while read files; do \
524 echo " $(INSTALL_HEADER) $$files '$(DESTDIR)$(includesdir)'"; \
525 $(INSTALL_HEADER) $$files "$(DESTDIR)$(includesdir)" || exit $$?; \
526 done
527
528uninstall-includesHEADERS:
529 @$(NORMAL_UNINSTALL)
530 @list='$(includes_HEADERS)'; test -n "$(includesdir)" || list=; \
531 files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \
532 test -n "$$files" || exit 0; \
533 echo " ( cd '$(DESTDIR)$(includesdir)' && rm -f" $$files ")"; \
534 cd "$(DESTDIR)$(includesdir)" && rm -f $$files
535
536ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
537 list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
538 unique=`for i in $$list; do \
539 if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
540 done | \
541 $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
542 END { if (nonempty) { for (i in files) print i; }; }'`; \
543 mkid -fID $$unique
544tags: TAGS
545
546TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
547 $(TAGS_FILES) $(LISP)
548 set x; \
549 here=`pwd`; \
550 list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
551 unique=`for i in $$list; do \
552 if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
553 done | \
554 $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
555 END { if (nonempty) { for (i in files) print i; }; }'`; \
556 shift; \
557 if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
558 test -n "$$unique" || unique=$$empty_fix; \
559 if test $$# -gt 0; then \
560 $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
561 "$$@" $$unique; \
562 else \
563 $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
564 $$unique; \
565 fi; \
566 fi
567ctags: CTAGS
568CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
569 $(TAGS_FILES) $(LISP)
570 list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
571 unique=`for i in $$list; do \
572 if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
573 done | \
574 $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
575 END { if (nonempty) { for (i in files) print i; }; }'`; \
576 test -z "$(CTAGS_ARGS)$$unique" \
577 || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
578 $$unique
579
580GTAGS:
581 here=`$(am__cd) $(top_builddir) && pwd` \
582 && $(am__cd) $(top_srcdir) \
583 && gtags -i $(GTAGS_ARGS) "$$here"
584
585distclean-tags:
586 -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
587
588distdir: $(DISTFILES)
589 @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
590 topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
591 list='$(DISTFILES)'; \
592 dist_files=`for file in $$list; do echo $$file; done | \
593 sed -e "s|^$$srcdirstrip/||;t" \
594 -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
595 case $$dist_files in \
596 */*) $(MKDIR_P) `echo "$$dist_files" | \
597 sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
598 sort -u` ;; \
599 esac; \
600 for file in $$dist_files; do \
601 if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
602 if test -d $$d/$$file; then \
603 dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
604 if test -d "$(distdir)/$$file"; then \
605 find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
606 fi; \
607 if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
608 cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
609 find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
610 fi; \
611 cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
612 else \
613 test -f "$(distdir)/$$file" \
614 || cp -p $$d/$$file "$(distdir)/$$file" \
615 || exit 1; \
616 fi; \
617 done
618check-am: all-am
619check: check-am
620all-am: Makefile $(LTLIBRARIES) $(HEADERS)
621installdirs:
622 for dir in "$(DESTDIR)$(libdir)" "$(DESTDIR)$(includesdir)"; do \
623 test -z "$$dir" || $(MKDIR_P) "$$dir"; \
624 done
625install: install-am
626install-exec: install-exec-am
627install-data: install-data-am
628uninstall: uninstall-am
629
630install-am: all-am
631 @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
632
633installcheck: installcheck-am
634install-strip:
635 $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
636 install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
637 `test -z '$(STRIP)' || \
638 echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
639mostlyclean-generic:
640
641clean-generic:
642
643distclean-generic:
644 -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
645 -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
646
647maintainer-clean-generic:
648 @echo "This command is intended for maintainers to use"
649 @echo "it deletes files that may require special tools to rebuild."
650 -test -z "$(MAINTAINERCLEANFILES)" || rm -f $(MAINTAINERCLEANFILES)
651clean: clean-am
652
653clean-am: clean-generic clean-libLTLIBRARIES clean-libtool clean-local \
654 mostlyclean-am
655
656distclean: distclean-am
657 -rm -rf ./$(DEPDIR)
658 -rm -f Makefile
659distclean-am: clean-am distclean-compile distclean-generic \
660 distclean-tags
661
662dvi: dvi-am
663
664dvi-am:
665
666html: html-am
667
668html-am:
669
670info: info-am
671
672info-am:
673
674install-data-am: install-includesHEADERS
675
676install-dvi: install-dvi-am
677
678install-dvi-am:
679
680install-exec-am: install-libLTLIBRARIES
681
682install-html: install-html-am
683
684install-html-am:
685
686install-info: install-info-am
687
688install-info-am:
689
690install-man:
691
692install-pdf: install-pdf-am
693
694install-pdf-am:
695
696install-ps: install-ps-am
697
698install-ps-am:
699
700installcheck-am:
701
702maintainer-clean: maintainer-clean-am
703 -rm -rf ./$(DEPDIR)
704 -rm -f Makefile
705maintainer-clean-am: distclean-am maintainer-clean-generic
706
707mostlyclean: mostlyclean-am
708
709mostlyclean-am: mostlyclean-compile mostlyclean-generic \
710 mostlyclean-libtool
711
712pdf: pdf-am
713
714pdf-am:
715
716ps: ps-am
717
718ps-am:
719
720uninstall-am: uninstall-includesHEADERS uninstall-libLTLIBRARIES
721
722.MAKE: install-am install-strip
723
724.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \
725 clean-libLTLIBRARIES clean-libtool clean-local ctags distclean \
726 distclean-compile distclean-generic distclean-libtool \
727 distclean-tags distdir dvi dvi-am html html-am info info-am \
728 install install-am install-data install-data-am install-dvi \
729 install-dvi-am install-exec install-exec-am install-html \
730 install-html-am install-includesHEADERS install-info \
731 install-info-am install-libLTLIBRARIES install-man install-pdf \
732 install-pdf-am install-ps install-ps-am install-strip \
733 installcheck installcheck-am installdirs maintainer-clean \
734 maintainer-clean-generic mostlyclean mostlyclean-compile \
735 mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
736 tags uninstall uninstall-am uninstall-includesHEADERS \
737 uninstall-libLTLIBRARIES
738
739
740@EET_AMALGAMATION_TRUE@eet_amalgamation.c: $(base_sources) Makefile
741@EET_AMALGAMATION_TRUE@ -rm -f eet_amalgamation.c
742
743@EET_AMALGAMATION_TRUE@ @echo "#ifdef HAVE_CONFIG_H" >> eet_amalgamation.c
744@EET_AMALGAMATION_TRUE@ @echo "# include \"config.h\"" >> eet_amalgamation.c
745@EET_AMALGAMATION_TRUE@ @echo "#endif" >> eet_amalgamation.c
746
747@EET_AMALGAMATION_TRUE@ @echo "#ifdef HAVE_ALLOCA_H" >> eet_amalgamation.c
748@EET_AMALGAMATION_TRUE@ @echo "# include <alloca.h>" >> eet_amalgamation.c
749@EET_AMALGAMATION_TRUE@ @echo "#elif defined __GNUC__" >> eet_amalgamation.c
750@EET_AMALGAMATION_TRUE@ @echo "# define alloca __builtin_alloca" >> eet_amalgamation.c
751@EET_AMALGAMATION_TRUE@ @echo "#elif defined _AIX" >> eet_amalgamation.c
752@EET_AMALGAMATION_TRUE@ @echo "# define alloca __alloca" >> eet_amalgamation.c
753@EET_AMALGAMATION_TRUE@ @echo "#elif defined _MSC_VER" >> eet_amalgamation.c
754@EET_AMALGAMATION_TRUE@ @echo "# include <malloc.h>" >> eet_amalgamation.c
755@EET_AMALGAMATION_TRUE@ @echo "# define alloca _alloca" >> eet_amalgamation.c
756@EET_AMALGAMATION_TRUE@ @echo "#else" >> eet_amalgamation.c
757@EET_AMALGAMATION_TRUE@ @echo "# include <stddef.h>" >> eet_amalgamation.c
758@EET_AMALGAMATION_TRUE@ @echo "# ifdef __cplusplus" >> eet_amalgamation.c
759@EET_AMALGAMATION_TRUE@ @echo "#extern \"C\"" >> eet_amalgamation.c
760@EET_AMALGAMATION_TRUE@ @echo "# endif" >> eet_amalgamation.c
761@EET_AMALGAMATION_TRUE@ @echo "#void *alloca (size_t);" >> eet_amalgamation.c
762@EET_AMALGAMATION_TRUE@ @echo "#endif" >> eet_amalgamation.c
763
764@EET_AMALGAMATION_TRUE@ @echo "#include <stdio.h>" >> eet_amalgamation.c
765@EET_AMALGAMATION_TRUE@ @echo "#include <string.h>" >> eet_amalgamation.c
766@EET_AMALGAMATION_TRUE@ @echo "#include <math.h>" >> eet_amalgamation.c
767@EET_AMALGAMATION_TRUE@ @echo "#include <ctype.h>" >> eet_amalgamation.c
768@EET_AMALGAMATION_TRUE@ @echo "#include <limits.h>" >> eet_amalgamation.c
769@EET_AMALGAMATION_TRUE@ @echo "#include <sys/types.h>" >> eet_amalgamation.c
770@EET_AMALGAMATION_TRUE@ @echo "#include <sys/stat.h>" >> eet_amalgamation.c
771@EET_AMALGAMATION_TRUE@ @echo "#ifdef HAVE_SIGNATURE" >> eet_amalgamation.c
772@EET_AMALGAMATION_TRUE@ @echo "# include <sys/mman.h>" >> eet_amalgamation.c
773@EET_AMALGAMATION_TRUE@ @echo "#endif" >> eet_amalgamation.c
774@EET_AMALGAMATION_TRUE@ @echo "#include <setjmp.h>" >> eet_amalgamation.c
775@EET_AMALGAMATION_TRUE@ @echo "#include <errno.h>" >> eet_amalgamation.c
776@EET_AMALGAMATION_TRUE@ @echo "#include <time.h>" >> eet_amalgamation.c
777@EET_AMALGAMATION_TRUE@ @echo "#include <fnmatch.h>" >> eet_amalgamation.c
778@EET_AMALGAMATION_TRUE@ @echo "#include <fcntl.h>" >> eet_amalgamation.c
779
780@EET_AMALGAMATION_TRUE@ @echo "#ifdef _WIN32" >> eet_amalgamation.c
781@EET_AMALGAMATION_TRUE@ @echo "# include <winsock2.h>" >> eet_amalgamation.c
782@EET_AMALGAMATION_TRUE@ @echo "#endif" >> eet_amalgamation.c
783
784@EET_AMALGAMATION_TRUE@ @echo "#ifndef _MSC_VER" >> eet_amalgamation.c
785@EET_AMALGAMATION_TRUE@ @echo "# include <unistd.h>" >> eet_amalgamation.c
786@EET_AMALGAMATION_TRUE@ @echo "#endif" >> eet_amalgamation.c
787
788@EET_AMALGAMATION_TRUE@ @echo "#ifdef HAVE_NETINET_IN_H" >> eet_amalgamation.c
789@EET_AMALGAMATION_TRUE@ @echo "# include <netinet/in.h>" >> eet_amalgamation.c
790@EET_AMALGAMATION_TRUE@ @echo "#endif" >> eet_amalgamation.c
791
792@EET_AMALGAMATION_TRUE@ @echo "#ifdef HAVE_GNUTLS" >> eet_amalgamation.c
793@EET_AMALGAMATION_TRUE@ @echo "# include <gnutls/gnutls.h>" >> eet_amalgamation.c
794@EET_AMALGAMATION_TRUE@ @echo "# include <gcrypt.h>" >> eet_amalgamation.c
795@EET_AMALGAMATION_TRUE@ @echo "#endif" >> eet_amalgamation.c
796
797@EET_AMALGAMATION_TRUE@ @echo "#ifdef HAVE_OPENSSL" >> eet_amalgamation.c
798@EET_AMALGAMATION_TRUE@ @echo "# include <openssl/err.h>" >> eet_amalgamation.c
799@EET_AMALGAMATION_TRUE@ @echo "# include <openssl/evp.h>" >> eet_amalgamation.c
800@EET_AMALGAMATION_TRUE@ @echo "# include <openssl/sha.h>" >> eet_amalgamation.c
801@EET_AMALGAMATION_TRUE@ @echo "#endif" >> eet_amalgamation.c
802
803@EET_AMALGAMATION_TRUE@ @echo "#ifdef HAVE_SIGNATURE" >> eet_amalgamation.c
804@EET_AMALGAMATION_TRUE@ @echo "# ifdef HAVE_GNUTLS" >> eet_amalgamation.c
805@EET_AMALGAMATION_TRUE@ @echo "# include <gnutls/gnutls.h>" >> eet_amalgamation.c
806@EET_AMALGAMATION_TRUE@ @echo "# include <gnutls/x509.h>" >> eet_amalgamation.c
807@EET_AMALGAMATION_TRUE@ @echo "# else" >> eet_amalgamation.c
808@EET_AMALGAMATION_TRUE@ @echo "# include <openssl/rsa.h>" >> eet_amalgamation.c
809@EET_AMALGAMATION_TRUE@ @echo "# include <openssl/objects.h>" >> eet_amalgamation.c
810@EET_AMALGAMATION_TRUE@ @echo "# include <openssl/err.h>" >> eet_amalgamation.c
811@EET_AMALGAMATION_TRUE@ @echo "# include <openssl/ssl.h>" >> eet_amalgamation.c
812@EET_AMALGAMATION_TRUE@ @echo "# include <openssl/dh.h>" >> eet_amalgamation.c
813@EET_AMALGAMATION_TRUE@ @echo "# include <openssl/dsa.h>" >> eet_amalgamation.c
814@EET_AMALGAMATION_TRUE@ @echo "# include <openssl/evp.h>" >> eet_amalgamation.c
815@EET_AMALGAMATION_TRUE@ @echo "# include <openssl/x509.h>" >> eet_amalgamation.c
816@EET_AMALGAMATION_TRUE@ @echo "# include <openssl/pem.h>" >> eet_amalgamation.c
817@EET_AMALGAMATION_TRUE@ @echo "# endif" >> eet_amalgamation.c
818@EET_AMALGAMATION_TRUE@ @echo "#endif" >> eet_amalgamation.c
819
820@EET_AMALGAMATION_TRUE@ @echo "#ifdef HAVE_CIPHER" >> eet_amalgamation.c
821@EET_AMALGAMATION_TRUE@ @echo "# ifdef HAVE_GNUTLS" >> eet_amalgamation.c
822@EET_AMALGAMATION_TRUE@ @echo "# include <gnutls/x509.h>" >> eet_amalgamation.c
823@EET_AMALGAMATION_TRUE@ @echo "# include <gcrypt.h>" >> eet_amalgamation.c
824@EET_AMALGAMATION_TRUE@ @echo "# else" >> eet_amalgamation.c
825@EET_AMALGAMATION_TRUE@ @echo "# include <openssl/evp.h>" >> eet_amalgamation.c
826@EET_AMALGAMATION_TRUE@ @echo "# include <openssl/hmac.h>" >> eet_amalgamation.c
827@EET_AMALGAMATION_TRUE@ @echo "# include <openssl/rand.h>" >> eet_amalgamation.c
828@EET_AMALGAMATION_TRUE@ @echo "# endif" >> eet_amalgamation.c
829@EET_AMALGAMATION_TRUE@ @echo "#endif" >> eet_amalgamation.c
830
831@EET_AMALGAMATION_TRUE@ @echo "#include <zlib.h>" >> eet_amalgamation.c
832@EET_AMALGAMATION_TRUE@ @echo "#include <jpeglib.h>" >> eet_amalgamation.c
833
834@EET_AMALGAMATION_TRUE@ @echo "#ifdef HAVE_EVIL" >> eet_amalgamation.c
835@EET_AMALGAMATION_TRUE@ @echo "# include <Evil.h>" >> eet_amalgamation.c
836@EET_AMALGAMATION_TRUE@ @echo "#endif" >> eet_amalgamation.c
837
838@EET_AMALGAMATION_TRUE@ @echo "#include <Eet.h>" >> eet_amalgamation.c
839
840@EET_AMALGAMATION_TRUE@ @echo "#include \"Eet_private.h\"" >> eet_amalgamation.c
841@EET_AMALGAMATION_TRUE@ @echo "#include \"Eet.h\"" >> eet_amalgamation.c
842
843@EET_AMALGAMATION_TRUE@ @for f in $(base_sources); do \
844@EET_AMALGAMATION_TRUE@ if [ `echo $$f | sed -e 's/^...\(.\).*/\1/'` != '/' ]; then \
845@EET_AMALGAMATION_TRUE@ file="$(srcdir)/$$f" ; \
846@EET_AMALGAMATION_TRUE@ else \
847@EET_AMALGAMATION_TRUE@ file="$$f" ; \
848@EET_AMALGAMATION_TRUE@ fi ; \
849@EET_AMALGAMATION_TRUE@ echo "/* file: $$file */" >> eet_amalgamation.c; \
850@EET_AMALGAMATION_TRUE@ grep -v -e '^# *include \+.\(config\|\|Evil\|Eina\|stdio\|string\|math\|ctype\|limits\|sys/types\|sys/stat\|sys/mman\|setjmp\|errno\|time\|fnmatch\|fcntl\|winsock2\|unistd\|netinet/in\|gnutls/gnutls\|gcrypt\|gnutls/x509\|openssl/rsa\|openssl/objects\|openssl/err\|openssl/ssl\|openssl/dh\|openssl/dsa\|openssl/evp\|openssl/pem\|openssl/sha\|openssl/hmac\|openssl/x509\|openssl/rand\|zlib\|jpeglib\|Eet_private\|Eet\)[.]h.*' $$file >> eet_amalgamation.c; \
851@EET_AMALGAMATION_TRUE@ done
852@EET_AMALGAMATION_TRUE@ @echo "eet_amalgamation.c generated"
853
854clean-local:
855 @rm -rf *.gcno eet_amalgamation.c
856
857# Tell versions [3.59,3.63) of GNU make to not export all variables.
858# Otherwise a system limit (for SysV at least) may be exceeded.
859.NOEXPORT:
diff --git a/libraries/eet/src/lib/eet_alloc.c b/libraries/eet/src/lib/eet_alloc.c
deleted file mode 100644
index 29e276c..0000000
--- a/libraries/eet/src/lib/eet_alloc.c
+++ /dev/null
@@ -1,93 +0,0 @@
1#ifdef HAVE_CONFIG_H
2# include "config.h"
3#endif
4
5#include <Eina.h>
6
7#include "Eet.h"
8#include "Eet_private.h"
9
10typedef struct _Eet_Mempool Eet_Mempool;
11struct _Eet_Mempool
12{
13 const char *name;
14 Eina_Mempool *mp;
15 size_t size;
16};
17
18#define GENERIC_ALLOC_FREE(TYPE, Type) \
19 Eet_Mempool Type##_mp = { #TYPE, NULL, sizeof (TYPE) }; \
20 \
21 TYPE * \
22 Type##_malloc(unsigned int num) \
23 { \
24 return eina_mempool_malloc(Type##_mp.mp, num * sizeof (TYPE)); \
25 } \
26 TYPE * \
27 Type##_calloc(unsigned int num) \
28 { \
29 return eina_mempool_calloc(Type##_mp.mp, num * sizeof (TYPE)); \
30 } \
31 void \
32 Type##_mp_free(TYPE *e) \
33 { \
34 eina_mempool_free(Type##_mp.mp, e); \
35 }
36
37GENERIC_ALLOC_FREE(Eet_File_Directory, eet_file_directory);
38GENERIC_ALLOC_FREE(Eet_File_Node, eet_file_node);
39GENERIC_ALLOC_FREE(Eet_File_Header, eet_file_header);
40GENERIC_ALLOC_FREE(Eet_Dictionary, eet_dictionary);
41GENERIC_ALLOC_FREE(Eet_File, eet_file);
42
43static Eet_Mempool *mempool_array[] = {
44 &eet_file_directory_mp,
45 &eet_file_node_mp,
46 &eet_file_header_mp,
47 &eet_dictionary_mp,
48 &eet_file_mp,
49};
50
51Eina_Bool
52eet_mempool_init(void)
53{
54 const char *choice;
55 unsigned int i;
56
57 choice = getenv("EINA_MEMPOOL");
58 if ((!choice) || (!choice[0]))
59 choice = "chained_mempool";
60
61 for (i = 0; i < sizeof (mempool_array) / sizeof (mempool_array[0]); ++i)
62 {
63 retry:
64 mempool_array[i]->mp = eina_mempool_add(choice, mempool_array[i]->name, NULL, mempool_array[i]->size, 64);
65 if (!mempool_array[i]->mp)
66 {
67 if (!strcmp(choice, "pass_through"))
68 {
69 ERR("Falling back to pass through ! Previously tried '%s' mempool.", choice);
70 choice = "pass_through";
71 goto retry;
72 }
73 else
74 {
75 ERR("Impossible to allocate mempool '%s' !", choice);
76 return EINA_FALSE;
77 }
78 }
79 }
80 return EINA_TRUE;
81}
82
83void
84eet_mempool_shutdown(void)
85{
86 unsigned int i;
87
88 for (i = 0; i < sizeof (mempool_array) / sizeof (mempool_array[0]); ++i)
89 {
90 eina_mempool_del(mempool_array[i]->mp);
91 mempool_array[i]->mp = NULL;
92 }
93}
diff --git a/libraries/eet/src/lib/eet_cipher.c b/libraries/eet/src/lib/eet_cipher.c
deleted file mode 100644
index 2425e22..0000000
--- a/libraries/eet/src/lib/eet_cipher.c
+++ /dev/null
@@ -1,1387 +0,0 @@
1#ifdef HAVE_CONFIG_H
2# include <config.h>
3#endif /* ifdef HAVE_CONFIG_H */
4
5#ifdef HAVE_ALLOCA_H
6# include <alloca.h>
7#elif defined __GNUC__
8# define alloca __builtin_alloca
9#elif defined _AIX
10# define alloca __alloca
11#elif defined _MSC_VER
12# include <malloc.h>
13# define alloca _alloca
14#else /* ifdef HAVE_ALLOCA_H */
15# include <stddef.h>
16# ifdef __cplusplus
17extern "C"
18# endif /* ifdef __cplusplus */
19void *alloca(size_t);
20#endif /* ifdef HAVE_ALLOCA_H */
21
22#include <stdio.h>
23#include <string.h>
24#include <sys/types.h>
25#include <sys/stat.h>
26
27#ifdef HAVE_UNISTD_H
28# include <unistd.h>
29#endif /* ifdef HAVE_UNISTD_H */
30
31#ifdef HAVE_NETINET_IN_H
32# include <netinet/in.h>
33#endif /* ifdef HAVE_NETINET_IN_H */
34
35#ifdef HAVE_SIGNATURE
36# include <sys/mman.h>
37# ifdef HAVE_GNUTLS
38# include <gnutls/gnutls.h>
39# include <gnutls/x509.h>
40# else /* ifdef HAVE_GNUTLS */
41# include <openssl/rsa.h>
42# include <openssl/objects.h>
43# include <openssl/err.h>
44# include <openssl/ssl.h>
45# include <openssl/dh.h>
46# include <openssl/dsa.h>
47# include <openssl/evp.h>
48# include <openssl/x509.h>
49# include <openssl/pem.h>
50# endif /* ifdef HAVE_GNUTLS */
51#endif /* ifdef HAVE_SIGNATURE */
52
53#ifdef HAVE_OPENSSL
54# include <openssl/sha.h>
55#endif /* ifdef HAVE_OPENSSL */
56
57#ifdef HAVE_CIPHER
58# ifdef HAVE_GNUTLS
59# if defined EET_USE_NEW_PUBKEY_VERIFY_HASH || defined EET_USE_NEW_PRIVKEY_SIGN_DATA
60# include <gnutls/abstract.h>
61# endif
62# include <gnutls/x509.h>
63# include <gcrypt.h>
64# else /* ifdef HAVE_GNUTLS */
65# include <openssl/evp.h>
66# include <openssl/hmac.h>
67# include <openssl/rand.h>
68# endif /* ifdef HAVE_GNUTLS */
69#endif /* ifdef HAVE_CIPHER */
70
71#include "Eet.h"
72#include "Eet_private.h"
73
74#define EET_MAGIC_SIGN 0x1ee74271
75
76#ifdef HAVE_GNUTLS
77# define MAX_KEY_LEN 32
78# define MAX_IV_LEN 16
79#else /* ifdef HAVE_GNUTLS */
80# define MAX_KEY_LEN EVP_MAX_KEY_LENGTH
81# define MAX_IV_LEN EVP_MAX_IV_LENGTH
82#endif /* ifdef HAVE_GNUTLS */
83
84#ifdef HAVE_CIPHER
85# ifdef HAVE_GNUTLS
86static Eet_Error
87eet_hmac_sha1(const void *key,
88 size_t key_len,
89 const void *data,
90 size_t data_len,
91 unsigned char *res);
92# endif /* ifdef HAVE_GNUTLS */
93static Eet_Error
94eet_pbkdf2_sha1(const char *key,
95 int key_len,
96 const unsigned char *salt,
97 unsigned int salt_len,
98 int iter,
99 unsigned char *res,
100 int res_len);
101#endif /* ifdef HAVE_CIPHER */
102
103struct _Eet_Key
104{
105 int references;
106#ifdef HAVE_SIGNATURE
107# ifdef HAVE_GNUTLS
108 gnutls_x509_crt_t certificate;
109 gnutls_x509_privkey_t private_key;
110# else /* ifdef HAVE_GNUTLS */
111 X509 *certificate;
112 EVP_PKEY *private_key;
113# endif /* ifdef HAVE_GNUTLS */
114#endif /* ifdef HAVE_SIGNATURE */
115};
116
117EAPI Eet_Key *
118eet_identity_open(const char *certificate_file,
119 const char *private_key_file,
120 Eet_Key_Password_Callback cb)
121{
122#ifdef HAVE_SIGNATURE
123 /* Signature declarations */
124 Eet_Key *key = NULL;
125# ifdef HAVE_GNUTLS
126 /* Gnutls private declarations */
127 Eina_File *f = NULL;
128 void *data = NULL;
129 gnutls_datum_t load_file = { NULL, 0 };
130 char pass[1024];
131
132 /* Init */
133 if (!(key = malloc(sizeof(Eet_Key))))
134 goto on_error;
135
136 key->references = 1;
137
138 if (gnutls_x509_crt_init(&(key->certificate)))
139 goto on_error;
140
141 if (gnutls_x509_privkey_init(&(key->private_key)))
142 goto on_error;
143
144 /* Mmap certificate_file */
145 f = eina_file_open(certificate_file, 0);
146 if (!f)
147 goto on_error;
148
149 /* let's make mmap safe and just get 0 pages for IO erro */
150 eina_mmap_safety_enabled_set(EINA_TRUE);
151
152 data = eina_file_map_all(f, EINA_FILE_SEQUENTIAL);
153 if (!data) goto on_error;
154
155 /* Import the certificate in Eet_Key structure */
156 load_file.data = data;
157 load_file.size = eina_file_size_get(f);
158 if (gnutls_x509_crt_import(key->certificate, &load_file,
159 GNUTLS_X509_FMT_PEM) < 0)
160 goto on_error;
161
162 eina_file_map_free(f, data);
163
164 /* Reset values */
165 eina_file_close(f);
166 f = NULL;
167 data = NULL;
168 load_file.data = NULL;
169 load_file.size = 0;
170
171 /* Mmap private_key_file */
172 f = eina_file_open(private_key_file, 0);
173 if (!f)
174 goto on_error;
175
176 /* let's make mmap safe and just get 0 pages for IO erro */
177 eina_mmap_safety_enabled_set(EINA_TRUE);
178
179 data = eina_file_map_all(f, EINA_FILE_SEQUENTIAL);
180 if (!data)
181 goto on_error;
182
183 /* Import the private key in Eet_Key structure */
184 load_file.data = data;
185 load_file.size = eina_file_size_get(f);
186 /* Try to directly import the PEM encoded private key */
187 if (gnutls_x509_privkey_import(key->private_key, &load_file,
188 GNUTLS_X509_FMT_PEM) < 0)
189 {
190 /* Else ask for the private key pass */
191 if (cb && cb(pass, 1024, 0, NULL))
192 {
193 /* If pass then try to decode the pkcs 8 private key */
194 if (gnutls_x509_privkey_import_pkcs8(key->private_key, &load_file,
195 GNUTLS_X509_FMT_PEM, pass, 0))
196 goto on_error;
197 }
198 else
199 /* Else try to import the pkcs 8 private key without pass */
200 if (gnutls_x509_privkey_import_pkcs8(key->private_key, &load_file,
201 GNUTLS_X509_FMT_PEM, NULL, 1))
202 goto on_error;
203 }
204
205 eina_file_map_free(f, data);
206 eina_file_close(f);
207
208 return key;
209
210on_error:
211 if (data) eina_file_map_free(f, data);
212 if (f) eina_file_close(f);
213
214 if (key)
215 {
216 if (key->certificate)
217 gnutls_x509_crt_deinit(key->certificate);
218
219 if (key->private_key)
220 gnutls_x509_privkey_deinit(key->private_key);
221
222 free(key);
223 }
224
225# else /* ifdef HAVE_GNUTLS */
226 /* Openssl private declarations */
227 FILE *fp;
228 EVP_PKEY *pkey = NULL;
229 X509 *cert = NULL;
230
231 /* Load the X509 certificate in memory. */
232 fp = fopen(certificate_file, "r");
233 if (!fp)
234 return NULL;
235
236 cert = PEM_read_X509(fp, NULL, NULL, NULL);
237 fclose(fp);
238 if (!cert)
239 goto on_error;
240
241 /* Check the presence of the public key. Just in case. */
242 pkey = X509_get_pubkey(cert);
243 if (!pkey)
244 goto on_error;
245
246 /* Load the private key in memory. */
247 fp = fopen(private_key_file, "r");
248 if (!fp)
249 goto on_error;
250
251 pkey = PEM_read_PrivateKey(fp, NULL, cb, NULL);
252 fclose(fp);
253 if (!pkey)
254 goto on_error;
255
256 /* Load the certificate and the private key in Eet_Key structure */
257 key = malloc(sizeof(Eet_Key));
258 if (!key)
259 goto on_error;
260
261 key->references = 1;
262 key->certificate = cert;
263 key->private_key = pkey;
264
265 return key;
266
267on_error:
268 if (cert)
269 X509_free(cert);
270
271 if (pkey)
272 EVP_PKEY_free(pkey);
273
274# endif /* ifdef HAVE_GNUTLS */
275#else
276 certificate_file = NULL;
277 private_key_file = NULL;
278 cb = NULL;
279#endif /* ifdef HAVE_SIGNATURE */
280 return NULL;
281}
282
283EAPI void
284eet_identity_close(Eet_Key *key)
285{
286#ifdef HAVE_SIGNATURE
287 if (!key || (key->references > 0))
288 return;
289
290# ifdef HAVE_GNUTLS
291 gnutls_x509_crt_deinit(key->certificate);
292 gnutls_x509_privkey_deinit(key->private_key);
293# else /* ifdef HAVE_GNUTLS */
294 X509_free(key->certificate);
295 EVP_PKEY_free(key->private_key);
296# endif /* ifdef HAVE_GNUTLS */
297 free(key);
298#else
299 key = NULL;
300#endif /* ifdef HAVE_SIGNATURE */
301}
302
303EAPI void
304eet_identity_print(Eet_Key *key,
305 FILE *out)
306{
307#ifdef HAVE_SIGNATURE
308# ifdef HAVE_GNUTLS
309 const char *names[6] = {
310 "Modulus",
311 "Public exponent",
312 "Private exponent",
313 "First prime",
314 "Second prime",
315 "Coefficient"
316 };
317 int err = 0;
318 gnutls_datum_t data = { NULL, 0 };
319 gnutls_datum_t rsa_raw[6];
320 size_t size = 128;
321 char *res = NULL;
322 char buf[33];
323 unsigned int i, j;
324
325 if (!key)
326 return;
327
328 if (key->private_key)
329 {
330 if (gnutls_x509_privkey_export_rsa_raw(key->private_key,
331 rsa_raw + 0, /* Modulus */
332 rsa_raw + 1, /* Public exponent */
333 rsa_raw + 2, /* Private exponent */
334 rsa_raw + 3, /* First prime */
335 rsa_raw + 4, /* Second prime */
336 rsa_raw + 5)) /* Coefficient */
337 goto on_error;
338
339 if (!(res = malloc(size)))
340 goto on_error;
341
342 fprintf(out, "Private Key:\n");
343 buf[32] = '\0';
344
345 for (i = 0; i < 6; i++)
346 {
347 while ((err = gnutls_hex_encode(rsa_raw + i, res, &size)) ==
348 GNUTLS_E_SHORT_MEMORY_BUFFER)
349 {
350 size += 128;
351 if (!(res = realloc(res, size)))
352 goto on_error;
353 }
354 if (err)
355 goto on_error;
356
357 fprintf(out, "\t%s:\n", names[i]);
358 for (j = 0; strlen(res) > j; j += 32)
359 {
360 snprintf(buf, 32, "%s", res + j);
361 fprintf(out, "\t\t%s\n", buf);
362 }
363 }
364 free(res);
365 res = NULL;
366 }
367
368 if (key->certificate)
369 {
370 fprintf(out, "Public certificate:\n");
371 if (gnutls_x509_crt_print(key->certificate, GNUTLS_X509_CRT_FULL,
372 &data))
373 goto on_error;
374
375 fprintf(out, "%s\n", data.data);
376 gnutls_free(data.data);
377 data.data = NULL;
378 }
379
380on_error:
381 if (res)
382 free(res);
383
384 if (data.data)
385 gnutls_free(data.data);
386
387 return;
388# else /* ifdef HAVE_GNUTLS */
389 RSA *rsa;
390 DSA *dsa;
391 DH *dh;
392
393 if (!key)
394 return;
395
396 rsa = EVP_PKEY_get1_RSA(key->private_key);
397 if (rsa)
398 {
399 fprintf(out, "Private key (RSA):\n");
400 RSA_print_fp(out, rsa, 0);
401 }
402
403 dsa = EVP_PKEY_get1_DSA(key->private_key);
404 if (dsa)
405 {
406 fprintf(out, "Private key (DSA):\n");
407 DSA_print_fp(out, dsa, 0);
408 }
409
410 dh = EVP_PKEY_get1_DH(key->private_key);
411 if (dh)
412 {
413 fprintf(out, "Private key (DH):\n");
414 DHparams_print_fp(out, dh);
415 }
416
417 fprintf(out, "Public certificate:\n");
418 X509_print_fp(out, key->certificate);
419# endif /* ifdef HAVE_GNUTLS */
420#else /* ifdef HAVE_SIGNATURE */
421 key = NULL;
422 out = NULL;
423 ERR("You need to compile signature support in EET.");
424#endif /* ifdef HAVE_SIGNATURE */
425}
426
427void
428eet_identity_ref(Eet_Key *key)
429{
430 if (!key)
431 return;
432
433 key->references++;
434}
435
436void
437eet_identity_unref(Eet_Key *key)
438{
439 if (!key)
440 return;
441
442 key->references--;
443 eet_identity_close(key);
444}
445
446void *
447eet_identity_compute_sha1(const void *data_base,
448 unsigned int data_length,
449 int *sha1_length)
450{
451 void *result;
452
453#ifdef HAVE_SIGNATURE
454# ifdef HAVE_GNUTLS
455 result = malloc(gcry_md_get_algo_dlen(GCRY_MD_SHA1));
456 if (!result)
457 return NULL;
458
459 gcry_md_hash_buffer(GCRY_MD_SHA1, result, data_base, data_length);
460 if (sha1_length)
461 *sha1_length = gcry_md_get_algo_dlen(GCRY_MD_SHA1);
462
463# else /* ifdef HAVE_GNUTLS */
464# ifdef HAVE_OPENSSL
465 result = malloc(SHA_DIGEST_LENGTH);
466 if (!result)
467 return NULL;
468
469 SHA1(data_base, data_length, result);
470 if (sha1_length)
471 *sha1_length = SHA_DIGEST_LENGTH;
472
473# else /* ifdef HAVE_OPENSSL */
474 result = NULL;
475# endif /* ifdef HAVE_OPENSSL */
476# endif /* ifdef HAVE_GNUTLS */
477#else /* ifdef HAVE_SIGNATURE */
478 data_base = NULL;
479 data_length = 0;
480 sha1_length = NULL;
481 result = NULL;
482#endif /* ifdef HAVE_SIGNATURE */
483
484 return result;
485}
486
487Eet_Error
488eet_identity_sign(FILE *fp,
489 Eet_Key *key)
490{
491#ifdef HAVE_SIGNATURE
492 Eet_Error err = EET_ERROR_NONE;
493 struct stat st_buf;
494 void *data;
495 int fd;
496 int head[3];
497 unsigned char *sign = NULL;
498 unsigned char *cert = NULL;
499# ifdef HAVE_GNUTLS
500 gnutls_datum_t datum = { NULL, 0 };
501 size_t sign_len = 0;
502 size_t cert_len = 0;
503#ifdef EET_USE_NEW_PRIVKEY_SIGN_DATA
504 gnutls_datum_t signum = { NULL, 0 };
505 gnutls_privkey_t privkey;
506#endif
507# else /* ifdef HAVE_GNUTLS */
508 EVP_MD_CTX md_ctx;
509 unsigned int sign_len = 0;
510 int cert_len = 0;
511# endif /* ifdef HAVE_GNUTLS */
512
513 /* A few check and flush pending write. */
514 if (!fp || !key || !key->certificate || !key->private_key)
515 return EET_ERROR_BAD_OBJECT;
516
517 /* Get the file size. */
518 fd = fileno(fp);
519 if (fd < 0)
520 return EET_ERROR_BAD_OBJECT;
521
522 if (fstat(fd, &st_buf) < 0)
523 return EET_ERROR_MMAP_FAILED;
524
525 /* let's make mmap safe and just get 0 pages for IO erro */
526 eina_mmap_safety_enabled_set(EINA_TRUE);
527
528 /* Map the file in memory. */
529 data = mmap(NULL, st_buf.st_size, PROT_READ, MAP_PRIVATE, fd, 0);
530 if (data == MAP_FAILED)
531 return EET_ERROR_MMAP_FAILED;
532
533# ifdef HAVE_GNUTLS
534 datum.data = data;
535 datum.size = st_buf.st_size;
536
537 /* Get the signature length */
538#ifdef EET_USE_NEW_PRIVKEY_SIGN_DATA
539 if (gnutls_privkey_init(&privkey) < 0)
540 {
541 err = EET_ERROR_SIGNATURE_FAILED;
542 goto on_error;
543 }
544
545 if (gnutls_privkey_import_x509(privkey, key->private_key, 0) < 0)
546 {
547 err = EET_ERROR_SIGNATURE_FAILED;
548 goto on_error;
549 }
550
551 if (gnutls_privkey_sign_data(privkey, GNUTLS_DIG_SHA1, 0, &datum, &signum) < 0)
552 {
553 err = EET_ERROR_SIGNATURE_FAILED;
554 goto on_error;
555 }
556
557 sign = signum.data;
558 sign_len = signum.size;
559#else
560 if (gnutls_x509_privkey_sign_data(key->private_key, GNUTLS_DIG_SHA1, 0,
561 &datum, sign, &sign_len) &&
562 !sign_len)
563 {
564 err = EET_ERROR_SIGNATURE_FAILED;
565 goto on_error;
566 }
567
568 /* Get the signature */
569 sign = malloc(sign_len);
570 if (!sign ||
571 gnutls_x509_privkey_sign_data(key->private_key, GNUTLS_DIG_SHA1, 0,
572 &datum,
573 sign, &sign_len))
574 {
575 if (!sign)
576 err = EET_ERROR_OUT_OF_MEMORY;
577 else
578 err = EET_ERROR_SIGNATURE_FAILED;
579
580 goto on_error;
581 }
582#endif
583
584 /* Get the certificate length */
585 if (gnutls_x509_crt_export(key->certificate, GNUTLS_X509_FMT_DER, cert,
586 &cert_len) &&
587 !cert_len)
588 {
589 err = EET_ERROR_SIGNATURE_FAILED;
590 goto on_error;
591 }
592
593 /* Get the certificate */
594 cert = malloc(cert_len);
595 if (!cert ||
596 gnutls_x509_crt_export(key->certificate, GNUTLS_X509_FMT_DER, cert,
597 &cert_len))
598 {
599 if (!cert)
600 err = EET_ERROR_OUT_OF_MEMORY;
601 else
602 err = EET_ERROR_SIGNATURE_FAILED;
603
604 goto on_error;
605 }
606
607# else /* ifdef HAVE_GNUTLS */
608 sign_len = EVP_PKEY_size(key->private_key);
609 sign = malloc(sign_len);
610 if (!sign)
611 {
612 err = EET_ERROR_OUT_OF_MEMORY;
613 goto on_error;
614 }
615
616 /* Do the signature. */
617 EVP_SignInit(&md_ctx, EVP_sha1());
618 EVP_SignUpdate(&md_ctx, data, st_buf.st_size);
619 err = EVP_SignFinal(&md_ctx,
620 sign,
621 (unsigned int *)&sign_len,
622 key->private_key);
623 if (err != 1)
624 {
625 ERR_print_errors_fp(stdout);
626 err = EET_ERROR_SIGNATURE_FAILED;
627 goto on_error;
628 }
629
630 /* Give me the der (binary form for X509). */
631 cert_len = i2d_X509(key->certificate, &cert);
632 if (cert_len < 0)
633 {
634 ERR_print_errors_fp(stdout);
635 err = EET_ERROR_X509_ENCODING_FAILED;
636 goto on_error;
637 }
638
639# endif /* ifdef HAVE_GNUTLS */
640 /* Append the signature at the end of the file. */
641 head[0] = (int)htonl ((unsigned int)EET_MAGIC_SIGN);
642 head[1] = (int)htonl ((unsigned int)sign_len);
643 head[2] = (int)htonl ((unsigned int)cert_len);
644
645 if (fwrite(head, sizeof(head), 1, fp) != 1)
646 {
647 err = EET_ERROR_WRITE_ERROR;
648 goto on_error;
649 }
650
651 if (fwrite(sign, sign_len, 1, fp) != 1)
652 {
653 err = EET_ERROR_WRITE_ERROR;
654 goto on_error;
655 }
656
657 if (fwrite(cert, cert_len, 1, fp) != 1)
658 {
659 err = EET_ERROR_WRITE_ERROR;
660 goto on_error;
661 }
662
663on_error:
664# ifdef HAVE_GNUTLS
665 if (cert)
666 free(cert);
667
668# else /* ifdef HAVE_GNUTLS */
669 if (cert)
670 OPENSSL_free(cert);
671
672# endif /* ifdef HAVE_GNUTLS */
673 if (sign)
674 free(sign);
675
676 munmap(data, st_buf.st_size);
677 return err;
678#else /* ifdef HAVE_SIGNATURE */
679 fp = NULL;
680 key = NULL;
681 return EET_ERROR_NOT_IMPLEMENTED;
682#endif /* ifdef HAVE_SIGNATURE */
683}
684
685const void *
686eet_identity_check(const void *data_base,
687 unsigned int data_length,
688 void **sha1,
689 int *sha1_length,
690 const void *signature_base,
691 unsigned int signature_length,
692 const void **raw_signature_base,
693 unsigned int *raw_signature_length,
694 int *x509_length)
695{
696#ifdef HAVE_SIGNATURE
697 const int *header = signature_base;
698 const unsigned char *sign;
699 const unsigned char *cert_der;
700 int sign_len;
701 int cert_len;
702 int magic;
703
704 /* At least the header size */
705 if (signature_length < sizeof(int) * 3)
706 return NULL;
707
708 /* Get the header */
709 magic = ntohl(header[0]);
710 sign_len = ntohl(header[1]);
711 cert_len = ntohl(header[2]);
712
713 /* Verify the header */
714 if (magic != EET_MAGIC_SIGN)
715 return NULL;
716
717 if (sign_len + cert_len + sizeof(int) * 3 > signature_length)
718 return NULL;
719
720 /* Update the signature and certificate pointer */
721 sign = (unsigned char *)signature_base + sizeof(int) * 3;
722 cert_der = sign + sign_len;
723
724# ifdef HAVE_GNUTLS
725 gnutls_x509_crt_t cert;
726 gnutls_datum_t datum;
727 gnutls_datum_t signature;
728# if EET_USE_NEW_GNUTLS_API
729# if EET_USE_NEW_PUBKEY_VERIFY_HASH
730 gnutls_pubkey_t pubkey;
731 gnutls_digest_algorithm_t hash_algo;
732# endif
733 unsigned char *hash;
734 gcry_md_hd_t md;
735 int err;
736# endif /* if EET_USE_NEW_GNUTLS_API */
737
738 /* Create an understanding certificate structure for gnutls */
739 datum.data = (void *)cert_der;
740 datum.size = cert_len;
741 gnutls_x509_crt_init(&cert);
742 gnutls_x509_crt_import(cert, &datum, GNUTLS_X509_FMT_DER);
743
744 signature.data = (void *)sign;
745 signature.size = sign_len;
746
747 /* Verify the signature */
748# if EET_USE_NEW_GNUTLS_API
749 /*
750 I am waiting for my patch being accepted in GnuTLS release.
751 But we now have a way to prevent double computation of SHA1.
752 */
753 err = gcry_md_open (&md, GCRY_MD_SHA1, 0);
754 if (err < 0)
755 return NULL;
756
757 gcry_md_write(md, data_base, data_length);
758
759 hash = gcry_md_read(md, GCRY_MD_SHA1);
760 if (!hash)
761 goto on_error;
762
763 datum.size = gcry_md_get_algo_dlen(GCRY_MD_SHA1);
764 datum.data = hash;
765
766# ifdef EET_USE_NEW_PUBKEY_VERIFY_HASH
767 if (gnutls_pubkey_init(&pubkey) < 0)
768 goto on_error;
769
770 if (gnutls_pubkey_import_x509(pubkey, cert, 0) < 0)
771 goto on_error;
772
773 if (gnutls_pubkey_get_verify_algorithm(pubkey, &signature, &hash_algo) < 0)
774 goto on_error;
775
776 if (gnutls_pubkey_verify_hash(pubkey, 0, &datum, &signature) < 0)
777 goto on_error;
778# else
779 if (!gnutls_x509_crt_verify_hash(cert, 0, &datum, &signature))
780 goto on_error;
781# endif
782
783 if (sha1)
784 {
785 *sha1 = malloc(datum.size);
786 if (!*sha1) goto on_error;
787
788 memcpy(*sha1, hash, datum.size);
789 *sha1_length = datum.size;
790 }
791
792 gcry_md_close(md);
793# else /* if EET_USE_NEW_GNUTLS_API */
794 datum.data = (void *)data_base;
795 datum.size = data_length;
796
797 if (!gnutls_x509_crt_verify_data(cert, 0, &datum, &signature))
798 return NULL;
799
800 if (sha1)
801 {
802 *sha1 = NULL;
803 *sha1_length = -1;
804 }
805
806# endif /* if EET_USE_NEW_GNUTLS_API */
807 gnutls_x509_crt_deinit(cert);
808
809# else /* ifdef HAVE_GNUTLS */
810 const unsigned char *tmp;
811 EVP_PKEY *pkey;
812 X509 *x509;
813 EVP_MD_CTX md_ctx;
814 int err;
815
816 /* Strange but d2i_X509 seems to put 0 all over the place. */
817 tmp = alloca(cert_len);
818 memcpy((char *)tmp, cert_der, cert_len);
819 x509 = d2i_X509(NULL, &tmp, cert_len);
820 if (!x509)
821 return NULL;
822
823 /* Get public key - eay */
824 pkey = X509_get_pubkey(x509);
825 if (!pkey)
826 {
827 X509_free(x509);
828 return NULL;
829 }
830
831 /* Verify the signature */
832 EVP_VerifyInit(&md_ctx, EVP_sha1());
833 EVP_VerifyUpdate(&md_ctx, data_base, data_length);
834 err = EVP_VerifyFinal(&md_ctx, sign, sign_len, pkey);
835
836 X509_free(x509);
837 EVP_PKEY_free(pkey);
838
839 if (sha1)
840 {
841 *sha1 = NULL;
842 *sha1_length = -1;
843 }
844
845 if (err != 1)
846 return NULL;
847
848# endif /* ifdef HAVE_GNUTLS */
849 if (x509_length)
850 *x509_length = cert_len;
851
852 if (raw_signature_base)
853 *raw_signature_base = sign;
854
855 if (raw_signature_length)
856 *raw_signature_length = sign_len;
857
858 return cert_der;
859# ifdef HAVE_GNUTLS
860# if EET_USE_NEW_GNUTLS_API
861 on_error:
862 gcry_md_close(md);
863 return NULL;
864# endif
865# endif
866#else /* ifdef HAVE_SIGNATURE */
867 data_base = NULL;
868 data_length = 0;
869 sha1 = NULL;
870 sha1_length = NULL;
871 signature_base = NULL;
872 signature_length = 0;
873 raw_signature_base = NULL;
874 raw_signature_length = NULL;
875 x509_length = NULL;
876 return NULL;
877#endif /* ifdef HAVE_SIGNATURE */
878}
879
880EAPI void
881eet_identity_certificate_print(const unsigned char *certificate,
882 int der_length,
883 FILE *out)
884{
885#ifdef HAVE_SIGNATURE
886 if (!certificate || !out || der_length <= 0)
887 {
888 ERR("No certificate provided.");
889 return;
890 }
891
892# ifdef HAVE_GNUTLS
893 gnutls_datum_t datum;
894 gnutls_x509_crt_t cert;
895
896 /* Create an understanding certificate structure for gnutls */
897 datum.data = (void *)certificate;
898 datum.size = der_length;
899 if (gnutls_x509_crt_init(&cert))
900 goto on_error;
901
902 if (gnutls_x509_crt_import(cert, &datum, GNUTLS_X509_FMT_DER))
903 goto on_error;
904
905 /* Pretty print the certificate */
906 datum.data = NULL;
907 datum.size = 0;
908 if (gnutls_x509_crt_print(cert, GNUTLS_X509_CRT_FULL, &datum))
909 goto on_error;
910
911 INF("Public certificate :");
912 INF("%s", datum.data);
913
914on_error:
915 if (datum.data)
916 gnutls_free(datum.data);
917
918 gnutls_x509_crt_deinit(cert);
919# else /* ifdef HAVE_GNUTLS */
920 const unsigned char *tmp;
921 X509 *x509;
922
923 /* Strange but d2i_X509 seems to put 0 all over the place. */
924 tmp = alloca(der_length);
925 memcpy((char *)tmp, certificate, der_length);
926 x509 = d2i_X509(NULL, &tmp, der_length);
927 if (!x509)
928 {
929 INF("Not a valid certificate.");
930 return;
931 }
932
933 INF("Public certificate :");
934 X509_print_fp(out, x509);
935
936 X509_free(x509);
937# endif /* ifdef HAVE_GNUTLS */
938#else /* ifdef HAVE_SIGNATURE */
939 certificate = NULL;
940 der_length = 0;
941 out = NULL;
942 ERR("You need to compile signature support in EET.");
943#endif /* ifdef HAVE_SIGNATURE */
944}
945
946Eet_Error
947eet_cipher(const void *data,
948 unsigned int size,
949 const char *key,
950 unsigned int length,
951 void **result,
952 unsigned int *result_length)
953{
954#ifdef HAVE_CIPHER
955 /* Cipher declarations */
956 unsigned int *ret = NULL;
957 unsigned char iv[MAX_IV_LEN];
958 unsigned char ik[MAX_KEY_LEN];
959 unsigned char key_material[MAX_IV_LEN + MAX_KEY_LEN];
960 unsigned int salt;
961 unsigned int tmp = 0;
962 int crypted_length;
963 int opened = 0;
964# ifdef HAVE_GNUTLS
965 /* Gcrypt declarations */
966 gcry_error_t err = 0;
967 gcry_cipher_hd_t cipher;
968# else /* ifdef HAVE_GNUTLS */
969 /* Openssl declarations*/
970 EVP_CIPHER_CTX ctx;
971 unsigned int *buffer;
972 int tmp_len;
973# endif /* ifdef HAVE_GNUTLS */
974
975# ifdef HAVE_GNUTLS
976 /* Gcrypt salt generation */
977 gcry_create_nonce((unsigned char *)&salt, sizeof(salt));
978# else /* ifdef HAVE_GNUTLS */
979 /* Openssl salt generation */
980 if (!RAND_bytes((unsigned char *)&salt, sizeof (unsigned int)))
981 return EET_ERROR_PRNG_NOT_SEEDED;
982
983# endif /* ifdef HAVE_GNUTLS */
984
985 eet_pbkdf2_sha1(key,
986 length,
987 (unsigned char *)&salt,
988 sizeof(unsigned int),
989 2048,
990 key_material,
991 MAX_KEY_LEN + MAX_IV_LEN);
992
993 memcpy(iv, key_material, MAX_IV_LEN);
994 memcpy(ik, key_material + MAX_IV_LEN, MAX_KEY_LEN);
995
996 memset(key_material, 0, sizeof (key_material));
997
998 crypted_length = ((((size + sizeof (unsigned int)) >> 5) + 1) << 5);
999 ret = malloc(crypted_length + sizeof(unsigned int));
1000 if (!ret)
1001 {
1002 memset(iv, 0, sizeof (iv));
1003 memset(ik, 0, sizeof (ik));
1004 memset(&salt, 0, sizeof (salt));
1005 return EET_ERROR_OUT_OF_MEMORY;
1006 }
1007
1008 *ret = salt;
1009 memset(&salt, 0, sizeof (salt));
1010 tmp = htonl(size);
1011
1012# ifdef HAVE_GNUTLS
1013 *(ret + 1) = tmp;
1014 memcpy(ret + 2, data, size);
1015
1016 /* Gcrypt create the corresponding cipher
1017 AES with a 256 bit key, Cipher Block Chaining mode */
1018 err = gcry_cipher_open(&cipher, GCRY_CIPHER_AES256, GCRY_CIPHER_MODE_CBC, 0);
1019 if (err)
1020 goto on_error;
1021
1022 opened = 1;
1023 err = gcry_cipher_setiv(cipher, iv, MAX_IV_LEN);
1024 if (err)
1025 goto on_error;
1026
1027 err = gcry_cipher_setkey(cipher, ik, MAX_KEY_LEN);
1028 if (err)
1029 goto on_error;
1030
1031 memset(iv, 0, sizeof (iv));
1032 memset(ik, 0, sizeof (ik));
1033
1034 /* Gcrypt encrypt */
1035 err = gcry_cipher_encrypt(cipher,
1036 (unsigned char *)(ret + 1),
1037 crypted_length,
1038 NULL,
1039 0);
1040 if (err)
1041 goto on_error;
1042
1043 /* Gcrypt close the cipher */
1044 gcry_cipher_close(cipher);
1045# else /* ifdef HAVE_GNUTLS */
1046 buffer = alloca(crypted_length);
1047 *buffer = tmp;
1048
1049 memcpy(buffer + 1, data, size);
1050
1051 /* Openssl create the corresponding cipher
1052 AES with a 256 bit key, Cipher Block Chaining mode */
1053 EVP_CIPHER_CTX_init(&ctx);
1054 if (!EVP_EncryptInit_ex(&ctx, EVP_aes_256_cbc(), NULL, ik, iv))
1055 goto on_error;
1056
1057 opened = 1;
1058
1059 memset(iv, 0, sizeof (iv));
1060 memset(ik, 0, sizeof (ik));
1061
1062 /* Openssl encrypt */
1063 if (!EVP_EncryptUpdate(&ctx, (unsigned char *)(ret + 1), &tmp_len,
1064 (unsigned char *)buffer,
1065 size + sizeof(unsigned int)))
1066 goto on_error;
1067
1068 /* Openssl close the cipher */
1069 if (!EVP_EncryptFinal_ex(&ctx, ((unsigned char *)(ret + 1)) + tmp_len,
1070 &tmp_len))
1071 goto on_error;
1072
1073 EVP_CIPHER_CTX_cleanup(&ctx);
1074# endif /* ifdef HAVE_GNUTLS */
1075
1076 /* Set return values */
1077 if (result_length)
1078 *result_length = crypted_length + sizeof(unsigned int);
1079
1080 if (result)
1081 *result = ret;
1082 else
1083 free(ret);
1084
1085 return EET_ERROR_NONE;
1086
1087on_error:
1088 memset(iv, 0, sizeof (iv));
1089 memset(ik, 0, sizeof (ik));
1090
1091# ifdef HAVE_GNUTLS
1092 /* Gcrypt error */
1093 if (opened)
1094 gcry_cipher_close(cipher);
1095
1096# else /* ifdef HAVE_GNUTLS */
1097 /* Openssl error */
1098 if (opened)
1099 EVP_CIPHER_CTX_cleanup(&ctx);
1100
1101# endif /* ifdef HAVE_GNUTLS */
1102 /* General error */
1103 free(ret);
1104 if (result)
1105 *result = NULL;
1106
1107 if (result_length)
1108 *result_length = 0;
1109
1110 return EET_ERROR_ENCRYPT_FAILED;
1111#else /* ifdef HAVE_CIPHER */
1112 /* Cipher not supported */
1113 (void)data;
1114 (void)size;
1115 (void)key;
1116 (void)length;
1117 (void)result;
1118 (void)result_length;
1119 return EET_ERROR_NOT_IMPLEMENTED;
1120#endif /* ifdef HAVE_CIPHER */
1121}
1122
1123Eet_Error
1124eet_decipher(const void *data,
1125 unsigned int size,
1126 const char *key,
1127 unsigned int length,
1128 void **result,
1129 unsigned int *result_length)
1130{
1131#ifdef HAVE_CIPHER
1132 const unsigned int *over = data;
1133 unsigned int *ret = NULL;
1134 unsigned char ik[MAX_KEY_LEN];
1135 unsigned char iv[MAX_IV_LEN];
1136 unsigned char key_material[MAX_KEY_LEN + MAX_IV_LEN];
1137 unsigned int salt;
1138 int tmp_len;
1139 int tmp = 0;
1140
1141 /* At least the salt and an AES block */
1142 if (size < sizeof(unsigned int) + 16)
1143 return EET_ERROR_BAD_OBJECT;
1144
1145 /* Get the salt */
1146 salt = *over;
1147
1148 /* Generate the iv and the key with the salt */
1149 eet_pbkdf2_sha1(key, length, (unsigned char *)&salt,
1150 sizeof(unsigned int), 2048, key_material,
1151 MAX_KEY_LEN + MAX_IV_LEN);
1152
1153 memcpy(iv, key_material, MAX_IV_LEN);
1154 memcpy(ik, key_material + MAX_IV_LEN, MAX_KEY_LEN);
1155
1156 memset(key_material, 0, sizeof (key_material));
1157 memset(&salt, 0, sizeof (salt));
1158
1159 /* Align to AES block size if size is not align */
1160 tmp_len = size - sizeof (unsigned int);
1161 if ((tmp_len & 0x1F) != 0)
1162 goto on_error;
1163
1164 ret = malloc(tmp_len);
1165 if (!ret)
1166 goto on_error;
1167
1168# ifdef HAVE_GNUTLS
1169 gcry_error_t err = 0;
1170 gcry_cipher_hd_t cipher;
1171
1172 /* Gcrypt create the corresponding cipher */
1173 err = gcry_cipher_open(&cipher, GCRY_CIPHER_AES256, GCRY_CIPHER_MODE_CBC, 0);
1174 if (err)
1175 return EET_ERROR_DECRYPT_FAILED;
1176
1177 err = gcry_cipher_setiv(cipher, iv, MAX_IV_LEN);
1178 if (err)
1179 goto on_error;
1180
1181 err = gcry_cipher_setkey(cipher, ik, MAX_KEY_LEN);
1182 if (err)
1183 goto on_error;
1184
1185 memset(iv, 0, sizeof (iv));
1186 memset(ik, 0, sizeof (ik));
1187
1188 /* Gcrypt decrypt */
1189 err = gcry_cipher_decrypt(cipher, ret, tmp_len,
1190 ((unsigned int *)data) + 1, tmp_len);
1191 if (err)
1192 goto on_error;
1193
1194 /* Gcrypt close the cipher */
1195 gcry_cipher_close(cipher);
1196
1197# else /* ifdef HAVE_GNUTLS */
1198 EVP_CIPHER_CTX ctx;
1199 int opened = 0;
1200
1201 /* Openssl create the corresponding cipher */
1202 EVP_CIPHER_CTX_init(&ctx);
1203 opened = 1;
1204
1205 if (!EVP_DecryptInit_ex(&ctx, EVP_aes_256_cbc(), NULL, ik, iv))
1206 goto on_error;
1207
1208 memset(iv, 0, sizeof (iv));
1209 memset(ik, 0, sizeof (ik));
1210
1211 /* Openssl decrypt */
1212 if (!EVP_DecryptUpdate(&ctx, (unsigned char *)ret, &tmp,
1213 (unsigned char *)(over + 1), tmp_len))
1214 goto on_error;
1215
1216 /* Openssl close the cipher*/
1217 EVP_CIPHER_CTX_cleanup(&ctx);
1218# endif /* ifdef HAVE_GNUTLS */
1219 /* Get the decrypted data size */
1220 tmp = *ret;
1221 tmp = ntohl(tmp);
1222 if (tmp > tmp_len)
1223 goto on_error;
1224
1225 /* Update the return values */
1226 if (result_length)
1227 *result_length = tmp;
1228
1229 if (result)
1230 {
1231 *result = NULL;
1232 *result = malloc(tmp);
1233 if (!*result)
1234 goto on_error;
1235
1236 memcpy(*result, ret + 1, tmp);
1237 }
1238
1239 free(ret);
1240
1241 return EET_ERROR_NONE;
1242
1243on_error:
1244 memset(iv, 0, sizeof (iv));
1245 memset(ik, 0, sizeof (ik));
1246
1247# ifdef HAVE_GNUTLS
1248# else
1249 if (opened)
1250 EVP_CIPHER_CTX_cleanup(&ctx);
1251
1252# endif /* ifdef HAVE_GNUTLS */
1253 if (result)
1254 *result = NULL;
1255
1256 if (result_length)
1257 *result_length = 0;
1258
1259 if (ret)
1260 free(ret);
1261
1262 return EET_ERROR_DECRYPT_FAILED;
1263#else /* ifdef HAVE_CIPHER */
1264 (void)data;
1265 (void)size;
1266 (void)key;
1267 (void)length;
1268 (void)result;
1269 (void)result_length;
1270 return EET_ERROR_NOT_IMPLEMENTED;
1271#endif /* ifdef HAVE_CIPHER */
1272}
1273
1274#ifdef HAVE_CIPHER
1275# ifdef HAVE_GNUTLS
1276static Eet_Error
1277eet_hmac_sha1(const void *key,
1278 size_t key_len,
1279 const void *data,
1280 size_t data_len,
1281 unsigned char *res)
1282{
1283 size_t hlen = gcry_md_get_algo_dlen (GCRY_MD_SHA1);
1284 gcry_md_hd_t mdh;
1285 unsigned char *hash;
1286 gpg_error_t err;
1287
1288 err = gcry_md_open(&mdh, GCRY_MD_SHA1, GCRY_MD_FLAG_HMAC);
1289 if (err != GPG_ERR_NO_ERROR)
1290 return 1;
1291
1292 err = gcry_md_setkey(mdh, key, key_len);
1293 if (err != GPG_ERR_NO_ERROR)
1294 {
1295 gcry_md_close(mdh);
1296 return 1;
1297 }
1298
1299 gcry_md_write(mdh, data, data_len);
1300
1301 hash = gcry_md_read(mdh, GCRY_MD_SHA1);
1302 if (!hash)
1303 {
1304 gcry_md_close(mdh);
1305 return 1;
1306 }
1307
1308 memcpy(res, hash, hlen);
1309
1310 gcry_md_close(mdh);
1311
1312 return 0;
1313}
1314
1315# endif /* ifdef HAVE_GNUTLS */
1316
1317static Eet_Error
1318eet_pbkdf2_sha1(const char *key,
1319 int key_len,
1320 const unsigned char *salt,
1321 unsigned int salt_len,
1322 int iter,
1323 unsigned char *res,
1324 int res_len)
1325{
1326 unsigned char digest[20];
1327 unsigned char tab[4];
1328 unsigned char *p = res;
1329 unsigned char *buf;
1330 unsigned long i;
1331 int digest_len = 20;
1332 int len = res_len;
1333 int tmp_len;
1334 int j, k;
1335# ifdef HAVE_GNUTLS
1336# else
1337 HMAC_CTX hctx;
1338# endif /* ifdef HAVE_GNUTLS */
1339
1340 buf = alloca(salt_len + 4);
1341 if (!buf)
1342 return 1;
1343
1344 for (i = 1; len; len -= tmp_len, p += tmp_len, i++)
1345 {
1346 if (len > digest_len)
1347 tmp_len = digest_len;
1348 else
1349 tmp_len = len;
1350
1351 tab[0] = (unsigned char)(i & 0xff000000) >> 24;
1352 tab[1] = (unsigned char)(i & 0x00ff0000) >> 16;
1353 tab[2] = (unsigned char)(i & 0x0000ff00) >> 8;
1354 tab[3] = (unsigned char)(i & 0x000000ff) >> 0;
1355
1356# ifdef HAVE_GNUTLS
1357 memcpy(buf, salt, salt_len);
1358 memcpy(buf + salt_len, tab, 4);
1359 eet_hmac_sha1(key, key_len, buf, salt_len + 4, digest);
1360# else /* ifdef HAVE_GNUTLS */
1361 HMAC_Init(&hctx, key, key_len, EVP_sha1());
1362 HMAC_Update(&hctx, salt, salt_len);
1363 HMAC_Update(&hctx, tab, 4);
1364 HMAC_Final(&hctx, digest, NULL);
1365# endif /* ifdef HAVE_GNUTLS */
1366 memcpy(p, digest, tmp_len);
1367
1368 for (j = 1; j < iter; j++)
1369 {
1370# ifdef HAVE_GNUTLS
1371 eet_hmac_sha1(key, key_len, digest, 20, digest);
1372# else /* ifdef HAVE_GNUTLS */
1373 HMAC(EVP_sha1(), key, key_len, digest, 20, digest, NULL);
1374# endif /* ifdef HAVE_GNUTLS */
1375 for (k = 0; k < tmp_len; k++)
1376 p[k] ^= digest[k];
1377 }
1378 }
1379
1380# ifdef HAVE_GNUTLS
1381# else
1382 HMAC_cleanup(&hctx);
1383# endif /* ifdef HAVE_GNUTLS */
1384 return 0;
1385}
1386
1387#endif /* ifdef HAVE_CIPHER */
diff --git a/libraries/eet/src/lib/eet_connection.c b/libraries/eet/src/lib/eet_connection.c
deleted file mode 100644
index 7b6b934..0000000
--- a/libraries/eet/src/lib/eet_connection.c
+++ /dev/null
@@ -1,222 +0,0 @@
1#ifdef HAVE_CONFIG_H
2# include <config.h>
3#endif /* ifdef HAVE_CONFIG_H */
4
5#ifdef HAVE_ALLOCA_H
6# include <alloca.h>
7#elif defined __GNUC__
8# define alloca __builtin_alloca
9#elif defined _AIX
10# define alloca __alloca
11#elif defined _MSC_VER
12# include <malloc.h>
13# define alloca _alloca
14#else /* ifdef HAVE_ALLOCA_H */
15# include <stddef.h>
16# ifdef __cplusplus
17extern "C"
18# endif /* ifdef __cplusplus */
19void *alloca(size_t);
20#endif /* ifdef HAVE_ALLOCA_H */
21
22#include <string.h>
23#include <stdlib.h>
24
25#ifdef HAVE_NETINET_IN_H
26# include <netinet/in.h>
27#endif /* ifdef HAVE_NETINET_IN_H */
28
29#ifdef _WIN32
30# include <winsock2.h>
31#endif /* ifdef _WIN32 */
32
33#include <Eina.h>
34
35#include "Eet.h"
36#include "Eet_private.h"
37
38/* max message size: 1Mb - raised from original 64Kb */
39#define MAX_MSG_SIZE (1024 * 1024)
40#define MAGIC_EET_DATA_PACKET 0x4270ACE1
41
42struct _Eet_Connection
43{
44 Eet_Read_Cb *eet_read_cb;
45 Eet_Write_Cb *eet_write_cb;
46 void *user_data;
47
48 size_t allocated;
49 size_t size;
50 size_t received;
51
52 void *buffer;
53};
54
55EAPI Eet_Connection *
56eet_connection_new(Eet_Read_Cb *eet_read_cb,
57 Eet_Write_Cb *eet_write_cb,
58 const void *user_data)
59{
60 Eet_Connection *conn;
61
62 if ((!eet_read_cb) || (!eet_write_cb)) return NULL;
63
64 conn = calloc(1, sizeof (Eet_Connection));
65 if (!conn) return NULL;
66 conn->eet_read_cb = eet_read_cb;
67 conn->eet_write_cb = eet_write_cb;
68 conn->user_data = (void *)user_data;
69 return conn;
70}
71
72EAPI int
73eet_connection_received(Eet_Connection *conn,
74 const void *data,
75 size_t size)
76{
77 if ((!conn) || (!data) || (!size)) return size;
78 do
79 {
80 size_t copy_size;
81
82 if (conn->size == 0)
83 {
84 const int *msg;
85 size_t packet_size;
86
87 if (size < (sizeof(int) * 2)) break;
88
89 msg = data;
90 /* Check the magic */
91 if (ntohl(msg[0]) != MAGIC_EET_DATA_PACKET) break;
92
93 packet_size = ntohl(msg[1]);
94 /* Message should always be under MAX_MSG_SIZE */
95 if (packet_size > MAX_MSG_SIZE) break;
96
97 data = (void *)(msg + 2);
98 size -= sizeof(int) * 2;
99 if ((size_t)packet_size <= size)
100 {
101 /* Not a partial receive, go the quick way. */
102 if (!conn->eet_read_cb(data, packet_size, conn->user_data))
103 break;
104
105 data = (void *)((char *)data + packet_size);
106 size -= packet_size;
107 conn->received = 0;
108 continue;
109 }
110 conn->size = packet_size;
111 if (conn->allocated < conn->size)
112 {
113 void *tmp;
114
115 tmp = realloc(conn->buffer, conn->size);
116 if (!tmp) break;
117 conn->buffer = tmp;
118 conn->allocated = conn->size;
119 }
120 }
121
122 /* Partial receive */
123 copy_size =
124 (conn->size - conn->received >=
125 size) ? size : conn->size - conn->received;
126 memcpy((char *)conn->buffer + conn->received, data, copy_size);
127
128 conn->received += copy_size;
129 data = (void *)((char *)data + copy_size);
130 size -= copy_size;
131
132 if (conn->received == conn->size)
133 {
134 size_t data_size;
135
136 data_size = conn->size;
137 conn->size = 0;
138 conn->received = 0;
139 /* Completed a packet. */
140 if (!conn->eet_read_cb(conn->buffer, data_size, conn->user_data))
141 {
142 /* Something goes wrong. Stop now. */
143 size += data_size;
144 break;
145 }
146 }
147 }
148 while (size > 0);
149
150 return size;
151}
152
153static Eina_Bool
154_eet_connection_raw_send(Eet_Connection *conn,
155 void *data,
156 int data_size)
157{
158 int *message;
159
160 /* Message should always be under MAX_MSG_SIZE */
161 if (data_size > MAX_MSG_SIZE) return EINA_FALSE;
162 message = alloca(data_size + (sizeof(int) * 2));
163 message[0] = htonl(MAGIC_EET_DATA_PACKET);
164 message[1] = htonl(data_size);
165 memcpy(message + 2, data, data_size);
166 conn->eet_write_cb(message,
167 data_size + (sizeof(int) * 2),
168 conn->user_data);
169 return EINA_TRUE;
170}
171
172EAPI Eina_Bool
173eet_connection_send(Eet_Connection *conn,
174 Eet_Data_Descriptor *edd,
175 const void *data_in,
176 const char *cipher_key)
177{
178 void *flat_data;
179 int data_size;
180 Eina_Bool ret = EINA_FALSE;
181
182 flat_data = eet_data_descriptor_encode_cipher(edd,
183 data_in,
184 cipher_key,
185 &data_size);
186 if (!flat_data) return EINA_FALSE;
187 if (_eet_connection_raw_send(conn, flat_data, data_size)) ret = EINA_TRUE;
188 free(flat_data);
189 return ret;
190}
191
192EAPI Eina_Bool
193eet_connection_node_send(Eet_Connection *conn,
194 Eet_Node *node,
195 const char *cipher_key)
196{
197 void *data;
198 int data_size;
199 Eina_Bool ret = EINA_FALSE;
200
201 data = eet_data_node_encode_cipher(node, cipher_key, &data_size);
202 if (!data) return EINA_FALSE;
203 if (_eet_connection_raw_send(conn, data, data_size))
204 ret = EINA_TRUE;
205 free(data);
206 return ret;
207}
208
209EAPI void *
210eet_connection_close(Eet_Connection *conn,
211 Eina_Bool *on_going)
212{
213 void *user_data;
214
215 if (!conn) return NULL;
216 if (on_going) *on_going = conn->received == 0 ? EINA_FALSE : EINA_TRUE;
217 user_data = conn->user_data;
218 free(conn->buffer);
219 free(conn);
220 return user_data;
221}
222
diff --git a/libraries/eet/src/lib/eet_data.c b/libraries/eet/src/lib/eet_data.c
deleted file mode 100644
index d502f44..0000000
--- a/libraries/eet/src/lib/eet_data.c
+++ /dev/null
@@ -1,4986 +0,0 @@
1#ifdef HAVE_CONFIG_H
2# include <config.h>
3#endif /* ifdef HAVE_CONFIG_H */
4
5#include <stdio.h>
6#include <string.h>
7#include <math.h>
8#include <ctype.h>
9#include <limits.h>
10
11#ifdef HAVE_NETINET_IN_H
12# include <netinet/in.h>
13#endif /* ifdef HAVE_NETINET_IN_H */
14
15#ifdef _WIN32
16# include <winsock2.h>
17#endif /* ifdef _WIN32 */
18
19#include <Eina.h>
20
21#include "Eet.h"
22#include "Eet_private.h"
23
24/*
25 * routines for doing data -> struct and struct -> data conversion
26 *
27 * types:
28 *
29 * basic types:
30 * a sequence of...
31 *
32 * char
33 * short
34 * int
35 * long long
36 * float
37 * double
38 * unsigned char
39 * unsigned short
40 * unsigned int
41 * unsgined long long
42 * string
43 *
44 * groupings:
45 * multiple entries ordered as...
46 *
47 * fixed size array [ of basic types ]
48 * variable size array [ of basic types ]
49 * linked list [ of basic types ]
50 * hash table [ of basic types ]
51 *
52 * need to provide builder/accessor funcs for:
53 *
54 * list_next
55 * list_append
56 *
57 * hash_foreach
58 * hash_add
59 *
60 */
61
62/*---*/
63
64typedef struct _Eet_Data_Element Eet_Data_Element;
65typedef struct _Eet_Data_Basic_Type_Codec Eet_Data_Basic_Type_Codec;
66typedef struct _Eet_Data_Group_Type_Codec Eet_Data_Group_Type_Codec;
67typedef struct _Eet_Data_Chunk Eet_Data_Chunk;
68typedef struct _Eet_Data_Stream Eet_Data_Stream;
69typedef struct _Eet_Data_Descriptor_Hash Eet_Data_Descriptor_Hash;
70typedef struct _Eet_Data_Encode_Hash_Info Eet_Data_Encode_Hash_Info;
71typedef struct _Eet_Free Eet_Free;
72typedef struct _Eet_Free_Context Eet_Free_Context;
73typedef struct _Eet_Variant_Unknow Eet_Variant_Unknow;
74
75/*---*/
76
77/* TODO:
78 * Eet_Data_Basic_Type_Codec (Coder, Decoder)
79 * Eet_Data_Group_Type_Codec (Coder, Decoder)
80 */
81struct _Eet_Data_Basic_Type_Codec
82{
83 int size;
84 const char *name;
85 int (*get)(const Eet_Dictionary *ed,
86 const void *src,
87 const void *src_end,
88 void *dest);
89 void * (*put)(Eet_Dictionary *ed, const void *src, int *size_ret);
90};
91
92struct _Eet_Data_Group_Type_Codec
93{
94 int (*get)(Eet_Free_Context *context,
95 const Eet_Dictionary *ed,
96 Eet_Data_Descriptor *edd,
97 Eet_Data_Element *ede,
98 Eet_Data_Chunk *echnk,
99 int type,
100 int group_type,
101 void *data_in,
102 char **p,
103 int *size);
104 void (*put)(Eet_Dictionary *ed,
105 Eet_Data_Descriptor *edd,
106 Eet_Data_Element *ede,
107 Eet_Data_Stream *ds,
108 void *data_in);
109};
110
111struct _Eet_Data_Chunk
112{
113 char *name;
114 int len;
115 int size;
116 int hash;
117 void *data;
118 unsigned char type;
119 unsigned char group_type;
120};
121
122struct _Eet_Data_Stream
123{
124 void *data;
125 int size;
126 int pos;
127};
128
129struct _Eet_Data_Descriptor_Hash
130{
131 Eet_Data_Element *element;
132 Eet_Data_Descriptor_Hash *next;
133};
134
135struct _Eet_Data_Descriptor
136{
137 const char *name;
138 const Eet_Dictionary *ed;
139 int size;
140 struct
141 {
142 void * (*mem_alloc)(size_t size);
143 void (*mem_free)(void *mem);
144 char * (*str_alloc)(const char *str);
145 char * (*str_direct_alloc)(const char *str);
146 void (*str_free)(const char *str);
147 void (*str_direct_free)(const char *str);
148 void * (*list_next)(void *l);
149 void * (*list_append)(void *l, void *d);
150 void * (*list_data)(void *l);
151 void * (*list_free)(void *l);
152 void (*hash_foreach)(void *h,
153 int (*func)(void *h,
154 const char *k,
155 void *dt,
156 void *fdt),
157 void *fdt);
158 void * (*hash_add)(void *h, const char *k, void *d);
159 void (*hash_free)(void *h);
160 const char *(*type_get)(const void *data, Eina_Bool *unknow);
161 Eina_Bool (*type_set)(const char *type,
162 void *data,
163 Eina_Bool unknow);
164 void * (*array_alloc)(size_t size);
165 void (*array_free)(void *mem);
166 } func;
167 struct
168 {
169 int num;
170 Eet_Data_Element *set;
171 struct
172 {
173 int size;
174 Eet_Data_Descriptor_Hash *buckets;
175 } hash;
176 } elements;
177
178 Eina_Bool unified_type : 1;
179// char *strings;
180// int strings_len;
181};
182
183struct _Eet_Data_Element
184{
185 const char *name;
186 const char *counter_name;
187 const char *directory_name_ptr;
188 Eet_Data_Descriptor *subtype;
189 int offset; /* offset in bytes from the base element */
190 int count; /* number of elements for a fixed array */
191 int counter_offset; /* for a variable array we need the offset of the count variable */
192 unsigned char type; /* EET_T_XXX */
193 unsigned char group_type; /* EET_G_XXX */
194};
195
196struct _Eet_Data_Encode_Hash_Info
197{
198 Eet_Data_Stream *ds;
199 Eet_Data_Element *ede;
200 Eet_Dictionary *ed;
201};
202
203#define EET_FREE_COUNT 256
204struct _Eet_Free
205{
206 int ref;
207 Eina_Array list[EET_FREE_COUNT];
208};
209
210struct _Eet_Free_Context
211{
212 Eet_Free freelist;
213 Eet_Free freelist_array;
214 Eet_Free freelist_list;
215 Eet_Free freelist_hash;
216 Eet_Free freelist_str;
217 Eet_Free freelist_direct_str;
218};
219
220struct _Eet_Variant_Unknow
221{
222 EINA_MAGIC
223
224 int size;
225 char data[1];
226};
227
228/*---*/
229
230static void
231 eet_free_context_init(Eet_Free_Context *context);
232static void
233 eet_free_context_shutdown(Eet_Free_Context *context);
234
235static int
236eet_data_get_char(const Eet_Dictionary *ed,
237 const void *src,
238 const void *src_end,
239 void *dest);
240static void *
241eet_data_put_char(Eet_Dictionary *ed,
242 const void *src,
243 int *size_ret);
244static int
245eet_data_get_short(const Eet_Dictionary *ed,
246 const void *src,
247 const void *src_end,
248 void *dest);
249static void *
250eet_data_put_short(Eet_Dictionary *ed,
251 const void *src,
252 int *size_ret);
253static inline int
254eet_data_get_int(const Eet_Dictionary *ed,
255 const void *src,
256 const void *src_end,
257 void *dest);
258static void *
259eet_data_put_int(Eet_Dictionary *ed,
260 const void *src,
261 int *size_ret);
262static int
263eet_data_get_long_long(const Eet_Dictionary *ed,
264 const void *src,
265 const void *src_end,
266 void *dest);
267static void *
268eet_data_put_long_long(Eet_Dictionary *ed,
269 const void *src,
270 int *size_ret);
271static int
272eet_data_get_float(const Eet_Dictionary *ed,
273 const void *src,
274 const void *src_end,
275 void *dest);
276static void *
277eet_data_put_float(Eet_Dictionary *ed,
278 const void *src,
279 int *size_ret);
280static int
281eet_data_get_double(const Eet_Dictionary *ed,
282 const void *src,
283 const void *src_end,
284 void *dest);
285static void *
286eet_data_put_double(Eet_Dictionary *ed,
287 const void *src,
288 int *size_ret);
289static int
290eet_data_get_f32p32(const Eet_Dictionary *ed,
291 const void *src,
292 const void *src_end,
293 void *dest);
294static void *
295eet_data_put_f32p32(Eet_Dictionary *ed,
296 const void *src,
297 int *size_ret);
298static int
299eet_data_get_f16p16(const Eet_Dictionary *ed,
300 const void *src,
301 const void *src_end,
302 void *dest);
303static void *
304eet_data_put_f16p16(Eet_Dictionary *ed,
305 const void *src,
306 int *size_ret);
307static int
308eet_data_get_f8p24(const Eet_Dictionary *ed,
309 const void *src,
310 const void *src_end,
311 void *dest);
312static void *
313eet_data_put_f8p24(Eet_Dictionary *ed,
314 const void *src,
315 int *size_ret);
316static inline int
317eet_data_get_string(const Eet_Dictionary *ed,
318 const void *src,
319 const void *src_end,
320 void *dest);
321static void *
322eet_data_put_string(Eet_Dictionary *ed,
323 const void *src,
324 int *size_ret);
325static int
326eet_data_get_istring(const Eet_Dictionary *ed,
327 const void *src,
328 const void *src_end,
329 void *dest);
330static void *
331eet_data_put_istring(Eet_Dictionary *ed,
332 const void *src,
333 int *size_ret);
334static int
335eet_data_get_null(const Eet_Dictionary *ed,
336 const void *src,
337 const void *src_end,
338 void *dest);
339static void *
340eet_data_put_null(Eet_Dictionary *ed,
341 const void *src,
342 int *size_ret);
343
344static int
345eet_data_get_type(const Eet_Dictionary *ed,
346 int type,
347 const void *src,
348 const void *src_end,
349 void *dest);
350static void *
351eet_data_put_type(Eet_Dictionary *ed,
352 int type,
353 const void *src,
354 int *size_ret);
355
356static Eet_Node *
357eet_data_node_simple_type(int type,
358 const char *name,
359 void *dd);
360
361static int
362eet_data_get_unknown(Eet_Free_Context *context,
363 const Eet_Dictionary *ed,
364 Eet_Data_Descriptor *edd,
365 Eet_Data_Element *ede,
366 Eet_Data_Chunk *echnk,
367 int type,
368 int group_type,
369 void *data_in,
370 char **p,
371 int *size);
372static void
373eet_data_put_unknown(Eet_Dictionary *ed,
374 Eet_Data_Descriptor *edd,
375 Eet_Data_Element *ede,
376 Eet_Data_Stream *ds,
377 void *data_in);
378static void
379eet_data_put_array(Eet_Dictionary *ed,
380 Eet_Data_Descriptor *edd,
381 Eet_Data_Element *ede,
382 Eet_Data_Stream *ds,
383 void *data_in);
384static int
385eet_data_get_array(Eet_Free_Context *context,
386 const Eet_Dictionary *ed,
387 Eet_Data_Descriptor *edd,
388 Eet_Data_Element *ede,
389 Eet_Data_Chunk *echnk,
390 int type,
391 int group_type,
392 void *data,
393 char **p,
394 int *size);
395static int
396eet_data_get_list(Eet_Free_Context *context,
397 const Eet_Dictionary *ed,
398 Eet_Data_Descriptor *edd,
399 Eet_Data_Element *ede,
400 Eet_Data_Chunk *echnk,
401 int type,
402 int group_type,
403 void *data_in,
404 char **p,
405 int *size);
406static void
407eet_data_put_list(Eet_Dictionary *ed,
408 Eet_Data_Descriptor *edd,
409 Eet_Data_Element *ede,
410 Eet_Data_Stream *ds,
411 void *data_in);
412static void
413eet_data_put_hash(Eet_Dictionary *ed,
414 Eet_Data_Descriptor *edd,
415 Eet_Data_Element *ede,
416 Eet_Data_Stream *ds,
417 void *data_in);
418static int
419eet_data_get_hash(Eet_Free_Context *context,
420 const Eet_Dictionary *ed,
421 Eet_Data_Descriptor *edd,
422 Eet_Data_Element *ede,
423 Eet_Data_Chunk *echnk,
424 int type,
425 int group_type,
426 void *data,
427 char **p,
428 int *size);
429static void
430eet_data_put_union(Eet_Dictionary *ed,
431 Eet_Data_Descriptor *edd,
432 Eet_Data_Element *ede,
433 Eet_Data_Stream *ds,
434 void *data_in);
435static int
436eet_data_get_union(Eet_Free_Context *context,
437 const Eet_Dictionary *ed,
438 Eet_Data_Descriptor *edd,
439 Eet_Data_Element *ede,
440 Eet_Data_Chunk *echnk,
441 int type,
442 int group_type,
443 void *data,
444 char **p,
445 int *size);
446static void
447eet_data_put_variant(Eet_Dictionary *ed,
448 Eet_Data_Descriptor *edd,
449 Eet_Data_Element *ede,
450 Eet_Data_Stream *ds,
451 void *data_in);
452static int
453eet_data_get_variant(Eet_Free_Context *context,
454 const Eet_Dictionary *ed,
455 Eet_Data_Descriptor *edd,
456 Eet_Data_Element *ede,
457 Eet_Data_Chunk *echnk,
458 int type,
459 int group_type,
460 void *data,
461 char **p,
462 int *size);
463
464static void
465eet_data_chunk_get(const Eet_Dictionary *ed,
466 Eet_Data_Chunk *chnk,
467 const void *src,
468 int size);
469static Eet_Data_Chunk *
470eet_data_chunk_new(void *data,
471 int size,
472 const char *name,
473 int type,
474 int group_type);
475static void
476eet_data_chunk_free(Eet_Data_Chunk *chnk);
477
478static Eet_Data_Stream *
479 eet_data_stream_new(void);
480static void
481 eet_data_stream_write(Eet_Data_Stream *ds,
482 const void *data,
483 int size);
484static void
485eet_data_stream_free(Eet_Data_Stream *ds);
486
487static void
488eet_data_chunk_put(Eet_Dictionary *ed,
489 Eet_Data_Chunk *chnk,
490 Eet_Data_Stream *ds);
491
492static int
493eet_data_descriptor_encode_hash_cb(void *hash,
494 const char *key,
495 void *hdata,
496 void *fdata);
497static void *_eet_data_descriptor_encode(Eet_Dictionary *ed,
498 Eet_Data_Descriptor *edd,
499 const void *data_in,
500 int *size_ret);
501static void *_eet_data_descriptor_decode(Eet_Free_Context *context,
502 const Eet_Dictionary *ed,
503 Eet_Data_Descriptor *edd,
504 const void *data_in,
505 int size_in,
506 void *data_out,
507 int size_out);
508
509/*---*/
510
511static const Eet_Data_Basic_Type_Codec eet_basic_codec[] =
512{
513 {sizeof(char), "char", eet_data_get_char, eet_data_put_char },
514 {sizeof(short), "short", eet_data_get_short, eet_data_put_short },
515 {sizeof(int), "int", eet_data_get_int, eet_data_put_int },
516 {sizeof(long long), "long_long", eet_data_get_long_long, eet_data_put_long_long},
517 {sizeof(float), "float", eet_data_get_float, eet_data_put_float },
518 {sizeof(double), "double", eet_data_get_double, eet_data_put_double },
519 {sizeof(char), "uchar", eet_data_get_char, eet_data_put_char },
520 {sizeof(short), "ushort", eet_data_get_short, eet_data_put_short },
521 {sizeof(int), "uint", eet_data_get_int, eet_data_put_int },
522 {sizeof(long long), "ulong_long", eet_data_get_long_long, eet_data_put_long_long},
523 {sizeof(char *), "string", eet_data_get_string, eet_data_put_string },
524 {sizeof(char *), "inlined", eet_data_get_istring, eet_data_put_istring },
525 {sizeof(void *), "NULL", eet_data_get_null, eet_data_put_null },
526 {sizeof(Eina_F32p32), "f32p32", eet_data_get_f32p32, eet_data_put_f32p32 },
527 {sizeof(Eina_F16p16), "f16p16", eet_data_get_f16p16, eet_data_put_f16p16 },
528 {sizeof(Eina_F8p24), "f8p24", eet_data_get_f8p24, eet_data_put_f8p24 }
529};
530
531static const Eet_Data_Group_Type_Codec eet_group_codec[] =
532{
533 { eet_data_get_unknown, eet_data_put_unknown },
534 { eet_data_get_array, eet_data_put_array },
535 { eet_data_get_array, eet_data_put_array },
536 { eet_data_get_list, eet_data_put_list },
537 { eet_data_get_hash, eet_data_put_hash },
538 { eet_data_get_union, eet_data_put_union },
539 { eet_data_get_variant, eet_data_put_variant }
540};
541
542static int _eet_data_words_bigendian = -1;
543
544/*---*/
545
546#define SWAP64(x) (x) = \
547 ((((unsigned long long)(x) & 0x00000000000000ffULL) << 56) | \
548 (((unsigned long long)(x) & 0x000000000000ff00ULL) << 40) | \
549 (((unsigned long long)(x) & 0x0000000000ff0000ULL) << 24) | \
550 (((unsigned long long)(x) & 0x00000000ff000000ULL) << 8) | \
551 (((unsigned long long)(x) & 0x000000ff00000000ULL) >> 8) | \
552 (((unsigned long long)(x) & 0x0000ff0000000000ULL) >> 24) | \
553 (((unsigned long long)(x) & 0x00ff000000000000ULL) >> 40) | \
554 (((unsigned long long)(x) & 0xff00000000000000ULL) >> 56))
555#define SWAP32(x) (x) = \
556 ((((int)(x) & 0x000000ff) << 24) | \
557 (((int)(x) & 0x0000ff00) << 8) | \
558 (((int)(x) & 0x00ff0000) >> 8) | \
559 (((int)(x) & 0xff000000) >> 24))
560#define SWAP16(x) (x) = \
561 ((((short)(x) & 0x00ff) << 8) | \
562 (((short)(x) & 0xff00) >> 8))
563
564#ifdef CONV8
565# undef CONV8
566#endif /* ifdef CONV8 */
567#ifdef CONV16
568# undef CONV16
569#endif /* ifdef CONV16 */
570#ifdef CONV32
571# undef CONV32
572#endif /* ifdef CONV32 */
573#ifdef CONV64
574# undef CONV64
575#endif /* ifdef CONV64 */
576
577#define CONV8(x)
578#define CONV16(x) {if (_eet_data_words_bigendian) {SWAP16(x); }}
579#define CONV32(x) {if (_eet_data_words_bigendian) {SWAP32(x); }}
580#define CONV64(x) {if (_eet_data_words_bigendian) {SWAP64(x); }}
581
582#define IS_SIMPLE_TYPE(Type) (Type > EET_T_UNKNOW && Type < EET_T_LAST)
583#define IS_POINTER_TYPE(Type) (Type >= EET_T_STRING && Type <= EET_T_NULL)
584
585#define POINTER_TYPE_DECODE(Context, \
586 Ed, \
587 Edd, \
588 Ede, \
589 Echnk, \
590 Type, \
591 Data, \
592 P, \
593 Size, \
594 Label) \
595 do { \
596 int ___r; \
597 ___r = eet_data_get_unknown(Context, \
598 Ed, \
599 Edd, Ede, \
600 Echnk, \
601 Type, EET_G_UNKNOWN, \
602 Data, P, Size); \
603 if (!___r) { goto Label; } \
604 } while (0)
605
606#define STRUCT_TYPE_DECODE(Data_Ret, Context, Ed, Ede, Data, Size, SubSize, Label) \
607 do { \
608 Data_Ret = _eet_data_descriptor_decode(Context, \
609 Ed, \
610 Ede, \
611 Data, \
612 Size, \
613 SubSize > 0 ? Data_Ret : NULL, \
614 SubSize); \
615 if (!Data_Ret) { goto Label; } \
616 } while (0)
617
618#define EET_I_STRING 1 << 4
619#define EET_I_INLINED_STRING 2 << 4
620#define EET_I_NULL 3 << 4
621
622#define EET_MAGIC_VARIANT 0xF1234BC
623/*---*/
624
625/* CHAR TYPE */
626static int
627eet_data_get_char(const Eet_Dictionary *ed __UNUSED__,
628 const void *src,
629 const void *src_end,
630 void *dst)
631{
632 char *s, *d;
633
634 if (((char *)src + sizeof(char)) > (char *)src_end)
635 return -1;
636
637 s = (char *)src;
638 d = (char *)dst;
639 *d = *s;
640 CONV8(*d);
641 return sizeof(char);
642}
643
644static void *
645eet_data_put_char(Eet_Dictionary *ed __UNUSED__,
646 const void *src,
647 int *size_ret)
648{
649 char *s, *d;
650
651 d = (char *)malloc(sizeof(char));
652 if (!d)
653 return NULL;
654
655 s = (char *)src;
656 *d = *s;
657 CONV8(*d);
658 *size_ret = sizeof(char);
659 return d;
660}
661
662/* SHORT TYPE */
663static int
664eet_data_get_short(const Eet_Dictionary *ed __UNUSED__,
665 const void *src,
666 const void *src_end,
667 void *dst)
668{
669 short *d;
670
671 if (((char *)src + sizeof(short)) > (char *)src_end)
672 return -1;
673
674 memcpy(dst, src, sizeof(short));
675 d = (short *)dst;
676 CONV16(*d);
677 return sizeof(short);
678}
679
680static void *
681eet_data_put_short(Eet_Dictionary *ed __UNUSED__,
682 const void *src,
683 int *size_ret)
684{
685 short *s, *d;
686
687 d = (short *)malloc(sizeof(short));
688 if (!d)
689 return NULL;
690
691 s = (short *)src;
692 *d = *s;
693 CONV16(*d);
694 *size_ret = sizeof(short);
695 return d;
696}
697
698/* INT TYPE */
699static inline int
700eet_data_get_int(const Eet_Dictionary *ed __UNUSED__,
701 const void *src,
702 const void *src_end,
703 void *dst)
704{
705 int *d;
706
707 if (((char *)src + sizeof(int)) > (char *)src_end)
708 return -1;
709
710 memcpy(dst, src, sizeof(int));
711 d = (int *)dst;
712 CONV32(*d);
713 return sizeof(int);
714}
715
716static void *
717eet_data_put_int(Eet_Dictionary *ed __UNUSED__,
718 const void *src,
719 int *size_ret)
720{
721 int *s, *d;
722
723 d = (int *)malloc(sizeof(int));
724 if (!d)
725 return NULL;
726
727 s = (int *)src;
728 *d = *s;
729 CONV32(*d);
730 *size_ret = sizeof(int);
731 return d;
732}
733
734/* LONG LONG TYPE */
735static int
736eet_data_get_long_long(const Eet_Dictionary *ed __UNUSED__,
737 const void *src,
738 const void *src_end,
739 void *dst)
740{
741 unsigned long long *d;
742
743 if (((char *)src + sizeof(unsigned long long)) > (char *)src_end)
744 return -1;
745
746 memcpy(dst, src, sizeof(unsigned long long));
747 d = (unsigned long long *)dst;
748 CONV64(*d);
749 return sizeof(unsigned long long);
750}
751
752static void *
753eet_data_put_long_long(Eet_Dictionary *ed __UNUSED__,
754 const void *src,
755 int *size_ret)
756{
757 unsigned long long *s, *d;
758
759 d = (unsigned long long *)malloc(sizeof(unsigned long long));
760 if (!d)
761 return NULL;
762
763 s = (unsigned long long *)src;
764 *d = *s;
765 CONV64(*d);
766 *size_ret = sizeof(unsigned long long);
767 return d;
768}
769
770/* STRING TYPE */
771static inline int
772eet_data_get_string_hash(const Eet_Dictionary *ed,
773 const void *src,
774 const void *src_end)
775{
776 if (ed)
777 {
778 int idx;
779
780 if (eet_data_get_int(ed, src, src_end, &idx) < 0)
781 return -1;
782
783 return eet_dictionary_string_get_hash(ed, idx);
784 }
785
786 return -1;
787}
788
789static inline int
790eet_data_get_string(const Eet_Dictionary *ed,
791 const void *src,
792 const void *src_end,
793 void *dst)
794{
795 char *s, **d;
796
797 d = (char **)dst;
798
799 if (ed)
800 {
801 const char *str;
802 int idx;
803
804 if (eet_data_get_int(ed, src, src_end, &idx) < 0)
805 return -1;
806
807 str = eet_dictionary_string_get_char(ed, idx);
808 if (!str)
809 return -1;
810
811 *d = (char *)str;
812 return eet_dictionary_string_get_size(ed, idx);
813 }
814
815 s = (char *)src;
816 if (!s)
817 {
818 *d = NULL;
819 return 0;
820 }
821
822 *d = s;
823 return strlen(s) + 1;
824}
825
826static void *
827eet_data_put_string(Eet_Dictionary *ed,
828 const void *src,
829 int *size_ret)
830{
831 char *s, *d;
832 int len;
833
834 if (ed)
835 {
836 const char *str;
837 int idx;
838
839 str = *((const char **)src);
840 if (!str)
841 return NULL;
842
843 idx = eet_dictionary_string_add(ed, str);
844 if (idx == -1)
845 return NULL;
846
847 return eet_data_put_int(ed, &idx, size_ret);
848 }
849
850 s = (char *)(*((char **)src));
851 if (!s)
852 return NULL;
853
854 len = strlen(s);
855 d = malloc(len + 1);
856 if (!d)
857 return NULL;
858
859 memcpy(d, s, len + 1);
860 *size_ret = len + 1;
861 return d;
862}
863
864/* ALWAYS INLINED STRING TYPE */
865static int
866eet_data_get_istring(const Eet_Dictionary *ed __UNUSED__,
867 const void *src,
868 const void *src_end,
869 void *dst)
870{
871 return eet_data_get_string(NULL, src, src_end, dst);
872}
873
874static void *
875eet_data_put_istring(Eet_Dictionary *ed __UNUSED__,
876 const void *src,
877 int *size_ret)
878{
879 return eet_data_put_string(NULL, src, size_ret);
880}
881
882/* ALWAYS NULL TYPE */
883static int
884eet_data_get_null(const Eet_Dictionary *ed __UNUSED__,
885 const void *src __UNUSED__,
886 const void *src_end __UNUSED__,
887 void *dst)
888{
889 char **d;
890
891 d = (char **)dst;
892
893 *d = NULL;
894 return 1;
895}
896
897static void *
898eet_data_put_null(Eet_Dictionary *ed __UNUSED__,
899 const void *src __UNUSED__,
900 int *size_ret)
901{
902 *size_ret = 0;
903 return NULL;
904}
905
906/**
907 * Fast lookups of simple doubles/floats.
908 *
909 * These aren't properly a cache because they don't store pre-calculated
910 * values, but have a so simple math that is almost as fast.
911 */
912static inline int
913_eet_data_float_cache_get(const char *s,
914 int len,
915 float *d)
916{
917 /* fast handle of simple case 0xMp+E*/
918 if ((len == 6) && (s[0] == '0') && (s[1] == 'x') && (s[3] == 'p'))
919 {
920 int mantisse = (s[2] >= 'a') ? (s[2] - 'a' + 10) : (s[2] - '0');
921 int exponent = (s[5] - '0');
922
923 if (s[4] == '+')
924 *d = (float)(mantisse << exponent);
925 else
926 *d = (float)mantisse / (float)(1 << exponent);
927
928 return 1;
929 }
930
931 return 0;
932}
933
934static inline int
935_eet_data_double_cache_get(const char *s,
936 int len,
937 double *d)
938{
939 /* fast handle of simple case 0xMp+E*/
940 if ((len == 6) && (s[0] == '0') && (s[1] == 'x') && (s[3] == 'p'))
941 {
942 int mantisse = (s[2] >= 'a') ? (s[2] - 'a' + 10) : (s[2] - '0');
943 int exponent = (s[5] - '0');
944
945 if (s[4] == '+')
946 *d = (double)(mantisse << exponent);
947 else
948 *d = (double)mantisse / (double)(1 << exponent);
949
950 return 1;
951 }
952
953 return 0;
954}
955
956/* FLOAT TYPE */
957static int
958eet_data_get_float(const Eet_Dictionary *ed,
959 const void *src,
960 const void *src_end,
961 void *dst)
962{
963 float *d;
964 int idx;
965
966 d = (float *)dst;
967 if (!ed)
968 {
969 const char *s, *p;
970 long long mantisse;
971 long exponent;
972 int len;
973
974 s = (const char *)src;
975 p = s;
976 len = 0;
977 while ((p < (const char *)src_end) && (*p != 0)) {len++; p++; }
978
979 if (_eet_data_float_cache_get(s, len, d) != 0)
980 return len + 1;
981
982 if (eina_convert_atod(s, len, &mantisse, &exponent) == EINA_FALSE)
983 return -1;
984
985 *d = (float)ldexp((double)mantisse, exponent);
986
987 return len + 1;
988 }
989
990 if (eet_data_get_int(ed, src, src_end, &idx) < 0)
991 return -1;
992
993 if (!eet_dictionary_string_get_float(ed, idx, d))
994 return -1;
995
996 return 1;
997}
998
999static void *
1000eet_data_put_float(Eet_Dictionary *ed,
1001 const void *src,
1002 int *size_ret)
1003{
1004 char buf[128];
1005 int idx;
1006
1007 eina_convert_dtoa((double)(*(float *)src), buf);
1008
1009 if (!ed)
1010 {
1011 char *d;
1012 int len;
1013
1014 len = strlen(buf);
1015 d = malloc(len + 1);
1016 if (!d)
1017 return NULL;
1018
1019 memcpy(d, buf, len + 1);
1020 *size_ret = len + 1;
1021 return d;
1022 }
1023
1024 idx = eet_dictionary_string_add(ed, buf);
1025 if (idx == -1)
1026 return NULL;
1027
1028 return eet_data_put_int(ed, &idx, size_ret);
1029}
1030
1031/* DOUBLE TYPE */
1032static int
1033eet_data_get_double(const Eet_Dictionary *ed,
1034 const void *src,
1035 const void *src_end,
1036 void *dst)
1037{
1038 double *d;
1039 int idx;
1040
1041 d = (double *)dst;
1042
1043 if (!ed)
1044 {
1045 const char *s, *p;
1046 long long mantisse = 0;
1047 long exponent = 0;
1048 int len;
1049
1050 s = (const char *)src;
1051 p = s;
1052 len = 0;
1053 while ((p < (const char *)src_end) && (*p != 0)) {len++; p++; }
1054
1055 if (_eet_data_double_cache_get(s, len, d) != 0)
1056 return len + 1;
1057
1058 if (eina_convert_atod(s, len, &mantisse, &exponent) == EINA_FALSE)
1059 return -1;
1060
1061 *d = ldexp((double)mantisse, exponent);
1062
1063 return len + 1;
1064 }
1065
1066 if (eet_data_get_int(ed, src, src_end, &idx) < 0)
1067 return -1;
1068
1069 if (!eet_dictionary_string_get_double(ed, idx, d))
1070 return -1;
1071
1072 return 1;
1073}
1074
1075static void *
1076eet_data_put_double(Eet_Dictionary *ed,
1077 const void *src,
1078 int *size_ret)
1079{
1080 char buf[128];
1081 int idx;
1082
1083 eina_convert_dtoa((double)(*(double *)src), buf);
1084
1085 if (!ed)
1086 {
1087 char *d;
1088 int len;
1089
1090 len = strlen(buf);
1091 d = malloc(len + 1);
1092 if (!d)
1093 return NULL;
1094
1095 memcpy(d, buf, len + 1);
1096 *size_ret = len + 1;
1097
1098 return d;
1099 }
1100
1101 idx = eet_dictionary_string_add(ed, buf);
1102 if (idx == -1)
1103 return NULL;
1104
1105 return eet_data_put_int(ed, &idx, size_ret);
1106}
1107
1108static int
1109eet_data_get_f32p32(const Eet_Dictionary *ed,
1110 const void *src,
1111 const void *src_end,
1112 void *dst)
1113{
1114 Eina_F32p32 *fp;
1115 int idx;
1116
1117 fp = (Eina_F32p32 *)dst;
1118
1119 if (!ed)
1120 {
1121 const char *s, *p;
1122 int len;
1123
1124 s = (const char *)src;
1125 p = s;
1126 len = 0;
1127 while ((p < (const char *)src_end) && (*p != 0)) { len++; p++; }
1128
1129 if (!(eina_convert_atofp(s, len, fp)))
1130 return -1;
1131
1132 return 1;
1133 }
1134
1135 if (eet_data_get_int(ed, src, src_end, &idx) < 0)
1136 return -1;
1137
1138 if (!eet_dictionary_string_get_fp(ed, idx, fp))
1139 return -1;
1140
1141 return 1;
1142}
1143
1144static void *
1145eet_data_put_f32p32(Eet_Dictionary *ed,
1146 const void *src,
1147 int *size_ret)
1148{
1149 char buf[128];
1150 int idx;
1151
1152 eina_convert_fptoa((Eina_F32p32)(*(Eina_F32p32 *)src), buf);
1153
1154 if (!ed)
1155 {
1156 char *d;
1157 int len;
1158
1159 len = strlen(buf);
1160 d = malloc(len + 1);
1161 if (!d)
1162 return NULL;
1163
1164 memcpy(d, buf, len + 1);
1165 *size_ret = len + 1;
1166
1167 return d;
1168 }
1169
1170 idx = eet_dictionary_string_add(ed, buf);
1171 if (idx == -1)
1172 return NULL;
1173
1174 return eet_data_put_int(ed, &idx, size_ret);
1175}
1176
1177static int
1178eet_data_get_f16p16(const Eet_Dictionary *ed,
1179 const void *src,
1180 const void *src_end,
1181 void *dst)
1182{
1183 Eina_F32p32 tmp;
1184 Eina_F16p16 *fp;
1185
1186 fp = (Eina_F16p16 *)dst;
1187
1188 if (eet_data_get_f32p32(ed, src, src_end, &tmp) < 0)
1189 return -1;
1190
1191 *fp = eina_f32p32_to_f16p16(tmp);
1192 return 1;
1193}
1194
1195static void *
1196eet_data_put_f16p16(Eet_Dictionary *ed,
1197 const void *src,
1198 int *size_ret)
1199{
1200 Eina_F32p32 tmp;
1201
1202 tmp = eina_f16p16_to_f32p32((Eina_F16p16)(*(Eina_F16p16 *)src));
1203 return eet_data_put_f32p32(ed, &tmp, size_ret);
1204}
1205
1206static int
1207eet_data_get_f8p24(const Eet_Dictionary *ed,
1208 const void *src,
1209 const void *src_end,
1210 void *dst)
1211{
1212 Eina_F32p32 tmp;
1213 Eina_F8p24 *fp;
1214
1215 fp = (Eina_F8p24 *)dst;
1216
1217 if (eet_data_get_f32p32(ed, src, src_end, &tmp) < 0)
1218 return -1;
1219
1220 *fp = eina_f32p32_to_f8p24(tmp);
1221 return 1;
1222}
1223
1224static void *
1225eet_data_put_f8p24(Eet_Dictionary *ed,
1226 const void *src,
1227 int *size_ret)
1228{
1229 Eina_F32p32 tmp;
1230
1231 tmp = eina_f8p24_to_f32p32((Eina_F8p24)(*(Eina_F8p24 *)src));
1232 return eet_data_put_f32p32(ed, &tmp, size_ret);
1233}
1234
1235static inline int
1236eet_data_get_type(const Eet_Dictionary *ed,
1237 int type,
1238 const void *src,
1239 const void *src_end,
1240 void *dest)
1241{
1242 int ret;
1243
1244 ret = eet_basic_codec[type - 1].get(ed, src, src_end, dest);
1245 return ret;
1246}
1247
1248static inline void *
1249eet_data_put_type(Eet_Dictionary *ed,
1250 int type,
1251 const void *src,
1252 int *size_ret)
1253{
1254 void *ret;
1255
1256 ret = eet_basic_codec[type - 1].put(ed, src, size_ret);
1257 return ret;
1258}
1259
1260static inline Eina_Bool
1261eet_data_type_match(int type1,
1262 int type2)
1263{
1264 if (type1 == type2)
1265 return EINA_TRUE;
1266
1267 /* Note: All floating point type are equivalent and could be read
1268 without problem by any other floating point getter. */
1269 switch (type1)
1270 {
1271 case EET_T_FLOAT:
1272 case EET_T_DOUBLE:
1273 case EET_T_F32P32:
1274 case EET_T_F16P16:
1275 case EET_T_F8P24:
1276 switch (type2)
1277 {
1278 case EET_T_FLOAT:
1279 case EET_T_DOUBLE:
1280 case EET_T_F32P32:
1281 case EET_T_F16P16:
1282 case EET_T_F8P24:
1283 return EINA_TRUE;
1284
1285 default:
1286 break;
1287 } /* switch */
1288 break;
1289
1290 default:
1291 break;
1292 }
1293
1294 return EINA_FALSE;
1295}
1296
1297/* chunk format...
1298 *
1299 * char[4] = "CHnK"; // untyped data ... or
1300 * char[4] = "CHKx"; // typed data - x == type
1301 *
1302 * int = chunk size (including magic string);
1303 * char[] = chunk magic/name string (0 byte terminated);
1304 * ... sub-chunks (a chunk can contain chuncks recusrively) ...
1305 * or
1306 * ... payload data ...
1307 *
1308 */
1309
1310static inline void
1311eet_data_chunk_get(const Eet_Dictionary *ed,
1312 Eet_Data_Chunk *chnk,
1313 const void *src,
1314 int size)
1315{
1316 const char *s;
1317 int ret1, ret2;
1318
1319 if (!src)
1320 return;
1321
1322 if (size <= 8)
1323 return;
1324
1325 if (!chnk)
1326 return;
1327
1328 s = src;
1329 if (s[2] == 'K')
1330 {
1331 if ((s[0] != 'C') || (s[1] != 'H') || (s[2] != 'K'))
1332 return;
1333
1334 chnk->type = (unsigned char)(s[3]);
1335 if (chnk->type >= EET_I_LIMIT)
1336 {
1337 chnk->group_type =
1338 ((chnk->type - EET_I_LIMIT) & 0xF) + EET_G_UNKNOWN;
1339 switch ((chnk->type - EET_I_LIMIT) & 0xF0)
1340 {
1341#define EET_UNMATCH_TYPE(Type) \
1342case EET_I_ ## Type: chnk->type = EET_T_ ## Type; break;
1343
1344 EET_UNMATCH_TYPE(STRING);
1345 EET_UNMATCH_TYPE(INLINED_STRING);
1346 EET_UNMATCH_TYPE(NULL);
1347
1348 default:
1349 return;
1350 }
1351 }
1352 else if (chnk->type > EET_T_LAST)
1353 {
1354 chnk->group_type = chnk->type;
1355 chnk->type = EET_T_UNKNOW;
1356 }
1357 else
1358 chnk->group_type = EET_G_UNKNOWN;
1359 if ((chnk->type >= EET_T_LAST) ||
1360 (chnk->group_type >=
1361 EET_G_LAST))
1362 {
1363 chnk->type = 0;
1364 chnk->group_type = 0;
1365 }
1366 }
1367 else if ((s[0] != 'C') || (s[1] != 'H') || (s[2] != 'n') || (s[3] != 'K'))
1368 return;
1369
1370 ret1 = eet_data_get_type(ed, EET_T_INT, (s + 4), (s + size), &(chnk->size));
1371
1372 if (ret1 <= 0)
1373 return;
1374
1375 if ((chnk->size < 0) || ((chnk->size + 8) > size))
1376 return;
1377
1378 ret2 = eet_data_get_type(ed, EET_T_STRING, (s + 8), (s + size), &(chnk->name));
1379
1380 if (ret2 <= 0)
1381 return;
1382
1383 chnk->len = ret2;
1384
1385 /* Precalc hash */
1386 chnk->hash = eet_data_get_string_hash(ed, (s + 8), (s + size));
1387
1388 if (ed)
1389 {
1390 chnk->data = (char *)src + 4 + ret1 + sizeof(int);
1391 chnk->size -= sizeof(int);
1392 }
1393 else
1394 {
1395 chnk->data = (char *)src + 4 + ret1 + chnk->len;
1396 chnk->size -= chnk->len;
1397 }
1398
1399 return;
1400}
1401
1402static inline Eet_Data_Chunk *
1403eet_data_chunk_new(void *data,
1404 int size,
1405 const char *name,
1406 int type,
1407 int group_type)
1408{
1409 Eet_Data_Chunk *chnk;
1410
1411 if (!name)
1412 return NULL;
1413
1414 chnk = calloc(1, sizeof(Eet_Data_Chunk));
1415 if (!chnk)
1416 return NULL;
1417
1418 /* Note: Another security, so older eet library could read file
1419 saved with fixed point value. */
1420 if (type == EET_T_F32P32
1421 || type == EET_T_F16P16
1422 || type == EET_T_F8P24)
1423 type = EET_T_DOUBLE;
1424
1425 chnk->name = strdup(name);
1426 chnk->len = strlen(name) + 1;
1427 chnk->size = size;
1428 chnk->data = data;
1429 chnk->type = type;
1430 chnk->group_type = group_type;
1431 return chnk;
1432}
1433
1434static inline void
1435eet_data_chunk_free(Eet_Data_Chunk *chnk)
1436{
1437 if (chnk->name)
1438 free(chnk->name);
1439
1440 free(chnk);
1441}
1442
1443static inline Eet_Data_Stream *
1444eet_data_stream_new(void)
1445{
1446 Eet_Data_Stream *ds;
1447
1448 ds = calloc(1, sizeof(Eet_Data_Stream));
1449 if (!ds)
1450 return NULL;
1451
1452 return ds;
1453}
1454
1455static inline void
1456eet_data_stream_free(Eet_Data_Stream *ds)
1457{
1458 if (ds->data)
1459 free(ds->data);
1460
1461 free(ds);
1462}
1463
1464static inline void
1465eet_data_stream_flush(Eet_Data_Stream *ds)
1466{
1467 free(ds);
1468}
1469
1470static inline void
1471eet_data_stream_write(Eet_Data_Stream *ds,
1472 const void *data,
1473 int size)
1474{
1475 char *p;
1476
1477 if ((ds->pos + size) > ds->size)
1478 {
1479 ds->data = realloc(ds->data, ds->size + size + 512);
1480 if (!ds->data)
1481 {
1482 ds->pos = 0;
1483 ds->size = 0;
1484 return;
1485 }
1486
1487 ds->size = ds->size + size + 512;
1488 }
1489
1490 p = ds->data;
1491 memcpy(p + ds->pos, data, size);
1492 ds->pos += size;
1493}
1494
1495static void
1496eet_data_chunk_put(Eet_Dictionary *ed,
1497 Eet_Data_Chunk *chnk,
1498 Eet_Data_Stream *ds)
1499{
1500 int *size;
1501 void *string;
1502 int s;
1503 int size_ret = 0;
1504 int string_ret = 0;
1505 unsigned char buf[4] = "CHK";
1506
1507 /* disable this check - it will allow empty chunks to be written. this is
1508 * right for corner-cases when y have a struct with empty fields (empty
1509 * strings or empty list ptrs etc.) */
1510 /* if (!chnk->data && chnk->type != EET_T_NULL) return; */
1511 /* chunk head */
1512
1513/* eet_data_stream_write(ds, "CHnK", 4);*/
1514 if (chnk->type != EET_T_UNKNOW)
1515 {
1516 if (chnk->group_type != EET_G_UNKNOWN)
1517 {
1518 int type = EET_I_LIMIT + chnk->group_type - EET_G_UNKNOWN;
1519
1520 switch (chnk->type)
1521 {
1522 /* Only make sense with pointer type. */
1523#define EET_MATCH_TYPE(Type) \
1524case EET_T_ ## Type: type += EET_I_ ## Type; break;
1525
1526 EET_MATCH_TYPE(STRING);
1527 EET_MATCH_TYPE(INLINED_STRING);
1528 EET_MATCH_TYPE(NULL);
1529
1530 default:
1531 return;
1532 }
1533
1534 buf[3] = type;
1535 }
1536 else
1537 buf[3] = chnk->type;
1538 }
1539 else
1540 buf[3] = chnk->group_type;
1541
1542 string = eet_data_put_string(ed, &chnk->name, &string_ret);
1543 if (!string)
1544 return;
1545
1546 /* size of chunk payload data + name */
1547 s = chnk->size + string_ret;
1548 size = eet_data_put_int(ed, &s, &size_ret);
1549
1550 /* FIXME: If something goes wrong the resulting file will be corrupted. */
1551 if (!size)
1552 goto on_error;
1553
1554 eet_data_stream_write(ds, buf, 4);
1555
1556 /* write chunk length */
1557 eet_data_stream_write(ds, size, size_ret);
1558
1559 /* write chunk name */
1560 eet_data_stream_write(ds, string, string_ret);
1561
1562 /* write payload */
1563 if (chnk->data)
1564 eet_data_stream_write(ds, chnk->data, chnk->size);
1565
1566 free(string);
1567on_error:
1568 free(size);
1569}
1570
1571/*---*/
1572
1573static void
1574_eet_descriptor_hash_new(Eet_Data_Descriptor *edd)
1575{
1576 int i;
1577
1578 edd->elements.hash.size = 1 << 6;
1579 edd->elements.hash.buckets = calloc(
1580 1,
1581 sizeof(Eet_Data_Descriptor_Hash) *
1582 edd->elements.hash.size);
1583 for (i = 0; i < edd->elements.num; i++)
1584 {
1585 Eet_Data_Element *ede;
1586 int hash;
1587
1588 ede = &(edd->elements.set[i]);
1589 hash = _eet_hash_gen((char *)ede->name, 6);
1590 if (!edd->elements.hash.buckets[hash].element)
1591 edd->elements.hash.buckets[hash].element = ede;
1592 else
1593 {
1594 Eet_Data_Descriptor_Hash *bucket;
1595
1596 bucket = calloc(1, sizeof(Eet_Data_Descriptor_Hash));
1597 bucket->element = ede;
1598 bucket->next = edd->elements.hash.buckets[hash].next;
1599 edd->elements.hash.buckets[hash].next = bucket;
1600 }
1601 }
1602}
1603
1604static void
1605_eet_descriptor_hash_free(Eet_Data_Descriptor *edd)
1606{
1607 int i;
1608
1609 for (i = 0; i < edd->elements.hash.size; i++)
1610 {
1611 Eet_Data_Descriptor_Hash *bucket, *pbucket;
1612
1613 bucket = edd->elements.hash.buckets[i].next;
1614 while (bucket)
1615 {
1616 pbucket = bucket;
1617 bucket = bucket->next;
1618 free(pbucket);
1619 }
1620 }
1621 if (edd->elements.hash.buckets)
1622 free(edd->elements.hash.buckets);
1623}
1624
1625static Eet_Data_Element *
1626_eet_descriptor_hash_find(Eet_Data_Descriptor *edd,
1627 char *name,
1628 int hash)
1629{
1630 Eet_Data_Descriptor_Hash *bucket;
1631
1632 if (hash < 0)
1633 hash = _eet_hash_gen(name, 6);
1634 else
1635 hash &= 0x3f;
1636
1637 if (!edd->elements.hash.buckets[hash].element)
1638 return NULL; /*
1639 When we use the dictionary as a source for chunk name, we will always
1640 have the same pointer in name. It's a good idea to just compare pointer
1641 instead of running strcmp on both string.
1642 */
1643
1644 if (edd->elements.hash.buckets[hash].element->directory_name_ptr == name)
1645 return edd->elements.hash.buckets[hash].element;
1646
1647 if (!strcmp(edd->elements.hash.buckets[hash].element->name, name))
1648 {
1649 edd->elements.hash.buckets[hash].element->directory_name_ptr = name;
1650 return edd->elements.hash.buckets[hash].element;
1651 }
1652
1653 bucket = edd->elements.hash.buckets[hash].next;
1654 while (bucket)
1655 {
1656 if (bucket->element->directory_name_ptr == name)
1657 return bucket->element;
1658
1659 if (!strcmp(bucket->element->name, name))
1660 {
1661 bucket->element->directory_name_ptr = name;
1662 return bucket->element;
1663 }
1664
1665 bucket = bucket->next;
1666 }
1667 return NULL;
1668}
1669
1670static void *
1671_eet_mem_alloc(size_t size)
1672{
1673 return calloc(1, size);
1674}
1675
1676static void
1677_eet_mem_free(void *mem)
1678{
1679 free(mem);
1680}
1681
1682static char *
1683_eet_str_alloc(const char *str)
1684{
1685 return strdup(str);
1686}
1687
1688static void
1689_eet_str_free(const char *str)
1690{
1691 free((char *)str);
1692}
1693
1694static Eina_Hash *
1695_eet_eina_hash_add_alloc(Eina_Hash *hash,
1696 const char *key,
1697 void *data)
1698{
1699 if (!hash)
1700 hash = eina_hash_string_small_new(NULL);
1701
1702 if (!hash)
1703 return NULL;
1704
1705 eina_hash_add(hash, key, data);
1706 return hash;
1707}
1708
1709static Eina_Hash *
1710_eet_eina_hash_direct_add_alloc(Eina_Hash *hash,
1711 const char *key,
1712 void *data)
1713{
1714 if (!hash)
1715 hash = eina_hash_string_small_new(NULL);
1716
1717 if (!hash)
1718 return NULL;
1719
1720 eina_hash_direct_add(hash, key, data);
1721 return hash;
1722}
1723
1724static char *
1725_eet_str_direct_alloc(const char *str)
1726{
1727 return (char *)str;
1728}
1729
1730static void
1731_eet_str_direct_free(const char *str __UNUSED__)
1732{
1733}
1734
1735static void
1736_eet_eina_hash_foreach(void *hash,
1737 Eina_Hash_Foreach cb,
1738 void *fdata)
1739{
1740 if (hash)
1741 eina_hash_foreach(hash, cb, fdata);
1742}
1743
1744static void
1745_eet_eina_hash_free(void *hash)
1746{
1747 if (hash)
1748 eina_hash_free(hash);
1749}
1750
1751/*---*/
1752EAPI Eina_Bool
1753eet_eina_stream_data_descriptor_class_set(Eet_Data_Descriptor_Class *eddc,
1754 /* When we change the structure content in the future, we need to handle old structure type too */
1755 unsigned int eddc_size,
1756 const char *name,
1757 int size)
1758{
1759 if (!eddc || !name || eddc_size != sizeof (Eet_Data_Descriptor_Class))
1760 return EINA_FALSE;
1761
1762 eddc->name = name;
1763 eddc->size = size;
1764 eddc->version = EET_DATA_DESCRIPTOR_CLASS_VERSION;
1765
1766 eddc->func.mem_alloc = _eet_mem_alloc;
1767 eddc->func.mem_free = _eet_mem_free;
1768 eddc->func.str_alloc = (char *(*)(const char *))eina_stringshare_add;
1769 eddc->func.str_free = eina_stringshare_del;
1770 eddc->func.list_next = (void *(*)(void *))eina_list_next;
1771 eddc->func.list_append = (void *(*)(void *, void *))eina_list_append;
1772 eddc->func.list_data = (void *(*)(void *))eina_list_data_get;
1773 eddc->func.list_free = (void *(*)(void *))eina_list_free;
1774 eddc->func.hash_foreach = (void (*)(void *, int (*)(void *, const char *, void *, void *), void *))_eet_eina_hash_foreach;
1775 eddc->func.hash_add = (void *(*)(void *, const char *, void *))_eet_eina_hash_add_alloc;
1776 eddc->func.hash_free = (void (*)(void *))_eet_eina_hash_free;
1777
1778 /* This will cause an ABI incompatibility */
1779 eddc->func.array_alloc = _eet_mem_alloc;
1780 eddc->func.array_free = _eet_mem_free;
1781
1782 return EINA_TRUE;
1783}
1784
1785EAPI Eina_Bool
1786eet_eina_file_data_descriptor_class_set(Eet_Data_Descriptor_Class *eddc,
1787 /* When we change the structure content in the future, we need to handle old structure type too */
1788 unsigned int eddc_size,
1789 const char *name,
1790 int size)
1791{
1792 if (!eet_eina_stream_data_descriptor_class_set(eddc, eddc_size, name, size))
1793 return EINA_FALSE;
1794
1795 eddc->version = EET_DATA_DESCRIPTOR_CLASS_VERSION;
1796
1797 eddc->func.hash_add = (void *(*)(void *, const char *, void *))_eet_eina_hash_direct_add_alloc;
1798 eddc->func.str_direct_alloc = _eet_str_direct_alloc;
1799 eddc->func.str_direct_free = _eet_str_direct_free;
1800
1801 return EINA_TRUE;
1802}
1803
1804static Eet_Data_Descriptor *
1805_eet_data_descriptor_new(const Eet_Data_Descriptor_Class *eddc,
1806 int version)
1807{
1808 Eet_Data_Descriptor *edd;
1809
1810 if (!eddc)
1811 return NULL;
1812
1813 edd = calloc(1, sizeof (Eet_Data_Descriptor));
1814 if (!edd)
1815 return NULL;
1816
1817 edd->name = eddc->name;
1818 edd->ed = NULL;
1819 edd->size = eddc->size;
1820 edd->func.mem_alloc = _eet_mem_alloc;
1821 edd->func.mem_free = _eet_mem_free;
1822 edd->func.str_alloc = _eet_str_alloc;
1823 edd->func.str_free = _eet_str_free;
1824 if (eddc->func.mem_alloc)
1825 edd->func.mem_alloc = eddc->func.mem_alloc;
1826
1827 if (eddc->func.mem_free)
1828 edd->func.mem_free = eddc->func.mem_free;
1829
1830 if (eddc->func.str_alloc)
1831 edd->func.str_alloc = eddc->func.str_alloc;
1832
1833 if (eddc->func.str_free)
1834 edd->func.str_free = eddc->func.str_free;
1835
1836 edd->func.list_next = eddc->func.list_next;
1837 edd->func.list_append = eddc->func.list_append;
1838 edd->func.list_data = eddc->func.list_data;
1839 edd->func.list_free = eddc->func.list_free;
1840 edd->func.hash_foreach = eddc->func.hash_foreach;
1841 edd->func.hash_add = eddc->func.hash_add;
1842 edd->func.hash_free = eddc->func.hash_free;
1843
1844 if (eddc->version > 1 && version > 1)
1845 {
1846 edd->func.str_direct_alloc = eddc->func.str_direct_alloc;
1847 edd->func.str_direct_free = eddc->func.str_direct_free;
1848 }
1849
1850 if (eddc->version > 2)
1851 {
1852 edd->func.type_get = eddc->func.type_get;
1853 edd->func.type_set = eddc->func.type_set;
1854 }
1855
1856 if (eddc->version > 3)
1857 {
1858 edd->func.array_alloc = eddc->func.array_alloc;
1859 edd->func.array_free = eddc->func.array_free;
1860 }
1861
1862 return edd;
1863}
1864
1865EAPI Eet_Data_Descriptor *
1866eet_data_descriptor_new(const char *name,
1867 int size,
1868 Eet_Descriptor_List_Next_Callback func_list_next,
1869 Eet_Descriptor_List_Append_Callback func_list_append,
1870 Eet_Descriptor_List_Data_Callback func_list_data,
1871 Eet_Descriptor_List_Free_Callback func_list_free,
1872 Eet_Descriptor_Hash_Foreach_Callback func_hash_foreach,
1873 Eet_Descriptor_Hash_Add_Callback func_hash_add,
1874 Eet_Descriptor_Hash_Free_Callback func_hash_free)
1875{
1876 Eet_Data_Descriptor_Class eddc;
1877
1878 if (!name)
1879 return NULL;
1880
1881 memset(&eddc, 0, sizeof (Eet_Data_Descriptor_Class));
1882
1883 eddc.name = name;
1884 eddc.size = size;
1885 eddc.version = 0;
1886
1887 eddc.func.list_next = func_list_next;
1888 eddc.func.list_append = func_list_append;
1889 eddc.func.list_data = func_list_data;
1890 eddc.func.list_free = func_list_free;
1891 eddc.func.hash_foreach = func_hash_foreach;
1892 eddc.func.hash_add = func_hash_add;
1893 eddc.func.hash_free = func_hash_free;
1894
1895 return _eet_data_descriptor_new(&eddc, 0);
1896}
1897
1898EAPI Eet_Data_Descriptor *
1899eet_data_descriptor2_new(const Eet_Data_Descriptor_Class *eddc)
1900{
1901 return _eet_data_descriptor_new(eddc, 1);
1902}
1903
1904EAPI Eet_Data_Descriptor *
1905eet_data_descriptor3_new(const Eet_Data_Descriptor_Class *eddc)
1906{
1907 return _eet_data_descriptor_new(eddc, 2);
1908}
1909
1910EAPI Eet_Data_Descriptor *
1911eet_data_descriptor_stream_new(const Eet_Data_Descriptor_Class *eddc)
1912{
1913 return _eet_data_descriptor_new(eddc, 1);
1914}
1915
1916EAPI Eet_Data_Descriptor *
1917eet_data_descriptor_file_new(const Eet_Data_Descriptor_Class *eddc)
1918{
1919 return _eet_data_descriptor_new(eddc, 2);
1920}
1921
1922EAPI void
1923eet_data_descriptor_free(Eet_Data_Descriptor *edd)
1924{
1925 if (!edd)
1926 return;
1927
1928 _eet_descriptor_hash_free(edd);
1929 if (edd->elements.set)
1930 free(edd->elements.set);
1931
1932 free(edd);
1933}
1934
1935EAPI void
1936eet_data_descriptor_element_add(Eet_Data_Descriptor *edd,
1937 const char *name,
1938 int type,
1939 int group_type,
1940 int offset,
1941 int count,
1942/* int counter_offset, */
1943 const char *counter_name /* FIXME: Useless should go on a major release */,
1944 Eet_Data_Descriptor *subtype)
1945{
1946 Eet_Data_Element *ede;
1947 Eet_Data_Element *tmp;
1948
1949 /* UNION, VARIANT type would not work with simple type, we need a way to map the type. */
1950 if ((group_type == EET_G_UNION
1951 || group_type == EET_G_VARIANT)
1952 &&
1953 (type != EET_T_UNKNOW
1954 || !subtype
1955 || !subtype->func.type_get
1956 || !subtype->func.type_set))
1957 return;
1958
1959 /* VARIANT type will only work if the map only contains EET_G_*, but not UNION, VARIANT and ARRAY. */
1960 if (group_type == EET_G_VARIANT)
1961 {
1962 int i;
1963
1964 for (i = 0; i < subtype->elements.num; ++i)
1965 if (subtype->elements.set[i].type != EET_T_UNKNOW
1966 && subtype->elements.set[i].group_type > EET_G_VAR_ARRAY
1967 && subtype->elements.set[i].group_type < EET_G_UNION)
1968 return;
1969
1970 subtype->unified_type = EINA_TRUE;
1971 }
1972
1973 if (subtype
1974 && subtype->unified_type
1975 && (type != EET_T_UNKNOW
1976 || group_type < EET_G_UNION))
1977 return;
1978
1979 /* Sanity check done, let allocate ! */
1980 edd->elements.num++;
1981 tmp = realloc(edd->elements.set, edd->elements.num * sizeof(Eet_Data_Element));
1982 if (!tmp)
1983 return;
1984
1985 edd->elements.set = tmp;
1986 ede = &(edd->elements.set[edd->elements.num - 1]);
1987 ede->name = name;
1988 ede->directory_name_ptr = NULL;
1989
1990 /*
1991 * We do a special case when we do list,hash or whatever group of simple type.
1992 * Instead of handling it in encode/decode/dump/undump, we create an
1993 * implicit structure with only the simple type.
1994 */
1995 if ((group_type > EET_G_UNKNOWN)
1996 && (group_type < EET_G_LAST)
1997 && (((type > EET_T_UNKNOW) && (type < EET_T_STRING))
1998 || ((type > EET_T_NULL) && (type < EET_T_LAST)))
1999 && (!subtype))
2000 {
2001 subtype = calloc(1, sizeof (Eet_Data_Descriptor));
2002 if (!subtype)
2003 return;
2004
2005 subtype->name = "implicit";
2006 subtype->size = eet_basic_codec[type - 1].size;
2007 memcpy(&subtype->func, &edd->func, sizeof(subtype->func));
2008
2009 eet_data_descriptor_element_add(subtype,
2010 eet_basic_codec[type - 1].name,
2011 type,
2012 EET_G_UNKNOWN,
2013 0,
2014 0,
2015 /* 0, */ NULL,
2016 NULL);
2017 type = EET_T_UNKNOW;
2018 }
2019
2020 ede->type = type;
2021 ede->group_type = group_type;
2022 ede->offset = offset;
2023 ede->count = count;
2024 /* FIXME: For the time being, VAR_ARRAY, UNION and VARIANT will put the counter_offset in count. */
2025 ede->counter_offset = count;
2026/* ede->counter_offset = counter_offset; */
2027 ede->counter_name = counter_name;
2028
2029 ede->subtype = subtype;
2030}
2031
2032EAPI void *
2033eet_data_read_cipher(Eet_File *ef,
2034 Eet_Data_Descriptor *edd,
2035 const char *name,
2036 const char *cipher_key)
2037{
2038 const Eet_Dictionary *ed = NULL;
2039 const void *data = NULL;
2040 void *data_dec;
2041 Eet_Free_Context context;
2042 int required_free = 0;
2043 int size;
2044
2045 ed = eet_dictionary_get(ef);
2046
2047 if (!cipher_key)
2048 data = eet_read_direct(ef, name, &size);
2049
2050 if (!data)
2051 {
2052 required_free = 1;
2053 data = eet_read_cipher(ef, name, &size, cipher_key);
2054 if (!data)
2055 return NULL;
2056 }
2057
2058 eet_free_context_init(&context);
2059 data_dec = _eet_data_descriptor_decode(&context, ed, edd, data, size, NULL, 0);
2060 eet_free_context_shutdown(&context);
2061
2062 if (required_free)
2063 free((void *)data);
2064
2065 return data_dec;
2066}
2067
2068EAPI Eet_Node *
2069eet_data_node_read_cipher(Eet_File *ef,
2070 const char *name,
2071 const char *cipher_key)
2072{
2073 const Eet_Dictionary *ed = NULL;
2074 const void *data = NULL;
2075 Eet_Node *result;
2076 Eet_Free_Context context;
2077 int required_free = 0;
2078 int size;
2079
2080 ed = eet_dictionary_get(ef);
2081
2082 if (!cipher_key)
2083 data = eet_read_direct(ef, name, &size);
2084
2085 if (!data)
2086 {
2087 required_free = 1;
2088 data = eet_read_cipher(ef, name, &size, cipher_key);
2089 if (!data)
2090 return NULL;
2091 }
2092
2093 eet_free_context_init(&context);
2094 result = _eet_data_descriptor_decode(&context, ed, NULL, data, size, NULL, 0);
2095 eet_free_context_shutdown(&context);
2096
2097 if (required_free)
2098 free((void *)data);
2099
2100 return result;
2101}
2102
2103EAPI void *
2104eet_data_read(Eet_File *ef,
2105 Eet_Data_Descriptor *edd,
2106 const char *name)
2107{
2108 return eet_data_read_cipher(ef, edd, name, NULL);
2109}
2110
2111EAPI int
2112eet_data_write_cipher(Eet_File *ef,
2113 Eet_Data_Descriptor *edd,
2114 const char *name,
2115 const char *cipher_key,
2116 const void *data,
2117 int compress)
2118{
2119 Eet_Dictionary *ed;
2120 void *data_enc;
2121 int size;
2122 int val;
2123
2124 ed = eet_dictionary_get(ef);
2125
2126 data_enc = _eet_data_descriptor_encode(ed, edd, data, &size);
2127 if (!data_enc)
2128 return 0;
2129
2130 val = eet_write_cipher(ef, name, data_enc, size, compress, cipher_key);
2131 free(data_enc);
2132 return val;
2133}
2134
2135EAPI int
2136eet_data_write(Eet_File *ef,
2137 Eet_Data_Descriptor *edd,
2138 const char *name,
2139 const void *data,
2140 int compress)
2141{
2142 return eet_data_write_cipher(ef, edd, name, NULL, data, compress);
2143}
2144
2145static void
2146eet_free_context_init(Eet_Free_Context *context)
2147{
2148 unsigned int i = 0;
2149
2150 memset(context, 0, sizeof (Eet_Free_Context));
2151 for (i = 0; i < EET_FREE_COUNT; ++i)
2152 {
2153 eina_array_step_set(&context->freelist.list[i],
2154 sizeof (context->freelist.list[i]),
2155 32);
2156 eina_array_step_set(&context->freelist_array.list[i],
2157 sizeof (context->freelist.list[i]),
2158 32);
2159 eina_array_step_set(&context->freelist_list.list[i],
2160 sizeof (context->freelist.list[i]),
2161 32);
2162 eina_array_step_set(&context->freelist_hash.list[i],
2163 sizeof (context->freelist.list[i]),
2164 32);
2165 eina_array_step_set(&context->freelist_str.list[i],
2166 sizeof (context->freelist.list[i]),
2167 32);
2168 eina_array_step_set(&context->freelist_direct_str.list[i],
2169 sizeof (context->freelist.list[i]),
2170 32);
2171 }
2172}
2173
2174static void
2175eet_free_context_shutdown(Eet_Free_Context *context)
2176{
2177 unsigned int i = 0;
2178
2179 for (i = 0; i < EET_FREE_COUNT; ++i)
2180 {
2181 eina_array_flush(&context->freelist.list[i]);
2182 eina_array_flush(&context->freelist_array.list[i]);
2183 eina_array_flush(&context->freelist_list.list[i]);
2184 eina_array_flush(&context->freelist_hash.list[i]);
2185 eina_array_flush(&context->freelist_str.list[i]);
2186 eina_array_flush(&context->freelist_direct_str.list[i]);
2187 }
2188}
2189
2190static int
2191_eet_free_hash(void *data)
2192{
2193#ifdef _WIN64
2194 __int64 ptr = (UINT_PTR)data;
2195#else /* ifdef _WIN64 */
2196 unsigned long ptr = (unsigned long)(data);
2197#endif /* ifdef _WIN64 */
2198 int hash;
2199
2200 hash = ptr;
2201 hash ^= ptr >> 8;
2202 hash ^= ptr >> 16;
2203 hash ^= ptr >> 24;
2204
2205#if defined (_WIN64) || ((!defined (_WIN32)) && (LONG_BIT != 32))
2206 hash ^= ptr >> 32;
2207 hash ^= ptr >> 40;
2208 hash ^= ptr >> 48;
2209 hash ^= ptr >> 56;
2210#endif /* if defined (_WIN64) || ((!defined (_WIN32)) && (LONG_BIT != 32)) */
2211
2212 return hash & 0xFF;
2213}
2214
2215static void
2216_eet_free_add(Eet_Free *ef,
2217 void *data)
2218{
2219 void *track;
2220 Eina_Array_Iterator it;
2221 unsigned int i;
2222 int hash;
2223
2224 hash = _eet_free_hash(data);
2225
2226 EINA_ARRAY_ITER_NEXT(&ef->list[hash], i, track, it)
2227 if (track == data)
2228 return;
2229
2230 eina_array_push(&ef->list[hash], data);
2231}
2232
2233#if 0
2234static void
2235_eet_free_del(Eet_Free *ef,
2236 void *data)
2237{
2238 void *track;
2239 Eina_Array_Iterator it;
2240 unsigned int i;
2241 int hash;
2242
2243 hash = _eet_free_hash(data);
2244
2245 EINA_ARRAY_ITER_NEXT(&ef->list[hash], i, track, it)
2246 if (track == data)
2247 {
2248 eina_array_data_set(&ef->list[hash], i, NULL);
2249 return;
2250 }
2251}
2252
2253#endif
2254
2255static void
2256_eet_free_reset(Eet_Free *ef)
2257{
2258 unsigned int i;
2259
2260 if (ef->ref > 0)
2261 return;
2262
2263 for (i = 0; i < EET_FREE_COUNT; ++i)
2264 eina_array_clean(&ef->list[i]);
2265}
2266
2267static void
2268_eet_free_ref(Eet_Free *ef)
2269{
2270 ef->ref++;
2271}
2272
2273static void
2274_eet_free_unref(Eet_Free *ef)
2275{
2276 ef->ref--;
2277}
2278
2279#define _eet_freelist_add(Ctx, Data) _eet_free_add(&Ctx->freelist, Data);
2280#define _eet_freelist_del(Ctx, Data) _eet_free_del(&Ctx->freelist, Data);
2281#define _eet_freelist_reset(Ctx) _eet_free_reset(&Ctx->freelist);
2282#define _eet_freelist_ref(Ctx) _eet_free_ref(&Ctx->freelist);
2283#define _eet_freelist_unref(Ctx) _eet_free_unref(&Ctx->freelist);
2284
2285static void
2286_eet_freelist_free(Eet_Free_Context *context,
2287 Eet_Data_Descriptor *edd)
2288{
2289 void *track;
2290 Eina_Array_Iterator it;
2291 unsigned int j;
2292 unsigned int i;
2293
2294 if (context->freelist.ref > 0)
2295 return;
2296
2297 for (j = 0; j < EET_FREE_COUNT; ++j)
2298 EINA_ARRAY_ITER_NEXT(&context->freelist.list[j], i, track, it)
2299 if (track)
2300 {
2301 if (edd)
2302 edd->func.mem_free(track);
2303 else
2304 free(track);
2305 }
2306 _eet_free_reset(&context->freelist);
2307}
2308
2309#define _eet_freelist_array_add(Ctx, Data) _eet_free_add(&Ctx->freelist_array, Data);
2310#define _eet_freelist_array_del(Ctx, Data) _eet_free_del(&Ctx->freelist_array, Data);
2311#define _eet_freelist_array_reset(Ctx) _eet_free_reset(&Ctx->freelist_array);
2312#define _eet_freelist_array_ref(Ctx) _eet_free_ref(&Ctx->freelist_array);
2313#define _eet_freelist_array_unref(Ctx) _eet_free_unref(&Ctx->freelist_array);
2314
2315static void
2316_eet_freelist_array_free(Eet_Free_Context *context,
2317 Eet_Data_Descriptor *edd)
2318{
2319 void *track;
2320 Eina_Array_Iterator it;
2321 unsigned int j;
2322 unsigned int i;
2323
2324 if (context->freelist_array.ref > 0)
2325 return;
2326
2327 for (j = 0; j < EET_FREE_COUNT; ++j)
2328 EINA_ARRAY_ITER_NEXT(&context->freelist_array.list[j], i, track, it)
2329 if (track)
2330 {
2331 if (edd)
2332 {
2333 if (edd->func.array_free)
2334 edd->func.array_free(track);
2335 else
2336 edd->func.mem_free(track);
2337 }
2338 else
2339 free(track);
2340 }
2341 _eet_free_reset(&context->freelist_array);
2342}
2343
2344#define _eet_freelist_list_add(Ctx, Data) _eet_free_add(&Ctx->freelist_list, Data);
2345#define _eet_freelist_list_del(Ctx, Data) _eet_free_del(&Ctx->freelist_list, Data);
2346#define _eet_freelist_list_reset(Ctx) _eet_free_reset(&Ctx->freelist_list);
2347#define _eet_freelist_list_ref(Ctx) _eet_free_ref(&Ctx->freelist_list);
2348#define _eet_freelist_list_unref(Ctx) _eet_free_unref(&Ctx->freelist_list);
2349
2350static void
2351_eet_freelist_list_free(Eet_Free_Context *context,
2352 Eet_Data_Descriptor *edd)
2353{
2354 void *track;
2355 Eina_Array_Iterator it;
2356 unsigned int j;
2357 unsigned int i;
2358
2359 if (context->freelist_list.ref > 0)
2360 return;
2361
2362 for (j = 0; j < EET_FREE_COUNT; ++j)
2363 EINA_ARRAY_ITER_NEXT(&context->freelist_list.list[j], i, track, it)
2364 if (track)
2365 {
2366 if (edd)
2367 edd->func.list_free(*((void **)(track)));
2368 }
2369 _eet_free_reset(&context->freelist_list);
2370}
2371
2372#define _eet_freelist_str_add(Ctx, Data) _eet_free_add(&Ctx->freelist_str, Data);
2373#define _eet_freelist_str_del(Ctx, Data) _eet_free_del(&Ctx->freelist_str, Data);
2374#define _eet_freelist_str_reset(Ctx) _eet_free_reset(&Ctx->freelist_str);
2375#define _eet_freelist_str_ref(Ctx) _eet_free_ref(&Ctx->freelist_str);
2376#define _eet_freelist_str_unref(Ctx) _eet_free_unref(&Ctx->freelist_str);
2377
2378static void
2379_eet_freelist_str_free(Eet_Free_Context *context,
2380 Eet_Data_Descriptor *edd)
2381{
2382 void *track;
2383 Eina_Array_Iterator it;
2384 unsigned int j;
2385 unsigned int i;
2386
2387 if (context->freelist_str.ref > 0)
2388 return;
2389
2390 for (j = 0; j < EET_FREE_COUNT; ++j)
2391 EINA_ARRAY_ITER_NEXT(&context->freelist_str.list[j], i, track, it)
2392 if (track)
2393 {
2394 if (edd)
2395 edd->func.str_free(track);
2396 else
2397 free(track);
2398 }
2399 _eet_free_reset(&context->freelist_str);
2400}
2401
2402#define _eet_freelist_direct_str_add(Ctx, Data) _eet_free_add(&Ctx->freelist_direct_str, Data);
2403#define _eet_freelist_direct_str_del(Ctx, Data) _eet_free_del(&Ctx->freelist_direct_str, Data);
2404#define _eet_freelist_direct_str_reset(Ctx) _eet_free_reset(&Ctx->freelist_direct_str);
2405#define _eet_freelist_direct_str_ref(Ctx) _eet_free_ref(&Ctx->freelist_direct_str);
2406#define _eet_freelist_direct_str_unref(Ctx) _eet_free_unref(&Ctx->freelist_direct_str);
2407
2408static void
2409_eet_freelist_direct_str_free(Eet_Free_Context *context,
2410 Eet_Data_Descriptor *edd)
2411{
2412 void *track;
2413 Eina_Array_Iterator it;
2414 unsigned int j;
2415 unsigned int i;
2416
2417 if (context->freelist_direct_str.ref > 0)
2418 return;
2419
2420 for (j = 0; j < EET_FREE_COUNT; ++j)
2421 EINA_ARRAY_ITER_NEXT(&context->freelist_str.list[j], i, track, it)
2422 if (track)
2423 {
2424 if (edd)
2425 edd->func.str_direct_free(track);
2426 else
2427 free(track);
2428 }
2429 _eet_free_reset(&context->freelist_direct_str);
2430}
2431
2432#define _eet_freelist_hash_add(Ctx, Data) _eet_free_add(&Ctx->freelist_hash, Data);
2433#define _eet_freelist_hash_del(Ctx, Data) _eet_free_del(&Ctx->freelist_hash, Data);
2434#define _eet_freelist_hash_reset(Ctx) _eet_free_reset(&Ctx->freelist_hash);
2435#define _eet_freelist_hash_ref(Ctx) _eet_free_ref(&Ctx->freelist_hash);
2436#define _eet_freelist_hash_unref(Ctx) _eet_free_unref(&Ctx->freelist_hash);
2437
2438static void
2439_eet_freelist_hash_free(Eet_Free_Context *context,
2440 Eet_Data_Descriptor *edd)
2441{
2442 void *track;
2443 Eina_Array_Iterator it;
2444 unsigned int j;
2445 unsigned int i;
2446
2447 if (context->freelist_hash.ref > 0)
2448 return;
2449
2450 for (j = 0; j < EET_FREE_COUNT; ++j)
2451 EINA_ARRAY_ITER_NEXT(&context->freelist_hash.list[j], i, track, it)
2452 if (track)
2453 {
2454 if (edd)
2455 edd->func.hash_free(track);
2456 else
2457 free(track);
2458 }
2459 _eet_free_reset(&context->freelist_hash);
2460}
2461
2462static void
2463_eet_freelist_all_ref(Eet_Free_Context *freelist_context)
2464{
2465 _eet_freelist_ref(freelist_context);
2466 _eet_freelist_str_ref(freelist_context);
2467 _eet_freelist_list_ref(freelist_context);
2468 _eet_freelist_hash_ref(freelist_context);
2469 _eet_freelist_direct_str_ref(freelist_context);
2470}
2471
2472static void
2473_eet_freelist_all_unref(Eet_Free_Context *freelist_context)
2474{
2475 _eet_freelist_unref(freelist_context);
2476 _eet_freelist_str_unref(freelist_context);
2477 _eet_freelist_list_unref(freelist_context);
2478 _eet_freelist_hash_unref(freelist_context);
2479 _eet_freelist_direct_str_unref(freelist_context);
2480}
2481
2482static int
2483eet_data_descriptor_encode_hash_cb(void *hash __UNUSED__,
2484 const char *cipher_key,
2485 void *hdata,
2486 void *fdata)
2487{
2488 Eet_Dictionary *ed;
2489 Eet_Data_Encode_Hash_Info *edehi;
2490 Eet_Data_Stream *ds;
2491 Eet_Data_Element *ede;
2492 Eet_Data_Chunk *echnk;
2493 void *data = NULL;
2494 int size;
2495
2496 edehi = fdata;
2497 ede = edehi->ede;
2498 ds = edehi->ds;
2499 ed = edehi->ed;
2500
2501 /* Store key */
2502 data = eet_data_put_type(ed,
2503 EET_T_STRING,
2504 &cipher_key,
2505 &size);
2506 if (data)
2507 {
2508 echnk = eet_data_chunk_new(data,
2509 size,
2510 ede->name,
2511 ede->type,
2512 ede->group_type);
2513 eet_data_chunk_put(ed, echnk, ds);
2514 eet_data_chunk_free(echnk);
2515 free(data);
2516 data = NULL;
2517 }
2518
2519 EET_ASSERT(!((ede->type > EET_T_UNKNOW) && (ede->type < EET_T_STRING)), return );
2520
2521 /* Store data */
2522 if (ede->type >= EET_T_STRING)
2523 eet_data_put_unknown(ed, NULL, ede, ds, &hdata);
2524 else
2525 {
2526 if (ede->subtype)
2527 data = _eet_data_descriptor_encode(ed,
2528 ede->subtype,
2529 hdata,
2530 &size);
2531
2532 if (data)
2533 {
2534 echnk = eet_data_chunk_new(data,
2535 size,
2536 ede->name,
2537 ede->type,
2538 ede->group_type);
2539 eet_data_chunk_put(ed, echnk, ds);
2540 eet_data_chunk_free(echnk);
2541 free(data);
2542 data = NULL;
2543 }
2544 }
2545
2546 return 1;
2547}
2548
2549static char *
2550_eet_data_dump_token_get(const char *src,
2551 int *len)
2552{
2553 const char *p;
2554 char *tok = NULL;
2555 int in_token = 0;
2556 int in_quote = 0;
2557 int tlen = 0, tsize = 0;
2558
2559#define TOK_ADD(x) \
2560 do { \
2561 tlen++; \
2562 if (tlen >= tsize) \
2563 { \
2564 tsize += 32; \
2565 tok = realloc(tok, tsize); \
2566 } \
2567 tok[tlen - 1] = x; \
2568 } while (0)
2569
2570 for (p = src; *len > 0; p++, (*len)--)
2571 {
2572 if (in_token)
2573 {
2574 if (in_quote)
2575 {
2576 if ((p[0] == '\"') && (p > src) && (p[-1] != '\\'))
2577 in_quote = 0;
2578 else if ((p[0] == '\\') && (*len > 1) &&
2579 (p[1] == '\"'))
2580 {
2581/* skip */
2582 }
2583 else if ((p[0] == '\\') && (p > src) && (p[-1] == '\\'))
2584 {
2585/* skip */
2586 }
2587 else if ((p[0] == '\\') && (*len > 1) && (p[1] == 'n'))
2588 {
2589/* skip */
2590 }
2591 else if ((p[0] == 'n') && (p > src) && (p[-1] == '\\'))
2592 TOK_ADD('\n');
2593 else
2594 TOK_ADD(p[0]);
2595 }
2596 else
2597 {
2598 if (p[0] == '\"')
2599 in_quote = 1;
2600 else
2601 {
2602 if ((isspace(p[0])) || (p[0] == ';')) /* token ends here */
2603 {
2604 TOK_ADD(0);
2605 (*len)--;
2606 return tok;
2607 }
2608 else
2609 TOK_ADD(p[0]);
2610 }
2611 }
2612 }
2613 else if (!((isspace(p[0])) || (p[0] == ';')))
2614 {
2615 in_token = 1;
2616 (*len)++;
2617 p--;
2618 }
2619 }
2620 if (in_token)
2621 {
2622 TOK_ADD(0);
2623 return tok;
2624 }
2625
2626 if (tok)
2627 free(tok);
2628
2629 return NULL;
2630}
2631
2632static void
2633eet_data_encode(Eet_Dictionary *ed,
2634 Eet_Data_Stream *ds,
2635 void *data,
2636 const char *name,
2637 int size,
2638 int type,
2639 int group_type)
2640{
2641 Eet_Data_Chunk *echnk;
2642
2643 if (!data)
2644 type = EET_T_NULL;
2645
2646 if (group_type != EET_G_UNKNOWN)
2647 if (type >= EET_T_LAST)
2648 type = EET_T_UNKNOW;
2649
2650 echnk = eet_data_chunk_new(data, size, name, type, group_type);
2651 eet_data_chunk_put(ed, echnk, ds);
2652 eet_data_chunk_free(echnk);
2653 free(data);
2654}
2655
2656static void *
2657_eet_data_dump_encode(int parent_type,
2658 Eet_Dictionary *ed,
2659 Eet_Node *node,
2660 int *size_ret)
2661{
2662 Eet_Data_Chunk *chnk = NULL;
2663 Eet_Data_Stream *ds;
2664 void *cdata, *data;
2665 int csize, size;
2666 int count;
2667 int child_type;
2668 Eet_Node *n;
2669
2670 if (_eet_data_words_bigendian == -1)
2671 {
2672 unsigned long int v;
2673
2674 v = htonl(0x12345678);
2675 if (v == 0x12345678)
2676 _eet_data_words_bigendian = 1;
2677 else
2678 _eet_data_words_bigendian = 0;
2679 }
2680
2681 if (!node)
2682 return NULL;
2683
2684 ds = eet_data_stream_new();
2685 if (!ds)
2686 return NULL;
2687
2688 switch (node->type)
2689 {
2690 case EET_G_UNKNOWN:
2691 for (n = node->values; n; n = n->next)
2692 {
2693 data = _eet_data_dump_encode(node->type, ed, n, &size);
2694 if (data)
2695 {
2696 eet_data_stream_write(ds, data, size);
2697 free(data);
2698 }
2699 }
2700 break;
2701
2702 case EET_G_ARRAY:
2703 case EET_G_VAR_ARRAY:
2704 for (child_type = EET_T_NULL, n = node->values; n; n = n->next)
2705 {
2706 if (n->type != EET_T_NULL)
2707 {
2708 child_type = n->type;
2709 break;
2710 }
2711 }
2712
2713 data = eet_data_put_type(ed,
2714 EET_T_INT,
2715 &node->count,
2716 &size);
2717 eet_data_encode(ed,
2718 ds,
2719 data,
2720 node->name,
2721 size,
2722 child_type,
2723 node->type);
2724
2725 count = node->count;
2726
2727 for (n = node->values; n; n = n->next)
2728 {
2729 int pos = ds->pos;
2730
2731 switch (n->type)
2732 {
2733 case EET_T_STRING:
2734 case EET_T_INLINED_STRING:
2735 data = eet_data_put_type(ed,
2736 n->type,
2737 &(n->data.value.str),
2738 &size);
2739 if (data)
2740 eet_data_encode(ed,
2741 ds,
2742 data,
2743 node->name,
2744 size,
2745 n->type,
2746 node->type);
2747
2748 break;
2749
2750 case EET_T_NULL:
2751 continue;
2752
2753 default:
2754 data = _eet_data_dump_encode(n->type, ed, n, &size);
2755 eet_data_encode(ed,
2756 ds,
2757 data,
2758 node->name,
2759 size,
2760 n->type,
2761 node->type);
2762 break;
2763 } /* switch */
2764 if (ds->pos != pos)
2765 count--;
2766 }
2767
2768 for (; count; count--)
2769 {
2770 eet_data_encode(ed,
2771 ds,
2772 NULL,
2773 node->name,
2774 0,
2775 EET_T_NULL,
2776 node->type);
2777 }
2778
2779 /* Array is somekind of special case, so we should embed it inside another chunk. */
2780 *size_ret = ds->pos;
2781 cdata = ds->data;
2782
2783 ds->data = NULL;
2784 ds->size = 0;
2785 eet_data_stream_free(ds);
2786
2787 return cdata;
2788 break;
2789
2790 case EET_G_LIST:
2791 for (n = node->values; n; n = n->next)
2792 {
2793 switch (n->type)
2794 {
2795 case EET_T_STRING:
2796 case EET_T_INLINED_STRING:
2797 data = eet_data_put_type(ed,
2798 n->type,
2799 &(n->data.value.str),
2800 &size);
2801 if (data)
2802 eet_data_encode(ed,
2803 ds,
2804 data,
2805 node->name,
2806 size,
2807 n->type,
2808 node->type);
2809
2810 break;
2811
2812 case EET_T_NULL:
2813 continue;
2814
2815 default:
2816 data = _eet_data_dump_encode(node->type, ed, n, &size);
2817 eet_data_encode(ed,
2818 ds,
2819 data,
2820 node->name,
2821 size,
2822 n->type,
2823 node->type);
2824 } /* switch */
2825 }
2826
2827 /* List is another somekind of special case, every chunk is embed inside a list chunk. */
2828 *size_ret = ds->pos;
2829 cdata = ds->data;
2830
2831 ds->data = NULL;
2832 ds->size = 0;
2833 eet_data_stream_free(ds);
2834
2835 return cdata;
2836 break;
2837
2838 case EET_G_HASH:
2839 if (node->key)
2840 {
2841 data = eet_data_put_type(ed,
2842 EET_T_STRING,
2843 &node->key,
2844 &size);
2845 eet_data_encode(ed,
2846 ds,
2847 data,
2848 node->name,
2849 size,
2850 node->type,
2851 node->type);
2852 }
2853 else
2854 /* A Hash without key will not decode correctly. */
2855 return NULL;
2856
2857 for (n = node->values; n; n = n->next)
2858 {
2859 switch (n->type)
2860 {
2861 case EET_T_STRING:
2862 case EET_T_INLINED_STRING:
2863 data = eet_data_put_type(ed,
2864 n->type,
2865 &(n->data.value.str),
2866 &size);
2867 if (data)
2868 eet_data_encode(ed,
2869 ds,
2870 data,
2871 node->name,
2872 size,
2873 n->type,
2874 node->type);
2875
2876 break;
2877
2878 case EET_T_NULL:
2879 continue;
2880
2881 default:
2882 data = _eet_data_dump_encode(node->type, ed, n, &size);
2883 eet_data_encode(ed,
2884 ds,
2885 data,
2886 node->name,
2887 size,
2888 n->type,
2889 node->type);
2890 } /* switch */
2891 }
2892
2893 /* Hash is somekind of special case, so we should embed it inside another chunk. */
2894 *size_ret = ds->pos;
2895 cdata = ds->data;
2896
2897 eet_data_stream_flush(ds);
2898
2899 return cdata;
2900
2901 case EET_T_NULL:
2902 break;
2903
2904#define EET_DATA_NODE_ENCODE(Eet_Type, Type) \
2905case Eet_Type: \
2906 data = eet_data_put_type(ed, node->type, &(node->data.value.Type), &size); \
2907 if (data) \
2908 { \
2909 eet_data_encode(ed, \
2910 ds, \
2911 data, \
2912 node->name, \
2913 size, \
2914 node->type, \
2915 parent_type); \
2916 cdata = ds->data; \
2917 *size_ret = ds->pos; \
2918 eet_data_stream_flush(ds); \
2919 return cdata; \
2920 } /* switch */ \
2921 break;
2922
2923 EET_DATA_NODE_ENCODE(EET_T_CHAR, c);
2924 EET_DATA_NODE_ENCODE(EET_T_SHORT, s);
2925 EET_DATA_NODE_ENCODE(EET_T_INT, i);
2926 EET_DATA_NODE_ENCODE(EET_T_LONG_LONG, l);
2927 EET_DATA_NODE_ENCODE(EET_T_FLOAT, f);
2928 EET_DATA_NODE_ENCODE(EET_T_DOUBLE, d);
2929 EET_DATA_NODE_ENCODE(EET_T_UCHAR, uc);
2930 EET_DATA_NODE_ENCODE(EET_T_USHORT, us);
2931 EET_DATA_NODE_ENCODE(EET_T_UINT, ui);
2932 EET_DATA_NODE_ENCODE(EET_T_ULONG_LONG, ul);
2933 EET_DATA_NODE_ENCODE(EET_T_INLINED_STRING, str);
2934 EET_DATA_NODE_ENCODE(EET_T_STRING, str);
2935
2936 default:
2937 break;
2938 }
2939
2940 if ((node->type >= EET_G_UNKNOWN) && (node->type < EET_G_LAST))
2941 chnk = eet_data_chunk_new(ds->data,
2942 ds->pos,
2943 node->name,
2944 EET_T_UNKNOW,
2945 node->type);
2946 else
2947 chnk = eet_data_chunk_new(ds->data,
2948 ds->pos,
2949 node->name,
2950 node->type,
2951 EET_G_UNKNOWN);
2952
2953 eet_data_stream_flush(ds);
2954
2955 ds = eet_data_stream_new();
2956 eet_data_chunk_put(ed, chnk, ds);
2957 cdata = ds->data;
2958 csize = ds->pos;
2959
2960 eet_data_stream_flush(ds);
2961 *size_ret = csize;
2962
2963 free(chnk->data);
2964 eet_data_chunk_free(chnk);
2965
2966 return cdata;
2967}
2968
2969static void *
2970_eet_data_dump_parse(Eet_Dictionary *ed,
2971 int *size_ret,
2972 const char *src,
2973 int size)
2974{
2975 void *cdata = NULL;
2976 const char *p = NULL;
2977#define M_NONE 0
2978#define M_STRUCT 1
2979#define M_ 2
2980 int left, jump;
2981 Eet_Node *node_base = NULL;
2982 Eet_Node *node = NULL;
2983 Eet_Node *n = NULL, *nn = NULL;
2984
2985 /* FIXME; handle parse errors */
2986#define TOK_GET(t) \
2987 jump = left; t = _eet_data_dump_token_get(p, &left); p += jump - left;
2988 left = size;
2989 for (p = src; p < (src + size); )
2990 {
2991 char *tok1, *tok2, *tok3, *tok4;
2992
2993 TOK_GET(tok1);
2994 if (tok1)
2995 {
2996 if (!strcmp(tok1, "group"))
2997 {
2998 TOK_GET(tok2);
2999 if (tok2)
3000 {
3001 TOK_GET(tok3);
3002 if (tok3)
3003 {
3004 TOK_GET(tok4);
3005 if (tok4)
3006 {
3007 if (!strcmp(tok4, "{"))
3008 {
3009/* we have 'group NAM TYP {' */
3010 n = eet_node_new();
3011 if (n)
3012 {
3013 n->parent = node;
3014 if (!node_base)
3015 node_base = n;
3016
3017 if (node)
3018 {
3019/* append node */
3020 if (!node->values)
3021 node->values = n;
3022 else
3023 for (nn = node->values; nn;
3024 nn = nn->next)
3025 {
3026 if (!nn->next)
3027 {
3028 nn->next = n;
3029 break;
3030 }
3031 }
3032 }
3033
3034 n->name = eina_stringshare_add(tok2);
3035 if (!strcmp(tok3, "struct"))
3036 n->type = EET_G_UNKNOWN;
3037 else if (!strcmp(tok3, "array"))
3038 n->type = EET_G_ARRAY;
3039 else if (!strcmp(tok3, "var_array"))
3040 n->type = EET_G_VAR_ARRAY;
3041 else if (!strcmp(tok3, "list"))
3042 n->type = EET_G_LIST;
3043 else if (!strcmp(tok3, "hash"))
3044 n->type = EET_G_HASH;
3045 else
3046 ERR(
3047 "ERROR: group type '%s' invalid.",
3048 tok3);
3049
3050 node = n;
3051 }
3052 }
3053
3054 free(tok4);
3055 }
3056
3057 free(tok3);
3058 }
3059
3060 free(tok2);
3061 }
3062 }
3063 else if (!strcmp(tok1, "value"))
3064 {
3065 TOK_GET(tok2);
3066 if (tok2)
3067 {
3068 TOK_GET(tok3);
3069 if (tok3)
3070 {
3071 TOK_GET(tok4);
3072 if (tok4)
3073 {
3074/* we have 'value NAME TYP XXX' */
3075 if (node_base)
3076 {
3077 n = eet_node_new();
3078 if (n)
3079 {
3080 n->parent = node;
3081/* append node */
3082 if (!node->values)
3083 node->values = n;
3084 else
3085 for (nn = node->values; nn;
3086 nn = nn->next)
3087 {
3088 if (!nn->next)
3089 {
3090 nn->next = n;
3091 break;
3092 }
3093 }
3094
3095 n->name = eina_stringshare_add(tok2);
3096 if (!strcmp(tok3, "char:"))
3097 {
3098 n->type = EET_T_CHAR;
3099 sscanf(tok4, "%hhi",
3100 &(n->data.value.c));
3101 }
3102 else if (!strcmp(tok3, "short:"))
3103 {
3104 n->type = EET_T_SHORT;
3105 sscanf(tok4, "%hi",
3106 &(n->data.value.s));
3107 }
3108 else if (!strcmp(tok3, "int:"))
3109 {
3110 n->type = EET_T_INT;
3111 sscanf(tok4, "%i",
3112 &(n->data.value.i));
3113 }
3114 else if (!strcmp(tok3, "long_long:"))
3115 {
3116 n->type = EET_T_LONG_LONG;
3117 sscanf(tok4, "%lli",
3118 &(n->data.value.l));
3119 }
3120 else if (!strcmp(tok3, "float:"))
3121 {
3122 n->type = EET_T_FLOAT;
3123 sscanf(tok4, "%f",
3124 &(n->data.value.f));
3125 }
3126 else if (!strcmp(tok3, "double:"))
3127 {
3128 n->type = EET_T_DOUBLE;
3129 sscanf(tok4, "%lf",
3130 &(n->data.value.d));
3131 }
3132 else if (!strcmp(tok3, "uchar:"))
3133 {
3134 n->type = EET_T_UCHAR;
3135 sscanf(tok4, "%hhu",
3136 &(n->data.value.uc));
3137 }
3138 else if (!strcmp(tok3, "ushort:"))
3139 {
3140 n->type = EET_T_USHORT;
3141 sscanf(tok4, "%hu",
3142 &(n->data.value.us));
3143 }
3144 else if (!strcmp(tok3, "uint:"))
3145 {
3146 n->type = EET_T_UINT;
3147 sscanf(tok4, "%u",
3148 &(n->data.value.ui));
3149 }
3150 else if (!strcmp(tok3, "ulong_long:"))
3151 {
3152 n->type = EET_T_ULONG_LONG;
3153 sscanf(tok4, "%llu",
3154 &(n->data.value.ul));
3155 }
3156 else if (!strcmp(tok3, "string:"))
3157 {
3158 n->type = EET_T_STRING;
3159 n->data.value.str =
3160 eina_stringshare_add(tok4);
3161 }
3162 else if (!strcmp(tok3, "inlined:"))
3163 {
3164 n->type = EET_T_INLINED_STRING;
3165 n->data.value.str =
3166 eina_stringshare_add(tok4);
3167 }
3168 else if (!strcmp(tok3, "null"))
3169 {
3170 n->type = EET_T_NULL;
3171 n->data.value.str = NULL;
3172 }
3173 else
3174 ERR(
3175 "ERROR: value type '%s' invalid.",
3176 tok4);
3177 }
3178 }
3179
3180 free(tok4);
3181 }
3182
3183 free(tok3);
3184 }
3185
3186 free(tok2);
3187 }
3188 }
3189 else if (!strcmp(tok1, "key"))
3190 {
3191 TOK_GET(tok2);
3192 if (tok2)
3193 {
3194/* we have 'key NAME' */
3195 if (node)
3196 node->key = eina_stringshare_add(tok2);
3197
3198 free(tok2);
3199 }
3200 }
3201 else if (!strcmp(tok1, "count"))
3202 {
3203 TOK_GET(tok2);
3204 if (tok2)
3205 {
3206/* we have a 'count COUNT' */
3207 if (node)
3208 sscanf(tok2, "%i", &(node->count));
3209
3210 free(tok2);
3211 }
3212 }
3213 else if (!strcmp(tok1, "}"))
3214 /* we have an end of the group */
3215 if (node)
3216 node = node->parent;
3217
3218 free(tok1);
3219 }
3220 }
3221
3222 if (node_base)
3223 {
3224 cdata = _eet_data_dump_encode(EET_G_UNKNOWN, ed, node_base, size_ret);
3225 eet_node_del(node_base);
3226 }
3227
3228 return cdata;
3229}
3230
3231#define NEXT_CHUNK(P, Size, Echnk, Ed) \
3232 { \
3233 int __tmp; \
3234 __tmp = Ed ? (int)(sizeof(int) * 2) : Echnk.len + 4; \
3235 P += (4 + Echnk.size + __tmp); \
3236 Size -= (4 + Echnk.size + __tmp); \
3237 }
3238
3239static void *
3240_eet_data_descriptor_decode(Eet_Free_Context *context,
3241 const Eet_Dictionary *ed,
3242 Eet_Data_Descriptor *edd,
3243 const void *data_in,
3244 int size_in,
3245 void *data_out,
3246 int size_out)
3247{
3248 Eet_Node *result = NULL;
3249 void *data = NULL;
3250 char *p;
3251 int size, i;
3252 Eet_Data_Chunk chnk;
3253
3254 if (_eet_data_words_bigendian == -1)
3255 {
3256 unsigned long int v;
3257
3258 v = htonl(0x12345678);
3259 if (v == 0x12345678)
3260 _eet_data_words_bigendian = 1;
3261 else
3262 _eet_data_words_bigendian = 0;
3263 }
3264
3265 if (edd)
3266 {
3267 if (data_out)
3268 {
3269 if (size_out <= edd->size)
3270 data = data_out;
3271 }
3272 else
3273 {
3274 data = edd->func.mem_alloc(edd->size);
3275 }
3276
3277 if (!data)
3278 return NULL;
3279
3280 if (edd->ed != ed)
3281 {
3282 for (i = 0; i < edd->elements.num; i++)
3283 edd->elements.set[i].directory_name_ptr = NULL;
3284 edd->ed = ed;
3285 }
3286 }
3287
3288 _eet_freelist_all_ref(context);
3289 if (data && !data_out)
3290 _eet_freelist_add(context, data);
3291
3292 memset(&chnk, 0, sizeof(Eet_Data_Chunk));
3293 eet_data_chunk_get(ed, &chnk, data_in, size_in);
3294 if (!chnk.name)
3295 goto error;
3296
3297 if (edd)
3298 if (strcmp(chnk.name, edd->name))
3299 goto error;
3300
3301 p = chnk.data;
3302 if (ed)
3303 size = size_in - (4 + sizeof(int) * 2);
3304 else
3305 size = size_in - (4 + 4 + chnk.len);
3306
3307 if (edd)
3308 {
3309 if (!edd->elements.hash.buckets)
3310 _eet_descriptor_hash_new(edd);
3311 }
3312 else
3313 {
3314 switch (chnk.group_type)
3315 {
3316 case EET_G_UNKNOWN:
3317 switch (chnk.type)
3318 {
3319 case EET_T_STRING:
3320 return eet_node_string_new(chnk.name, chnk.data);
3321
3322 case EET_T_INLINED_STRING:
3323 return eet_node_inlined_string_new(chnk.name, chnk.data);
3324
3325 case EET_T_NULL:
3326 return eet_node_null_new(chnk.name);
3327
3328 default:
3329 result = eet_node_struct_new(chnk.name, NULL);
3330 } /* switch */
3331 break;
3332
3333 case EET_G_VAR_ARRAY:
3334 return eet_node_var_array_new(chnk.name, NULL);
3335
3336 case EET_G_LIST:
3337 case EET_G_HASH:
3338 case EET_G_ARRAY:
3339 case EET_G_UNION:
3340 case EET_G_VARIANT:
3341 default:
3342 goto error;
3343 }
3344 }
3345
3346 while (size > 0)
3347 {
3348 Eet_Data_Chunk echnk;
3349 Eet_Data_Element *ede = NULL;
3350 Eet_Node *child = NULL;
3351 int group_type = EET_G_UNKNOWN, type = EET_T_UNKNOW;
3352 int ret = 0;
3353
3354 /* get next data chunk */
3355 memset(&echnk, 0, sizeof(Eet_Data_Chunk));
3356 eet_data_chunk_get(ed, &echnk, p, size);
3357 if (!echnk.name)
3358 goto error; /* FIXME: don't REPLY on edd - work without */
3359
3360 if (edd)
3361 {
3362 ede = _eet_descriptor_hash_find(edd, echnk.name, echnk.hash);
3363 if (ede)
3364 {
3365 group_type = ede->group_type;
3366 type = ede->type;
3367 if ((echnk.type == 0) && (echnk.group_type == 0))
3368 {
3369 type = ede->type;
3370 group_type = ede->group_type;
3371 }
3372 else
3373 {
3374 if (IS_SIMPLE_TYPE(echnk.type) &&
3375 eet_data_type_match(echnk.type, ede->type))
3376/* Needed when converting on the fly from FP to Float */
3377 type = ede->type;
3378 else if ((echnk.group_type > EET_G_UNKNOWN) &&
3379 (echnk.group_type < EET_G_LAST) &&
3380 (echnk.group_type == ede->group_type))
3381 group_type = echnk.group_type;
3382 }
3383 }
3384 }
3385 /*...... dump to node */
3386 else
3387 {
3388 type = echnk.type;
3389 group_type = echnk.group_type;
3390 }
3391
3392 if (!edd && group_type == EET_G_UNKNOWN && IS_SIMPLE_TYPE(type))
3393 {
3394 unsigned char dd[128];
3395
3396 ret = eet_data_get_type(ed,
3397 type,
3398 echnk.data,
3399 ((char *)echnk.data) + echnk.size,
3400 dd);
3401 if (ret <= 0)
3402 goto error;
3403
3404 child = eet_data_node_simple_type(type, echnk.name, dd);
3405
3406 eet_node_struct_append(result, echnk.name, child);
3407 }
3408 else
3409 {
3410 ret = eet_group_codec[group_type - 100].get(
3411 context,
3412 ed,
3413 edd,
3414 ede,
3415 &echnk,
3416 type,
3417 group_type,
3418 ede ? (void *)(((char *)data) + ede->offset) : (void **)&result,
3419 &p,
3420 &size);
3421
3422 if (ret <= 0)
3423 goto error;
3424 }
3425
3426 /* advance to next chunk */
3427 NEXT_CHUNK(p, size, echnk, ed);
3428 }
3429
3430 _eet_freelist_all_unref(context);
3431 if (!edd)
3432 {
3433 _eet_freelist_str_free(context, edd);
3434 _eet_freelist_direct_str_free(context, edd);
3435 _eet_freelist_list_free(context, edd);
3436 _eet_freelist_hash_free(context, edd);
3437 _eet_freelist_array_free(context, edd);
3438 _eet_freelist_free(context, edd);
3439 }
3440 else
3441 {
3442 _eet_freelist_reset(context);
3443 _eet_freelist_str_reset(context);
3444 _eet_freelist_list_reset(context);
3445 _eet_freelist_hash_reset(context);
3446 _eet_freelist_direct_str_reset(context);
3447 _eet_freelist_array_reset(context);
3448 }
3449
3450 if (!edd)
3451 return result;
3452
3453 return data;
3454
3455error:
3456 eet_node_del(result);
3457
3458 _eet_freelist_all_unref(context);
3459 _eet_freelist_str_free(context, edd);
3460 _eet_freelist_direct_str_free(context, edd);
3461 _eet_freelist_list_free(context, edd);
3462 _eet_freelist_hash_free(context, edd);
3463 _eet_freelist_array_free(context, edd);
3464 _eet_freelist_free(context, edd);
3465
3466 /* FIXME: Warn that something goes wrong here. */
3467 return NULL;
3468}
3469
3470static int
3471eet_data_get_list(Eet_Free_Context *context,
3472 const Eet_Dictionary *ed,
3473 Eet_Data_Descriptor *edd,
3474 Eet_Data_Element *ede,
3475 Eet_Data_Chunk *echnk,
3476 int type,
3477 int group_type __UNUSED__,
3478 void *data,
3479 char **p,
3480 int *size)
3481{
3482 Eet_Data_Descriptor *subtype = NULL;
3483 void *list = NULL;
3484 void **ptr;
3485 void *data_ret;
3486
3487 EET_ASSERT(!((type > EET_T_UNKNOW) && (type < EET_T_STRING)), return 0);
3488
3489 if (ede)
3490 {
3491 subtype = ede->subtype;
3492
3493 if (type != ede->type)
3494 return 0;
3495 }
3496
3497 ptr = (void **)data;
3498 list = *ptr;
3499 data_ret = NULL;
3500
3501 if (IS_POINTER_TYPE(type))
3502 POINTER_TYPE_DECODE(context,
3503 ed,
3504 edd,
3505 ede,
3506 echnk,
3507 type,
3508 &data_ret,
3509 p,
3510 size,
3511 on_error);
3512 else
3513 STRUCT_TYPE_DECODE(data_ret,
3514 context,
3515 ed,
3516 subtype,
3517 echnk->data,
3518 echnk->size,
3519 -1,
3520 on_error);
3521
3522 if (edd)
3523 {
3524 list = edd->func.list_append(list, data_ret);
3525 *ptr = list;
3526 _eet_freelist_list_add(context, ptr);
3527 }
3528 else
3529 eet_node_list_append(*((Eet_Node **)data), echnk->name, data_ret);
3530
3531 return 1;
3532
3533on_error:
3534 return 0;
3535}
3536
3537static int
3538eet_data_get_hash(Eet_Free_Context *context,
3539 const Eet_Dictionary *ed,
3540 Eet_Data_Descriptor *edd,
3541 Eet_Data_Element *ede,
3542 Eet_Data_Chunk *echnk,
3543 int type,
3544 int group_type __UNUSED__,
3545 void *data,
3546 char **p,
3547 int *size)
3548{
3549 void **ptr;
3550 void *hash = NULL;
3551 char *key = NULL;
3552 void *data_ret = NULL;
3553 int ret = 0;
3554
3555 EET_ASSERT(!((type > EET_T_UNKNOW) && (type < EET_T_STRING)), return 0);
3556
3557 ptr = (void **)data;
3558 hash = *ptr;
3559
3560 /* Read key */
3561 ret = eet_data_get_type(ed,
3562 EET_T_STRING,
3563 echnk->data,
3564 ((char *)echnk->data) + echnk->size,
3565 &key);
3566 if (ret <= 0)
3567 goto on_error;
3568
3569 if (!key)
3570 goto on_error;
3571
3572 /* Advance to next chunk */
3573 NEXT_CHUNK((*p), (*size), (*echnk), ed);
3574 memset(echnk, 0, sizeof(Eet_Data_Chunk));
3575
3576 /* Read value */
3577 eet_data_chunk_get(ed, echnk, *p, *size);
3578 if (!echnk->name)
3579 goto on_error;
3580
3581 if (ede)
3582 if ((ede->group_type != echnk->group_type)
3583 || (ede->type != echnk->type))
3584 goto on_error;
3585
3586 if (IS_POINTER_TYPE(echnk->type))
3587 POINTER_TYPE_DECODE(context,
3588 ed,
3589 edd,
3590 ede,
3591 echnk,
3592 echnk->type,
3593 &data_ret,
3594 p,
3595 size,
3596 on_error);
3597 else
3598 STRUCT_TYPE_DECODE(data_ret,
3599 context,
3600 ed,
3601 ede ? ede->subtype : NULL,
3602 echnk->data,
3603 echnk->size,
3604 -1,
3605 on_error);
3606
3607 if (edd)
3608 {
3609 hash = edd->func.hash_add(hash, key, data_ret);
3610 *ptr = hash;
3611 _eet_freelist_hash_add(context, hash);
3612 }
3613 else
3614 eet_node_hash_add(*((Eet_Node **)data), echnk->name, key, data_ret);
3615
3616 return 1;
3617
3618on_error:
3619 return 0;
3620}
3621
3622/* var arrays and fixed arrays have to
3623 * get all chunks at once. for fixed arrays
3624 * we can get each chunk and increment a
3625 * counter stored on the element itself but
3626 * it wont be thread safe. for var arrays
3627 * we still need a way to get the number of
3628 * elements from the data, so storing the
3629 * number of elements and the element data on
3630 * each chunk is pointless.
3631 */
3632static int
3633eet_data_get_array(Eet_Free_Context *context,
3634 const Eet_Dictionary *ed,
3635 Eet_Data_Descriptor *edd,
3636 Eet_Data_Element *ede,
3637 Eet_Data_Chunk *echnk,
3638 int type,
3639 int group_type,
3640 void *data,
3641 char **p,
3642 int *size)
3643{
3644 Eina_List *childs = NULL;
3645 const char *name;
3646 Eet_Node *tmp;
3647 void *ptr;
3648 int count;
3649 int ret;
3650 int subsize = 0;
3651 int i;
3652
3653 EET_ASSERT(!((type > EET_T_UNKNOW) && (type < EET_T_STRING)), return 0);
3654
3655 ptr = data;
3656 /* read the number of elements */
3657 ret = eet_data_get_type(ed,
3658 EET_T_INT,
3659 echnk->data,
3660 ((char *)echnk->data) + echnk->size,
3661 &count);
3662 if (ret <= 0)
3663 return ret;
3664
3665 name = echnk->name;
3666
3667 if (ede)
3668 {
3669 if (IS_POINTER_TYPE(type))
3670 subsize = eet_basic_codec[ede->type].size;
3671 else
3672 subsize = ede->subtype->size;
3673
3674 if (group_type == EET_G_VAR_ARRAY)
3675 {
3676 /* store the number of elements
3677 * on the counter offset */
3678 *(int *)(((char *)data) + ede->count - ede->offset) = count;
3679 /* allocate space for the array of elements */
3680 if (edd->func.array_alloc)
3681 *(void **)ptr = edd->func.array_alloc(count * subsize);
3682 else
3683 *(void **)ptr = edd->func.mem_alloc(count * subsize);
3684
3685 if (!*(void **)ptr)
3686 return 0;
3687
3688 memset(*(void **)ptr, 0, count * subsize);
3689
3690 _eet_freelist_array_add(context, *(void **)ptr);
3691 }
3692 }
3693
3694 /* get all array elements */
3695 for (i = 0; i < count; i++)
3696 {
3697 void *dst = NULL;
3698
3699 /* Advance to next chunk */
3700 NEXT_CHUNK((*p), (*size), (*echnk), ed);
3701 memset(echnk, 0, sizeof(Eet_Data_Chunk));
3702
3703 eet_data_chunk_get(ed, echnk, *p, *size);
3704 if (!echnk->name || strcmp(echnk->name, name) != 0)
3705 goto on_error; /* get the data */
3706
3707 if ((echnk->group_type != group_type)
3708 || ((echnk->type != type) && (echnk->type != EET_T_NULL)))
3709 goto on_error;
3710
3711 if (ede)
3712 if ((ede->group_type != echnk->group_type)
3713 || ((echnk->type != ede->type) && (echnk->type != EET_T_NULL)))
3714 goto on_error;
3715
3716 /* get the destination pointer */
3717 if (ede)
3718 {
3719 if (group_type == EET_G_ARRAY)
3720 dst = (char *)ptr + (subsize * i);
3721 else
3722 dst = *(char **)ptr + (subsize * i);
3723 }
3724
3725 if (IS_POINTER_TYPE(echnk->type))
3726 {
3727 void *data_ret = NULL;
3728
3729 POINTER_TYPE_DECODE(context,
3730 ed,
3731 edd,
3732 ede,
3733 echnk,
3734 echnk->type,
3735 &data_ret,
3736 p,
3737 size,
3738 on_error);
3739 if (dst)
3740 memcpy(dst, &data_ret, subsize);
3741
3742 if (!edd)
3743 childs = eina_list_append(childs, data_ret);
3744 }
3745 else
3746 {
3747 STRUCT_TYPE_DECODE(dst,
3748 context,
3749 ed,
3750 ede ? ede->subtype : NULL,
3751 echnk->data,
3752 echnk->size,
3753 subsize,
3754 on_error);
3755
3756 if (!edd)
3757 childs = eina_list_append(childs, dst);
3758 }
3759 }
3760
3761 if (!edd)
3762 {
3763 Eet_Node *parent = *((Eet_Node **)data);
3764 Eet_Node *array;
3765
3766 if (group_type == EET_G_ARRAY)
3767 array = eet_node_array_new(name, count, childs);
3768 else
3769 array = eet_node_var_array_new(name, childs);
3770
3771 if (!array)
3772 goto on_error;
3773
3774 eet_node_struct_append(parent, name, array);
3775 }
3776
3777 return 1;
3778
3779on_error:
3780 EINA_LIST_FREE(childs, tmp)
3781 eet_node_del(tmp);
3782
3783 return 0;
3784}
3785
3786static void
3787eet_data_put_union(Eet_Dictionary *ed,
3788 Eet_Data_Descriptor *edd __UNUSED__,
3789 Eet_Data_Element *ede,
3790 Eet_Data_Stream *ds,
3791 void *data_in)
3792{
3793 const char *union_type;
3794 int i;
3795
3796 EET_ASSERT(!((ede->type != EET_T_UNKNOW) || (!ede->subtype)), return );
3797
3798 union_type = ede->subtype->func.type_get(
3799 ((char *)data_in) + ede->count - ede->offset,
3800 NULL);
3801
3802 if (!union_type)
3803 return;
3804
3805 /* Search the structure of the union to encode. */
3806 for (i = 0; i < ede->subtype->elements.num; ++i)
3807 if (strcmp(ede->subtype->elements.set[i].name, union_type) == 0)
3808 {
3809 Eet_Data_Element *sede;
3810 void *data;
3811 int size;
3812
3813 /* Yeah we found it ! */
3814 data = eet_data_put_type(ed, EET_T_STRING, &union_type, &size);
3815 if (data)
3816 eet_data_encode(ed,
3817 ds,
3818 data,
3819 ede->name,
3820 size,
3821 ede->type,
3822 ede->group_type);
3823
3824 sede = &(ede->subtype->elements.set[i]);
3825 data = _eet_data_descriptor_encode(ed,
3826 sede->subtype,
3827 data_in,
3828 &size);
3829 if (data)
3830 eet_data_encode(ed,
3831 ds,
3832 data,
3833 ede->name,
3834 size,
3835 ede->type,
3836 ede->group_type);
3837
3838 break;
3839 }
3840}
3841
3842static int
3843eet_data_get_union(Eet_Free_Context *context,
3844 const Eet_Dictionary *ed,
3845 Eet_Data_Descriptor *edd __UNUSED__,
3846 Eet_Data_Element *ede,
3847 Eet_Data_Chunk *echnk,
3848 int type,
3849 int group_type,
3850 void *data,
3851 char **p,
3852 int *size)
3853{
3854 const char *union_type;
3855 void *data_ret = NULL;
3856 int ret = 0;
3857 int i;
3858
3859 /* Read type */
3860 ret = eet_data_get_type(ed,
3861 EET_T_STRING,
3862 echnk->data,
3863 ((char *)echnk->data) + echnk->size,
3864 &union_type);
3865 if (ret <= 0)
3866 goto on_error;
3867
3868 /* Advance to next chunk */
3869 NEXT_CHUNK((*p), (*size), (*echnk), ed);
3870 memset(echnk, 0, sizeof(Eet_Data_Chunk));
3871
3872 /* Read value */
3873 eet_data_chunk_get(ed, echnk, *p, *size);
3874 if (!echnk->name)
3875 goto on_error;
3876
3877 if (ede)
3878 {
3879 EET_ASSERT(!(ede->group_type != group_type || ede->type != type),
3880 goto on_error);
3881
3882 /* Search the structure of the union to decode */
3883 for (i = 0; i < ede->subtype->elements.num; ++i)
3884 if (strcmp(ede->subtype->elements.set[i].name, union_type) == 0)
3885 {
3886 Eet_Data_Element *sede;
3887 char *ut;
3888
3889 /* Yeah we found it ! */
3890 sede = &(ede->subtype->elements.set[i]);
3891 EET_ASSERT(sede->subtype, goto on_error);
3892
3893 data_ret = _eet_data_descriptor_decode(context,
3894 ed,
3895 sede->subtype,
3896 echnk->data,
3897 echnk->size,
3898 data,
3899 sede->subtype->size);
3900 if (!data_ret)
3901 goto on_error;
3902
3903 /* Set union type. */
3904 if ((!ed) || (!ede->subtype->func.str_direct_alloc))
3905 {
3906 ut = ede->subtype->func.str_alloc(union_type);
3907 _eet_freelist_str_add(context, ut);
3908 }
3909 else
3910 {
3911 ut = ede->subtype->func.str_direct_alloc(union_type);
3912 _eet_freelist_direct_str_add(context, ut);
3913 }
3914
3915 ede->subtype->func.type_set(
3916 ut,
3917 ((char *)data) + ede->count -
3918 ede->offset,
3919 EINA_FALSE);
3920
3921 break;
3922 }
3923 }
3924 else
3925 {
3926 /* FIXME: generate node structure. */
3927 data_ret = _eet_data_descriptor_decode(context,
3928 ed, NULL,
3929 echnk->data, echnk->size,
3930 NULL, 0);
3931 goto on_error;
3932 }
3933
3934 return 1;
3935
3936on_error:
3937 return 0;
3938}
3939
3940static void
3941eet_data_put_variant(Eet_Dictionary *ed,
3942 Eet_Data_Descriptor *edd __UNUSED__,
3943 Eet_Data_Element *ede,
3944 Eet_Data_Stream *ds,
3945 void *data_in)
3946{
3947 const char *union_type;
3948 void *data;
3949 Eina_Bool unknow = EINA_FALSE;
3950 int size;
3951 int i;
3952
3953 EET_ASSERT(!((ede->type != EET_T_UNKNOW) || (!ede->subtype)), return );
3954
3955 union_type = ede->subtype->func.type_get(
3956 ((char *)data_in) + ede->count - ede->offset,
3957 &unknow);
3958
3959 if (!union_type && unknow == EINA_FALSE)
3960 return;
3961
3962 if (unknow)
3963 {
3964 /* Handle opaque internal representation */
3965 Eet_Variant_Unknow *evu;
3966
3967 data = eet_data_put_type(ed, EET_T_STRING, &union_type, &size);
3968 if (data)
3969 eet_data_encode(ed,
3970 ds,
3971 data,
3972 ede->name,
3973 size,
3974 ede->type,
3975 ede->group_type);
3976
3977 evu = (Eet_Variant_Unknow *)data_in;
3978 if (evu && EINA_MAGIC_CHECK(evu, EET_MAGIC_VARIANT))
3979 eet_data_encode(ed,
3980 ds,
3981 evu->data,
3982 ede->name,
3983 evu->size,
3984 ede->type,
3985 ede->group_type);
3986 }
3987 else
3988 /* Search the structure of the union to encode. */
3989 for (i = 0; i < ede->subtype->elements.num; ++i)
3990 if (strcmp(ede->subtype->elements.set[i].name, union_type) == 0)
3991 {
3992 Eet_Data_Element *sede;
3993
3994 /* Yeah we found it ! */
3995 data = eet_data_put_type(ed, EET_T_STRING, &union_type, &size);
3996 if (data)
3997 eet_data_encode(ed,
3998 ds,
3999 data,
4000 ede->name,
4001 size,
4002 ede->type,
4003 ede->group_type);
4004
4005 sede = &(ede->subtype->elements.set[i]);
4006
4007 if (sede->group_type != EET_G_UNKNOWN)
4008 {
4009 Eet_Data_Stream *lds;
4010
4011 lds = eet_data_stream_new();
4012 eet_group_codec[sede->group_type - 100].put(ed,
4013 sede->subtype,
4014 sede,
4015 lds,
4016 data_in);
4017 if (lds->size != 0)
4018 {
4019 eet_data_encode(ed, ds, lds->data, ede->name, lds->pos,
4020 ede->type, ede->group_type);
4021
4022 lds->data = NULL;
4023 lds->size = 0;
4024 }
4025 else
4026 eet_data_encode(ed, ds, NULL, ede->name, 0,
4027 EET_T_NULL, ede->group_type);
4028
4029 eet_data_stream_free(lds);
4030 }
4031 else
4032 {
4033 data = _eet_data_descriptor_encode(ed,
4034 sede->subtype,
4035 *(void **)data_in,
4036 &size);
4037 if (data)
4038 eet_data_encode(ed,
4039 ds,
4040 data,
4041 ede->name,
4042 size,
4043 ede->type,
4044 ede->group_type);
4045 }
4046
4047 break;
4048 }
4049}
4050
4051static int
4052eet_data_get_variant(Eet_Free_Context *context,
4053 const Eet_Dictionary *ed,
4054 Eet_Data_Descriptor *edd __UNUSED__,
4055 Eet_Data_Element *ede,
4056 Eet_Data_Chunk *echnk,
4057 int type __UNUSED__,
4058 int group_type __UNUSED__,
4059 void *data,
4060 char **p,
4061 int *size)
4062{
4063 const char *union_type;
4064 void *data_ret = NULL;
4065 int ret = 0;
4066 int i;
4067
4068 /* Read type */
4069 ret = eet_data_get_type(ed,
4070 EET_T_STRING,
4071 echnk->data,
4072 ((char *)echnk->data) + echnk->size,
4073 &union_type);
4074 if (ret <= 0)
4075 goto on_error;
4076
4077 /* Advance to next chunk */
4078 NEXT_CHUNK((*p), (*size), (*echnk), ed);
4079 memset(echnk, 0, sizeof(Eet_Data_Chunk));
4080
4081 /* Read value */
4082 eet_data_chunk_get(ed, echnk, *p, *size);
4083 if (!echnk->name)
4084 goto on_error;
4085
4086 if (ede)
4087 {
4088 char *ut;
4089
4090 EET_ASSERT(ede->subtype, goto on_error);
4091
4092 if ((!ed) || (!ede->subtype->func.str_direct_alloc))
4093 {
4094 ut = ede->subtype->func.str_alloc(union_type);
4095 _eet_freelist_str_add(context, ut);
4096 }
4097 else
4098 {
4099 ut = ede->subtype->func.str_direct_alloc(union_type);
4100 _eet_freelist_direct_str_add(context, ut);
4101 }
4102
4103 /* Search the structure of the union to decode */
4104 for (i = 0; i < ede->subtype->elements.num; ++i)
4105 if (strcmp(ede->subtype->elements.set[i].name, union_type) == 0)
4106 {
4107 Eet_Data_Element *sede;
4108
4109 /* Yeah we found it ! */
4110 sede = &(ede->subtype->elements.set[i]);
4111
4112 if (sede->group_type != EET_G_UNKNOWN)
4113 {
4114 Eet_Data_Chunk chnk;
4115 char *p2;
4116 int size2;
4117
4118 p2 = echnk->data;
4119 size2 = echnk->size;
4120
4121 /* Didn't find a proper way to provide this
4122 without duplicating code */
4123 while (size2 > 0)
4124 {
4125 memset(&chnk, 0, sizeof(Eet_Data_Chunk));
4126 eet_data_chunk_get(ed, &chnk, p2, size2);
4127
4128 if (!chnk.name)
4129 goto on_error;
4130
4131 ret = eet_group_codec[sede->group_type - 100].get
4132 (context, ed, sede->subtype, sede, &chnk, sede->type,
4133 sede->group_type, data, &p2, &size2);
4134
4135 if (ret <= 0)
4136 goto on_error;
4137
4138/* advance to next chunk */
4139 NEXT_CHUNK(p2, size2, chnk, ed);
4140 }
4141
4142 /* Put garbage so that we will not put eet_variant_unknow in it */
4143 data_ret = (void *)data;
4144
4145 /* Set variant type. */
4146 ede->subtype->func.type_set
4147 (ut, ((char *)data) + ede->count - ede->offset,
4148 EINA_FALSE);
4149 break;
4150 }
4151
4152 data_ret = _eet_data_descriptor_decode(context,
4153 ed,
4154 sede->subtype,
4155 echnk->data,
4156 echnk->size,
4157 NULL, 0);
4158 if (!data_ret)
4159 break;
4160
4161 /* And point to the variant data. */
4162 *(void **)data = data_ret;
4163
4164 /* Set variant type. */
4165 ede->subtype->func.type_set
4166 (ut, ((char *)data) + ede->count - ede->offset, EINA_FALSE);
4167 break;
4168 }
4169
4170 if (!data_ret)
4171 {
4172 Eet_Variant_Unknow *evu;
4173
4174 evu = calloc(1, sizeof (Eet_Variant_Unknow) + echnk->size - 1);
4175 if (!evu)
4176 goto on_error;
4177
4178 evu->size = echnk->size;
4179 memcpy(evu->data, echnk->data, evu->size);
4180 EINA_MAGIC_SET(evu, EET_MAGIC_VARIANT);
4181
4182 /* And point to the opaque internal data scructure */
4183 *(void **)data = evu;
4184
4185 /* Set variant type. */
4186 ede->subtype->func.type_set
4187 (ut, ((char *)data) + ede->count - ede->offset, EINA_TRUE);
4188 }
4189 }
4190 else
4191 {
4192 /* FIXME: dump node structure. */
4193 data_ret = _eet_data_descriptor_decode(context,
4194 ed, NULL,
4195 echnk->data, echnk->size,
4196 NULL, 0);
4197 goto on_error;
4198 }
4199
4200 return 1;
4201
4202on_error:
4203 return 0;
4204}
4205
4206static Eet_Node *
4207eet_data_node_simple_type(int type,
4208 const char *name,
4209 void *dd)
4210{
4211#ifdef EET_T_TYPE
4212# undef EET_T_TYPE
4213#endif /* ifdef EET_T_TYPE */
4214
4215#define EET_T_TYPE(Eet_Type, Eet_Node_Type, Type) \
4216case Eet_Type: \
4217 return eet_node_ ## Eet_Node_Type ## _new(name, *((Type *)dd)); \
4218
4219 switch (type)
4220 {
4221 EET_T_TYPE(EET_T_CHAR, char, char);
4222 EET_T_TYPE(EET_T_SHORT, short, short);
4223 EET_T_TYPE(EET_T_INT, int, int);
4224 EET_T_TYPE(EET_T_LONG_LONG, long_long, long long);
4225 EET_T_TYPE(EET_T_FLOAT, float, float);
4226 EET_T_TYPE(EET_T_DOUBLE, double, double);
4227 EET_T_TYPE(EET_T_UCHAR, unsigned_char, unsigned char);
4228 EET_T_TYPE(EET_T_USHORT, unsigned_short, unsigned short);
4229 EET_T_TYPE(EET_T_UINT, unsigned_int, unsigned int);
4230 EET_T_TYPE(EET_T_ULONG_LONG, unsigned_long_long, unsigned long long);
4231 EET_T_TYPE(EET_T_STRING, string, char *);
4232 EET_T_TYPE(EET_T_INLINED_STRING, inlined_string, char *);
4233
4234 case EET_T_NULL:
4235 return eet_node_null_new(name);
4236
4237 default:
4238 ERR("Unknow type passed to eet_data_node_simple_type");
4239 return NULL;
4240 }
4241}
4242
4243static int
4244eet_data_get_unknown(Eet_Free_Context *context,
4245 const Eet_Dictionary *ed,
4246 Eet_Data_Descriptor *edd,
4247 Eet_Data_Element *ede,
4248 Eet_Data_Chunk *echnk,
4249 int type,
4250 int group_type __UNUSED__,
4251 void *data,
4252 char **p __UNUSED__,
4253 int *size __UNUSED__)
4254{
4255 int ret;
4256 void *data_ret;
4257
4258 if (IS_SIMPLE_TYPE(type))
4259 {
4260 unsigned char dd[128];
4261
4262 ret = eet_data_get_type(ed,
4263 type,
4264 echnk->data,
4265 ((char *)echnk->data) + echnk->size,
4266 edd ? (char *)data : (char *)dd);
4267 if (ret <= 0)
4268 return ret;
4269
4270 if (!edd)
4271 {
4272 Eet_Node **parent = data;
4273 Eet_Node *node;
4274
4275 node = eet_data_node_simple_type(type, echnk->name, dd);
4276
4277 if (*parent)
4278 eet_node_struct_append(*parent, echnk->name, node);
4279 else
4280 *parent = node;
4281 }
4282 else
4283 {
4284 if (type == EET_T_STRING)
4285 {
4286 char **str;
4287
4288 str = (char **)(((char *)data));
4289 if (*str)
4290 {
4291 if ((!ed) || (!edd->func.str_direct_alloc))
4292 {
4293 *str = edd->func.str_alloc(*str);
4294 _eet_freelist_str_add(context, *str);
4295 }
4296 else
4297 {
4298 *str = edd->func.str_direct_alloc(*str);
4299 _eet_freelist_direct_str_add(context, *str);
4300 }
4301 }
4302 }
4303 else if (edd && type == EET_T_INLINED_STRING)
4304 {
4305 char **str;
4306
4307 str = (char **)(((char *)data));
4308 if (*str)
4309 {
4310 *str = edd->func.str_alloc(*str);
4311 _eet_freelist_str_add(context, *str);
4312 }
4313 }
4314 }
4315 }
4316 else
4317 {
4318 Eet_Data_Descriptor *subtype;
4319
4320 subtype = ede ? ede->subtype : NULL;
4321
4322 if (subtype || !edd)
4323 {
4324 Eet_Node **parent = data;
4325 void **ptr;
4326
4327 data_ret = _eet_data_descriptor_decode(context,
4328 ed,
4329 subtype,
4330 echnk->data,
4331 echnk->size,
4332 NULL, 0);
4333 if (!data_ret)
4334 return 0;
4335
4336 if (edd)
4337 {
4338 ptr = (void **)(((char *)data));
4339 *ptr = (void *)data_ret;
4340 }
4341 else
4342 {
4343 Eet_Node *node = data_ret;
4344
4345 if (*parent)
4346 {
4347 node = eet_node_struct_child_new(echnk->name, node);
4348 eet_node_struct_append(*parent, echnk->name, node);
4349 }
4350 else
4351 *parent = node;
4352 }
4353 }
4354 }
4355
4356 return 1;
4357}
4358
4359static void
4360eet_data_put_array(Eet_Dictionary *ed,
4361 Eet_Data_Descriptor *edd __UNUSED__,
4362 Eet_Data_Element *ede,
4363 Eet_Data_Stream *ds,
4364 void *data_in)
4365{
4366 void *data;
4367 int offset = 0;
4368 int subsize;
4369 int count;
4370 int size;
4371 int j;
4372
4373 EET_ASSERT(!((ede->type > EET_T_UNKNOW) && (ede->type < EET_T_STRING)),
4374 return );
4375
4376 if (ede->group_type == EET_G_ARRAY)
4377 count = ede->counter_offset;
4378 else
4379 count = *(int *)(((char *)data_in) + ede->count - ede->offset);
4380
4381 if (count <= 0)
4382 return; /* Store number of elements */
4383
4384 data = eet_data_put_type(ed, EET_T_INT, &count, &size);
4385 if (data)
4386 eet_data_encode(ed, ds, data, ede->name, size, ede->type, ede->group_type);
4387
4388 if (IS_POINTER_TYPE(ede->type))
4389 subsize = eet_basic_codec[ede->type].size;
4390 else
4391 subsize = ede->subtype->size;
4392
4393 for (j = 0; j < count; j++)
4394 {
4395 void *d;
4396 int pos = ds->pos;
4397
4398 if (ede->group_type == EET_G_ARRAY)
4399 d = (void *)(((char *)data_in) + offset);
4400 else
4401 d = *(((char **)data_in)) + offset;
4402
4403 if (IS_POINTER_TYPE(ede->type))
4404 {
4405 if (*(char **)d)
4406 eet_data_put_unknown(ed, NULL, ede, ds, d);
4407 }
4408 else
4409 {
4410 data = _eet_data_descriptor_encode(ed, ede->subtype, d, &size);
4411 if (data)
4412 eet_data_encode(ed,
4413 ds,
4414 data,
4415 ede->name,
4416 size,
4417 ede->type,
4418 ede->group_type);
4419 }
4420
4421 if (pos == ds->pos)
4422 /* Add a NULL element just to have the correct array layout. */
4423 eet_data_encode(ed,
4424 ds,
4425 NULL,
4426 ede->name,
4427 0,
4428 EET_T_NULL,
4429 ede->group_type);
4430
4431 offset += subsize;
4432 }
4433}
4434
4435static void
4436eet_data_put_unknown(Eet_Dictionary *ed,
4437 Eet_Data_Descriptor *edd __UNUSED__,
4438 Eet_Data_Element *ede,
4439 Eet_Data_Stream *ds,
4440 void *data_in)
4441{
4442 void *data = NULL;
4443 int size;
4444
4445 if (IS_SIMPLE_TYPE(ede->type))
4446 data = eet_data_put_type(ed, ede->type, data_in, &size);
4447 else if (ede->subtype)
4448 if (*((char **)data_in))
4449 data = _eet_data_descriptor_encode(ed,
4450 ede->subtype,
4451 *((char **)((char *)(data_in))),
4452 &size);
4453
4454 if (data)
4455 eet_data_encode(ed,
4456 ds,
4457 data,
4458 ede->name,
4459 size,
4460 ede->type,
4461 ede->group_type);
4462}
4463
4464static void
4465eet_data_put_list(Eet_Dictionary *ed,
4466 Eet_Data_Descriptor *edd,
4467 Eet_Data_Element *ede,
4468 Eet_Data_Stream *ds,
4469 void *data_in)
4470{
4471 void *data;
4472 void *l;
4473 int size;
4474
4475 EET_ASSERT(!(((ede->type > EET_T_UNKNOW) && (ede->type < EET_T_STRING))
4476 || ((ede->type > EET_T_NULL) && (ede->type < EET_T_LAST))),
4477 return );
4478
4479 l = *((void **)(((char *)data_in)));
4480 for (; l; l = edd->func.list_next(l))
4481 {
4482 if (IS_POINTER_TYPE(ede->type))
4483 {
4484 const void *str = edd->func.list_data(l);
4485 eet_data_put_unknown(ed, NULL, ede, ds, &str);
4486 }
4487 else
4488 {
4489 data = _eet_data_descriptor_encode(ed,
4490 ede->subtype,
4491 edd->func.list_data(l),
4492 &size);
4493 if (data)
4494 eet_data_encode(ed,
4495 ds,
4496 data,
4497 ede->name,
4498 size,
4499 ede->type,
4500 ede->group_type);
4501 }
4502 }
4503}
4504
4505static void
4506eet_data_put_hash(Eet_Dictionary *ed,
4507 Eet_Data_Descriptor *edd,
4508 Eet_Data_Element *ede,
4509 Eet_Data_Stream *ds,
4510 void *data_in)
4511{
4512 Eet_Data_Encode_Hash_Info fdata;
4513 void *l;
4514
4515 l = *((void **)(((char *)data_in)));
4516 fdata.ds = ds;
4517 fdata.ede = ede;
4518 fdata.ed = ed;
4519 edd->func.hash_foreach(l, eet_data_descriptor_encode_hash_cb, &fdata);
4520}
4521
4522EAPI int
4523eet_data_dump_cipher(Eet_File *ef,
4524 const char *name,
4525 const char *cipher_key,
4526 Eet_Dump_Callback dumpfunc,
4527 void *dumpdata)
4528{
4529 const Eet_Dictionary *ed = NULL;
4530 const void *data = NULL;
4531 Eet_Node *result;
4532 Eet_Free_Context context;
4533 int required_free = 0;
4534 int size;
4535
4536 ed = eet_dictionary_get(ef);
4537
4538 if (!cipher_key)
4539 data = eet_read_direct(ef, name, &size);
4540
4541 if (!data)
4542 {
4543 required_free = 1;
4544 data = eet_read_cipher(ef, name, &size, cipher_key);
4545 if (!data)
4546 return 0;
4547 }
4548
4549 eet_free_context_init(&context);
4550 result = _eet_data_descriptor_decode(&context, ed, NULL, data, size, NULL, 0);
4551 eet_free_context_shutdown(&context);
4552
4553 eet_node_dump(result, 0, dumpfunc, dumpdata);
4554
4555 eet_node_del(result);
4556
4557 if (required_free)
4558 free((void *)data);
4559
4560 return result ? 1 : 0;
4561}
4562
4563EAPI int
4564eet_data_dump(Eet_File *ef,
4565 const char *name,
4566 Eet_Dump_Callback dumpfunc,
4567 void *dumpdata)
4568{
4569 return eet_data_dump_cipher(ef, name, NULL, dumpfunc, dumpdata);
4570}
4571
4572EAPI int
4573eet_data_text_dump_cipher(const void *data_in,
4574 const char *cipher_key,
4575 int size_in,
4576 Eet_Dump_Callback dumpfunc,
4577 void *dumpdata)
4578{
4579 void *ret = NULL;
4580 Eet_Node *result;
4581 Eet_Free_Context context;
4582 unsigned int ret_len = 0;
4583
4584 if (!data_in)
4585 return 0;
4586
4587 if (cipher_key)
4588 {
4589 if (eet_decipher(data_in, size_in, cipher_key,
4590 strlen(cipher_key), &ret, &ret_len))
4591 {
4592 if (ret)
4593 free(ret);
4594
4595 return 0;
4596 }
4597 }
4598 else
4599 {
4600 ret = (void *)data_in;
4601 ret_len = size_in;
4602 }
4603
4604 eet_free_context_init(&context);
4605 result = _eet_data_descriptor_decode(&context, NULL, NULL, ret, ret_len, NULL, 0);
4606 eet_free_context_shutdown(&context);
4607
4608 eet_node_dump(result, 0, dumpfunc, dumpdata);
4609
4610 eet_node_del(result);
4611 if (cipher_key)
4612 free(ret);
4613
4614 return result ? 1 : 0;
4615}
4616
4617EAPI int
4618eet_data_text_dump(const void *data_in,
4619 int size_in,
4620 Eet_Dump_Callback dumpfunc,
4621 void *dumpdata)
4622{
4623 return eet_data_text_dump_cipher(data_in, NULL, size_in, dumpfunc, dumpdata);
4624}
4625
4626EAPI void *
4627eet_data_text_undump_cipher(const char *text,
4628 const char *cipher_key,
4629 int textlen,
4630 int *size_ret)
4631{
4632 void *ret = NULL;
4633
4634 ret = _eet_data_dump_parse(NULL, size_ret, text, textlen);
4635 if (ret && cipher_key)
4636 {
4637 void *ciphered = NULL;
4638 unsigned int ciphered_len;
4639
4640 if (eet_cipher(ret, *size_ret, cipher_key,
4641 strlen(cipher_key), &ciphered, &ciphered_len))
4642 {
4643 if (ciphered)
4644 free(ciphered);
4645
4646 size_ret = 0;
4647 free(ret);
4648 return NULL;
4649 }
4650
4651 free(ret);
4652 *size_ret = ciphered_len;
4653 ret = ciphered;
4654 }
4655
4656 return ret;
4657}
4658
4659EAPI void *
4660eet_data_text_undump(const char *text,
4661 int textlen,
4662 int *size_ret)
4663{
4664 return eet_data_text_undump_cipher(text, NULL, textlen, size_ret);
4665}
4666
4667EAPI int
4668eet_data_undump_cipher(Eet_File *ef,
4669 const char *name,
4670 const char *cipher_key,
4671 const char *text,
4672 int textlen,
4673 int compress)
4674{
4675 Eet_Dictionary *ed;
4676 void *data_enc;
4677 int size;
4678 int val;
4679
4680 ed = eet_dictionary_get(ef);
4681
4682 data_enc = _eet_data_dump_parse(ed, &size, text, textlen);
4683 if (!data_enc)
4684 return 0;
4685
4686 val = eet_write_cipher(ef, name, data_enc, size, compress, cipher_key);
4687 free(data_enc);
4688 return val;
4689}
4690
4691EAPI int
4692eet_data_undump(Eet_File *ef,
4693 const char *name,
4694 const char *text,
4695 int textlen,
4696 int compress)
4697{
4698 return eet_data_undump_cipher(ef, name, NULL, text, textlen, compress);
4699}
4700
4701EAPI void *
4702eet_data_descriptor_decode_cipher(Eet_Data_Descriptor *edd,
4703 const void *data_in,
4704 const char *cipher_key,
4705 int size_in)
4706{
4707 void *deciphered = (void *)data_in;
4708 void *ret;
4709 Eet_Free_Context context;
4710 unsigned int deciphered_len = size_in;
4711
4712 if (cipher_key && data_in)
4713 if (eet_decipher(data_in, size_in, cipher_key,
4714 strlen(cipher_key), &deciphered, &deciphered_len))
4715 {
4716 if (deciphered)
4717 free(deciphered);
4718
4719 return NULL;
4720 }
4721
4722 eet_free_context_init(&context);
4723 ret = _eet_data_descriptor_decode(&context,
4724 NULL,
4725 edd,
4726 deciphered,
4727 deciphered_len,
4728 NULL, 0);
4729 eet_free_context_shutdown(&context);
4730
4731 if (data_in != deciphered)
4732 free(deciphered);
4733
4734 return ret;
4735}
4736
4737EAPI void *
4738eet_data_descriptor_decode(Eet_Data_Descriptor *edd,
4739 const void *data_in,
4740 int size_in)
4741{
4742 return eet_data_descriptor_decode_cipher(edd, data_in, NULL, size_in);
4743}
4744
4745EAPI Eet_Node *
4746eet_data_node_decode_cipher(const void *data_in,
4747 const char *cipher_key,
4748 int size_in)
4749{
4750 void *deciphered = (void *)data_in;
4751 Eet_Node *ret;
4752 Eet_Free_Context context;
4753 unsigned int deciphered_len = size_in;
4754
4755 if (cipher_key && data_in)
4756 if (eet_decipher(data_in, size_in, cipher_key,
4757 strlen(cipher_key), &deciphered, &deciphered_len))
4758 {
4759 if (deciphered)
4760 free(deciphered);
4761
4762 return NULL;
4763 }
4764
4765 eet_free_context_init(&context);
4766 ret = _eet_data_descriptor_decode(&context,
4767 NULL,
4768 NULL,
4769 deciphered,
4770 deciphered_len,
4771 NULL, 0);
4772 eet_free_context_shutdown(&context);
4773
4774 if (data_in != deciphered)
4775 free(deciphered);
4776
4777 return ret;
4778}
4779
4780static void *
4781_eet_data_descriptor_encode(Eet_Dictionary *ed,
4782 Eet_Data_Descriptor *edd,
4783 const void *data_in,
4784 int *size_ret)
4785{
4786 Eet_Data_Stream *ds;
4787 Eet_Data_Chunk *chnk;
4788 void *cdata;
4789 int csize;
4790 int i;
4791
4792 if (_eet_data_words_bigendian == -1)
4793 {
4794 unsigned long int v;
4795
4796 v = htonl(0x12345678);
4797 if (v == 0x12345678)
4798 _eet_data_words_bigendian = 1;
4799 else
4800 _eet_data_words_bigendian = 0;
4801 }
4802
4803 ds = eet_data_stream_new();
4804 for (i = 0; i < edd->elements.num; i++)
4805 {
4806 Eet_Data_Element *ede;
4807
4808 ede = &(edd->elements.set[i]);
4809 eet_group_codec[ede->group_type - 100].put(
4810 ed,
4811 edd,
4812 ede,
4813 ds,
4814 ((char *)data_in) +
4815 ede->offset);
4816 }
4817 chnk = eet_data_chunk_new(ds->data,
4818 ds->pos,
4819 edd->name,
4820 EET_T_UNKNOW,
4821 EET_G_UNKNOWN);
4822 ds->data = NULL;
4823 ds->size = 0;
4824 eet_data_stream_free(ds);
4825
4826 ds = eet_data_stream_new();
4827 eet_data_chunk_put(ed, chnk, ds);
4828 cdata = ds->data;
4829 csize = ds->pos;
4830
4831 ds->data = NULL;
4832 ds->size = 0;
4833 eet_data_stream_free(ds);
4834 *size_ret = csize;
4835
4836 free(chnk->data);
4837 eet_data_chunk_free(chnk);
4838
4839 return cdata;
4840}
4841
4842EAPI int
4843eet_data_node_write_cipher(Eet_File *ef,
4844 const char *name,
4845 const char *cipher_key,
4846 Eet_Node *node,
4847 int compress)
4848{
4849 Eet_Dictionary *ed;
4850 void *data_enc;
4851 int size;
4852 int val;
4853
4854 ed = eet_dictionary_get(ef);
4855
4856 data_enc = _eet_data_dump_encode(EET_G_UNKNOWN, ed, node, &size);
4857 if (!data_enc)
4858 return 0;
4859
4860 val = eet_write_cipher(ef, name, data_enc, size, compress, cipher_key);
4861 free(data_enc);
4862 return val;
4863}
4864
4865EAPI void *
4866eet_data_node_encode_cipher(Eet_Node *node,
4867 const char *cipher_key,
4868 int *size_ret)
4869{
4870 void *ret = NULL;
4871 void *ciphered = NULL;
4872 unsigned int ciphered_len = 0;
4873 int size;
4874
4875 ret = _eet_data_dump_encode(EET_G_UNKNOWN, NULL, node, &size);
4876 if (cipher_key && ret)
4877 {
4878 if (eet_cipher(ret, size, cipher_key,
4879 strlen(cipher_key), &ciphered, &ciphered_len))
4880 {
4881 if (ciphered)
4882 free(ciphered);
4883
4884 if (size_ret)
4885 *size_ret = 0;
4886
4887 free(ret);
4888 return NULL;
4889 }
4890
4891 free(ret);
4892 size = (int)ciphered_len;
4893 ret = ciphered;
4894 }
4895
4896 if (size_ret)
4897 *size_ret = size;
4898
4899 return ret;
4900}
4901
4902EAPI void *
4903eet_data_descriptor_encode_cipher(Eet_Data_Descriptor *edd,
4904 const void *data_in,
4905 const char *cipher_key,
4906 int *size_ret)
4907{
4908 void *ret = NULL;
4909 void *ciphered = NULL;
4910 unsigned int ciphered_len = 0;
4911 int size;
4912
4913 ret = _eet_data_descriptor_encode(NULL, edd, data_in, &size);
4914 if (cipher_key && ret)
4915 {
4916 if (eet_cipher(ret, size, cipher_key,
4917 strlen(cipher_key), &ciphered, &ciphered_len))
4918 {
4919 if (ciphered)
4920 free(ciphered);
4921
4922 if (size_ret)
4923 *size_ret = 0;
4924
4925 free(ret);
4926 return NULL;
4927 }
4928
4929 free(ret);
4930 size = ciphered_len;
4931 ret = ciphered;
4932 }
4933
4934 if (size_ret)
4935 *size_ret = size;
4936
4937 return ret;
4938}
4939
4940EAPI void *
4941eet_data_descriptor_encode(Eet_Data_Descriptor *edd,
4942 const void *data_in,
4943 int *size_ret)
4944{
4945 return eet_data_descriptor_encode_cipher(edd, data_in, NULL, size_ret);
4946}
4947
4948EAPI void *
4949eet_data_xattr_cipher_get(const char *filename,
4950 const char *attribute,
4951 Eet_Data_Descriptor *edd,
4952 const char *cipher_key)
4953{
4954 void *blob;
4955 void *ret;
4956 ssize_t size;
4957
4958 blob = eina_xattr_get(filename, attribute, &size);
4959 if (!blob) return NULL;
4960
4961 ret = eet_data_descriptor_decode_cipher(edd, blob, cipher_key, size);
4962 free(blob);
4963
4964 return ret;
4965}
4966
4967EAPI Eina_Bool
4968eet_data_xattr_cipher_set(const char *filename,
4969 const char *attribute,
4970 Eet_Data_Descriptor *edd,
4971 const char *cipher_key,
4972 const void *data,
4973 Eina_Xattr_Flags flags)
4974{
4975 void *blob;
4976 int size;
4977 Eina_Bool ret;
4978
4979 blob = eet_data_descriptor_encode_cipher(edd, data, cipher_key, &size);
4980 if (!blob) return EINA_FALSE;
4981
4982 ret = eina_xattr_set(filename, attribute, blob, size, flags);
4983 free(blob);
4984
4985 return ret;
4986}
diff --git a/libraries/eet/src/lib/eet_dictionary.c b/libraries/eet/src/lib/eet_dictionary.c
deleted file mode 100644
index c79239b..0000000
--- a/libraries/eet/src/lib/eet_dictionary.c
+++ /dev/null
@@ -1,444 +0,0 @@
1#ifdef HAVE_CONFIG_H
2# include <config.h>
3#endif /* ifdef HAVE_CONFIG_H */
4
5#include <stdio.h>
6#include <string.h>
7#include <math.h>
8
9#include <Eina.h>
10
11#include "Eet.h"
12#include "Eet_private.h"
13
14Eet_Dictionary *
15eet_dictionary_add(void)
16{
17 Eet_Dictionary *new;
18
19 new = eet_dictionary_calloc(1);
20 if (!new)
21 return NULL;
22
23 memset(new->hash, -1, sizeof (int) * 256);
24
25 return new;
26}
27
28void
29eet_dictionary_free(Eet_Dictionary *ed)
30{
31 int i;
32
33 if (!ed) return;
34
35 for (i = 0; i < ed->count; ++i)
36 if (ed->all[i].allocated)
37 eina_stringshare_del(ed->all[i].str);
38
39 if (ed->all)
40 free(ed->all);
41
42 if (ed->converts) eina_hash_free(ed->converts);
43
44 eet_dictionary_mp_free(ed);
45}
46
47static int
48_eet_dictionary_lookup(Eet_Dictionary *ed,
49 const char *string,
50 int len,
51 int hash)
52{
53 Eina_Bool found = EINA_FALSE;
54 int prev = -1;
55 int current;
56
57 current = ed->hash[hash];
58
59 while (current != -1)
60 {
61 if (ed->all[current].len == len)
62 {
63 if (ed->all[current].str &&
64 (ed->all[current].str == string || strcmp(ed->all[current].str, string) == 0))
65 {
66 found = EINA_TRUE;
67 break;
68 }
69 }
70
71 prev = current;
72 current = ed->all[current].next;
73 }
74
75 if (current == -1 && found)
76 return prev;
77
78 return current;
79}
80
81int
82eet_dictionary_string_add(Eet_Dictionary *ed,
83 const char *string)
84{
85 Eet_String *current;
86 const char *str;
87 int hash;
88 int idx;
89 int len;
90
91 if (!ed)
92 return -1;
93
94 hash = _eet_hash_gen(string, 8);
95 len = strlen(string) + 1;
96
97 idx = _eet_dictionary_lookup(ed, string, len, hash);
98
99 if (idx != -1)
100 {
101 if (ed->all[idx].str && (ed->all[idx].str == string || strcmp(ed->all[idx].str, string) == 0))
102 return idx;
103 }
104
105 if (ed->total == ed->count)
106 {
107 Eet_String *new;
108 int total;
109
110 total = ed->total + 8;
111
112 new = realloc(ed->all, total * sizeof(Eet_String));
113 if (!new)
114 return -1;
115
116 ed->all = new;
117 ed->total = total;
118 }
119
120 str = eina_stringshare_add(string);
121 if (!str)
122 return -1;
123
124 current = ed->all + ed->count;
125
126 current->allocated = EINA_TRUE;
127
128 current->hash = hash;
129
130 current->str = str;
131 current->len = len;
132
133 if (idx == -1)
134 {
135 current->next = ed->hash[hash];
136 current->prev = -1;
137 ed->hash[hash] = ed->count;
138 }
139 else
140 {
141 current->next = idx;
142 current->prev = ed->all[idx].prev;
143
144 if (current->next != -1)
145 ed->all[current->next].prev = ed->count;
146
147 if (current->prev != -1)
148 ed->all[current->prev].next = ed->count;
149 else
150 ed->hash[hash] = ed->count;
151 }
152
153 return ed->count++;
154}
155
156int
157eet_dictionary_string_get_size(const Eet_Dictionary *ed,
158 int idx)
159{
160 if (!ed)
161 return 0;
162
163 if (idx < 0)
164 return 0;
165
166 if (idx < ed->count)
167 return ed->all[idx].len;
168
169 return 0;
170}
171
172EAPI int
173eet_dictionary_count(const Eet_Dictionary *ed)
174{
175 return ed->count;
176}
177
178int
179eet_dictionary_string_get_hash(const Eet_Dictionary *ed,
180 int idx)
181{
182 if (!ed)
183 return -1;
184
185 if (idx < 0)
186 return -1;
187
188 if (idx < ed->count)
189 return ed->all[idx].hash;
190
191 return -1;
192}
193
194const char *
195eet_dictionary_string_get_char(const Eet_Dictionary *ed,
196 int idx)
197{
198 if (!ed)
199 return NULL;
200
201 if (idx < 0)
202 return NULL;
203
204 if (idx < ed->count)
205 {
206#ifdef _WIN32
207 /* Windows file system could change the mmaped file when replacing a file. So we need to copy all string in memory to avoid bugs. */
208 if (!ed->all[idx].allocated)
209 {
210 ed->all[idx].str = eina_stringshare_add(ed->all[idx].str);
211 ed->all[idx].allocated = EINA_TRUE;
212 }
213#endif /* ifdef _WIN32 */
214 return ed->all[idx].str;
215 }
216
217 return NULL;
218}
219
220static inline Eina_Bool
221_eet_dictionary_string_get_me_cache(const char *s,
222 int len,
223 int *mantisse,
224 int *exponent)
225{
226 if ((len == 6) && (s[0] == '0') && (s[1] == 'x') && (s[3] == 'p'))
227 {
228 *mantisse = (s[2] >= 'a') ? (s[2] - 'a' + 10) : (s[2] - '0');
229 *exponent = (s[5] - '0');
230
231 return EINA_TRUE;
232 }
233
234 return EINA_FALSE;
235}
236
237static inline Eina_Bool
238_eet_dictionary_string_get_float_cache(const char *s,
239 int len,
240 float *result)
241{
242 int mantisse;
243 int exponent;
244
245 if (_eet_dictionary_string_get_me_cache(s, len, &mantisse, &exponent))
246 {
247 if (s[4] == '+')
248 *result = (float)(mantisse << exponent);
249 else
250 *result = (float)mantisse / (float)(1 << exponent);
251
252 return EINA_TRUE;
253 }
254
255 return EINA_FALSE;
256}
257
258static inline Eina_Bool
259_eet_dictionary_string_get_double_cache(const char *s,
260 int len,
261 double *result)
262{
263 int mantisse;
264 int exponent;
265
266 if (_eet_dictionary_string_get_me_cache(s, len, &mantisse, &exponent))
267 {
268 if (s[4] == '+')
269 *result = (double)(mantisse << exponent);
270 else
271 *result = (double)mantisse / (float)(1 << exponent);
272
273 return EINA_TRUE;
274 }
275
276 return EINA_FALSE;
277}
278
279static inline Eina_Bool
280_eet_dictionary_test(const Eet_Dictionary *ed,
281 int idx,
282 void *result)
283{
284 if (!result)
285 return EINA_FALSE;
286
287 if (!ed)
288 return EINA_FALSE;
289
290 if (idx < 0)
291 return EINA_FALSE;
292
293 if (!(idx < ed->count))
294 return EINA_FALSE;
295
296 return EINA_TRUE;
297}
298
299static Eet_Convert *
300eet_dictionary_convert_get(const Eet_Dictionary *ed,
301 int idx,
302 const char **str)
303{
304 Eet_Convert *result;
305
306 *str = ed->all[idx].str;
307
308 if (!ed->converts)
309 {
310 ((Eet_Dictionary *)ed)->converts = eina_hash_int32_new(free);
311
312 goto add_convert;
313 }
314
315 result = eina_hash_find(ed->converts, &idx);
316 if (result) return result;
317
318add_convert:
319 result = calloc(1, sizeof (Eet_Convert));
320
321 eina_hash_add(ed->converts, &idx, result);
322 return result;
323}
324
325Eina_Bool
326eet_dictionary_string_get_float(const Eet_Dictionary *ed,
327 int idx,
328 float *result)
329{
330 Eet_Convert *convert;
331 const char *str;
332
333 if (!_eet_dictionary_test(ed, idx, result))
334 return EINA_FALSE;
335
336 convert = eet_dictionary_convert_get(ed, idx, &str);
337 if (!convert) return EINA_FALSE;
338
339 if (!(convert->type & EET_D_FLOAT))
340 {
341 if (!_eet_dictionary_string_get_float_cache(str, ed->all[idx].len,
342 &convert->f))
343 {
344 long long mantisse = 0;
345 long exponent = 0;
346
347 if (eina_convert_atod(str, ed->all[idx].len, &mantisse,
348 &exponent) == EINA_FALSE)
349 return EINA_FALSE;
350
351 convert->f = ldexpf((float)mantisse, exponent);
352 }
353
354 convert->type |= EET_D_FLOAT;
355 }
356
357 *result = convert->f;
358 return EINA_TRUE;
359}
360
361Eina_Bool
362eet_dictionary_string_get_double(const Eet_Dictionary *ed,
363 int idx,
364 double *result)
365{
366 Eet_Convert *convert;
367 const char *str;
368
369 if (!_eet_dictionary_test(ed, idx, result))
370 return EINA_FALSE;
371
372 convert = eet_dictionary_convert_get(ed, idx, &str);
373 if (!convert) return EINA_FALSE;
374
375 if (!(convert->type & EET_D_DOUBLE))
376 {
377 if (!_eet_dictionary_string_get_double_cache(str, ed->all[idx].len,
378 &convert->d))
379 {
380 long long mantisse = 0;
381 long exponent = 0;
382
383 if (eina_convert_atod(str, ed->all[idx].len, &mantisse,
384 &exponent) == EINA_FALSE)
385 return EINA_FALSE;
386
387 convert->d = ldexp((double)mantisse, exponent);
388 }
389
390 convert->type |= EET_D_DOUBLE;
391 }
392
393 *result = convert->d;
394 return EINA_TRUE;
395}
396
397Eina_Bool
398eet_dictionary_string_get_fp(const Eet_Dictionary *ed,
399 int idx,
400 Eina_F32p32 *result)
401{
402 Eet_Convert *convert;
403 const char *str;
404
405 if (!_eet_dictionary_test(ed, idx, result))
406 return EINA_FALSE;
407
408 convert = eet_dictionary_convert_get(ed, idx, &str);
409 if (!convert) return EINA_FALSE;
410
411 if (!(convert->type & EET_D_FIXED_POINT))
412 {
413 Eina_F32p32 fp;
414
415 if (!eina_convert_atofp(str, ed->all[idx].len, &fp))
416 return EINA_FALSE;
417
418 convert->fp = fp;
419 convert->type |= EET_D_FIXED_POINT;
420 }
421
422 *result = convert->fp;
423 return EINA_TRUE;
424}
425
426EAPI int
427eet_dictionary_string_check(Eet_Dictionary *ed,
428 const char *string)
429{
430 int i;
431
432 if ((!ed) || (!string))
433 return 0;
434
435 if ((ed->start <= string) && (string < ed->end))
436 return 1;
437
438 for (i = 0; i < ed->count; ++i)
439 if ((ed->all[i].allocated) && ed->all[i].str == string)
440 return 1;
441
442 return 0;
443}
444
diff --git a/libraries/eet/src/lib/eet_image.c b/libraries/eet/src/lib/eet_image.c
deleted file mode 100644
index b622236..0000000
--- a/libraries/eet/src/lib/eet_image.c
+++ /dev/null
@@ -1,1825 +0,0 @@
1#ifdef HAVE_CONFIG_H
2# include <config.h>
3#endif /* ifdef HAVE_CONFIG_H */
4
5#ifdef HAVE_ALLOCA_H
6# include <alloca.h>
7#elif defined __GNUC__
8# define alloca __builtin_alloca
9#elif defined _AIX
10# define alloca __alloca
11#elif defined _MSC_VER
12# include <malloc.h>
13# define alloca _alloca
14#else /* ifdef HAVE_ALLOCA_H */
15# include <stddef.h>
16# ifdef __cplusplus
17extern "C"
18# endif /* ifdef __cplusplus */
19void *alloca(size_t);
20#endif /* ifdef HAVE_ALLOCA_H */
21
22#ifdef HAVE_NETINET_IN_H
23# ifdef __OpenBSD__
24# include <sys/types.h>
25# endif /* ifdef __OpenBSD__ */
26# include <netinet/in.h>
27#endif /* ifdef HAVE_NETINET_IN_H */
28
29#ifdef _WIN32
30# include <winsock2.h>
31# define HAVE_BOOLEAN
32#endif /* ifdef _WIN32 */
33
34#include <stdio.h>
35#include <string.h>
36#include <setjmp.h>
37#include <zlib.h>
38#include <jpeglib.h>
39
40#include "Eet.h"
41#include "Eet_private.h"
42
43/*---*/
44
45typedef struct _JPEG_error_mgr *emptr;
46
47/*---*/
48
49struct _JPEG_error_mgr
50{
51 struct jpeg_error_mgr pub;
52 jmp_buf setjmp_buffer;
53};
54
55struct jpeg_membuf_src
56{
57 struct jpeg_source_mgr pub;
58
59 const unsigned char *buf;
60 size_t len;
61 struct jpeg_membuf_src *self;
62};
63
64static void
65_eet_jpeg_membuf_src_init(j_decompress_ptr cinfo)
66{
67 /* FIXME: Use attribute unused */
68 (void)cinfo;
69}
70
71static boolean
72_eet_jpeg_membuf_src_fill(j_decompress_ptr cinfo)
73{
74 static const JOCTET jpeg_eoi[2] = { 0xFF, JPEG_EOI };
75 struct jpeg_membuf_src *src = (struct jpeg_membuf_src *)cinfo->src;
76
77 src->pub.bytes_in_buffer = sizeof(jpeg_eoi);
78 src->pub.next_input_byte = jpeg_eoi;
79
80 return TRUE;
81}
82
83static void
84_eet_jpeg_membuf_src_skip(j_decompress_ptr cinfo,
85 long num_bytes)
86{
87 struct jpeg_membuf_src *src = (struct jpeg_membuf_src *)cinfo->src;
88
89 src->pub.bytes_in_buffer -= num_bytes;
90 src->pub.next_input_byte += num_bytes;
91}
92
93static void
94_eet_jpeg_membuf_src_term(j_decompress_ptr cinfo)
95{
96 struct jpeg_membuf_src *src = ((struct jpeg_membuf_src *)cinfo->src)->self;
97
98 free(src);
99 cinfo->src = NULL;
100}
101
102static int
103eet_jpeg_membuf_src(j_decompress_ptr cinfo,
104 const void *buf,
105 size_t len)
106{
107 struct jpeg_membuf_src *src;
108
109 src = calloc(1, sizeof(*src));
110 if (!src)
111 return -1;
112
113 src->self = src;
114
115 cinfo->src = &src->pub;
116 src->buf = buf;
117 src->len = len;
118 src->pub.init_source = _eet_jpeg_membuf_src_init;
119 src->pub.fill_input_buffer = _eet_jpeg_membuf_src_fill;
120 src->pub.skip_input_data = _eet_jpeg_membuf_src_skip;
121 src->pub.resync_to_restart = jpeg_resync_to_restart;
122 src->pub.term_source = _eet_jpeg_membuf_src_term;
123 src->pub.bytes_in_buffer = src->len;
124 src->pub.next_input_byte = src->buf;
125
126 return 0;
127}
128
129struct jpeg_membuf_dst
130{
131 struct jpeg_destination_mgr pub;
132
133 void **dst_buf;
134 size_t *dst_len;
135
136 unsigned char *buf;
137 size_t len;
138 int failed;
139 struct jpeg_membuf_dst *self;
140};
141
142static void
143_eet_jpeg_membuf_dst_init(j_compress_ptr cinfo)
144{
145 /* FIXME: Use eina attribute */
146 (void)cinfo;
147}
148
149static boolean
150_eet_jpeg_membuf_dst_flush(j_compress_ptr cinfo)
151{
152 struct jpeg_membuf_dst *dst = (struct jpeg_membuf_dst *)cinfo->dest;
153 unsigned char *buf;
154
155 if (dst->len >= 0x40000000 ||
156 !(buf = realloc(dst->buf, dst->len * 2)))
157 {
158 dst->failed = 1;
159 dst->pub.next_output_byte = dst->buf;
160 dst->pub.free_in_buffer = dst->len;
161 return TRUE;
162 }
163
164 dst->pub.next_output_byte =
165 buf + ((unsigned char *)dst->pub.next_output_byte - dst->buf);
166 dst->buf = buf;
167 dst->pub.free_in_buffer += dst->len;
168 dst->len *= 2;
169
170 return FALSE;
171}
172
173static void
174_eet_jpeg_membuf_dst_term(j_compress_ptr cinfo)
175{
176 struct jpeg_membuf_dst *dst = ((struct jpeg_membuf_dst *)cinfo->dest)->self;
177
178 if (dst->failed)
179 {
180 *dst->dst_buf = NULL;
181 *dst->dst_len = 0;
182 free(dst->buf);
183 }
184 else
185 {
186 *dst->dst_buf = dst->buf;
187 *dst->dst_len = (unsigned char *)dst->pub.next_output_byte - dst->buf;
188 }
189
190 free(dst);
191 cinfo->dest = NULL;
192}
193
194static int
195eet_jpeg_membuf_dst(j_compress_ptr cinfo,
196 void **buf,
197 size_t *len)
198{
199 struct jpeg_membuf_dst *dst;
200
201 dst = calloc(1, sizeof(*dst));
202 if (!dst)
203 return -1;
204
205 dst->buf = malloc(32768);
206 if (!dst->buf)
207 {
208 free(dst);
209 return -1;
210 }
211
212 dst->self = dst;
213 dst->len = 32768;
214
215 cinfo->dest = &dst->pub;
216 dst->pub.init_destination = _eet_jpeg_membuf_dst_init;
217 dst->pub.empty_output_buffer = _eet_jpeg_membuf_dst_flush;
218 dst->pub.term_destination = _eet_jpeg_membuf_dst_term;
219 dst->pub.free_in_buffer = dst->len;
220 dst->pub.next_output_byte = dst->buf;
221 dst->dst_buf = buf;
222 dst->dst_len = len;
223 dst->failed = 0;
224
225 return 0;
226}
227
228/*---*/
229
230static void _JPEGFatalErrorHandler(j_common_ptr cinfo);
231static void _JPEGErrorHandler(j_common_ptr cinfo);
232static void _JPEGErrorHandler2(j_common_ptr cinfo,
233 int msg_level);
234
235static int
236eet_data_image_jpeg_header_decode(const void *data,
237 int size,
238 unsigned int *w,
239 unsigned int *h);
240static int
241eet_data_image_jpeg_rgb_decode(const void *data,
242 int size,
243 unsigned int src_x,
244 unsigned int src_y,
245 unsigned int *d,
246 unsigned int w,
247 unsigned int h,
248 unsigned int row_stride);
249static int
250eet_data_image_jpeg_alpha_decode(const void *data,
251 int size,
252 unsigned int src_x,
253 unsigned int src_y,
254 unsigned int *d,
255 unsigned int w,
256 unsigned int h,
257 unsigned int row_stride);
258static void *
259eet_data_image_lossless_convert(int *size,
260 const void *data,
261 unsigned int w,
262 unsigned int h,
263 int alpha);
264static void *
265eet_data_image_lossless_compressed_convert(int *size,
266 const void *data,
267 unsigned int w,
268 unsigned int h,
269 int alpha,
270 int compression);
271static void *
272eet_data_image_jpeg_convert(int *size,
273 const void *data,
274 unsigned int w,
275 unsigned int h,
276 int alpha,
277 int quality);
278static void *
279eet_data_image_jpeg_alpha_convert(int *size,
280 const void *data,
281 unsigned int w,
282 unsigned int h,
283 int alpha,
284 int quality);
285
286/*---*/
287
288static int _eet_image_words_bigendian = -1;
289
290/*---*/
291
292#define SWAP64(x) (x) = \
293 ((((unsigned long long)(x) & 0x00000000000000ffULL) << 56) | \
294 (((unsigned long long)(x) & 0x000000000000ff00ULL) << 40) | \
295 (((unsigned long long)(x) & 0x0000000000ff0000ULL) << 24) | \
296 (((unsigned long long)(x) & 0x00000000ff000000ULL) << 8) | \
297 (((unsigned long long)(x) & 0x000000ff00000000ULL) >> 8) | \
298 (((unsigned long long)(x) & 0x0000ff0000000000ULL) >> 24) | \
299 (((unsigned long long)(x) & 0x00ff000000000000ULL) >> 40) | \
300 (((unsigned long long)(x) & 0xff00000000000000ULL) >> 56))
301#define SWAP32(x) (x) = \
302 ((((int)(x) & 0x000000ff) << 24) | \
303 (((int)(x) & 0x0000ff00) << 8) | \
304 (((int)(x) & 0x00ff0000) >> 8) | \
305 (((int)(x) & 0xff000000) >> 24))
306#define SWAP16(x) (x) = \
307 ((((short)(x) & 0x00ff) << 8) | \
308 (((short)(x) & 0xff00) >> 8))
309
310#ifdef CONV8
311# undef CONV8
312#endif /* ifdef CONV8 */
313#ifdef CONV16
314# undef CONV16
315#endif /* ifdef CONV16 */
316#ifdef CONV32
317# undef CONV32
318#endif /* ifdef CONV32 */
319#ifdef CONV64
320# undef CONV64
321#endif /* ifdef CONV64 */
322
323#define CONV8(x)
324#define CONV16(x) {if (_eet_image_words_bigendian) {SWAP16(x); }}
325#define CONV32(x) {if (_eet_image_words_bigendian) {SWAP32(x); }}
326#define CONV64(x) {if (_eet_image_words_bigendian) {SWAP64(x); }}
327
328/*---*/
329
330static void
331_JPEGFatalErrorHandler(j_common_ptr cinfo)
332{
333 emptr errmgr;
334
335 errmgr = (emptr)cinfo->err;
336 /* cinfo->err->output_message(cinfo);*/
337 longjmp(errmgr->setjmp_buffer, 1);
338 return;
339}
340
341static void
342_JPEGErrorHandler(j_common_ptr cinfo __UNUSED__)
343{
344 /* emptr errmgr; */
345
346 /* errmgr = (emptr) cinfo->err; */
347 /* cinfo->err->output_message(cinfo);*/
348 /* longjmp(errmgr->setjmp_buffer, 1);*/
349 return;
350}
351
352static void
353_JPEGErrorHandler2(j_common_ptr cinfo __UNUSED__,
354 int msg_level __UNUSED__)
355{
356 /* emptr errmgr; */
357
358 /* errmgr = (emptr) cinfo->err; */
359 /* cinfo->err->output_message(cinfo);*/
360 /* longjmp(errmgr->setjmp_buffer, 1);*/
361 return;
362}
363
364static int
365eet_data_image_jpeg_header_decode(const void *data,
366 int size,
367 unsigned int *w,
368 unsigned int *h)
369{
370 struct jpeg_decompress_struct cinfo;
371 struct _JPEG_error_mgr jerr;
372
373 memset(&cinfo, 0, sizeof (struct jpeg_decompress_struct));
374
375 cinfo.err = jpeg_std_error(&(jerr.pub));
376 jerr.pub.error_exit = _JPEGFatalErrorHandler;
377 jerr.pub.emit_message = _JPEGErrorHandler2;
378 jerr.pub.output_message = _JPEGErrorHandler;
379 if (setjmp(jerr.setjmp_buffer))
380 return 0;
381
382 jpeg_create_decompress(&cinfo);
383
384 if (eet_jpeg_membuf_src(&cinfo, data, (size_t)size))
385 {
386 jpeg_destroy_decompress(&cinfo);
387 return 0;
388 }
389
390 jpeg_read_header(&cinfo, TRUE);
391 cinfo.do_fancy_upsampling = FALSE;
392 cinfo.do_block_smoothing = FALSE;
393 jpeg_start_decompress(&cinfo);
394
395 /* head decoding */
396 *w = cinfo.output_width;
397 *h = cinfo.output_height;
398
399 free(cinfo.src);
400 cinfo.src = NULL;
401
402 jpeg_destroy_decompress(&cinfo);
403
404 if ((*w < 1) || (*h < 1) || (*w > 8192) || (*h > 8192))
405 return 0;
406
407 return 1;
408}
409
410static int
411eet_data_image_jpeg_rgb_decode(const void *data,
412 int size,
413 unsigned int src_x,
414 unsigned int src_y,
415 unsigned int *d,
416 unsigned int w,
417 unsigned int h,
418 unsigned int row_stride)
419{
420 struct jpeg_decompress_struct cinfo;
421 struct _JPEG_error_mgr jerr;
422 unsigned char *ptr, *line[16], *tdata = NULL;
423 unsigned int *ptr2, *tmp;
424 unsigned int iw, ih;
425 unsigned int x, y, l, scans;
426 unsigned int i;
427
428 /* FIXME: handle src_x, src_y and row_stride correctly */
429 if (!d)
430 return 0;
431
432 memset(&cinfo, 0, sizeof (struct jpeg_decompress_struct));
433
434 cinfo.err = jpeg_std_error(&(jerr.pub));
435 jerr.pub.error_exit = _JPEGFatalErrorHandler;
436 jerr.pub.emit_message = _JPEGErrorHandler2;
437 jerr.pub.output_message = _JPEGErrorHandler;
438 if (setjmp(jerr.setjmp_buffer))
439 return 0;
440
441 jpeg_create_decompress(&cinfo);
442
443 if (eet_jpeg_membuf_src(&cinfo, data, (size_t)size))
444 {
445 jpeg_destroy_decompress(&cinfo);
446 return 0;
447 }
448
449 jpeg_read_header(&cinfo, TRUE);
450 cinfo.dct_method = JDCT_ISLOW; // JDCT_FLOAT JDCT_IFAST(quality loss)
451 cinfo.do_fancy_upsampling = FALSE;
452 cinfo.do_block_smoothing = FALSE;
453 jpeg_start_decompress(&cinfo);
454
455 /* head decoding */
456 iw = cinfo.output_width;
457 ih = cinfo.output_height;
458 if ((iw != w) || (ih != h))
459 {
460 free(cinfo.src);
461 cinfo.src = NULL;
462
463 jpeg_destroy_decompress(&cinfo);
464 return 0;
465 }
466
467 /* end head decoding */
468 /* data decoding */
469 if (cinfo.rec_outbuf_height > 16)
470 {
471 free(cinfo.src);
472 cinfo.src = NULL;
473
474 jpeg_destroy_decompress(&cinfo);
475 return 0;
476 }
477
478 tdata = alloca((iw) * 16 * 3);
479 ptr2 = d;
480
481 if (cinfo.output_components == 3)
482 {
483 for (i = 0; i < (unsigned int)cinfo.rec_outbuf_height; i++)
484 line[i] = tdata + (i * (iw) * 3);
485 for (l = 0; l < ih; l += cinfo.rec_outbuf_height)
486 {
487 jpeg_read_scanlines(&cinfo, line, cinfo.rec_outbuf_height);
488 scans = cinfo.rec_outbuf_height;
489 if ((ih - l) < scans)
490 scans = ih - l;
491
492 ptr = tdata;
493
494 if (l + scans >= src_y && l < src_y + h)
495 {
496 y = src_y - l;
497 if (src_y < l)
498 y = 0;
499
500 for (ptr += 3 * iw * y; y < scans && (y + l) < (src_y + h);
501 y++)
502 {
503 tmp = ptr2;
504 ptr += 3 * src_x;
505 for (x = 0; x < w; x++)
506 {
507 *ptr2 =
508 (0xff000000) |
509 ((ptr[0]) << 16) | ((ptr[1]) << 8) | (ptr[2]);
510 ptr += 3;
511 ptr2++;
512 }
513 ptr += 3 * (iw - w);
514 ptr2 = tmp + row_stride / 4;
515 }
516 }
517 }
518 }
519 else if (cinfo.output_components == 1)
520 {
521 for (i = 0; i < (unsigned int)cinfo.rec_outbuf_height; i++)
522 line[i] = tdata + (i * (iw));
523 for (l = 0; l < (ih); l += cinfo.rec_outbuf_height)
524 {
525 jpeg_read_scanlines(&cinfo, line, cinfo.rec_outbuf_height);
526 scans = cinfo.rec_outbuf_height;
527 if (((ih) - l) < scans)
528 scans = (ih) - l;
529
530 ptr = tdata;
531
532 if (l >= src_y && l < src_y + h)
533 {
534 y = src_y - l;
535 if (src_y < l)
536 y = 0;
537
538 for (ptr += iw * y; y < scans && (y + l) < (src_y + h); y++)
539 {
540 tmp = ptr2;
541 ptr += src_x;
542 for (x = 0; x < w; x++)
543 {
544 *ptr2 =
545 (0xff000000) |
546 ((ptr[0]) << 16) | ((ptr[0]) << 8) | (ptr[0]);
547 ptr++;
548 ptr2++;
549 }
550 ptr += iw - w;
551 ptr2 = tmp + row_stride / 4;
552 }
553 }
554 }
555 }
556
557 /* end data decoding */
558 jpeg_finish_decompress(&cinfo);
559 jpeg_destroy_decompress(&cinfo);
560 return 1;
561}
562
563static int
564eet_data_image_jpeg_alpha_decode(const void *data,
565 int size,
566 unsigned int src_x,
567 unsigned int src_y,
568 unsigned int *d,
569 unsigned int w,
570 unsigned int h,
571 unsigned int row_stride)
572{
573 struct jpeg_decompress_struct cinfo;
574 struct _JPEG_error_mgr jerr;
575 unsigned char *ptr, *line[16], *tdata = NULL;
576 unsigned int *ptr2, *tmp;
577 unsigned int x, y, l, scans;
578 unsigned int i, iw;
579
580 /* FIXME: handle src_x, src_y and row_stride correctly */
581 if (!d)
582 return 0;
583
584 memset(&cinfo, 0, sizeof (struct jpeg_decompress_struct));
585
586 cinfo.err = jpeg_std_error(&(jerr.pub));
587 jerr.pub.error_exit = _JPEGFatalErrorHandler;
588 jerr.pub.emit_message = _JPEGErrorHandler2;
589 jerr.pub.output_message = _JPEGErrorHandler;
590 if (setjmp(jerr.setjmp_buffer))
591 return 0;
592
593 jpeg_create_decompress(&cinfo);
594
595 if (eet_jpeg_membuf_src(&cinfo, data, (size_t)size))
596 {
597 jpeg_destroy_decompress(&cinfo);
598 return 0;
599 }
600
601 jpeg_read_header(&cinfo, TRUE);
602 cinfo.dct_method = JDCT_ISLOW; // JDCT_FLOAT JDCT_IFAST(quality loss)
603 cinfo.do_fancy_upsampling = FALSE;
604 cinfo.do_block_smoothing = FALSE;
605 jpeg_start_decompress(&cinfo);
606
607 /* head decoding */
608 iw = cinfo.output_width;
609 if (w != cinfo.output_width
610 || h != cinfo.output_height)
611 {
612 free(cinfo.src);
613 cinfo.src = NULL;
614
615 jpeg_destroy_decompress(&cinfo);
616 return 0;
617 }
618
619 /* end head decoding */
620 /* data decoding */
621 if (cinfo.rec_outbuf_height > 16)
622 {
623 free(cinfo.src);
624 cinfo.src = NULL;
625
626 jpeg_destroy_decompress(&cinfo);
627 return 0;
628 }
629
630 tdata = alloca(w * 16 * 3);
631 ptr2 = d;
632
633 if (cinfo.output_components == 1)
634 {
635 for (i = 0; i < (unsigned int)cinfo.rec_outbuf_height; i++)
636 line[i] = tdata + (i * w);
637 for (l = 0; l < h; l += cinfo.rec_outbuf_height)
638 {
639 jpeg_read_scanlines(&cinfo, line, cinfo.rec_outbuf_height);
640 scans = cinfo.rec_outbuf_height;
641 if ((h - l) < scans)
642 scans = h - l;
643
644 ptr = tdata;
645
646 if (l >= src_y && l < src_y + h)
647 {
648 y = src_y - l;
649 if (src_y < l)
650 y = 0;
651
652 for (ptr += iw * y; y < scans && (y + l) < (src_y + h); y++)
653 {
654 tmp = ptr2;
655 ptr += src_x;
656 for (x = 0; x < w; x++)
657 {
658 *ptr2 =
659 ((*ptr2) & 0x00ffffff) |
660 ((ptr[0]) << 24);
661 ptr++;
662 ptr2++;
663 }
664 ptr += iw - w;
665 ptr2 = tmp + row_stride / 4;
666 }
667 }
668 }
669 }
670
671 /* end data decoding */
672 jpeg_finish_decompress(&cinfo);
673 jpeg_destroy_decompress(&cinfo);
674 return 1;
675}
676
677static void *
678eet_data_image_lossless_convert(int *size,
679 const void *data,
680 unsigned int w,
681 unsigned int h,
682 int alpha)
683{
684 if (_eet_image_words_bigendian == -1)
685 {
686 unsigned long int v;
687
688 v = htonl(0x12345678);
689 if (v == 0x12345678)
690 _eet_image_words_bigendian = 1;
691 else
692 _eet_image_words_bigendian = 0;
693 }
694
695 {
696 unsigned char *d;
697 int *header;
698
699 d = malloc((w * h * 4) + (8 * 4));
700 if (!d)
701 return NULL;
702
703 header = (int *)d;
704 memset(d, 0, 32);
705
706 header[0] = 0xac1dfeed;
707 header[1] = w;
708 header[2] = h;
709 header[3] = alpha;
710
711 memcpy(d + 32, data, w * h * 4);
712
713 if (_eet_image_words_bigendian)
714 {
715 unsigned int i;
716
717 for (i = 0; i < ((w * h) + 8); i++) SWAP32(header[i]);
718 }
719
720 *size = ((w * h * 4) + (8 * 4));
721 return d;
722 }
723}
724
725static void *
726eet_data_image_lossless_compressed_convert(int *size,
727 const void *data,
728 unsigned int w,
729 unsigned int h,
730 int alpha,
731 int compression)
732{
733 if (_eet_image_words_bigendian == -1)
734 {
735 unsigned long int v;
736
737 v = htonl(0x12345678);
738 if (v == 0x12345678)
739 _eet_image_words_bigendian = 1;
740 else
741 _eet_image_words_bigendian = 0;
742 }
743
744 {
745 unsigned char *d;
746 unsigned char *comp;
747 int *header;
748 int ret;
749 uLongf buflen;
750
751 d = malloc((w * h * 4) + (8 * 4));
752 if (!d)
753 return NULL;
754
755 buflen = (((w * h * 101) / 100) + 3) * 4;
756 comp = malloc(buflen);
757 if (!comp)
758 {
759 free(d);
760 return NULL;
761 }
762
763 header = (int *)d;
764 memset(d, 0, 32);
765
766 header[0] = 0xac1dfeed;
767 header[1] = w;
768 header[2] = h;
769 header[3] = alpha;
770 header[4] = compression;
771 memcpy(d + 32, data, w * h * 4);
772
773 if (_eet_image_words_bigendian)
774 {
775 unsigned int i;
776
777 for (i = 0; i < ((w * h) + 8); i++) SWAP32(header[i]);
778 }
779
780 ret = compress2((Bytef *)comp, &buflen,
781 (Bytef *)(d + 32),
782 (uLong)(w * h * 4),
783 compression);
784 if (ret != Z_OK || buflen > (w * h * 4))
785 {
786 free(comp);
787 free(d);
788 *size = -1;
789 return NULL;
790 }
791
792 memcpy(d + 32, comp, buflen);
793 *size = (8 * 4) + buflen;
794 free(comp);
795 return d;
796 }
797}
798
799static void *
800eet_data_image_jpeg_convert(int *size,
801 const void *data,
802 unsigned int w,
803 unsigned int h,
804 int alpha,
805 int quality)
806{
807 struct jpeg_compress_struct cinfo;
808 struct _JPEG_error_mgr jerr;
809 const int *ptr;
810 void *d = NULL;
811 size_t sz = 0;
812 JSAMPROW *jbuf;
813 unsigned char *buf;
814
815 (void)alpha; /* unused */
816
817 buf = alloca(3 * w);
818
819 memset(&cinfo, 0, sizeof (struct jpeg_compress_struct));
820
821 cinfo.err = jpeg_std_error(&(jerr.pub));
822 jerr.pub.error_exit = _JPEGFatalErrorHandler;
823 jerr.pub.emit_message = _JPEGErrorHandler2;
824 jerr.pub.output_message = _JPEGErrorHandler;
825 if (setjmp(jerr.setjmp_buffer))
826 return NULL;
827
828 jpeg_create_compress(&cinfo);
829
830 if (eet_jpeg_membuf_dst(&cinfo, &d, &sz))
831 {
832 jpeg_destroy_compress(&cinfo);
833 return NULL;
834 }
835
836 cinfo.image_width = w;
837 cinfo.image_height = h;
838 cinfo.input_components = 3;
839 cinfo.in_color_space = JCS_RGB;
840 cinfo.optimize_coding = FALSE;
841 cinfo.dct_method = JDCT_ISLOW; // JDCT_FLOAT JDCT_IFAST(quality loss)
842 if (quality < 60) cinfo.dct_method = JDCT_IFAST;
843 jpeg_set_defaults(&cinfo);
844 jpeg_set_quality(&cinfo, quality, TRUE);
845
846 if (quality >= 90)
847 {
848 cinfo.comp_info[0].h_samp_factor = 1;
849 cinfo.comp_info[0].v_samp_factor = 1;
850 cinfo.comp_info[1].h_samp_factor = 1;
851 cinfo.comp_info[1].v_samp_factor = 1;
852 cinfo.comp_info[2].h_samp_factor = 1;
853 cinfo.comp_info[2].v_samp_factor = 1;
854 }
855
856 jpeg_start_compress(&cinfo, TRUE);
857
858 while (cinfo.next_scanline < cinfo.image_height)
859 {
860 unsigned int i, j;
861
862 /* convert scaline from ARGB to RGB packed */
863 ptr = ((const int *)data) + cinfo.next_scanline * w;
864 for (j = 0, i = 0; i < w; i++)
865 {
866 buf[j++] = ((*ptr) >> 16) & 0xff;
867 buf[j++] = ((*ptr) >> 8) & 0xff;
868 buf[j++] = ((*ptr)) & 0xff;
869 ptr++;
870 }
871 jbuf = (JSAMPROW *)(&buf);
872 jpeg_write_scanlines(&cinfo, jbuf, 1);
873 }
874
875 jpeg_finish_compress(&cinfo);
876 jpeg_destroy_compress(&cinfo);
877
878 *size = sz;
879 return d;
880}
881
882static void *
883eet_data_image_jpeg_alpha_convert(int *size,
884 const void *data,
885 unsigned int w,
886 unsigned int h,
887 int alpha,
888 int quality)
889{
890 unsigned char *d1, *d2;
891 unsigned char *d;
892 int *header;
893 int sz1, sz2;
894
895 (void)alpha; /* unused */
896
897 if (_eet_image_words_bigendian == -1)
898 {
899 unsigned long int v;
900
901 v = htonl(0x12345678);
902 if (v == 0x12345678)
903 _eet_image_words_bigendian = 1;
904 else
905 _eet_image_words_bigendian = 0;
906 }
907
908 {
909 const int *ptr;
910 void *dst = NULL;
911 size_t sz = 0;
912 struct _JPEG_error_mgr jerr;
913 JSAMPROW *jbuf;
914 struct jpeg_compress_struct cinfo;
915 unsigned char *buf;
916
917 buf = alloca(3 * w);
918
919 cinfo.err = jpeg_std_error(&(jerr.pub));
920 jerr.pub.error_exit = _JPEGFatalErrorHandler;
921 jerr.pub.emit_message = _JPEGErrorHandler2;
922 jerr.pub.output_message = _JPEGErrorHandler;
923 if (setjmp(jerr.setjmp_buffer))
924 return NULL;
925
926 jpeg_create_compress(&cinfo);
927 if (eet_jpeg_membuf_dst(&cinfo, &dst, &sz))
928 {
929 jpeg_destroy_compress(&cinfo);
930 return NULL;
931 }
932
933 cinfo.image_width = w;
934 cinfo.image_height = h;
935 cinfo.input_components = 3;
936 cinfo.in_color_space = JCS_RGB;
937 cinfo.optimize_coding = FALSE;
938 cinfo.dct_method = JDCT_ISLOW; // JDCT_FLOAT JDCT_IFAST(quality loss)
939 if (quality < 60) cinfo.dct_method = JDCT_IFAST;
940 jpeg_set_defaults(&cinfo);
941 jpeg_set_quality(&cinfo, quality, TRUE);
942 if (quality >= 90)
943 {
944 cinfo.comp_info[0].h_samp_factor = 1;
945 cinfo.comp_info[0].v_samp_factor = 1;
946 cinfo.comp_info[1].h_samp_factor = 1;
947 cinfo.comp_info[1].v_samp_factor = 1;
948 cinfo.comp_info[2].h_samp_factor = 1;
949 cinfo.comp_info[2].v_samp_factor = 1;
950 }
951
952 jpeg_start_compress(&cinfo, TRUE);
953
954 while (cinfo.next_scanline < cinfo.image_height)
955 {
956 unsigned int i, j;
957
958 ptr = ((const int *)data) + cinfo.next_scanline * w;
959 /* convert scaline from ARGB to RGB packed */
960 for (j = 0, i = 0; i < w; i++)
961 {
962 buf[j++] = ((*ptr) >> 16) & 0xff;
963 buf[j++] = ((*ptr) >> 8) & 0xff;
964 buf[j++] = ((*ptr)) & 0xff;
965 ptr++;
966 }
967 jbuf = (JSAMPROW *)(&buf);
968 jpeg_write_scanlines(&cinfo, jbuf, 1);
969 }
970
971 jpeg_finish_compress(&cinfo);
972 jpeg_destroy_compress(&cinfo);
973
974 d1 = dst;
975 sz1 = sz;
976 }
977 {
978 const int *ptr;
979 void *dst = NULL;
980 size_t sz = 0;
981 struct _JPEG_error_mgr jerr;
982 JSAMPROW *jbuf;
983 struct jpeg_compress_struct cinfo;
984 unsigned char *buf;
985
986 buf = alloca(3 * w);
987
988 cinfo.err = jpeg_std_error(&(jerr.pub));
989 jerr.pub.error_exit = _JPEGFatalErrorHandler;
990 jerr.pub.emit_message = _JPEGErrorHandler2;
991 jerr.pub.output_message = _JPEGErrorHandler;
992 if (setjmp(jerr.setjmp_buffer))
993 {
994 free(d1);
995 return NULL;
996 }
997
998 jpeg_create_compress(&cinfo);
999 if (eet_jpeg_membuf_dst(&cinfo, &dst, &sz))
1000 {
1001 jpeg_destroy_compress(&cinfo);
1002 free(d1);
1003 return NULL;
1004 }
1005
1006 cinfo.image_width = w;
1007 cinfo.image_height = h;
1008 cinfo.input_components = 1;
1009 cinfo.in_color_space = JCS_GRAYSCALE;
1010 jpeg_set_defaults(&cinfo);
1011 jpeg_set_quality(&cinfo, quality, TRUE);
1012 if (quality >= 90)
1013 {
1014 cinfo.comp_info[0].h_samp_factor = 1;
1015 cinfo.comp_info[0].v_samp_factor = 1;
1016 cinfo.comp_info[1].h_samp_factor = 1;
1017 cinfo.comp_info[1].v_samp_factor = 1;
1018 cinfo.comp_info[2].h_samp_factor = 1;
1019 cinfo.comp_info[2].v_samp_factor = 1;
1020 }
1021
1022 jpeg_start_compress(&cinfo, TRUE);
1023
1024 while (cinfo.next_scanline < cinfo.image_height)
1025 {
1026 unsigned int i, j;
1027
1028 ptr = ((const int *)data) + cinfo.next_scanline * w;
1029 /* convert scaline from ARGB to RGB packed */
1030 for (j = 0, i = 0; i < w; i++)
1031 {
1032 buf[j++] = ((*ptr) >> 24) & 0xff;
1033 ptr++;
1034 }
1035 jbuf = (JSAMPROW *)(&buf);
1036 jpeg_write_scanlines(&cinfo, jbuf, 1);
1037 }
1038
1039 jpeg_finish_compress(&cinfo);
1040 jpeg_destroy_compress(&cinfo);
1041
1042 d2 = dst;
1043 sz2 = sz;
1044 }
1045 d = malloc(12 + sz1 + sz2);
1046 if (!d)
1047 {
1048 free(d1);
1049 free(d2);
1050 return NULL;
1051 }
1052
1053 header = (int *)d;
1054 header[0] = 0xbeeff00d;
1055 header[1] = sz1;
1056 header[2] = sz2;
1057 if (_eet_image_words_bigendian)
1058 {
1059 int i;
1060
1061 for (i = 0; i < 3; i++) SWAP32(header[i]);
1062 }
1063
1064 memcpy(d + 12, d1, sz1);
1065 memcpy(d + 12 + sz1, d2, sz2);
1066
1067 free(d1);
1068 free(d2);
1069 *size = 12 + sz1 + sz2;
1070 return d;
1071}
1072
1073EAPI int
1074eet_data_image_write_cipher(Eet_File *ef,
1075 const char *name,
1076 const char *cipher_key,
1077 const void *data,
1078 unsigned int w,
1079 unsigned int h,
1080 int alpha,
1081 int comp,
1082 int quality,
1083 int lossy)
1084{
1085 void *d = NULL;
1086 int size = 0;
1087
1088 d = eet_data_image_encode(data, &size, w, h, alpha, comp, quality, lossy);
1089 if (d)
1090 {
1091 int v;
1092
1093 v = eet_write_cipher(ef, name, d, size, 0, cipher_key);
1094 free(d);
1095 return v;
1096 }
1097
1098 return 0;
1099}
1100
1101EAPI int
1102eet_data_image_write(Eet_File *ef,
1103 const char *name,
1104 const void *data,
1105 unsigned int w,
1106 unsigned int h,
1107 int alpha,
1108 int comp,
1109 int quality,
1110 int lossy)
1111{
1112 return eet_data_image_write_cipher(ef,
1113 name,
1114 NULL,
1115 data,
1116 w,
1117 h,
1118 alpha,
1119 comp,
1120 quality,
1121 lossy);
1122}
1123
1124EAPI void *
1125eet_data_image_read_cipher(Eet_File *ef,
1126 const char *name,
1127 const char *cipher_key,
1128 unsigned int *w,
1129 unsigned int *h,
1130 int *alpha,
1131 int *comp,
1132 int *quality,
1133 int *lossy)
1134{
1135 unsigned int *d = NULL;
1136 void *data = NULL;
1137 int free_data = 0;
1138 int size;
1139
1140 if (!cipher_key)
1141 data = (void *)eet_read_direct(ef, name, &size);
1142
1143 if (!data)
1144 {
1145 data = eet_read_cipher(ef, name, &size, cipher_key);
1146 free_data = 1;
1147 if (!data)
1148 return NULL;
1149 }
1150
1151 d = eet_data_image_decode(data, size, w, h, alpha, comp, quality, lossy);
1152
1153 if (free_data)
1154 free(data);
1155
1156 return d;
1157}
1158
1159EAPI void *
1160eet_data_image_read(Eet_File *ef,
1161 const char *name,
1162 unsigned int *w,
1163 unsigned int *h,
1164 int *alpha,
1165 int *comp,
1166 int *quality,
1167 int *lossy)
1168{
1169 return eet_data_image_read_cipher(ef, name, NULL, w, h, alpha,
1170 comp, quality, lossy);
1171}
1172
1173EAPI int
1174eet_data_image_read_to_surface_cipher(Eet_File *ef,
1175 const char *name,
1176 const char *cipher_key,
1177 unsigned int src_x,
1178 unsigned int src_y,
1179 unsigned int *d,
1180 unsigned int w,
1181 unsigned int h,
1182 unsigned int row_stride,
1183 int *alpha,
1184 int *comp,
1185 int *quality,
1186 int *lossy)
1187{
1188 void *data = NULL;
1189 int free_data = 0;
1190 int res = 1;
1191 int size;
1192
1193 if (!cipher_key)
1194 data = (void *)eet_read_direct(ef, name, &size);
1195
1196 if (!data)
1197 {
1198 data = eet_read_cipher(ef, name, &size, cipher_key);
1199 free_data = 1;
1200 if (!data)
1201 return 0;
1202 }
1203
1204 res = eet_data_image_decode_to_surface(data, size, src_x, src_y, d,
1205 w, h, row_stride, alpha,
1206 comp, quality, lossy);
1207
1208 if (free_data)
1209 free(data);
1210
1211 return res;
1212}
1213
1214EAPI int
1215eet_data_image_read_to_surface(Eet_File *ef,
1216 const char *name,
1217 unsigned int src_x,
1218 unsigned int src_y,
1219 unsigned int *d,
1220 unsigned int w,
1221 unsigned int h,
1222 unsigned int row_stride,
1223 int *alpha,
1224 int *comp,
1225 int *quality,
1226 int *lossy)
1227{
1228 return eet_data_image_read_to_surface_cipher(ef, name, NULL,
1229 src_x, src_y, d,
1230 w, h, row_stride,
1231 alpha, comp, quality,
1232 lossy);
1233}
1234
1235EAPI int
1236eet_data_image_header_read_cipher(Eet_File *ef,
1237 const char *name,
1238 const char *cipher_key,
1239 unsigned int *w,
1240 unsigned int *h,
1241 int *alpha,
1242 int *comp,
1243 int *quality,
1244 int *lossy)
1245{
1246 void *data = NULL;
1247 int size = 0;
1248 int free_data = 0;
1249 int d;
1250
1251 if (!cipher_key)
1252 data = (void *)eet_read_direct(ef, name, &size);
1253
1254 if (!data)
1255 {
1256 data = eet_read_cipher(ef, name, &size, cipher_key);
1257 free_data = 1;
1258 if (!data)
1259 return 0;
1260 }
1261
1262 d = eet_data_image_header_decode(data, size, w, h, alpha,
1263 comp, quality, lossy);
1264 if (free_data)
1265 free(data);
1266
1267 return d;
1268}
1269
1270EAPI int
1271eet_data_image_header_read(Eet_File *ef,
1272 const char *name,
1273 unsigned int *w,
1274 unsigned int *h,
1275 int *alpha,
1276 int *comp,
1277 int *quality,
1278 int *lossy)
1279{
1280 return eet_data_image_header_read_cipher(ef, name, NULL,
1281 w, h, alpha,
1282 comp, quality, lossy);
1283}
1284
1285EAPI void *
1286eet_data_image_encode_cipher(const void *data,
1287 const char *cipher_key,
1288 unsigned int w,
1289 unsigned int h,
1290 int alpha,
1291 int comp,
1292 int quality,
1293 int lossy,
1294 int *size_ret)
1295{
1296 void *d = NULL;
1297 void *ciphered_d = NULL;
1298 unsigned int ciphered_sz = 0;
1299 int size = 0;
1300
1301 if (lossy == 0)
1302 {
1303 if (comp > 0)
1304 d = eet_data_image_lossless_compressed_convert(&size, data,
1305 w, h, alpha, comp);
1306
1307 /* eet_data_image_lossless_compressed_convert will refuse to compress something
1308 if the result is bigger than the entry. */
1309 if (comp <= 0 || !d)
1310 d = eet_data_image_lossless_convert(&size, data, w, h, alpha);
1311 }
1312 else
1313 {
1314 if (!alpha)
1315 d = eet_data_image_jpeg_convert(&size, data, w, h, alpha, quality);
1316 else
1317 d = eet_data_image_jpeg_alpha_convert(&size, data,
1318 w, h, alpha, quality);
1319 }
1320
1321 if (cipher_key)
1322 {
1323 if(!eet_cipher(d, size, cipher_key, strlen(cipher_key), &ciphered_d,
1324 &ciphered_sz))
1325 {
1326 if (d)
1327 free(d);
1328
1329 d = ciphered_d;
1330 size = ciphered_sz;
1331 }
1332 else
1333 if (ciphered_d)
1334 free(ciphered_d);
1335 }
1336
1337 if (size_ret)
1338 *size_ret = size;
1339
1340 return d;
1341}
1342
1343EAPI void *
1344eet_data_image_encode(const void *data,
1345 int *size_ret,
1346 unsigned int w,
1347 unsigned int h,
1348 int alpha,
1349 int comp,
1350 int quality,
1351 int lossy)
1352{
1353 return eet_data_image_encode_cipher(data, NULL, w, h, alpha,
1354 comp, quality, lossy, size_ret);
1355}
1356
1357EAPI int
1358eet_data_image_header_decode_cipher(const void *data,
1359 const char *cipher_key,
1360 int size,
1361 unsigned int *w,
1362 unsigned int *h,
1363 int *alpha,
1364 int *comp,
1365 int *quality,
1366 int *lossy)
1367{
1368 int header[8];
1369 void *deciphered_d = NULL;
1370 unsigned int deciphered_sz = 0;
1371
1372 if (cipher_key)
1373 {
1374 if (!eet_decipher(data, size, cipher_key, strlen(cipher_key),
1375 &deciphered_d, &deciphered_sz))
1376 {
1377 data = deciphered_d;
1378 size = deciphered_sz;
1379 }
1380 else
1381 if (deciphered_d)
1382 free(deciphered_d);
1383 }
1384
1385 if (_eet_image_words_bigendian == -1)
1386 {
1387 unsigned long int v;
1388
1389 v = htonl(0x12345678);
1390 if (v == 0x12345678)
1391 _eet_image_words_bigendian = 1;
1392 else
1393 _eet_image_words_bigendian = 0;
1394 }
1395
1396 if (size < 32)
1397 return 0;
1398
1399 memcpy(header, data, 32);
1400 if (_eet_image_words_bigendian)
1401 {
1402 int i;
1403
1404 for (i = 0; i < 8; i++) SWAP32(header[i]);
1405 }
1406
1407 if ((unsigned)header[0] == 0xac1dfeed)
1408 {
1409 int iw, ih, al, cp;
1410
1411 iw = header[1];
1412 ih = header[2];
1413 al = header[3];
1414 cp = header[4];
1415 if ((iw < 1) || (ih < 1) || (iw > 8192) || (ih > 8192))
1416 return 0;
1417
1418 if ((cp == 0) && (size < ((iw * ih * 4) + 32)))
1419 return 0;
1420
1421 if (w)
1422 *w = iw;
1423
1424 if (h)
1425 *h = ih;
1426
1427 if (alpha)
1428 *alpha = al ? 1 : 0;
1429
1430 if (comp)
1431 *comp = cp;
1432
1433 if (lossy)
1434 *lossy = 0;
1435
1436 if (quality)
1437 *quality = 100;
1438
1439 return 1;
1440 }
1441 else if ((unsigned)header[0] == 0xbeeff00d)
1442 {
1443 unsigned int iw = 0, ih = 0;
1444 unsigned const char *dt;
1445 int sz1;
1446 int ok;
1447
1448 sz1 = header[1];
1449/* sz2 = header[2]; */
1450 dt = data;
1451 dt += 12;
1452 ok = eet_data_image_jpeg_header_decode(dt, sz1, &iw, &ih);
1453 if (ok)
1454 {
1455 if (w)
1456 *w = iw;
1457
1458 if (h)
1459 *h = ih;
1460
1461 if (alpha)
1462 *alpha = 1;
1463
1464 if (comp)
1465 *comp = 0;
1466
1467 if (lossy)
1468 *lossy = 1;
1469
1470 if (quality)
1471 *quality = 75;
1472
1473 return 1;
1474 }
1475 }
1476 else
1477 {
1478 unsigned int iw = 0, ih = 0;
1479 int ok;
1480
1481 ok = eet_data_image_jpeg_header_decode(data, size, &iw, &ih);
1482 if (ok)
1483 {
1484 if (w)
1485 *w = iw;
1486
1487 if (h)
1488 *h = ih;
1489
1490 if (alpha)
1491 *alpha = 0;
1492
1493 if (comp)
1494 *comp = 0;
1495
1496 if (lossy)
1497 *lossy = 1;
1498
1499 if (quality)
1500 *quality = 75;
1501
1502 return 1;
1503 }
1504 }
1505
1506 return 0;
1507}
1508
1509EAPI int
1510eet_data_image_header_decode(const void *data,
1511 int size,
1512 unsigned int *w,
1513 unsigned int *h,
1514 int *alpha,
1515 int *comp,
1516 int *quality,
1517 int *lossy)
1518{
1519 return eet_data_image_header_decode_cipher(data,
1520 NULL,
1521 size,
1522 w,
1523 h,
1524 alpha,
1525 comp,
1526 quality,
1527 lossy);
1528}
1529
1530static void
1531_eet_data_image_copy_buffer(const unsigned int *src,
1532 unsigned int src_x,
1533 unsigned int src_y,
1534 unsigned int src_w,
1535 unsigned int *dst,
1536 unsigned int w,
1537 unsigned int h,
1538 unsigned int row_stride)
1539{
1540 src += src_x + src_y * src_w;
1541
1542 if (row_stride == src_w * 4 && w == src_w)
1543 memcpy(dst, src, row_stride * h);
1544 else
1545 {
1546 unsigned int *over = dst;
1547 unsigned int y;
1548
1549 for (y = 0; y < h; ++y, src += src_w, over += row_stride)
1550 memcpy(over, src, w * 4);
1551 }
1552}
1553
1554static int
1555_eet_data_image_decode_inside(const void *data,
1556 int size,
1557 unsigned int src_x,
1558 unsigned int src_y,
1559 unsigned int src_w,
1560 unsigned int src_h,
1561 unsigned int *d,
1562 unsigned int w,
1563 unsigned int h,
1564 unsigned int row_stride,
1565 int alpha,
1566 int comp,
1567 int quality,
1568 int lossy)
1569{
1570 if (lossy == 0 && quality == 100)
1571 {
1572 unsigned int *body;
1573
1574 body = ((unsigned int *)data) + 8;
1575 if (!comp)
1576 _eet_data_image_copy_buffer(body, src_x, src_y, src_w, d,
1577 w, h, row_stride);
1578 else
1579 {
1580 if (src_h == h && src_w == w && row_stride == src_w * 4)
1581 {
1582 uLongf dlen;
1583
1584 dlen = w * h * 4;
1585 uncompress((Bytef *)d, &dlen, (Bytef *)body,
1586 (uLongf)(size - 32));
1587 }
1588 else
1589 {
1590 Bytef *dtmp;
1591 uLongf dlen = src_w * src_h * 4;
1592
1593 /* FIXME: This could create a huge alloc. So compressed
1594 data and tile could not always work. */
1595 dtmp = malloc(dlen);
1596 if (!dtmp)
1597 return 0;
1598
1599 uncompress(dtmp, &dlen, (Bytef *)body, (uLongf)(size - 32));
1600
1601 _eet_data_image_copy_buffer((unsigned int *)dtmp,
1602 src_x, src_y, src_w, d,
1603 w, h, row_stride);
1604
1605 free(dtmp);
1606 }
1607 }
1608
1609 /* Fix swapiness. */
1610 if (_eet_image_words_bigendian)
1611 {
1612 unsigned int x;
1613
1614 for (x = 0; x < (w * h); x++) SWAP32(d[x]);
1615 }
1616 }
1617 else if (comp == 0 && lossy == 1)
1618 {
1619 if (alpha)
1620 {
1621 unsigned const char *dt;
1622 int header[8];
1623 int sz1, sz2;
1624
1625 memcpy(header, data, 32);
1626 if (_eet_image_words_bigendian)
1627 {
1628 int i;
1629
1630 for (i = 0; i < 8; i++) SWAP32(header[i]);
1631 }
1632
1633 sz1 = header[1];
1634 sz2 = header[2];
1635 dt = data;
1636 dt += 12;
1637
1638 if (eet_data_image_jpeg_rgb_decode(dt, sz1, src_x, src_y, d, w, h,
1639 row_stride))
1640 {
1641 dt += sz1;
1642 if (!eet_data_image_jpeg_alpha_decode(dt, sz2, src_x, src_y,
1643 d, w, h, row_stride))
1644 return 0;
1645 }
1646 }
1647 else if (!eet_data_image_jpeg_rgb_decode(data, size, src_x, src_y, d, w,
1648 h, row_stride))
1649 return 0;
1650 }
1651 else
1652 abort();
1653
1654 return 1;
1655}
1656
1657EAPI void *
1658eet_data_image_decode_cipher(const void *data,
1659 const char *cipher_key,
1660 int size,
1661 unsigned int *w,
1662 unsigned int *h,
1663 int *alpha,
1664 int *comp,
1665 int *quality,
1666 int *lossy)
1667{
1668 unsigned int *d = NULL;
1669 unsigned int iw, ih;
1670 int ialpha, icompress, iquality, ilossy;
1671 void *deciphered_d = NULL;
1672 unsigned int deciphered_sz = 0;
1673
1674 if (cipher_key)
1675 {
1676 if (!eet_decipher(data, size, cipher_key, strlen(cipher_key),
1677 &deciphered_d, &deciphered_sz))
1678 {
1679 data = deciphered_d;
1680 size = deciphered_sz;
1681 }
1682 else
1683 if (deciphered_d)
1684 free(deciphered_d);
1685 }
1686
1687 /* All check are done during header decode, this simplify the code a lot. */
1688 if (!eet_data_image_header_decode(data, size, &iw, &ih, &ialpha, &icompress,
1689 &iquality, &ilossy))
1690 return NULL;
1691
1692 d = malloc(iw * ih * 4);
1693 if (!d)
1694 return NULL;
1695
1696 if (!_eet_data_image_decode_inside(data, size, 0, 0, iw, ih, d, iw, ih, iw *
1697 4, ialpha, icompress, iquality, ilossy))
1698 {
1699 free(d);
1700 return NULL;
1701 }
1702
1703 if (w)
1704 *w = iw;
1705
1706 if (h)
1707 *h = ih;
1708
1709 if (alpha)
1710 *alpha = ialpha;
1711
1712 if (comp)
1713 *comp = icompress;
1714
1715 if (quality)
1716 *quality = iquality;
1717
1718 if (lossy)
1719 *lossy = ilossy;
1720
1721 return d;
1722}
1723
1724EAPI void *
1725eet_data_image_decode(const void *data,
1726 int size,
1727 unsigned int *w,
1728 unsigned int *h,
1729 int *alpha,
1730 int *comp,
1731 int *quality,
1732 int *lossy)
1733{
1734 return eet_data_image_decode_cipher(data, NULL, size, w, h,
1735 alpha, comp, quality, lossy);
1736}
1737
1738EAPI int
1739eet_data_image_decode_to_surface_cipher(const void *data,
1740 const char *cipher_key,
1741 int size,
1742 unsigned int src_x,
1743 unsigned int src_y,
1744 unsigned int *d,
1745 unsigned int w,
1746 unsigned int h,
1747 unsigned int row_stride,
1748 int *alpha,
1749 int *comp,
1750 int *quality,
1751 int *lossy)
1752{
1753 unsigned int iw, ih;
1754 int ialpha, icompress, iquality, ilossy;
1755 void *deciphered_d = NULL;
1756 unsigned int deciphered_sz = 0;
1757
1758 if (cipher_key)
1759 {
1760 if (!eet_decipher(data, size, cipher_key, strlen(cipher_key),
1761 &deciphered_d, &deciphered_sz))
1762 {
1763 data = deciphered_d;
1764 size = deciphered_sz;
1765 }
1766 else
1767 if (deciphered_d)
1768 free(deciphered_d);
1769 }
1770
1771 /* All check are done during header decode, this simplify the code a lot. */
1772 if (!eet_data_image_header_decode(data, size, &iw, &ih, &ialpha, &icompress,
1773 &iquality, &ilossy))
1774 return 0;
1775
1776 if (!d)
1777 return 0;
1778
1779 if (w * 4 > row_stride)
1780 return 0;
1781
1782 if (w > iw || h > ih)
1783 return 0;
1784
1785 if (!_eet_data_image_decode_inside(data, size, src_x, src_y, iw, ih, d, w, h,
1786 row_stride, ialpha, icompress, iquality,
1787 ilossy))
1788 return 0;
1789
1790 if (alpha)
1791 *alpha = ialpha;
1792
1793 if (comp)
1794 *comp = icompress;
1795
1796 if (quality)
1797 *quality = iquality;
1798
1799 if (lossy)
1800 *lossy = ilossy;
1801
1802 return 1;
1803}
1804
1805EAPI int
1806eet_data_image_decode_to_surface(const void *data,
1807 int size,
1808 unsigned int src_x,
1809 unsigned int src_y,
1810 unsigned int *d,
1811 unsigned int w,
1812 unsigned int h,
1813 unsigned int row_stride,
1814 int *alpha,
1815 int *comp,
1816 int *quality,
1817 int *lossy)
1818{
1819 return eet_data_image_decode_to_surface_cipher(data, NULL, size,
1820 src_x, src_y, d,
1821 w, h, row_stride,
1822 alpha, comp, quality,
1823 lossy);
1824}
1825
diff --git a/libraries/eet/src/lib/eet_lib.c b/libraries/eet/src/lib/eet_lib.c
deleted file mode 100644
index 04feebe..0000000
--- a/libraries/eet/src/lib/eet_lib.c
+++ /dev/null
@@ -1,2533 +0,0 @@
1#ifdef HAVE_CONFIG_H
2# include <config.h>
3#endif /* ifdef HAVE_CONFIG_H */
4
5#ifdef HAVE_ALLOCA_H
6# include <alloca.h>
7#elif defined __GNUC__
8# define alloca __builtin_alloca
9#elif defined _AIX
10# define alloca __alloca
11#elif defined _MSC_VER
12# include <malloc.h>
13# define alloca _alloca
14#else /* ifdef HAVE_ALLOCA_H */
15# include <stddef.h>
16# ifdef __cplusplus
17extern "C"
18# endif /* ifdef __cplusplus */
19void *alloca(size_t);
20#endif /* ifdef HAVE_ALLOCA_H */
21
22#ifdef _WIN32
23# include <winsock2.h>
24#endif /* ifdef _WIN32 */
25
26#include <stdio.h>
27#include <errno.h>
28#include <sys/types.h>
29#include <sys/stat.h>
30#include <time.h>
31#include <string.h>
32#include <fnmatch.h>
33#include <fcntl.h>
34#include <zlib.h>
35
36#ifdef HAVE_UNISTD_H
37# include <unistd.h>
38#endif /* ifdef HAVE_UNISTD_H */
39
40#ifdef HAVE_NETINET_IN_H
41# include <netinet/in.h>
42#endif /* ifdef HAVE_NETINET_IN_H */
43
44#ifdef HAVE_EVIL
45# include <Evil.h>
46#endif /* ifdef HAVE_EVIL */
47
48#include <Eina.h>
49
50#ifdef HAVE_GNUTLS
51# include <gnutls/gnutls.h>
52# include <gcrypt.h>
53#endif /* ifdef HAVE_GNUTLS */
54
55#ifdef HAVE_OPENSSL
56# include <openssl/err.h>
57# include <openssl/evp.h>
58#endif /* ifdef HAVE_OPENSSL */
59
60#ifdef EINA_HAVE_THREADS
61# ifdef HAVE_GNUTLS
62GCRY_THREAD_OPTION_PTHREAD_IMPL;
63# endif /* ifdef HAVE_GNUTLS */
64#endif /* ifdef EINA_HAVE_THREADS */
65
66#include "Eet.h"
67#include "Eet_private.h"
68
69#ifndef O_BINARY
70# define O_BINARY 0
71#endif
72
73static Eet_Version _version = { VMAJ, VMIN, VMIC, VREV };
74EAPI Eet_Version *eet_version = &_version;
75
76#ifdef HAVE_REALPATH
77# undef HAVE_REALPATH
78#endif /* ifdef HAVE_REALPATH */
79
80#define EET_MAGIC_FILE 0x1ee7ff00
81#define EET_MAGIC_FILE_HEADER 0x1ee7ff01
82
83#define EET_MAGIC_FILE2 0x1ee70f42
84
85#define EET_FILE2_HEADER_COUNT 3
86#define EET_FILE2_DIRECTORY_ENTRY_COUNT 6
87#define EET_FILE2_DICTIONARY_ENTRY_COUNT 5
88
89#define EET_FILE2_HEADER_SIZE (sizeof(int) * \
90 EET_FILE2_HEADER_COUNT)
91#define EET_FILE2_DIRECTORY_ENTRY_SIZE (sizeof(int) * \
92 EET_FILE2_DIRECTORY_ENTRY_COUNT)
93#define EET_FILE2_DICTIONARY_ENTRY_SIZE (sizeof(int) * \
94 EET_FILE2_DICTIONARY_ENTRY_COUNT)
95
96/* prototypes of internal calls */
97static Eet_File *
98eet_cache_find(const char *path,
99 Eet_File **cache,
100 int cache_num);
101static void
102eet_cache_add(Eet_File *ef,
103 Eet_File ***cache,
104 int *cache_num,
105 int *cache_alloc);
106static void
107eet_cache_del(Eet_File *ef,
108 Eet_File ***cache,
109 int *cache_num,
110 int *cache_alloc);
111static int
112eet_string_match(const char *s1,
113 const char *s2);
114#if 0 /* Unused */
115static Eet_Error
116eet_flush(Eet_File *ef);
117#endif /* if 0 */
118static Eet_Error
119 eet_flush2(Eet_File *ef);
120static Eet_File_Node *
121 find_node_by_name(Eet_File *ef,
122 const char *name);
123static int
124read_data_from_disk(Eet_File *ef,
125 Eet_File_Node *efn,
126 void *buf,
127 int len);
128
129static Eet_Error
130eet_internal_close(Eet_File *ef,
131 Eina_Bool locked);
132
133static Eina_Lock eet_cache_lock;
134
135#define LOCK_CACHE eina_lock_take(&eet_cache_lock)
136#define UNLOCK_CACHE eina_lock_release(&eet_cache_lock)
137
138#define INIT_FILE(File) eina_lock_new(&File->file_lock)
139#define LOCK_FILE(File) eina_lock_take(&File->file_lock)
140#define UNLOCK_FILE(File) eina_lock_release(&File->file_lock)
141#define DESTROY_FILE(File) eina_lock_free(&File->file_lock)
142
143/* cache. i don't expect this to ever be large, so arrays will do */
144static int eet_writers_num = 0;
145static int eet_writers_alloc = 0;
146static Eet_File **eet_writers = NULL;
147static int eet_readers_num = 0;
148static int eet_readers_alloc = 0;
149static Eet_File **eet_readers = NULL;
150static int eet_init_count = 0;
151
152/* log domain variable */
153int _eet_log_dom_global = -1;
154
155/* Check to see its' an eet file pointer */
156static inline int
157eet_check_pointer(const Eet_File *ef)
158{
159 if ((!ef) || (ef->magic != EET_MAGIC_FILE))
160 return 1;
161
162 return 0;
163}
164
165static inline int
166eet_check_header(const Eet_File *ef)
167{
168 if (!ef->header)
169 return 1;
170
171 if (!ef->header->directory)
172 return 1;
173
174 return 0;
175}
176
177static inline int
178eet_test_close(int test,
179 Eet_File *ef)
180{
181 if (test)
182 {
183 ef->delete_me_now = 1;
184 eet_internal_close(ef, EINA_TRUE);
185 }
186
187 return test;
188}
189
190/* find an eet file in the currently in use cache */
191static Eet_File *
192eet_cache_find(const char *path,
193 Eet_File **cache,
194 int cache_num)
195{
196 int i;
197
198 /* walk list */
199 for (i = 0; i < cache_num; i++)
200 {
201 /* if matches real path - return it */
202 if (eet_string_match(cache[i]->path, path))
203 if (!cache[i]->delete_me_now)
204 return cache[i];
205 }
206
207 /* not found */
208 return NULL;
209}
210
211/* add to end of cache */
212/* this should only be called when the cache lock is already held */
213static void
214eet_cache_add(Eet_File *ef,
215 Eet_File ***cache,
216 int *cache_num,
217 int *cache_alloc)
218{
219 Eet_File **new_cache;
220 int new_cache_num;
221 int new_cache_alloc;
222
223 new_cache_num = *cache_num;
224 if (new_cache_num >= 64) /* avoid fd overruns - limit to 128 (most recent) in the cache */
225 {
226 Eet_File *del_ef = NULL;
227 int i;
228
229 new_cache = *cache;
230 for (i = 0; i < new_cache_num; i++)
231 {
232 if (new_cache[i]->references == 0)
233 {
234 del_ef = new_cache[i];
235 break;
236 }
237 }
238
239 if (del_ef)
240 {
241 del_ef->delete_me_now = 1;
242 eet_internal_close(del_ef, EINA_TRUE);
243 }
244 }
245
246 new_cache = *cache;
247 new_cache_num = *cache_num;
248 new_cache_alloc = *cache_alloc;
249 new_cache_num++;
250 if (new_cache_num > new_cache_alloc)
251 {
252 new_cache_alloc += 16;
253 new_cache = realloc(new_cache, new_cache_alloc * sizeof(Eet_File *));
254 if (!new_cache)
255 {
256 CRIT("BAD ERROR! Eet realloc of cache list failed. Abort");
257 abort();
258 }
259 }
260
261 new_cache[new_cache_num - 1] = ef;
262 *cache = new_cache;
263 *cache_num = new_cache_num;
264 *cache_alloc = new_cache_alloc;
265}
266
267/* delete from cache */
268/* this should only be called when the cache lock is already held */
269static void
270eet_cache_del(Eet_File *ef,
271 Eet_File ***cache,
272 int *cache_num,
273 int *cache_alloc)
274{
275 Eet_File **new_cache;
276 int new_cache_num, new_cache_alloc;
277 int i, j;
278
279 new_cache = *cache;
280 new_cache_num = *cache_num;
281 new_cache_alloc = *cache_alloc;
282 if (new_cache_num <= 0)
283 return;
284
285 for (i = 0; i < new_cache_num; i++)
286 {
287 if (new_cache[i] == ef)
288 break;
289 }
290
291 if (i >= new_cache_num)
292 return;
293
294 new_cache_num--;
295 for (j = i; j < new_cache_num; j++)
296 new_cache[j] = new_cache[j + 1];
297
298 if (new_cache_num <= (new_cache_alloc - 16))
299 {
300 new_cache_alloc -= 16;
301 if (new_cache_num > 0)
302 {
303 new_cache = realloc(new_cache, new_cache_alloc * sizeof(Eet_File *));
304 if (!new_cache)
305 {
306 CRIT("BAD ERROR! Eet realloc of cache list failed. Abort");
307 abort();
308 }
309 }
310 else
311 {
312 free(new_cache);
313 new_cache = NULL;
314 }
315 }
316
317 *cache = new_cache;
318 *cache_num = new_cache_num;
319 *cache_alloc = new_cache_alloc;
320}
321
322/* internal string match. null friendly, catches same ptr */
323static int
324eet_string_match(const char *s1,
325 const char *s2)
326{
327 /* both null- no match */
328 if ((!s1) || (!s2))
329 return 0;
330
331 if (s1 == s2)
332 return 1;
333
334 return !strcmp(s1, s2);
335}
336
337/* flush out writes to a v2 eet file */
338static Eet_Error
339eet_flush2(Eet_File *ef)
340{
341 Eet_File_Node *efn;
342 FILE *fp;
343 Eet_Error error = EET_ERROR_NONE;
344 int head[EET_FILE2_HEADER_COUNT];
345 int num_directory_entries = 0;
346 int num_dictionary_entries = 0;
347 int bytes_directory_entries = 0;
348 int bytes_dictionary_entries = 0;
349 int bytes_strings = 0;
350 int data_offset = 0;
351 int strings_offset = 0;
352 int num;
353 int i;
354 int j;
355
356 if (eet_check_pointer(ef))
357 return EET_ERROR_BAD_OBJECT;
358
359 if (eet_check_header(ef))
360 return EET_ERROR_EMPTY;
361
362 if (!ef->writes_pending)
363 return EET_ERROR_NONE;
364
365 if ((ef->mode == EET_FILE_MODE_READ_WRITE)
366 || (ef->mode == EET_FILE_MODE_WRITE))
367 {
368 int fd;
369
370 /* opening for write - delete old copy of file right away */
371 unlink(ef->path);
372 fd = open(ef->path, O_CREAT | O_TRUNC | O_RDWR | O_BINARY, S_IRUSR | S_IWUSR);
373 fp = fdopen(fd, "wb");
374 if (!fp)
375 return EET_ERROR_NOT_WRITABLE;
376
377 fcntl(fd, F_SETFD, FD_CLOEXEC);
378 }
379 else
380 return EET_ERROR_NOT_WRITABLE;
381
382 /* calculate string base offset and data base offset */
383 num = (1 << ef->header->directory->size);
384 for (i = 0; i < num; ++i)
385 {
386 for (efn = ef->header->directory->nodes[i]; efn; efn = efn->next)
387 {
388 num_directory_entries++;
389 bytes_strings += strlen(efn->name) + 1;
390 }
391 }
392 if (ef->ed)
393 {
394 num_dictionary_entries = ef->ed->count;
395
396 for (i = 0; i < num_dictionary_entries; ++i)
397 bytes_strings += ef->ed->all[i].len;
398 }
399
400 /* calculate section bytes size */
401 bytes_directory_entries = EET_FILE2_DIRECTORY_ENTRY_SIZE *
402 num_directory_entries + EET_FILE2_HEADER_SIZE;
403 bytes_dictionary_entries = EET_FILE2_DICTIONARY_ENTRY_SIZE *
404 num_dictionary_entries;
405
406 /* calculate per entry offset */
407 strings_offset = bytes_directory_entries + bytes_dictionary_entries;
408 data_offset = bytes_directory_entries + bytes_dictionary_entries +
409 bytes_strings;
410
411 for (i = 0; i < num; ++i)
412 {
413 for (efn = ef->header->directory->nodes[i]; efn; efn = efn->next)
414 {
415 efn->offset = data_offset;
416 data_offset += efn->size;
417
418 efn->name_offset = strings_offset;
419 strings_offset += efn->name_size;
420 }
421 }
422
423 /* calculate dictionary strings offset */
424 if (ef->ed)
425 ef->ed->offset = strings_offset;
426
427 /* go thru and write the header */
428 head[0] = (int)htonl((unsigned int)EET_MAGIC_FILE2);
429 head[1] = (int)htonl((unsigned int)num_directory_entries);
430 head[2] = (int)htonl((unsigned int)num_dictionary_entries);
431
432 fseek(fp, 0, SEEK_SET);
433 if (fwrite(head, sizeof (head), 1, fp) != 1)
434 goto write_error;
435
436 /* write directories entry */
437 for (i = 0; i < num; i++)
438 {
439 for (efn = ef->header->directory->nodes[i]; efn; efn = efn->next)
440 {
441 unsigned int flag;
442 int ibuf[EET_FILE2_DIRECTORY_ENTRY_COUNT];
443
444 flag = (efn->alias << 2) | (efn->ciphered << 1) | efn->compression;
445
446 ibuf[0] = (int)htonl((unsigned int)efn->offset);
447 ibuf[1] = (int)htonl((unsigned int)efn->size);
448 ibuf[2] = (int)htonl((unsigned int)efn->data_size);
449 ibuf[3] = (int)htonl((unsigned int)efn->name_offset);
450 ibuf[4] = (int)htonl((unsigned int)efn->name_size);
451 ibuf[5] = (int)htonl((unsigned int)flag);
452
453 if (fwrite(ibuf, sizeof(ibuf), 1, fp) != 1)
454 goto write_error;
455 }
456 }
457
458 /* write dictionary */
459 if (ef->ed)
460 {
461 int offset = strings_offset;
462
463 for (j = 0; j < ef->ed->count; ++j)
464 {
465 int sbuf[EET_FILE2_DICTIONARY_ENTRY_COUNT];
466
467 sbuf[0] = (int)htonl((unsigned int)ef->ed->all[j].hash);
468 sbuf[1] = (int)htonl((unsigned int)offset);
469 sbuf[2] = (int)htonl((unsigned int)ef->ed->all[j].len);
470 sbuf[3] = (int)htonl((unsigned int)ef->ed->all[j].prev);
471 sbuf[4] = (int)htonl((unsigned int)ef->ed->all[j].next);
472
473 offset += ef->ed->all[j].len;
474
475 if (fwrite(sbuf, sizeof (sbuf), 1, fp) != 1)
476 goto write_error;
477 }
478 }
479
480 /* write directories name */
481 for (i = 0; i < num; i++)
482 {
483 for (efn = ef->header->directory->nodes[i]; efn; efn = efn->next)
484 {
485 if (fwrite(efn->name, efn->name_size, 1, fp) != 1)
486 goto write_error;
487 }
488 }
489
490 /* write strings */
491 if (ef->ed)
492 for (j = 0; j < ef->ed->count; ++j)
493 {
494 if (fwrite(ef->ed->all[j].str, ef->ed->all[j].len, 1, fp) != 1)
495 goto write_error;
496 }
497
498 /* write data */
499 for (i = 0; i < num; i++)
500 {
501 for (efn = ef->header->directory->nodes[i]; efn; efn = efn->next)
502 {
503 if (fwrite(efn->data, efn->size, 1, fp) != 1)
504 goto write_error;
505 }
506 }
507
508 /* flush all write to the file. */
509 fflush(fp);
510
511 /* append signature if required */
512 if (ef->key)
513 {
514 error = eet_identity_sign(fp, ef->key);
515 if (error != EET_ERROR_NONE)
516 goto sign_error;
517 }
518
519 /* no more writes pending */
520 ef->writes_pending = 0;
521
522 fclose(fp);
523
524 return EET_ERROR_NONE;
525
526write_error:
527 if (ferror(fp))
528 {
529 switch (errno)
530 {
531 case EFBIG: error = EET_ERROR_WRITE_ERROR_FILE_TOO_BIG; break;
532
533 case EIO: error = EET_ERROR_WRITE_ERROR_IO_ERROR; break;
534
535 case ENOSPC: error = EET_ERROR_WRITE_ERROR_OUT_OF_SPACE; break;
536
537 case EPIPE: error = EET_ERROR_WRITE_ERROR_FILE_CLOSED; break;
538
539 default: error = EET_ERROR_WRITE_ERROR; break;
540 }
541 }
542
543sign_error:
544 fclose(fp);
545 return error;
546}
547
548EAPI int
549eet_init(void)
550{
551 if (++eet_init_count != 1)
552 return eet_init_count;
553
554 if (!eina_init())
555 return --eet_init_count;
556
557 _eet_log_dom_global = eina_log_domain_register("eet", EET_DEFAULT_LOG_COLOR);
558 if (_eet_log_dom_global < 0)
559 {
560 EINA_LOG_ERR("Eet Can not create a general log domain.");
561 goto shutdown_eina;
562 }
563
564 eina_lock_new(&eet_cache_lock);
565
566 if (!eet_mempool_init())
567 {
568 EINA_LOG_ERR("Eet: Eet_Node mempool creation failed");
569 goto unregister_log_domain;
570 }
571
572 if (!eet_node_init())
573 {
574 EINA_LOG_ERR("Eet: Eet_Node mempool creation failed");
575 goto shutdown_mempool;
576 }
577
578#ifdef HAVE_GNUTLS
579 /* Before the library can be used, it must initialize itself if needed. */
580 if (gcry_control(GCRYCTL_ANY_INITIALIZATION_P) == 0)
581 {
582 gcry_check_version(NULL);
583 /* Disable warning messages about problems with the secure memory subsystem.
584 This command should be run right after gcry_check_version. */
585 if (gcry_control(GCRYCTL_DISABLE_SECMEM_WARN))
586 goto shutdown_eet; /* This command is used to allocate a pool of secure memory and thus
587 enabling the use of secure memory. It also drops all extra privileges the
588 process has (i.e. if it is run as setuid (root)). If the argument nbytes
589 is 0, secure memory will be disabled. The minimum amount of secure memory
590 allocated is currently 16384 bytes; you may thus use a value of 1 to
591 request that default size. */
592
593 if (gcry_control(GCRYCTL_INIT_SECMEM, 16384, 0))
594 WRN(
595 "BIG FAT WARNING: I AM UNABLE TO REQUEST SECMEM, Cryptographic operation are at risk !");
596 }
597
598# ifdef EINA_HAVE_THREADS
599 if (gcry_control(GCRYCTL_SET_THREAD_CBS, &gcry_threads_pthread))
600 WRN(
601 "YOU ARE USING PTHREADS, BUT I CANNOT INITIALIZE THREADSAFE GCRYPT OPERATIONS!");
602
603# endif /* ifdef EINA_HAVE_THREADS */
604 if (gnutls_global_init())
605 goto shutdown_eet;
606
607#endif /* ifdef HAVE_GNUTLS */
608#ifdef HAVE_OPENSSL
609 ERR_load_crypto_strings();
610 OpenSSL_add_all_algorithms();
611#endif /* ifdef HAVE_OPENSSL */
612
613 return eet_init_count;
614
615#ifdef HAVE_GNUTLS
616shutdown_eet:
617#endif
618 eet_node_shutdown();
619shutdown_mempool:
620 eet_mempool_shutdown();
621unregister_log_domain:
622 eina_log_domain_unregister(_eet_log_dom_global);
623 _eet_log_dom_global = -1;
624shutdown_eina:
625 eina_shutdown();
626 return --eet_init_count;
627}
628
629EAPI int
630eet_shutdown(void)
631{
632 if (--eet_init_count != 0)
633 return eet_init_count;
634
635 eet_clearcache();
636 eet_node_shutdown();
637 eet_mempool_shutdown();
638
639 eina_lock_free(&eet_cache_lock);
640
641#ifdef HAVE_GNUTLS
642 gnutls_global_deinit();
643#endif /* ifdef HAVE_GNUTLS */
644#ifdef HAVE_OPENSSL
645 EVP_cleanup();
646 ERR_free_strings();
647#endif /* ifdef HAVE_OPENSSL */
648 eina_log_domain_unregister(_eet_log_dom_global);
649 _eet_log_dom_global = -1;
650 eina_shutdown();
651
652 return eet_init_count;
653}
654
655EAPI Eet_Error
656eet_sync(Eet_File *ef)
657{
658 Eet_Error ret;
659
660 if (eet_check_pointer(ef))
661 return EET_ERROR_BAD_OBJECT;
662
663 if ((ef->mode != EET_FILE_MODE_WRITE) &&
664 (ef->mode != EET_FILE_MODE_READ_WRITE))
665 return EET_ERROR_NOT_WRITABLE;
666
667 if (!ef->writes_pending)
668 return EET_ERROR_NONE;
669
670 LOCK_FILE(ef);
671
672 ret = eet_flush2(ef);
673
674 UNLOCK_FILE(ef);
675 return ret;
676}
677
678EAPI void
679eet_clearcache(void)
680{
681 int num = 0;
682 int i;
683
684 /*
685 * We need to compute the list of eet file to close separately from the cache,
686 * due to eet_close removing them from the cache after each call.
687 */
688 LOCK_CACHE;
689 for (i = 0; i < eet_writers_num; i++)
690 {
691 if (eet_writers[i]->references <= 0)
692 num++;
693 }
694
695 for (i = 0; i < eet_readers_num; i++)
696 {
697 if (eet_readers[i]->references <= 0)
698 num++;
699 }
700
701 if (num > 0)
702 {
703 Eet_File **closelist = NULL;
704
705 closelist = alloca(num * sizeof(Eet_File *));
706 num = 0;
707 for (i = 0; i < eet_writers_num; i++)
708 {
709 if (eet_writers[i]->references <= 0)
710 {
711 closelist[num] = eet_writers[i];
712 eet_writers[i]->delete_me_now = 1;
713 num++;
714 }
715 }
716
717 for (i = 0; i < eet_readers_num; i++)
718 {
719 if (eet_readers[i]->references <= 0)
720 {
721 closelist[num] = eet_readers[i];
722 eet_readers[i]->delete_me_now = 1;
723 num++;
724 }
725 }
726
727 for (i = 0; i < num; i++)
728 {
729 eet_internal_close(closelist[i], EINA_TRUE);
730 }
731 }
732
733 UNLOCK_CACHE;
734}
735
736/* FIXME: MMAP race condition in READ_WRITE_MODE */
737static Eet_File *
738eet_internal_read2(Eet_File *ef)
739{
740 const int *data = (const int *)ef->data;
741 const char *start = (const char *)ef->data;
742 int idx = 0;
743 unsigned long int bytes_directory_entries;
744 unsigned long int bytes_dictionary_entries;
745 unsigned long int signature_base_offset;
746 unsigned long int num_directory_entries;
747 unsigned long int num_dictionary_entries;
748 unsigned int i;
749
750 idx += sizeof(int);
751 if (eet_test_close((int)ntohl(*data) != EET_MAGIC_FILE2, ef))
752 return NULL;
753
754 data++;
755
756#define GET_INT(Value, Pointer, Index) \
757 { \
758 Value = ntohl(*Pointer); \
759 Pointer++; \
760 Index += sizeof(int); \
761 }
762
763 /* get entries count and byte count */
764 GET_INT(num_directory_entries, data, idx);
765 /* get dictionary count and byte count */
766 GET_INT(num_dictionary_entries, data, idx);
767
768 bytes_directory_entries = EET_FILE2_DIRECTORY_ENTRY_SIZE *
769 num_directory_entries + EET_FILE2_HEADER_SIZE;
770 bytes_dictionary_entries = EET_FILE2_DICTIONARY_ENTRY_SIZE *
771 num_dictionary_entries;
772
773 /* we can't have > 0x7fffffff values here - invalid */
774 if (eet_test_close((num_directory_entries > 0x7fffffff), ef))
775 return NULL;
776
777 /* we can't have more bytes directory and bytes in dictionaries than the size of the file */
778 if (eet_test_close((bytes_directory_entries + bytes_dictionary_entries) >
779 ef->data_size, ef))
780 return NULL;
781
782 /* allocate header */
783 ef->header = eet_file_header_calloc(1);
784 if (eet_test_close(!ef->header, ef))
785 return NULL;
786
787 ef->header->magic = EET_MAGIC_FILE_HEADER;
788
789 /* allocate directory block in ram */
790 ef->header->directory = eet_file_directory_calloc(1);
791 if (eet_test_close(!ef->header->directory, ef))
792 return NULL;
793
794 /* 8 bit hash table (256 buckets) */
795 ef->header->directory->size = 8;
796 /* allocate base hash table */
797 ef->header->directory->nodes =
798 calloc(1, sizeof(Eet_File_Node *) * (1 << ef->header->directory->size));
799 if (eet_test_close(!ef->header->directory->nodes, ef))
800 return NULL;
801
802 signature_base_offset = 0;
803 if (num_directory_entries == 0)
804 {
805 signature_base_offset = ef->data_size;
806 }
807
808 /* actually read the directory block - all of it, into ram */
809 for (i = 0; i < num_directory_entries; ++i)
810 {
811 const char *name;
812 Eet_File_Node *efn;
813 unsigned long int name_offset;
814 unsigned long int name_size;
815 int hash;
816 int flag;
817
818 /* out directory block is inconsistent - we have overrun our */
819 /* dynamic block buffer before we finished scanning dir entries */
820 efn = eet_file_node_malloc(1);
821 if (eet_test_close(!efn, ef))
822 {
823 if (efn) eet_file_node_mp_free(efn); /* yes i know - we only get here if
824 * efn is null/0 -> trying to shut up
825 * warning tools like cppcheck */
826 return NULL;
827 }
828
829 /* get entrie header */
830 GET_INT(efn->offset, data, idx);
831 GET_INT(efn->size, data, idx);
832 GET_INT(efn->data_size, data, idx);
833 GET_INT(name_offset, data, idx);
834 GET_INT(name_size, data, idx);
835 GET_INT(flag, data, idx);
836
837 efn->compression = flag & 0x1 ? 1 : 0;
838 efn->ciphered = flag & 0x2 ? 1 : 0;
839 efn->alias = flag & 0x4 ? 1 : 0;
840
841#define EFN_TEST(Test, Ef, Efn) \
842 if (eet_test_close(Test, Ef)) \
843 { \
844 eet_file_node_mp_free(Efn); \
845 return NULL; \
846 }
847
848 /* check data pointer position */
849 EFN_TEST(!((efn->size > 0)
850 && (efn->offset + efn->size <= ef->data_size)
851 && (efn->offset > bytes_dictionary_entries +
852 bytes_directory_entries)), ef, efn);
853
854 /* check name position */
855 EFN_TEST(!((name_size > 0)
856 && (name_offset + name_size < ef->data_size)
857 && (name_offset >= bytes_dictionary_entries +
858 bytes_directory_entries)), ef, efn);
859
860 name = start + name_offset;
861
862 /* check '\0' at the end of name string */
863 EFN_TEST(name[name_size - 1] != '\0', ef, efn);
864
865 efn->free_name = 0;
866 efn->name = (char *)name;
867 efn->name_size = name_size;
868
869 hash = _eet_hash_gen(efn->name, ef->header->directory->size);
870 efn->next = ef->header->directory->nodes[hash];
871 ef->header->directory->nodes[hash] = efn;
872
873 /* read-only mode, so currently we have no data loaded */
874 if (ef->mode == EET_FILE_MODE_READ)
875 efn->data = NULL; /* read-write mode - read everything into ram */
876 else
877 {
878 efn->data = malloc(efn->size);
879 if (efn->data)
880 memcpy(efn->data, ef->data + efn->offset, efn->size);
881 }
882
883 /* compute the possible position of a signature */
884 if (signature_base_offset < efn->offset + efn->size)
885 signature_base_offset = efn->offset + efn->size;
886 }
887
888 ef->ed = NULL;
889
890 if (num_dictionary_entries)
891 {
892 const int *dico = (const int *)ef->data +
893 EET_FILE2_DIRECTORY_ENTRY_COUNT * num_directory_entries +
894 EET_FILE2_HEADER_COUNT;
895 int j;
896
897 if (eet_test_close((num_dictionary_entries *
898 (int)EET_FILE2_DICTIONARY_ENTRY_SIZE + idx) >
899 (bytes_dictionary_entries + bytes_directory_entries),
900 ef))
901 return NULL;
902
903 ef->ed = eet_dictionary_calloc(1);
904 if (eet_test_close(!ef->ed, ef))
905 return NULL;
906
907 ef->ed->all = calloc(1, num_dictionary_entries * sizeof(Eet_String));
908 if (eet_test_close(!ef->ed->all, ef))
909 return NULL;
910
911 ef->ed->count = num_dictionary_entries;
912 ef->ed->total = num_dictionary_entries;
913 ef->ed->start = start + bytes_dictionary_entries +
914 bytes_directory_entries;
915 ef->ed->end = ef->ed->start;
916
917 for (j = 0; j < ef->ed->count; ++j)
918 {
919 unsigned int offset;
920 int hash;
921
922 GET_INT(hash, dico, idx);
923 GET_INT(offset, dico, idx);
924 GET_INT(ef->ed->all[j].len, dico, idx);
925 GET_INT(ef->ed->all[j].prev, dico, idx);
926 GET_INT(ef->ed->all[j].next, dico, idx);
927
928 /* Hash value could be stored on 8bits data, but this will break alignment of all the others data.
929 So stick to int and check the value. */
930 if (eet_test_close(hash & 0xFFFFFF00, ef))
931 return NULL;
932
933 /* Check string position */
934 if (eet_test_close(!((ef->ed->all[j].len > 0)
935 && (offset >
936 (bytes_dictionary_entries +
937 bytes_directory_entries))
938 && (offset + ef->ed->all[j].len <
939 ef->data_size)), ef))
940 return NULL;
941
942 ef->ed->all[j].str = start + offset;
943
944 if (ef->ed->all[j].str + ef->ed->all[j].len > ef->ed->end)
945 ef->ed->end = ef->ed->all[j].str + ef->ed->all[j].len;
946
947 /* Check '\0' at the end of the string */
948 if (eet_test_close(ef->ed->all[j].str[ef->ed->all[j].len - 1] !=
949 '\0', ef))
950 return NULL;
951
952 ef->ed->all[j].hash = hash;
953 if (ef->ed->all[j].prev == -1)
954 ef->ed->hash[hash] = j;
955
956 /* compute the possible position of a signature */
957 if (signature_base_offset < offset + ef->ed->all[j].len)
958 signature_base_offset = offset + ef->ed->all[j].len;
959 }
960 }
961
962 /* Check if the file is signed */
963 ef->x509_der = NULL;
964 ef->x509_length = 0;
965 ef->signature = NULL;
966 ef->signature_length = 0;
967
968 if (signature_base_offset < ef->data_size)
969 {
970#ifdef HAVE_SIGNATURE
971 const unsigned char *buffer = ((const unsigned char *)ef->data) +
972 signature_base_offset;
973 ef->x509_der = eet_identity_check(ef->data,
974 signature_base_offset,
975 &ef->sha1,
976 &ef->sha1_length,
977 buffer,
978 ef->data_size - signature_base_offset,
979 &ef->signature,
980 &ef->signature_length,
981 &ef->x509_length);
982
983 if (eet_test_close(!ef->x509_der, ef))
984 return NULL;
985
986#else /* ifdef HAVE_SIGNATURE */
987 ERR(
988 "This file could be signed but you didn't compile the necessary code to check the signature.");
989#endif /* ifdef HAVE_SIGNATURE */
990 }
991
992 return ef;
993}
994
995#if EET_OLD_EET_FILE_FORMAT
996static Eet_File *
997eet_internal_read1(Eet_File *ef)
998{
999 const unsigned char *dyn_buf = NULL;
1000 const unsigned char *p = NULL;
1001 unsigned long int byte_entries;
1002 unsigned long int num_entries;
1003 unsigned int i;
1004 int idx = 0;
1005
1006 WRN(
1007 "EET file format of '%s' is deprecated. You should just open it one time with mode == EET_FILE_MODE_READ_WRITE to solve this issue.",
1008 ef->path);
1009
1010 /* build header table if read mode */
1011 /* geat header */
1012 idx += sizeof(int);
1013 if (eet_test_close((int)ntohl(*((int *)ef->data)) != EET_MAGIC_FILE, ef))
1014 return NULL;
1015
1016#define EXTRACT_INT(Value, Pointer, Index) \
1017 { \
1018 int tmp; \
1019 memcpy(&tmp, Pointer + Index, sizeof(int)); \
1020 Value = ntohl(tmp); \
1021 Index += sizeof(int); \
1022 }
1023
1024 /* get entries count and byte count */
1025 EXTRACT_INT(num_entries, ef->data, idx);
1026 EXTRACT_INT(byte_entries, ef->data, idx);
1027
1028 /* we can't have <= 0 values here - invalid */
1029 if (eet_test_close((num_entries > 0x7fffffff) ||
1030 (byte_entries > 0x7fffffff), ef))
1031 return NULL;
1032
1033 /* we can't have more entires than minimum bytes for those! invalid! */
1034 if (eet_test_close((num_entries * 20) > byte_entries, ef))
1035 return NULL;
1036
1037 /* check we will not outrun the file limit */
1038 if (eet_test_close(((byte_entries + (int)(sizeof(int) * 3)) >
1039 ef->data_size), ef))
1040 return NULL;
1041
1042 /* allocate header */
1043 ef->header = eet_file_header_calloc(1);
1044 if (eet_test_close(!ef->header, ef))
1045 return NULL;
1046
1047 ef->header->magic = EET_MAGIC_FILE_HEADER;
1048
1049 /* allocate directory block in ram */
1050 ef->header->directory = eet_file_directory_calloc(1);
1051 if (eet_test_close(!ef->header->directory, ef))
1052 return NULL;
1053
1054 /* 8 bit hash table (256 buckets) */
1055 ef->header->directory->size = 8;
1056 /* allocate base hash table */
1057 ef->header->directory->nodes =
1058 calloc(1, sizeof(Eet_File_Node *) * (1 << ef->header->directory->size));
1059 if (eet_test_close(!ef->header->directory->nodes, ef))
1060 return NULL;
1061
1062 /* actually read the directory block - all of it, into ram */
1063 dyn_buf = ef->data + idx;
1064
1065 /* parse directory block */
1066 p = dyn_buf;
1067
1068 for (i = 0; i < num_entries; i++)
1069 {
1070 Eet_File_Node *efn;
1071 void *data = NULL;
1072 int indexn = 0;
1073 int name_size;
1074 int hash;
1075 int k;
1076
1077#define HEADER_SIZE (sizeof(int) * 5)
1078
1079 /* out directory block is inconsistent - we have overrun our */
1080 /* dynamic block buffer before we finished scanning dir entries */
1081 if (eet_test_close(p + HEADER_SIZE >= (dyn_buf + byte_entries), ef))
1082 return NULL;
1083
1084 /* allocate all the ram needed for this stored node accounting */
1085 efn = eet_file_node_malloc(1);
1086 if (eet_test_close(!efn, ef))
1087 {
1088 if (efn) eet_file_node_mp_free(efn); /* yes i know - we only get here if
1089 * efn is null/0 -> trying to shut up
1090 * warning tools like cppcheck */
1091 return NULL;
1092 }
1093
1094 /* get entrie header */
1095 EXTRACT_INT(efn->offset, p, indexn);
1096 EXTRACT_INT(efn->compression, p, indexn);
1097 EXTRACT_INT(efn->size, p, indexn);
1098 EXTRACT_INT(efn->data_size, p, indexn);
1099 EXTRACT_INT(name_size, p, indexn);
1100
1101 efn->name_size = name_size;
1102 efn->ciphered = 0;
1103 efn->alias = 0;
1104
1105 /* invalid size */
1106 if (eet_test_close(efn->size <= 0, ef))
1107 {
1108 eet_file_node_mp_free(efn);
1109 return NULL;
1110 }
1111
1112 /* invalid name_size */
1113 if (eet_test_close(name_size <= 0, ef))
1114 {
1115 eet_file_node_mp_free(efn);
1116 return NULL;
1117 }
1118
1119 /* reading name would mean falling off end of dyn_buf - invalid */
1120 if (eet_test_close((p + 16 + name_size) > (dyn_buf + byte_entries), ef))
1121 {
1122 eet_file_node_mp_free(efn);
1123 return NULL;
1124 }
1125
1126 /* This code is useless if we dont want backward compatibility */
1127 for (k = name_size;
1128 k > 0 && ((unsigned char)*(p + HEADER_SIZE + k)) != 0; --k)
1129 ;
1130
1131 efn->free_name = ((unsigned char)*(p + HEADER_SIZE + k)) != 0;
1132
1133 if (efn->free_name)
1134 {
1135 efn->name = malloc(sizeof(char) * name_size + 1);
1136 if (eet_test_close(!efn->name, ef))
1137 {
1138 eet_file_node_mp_free(efn);
1139 return NULL;
1140 }
1141
1142 strncpy(efn->name, (char *)p + HEADER_SIZE, name_size);
1143 efn->name[name_size] = 0;
1144
1145 WRN(
1146 "File: %s is not up to date for key \"%s\" - needs rebuilding sometime",
1147 ef->path,
1148 efn->name);
1149 }
1150 else
1151 /* The only really useful peace of code for efn->name (no backward compatibility) */
1152 efn->name = (char *)((unsigned char *)(p + HEADER_SIZE));
1153
1154 /* get hash bucket it should go in */
1155 hash = _eet_hash_gen(efn->name, ef->header->directory->size);
1156 efn->next = ef->header->directory->nodes[hash];
1157 ef->header->directory->nodes[hash] = efn;
1158
1159 /* read-only mode, so currently we have no data loaded */
1160 if (ef->mode == EET_FILE_MODE_READ)
1161 efn->data = NULL; /* read-write mode - read everything into ram */
1162 else
1163 {
1164 data = malloc(efn->size);
1165 if (data)
1166 memcpy(data, ef->data + efn->offset, efn->size);
1167
1168 efn->data = data;
1169 }
1170
1171 /* advance */
1172 p += HEADER_SIZE + name_size;
1173 }
1174 return ef;
1175}
1176
1177#endif /* if EET_OLD_EET_FILE_FORMAT */
1178
1179/*
1180 * this should only be called when the cache lock is already held
1181 * (We could drop this restriction if we add a parameter to eet_test_close
1182 * that indicates if the lock is held or not. For now it is easiest
1183 * to just require that it is always held.)
1184 */
1185static Eet_File *
1186eet_internal_read(Eet_File *ef)
1187{
1188 const int *data = (const int *)ef->data;
1189
1190 if (eet_test_close((ef->data == (void *)-1) || (!ef->data), ef))
1191 return NULL;
1192
1193 if (eet_test_close(ef->data_size < (int)sizeof(int) * 3, ef))
1194 return NULL;
1195
1196 switch (ntohl(*data))
1197 {
1198#if EET_OLD_EET_FILE_FORMAT
1199 case EET_MAGIC_FILE:
1200 return eet_internal_read1(ef);
1201
1202#endif /* if EET_OLD_EET_FILE_FORMAT */
1203 case EET_MAGIC_FILE2:
1204 return eet_internal_read2(ef);
1205
1206 default:
1207 ef->delete_me_now = 1;
1208 eet_internal_close(ef, EINA_TRUE);
1209 break;
1210 }
1211
1212 return NULL;
1213}
1214
1215static Eet_Error
1216eet_internal_close(Eet_File *ef,
1217 Eina_Bool locked)
1218{
1219 Eet_Error err;
1220
1221 /* check to see its' an eet file pointer */
1222 if (eet_check_pointer(ef))
1223 return EET_ERROR_BAD_OBJECT;
1224
1225 if (!locked)
1226 LOCK_CACHE;
1227
1228 /* deref */
1229 ef->references--;
1230 /* if its still referenced - dont go any further */
1231 if (ef->references > 0)
1232 {
1233 /* flush any writes */
1234 if ((ef->mode == EET_FILE_MODE_WRITE) ||
1235 (ef->mode == EET_FILE_MODE_READ_WRITE))
1236 eet_sync(ef);
1237 goto on_error;
1238 }
1239
1240 err = eet_flush2(ef);
1241
1242 eet_identity_unref(ef->key);
1243 ef->key = NULL;
1244
1245 /* if not urgent to delete it - dont free it - leave it in cache */
1246 if ((!ef->delete_me_now) && (ef->mode == EET_FILE_MODE_READ))
1247 goto on_error;
1248
1249 /* remove from cache */
1250 if (ef->mode == EET_FILE_MODE_READ)
1251 eet_cache_del(ef, &eet_readers, &eet_readers_num, &eet_readers_alloc);
1252 else if ((ef->mode == EET_FILE_MODE_WRITE) ||
1253 (ef->mode == EET_FILE_MODE_READ_WRITE))
1254 eet_cache_del(ef, &eet_writers, &eet_writers_num, &eet_writers_alloc);
1255
1256 /* we can unlock the cache now */
1257 if (!locked)
1258 UNLOCK_CACHE;
1259
1260 DESTROY_FILE(ef);
1261
1262 /* free up data */
1263 if (ef->header)
1264 {
1265 if (ef->header->directory)
1266 {
1267 if (ef->header->directory->nodes)
1268 {
1269 int i, num;
1270
1271 num = (1 << ef->header->directory->size);
1272 for (i = 0; i < num; i++)
1273 {
1274 Eet_File_Node *efn;
1275
1276 while ((efn = ef->header->directory->nodes[i]))
1277 {
1278 if (efn->data)
1279 free(efn->data);
1280
1281 ef->header->directory->nodes[i] = efn->next;
1282
1283 if (efn->free_name)
1284 free(efn->name);
1285
1286 eet_file_node_mp_free(efn);
1287 }
1288 }
1289 free(ef->header->directory->nodes);
1290 }
1291
1292 eet_file_directory_mp_free(ef->header->directory);
1293 }
1294
1295 eet_file_header_mp_free(ef->header);
1296 }
1297
1298 eet_dictionary_free(ef->ed);
1299
1300 if (ef->sha1)
1301 free(ef->sha1);
1302
1303 if (ef->readfp)
1304 {
1305 if (ef->data)
1306 eina_file_map_free(ef->readfp, (void *)ef->data);
1307
1308 eina_file_close(ef->readfp);
1309 }
1310
1311 /* zero out ram for struct - caution tactic against stale memory use */
1312 memset(ef, 0, sizeof(Eet_File));
1313
1314 /* free it */
1315 eina_stringshare_del(ef->path);
1316 eet_file_mp_free(ef);
1317 return err;
1318
1319on_error:
1320 if (!locked)
1321 UNLOCK_CACHE;
1322
1323 return EET_ERROR_NONE;
1324}
1325
1326EAPI Eet_File *
1327eet_memopen_read(const void *data,
1328 size_t size)
1329{
1330 Eet_File *ef;
1331
1332 if (!data || size == 0)
1333 return NULL;
1334
1335 ef = eet_file_malloc(1);
1336 if (!ef)
1337 return NULL;
1338
1339 INIT_FILE(ef);
1340 ef->ed = NULL;
1341 ef->path = NULL;
1342 ef->key = NULL;
1343 ef->magic = EET_MAGIC_FILE;
1344 ef->references = 1;
1345 ef->mode = EET_FILE_MODE_READ;
1346 ef->header = NULL;
1347 ef->delete_me_now = 1;
1348 ef->readfp = NULL;
1349 ef->data = data;
1350 ef->data_size = size;
1351 ef->sha1 = NULL;
1352 ef->sha1_length = 0;
1353
1354 /* eet_internal_read expects the cache lock to be held when it is called */
1355 LOCK_CACHE;
1356 ef = eet_internal_read(ef);
1357 UNLOCK_CACHE;
1358 return ef;
1359}
1360
1361EAPI const char *
1362eet_file_get(Eet_File *ef)
1363{
1364 if (eet_check_pointer(ef)) return NULL;
1365 return ef->path;
1366}
1367
1368EAPI Eet_File *
1369eet_open(const char *file,
1370 Eet_File_Mode mode)
1371{
1372 Eina_File *fp;
1373 Eet_File *ef;
1374 int file_len;
1375 unsigned long int size;
1376
1377 if (!file)
1378 return NULL;
1379
1380 /* find the current file handle in cache*/
1381 ef = NULL;
1382 LOCK_CACHE;
1383 if (mode == EET_FILE_MODE_READ)
1384 {
1385 ef = eet_cache_find((char *)file, eet_writers, eet_writers_num);
1386 if (ef)
1387 {
1388 eet_sync(ef);
1389 ef->references++;
1390 ef->delete_me_now = 1;
1391 eet_internal_close(ef, EINA_TRUE);
1392 }
1393
1394 ef = eet_cache_find((char *)file, eet_readers, eet_readers_num);
1395 }
1396 else if ((mode == EET_FILE_MODE_WRITE) ||
1397 (mode == EET_FILE_MODE_READ_WRITE))
1398 {
1399 ef = eet_cache_find((char *)file, eet_readers, eet_readers_num);
1400 if (ef)
1401 {
1402 ef->delete_me_now = 1;
1403 ef->references++;
1404 eet_internal_close(ef, EINA_TRUE);
1405 }
1406
1407 ef = eet_cache_find((char *)file, eet_writers, eet_writers_num);
1408 }
1409
1410 /* try open the file based on mode */
1411 if ((mode == EET_FILE_MODE_READ) || (mode == EET_FILE_MODE_READ_WRITE))
1412 {
1413 /* Prevent garbage in futur comparison. */
1414 fp = eina_file_open(file, EINA_FALSE);
1415 if (!fp)
1416 goto open_error;
1417
1418 size = eina_file_size_get(fp);
1419
1420 if (size < ((int)sizeof(int) * 3))
1421 {
1422 eina_file_close(fp);
1423 fp = NULL;
1424
1425 size = 0;
1426
1427 goto open_error;
1428 }
1429
1430open_error:
1431 if (!fp && mode == EET_FILE_MODE_READ)
1432 goto on_error;
1433 }
1434 else
1435 {
1436 if (mode != EET_FILE_MODE_WRITE)
1437 return NULL;
1438
1439 size = 0;
1440
1441 fp = NULL;
1442 }
1443
1444 /* We found one */
1445 if (ef && ef->readfp != fp)
1446 {
1447 ef->delete_me_now = 1;
1448 ef->references++;
1449 eet_internal_close(ef, EINA_TRUE);
1450 ef = NULL;
1451 }
1452
1453 if (ef)
1454 {
1455 /* reference it up and return it */
1456 if (fp)
1457 eina_file_close(fp);
1458
1459 ef->references++;
1460 UNLOCK_CACHE;
1461 return ef;
1462 }
1463
1464 file_len = strlen(file) + 1;
1465
1466 /* Allocate struct for eet file and have it zero'd out */
1467 ef = eet_file_malloc(1);
1468 if (!ef)
1469 goto on_error;
1470
1471 /* fill some of the members */
1472 INIT_FILE(ef);
1473 ef->key = NULL;
1474 ef->readfp = fp;
1475 ef->path = eina_stringshare_add_length(file, file_len);
1476 ef->magic = EET_MAGIC_FILE;
1477 ef->references = 1;
1478 ef->mode = mode;
1479 ef->header = NULL;
1480 ef->writes_pending = 0;
1481 ef->delete_me_now = 0;
1482 ef->data = NULL;
1483 ef->data_size = 0;
1484 ef->sha1 = NULL;
1485 ef->sha1_length = 0;
1486
1487 ef->ed = (mode == EET_FILE_MODE_WRITE)
1488 || (!ef->readfp && mode == EET_FILE_MODE_READ_WRITE) ?
1489 eet_dictionary_add() : NULL;
1490
1491 if (!ef->readfp &&
1492 (mode == EET_FILE_MODE_READ_WRITE || mode == EET_FILE_MODE_WRITE))
1493 goto empty_file;
1494
1495 /* if we can't open - bail out */
1496 if (eet_test_close(!ef->readfp, ef))
1497 goto on_error;
1498
1499 /* if we opened for read or read-write */
1500 if ((mode == EET_FILE_MODE_READ) || (mode == EET_FILE_MODE_READ_WRITE))
1501 {
1502 ef->data_size = size;
1503 ef->data = eina_file_map_all(fp, EINA_FILE_SEQUENTIAL);
1504 if (eet_test_close((ef->data == NULL), ef))
1505 goto on_error;
1506
1507 ef = eet_internal_read(ef);
1508 if (!ef)
1509 goto on_error;
1510 }
1511
1512empty_file:
1513 /* add to cache */
1514 if (ef->references == 1)
1515 {
1516 if (ef->mode == EET_FILE_MODE_READ)
1517 eet_cache_add(ef, &eet_readers, &eet_readers_num, &eet_readers_alloc);
1518 else if ((ef->mode == EET_FILE_MODE_WRITE) ||
1519 (ef->mode == EET_FILE_MODE_READ_WRITE))
1520 eet_cache_add(ef, &eet_writers, &eet_writers_num, &eet_writers_alloc);
1521 }
1522
1523 UNLOCK_CACHE;
1524 return ef;
1525
1526on_error:
1527 UNLOCK_CACHE;
1528 return NULL;
1529}
1530
1531EAPI Eet_File_Mode
1532eet_mode_get(Eet_File *ef)
1533{
1534 /* check to see its' an eet file pointer */
1535 if ((!ef) || (ef->magic != EET_MAGIC_FILE))
1536 return EET_FILE_MODE_INVALID;
1537 else
1538 return ef->mode;
1539}
1540
1541EAPI const void *
1542eet_identity_x509(Eet_File *ef,
1543 int *der_length)
1544{
1545 if (!ef->x509_der)
1546 return NULL;
1547
1548 if (der_length)
1549 *der_length = ef->x509_length;
1550
1551 return ef->x509_der;
1552}
1553
1554EAPI const void *
1555eet_identity_signature(Eet_File *ef,
1556 int *signature_length)
1557{
1558 if (!ef->signature)
1559 return NULL;
1560
1561 if (signature_length)
1562 *signature_length = ef->signature_length;
1563
1564 return ef->signature;
1565}
1566
1567EAPI const void *
1568eet_identity_sha1(Eet_File *ef,
1569 int *sha1_length)
1570{
1571 if (!ef->sha1)
1572 ef->sha1 = eet_identity_compute_sha1(ef->data,
1573 ef->data_size,
1574 &ef->sha1_length);
1575
1576 if (sha1_length)
1577 *sha1_length = ef->sha1_length;
1578
1579 return ef->sha1;
1580}
1581
1582EAPI Eet_Error
1583eet_identity_set(Eet_File *ef,
1584 Eet_Key *key)
1585{
1586 Eet_Key *tmp;
1587
1588 if (!ef)
1589 return EET_ERROR_BAD_OBJECT;
1590
1591 tmp = ef->key;
1592 ef->key = key;
1593 eet_identity_ref(ef->key);
1594 eet_identity_unref(tmp);
1595
1596 /* flags that writes are pending */
1597 ef->writes_pending = 1;
1598
1599 return EET_ERROR_NONE;
1600}
1601
1602EAPI Eet_Error
1603eet_close(Eet_File *ef)
1604{
1605 return eet_internal_close(ef, EINA_FALSE);
1606}
1607
1608EAPI void *
1609eet_read_cipher(Eet_File *ef,
1610 const char *name,
1611 int *size_ret,
1612 const char *cipher_key)
1613{
1614 Eet_File_Node *efn;
1615 char *data = NULL;
1616 unsigned long int size = 0;
1617
1618 if (size_ret)
1619 *size_ret = 0;
1620
1621 /* check to see its' an eet file pointer */
1622 if (eet_check_pointer(ef))
1623 return NULL;
1624
1625 if (!name)
1626 return NULL;
1627
1628 if ((ef->mode != EET_FILE_MODE_READ) &&
1629 (ef->mode != EET_FILE_MODE_READ_WRITE))
1630 return NULL;
1631
1632 /* no header, return NULL */
1633 if (eet_check_header(ef))
1634 return NULL;
1635
1636 LOCK_FILE(ef);
1637
1638 /* hunt hash bucket */
1639 efn = find_node_by_name(ef, name);
1640 if (!efn)
1641 goto on_error;
1642
1643 /* get size (uncompressed, if compressed at all) */
1644 size = efn->data_size;
1645
1646 /* allocate data */
1647 data = malloc(size);
1648 if (!data)
1649 goto on_error;
1650
1651 /* uncompressed data */
1652 if (efn->compression == 0)
1653 {
1654 void *data_deciphered = NULL;
1655 unsigned int data_deciphered_sz = 0;
1656 /* if we already have the data in ram... copy that */
1657
1658 if (efn->ciphered && efn->size > size)
1659 {
1660 size = efn->size;
1661 data = realloc(data, efn->size);
1662 }
1663
1664 if (efn->data)
1665 memcpy(data, efn->data, size);
1666 else
1667 if (!read_data_from_disk(ef, efn, data, size))
1668 goto on_error;
1669
1670 if (efn->ciphered && cipher_key)
1671 {
1672 if (eet_decipher(data, efn->size, cipher_key, strlen(cipher_key),
1673 &data_deciphered, &data_deciphered_sz))
1674 {
1675 if (data_deciphered)
1676 free(data_deciphered);
1677
1678 goto on_error;
1679 }
1680
1681 free(data);
1682 data = data_deciphered;
1683 size = data_deciphered_sz;
1684 }
1685 }
1686 /* compressed data */
1687 else
1688 {
1689 void *tmp_data = NULL;
1690 void *data_deciphered = NULL;
1691 unsigned int data_deciphered_sz = 0;
1692 int free_tmp = 0;
1693 int compr_size = efn->size;
1694 uLongf dlen;
1695
1696 /* if we already have the data in ram... copy that */
1697 if (efn->data)
1698 tmp_data = efn->data;
1699 else
1700 {
1701 tmp_data = malloc(compr_size);
1702 if (!tmp_data)
1703 goto on_error;
1704
1705 free_tmp = 1;
1706
1707 if (!read_data_from_disk(ef, efn, tmp_data, compr_size))
1708 {
1709 free(tmp_data);
1710 goto on_error;
1711 }
1712 }
1713
1714 if (efn->ciphered && cipher_key)
1715 {
1716 if (eet_decipher(tmp_data, compr_size, cipher_key,
1717 strlen(cipher_key), &data_deciphered,
1718 &data_deciphered_sz))
1719 {
1720 if (free_tmp)
1721 free(tmp_data);
1722
1723 if (data_deciphered)
1724 free(data_deciphered);
1725
1726 goto on_error;
1727 }
1728
1729 if (free_tmp)
1730 free(tmp_data);
1731 free_tmp = 1;
1732 tmp_data = data_deciphered;
1733 compr_size = data_deciphered_sz;
1734 }
1735
1736 /* decompress it */
1737 dlen = size;
1738 if (uncompress((Bytef *)data, &dlen,
1739 tmp_data, (uLongf)compr_size))
1740 {
1741 if (free_tmp)
1742 free(tmp_data);
1743 goto on_error;
1744 }
1745
1746 if (free_tmp)
1747 free(tmp_data);
1748 }
1749
1750 UNLOCK_FILE(ef);
1751
1752 /* handle alias */
1753 if (efn->alias)
1754 {
1755 void *tmp;
1756
1757 if (data[size - 1] != '\0')
1758 goto on_error;
1759
1760 tmp = eet_read_cipher(ef, data, size_ret, cipher_key);
1761
1762 free(data);
1763
1764 data = tmp;
1765 }
1766 else
1767 /* fill in return values */
1768 if (size_ret)
1769 *size_ret = size;
1770
1771 return data;
1772
1773on_error:
1774 UNLOCK_FILE(ef);
1775 free(data);
1776 return NULL;
1777}
1778
1779EAPI void *
1780eet_read(Eet_File *ef,
1781 const char *name,
1782 int *size_ret)
1783{
1784 return eet_read_cipher(ef, name, size_ret, NULL);
1785}
1786
1787EAPI const void *
1788eet_read_direct(Eet_File *ef,
1789 const char *name,
1790 int *size_ret)
1791{
1792 Eet_File_Node *efn;
1793 const char *data = NULL;
1794 int size = 0;
1795
1796 if (size_ret)
1797 *size_ret = 0;
1798
1799 /* check to see its' an eet file pointer */
1800 if (eet_check_pointer(ef))
1801 return NULL;
1802
1803 if (!name)
1804 return NULL;
1805
1806 if ((ef->mode != EET_FILE_MODE_READ) &&
1807 (ef->mode != EET_FILE_MODE_READ_WRITE))
1808 return NULL;
1809
1810 /* no header, return NULL */
1811 if (eet_check_header(ef))
1812 return NULL;
1813
1814 LOCK_FILE(ef);
1815
1816 /* hunt hash bucket */
1817 efn = find_node_by_name(ef, name);
1818 if (!efn)
1819 goto on_error;
1820
1821 /* trick to detect data in memory instead of mmaped from disk */
1822 if (efn->offset > ef->data_size && !efn->data)
1823 goto on_error;
1824
1825 /* get size (uncompressed, if compressed at all) */
1826 size = efn->data_size;
1827
1828 if (efn->alias)
1829 {
1830 data = efn->data ? efn->data : ef->data + efn->offset;
1831
1832 /* handle alias case */
1833 if (efn->compression)
1834 {
1835 char *tmp;
1836 int compr_size = efn->size;
1837 uLongf dlen;
1838
1839 tmp = alloca(sizeof (compr_size));
1840 dlen = size;
1841
1842 if (uncompress((Bytef *)tmp, &dlen, (Bytef *)data,
1843 (uLongf)compr_size))
1844 goto on_error;
1845
1846 if (tmp[compr_size - 1] != '\0')
1847 goto on_error;
1848
1849 UNLOCK_FILE(ef);
1850
1851 return eet_read_direct(ef, tmp, size_ret);
1852 }
1853
1854 if (!data)
1855 goto on_error;
1856
1857 if (data[size - 1] != '\0')
1858 goto on_error;
1859
1860 UNLOCK_FILE(ef);
1861
1862 return eet_read_direct(ef, data, size_ret);
1863 }
1864 else
1865 /* uncompressed data */
1866 if (efn->compression == 0
1867 && efn->ciphered == 0)
1868 data = efn->data ? efn->data : ef->data + efn->offset; /* compressed data */
1869 else
1870 data = NULL;
1871
1872 /* fill in return values */
1873 if (size_ret)
1874 *size_ret = size;
1875
1876 UNLOCK_FILE(ef);
1877
1878 return data;
1879
1880on_error:
1881 UNLOCK_FILE(ef);
1882 return NULL;
1883}
1884
1885EAPI const char *
1886eet_alias_get(Eet_File *ef,
1887 const char *name)
1888{
1889 Eet_File_Node *efn;
1890 const char *data = NULL;
1891 int size = 0;
1892
1893 /* check to see its' an eet file pointer */
1894 if (eet_check_pointer(ef))
1895 return NULL;
1896
1897 if (!name)
1898 return NULL;
1899
1900 if ((ef->mode != EET_FILE_MODE_READ) &&
1901 (ef->mode != EET_FILE_MODE_READ_WRITE))
1902 return NULL;
1903
1904 /* no header, return NULL */
1905 if (eet_check_header(ef))
1906 return NULL;
1907
1908 LOCK_FILE(ef);
1909
1910 /* hunt hash bucket */
1911 efn = find_node_by_name(ef, name);
1912 if (!efn)
1913 goto on_error;
1914
1915 /* trick to detect data in memory instead of mmaped from disk */
1916 if (efn->offset > ef->data_size && !efn->data)
1917 goto on_error;
1918
1919 /* get size (uncompressed, if compressed at all) */
1920 size = efn->data_size;
1921
1922 if (!efn->alias) return NULL;
1923 data = efn->data ? efn->data : ef->data + efn->offset;
1924
1925 /* handle alias case */
1926 if (efn->compression)
1927 {
1928 char *tmp;
1929 int compr_size = efn->size;
1930 uLongf dlen;
1931
1932 tmp = alloca(sizeof (compr_size));
1933 dlen = size;
1934
1935 if (uncompress((Bytef *)tmp, &dlen, (Bytef *)data,
1936 (uLongf)compr_size))
1937 goto on_error;
1938
1939 if (tmp[compr_size - 1] != '\0')
1940 goto on_error;
1941
1942 UNLOCK_FILE(ef);
1943
1944 return eina_stringshare_add(tmp);
1945 }
1946
1947 if (!data)
1948 goto on_error;
1949
1950 if (data[size - 1] != '\0')
1951 goto on_error;
1952
1953 UNLOCK_FILE(ef);
1954
1955 return eina_stringshare_add(data);
1956
1957on_error:
1958 UNLOCK_FILE(ef);
1959 return NULL;
1960}
1961
1962EAPI Eina_Bool
1963eet_alias(Eet_File *ef,
1964 const char *name,
1965 const char *destination,
1966 int comp)
1967{
1968 Eet_File_Node *efn;
1969 void *data2;
1970 Eina_Bool exists_already = EINA_FALSE;
1971 int data_size;
1972 int hash;
1973
1974 /* check to see its' an eet file pointer */
1975 if (eet_check_pointer(ef))
1976 return EINA_FALSE;
1977
1978 if ((!name) || (!destination))
1979 return EINA_FALSE;
1980
1981 if ((ef->mode != EET_FILE_MODE_WRITE) &&
1982 (ef->mode != EET_FILE_MODE_READ_WRITE))
1983 return EINA_FALSE;
1984
1985 LOCK_FILE(ef);
1986
1987 if (!ef->header)
1988 {
1989 /* allocate header */
1990 ef->header = eet_file_header_calloc(1);
1991 if (!ef->header)
1992 goto on_error;
1993
1994 ef->header->magic = EET_MAGIC_FILE_HEADER;
1995 /* allocate directory block in ram */
1996 ef->header->directory = eet_file_directory_calloc(1);
1997 if (!ef->header->directory)
1998 {
1999 eet_file_header_mp_free(ef->header);
2000 ef->header = NULL;
2001 goto on_error;
2002 }
2003
2004 /* 8 bit hash table (256 buckets) */
2005 ef->header->directory->size = 8;
2006 /* allocate base hash table */
2007 ef->header->directory->nodes =
2008 calloc(1, sizeof(Eet_File_Node *) *
2009 (1 << ef->header->directory->size));
2010 if (!ef->header->directory->nodes)
2011 {
2012 eet_file_directory_mp_free(ef->header->directory);
2013 ef->header = NULL;
2014 goto on_error;
2015 }
2016 }
2017
2018 /* figure hash bucket */
2019 hash = _eet_hash_gen(name, ef->header->directory->size);
2020
2021 data_size = comp ?
2022 12 + (((strlen(destination) + 1) * 101) / 100)
2023 : strlen(destination) + 1;
2024
2025 data2 = malloc(data_size);
2026 if (!data2)
2027 goto on_error;
2028
2029 /* if we want to compress */
2030 if (comp)
2031 {
2032 uLongf buflen;
2033
2034 /* compress the data with max compression */
2035 buflen = (uLongf)data_size;
2036 if (compress2((Bytef *)data2, &buflen, (Bytef *)destination,
2037 (uLong)strlen(destination) + 1,
2038 Z_BEST_COMPRESSION) != Z_OK)
2039 {
2040 free(data2);
2041 goto on_error;
2042 }
2043
2044 /* record compressed chunk size */
2045 data_size = (int)buflen;
2046 if (data_size < 0 || data_size >= (int)(strlen(destination) + 1))
2047 {
2048 comp = 0;
2049 data_size = strlen(destination) + 1;
2050 }
2051 else
2052 {
2053 void *data3;
2054
2055 data3 = realloc(data2, data_size);
2056 if (data3)
2057 data2 = data3;
2058 }
2059 }
2060
2061 if (!comp)
2062 memcpy(data2, destination, data_size);
2063
2064 /* Does this node already exist? */
2065 for (efn = ef->header->directory->nodes[hash]; efn; efn = efn->next)
2066 {
2067 /* if it matches */
2068 if ((efn->name) && (eet_string_match(efn->name, name)))
2069 {
2070 free(efn->data);
2071 efn->alias = 1;
2072 efn->ciphered = 0;
2073 efn->compression = !!comp;
2074 efn->size = data_size;
2075 efn->data_size = strlen(destination) + 1;
2076 efn->data = data2;
2077 /* Put the offset above the limit to avoid direct access */
2078 efn->offset = ef->data_size + 1;
2079 exists_already = EINA_TRUE;
2080
2081 break;
2082 }
2083 }
2084 if (!exists_already)
2085 {
2086 efn = eet_file_node_malloc(1);
2087 if (!efn)
2088 {
2089 free(data2);
2090 goto on_error;
2091 }
2092
2093 efn->name = strdup(name);
2094 efn->name_size = strlen(efn->name) + 1;
2095 efn->free_name = 1;
2096
2097 efn->next = ef->header->directory->nodes[hash];
2098 ef->header->directory->nodes[hash] = efn;
2099 /* Put the offset above the limit to avoid direct access */
2100 efn->offset = ef->data_size + 1;
2101 efn->alias = 1;
2102 efn->ciphered = 0;
2103 efn->compression = !!comp;
2104 efn->size = data_size;
2105 efn->data_size = strlen(destination) + 1;
2106 efn->data = data2;
2107 }
2108
2109 /* flags that writes are pending */
2110 ef->writes_pending = 1;
2111
2112 UNLOCK_FILE(ef);
2113 return EINA_TRUE;
2114
2115on_error:
2116 UNLOCK_FILE(ef);
2117 return EINA_FALSE;
2118}
2119
2120EAPI int
2121eet_write_cipher(Eet_File *ef,
2122 const char *name,
2123 const void *data,
2124 int size,
2125 int comp,
2126 const char *cipher_key)
2127{
2128 Eet_File_Node *efn;
2129 void *data2 = NULL;
2130 int exists_already = 0;
2131 int data_size;
2132 int hash;
2133
2134 /* check to see its' an eet file pointer */
2135 if (eet_check_pointer(ef))
2136 return 0;
2137
2138 if ((!name) || (!data) || (size <= 0))
2139 return 0;
2140
2141 if ((ef->mode != EET_FILE_MODE_WRITE) &&
2142 (ef->mode != EET_FILE_MODE_READ_WRITE))
2143 return 0;
2144
2145 LOCK_FILE(ef);
2146
2147 if (!ef->header)
2148 {
2149 /* allocate header */
2150 ef->header = eet_file_header_calloc(1);
2151 if (!ef->header)
2152 goto on_error;
2153
2154 ef->header->magic = EET_MAGIC_FILE_HEADER;
2155 /* allocate directory block in ram */
2156 ef->header->directory = eet_file_directory_calloc(1);
2157 if (!ef->header->directory)
2158 {
2159 eet_file_header_mp_free(ef->header);
2160 ef->header = NULL;
2161 goto on_error;
2162 }
2163
2164 /* 8 bit hash table (256 buckets) */
2165 ef->header->directory->size = 8;
2166 /* allocate base hash table */
2167 ef->header->directory->nodes =
2168 calloc(1, sizeof(Eet_File_Node *) *
2169 (1 << ef->header->directory->size));
2170 if (!ef->header->directory->nodes)
2171 {
2172 eet_file_directory_mp_free(ef->header->directory);
2173 ef->header = NULL;
2174 goto on_error;
2175 }
2176 }
2177
2178 /* figure hash bucket */
2179 hash = _eet_hash_gen(name, ef->header->directory->size);
2180
2181 data_size = comp ? 12 + ((size * 101) / 100) : size;
2182
2183 if (comp || !cipher_key)
2184 {
2185 data2 = malloc(data_size);
2186 if (!data2)
2187 goto on_error;
2188 }
2189
2190 /* if we want to compress */
2191 if (comp)
2192 {
2193 uLongf buflen;
2194
2195 /* compress the data with max compression */
2196 buflen = (uLongf)data_size;
2197 if (compress2((Bytef *)data2, &buflen, (Bytef *)data,
2198 (uLong)size, Z_BEST_COMPRESSION) != Z_OK)
2199 {
2200 free(data2);
2201 goto on_error;
2202 }
2203
2204 /* record compressed chunk size */
2205 data_size = (int)buflen;
2206 if (data_size < 0 || data_size >= size)
2207 {
2208 comp = 0;
2209 data_size = size;
2210 }
2211 else
2212 {
2213 void *data3;
2214
2215 data3 = realloc(data2, data_size);
2216 if (data3)
2217 data2 = data3;
2218 }
2219 }
2220
2221 if (cipher_key)
2222 {
2223 void *data_ciphered = NULL;
2224 unsigned int data_ciphered_sz = 0;
2225 const void *tmp;
2226
2227 tmp = comp ? data2 : data;
2228 if (!eet_cipher(tmp, data_size, cipher_key, strlen(cipher_key),
2229 &data_ciphered, &data_ciphered_sz))
2230 {
2231 if (data2)
2232 free(data2);
2233
2234 data2 = data_ciphered;
2235 data_size = data_ciphered_sz;
2236 }
2237 else
2238 {
2239 if (data_ciphered)
2240 free(data_ciphered);
2241
2242 cipher_key = NULL;
2243 }
2244 }
2245 else
2246 if (!comp)
2247 memcpy(data2, data, size);
2248
2249 /* Does this node already exist? */
2250 for (efn = ef->header->directory->nodes[hash]; efn; efn = efn->next)
2251 {
2252 /* if it matches */
2253 if ((efn->name) && (eet_string_match(efn->name, name)))
2254 {
2255 free(efn->data);
2256 efn->alias = 0;
2257 efn->ciphered = cipher_key ? 1 : 0;
2258 efn->compression = !!comp;
2259 efn->size = data_size;
2260 efn->data_size = size;
2261 efn->data = data2;
2262 /* Put the offset above the limit to avoid direct access */
2263 efn->offset = ef->data_size + 1;
2264 exists_already = 1;
2265 break;
2266 }
2267 }
2268 if (!exists_already)
2269 {
2270 efn = eet_file_node_malloc(1);
2271 if (!efn)
2272 {
2273 free(data2);
2274 goto on_error;
2275 }
2276
2277 efn->name = strdup(name);
2278 efn->name_size = strlen(efn->name) + 1;
2279 efn->free_name = 1;
2280
2281 efn->next = ef->header->directory->nodes[hash];
2282 ef->header->directory->nodes[hash] = efn;
2283 /* Put the offset above the limit to avoid direct access */
2284 efn->offset = ef->data_size + 1;
2285 efn->alias = 0;
2286 efn->ciphered = cipher_key ? 1 : 0;
2287 efn->compression = !!comp;
2288 efn->size = data_size;
2289 efn->data_size = size;
2290 efn->data = data2;
2291 }
2292
2293 /* flags that writes are pending */
2294 ef->writes_pending = 1;
2295 UNLOCK_FILE(ef);
2296 return data_size;
2297
2298on_error:
2299 UNLOCK_FILE(ef);
2300 return 0;
2301}
2302
2303EAPI int
2304eet_write(Eet_File *ef,
2305 const char *name,
2306 const void *data,
2307 int size,
2308 int comp)
2309{
2310 return eet_write_cipher(ef, name, data, size, comp, NULL);
2311}
2312
2313EAPI int
2314eet_delete(Eet_File *ef,
2315 const char *name)
2316{
2317 Eet_File_Node *efn;
2318 Eet_File_Node *pefn;
2319 int hash;
2320 int exists_already = 0;
2321
2322 /* check to see its' an eet file pointer */
2323 if (eet_check_pointer(ef))
2324 return 0;
2325
2326 if (!name)
2327 return 0;
2328
2329 /* deleting keys is only possible in RW or WRITE mode */
2330 if (ef->mode == EET_FILE_MODE_READ)
2331 return 0;
2332
2333 if (eet_check_header(ef))
2334 return 0;
2335
2336 LOCK_FILE(ef);
2337
2338 /* figure hash bucket */
2339 hash = _eet_hash_gen(name, ef->header->directory->size);
2340
2341 /* Does this node already exist? */
2342 for (pefn = NULL, efn = ef->header->directory->nodes[hash];
2343 efn;
2344 pefn = efn, efn = efn->next)
2345 {
2346 /* if it matches */
2347 if (eet_string_match(efn->name, name))
2348 {
2349 if (efn->data)
2350 free(efn->data);
2351
2352 if (!pefn)
2353 ef->header->directory->nodes[hash] = efn->next;
2354 else
2355 pefn->next = efn->next;
2356
2357 if (efn->free_name)
2358 free(efn->name);
2359
2360 eet_file_node_mp_free(efn);
2361 exists_already = 1;
2362 break;
2363 }
2364 }
2365 /* flags that writes are pending */
2366 if (exists_already)
2367 ef->writes_pending = 1;
2368
2369 UNLOCK_FILE(ef);
2370
2371 /* update access time */
2372 return exists_already;
2373}
2374
2375EAPI Eet_Dictionary *
2376eet_dictionary_get(Eet_File *ef)
2377{
2378 if (eet_check_pointer(ef))
2379 return NULL;
2380
2381 return ef->ed;
2382}
2383
2384EAPI char **
2385eet_list(Eet_File *ef,
2386 const char *glob,
2387 int *count_ret)
2388{
2389 Eet_File_Node *efn;
2390 char **list_ret = NULL;
2391 int list_count = 0;
2392 int list_count_alloc = 0;
2393 int i, num;
2394
2395 /* check to see its' an eet file pointer */
2396 if (eet_check_pointer(ef) || eet_check_header(ef) ||
2397 (!glob) ||
2398 ((ef->mode != EET_FILE_MODE_READ) &&
2399 (ef->mode != EET_FILE_MODE_READ_WRITE)))
2400 {
2401 if (count_ret)
2402 *count_ret = 0;
2403
2404 return NULL;
2405 }
2406
2407 if (!strcmp(glob, "*"))
2408 glob = NULL;
2409
2410 LOCK_FILE(ef);
2411
2412 /* loop through all entries */
2413 num = (1 << ef->header->directory->size);
2414 for (i = 0; i < num; i++)
2415 {
2416 for (efn = ef->header->directory->nodes[i]; efn; efn = efn->next)
2417 {
2418 /* if the entry matches the input glob
2419 * check for * explicitly, because on some systems, * isn't well
2420 * supported
2421 */
2422 if ((!glob) || !fnmatch(glob, efn->name, 0))
2423 {
2424 /* add it to our list */
2425 list_count++;
2426
2427 /* only realloc in 32 entry chunks */
2428 if (list_count > list_count_alloc)
2429 {
2430 char **new_list = NULL;
2431
2432 list_count_alloc += 64;
2433 new_list =
2434 realloc(list_ret, list_count_alloc * (sizeof(char *)));
2435 if (!new_list)
2436 {
2437 free(list_ret);
2438
2439 goto on_error;
2440 }
2441
2442 list_ret = new_list;
2443 }
2444
2445 /* put pointer of name string in */
2446 list_ret[list_count - 1] = efn->name;
2447 }
2448 }
2449 }
2450
2451 UNLOCK_FILE(ef);
2452
2453 /* return count and list */
2454 if (count_ret)
2455 *count_ret = list_count;
2456
2457 return list_ret;
2458
2459on_error:
2460 UNLOCK_FILE(ef);
2461
2462 if (count_ret)
2463 *count_ret = 0;
2464
2465 return NULL;
2466}
2467
2468EAPI int
2469eet_num_entries(Eet_File *ef)
2470{
2471 int i, num, ret = 0;
2472 Eet_File_Node *efn;
2473
2474 /* check to see its' an eet file pointer */
2475 if (eet_check_pointer(ef) || eet_check_header(ef) ||
2476 ((ef->mode != EET_FILE_MODE_READ) &&
2477 (ef->mode != EET_FILE_MODE_READ_WRITE)))
2478 return -1;
2479
2480 LOCK_FILE(ef);
2481
2482 /* loop through all entries */
2483 num = (1 << ef->header->directory->size);
2484 for (i = 0; i < num; i++)
2485 {
2486 for (efn = ef->header->directory->nodes[i]; efn; efn = efn->next)
2487 ret++;
2488 }
2489
2490 UNLOCK_FILE(ef);
2491
2492 return ret;
2493}
2494
2495static Eet_File_Node *
2496find_node_by_name(Eet_File *ef,
2497 const char *name)
2498{
2499 Eet_File_Node *efn;
2500 int hash;
2501
2502 /* get hash bucket this should be in */
2503 hash = _eet_hash_gen(name, ef->header->directory->size);
2504
2505 for (efn = ef->header->directory->nodes[hash]; efn; efn = efn->next)
2506 {
2507 if (eet_string_match(efn->name, name))
2508 return efn;
2509 }
2510
2511 return NULL;
2512}
2513
2514static int
2515read_data_from_disk(Eet_File *ef,
2516 Eet_File_Node *efn,
2517 void *buf,
2518 int len)
2519{
2520 if (efn->offset > ef->data_size)
2521 return 0;
2522
2523 if (!ef->data)
2524 return 0;
2525
2526 if ((efn->offset + len) > ef->data_size)
2527 return 0;
2528
2529 memcpy(buf, ef->data + efn->offset, len);
2530
2531 return len;
2532}
2533
diff --git a/libraries/eet/src/lib/eet_node.c b/libraries/eet/src/lib/eet_node.c
deleted file mode 100644
index 11d7cc0..0000000
--- a/libraries/eet/src/lib/eet_node.c
+++ /dev/null
@@ -1,797 +0,0 @@
1#ifdef HAVE_CONFIG_H
2# include <config.h>
3#endif /* ifdef HAVE_CONFIG_H */
4
5#include <string.h>
6#include <stdio.h>
7
8#ifdef HAVE_EVIL
9# include <Evil.h>
10#endif /* ifdef HAVE_EVIL */
11
12#include <Eina.h>
13
14#include "Eet.h"
15#include "Eet_private.h"
16
17static Eina_Mempool *_eet_node_mp = NULL;
18
19Eet_Node *
20eet_node_new(void)
21{
22 Eet_Node *result;
23
24 result = eina_mempool_malloc(_eet_node_mp, sizeof (Eet_Node));
25 if (!result)
26 return NULL;
27
28 memset(result, 0, sizeof (Eet_Node));
29 return result;
30}
31
32void
33eet_node_free(Eet_Node *node)
34{
35 eina_mempool_free(_eet_node_mp, node);
36}
37
38static Eet_Node *
39_eet_node_new(const char *name,
40 int type)
41{
42 Eet_Node *n;
43
44 n = eet_node_new();
45 if (!n)
46 return NULL;
47
48 n->type = type;
49 n->name = eina_stringshare_add(name);
50
51 return n;
52}
53
54static void
55_eet_node_append(Eet_Node *n,
56 Eina_List *nodes)
57{
58 Eet_Node *value;
59 Eina_List *l;
60
61 EINA_LIST_REVERSE_FOREACH(nodes, l, value)
62 {
63 value->next = n->values;
64 n->values = value;
65 }
66}
67
68#define EET_NODE_NEW(Eet_type, Name, Value, Type) \
69 EAPI Eet_Node * \
70 eet_node_ ## Name ## _new(const char *name, Type Value) \
71 { \
72 Eet_Node *n; \
73 \
74 n = _eet_node_new(name, Eet_type); \
75 if (!n) { return NULL; } \
76 \
77 n->data.value.Value = Value; \
78 \
79 return n; \
80 }
81
82#define EET_NODE_STR_NEW(Eet_type, Name, Value, Type) \
83 EAPI Eet_Node * \
84 eet_node_ ## Name ## _new(const char *name, Type Value) \
85 { \
86 Eet_Node *n; \
87 \
88 n = _eet_node_new(name, Eet_type); \
89 if (!n) { return NULL; } \
90 \
91 n->data.value.Value = eina_stringshare_add(Value); \
92 \
93 return n; \
94 }
95
96EET_NODE_NEW(EET_T_CHAR, char, c, char)
97EET_NODE_NEW(EET_T_SHORT, short, s, short)
98EET_NODE_NEW(EET_T_INT, int, i, int)
99EET_NODE_NEW(EET_T_LONG_LONG, long_long, l, long long)
100EET_NODE_NEW(EET_T_FLOAT, float, f, float)
101EET_NODE_NEW(EET_T_DOUBLE, double, d, double)
102EET_NODE_NEW(EET_T_UCHAR, unsigned_char, uc, unsigned char)
103EET_NODE_NEW(EET_T_USHORT, unsigned_short, us, unsigned short)
104EET_NODE_NEW(EET_T_UINT, unsigned_int, ui, unsigned int)
105EET_NODE_NEW(EET_T_ULONG_LONG, unsigned_long_long, ul, unsigned long long)
106EET_NODE_STR_NEW(EET_T_STRING, string, str, const char *)
107EET_NODE_STR_NEW(EET_T_INLINED_STRING, inlined_string, str, const char *)
108
109Eet_Node *
110eet_node_null_new(const char *name)
111{
112 Eet_Node *n;
113
114 n = _eet_node_new(name, EET_T_NULL);
115 if (!n)
116 return NULL;
117
118 n->data.value.str = NULL;
119
120 return n;
121}
122
123Eet_Node *
124eet_node_list_new(const char *name,
125 Eina_List *nodes)
126{
127 Eet_Node *n;
128
129 n = _eet_node_new(name, EET_G_LIST);
130 if (!n)
131 return NULL;
132
133 _eet_node_append(n, nodes);
134
135 return n;
136}
137
138Eet_Node *
139eet_node_array_new(const char *name,
140 int count,
141 Eina_List *nodes)
142{
143 Eet_Node *n;
144
145 n = _eet_node_new(name, EET_G_ARRAY);
146 if (!n)
147 return NULL;
148
149 n->count = count;
150
151 _eet_node_append(n, nodes);
152
153 return n;
154}
155
156Eet_Node *
157eet_node_var_array_new(const char *name,
158 Eina_List *nodes)
159{
160 Eet_Node *n;
161
162 n = _eet_node_new(name, EET_G_VAR_ARRAY);
163 if (!n)
164 return NULL;
165
166 n->count = eina_list_count(nodes);
167
168 _eet_node_append(n, nodes);
169
170 return n;
171}
172
173Eet_Node *
174eet_node_hash_new(const char *name,
175 const char *key,
176 Eet_Node *node)
177{
178 Eina_List *nodes;
179 Eet_Node *n;
180
181 if (!node)
182 return NULL;
183
184 n = _eet_node_new(name, EET_G_HASH);
185 if (!n)
186 return NULL;
187
188 n->key = eina_stringshare_add(key);
189 nodes = eina_list_append(NULL, node);
190
191 _eet_node_append(n, nodes);
192
193 return n;
194}
195
196Eet_Node *
197eet_node_struct_new(const char *name,
198 Eina_List *nodes)
199{
200 Eet_Node *n;
201
202 n = _eet_node_new(name, EET_G_UNKNOWN);
203 if (!n)
204 return NULL;
205
206 _eet_node_append(n, nodes);
207
208 return n;
209}
210
211Eet_Node *
212eet_node_struct_child_new(const char *parent,
213 Eet_Node *child)
214{
215 Eet_Node *n;
216
217 if (!child) return NULL;
218
219 if (child->type != EET_G_UNKNOWN)
220 return child;
221
222 n = _eet_node_new(parent, EET_G_UNKNOWN);
223 if (!n)
224 return NULL;
225
226 _eet_node_append(n, eina_list_prepend(NULL, child));
227
228 return n;
229}
230
231Eet_Node *
232eet_node_children_get(Eet_Node *node)
233{
234 if (!node) return NULL;
235 return node->values;
236}
237
238Eet_Node *
239eet_node_next_get(Eet_Node *node)
240{
241 if (!node) return NULL;
242 return node->next;
243}
244
245Eet_Node *
246eet_node_parent_get(Eet_Node *node)
247{
248 if (!node) return NULL;
249 return node->parent;
250}
251
252void
253eet_node_list_append(Eet_Node *parent,
254 const char *name,
255 Eet_Node *child)
256{
257 const char *tmp;
258 Eet_Node *nn;
259
260 if ((!parent) || (!child)) return;
261 tmp = eina_stringshare_add(name);
262
263 for (nn = parent->values; nn; nn = nn->next)
264 if (nn->name == tmp && nn->type == EET_G_LIST)
265 {
266 Eet_Node *n;
267
268 if (!nn->values)
269 nn->values = child;
270 else
271 {
272 for (n = nn->values; n->next; n = n->next)
273 ;
274 n->next = child;
275 }
276
277 child->next = NULL;
278
279 eina_stringshare_del(tmp);
280
281 return;
282 }
283
284 /* No list found, so create it. */
285 nn = eet_node_list_new(tmp, eina_list_append(NULL, child));
286
287 /* And add it to the parent. */
288 nn->next = parent->values;
289 parent->values = nn;
290
291 eina_stringshare_del(tmp);
292}
293
294void
295eet_node_struct_append(Eet_Node *parent,
296 const char *name,
297 Eet_Node *child)
298{
299 const char *tmp;
300 Eet_Node *prev;
301 Eet_Node *nn;
302
303 if ((!parent) || (!child)) return;
304 if (parent->type != EET_G_UNKNOWN)
305 {
306 ERR("[%s] is not a structure. Will not insert [%s] in it",
307 parent->name,
308 name);
309 eet_node_del(child);
310 return;
311 }
312
313 tmp = eina_stringshare_add(name);
314
315 for (prev = NULL, nn = parent->values; nn; prev = nn, nn = nn->next)
316 if (nn->name == tmp && nn->type == child->type)
317 {
318 if (prev)
319 prev->next = nn->next;
320 else
321 parent->values = nn->next;
322
323 nn->next = NULL;
324 eet_node_del(nn);
325
326 break;
327 }
328
329 if (prev)
330 {
331 prev->next = child;
332 child->next = NULL;
333 }
334 else
335 {
336 child->next = NULL;
337 parent->values = child;
338 }
339
340 eina_stringshare_del(tmp);
341}
342
343void
344eet_node_hash_add(Eet_Node *parent,
345 const char *name,
346 const char *key,
347 Eet_Node *child)
348{
349 Eet_Node *nn;
350
351 if ((!parent) || (!child)) return;
352
353 /* No list found, so create it. */
354 nn = eet_node_hash_new(name, key, child);
355
356 /* And add it to the parent. */
357 nn->next = parent->values;
358 parent->values = nn;
359}
360
361int
362eet_node_type_get(Eet_Node *node)
363{
364 if (!node) return EET_T_UNKNOW;
365 return node->type;
366}
367
368Eet_Node_Data *
369eet_node_value_get(Eet_Node *node)
370{
371 if (!node) return NULL;
372 return &node->data;
373}
374
375const char *
376eet_node_name_get(Eet_Node *node)
377{
378 if (!node) return NULL;
379 return node->name;
380}
381
382void
383eet_node_del(Eet_Node *n)
384{
385 Eet_Node *nn;
386 Eet_Node *tmp;
387
388 if (!n)
389 return;
390
391 switch (n->type)
392 {
393 case EET_G_HASH:
394 eina_stringshare_del(n->key);
395
396 case EET_G_UNKNOWN:
397 case EET_G_VAR_ARRAY:
398 case EET_G_ARRAY:
399 case EET_G_LIST:
400 for (nn = n->values; nn; )
401 {
402 tmp = nn;
403 nn = nn->next;
404 eet_node_del(tmp);
405 }
406 break;
407
408 case EET_T_STRING:
409 case EET_T_INLINED_STRING:
410 eina_stringshare_del(n->data.value.str);
411 break;
412
413 case EET_T_CHAR:
414 case EET_T_SHORT:
415 case EET_T_INT:
416 case EET_T_LONG_LONG:
417 case EET_T_FLOAT:
418 case EET_T_DOUBLE:
419 case EET_T_UCHAR:
420 case EET_T_USHORT:
421 case EET_T_UINT:
422 break;
423 }
424
425 eina_stringshare_del(n->name);
426 eet_node_free(n);
427}
428
429static const char *eet_node_dump_g_name[6] = {
430 "struct",
431 "array",
432 "var_array",
433 "list",
434 "hash",
435 "???"
436};
437
438static const char *eet_node_dump_t_name[14][2] = {
439 { "???: ", "???" },
440 { "char: ", "%hhi" },
441 { "short: ", "%hi" },
442 { "int: ", "%i" },
443 { "long_long: ", "%lli" },
444 { "float: ", "%1.25f" },
445 { "double: ", "%1.25f" },
446 { "uchar: ", "%hhu" },
447 { "ushort: ", "%i" },
448 { "uint: ", "%u" },
449 { "ulong_long: ", "%llu" },
450 { "null", "" }
451};
452
453static void
454eet_node_dump_level(int level,
455 Eet_Dump_Callback dumpfunc,
456 void *dumpdata)
457{
458 int i;
459
460 for (i = 0; i < level; i++) dumpfunc(dumpdata, " ");
461}
462
463static char *
464eet_node_string_escape(const char *str)
465{
466 char *s, *sp;
467 const char *strp;
468 int sz = 0;
469
470 for (strp = str; *strp; strp++)
471 {
472 if (*strp == '\"')
473 sz += 2;
474 else if (*strp == '\\')
475 sz += 2;
476 else if (*strp == '\n')
477 sz += 2;
478 else
479 sz += 1;
480 }
481 s = malloc(sz + 1);
482 if (!s)
483 return NULL;
484
485 for (strp = str, sp = s; *strp; strp++, sp++)
486 {
487 if (*strp == '\"'
488 || *strp == '\\'
489 || *strp == '\n')
490 {
491 *sp = '\\';
492 sp++;
493 }
494
495 if (*strp == '\n')
496 *sp = 'n';
497 else
498 *sp = *strp;
499 }
500 *sp = 0;
501 return s;
502}
503
504static void
505eet_node_dump_string_escape(void *dumpdata,
506 Eet_Dump_Callback dumpfunc,
507 const char *str)
508{
509 char *s;
510
511 s = eet_node_string_escape(str);
512 if (!s)
513 return;
514
515 dumpfunc(dumpdata, s);
516 free(s);
517}
518
519static void
520eet_node_dump_simple_type(Eet_Node *n,
521 int level,
522 Eet_Dump_Callback dumpfunc,
523 void *dumpdata)
524{
525 const char *type_name = NULL;
526 char tbuf[256];
527
528 eet_node_dump_level(level, dumpfunc, dumpdata);
529 dumpfunc(dumpdata, "value \"");
530 eet_node_dump_string_escape(dumpdata, dumpfunc, n->name);
531 dumpfunc(dumpdata, "\" ");
532
533#ifdef EET_T_TYPE
534# undef EET_T_TYPE
535#endif /* ifdef EET_T_TYPE */
536
537#define EET_T_TYPE(Eet_Type, Type) \
538case Eet_Type: \
539{ \
540 dumpfunc(dumpdata, eet_node_dump_t_name[Eet_Type][0]); \
541 snprintf(tbuf, \
542 sizeof (tbuf), \
543 eet_node_dump_t_name[Eet_Type][1], \
544 n->data.value.Type); \
545 dumpfunc(dumpdata, tbuf); \
546 break; \
547}
548
549 switch (n->type)
550 {
551 EET_T_TYPE(EET_T_CHAR, c);
552 EET_T_TYPE(EET_T_SHORT, s);
553 EET_T_TYPE(EET_T_INT, i);
554 EET_T_TYPE(EET_T_LONG_LONG, l);
555 EET_T_TYPE(EET_T_FLOAT, f);
556 EET_T_TYPE(EET_T_DOUBLE, d);
557 EET_T_TYPE(EET_T_UCHAR, uc);
558 EET_T_TYPE(EET_T_USHORT, us);
559 EET_T_TYPE(EET_T_UINT, ui);
560 EET_T_TYPE(EET_T_ULONG_LONG, ul);
561
562 case EET_T_INLINED_STRING:
563 type_name = "inlined: \"";
564
565 case EET_T_STRING:
566 if (!type_name)
567 type_name = "string: \"";
568
569 dumpfunc(dumpdata, type_name);
570 eet_node_dump_string_escape(dumpdata, dumpfunc, n->data.value.str);
571 dumpfunc(dumpdata, "\"");
572 break;
573
574 case EET_T_NULL:
575 dumpfunc(dumpdata, "null");
576 break;
577
578 default:
579 dumpfunc(dumpdata, "???: ???");
580 break;
581 }
582
583 dumpfunc(dumpdata, ";\n");
584}
585
586static void
587eet_node_dump_group_start(int level,
588 Eet_Dump_Callback dumpfunc,
589 void *dumpdata,
590 int group_type,
591 const char *name)
592{
593 int chnk_type;
594
595 chnk_type = (group_type >= EET_G_UNKNOWN && group_type <= EET_G_HASH) ?
596 group_type : EET_G_LAST;
597
598 eet_node_dump_level(level, dumpfunc, dumpdata);
599 dumpfunc(dumpdata, "group \"");
600 eet_node_dump_string_escape(dumpdata, dumpfunc, name);
601 dumpfunc(dumpdata, "\" ");
602
603 dumpfunc(dumpdata, eet_node_dump_g_name[chnk_type - EET_G_UNKNOWN]);
604 dumpfunc(dumpdata, " {\n");
605}
606
607static void
608eet_node_dump_group_end(int level,
609 Eet_Dump_Callback dumpfunc,
610 void *dumpdata)
611{
612 eet_node_dump_level(level, dumpfunc, dumpdata);
613 dumpfunc(dumpdata, "}\n");
614}
615
616void
617eet_node_dump(Eet_Node *n,
618 int dumplevel,
619 Eet_Dump_Callback dumpfunc,
620 void *dumpdata)
621{
622 Eet_Node *it;
623
624 if (!n)
625 return;
626
627 switch (n->type)
628 {
629 case EET_G_VAR_ARRAY:
630 case EET_G_ARRAY:
631 case EET_G_UNKNOWN:
632 case EET_G_HASH:
633 case EET_G_LIST:
634 eet_node_dump_group_start(dumplevel,
635 dumpfunc,
636 dumpdata,
637 n->type,
638 n->name);
639
640 if (n->type == EET_G_VAR_ARRAY
641 || n->type == EET_G_ARRAY)
642 {
643 char tbuf[256];
644
645 eet_node_dump_level(dumplevel, dumpfunc, dumpdata);
646 dumpfunc(dumpdata, " count ");
647 eina_convert_itoa(n->count, tbuf);
648 dumpfunc(dumpdata, tbuf);
649 dumpfunc(dumpdata, ";\n");
650 }
651 else if (n->type == EET_G_HASH)
652 {
653 eet_node_dump_level(dumplevel, dumpfunc, dumpdata);
654 dumpfunc(dumpdata, " key \"");
655 eet_node_dump_string_escape(dumpdata, dumpfunc, n->key);
656 dumpfunc(dumpdata, "\";\n");
657 }
658
659 for (it = n->values; it; it = it->next)
660 eet_node_dump(it, dumplevel + 2, dumpfunc, dumpdata);
661
662 eet_node_dump_group_end(dumplevel, dumpfunc, dumpdata);
663 break;
664
665 case EET_T_STRING:
666 case EET_T_INLINED_STRING:
667 case EET_T_CHAR:
668 case EET_T_SHORT:
669 case EET_T_INT:
670 case EET_T_LONG_LONG:
671 case EET_T_FLOAT:
672 case EET_T_DOUBLE:
673 case EET_T_UCHAR:
674 case EET_T_USHORT:
675 case EET_T_UINT:
676 case EET_T_ULONG_LONG:
677 eet_node_dump_simple_type(n, dumplevel, dumpfunc, dumpdata);
678 break;
679 }
680}
681
682void *
683eet_node_walk(void *parent,
684 const char *name,
685 Eet_Node *root,
686 Eet_Node_Walk *cb,
687 void *user_data)
688{
689 Eet_Node *it;
690 void *me = NULL;
691 int i;
692
693 if (!root)
694 {
695 if (parent)
696 cb->struct_add(parent, name, NULL, user_data);
697
698 return NULL;
699 }
700
701 switch (root->type)
702 {
703 case EET_G_UNKNOWN:
704 me = cb->struct_alloc(root->name, user_data);
705
706 for (it = root->values; it; it = it->next)
707 eet_node_walk(me, it->name, it, cb, user_data);
708
709 break;
710
711 case EET_G_VAR_ARRAY:
712 case EET_G_ARRAY:
713 me = cb->array(root->type == EET_G_VAR_ARRAY ? EINA_TRUE : EINA_FALSE,
714 root->name, root->count, user_data);
715
716 for (i = 0, it = root->values; it; it = it->next)
717 cb->insert(me, i++, eet_node_walk(NULL,
718 NULL,
719 it,
720 cb,
721 user_data), user_data);
722
723 break;
724
725 case EET_G_LIST:
726 me = cb->list(root->name, user_data);
727
728 for (it = root->values; it; it = it->next)
729 cb->append(me, eet_node_walk(NULL,
730 NULL,
731 it,
732 cb,
733 user_data), user_data);
734
735 break;
736
737 case EET_G_HASH:
738 if (!parent)
739 return NULL;
740
741 return cb->hash(parent, root->name, root->key,
742 eet_node_walk(NULL,
743 NULL,
744 root->values,
745 cb,
746 user_data), user_data);
747
748 case EET_T_STRING:
749 case EET_T_INLINED_STRING:
750 case EET_T_CHAR:
751 case EET_T_SHORT:
752 case EET_T_INT:
753 case EET_T_LONG_LONG:
754 case EET_T_FLOAT:
755 case EET_T_DOUBLE:
756 case EET_T_UCHAR:
757 case EET_T_USHORT:
758 case EET_T_UINT:
759 case EET_T_ULONG_LONG:
760 me = cb->simple(root->type, &root->data, user_data);
761 break;
762 }
763
764 if (parent)
765 cb->struct_add(parent, name, me, user_data);
766
767 return me;
768}
769
770int
771eet_node_init(void)
772{
773 const char *choice;
774 const char *tmp;
775
776#ifdef EINA_DEFAULT_MEMPOOL
777 choice = "pass_through";
778#else
779 choice = "chained_mempool";
780#endif
781 tmp = getenv("EINA_MEMPOOL");
782 if (tmp && tmp[0])
783 choice = tmp;
784
785 _eet_node_mp =
786 eina_mempool_add(choice, "eet-node-alloc", NULL, sizeof(Eet_Node), 1024);
787
788 return _eet_node_mp ? 1 : 0;
789}
790
791void
792eet_node_shutdown(void)
793{
794 eina_mempool_del(_eet_node_mp);
795 _eet_node_mp = NULL;
796}
797
diff --git a/libraries/eet/src/lib/eet_utils.c b/libraries/eet/src/lib/eet_utils.c
deleted file mode 100644
index b04ad1b..0000000
--- a/libraries/eet/src/lib/eet_utils.c
+++ /dev/null
@@ -1,36 +0,0 @@
1#ifdef HAVE_CONFIG_H
2# include <config.h>
3#endif /* ifdef HAVE_CONFIG_H */
4
5#include <stdio.h>
6#include <math.h>
7
8#include "Eet.h"
9#include "Eet_private.h"
10
11int
12_eet_hash_gen(const char *key,
13 int hash_size)
14{
15 int hash_num = 0;
16 int value, i;
17 int mask;
18 unsigned char *ptr;
19
20 /* no string - index 0 */
21 if (!key)
22 return 0;
23
24 /* calc hash num */
25 for (i = 0, ptr = (unsigned char *)key, value = (int)(*ptr);
26 value;
27 ptr++, i++, value = (int)(*ptr))
28 hash_num ^= (value | (value << 8)) >> (i & 0x7);
29
30 /* mask it */
31 mask = (1 << hash_size) - 1;
32 hash_num &= mask;
33 /* return it */
34 return hash_num;
35}
36
diff --git a/libraries/eet/src/tests/Makefile.am b/libraries/eet/src/tests/Makefile.am
deleted file mode 100644
index 61158f7..0000000
--- a/libraries/eet/src/tests/Makefile.am
+++ /dev/null
@@ -1,18 +0,0 @@
1MAINTAINERCLEANFILES = Makefile.in
2
3AM_CPPFLAGS = \
4-I$(top_srcdir)/src/lib \
5-DTESTS_SRC_DIR=\"$(top_srcdir)/src/tests\" \
6@CHECK_CFLAGS@ \
7@EINA_CFLAGS@
8
9if EFL_ENABLE_TESTS
10
11check_PROGRAMS = eet_suite
12
13eet_suite_SOURCES = eet_suite.c eet_data_suite.c
14eet_suite_LDADD = $(top_builddir)/src/lib/libeet.la @EINA_LIBS@ @CHECK_LIBS@
15
16endif
17
18EXTRA_DIST = eet_suite.h cert.pem key_enc_none.pem key_enc.pem key.pem
diff --git a/libraries/eet/src/tests/Makefile.in b/libraries/eet/src/tests/Makefile.in
deleted file mode 100644
index e17a54e..0000000
--- a/libraries/eet/src/tests/Makefile.in
+++ /dev/null
@@ -1,547 +0,0 @@
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@
17VPATH = @srcdir@
18pkgdatadir = $(datadir)/@PACKAGE@
19pkgincludedir = $(includedir)/@PACKAGE@
20pkglibdir = $(libdir)/@PACKAGE@
21pkglibexecdir = $(libexecdir)/@PACKAGE@
22am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
23install_sh_DATA = $(install_sh) -c -m 644
24install_sh_PROGRAM = $(install_sh) -c
25install_sh_SCRIPT = $(install_sh) -c
26INSTALL_HEADER = $(INSTALL_DATA)
27transform = $(program_transform_name)
28NORMAL_INSTALL = :
29PRE_INSTALL = :
30POST_INSTALL = :
31NORMAL_UNINSTALL = :
32PRE_UNINSTALL = :
33POST_UNINSTALL = :
34build_triplet = @build@
35host_triplet = @host@
36@EFL_ENABLE_TESTS_TRUE@check_PROGRAMS = eet_suite$(EXEEXT)
37subdir = src/tests
38DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in TODO
39ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
40am__aclocal_m4_deps = $(top_srcdir)/m4/ac_attribute.m4 \
41 $(top_srcdir)/m4/ac_path_generic.m4 \
42 $(top_srcdir)/m4/efl_binary.m4 \
43 $(top_srcdir)/m4/efl_compiler_flag.m4 \
44 $(top_srcdir)/m4/efl_coverage.m4 \
45 $(top_srcdir)/m4/efl_doxygen.m4 \
46 $(top_srcdir)/m4/efl_fnmatch.m4 \
47 $(top_srcdir)/m4/efl_path_max.m4 $(top_srcdir)/m4/efl_tests.m4 \
48 $(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
49 $(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \
50 $(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/configure.ac
51am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
52 $(ACLOCAL_M4)
53mkinstalldirs = $(install_sh) -d
54CONFIG_HEADER = $(top_builddir)/config.h
55CONFIG_CLEAN_FILES =
56CONFIG_CLEAN_VPATH_FILES =
57am__eet_suite_SOURCES_DIST = eet_suite.c eet_data_suite.c
58@EFL_ENABLE_TESTS_TRUE@am_eet_suite_OBJECTS = eet_suite.$(OBJEXT) \
59@EFL_ENABLE_TESTS_TRUE@ eet_data_suite.$(OBJEXT)
60eet_suite_OBJECTS = $(am_eet_suite_OBJECTS)
61@EFL_ENABLE_TESTS_TRUE@eet_suite_DEPENDENCIES = \
62@EFL_ENABLE_TESTS_TRUE@ $(top_builddir)/src/lib/libeet.la
63AM_V_lt = $(am__v_lt_$(V))
64am__v_lt_ = $(am__v_lt_$(AM_DEFAULT_VERBOSITY))
65am__v_lt_0 = --silent
66DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)
67depcomp = $(SHELL) $(top_srcdir)/depcomp
68am__depfiles_maybe = depfiles
69am__mv = mv -f
70COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
71 $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
72LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
73 $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \
74 $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
75 $(AM_CFLAGS) $(CFLAGS)
76AM_V_CC = $(am__v_CC_$(V))
77am__v_CC_ = $(am__v_CC_$(AM_DEFAULT_VERBOSITY))
78am__v_CC_0 = @echo " CC " $@;
79AM_V_at = $(am__v_at_$(V))
80am__v_at_ = $(am__v_at_$(AM_DEFAULT_VERBOSITY))
81am__v_at_0 = @
82CCLD = $(CC)
83LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
84 $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
85 $(AM_LDFLAGS) $(LDFLAGS) -o $@
86AM_V_CCLD = $(am__v_CCLD_$(V))
87am__v_CCLD_ = $(am__v_CCLD_$(AM_DEFAULT_VERBOSITY))
88am__v_CCLD_0 = @echo " CCLD " $@;
89AM_V_GEN = $(am__v_GEN_$(V))
90am__v_GEN_ = $(am__v_GEN_$(AM_DEFAULT_VERBOSITY))
91am__v_GEN_0 = @echo " GEN " $@;
92SOURCES = $(eet_suite_SOURCES)
93DIST_SOURCES = $(am__eet_suite_SOURCES_DIST)
94ETAGS = etags
95CTAGS = ctags
96DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
97ACLOCAL = @ACLOCAL@
98ALLOCA = @ALLOCA@
99AMTAR = @AMTAR@
100AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
101AR = @AR@
102AS = @AS@
103AUTOCONF = @AUTOCONF@
104AUTOHEADER = @AUTOHEADER@
105AUTOMAKE = @AUTOMAKE@
106AWK = @AWK@
107CC = @CC@
108CCDEPMODE = @CCDEPMODE@
109CFLAGS = @CFLAGS@
110CHECK_CFLAGS = @CHECK_CFLAGS@
111CHECK_LIBS = @CHECK_LIBS@
112CPP = @CPP@
113CPPFLAGS = @CPPFLAGS@
114CYGPATH_W = @CYGPATH_W@
115DEBUG_CFLAGS = @DEBUG_CFLAGS@
116DEFS = @DEFS@
117DEPDIR = @DEPDIR@
118DLLTOOL = @DLLTOOL@
119DSYMUTIL = @DSYMUTIL@
120DUMPBIN = @DUMPBIN@
121ECHO_C = @ECHO_C@
122ECHO_N = @ECHO_N@
123ECHO_T = @ECHO_T@
124EET_CFLAGS = @EET_CFLAGS@
125EET_CPPFLAGS = @EET_CPPFLAGS@
126EET_LIBS = @EET_LIBS@
127EET_PRG = @EET_PRG@
128EFL_COVERAGE_CFLAGS = @EFL_COVERAGE_CFLAGS@
129EFL_COVERAGE_LIBS = @EFL_COVERAGE_LIBS@
130EFL_EET_BUILD = @EFL_EET_BUILD@
131EFL_FNMATCH_LIBS = @EFL_FNMATCH_LIBS@
132EGREP = @EGREP@
133EINA_CFLAGS = @EINA_CFLAGS@
134EINA_LIBS = @EINA_LIBS@
135EVIL_CFLAGS = @EVIL_CFLAGS@
136EVIL_LIBS = @EVIL_LIBS@
137EXEEXT = @EXEEXT@
138EXOTIC_CFLAGS = @EXOTIC_CFLAGS@
139EXOTIC_LIBS = @EXOTIC_LIBS@
140FGREP = @FGREP@
141GNUTLS_CFLAGS = @GNUTLS_CFLAGS@
142GNUTLS_LIBS = @GNUTLS_LIBS@
143GREP = @GREP@
144INSTALL = @INSTALL@
145INSTALL_DATA = @INSTALL_DATA@
146INSTALL_PROGRAM = @INSTALL_PROGRAM@
147INSTALL_SCRIPT = @INSTALL_SCRIPT@
148INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
149LD = @LD@
150LDFLAGS = @LDFLAGS@
151LIBGCRYPT_CFLAGS = @LIBGCRYPT_CFLAGS@
152LIBGCRYPT_CONFIG = @LIBGCRYPT_CONFIG@
153LIBGCRYPT_LIBS = @LIBGCRYPT_LIBS@
154LIBOBJS = @LIBOBJS@
155LIBS = @LIBS@
156LIBTOOL = @LIBTOOL@
157LIPO = @LIPO@
158LN_S = @LN_S@
159LTLIBOBJS = @LTLIBOBJS@
160MAKEINFO = @MAKEINFO@
161MKDIR_P = @MKDIR_P@
162NM = @NM@
163NMEDIT = @NMEDIT@
164OBJDUMP = @OBJDUMP@
165OBJEXT = @OBJEXT@
166OPENSSL_CFLAGS = @OPENSSL_CFLAGS@
167OPENSSL_LIBS = @OPENSSL_LIBS@
168OTOOL = @OTOOL@
169OTOOL64 = @OTOOL64@
170PACKAGE = @PACKAGE@
171PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
172PACKAGE_NAME = @PACKAGE_NAME@
173PACKAGE_STRING = @PACKAGE_STRING@
174PACKAGE_TARNAME = @PACKAGE_TARNAME@
175PACKAGE_URL = @PACKAGE_URL@
176PACKAGE_VERSION = @PACKAGE_VERSION@
177PATH_SEPARATOR = @PATH_SEPARATOR@
178PKG_CONFIG = @PKG_CONFIG@
179PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@
180PKG_CONFIG_PATH = @PKG_CONFIG_PATH@
181RANLIB = @RANLIB@
182SED = @SED@
183SET_MAKE = @SET_MAKE@
184SHELL = @SHELL@
185STRIP = @STRIP@
186VERSION = @VERSION@
187VMAJ = @VMAJ@
188abs_builddir = @abs_builddir@
189abs_srcdir = @abs_srcdir@
190abs_top_builddir = @abs_top_builddir@
191abs_top_srcdir = @abs_top_srcdir@
192ac_ct_CC = @ac_ct_CC@
193ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
194am__include = @am__include@
195am__leading_dot = @am__leading_dot@
196am__quote = @am__quote@
197am__tar = @am__tar@
198am__untar = @am__untar@
199bindir = @bindir@
200build = @build@
201build_alias = @build_alias@
202build_cpu = @build_cpu@
203build_os = @build_os@
204build_vendor = @build_vendor@
205builddir = @builddir@
206datadir = @datadir@
207datarootdir = @datarootdir@
208docdir = @docdir@
209dvidir = @dvidir@
210efl_doxygen = @efl_doxygen@
211efl_have_doxygen = @efl_have_doxygen@
212exec_prefix = @exec_prefix@
213have_lcov = @have_lcov@
214host = @host@
215host_alias = @host_alias@
216host_cpu = @host_cpu@
217host_os = @host_os@
218host_vendor = @host_vendor@
219htmldir = @htmldir@
220includedir = @includedir@
221infodir = @infodir@
222install_sh = @install_sh@
223libdir = @libdir@
224libexecdir = @libexecdir@
225localedir = @localedir@
226localstatedir = @localstatedir@
227lt_ECHO = @lt_ECHO@
228lt_enable_auto_import = @lt_enable_auto_import@
229mandir = @mandir@
230mkdir_p = @mkdir_p@
231oldincludedir = @oldincludedir@
232pdfdir = @pdfdir@
233pkgconfig_requires_private = @pkgconfig_requires_private@
234prefix = @prefix@
235program_transform_name = @program_transform_name@
236psdir = @psdir@
237release_info = @release_info@
238requirement_eet = @requirement_eet@
239sbindir = @sbindir@
240sharedstatedir = @sharedstatedir@
241srcdir = @srcdir@
242sysconfdir = @sysconfdir@
243target_alias = @target_alias@
244top_build_prefix = @top_build_prefix@
245top_builddir = @top_builddir@
246top_srcdir = @top_srcdir@
247version_info = @version_info@
248MAINTAINERCLEANFILES = Makefile.in
249AM_CPPFLAGS = \
250-I$(top_srcdir)/src/lib \
251-DTESTS_SRC_DIR=\"$(top_srcdir)/src/tests\" \
252@CHECK_CFLAGS@ \
253@EINA_CFLAGS@
254
255@EFL_ENABLE_TESTS_TRUE@eet_suite_SOURCES = eet_suite.c eet_data_suite.c
256@EFL_ENABLE_TESTS_TRUE@eet_suite_LDADD = $(top_builddir)/src/lib/libeet.la @EINA_LIBS@ @CHECK_LIBS@
257EXTRA_DIST = eet_suite.h cert.pem key_enc_none.pem key_enc.pem key.pem
258all: all-am
259
260.SUFFIXES:
261.SUFFIXES: .c .lo .o .obj
262$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
263 @for dep in $?; do \
264 case '$(am__configure_deps)' in \
265 *$$dep*) \
266 ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
267 && { if test -f $@; then exit 0; else break; fi; }; \
268 exit 1;; \
269 esac; \
270 done; \
271 echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu src/tests/Makefile'; \
272 $(am__cd) $(top_srcdir) && \
273 $(AUTOMAKE) --gnu src/tests/Makefile
274.PRECIOUS: Makefile
275Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
276 @case '$?' in \
277 *config.status*) \
278 cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
279 *) \
280 echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
281 cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
282 esac;
283
284$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
285 cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
286
287$(top_srcdir)/configure: $(am__configure_deps)
288 cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
289$(ACLOCAL_M4): $(am__aclocal_m4_deps)
290 cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
291$(am__aclocal_m4_deps):
292
293clean-checkPROGRAMS:
294 @list='$(check_PROGRAMS)'; test -n "$$list" || exit 0; \
295 echo " rm -f" $$list; \
296 rm -f $$list || exit $$?; \
297 test -n "$(EXEEXT)" || exit 0; \
298 list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \
299 echo " rm -f" $$list; \
300 rm -f $$list
301eet_suite$(EXEEXT): $(eet_suite_OBJECTS) $(eet_suite_DEPENDENCIES)
302 @rm -f eet_suite$(EXEEXT)
303 $(AM_V_CCLD)$(LINK) $(eet_suite_OBJECTS) $(eet_suite_LDADD) $(LIBS)
304
305mostlyclean-compile:
306 -rm -f *.$(OBJEXT)
307
308distclean-compile:
309 -rm -f *.tab.c
310
311@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eet_data_suite.Po@am__quote@
312@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eet_suite.Po@am__quote@
313
314.c.o:
315@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
316@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
317@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@
318@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
319@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
320@am__fastdepCC_FALSE@ $(COMPILE) -c $<
321
322.c.obj:
323@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
324@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
325@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@
326@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
327@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
328@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'`
329
330.c.lo:
331@am__fastdepCC_TRUE@ $(AM_V_CC)$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
332@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
333@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@
334@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
335@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
336@am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $<
337
338mostlyclean-libtool:
339 -rm -f *.lo
340
341clean-libtool:
342 -rm -rf .libs _libs
343
344ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
345 list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
346 unique=`for i in $$list; do \
347 if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
348 done | \
349 $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
350 END { if (nonempty) { for (i in files) print i; }; }'`; \
351 mkid -fID $$unique
352tags: TAGS
353
354TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
355 $(TAGS_FILES) $(LISP)
356 set x; \
357 here=`pwd`; \
358 list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
359 unique=`for i in $$list; do \
360 if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
361 done | \
362 $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
363 END { if (nonempty) { for (i in files) print i; }; }'`; \
364 shift; \
365 if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
366 test -n "$$unique" || unique=$$empty_fix; \
367 if test $$# -gt 0; then \
368 $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
369 "$$@" $$unique; \
370 else \
371 $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
372 $$unique; \
373 fi; \
374 fi
375ctags: CTAGS
376CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
377 $(TAGS_FILES) $(LISP)
378 list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
379 unique=`for i in $$list; do \
380 if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
381 done | \
382 $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
383 END { if (nonempty) { for (i in files) print i; }; }'`; \
384 test -z "$(CTAGS_ARGS)$$unique" \
385 || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
386 $$unique
387
388GTAGS:
389 here=`$(am__cd) $(top_builddir) && pwd` \
390 && $(am__cd) $(top_srcdir) \
391 && gtags -i $(GTAGS_ARGS) "$$here"
392
393distclean-tags:
394 -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
395
396distdir: $(DISTFILES)
397 @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
398 topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
399 list='$(DISTFILES)'; \
400 dist_files=`for file in $$list; do echo $$file; done | \
401 sed -e "s|^$$srcdirstrip/||;t" \
402 -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
403 case $$dist_files in \
404 */*) $(MKDIR_P) `echo "$$dist_files" | \
405 sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
406 sort -u` ;; \
407 esac; \
408 for file in $$dist_files; do \
409 if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
410 if test -d $$d/$$file; then \
411 dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
412 if test -d "$(distdir)/$$file"; then \
413 find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
414 fi; \
415 if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
416 cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
417 find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
418 fi; \
419 cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
420 else \
421 test -f "$(distdir)/$$file" \
422 || cp -p $$d/$$file "$(distdir)/$$file" \
423 || exit 1; \
424 fi; \
425 done
426check-am: all-am
427 $(MAKE) $(AM_MAKEFLAGS) $(check_PROGRAMS)
428check: check-am
429all-am: Makefile
430installdirs:
431install: install-am
432install-exec: install-exec-am
433install-data: install-data-am
434uninstall: uninstall-am
435
436install-am: all-am
437 @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
438
439installcheck: installcheck-am
440install-strip:
441 $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
442 install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
443 `test -z '$(STRIP)' || \
444 echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
445mostlyclean-generic:
446
447clean-generic:
448
449distclean-generic:
450 -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
451 -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
452
453maintainer-clean-generic:
454 @echo "This command is intended for maintainers to use"
455 @echo "it deletes files that may require special tools to rebuild."
456 -test -z "$(MAINTAINERCLEANFILES)" || rm -f $(MAINTAINERCLEANFILES)
457clean: clean-am
458
459clean-am: clean-checkPROGRAMS clean-generic clean-libtool \
460 mostlyclean-am
461
462distclean: distclean-am
463 -rm -rf ./$(DEPDIR)
464 -rm -f Makefile
465distclean-am: clean-am distclean-compile distclean-generic \
466 distclean-tags
467
468dvi: dvi-am
469
470dvi-am:
471
472html: html-am
473
474html-am:
475
476info: info-am
477
478info-am:
479
480install-data-am:
481
482install-dvi: install-dvi-am
483
484install-dvi-am:
485
486install-exec-am:
487
488install-html: install-html-am
489
490install-html-am:
491
492install-info: install-info-am
493
494install-info-am:
495
496install-man:
497
498install-pdf: install-pdf-am
499
500install-pdf-am:
501
502install-ps: install-ps-am
503
504install-ps-am:
505
506installcheck-am:
507
508maintainer-clean: maintainer-clean-am
509 -rm -rf ./$(DEPDIR)
510 -rm -f Makefile
511maintainer-clean-am: distclean-am maintainer-clean-generic
512
513mostlyclean: mostlyclean-am
514
515mostlyclean-am: mostlyclean-compile mostlyclean-generic \
516 mostlyclean-libtool
517
518pdf: pdf-am
519
520pdf-am:
521
522ps: ps-am
523
524ps-am:
525
526uninstall-am:
527
528.MAKE: check-am install-am install-strip
529
530.PHONY: CTAGS GTAGS all all-am check check-am clean \
531 clean-checkPROGRAMS clean-generic clean-libtool ctags \
532 distclean distclean-compile distclean-generic \
533 distclean-libtool distclean-tags distdir dvi dvi-am html \
534 html-am info info-am install install-am install-data \
535 install-data-am install-dvi install-dvi-am install-exec \
536 install-exec-am install-html install-html-am install-info \
537 install-info-am install-man install-pdf install-pdf-am \
538 install-ps install-ps-am install-strip installcheck \
539 installcheck-am installdirs maintainer-clean \
540 maintainer-clean-generic mostlyclean mostlyclean-compile \
541 mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
542 tags uninstall uninstall-am
543
544
545# Tell versions [3.59,3.63) of GNU make to not export all variables.
546# Otherwise a system limit (for SysV at least) may be exceeded.
547.NOEXPORT:
diff --git a/libraries/eet/src/tests/TODO b/libraries/eet/src/tests/TODO
deleted file mode 100644
index da5fa1b..0000000
--- a/libraries/eet/src/tests/TODO
+++ /dev/null
@@ -1,3 +0,0 @@
1The purpose of the current test is to check the validity of the result in a
2normal environment. But we should at some point also test the robustness of
3this library when for example malloc fail.
diff --git a/libraries/eet/src/tests/cert.pem b/libraries/eet/src/tests/cert.pem
deleted file mode 100644
index 3265462..0000000
--- a/libraries/eet/src/tests/cert.pem
+++ /dev/null
@@ -1,22 +0,0 @@
1-----BEGIN CERTIFICATE-----
2MIIDmTCCAwKgAwIBAgIJAIKWPcLUT5FAMA0GCSqGSIb3DQEBBQUAMIGQMQswCQYD
3VQQGEwJGUjEWMBQGA1UECBMNSWxlLURlLUZyYW5jZTEOMAwGA1UEBxMFUGFyaXMx
4FjAUBgNVBAoTDUVubGlnaHRlbm1lbnQxDjAMBgNVBAsTBVRlc3RzMQ0wCwYDVQQD
5EwRCQUlMMSIwIAYJKoZIhvcNAQkBFhNjZWRyaWMuYmFpbEBmcmVlLmZyMB4XDTA4
6MDczMDEzNDU1OVoXDTA5MDczMDEzNDU1OVowgZAxCzAJBgNVBAYTAkZSMRYwFAYD
7VQQIEw1JbGUtRGUtRnJhbmNlMQ4wDAYDVQQHEwVQYXJpczEWMBQGA1UEChMNRW5s
8aWdodGVubWVudDEOMAwGA1UECxMFVGVzdHMxDTALBgNVBAMTBEJBSUwxIjAgBgkq
9hkiG9w0BCQEWE2NlZHJpYy5iYWlsQGZyZWUuZnIwgZ8wDQYJKoZIhvcNAQEBBQAD
10gY0AMIGJAoGBAMiE486eROKePG0/639D4XTTDR9XSRWp1xqZzq7P+jjWRFbZ/MWV
11IVzkc4MRm83UOolbPj76LjM10cseaVAhK7G9CHp2dur4alWvdCXPH5Q+LPOFS9gM
12x0Jz9EZeHHOHZKLyJdKSmot+zluwJTLe081RRUwzNKct6JrVVG/7SmITAgMBAAGj
13gfgwgfUwHQYDVR0OBBYEFEFar6doT5ImL2rf0rJX7EYQqtYQMIHFBgNVHSMEgb0w
14gbqAFEFar6doT5ImL2rf0rJX7EYQqtYQoYGWpIGTMIGQMQswCQYDVQQGEwJGUjEW
15MBQGA1UECBMNSWxlLURlLUZyYW5jZTEOMAwGA1UEBxMFUGFyaXMxFjAUBgNVBAoT
16DUVubGlnaHRlbm1lbnQxDjAMBgNVBAsTBVRlc3RzMQ0wCwYDVQQDEwRCQUlMMSIw
17IAYJKoZIhvcNAQkBFhNjZWRyaWMuYmFpbEBmcmVlLmZyggkAgpY9wtRPkUAwDAYD
18VR0TBAUwAwEB/zANBgkqhkiG9w0BAQUFAAOBgQCpZJhk8BgQh0foiMkOwOMKvObq
19GxAzqjbr7iU9tEvJgwukCBv59ndBM0B5l5ybQdIYWQJOfZE1HTvB60swZMwqap9X
205QXgewymuXiVk+roVh34wg8Pg8F588G2BtLIoujY/gN3WJQR7YPD34iTPc4koV+A
214vs6nmL6wtW21+hsaw==
22-----END CERTIFICATE-----
diff --git a/libraries/eet/src/tests/eet_data_suite.c b/libraries/eet/src/tests/eet_data_suite.c
deleted file mode 100644
index c4d5e50..0000000
--- a/libraries/eet/src/tests/eet_data_suite.c
+++ /dev/null
@@ -1,73 +0,0 @@
1#include <string.h>
2#include <stdio.h>
3
4#include <Eina.h>
5
6#include "eet_suite.h"
7
8static char *
9_eet_str_direct_alloc(const char *str)
10{
11 return (char *)str;
12} /* _eet_str_direct_alloc */
13
14static void
15_eet_str_direct_free(const char *str)
16{
17 /* FIXME: Use attribute unused */
18 (void)str;
19} /* _eet_str_direct_free */
20
21static void
22_eet_eina_hash_foreach(void *hash,
23 Eina_Hash_Foreach cb,
24 void *fdata)
25{
26 if (hash)
27 eina_hash_foreach(hash, cb, fdata);
28} /* _eet_eina_hash_foreach */
29
30/* Internal wrapper for eina_hash */
31static Eina_Hash *
32_eet_eina_hash_add(Eina_Hash *hash,
33 const char *key,
34 const void *data)
35{
36 if (!hash)
37 hash = eina_hash_string_superfast_new(NULL);
38
39 if (!hash)
40 return NULL;
41
42 eina_hash_add(hash, key, data);
43 return hash;
44} /* _eet_eina_hash_add */
45
46static void
47_eet_eina_hash_free(Eina_Hash *hash)
48{
49 if (hash)
50 eina_hash_free(hash);
51} /* _eet_eina_hash_free */
52
53void
54eet_test_setup_eddc(Eet_Data_Descriptor_Class *eddc)
55{
56 eddc->version = EET_DATA_DESCRIPTOR_CLASS_VERSION;
57 eddc->func.mem_alloc = NULL;
58 eddc->func.mem_free = NULL;
59 eddc->func.str_alloc = NULL;
60 eddc->func.str_free = NULL;
61 eddc->func.list_next = (void *)eina_list_next;
62 eddc->func.list_append = (void *)eina_list_append;
63 eddc->func.list_data = (void *)eina_list_data_get;
64 eddc->func.list_free = (void *)eina_list_free;
65 eddc->func.hash_foreach = (void *)_eet_eina_hash_foreach;
66 eddc->func.hash_add = (void *)_eet_eina_hash_add;
67 eddc->func.hash_free = (void *)_eet_eina_hash_free;
68 eddc->func.str_direct_alloc = (void *)_eet_str_direct_alloc;
69 eddc->func.str_direct_free = (void *)_eet_str_direct_free;
70 eddc->func.array_alloc = NULL;
71 eddc->func.array_free = NULL;
72} /* eet_test_setup_eddc */
73
diff --git a/libraries/eet/src/tests/eet_suite.c b/libraries/eet/src/tests/eet_suite.c
deleted file mode 100644
index 91ef2a7..0000000
--- a/libraries/eet/src/tests/eet_suite.c
+++ /dev/null
@@ -1,2779 +0,0 @@
1#ifdef HAVE_CONFIG_H
2# include <config.h>
3#endif /* ifdef HAVE_CONFIG_H */
4
5#include <sys/types.h>
6#include <sys/stat.h>
7#include <stdlib.h>
8#include <string.h>
9#include <strings.h>
10#include <stdio.h>
11#include <fcntl.h>
12#include <unistd.h>
13
14#include <Eina.h>
15
16#ifdef EINA_HAVE_THREADS
17#if ((!defined(_WIN32_WCE)) && (!defined(_WIN32)))
18# include <pthread.h>
19# define _EET_INCLUDED_PTHREAD
20#endif
21#endif /* ifdef EINA_HAVE_THREADS */
22
23#include <check.h>
24
25#include "eet_suite.h"
26
27#define CERT_DIR ((*TESTS_SRC_DIR == '/') ? TESTS_SRC_DIR : "src/tests/" TESTS_SRC_DIR)
28
29START_TEST(eet_test_init)
30{
31 int ret;
32
33 ret = eet_init();
34 fail_if(ret != 1);
35
36 ret = eet_shutdown();
37 fail_if(ret != 0);
38}
39END_TEST
40
41typedef struct _Eet_Test_Basic_Type Eet_Test_Basic_Type;
42struct _Eet_Test_Basic_Type
43{
44 char c;
45 short s;
46 int i;
47 long long l;
48 char *str;
49 char *istr;
50 float f1;
51 float f2;
52 double d;
53 unsigned char uc;
54 unsigned short us;
55 unsigned int ui;
56 unsigned long long ul;
57 Eet_Test_Basic_Type *empty;
58 Eet_Test_Basic_Type *with;
59};
60
61#define EET_TEST_CHAR 0x42
62#define EET_TEST_SHORT 0x4224
63#define EET_TEST_INT 0x42211224
64#define EET_TEST_LONG_LONG 0x84CB42211224BC48
65#define EET_TEST_STRING "my little test with escape \\\""
66#define EET_TEST_KEY1 "key1"
67#define EET_TEST_KEY2 "key2"
68#define EET_TEST_FLOAT 123.45689
69#define EET_TEST_FLOAT2 1.0
70#define EET_TEST_FLOAT3 0.25
71#define EET_TEST_FLOAT4 0.0001234
72#define EET_TEST_DOUBLE 123456789.9876543210
73#define EET_TEST_DOUBLE2 1.0
74#define EET_TEST_DOUBLE3 0.25
75#define EET_TEST_FILE_KEY1 "keys/data/1"
76#define EET_TEST_FILE_KEY2 "keys/data/2"
77#define EET_TEST_FILE_IMAGE "keys/images/"
78
79typedef struct _Eet_Test_Image Eet_Test_Image;
80struct _Eet_Test_Image
81{
82 unsigned int w;
83 unsigned int h;
84 int alpha;
85 unsigned int color[64];
86};
87
88static const Eet_Test_Image test_noalpha = {
89 8, 8, 0,
90 {
91 0x00AA0000, 0x0000AA00, 0x000000AA, 0x00110000, 0x00AA0000, 0x0000AA00,
92 0x000000AA, 0x00110000,
93 0x0000AA00, 0x000000AA, 0x00110000, 0x00AA0000, 0x0000AA00, 0x000000AA,
94 0x00110000, 0x00AA0000,
95 0x000000AA, 0x00110000, 0x00AA0000, 0x0000AA00, 0x000000AA, 0x00110000,
96 0x00AA0000, 0x0000AA00,
97 0x00110000, 0x00AA0000, 0x0000AA00, 0x000000AA, 0x00110000, 0x00AA0000,
98 0x0000AA00, 0x000000AA,
99 0x00AA0000, 0x0000AA00, 0x000000AA, 0x00110000, 0x00AA0000, 0x0000AA00,
100 0x000000AA, 0x00110000,
101 0x0000AA00, 0x000000AA, 0x00110000, 0x00AA0000, 0x0000AA00, 0x000000AA,
102 0x00110000, 0x00AA0000,
103 0x000000AA, 0x00110000, 0x00AA0000, 0x0000AA00, 0x000000AA, 0x00110000,
104 0x00AA0000, 0x0000AA00,
105 0x00110000, 0x00AA0000, 0x0000AA00, 0x000000AA, 0x00110000, 0x00AA0000,
106 0x0000AA00, 0x000000AA
107 }
108};
109
110static const Eet_Test_Image test_alpha = {
111 8, 8, 1,
112 {
113 0x0FAA0000, 0x0000AA00, 0x000000AA, 0x00110000, 0x00AA0000, 0x0000AA00,
114 0x000000AA, 0x0F110000,
115 0x0000AA00, 0x0F0000AA, 0x00110000, 0x00AA0000, 0x0000AA00, 0x000000AA,
116 0x0F110000, 0x00AA0000,
117 0x000000AA, 0x00110000, 0x0FAA0000, 0x0000AA00, 0x000000AA, 0x0F110000,
118 0x00AA0000, 0x0000AA00,
119 0x00110000, 0x00AA0000, 0x0000AA00, 0x0F0000AA, 0x0F110000, 0x00AA0000,
120 0x0000AA00, 0x000000AA,
121 0x00AA0000, 0x0000AA00, 0x000000AA, 0x0F110000, 0x0FAA0000, 0x0000AA00,
122 0x000000AA, 0x00110000,
123 0x0000AA00, 0x000000AA, 0x0F110000, 0x00AA0000, 0x0000AA00, 0x0F0000AA,
124 0x00110000, 0x00AA0000,
125 0x000000AA, 0x0F110000, 0x00AA0000, 0x0000AA00, 0x000000AA, 0x00110000,
126 0x0FAA0000, 0x0000AA00,
127 0x0F110000, 0x00AA0000, 0x0000AA00, 0x000000AA, 0x00110000, 0x00AA0000,
128 0x0000AA00, 0x0F0000AA
129 }
130};
131
132static void
133_eet_test_basic_set(Eet_Test_Basic_Type *res,
134 int i)
135{
136 res->c = EET_TEST_CHAR;
137 res->s = EET_TEST_SHORT;
138 res->i = EET_TEST_INT + i;
139 res->l = EET_TEST_LONG_LONG;
140 res->str = EET_TEST_STRING;
141 res->istr = EET_TEST_STRING;
142 res->f1 = -EET_TEST_FLOAT;
143 res->d = -EET_TEST_DOUBLE;
144 res->f2 = EET_TEST_FLOAT4;
145 res->uc = EET_TEST_CHAR;
146 res->us = EET_TEST_SHORT;
147 res->ui = EET_TEST_INT;
148 res->ul = EET_TEST_LONG_LONG;
149 res->empty = NULL;
150 res->with = NULL;
151
152 if (i == 0)
153 {
154 Eet_Test_Basic_Type *tmp;
155
156 tmp = malloc(sizeof (Eet_Test_Basic_Type));
157 fail_if(!tmp);
158
159 res->with = tmp;
160 tmp->c = EET_TEST_CHAR;
161 tmp->s = EET_TEST_SHORT;
162 tmp->i = EET_TEST_INT + i + 1;
163 tmp->l = EET_TEST_LONG_LONG;
164 tmp->str = EET_TEST_STRING;
165 tmp->istr = EET_TEST_STRING;
166 tmp->f1 = -EET_TEST_FLOAT;
167 tmp->d = -EET_TEST_DOUBLE;
168 tmp->f2 = EET_TEST_FLOAT4;
169 tmp->uc = EET_TEST_CHAR;
170 tmp->us = EET_TEST_SHORT;
171 tmp->ui = EET_TEST_INT;
172 tmp->ul = EET_TEST_LONG_LONG;
173 tmp->empty = NULL;
174 tmp->with = NULL;
175 }
176} /* _eet_test_basic_set */
177
178static void
179_eet_test_basic_check(Eet_Test_Basic_Type *result,
180 int i)
181{
182 float tmp;
183
184 fail_if(result->c != EET_TEST_CHAR);
185 fail_if(result->s != EET_TEST_SHORT);
186 fail_if(result->i != EET_TEST_INT + i);
187 fail_if(result->l != (long long)EET_TEST_LONG_LONG);
188 fail_if(strcmp(result->str, EET_TEST_STRING) != 0);
189 fail_if(strcmp(result->istr, EET_TEST_STRING) != 0);
190 fail_if(result->uc != EET_TEST_CHAR);
191 fail_if(result->us != EET_TEST_SHORT);
192 fail_if(result->ui != EET_TEST_INT);
193 fail_if(result->ul != EET_TEST_LONG_LONG);
194
195 tmp = (result->f1 + EET_TEST_FLOAT);
196 if (tmp < 0)
197 tmp = -tmp;
198
199 fail_if(tmp > 0.005);
200
201 tmp = (result->f2 - EET_TEST_FLOAT4);
202 if (tmp < 0)
203 tmp = -tmp;
204
205 fail_if(tmp > 0.005);
206
207 tmp = (result->d + EET_TEST_DOUBLE);
208 if (tmp < 0)
209 tmp = -tmp;
210
211 fail_if(tmp > 0.00005);
212
213 fail_if(result->empty != NULL);
214 if (i == 0)
215 {
216 Eet_Test_Basic_Type *tmp2;
217
218 tmp2 = result->with;
219 fail_if(tmp2 == NULL);
220
221 fail_if(tmp2->c != EET_TEST_CHAR);
222 fail_if(tmp2->s != EET_TEST_SHORT);
223 fail_if(tmp2->i != EET_TEST_INT + i + 1);
224 fail_if(tmp2->l != (long long)EET_TEST_LONG_LONG);
225 fail_if(strcmp(tmp2->str, EET_TEST_STRING) != 0);
226 fail_if(strcmp(tmp2->istr, EET_TEST_STRING) != 0);
227 fail_if(tmp2->uc != EET_TEST_CHAR);
228 fail_if(tmp2->us != EET_TEST_SHORT);
229 fail_if(tmp2->ui != EET_TEST_INT);
230 fail_if(tmp2->ul != EET_TEST_LONG_LONG);
231 }
232 else
233 fail_if(result->with != NULL);
234} /* _eet_test_basic_check */
235
236static void
237_eet_build_basic_descriptor(Eet_Data_Descriptor *edd)
238{
239 EET_DATA_DESCRIPTOR_ADD_BASIC(edd,
240 Eet_Test_Basic_Type,
241 "c",
242 c,
243 EET_T_CHAR);
244 EET_DATA_DESCRIPTOR_ADD_BASIC(edd,
245 Eet_Test_Basic_Type,
246 "s",
247 s,
248 EET_T_SHORT);
249 EET_DATA_DESCRIPTOR_ADD_BASIC(edd,
250 Eet_Test_Basic_Type,
251 "i",
252 i,
253 EET_T_INT);
254 EET_DATA_DESCRIPTOR_ADD_BASIC(edd,
255 Eet_Test_Basic_Type,
256 "l",
257 l,
258 EET_T_LONG_LONG);
259 EET_DATA_DESCRIPTOR_ADD_BASIC(edd,
260 Eet_Test_Basic_Type,
261 "str",
262 str,
263 EET_T_STRING);
264 EET_DATA_DESCRIPTOR_ADD_BASIC(edd,
265 Eet_Test_Basic_Type,
266 "istr",
267 istr,
268 EET_T_INLINED_STRING);
269 EET_DATA_DESCRIPTOR_ADD_BASIC(edd,
270 Eet_Test_Basic_Type,
271 "f1",
272 f1,
273 EET_T_FLOAT);
274 EET_DATA_DESCRIPTOR_ADD_BASIC(edd,
275 Eet_Test_Basic_Type,
276 "f2",
277 f2,
278 EET_T_FLOAT);
279 EET_DATA_DESCRIPTOR_ADD_BASIC(edd,
280 Eet_Test_Basic_Type,
281 "d",
282 d,
283 EET_T_DOUBLE);
284 EET_DATA_DESCRIPTOR_ADD_BASIC(edd,
285 Eet_Test_Basic_Type,
286 "uc",
287 uc,
288 EET_T_UCHAR);
289 EET_DATA_DESCRIPTOR_ADD_BASIC(edd,
290 Eet_Test_Basic_Type,
291 "us",
292 us,
293 EET_T_USHORT);
294 EET_DATA_DESCRIPTOR_ADD_BASIC(edd,
295 Eet_Test_Basic_Type,
296 "ui",
297 ui,
298 EET_T_UINT);
299 EET_DATA_DESCRIPTOR_ADD_BASIC(edd,
300 Eet_Test_Basic_Type,
301 "ul",
302 ul,
303 EET_T_ULONG_LONG);
304
305 EET_DATA_DESCRIPTOR_ADD_SUB(edd, Eet_Test_Basic_Type, "empty", empty, edd);
306 EET_DATA_DESCRIPTOR_ADD_SUB(edd, Eet_Test_Basic_Type, "with", with, edd);
307} /* _eet_build_basic_descriptor */
308
309START_TEST(eet_test_basic_data_type_encoding_decoding)
310{
311 Eet_Data_Descriptor *edd;
312 Eet_Test_Basic_Type *result;
313 Eet_Data_Descriptor_Class eddc;
314 Eet_Test_Basic_Type etbt;
315 void *transfert;
316 int size;
317
318 eet_init();
319
320 _eet_test_basic_set(&etbt, 0);
321
322 eet_test_setup_eddc(&eddc);
323 eddc.name = "Eet_Test_Basic_Type";
324 eddc.size = sizeof(Eet_Test_Basic_Type);
325
326 edd = eet_data_descriptor_stream_new(&eddc);
327 fail_if(!edd);
328
329 _eet_build_basic_descriptor(edd);
330
331 transfert = eet_data_descriptor_encode(edd, &etbt, &size);
332 fail_if(!transfert || size <= 0);
333
334 result = eet_data_descriptor_decode(edd, transfert, size);
335 fail_if(!result);
336
337 _eet_test_basic_check(result, 0);
338
339 free(result->str);
340 free(result);
341
342 eet_data_descriptor_free(edd);
343
344 eet_shutdown();
345}
346END_TEST
347
348typedef struct _Eet_Test_Ex_Type Eet_Test_Ex_Type;
349struct _Eet_Test_Ex_Type
350{
351 char c;
352 short s;
353 int i;
354 unsigned long long l;
355 char *str;
356 char *istr;
357 float f1;
358 float f2;
359 float f3;
360 float f4;
361 double d1;
362 double d2;
363 double d3;
364 double d4;
365 Eina_List *list;
366 Eina_Hash *hash;
367 Eina_List *ilist;
368 Eina_List *slist;
369 Eina_Hash *ihash;
370 Eina_Hash *shash;
371 Eet_Test_Basic_Type sarray1[10];
372 unsigned int sarray2[5];
373 unsigned int varray1_count;
374 unsigned int *varray1;
375 unsigned int varray2_count;
376 Eet_Test_Basic_Type *varray2;
377 unsigned char uc;
378 unsigned short us;
379 unsigned int ui;
380 unsigned long long ul;
381 char *charray[10];
382};
383
384static int i42 = 42;
385static int i7 = 7;
386
387static void
388_eet_build_ex_descriptor(Eet_Data_Descriptor *edd)
389{
390 Eet_Data_Descriptor_Class eddc;
391 Eet_Test_Ex_Type etbt;
392 Eet_Data_Descriptor *eddb;
393
394 eet_test_setup_eddc(&eddc);
395 eddc.name = "Eet_Test_Basic_Type";
396 eddc.size = sizeof(Eet_Test_Basic_Type);
397 eddb = eet_data_descriptor_file_new(&eddc);
398 fail_if(!eddb);
399
400 _eet_build_basic_descriptor(eddb);
401
402 EET_DATA_DESCRIPTOR_ADD_BASIC(edd,
403 Eet_Test_Ex_Type,
404 "c",
405 c,
406 EET_T_CHAR);
407 EET_DATA_DESCRIPTOR_ADD_BASIC(edd,
408 Eet_Test_Ex_Type,
409 "s",
410 s,
411 EET_T_SHORT);
412 EET_DATA_DESCRIPTOR_ADD_BASIC(edd, Eet_Test_Ex_Type, "i", i, EET_T_INT);
413 EET_DATA_DESCRIPTOR_ADD_BASIC(edd,
414 Eet_Test_Ex_Type,
415 "l",
416 l,
417 EET_T_LONG_LONG);
418 EET_DATA_DESCRIPTOR_ADD_BASIC(edd,
419 Eet_Test_Ex_Type,
420 "str",
421 str,
422 EET_T_STRING);
423 EET_DATA_DESCRIPTOR_ADD_BASIC(edd,
424 Eet_Test_Ex_Type,
425 "istr",
426 istr,
427 EET_T_INLINED_STRING);
428 EET_DATA_DESCRIPTOR_ADD_BASIC(edd,
429 Eet_Test_Ex_Type,
430 "f1",
431 f1,
432 EET_T_FLOAT);
433 EET_DATA_DESCRIPTOR_ADD_BASIC(edd,
434 Eet_Test_Ex_Type,
435 "f2",
436 f2,
437 EET_T_FLOAT);
438 EET_DATA_DESCRIPTOR_ADD_BASIC(edd,
439 Eet_Test_Ex_Type,
440 "f3",
441 f3,
442 EET_T_FLOAT);
443 EET_DATA_DESCRIPTOR_ADD_BASIC(edd,
444 Eet_Test_Ex_Type,
445 "f4",
446 f4,
447 EET_T_FLOAT);
448 EET_DATA_DESCRIPTOR_ADD_BASIC(edd,
449 Eet_Test_Ex_Type,
450 "d1",
451 d1,
452 EET_T_DOUBLE);
453 EET_DATA_DESCRIPTOR_ADD_BASIC(edd,
454 Eet_Test_Ex_Type,
455 "d2",
456 d2,
457 EET_T_DOUBLE);
458 EET_DATA_DESCRIPTOR_ADD_BASIC(edd,
459 Eet_Test_Ex_Type,
460 "d3",
461 d3,
462 EET_T_DOUBLE);
463 EET_DATA_DESCRIPTOR_ADD_BASIC(edd,
464 Eet_Test_Ex_Type,
465 "d4",
466 d4,
467 EET_T_DOUBLE);
468 EET_DATA_DESCRIPTOR_ADD_BASIC(edd,
469 Eet_Test_Ex_Type,
470 "uc",
471 uc,
472 EET_T_UCHAR);
473 EET_DATA_DESCRIPTOR_ADD_BASIC(edd,
474 Eet_Test_Ex_Type,
475 "us",
476 us,
477 EET_T_USHORT);
478 EET_DATA_DESCRIPTOR_ADD_BASIC(edd,
479 Eet_Test_Ex_Type,
480 "ui",
481 ui,
482 EET_T_UINT);
483 EET_DATA_DESCRIPTOR_ADD_BASIC(edd,
484 Eet_Test_Ex_Type,
485 "ul",
486 ul,
487 EET_T_ULONG_LONG);
488 EET_DATA_DESCRIPTOR_ADD_ARRAY(edd,
489 Eet_Test_Ex_Type,
490 "sarray1",
491 sarray1,
492 eddb);
493 EET_DATA_DESCRIPTOR_ADD_VAR_ARRAY(edd,
494 Eet_Test_Ex_Type,
495 "varray2",
496 varray2,
497 eddb);
498 eet_data_descriptor_element_add(edd,
499 "varray1",
500 EET_T_INT,
501 EET_G_VAR_ARRAY,
502 (char *)(&(etbt.varray1)) - (char *)(&(etbt)),
503 (char *)(&(etbt.varray1_count)) -
504 (char *)(&(etbt)),
505 /* 0, */ NULL,
506 NULL);
507 eet_data_descriptor_element_add(edd, "sarray2", EET_T_INT, EET_G_ARRAY,
508 (char *)(&(etbt.sarray2)) - (char *)(&(etbt)),
509 /* 0, */ sizeof(etbt.sarray2) /
510 sizeof(etbt.sarray2[0]), NULL, NULL);
511 eet_data_descriptor_element_add(edd, "charray", EET_T_STRING, EET_G_ARRAY,
512 (char *)(&(etbt.charray)) - (char *)(&(etbt)),
513 /* 0, */ sizeof(etbt.charray) /
514 sizeof(etbt.charray[0]), NULL, NULL);
515 EET_DATA_DESCRIPTOR_ADD_LIST(edd, Eet_Test_Ex_Type, "list", list, edd);
516 EET_DATA_DESCRIPTOR_ADD_HASH(edd, Eet_Test_Ex_Type, "hash", hash, edd);
517 eet_data_descriptor_element_add(edd, "ilist", EET_T_INT, EET_G_LIST,
518 (char *)(&(etbt.ilist)) - (char *)(&(etbt)),
519 0, /* 0, */ NULL, NULL);
520 eet_data_descriptor_element_add(edd, "ihash", EET_T_INT, EET_G_HASH,
521 (char *)(&(etbt.ihash)) - (char *)(&(etbt)),
522 0, /* 0, */ NULL, NULL);
523 eet_data_descriptor_element_add(edd, "slist", EET_T_STRING, EET_G_LIST,
524 (char *)(&(etbt.slist)) - (char *)(&(etbt)),
525 0, /* 0, */ NULL, NULL);
526 eet_data_descriptor_element_add(edd, "shash", EET_T_STRING, EET_G_HASH,
527 (char *)(&(etbt.shash)) - (char *)(&(etbt)),
528 0, /* 0, */ NULL, NULL);
529} /* _eet_build_ex_descriptor */
530
531static Eet_Test_Ex_Type *
532_eet_test_ex_set(Eet_Test_Ex_Type *res,
533 int offset)
534{
535 unsigned int i;
536
537 if (!res)
538 res = malloc(sizeof(Eet_Test_Ex_Type));
539
540 if (!res)
541 return NULL;
542
543 res->c = EET_TEST_CHAR + offset;
544 res->s = EET_TEST_SHORT + offset;
545 res->i = EET_TEST_INT + offset;
546 res->l = EET_TEST_LONG_LONG + offset;
547 res->str = EET_TEST_STRING;
548 res->istr = EET_TEST_STRING;
549 res->f1 = EET_TEST_FLOAT + offset;
550 res->f2 = -(EET_TEST_FLOAT2 + offset);
551 res->f3 = EET_TEST_FLOAT3 + offset;
552 res->f4 = EET_TEST_FLOAT2 + offset;
553 res->d1 = EET_TEST_DOUBLE + offset;
554 res->d2 = -(EET_TEST_DOUBLE2 + offset);
555 res->d3 = EET_TEST_DOUBLE3 + offset;
556 res->d4 = EET_TEST_DOUBLE2 + offset;
557 res->list = NULL;
558 res->hash = NULL;
559 res->ilist = NULL;
560 res->ihash = NULL;
561 res->slist = NULL;
562 res->shash = NULL;
563 for (i = 0; i < sizeof(res->charray) / sizeof(res->charray[0]); ++i)
564 res->charray[i] = NULL;
565
566 res->varray2 = malloc(sizeof (Eet_Test_Basic_Type) * 10);
567 res->varray1 = malloc(sizeof (int) * 5);
568 fail_if(!res->varray1 || !res->varray2);
569 for (i = 0; i < 10; ++i)
570 {
571 _eet_test_basic_set(res->sarray1 + i, i);
572 _eet_test_basic_set(res->varray2 + i, i);
573 }
574 res->varray2_count = 10;
575 for (i = 0; i < 5; ++i)
576 {
577 res->sarray2[i] = i * 42 + 1;
578 res->varray1[i] = i * 42 + 1;
579 }
580 res->varray1_count = 5;
581
582 res->uc = EET_TEST_CHAR + offset;
583 res->us = EET_TEST_SHORT + offset;
584 res->ui = EET_TEST_INT + offset;
585 res->ul = EET_TEST_LONG_LONG + offset;
586
587 return res;
588} /* _eet_test_ex_set */
589
590static int
591_eet_test_ex_check(Eet_Test_Ex_Type *stuff,
592 int offset)
593{
594 double tmp;
595 unsigned int i;
596
597 if (!stuff)
598 return 1;
599
600 if (stuff->c != EET_TEST_CHAR + offset)
601 return 1;
602
603 if (stuff->s != EET_TEST_SHORT + offset)
604 return 1;
605
606 if (stuff->i != EET_TEST_INT + offset)
607 return 1;
608
609 if (stuff->l != EET_TEST_LONG_LONG + offset)
610 return 1;
611
612 if (strcmp(stuff->str, EET_TEST_STRING) != 0)
613 return 1;
614
615 if (strcmp(stuff->istr, EET_TEST_STRING) != 0)
616 return 1;
617
618 tmp = stuff->f1 - (EET_TEST_FLOAT + offset);
619 if (tmp < 0)
620 tmp = -tmp;
621
622 if (tmp > 0.005)
623 return 1;
624
625 tmp = stuff->d1 - (EET_TEST_DOUBLE + offset);
626 if (tmp < 0)
627 tmp = -tmp;
628
629 if (tmp > 0.00005)
630 return 1;
631
632 if (stuff->f2 != -(EET_TEST_FLOAT2 + offset))
633 return 1;
634
635 if (stuff->d2 != -(EET_TEST_DOUBLE2 + offset))
636 return 1;
637
638 if (stuff->f3 != EET_TEST_FLOAT3 + offset)
639 return 1;
640
641 if (stuff->d3 != EET_TEST_DOUBLE3 + offset)
642 return 1;
643
644 if (stuff->f4 != EET_TEST_FLOAT2 + offset)
645 return 1;
646
647 if (stuff->d4 != EET_TEST_DOUBLE2 + offset)
648 return 1;
649
650 if (stuff->uc != EET_TEST_CHAR + offset)
651 return 1;
652
653 if (stuff->us != EET_TEST_SHORT + offset)
654 return 1;
655
656 if (stuff->ui != (unsigned int)EET_TEST_INT + offset)
657 return 1;
658
659 if (stuff->ul != EET_TEST_LONG_LONG + offset)
660 return 1;
661
662 if (stuff->varray1_count != 5)
663 return 1;
664
665 if (stuff->varray2_count != 10)
666 return 1;
667
668 for (i = 0; i < 5; ++i)
669 if (stuff->sarray2[i] != i * 42 + 1 && stuff->varray1[i] != i * 42 + 1)
670 return 1;
671
672 for (i = 0; i < 10; ++i)
673 {
674 _eet_test_basic_check(stuff->sarray1 + i, i);
675 _eet_test_basic_check(stuff->varray2 + i, i);
676 }
677
678 return 0;
679} /* _eet_test_ex_check */
680
681static Eina_Bool
682func(__UNUSED__ const Eina_Hash *hash,
683 const void *key,
684 void *data,
685 void *fdata)
686{
687 int *res = fdata;
688
689 if (strcmp(key, EET_TEST_KEY1) != 0
690 && strcmp(key, EET_TEST_KEY2) != 0)
691 *res = 1;
692
693 if (_eet_test_ex_check(data, 2))
694 *res = 1;
695
696 return EINA_TRUE;
697} /* func */
698
699static Eina_Bool
700func7(__UNUSED__ const Eina_Hash *hash,
701 __UNUSED__ const void *key,
702 void *data,
703 void *fdata)
704{
705 int *res = fdata;
706 int *val;
707
708 val = data;
709 if (!val)
710 *res = 1;
711
712 if (*val != 7)
713 *res = 1;
714
715 return EINA_TRUE;
716} /* func7 */
717
718START_TEST(eet_test_data_type_encoding_decoding)
719{
720 Eet_Data_Descriptor *edd;
721 Eet_Test_Ex_Type *result;
722 void *transfert;
723 Eet_Data_Descriptor_Class eddc;
724 Eet_Test_Ex_Type etbt;
725 int size;
726 int test;
727
728 eet_init();
729
730 _eet_test_ex_set(&etbt, 0);
731 etbt.list = eina_list_prepend(etbt.list, _eet_test_ex_set(NULL, 1));
732 etbt.hash = eina_hash_string_superfast_new(NULL);
733 eina_hash_add(etbt.hash, EET_TEST_KEY1, _eet_test_ex_set(NULL, 2));
734 etbt.ilist = eina_list_prepend(etbt.ilist, &i42);
735 etbt.ihash = eina_hash_string_superfast_new(NULL);
736 eina_hash_add(etbt.ihash, EET_TEST_KEY1, &i7);
737 etbt.slist = eina_list_prepend(NULL, "test");
738 etbt.shash = eina_hash_string_superfast_new(NULL);
739 eina_hash_add(etbt.shash, EET_TEST_KEY1, "test");
740 memset(&etbt.charray, 0, sizeof(etbt.charray));
741 etbt.charray[0] = "test";
742 etbt.charray[5] = "plouf";
743
744 eet_test_setup_eddc(&eddc);
745 eddc.name = "Eet_Test_Ex_Type";
746 eddc.size = sizeof(Eet_Test_Ex_Type);
747
748 edd = eet_data_descriptor_file_new(&eddc);
749 fail_if(!edd);
750
751 _eet_build_ex_descriptor(edd);
752
753 transfert = eet_data_descriptor_encode(edd, &etbt, &size);
754 fail_if(!transfert || size <= 0);
755
756 result = eet_data_descriptor_decode(edd, transfert, size);
757 fail_if(!result);
758
759 fail_if(_eet_test_ex_check(result, 0) != 0);
760 fail_if(_eet_test_ex_check(eina_list_data_get(result->list), 1) != 0);
761 fail_if(eina_list_data_get(result->ilist) == NULL);
762 fail_if(*((int *)eina_list_data_get(result->ilist)) != 42);
763 fail_if(eina_list_data_get(result->slist) == NULL);
764 fail_if(strcmp(eina_list_data_get(result->slist), "test") != 0);
765 fail_if(eina_hash_find(result->shash, EET_TEST_KEY1) == NULL);
766 fail_if(strcmp(eina_hash_find(result->shash, EET_TEST_KEY1), "test") != 0);
767 fail_if(strcmp(result->charray[0], "test") != 0);
768 fail_if(strcmp(result->charray[5], "plouf") != 0);
769
770 test = 0;
771 if (result->hash)
772 eina_hash_foreach(result->hash, func, &test);
773
774 fail_if(test != 0);
775 if (result->ihash)
776 eina_hash_foreach(result->ihash, func7, &test);
777
778 fail_if(test != 0);
779
780 eet_shutdown();
781}
782END_TEST
783
784static void
785append_string(void *data,
786 const char *str)
787{
788 char **string = data;
789 int length;
790
791 if (!data)
792 return;
793
794 length = *string ? strlen(*string) : 0;
795 *string = realloc(*string, strlen(str) + length + 1);
796
797 memcpy((*string) + length, str, strlen(str) + 1);
798} /* append_string */
799
800START_TEST(eet_test_data_type_dump_undump)
801{
802 Eet_Data_Descriptor *edd;
803 Eet_Test_Ex_Type *result;
804 Eet_Data_Descriptor_Class eddc;
805 Eet_Test_Ex_Type etbt;
806 char *transfert1;
807 char *transfert2;
808 char *string1;
809 char *string2;
810 int size1;
811 int size2;
812 int test;
813
814 eet_init();
815
816 _eet_test_ex_set(&etbt, 0);
817 etbt.list = eina_list_prepend(etbt.list, _eet_test_ex_set(NULL, 1));
818 etbt.list = eina_list_prepend(etbt.list, _eet_test_ex_set(NULL, 1));
819 etbt.hash = eina_hash_string_superfast_new(NULL);
820 eina_hash_add(etbt.hash, EET_TEST_KEY1, _eet_test_ex_set(NULL, 2));
821 etbt.hash = eina_hash_string_superfast_new(NULL);
822 eina_hash_add(etbt.hash, EET_TEST_KEY2, _eet_test_ex_set(NULL, 2));
823 etbt.ilist = eina_list_prepend(etbt.ilist, &i42);
824 etbt.ilist = eina_list_prepend(etbt.ilist, &i42);
825 etbt.ihash = eina_hash_string_superfast_new(NULL);
826 eina_hash_add(etbt.ihash, EET_TEST_KEY1, &i7);
827 etbt.ihash = eina_hash_string_superfast_new(NULL);
828 eina_hash_add(etbt.ihash, EET_TEST_KEY2, &i7);
829 etbt.slist = eina_list_prepend(NULL, "test");
830 etbt.shash = eina_hash_string_superfast_new(NULL);
831 eina_hash_add(etbt.shash, EET_TEST_KEY1, "test");
832 memset(&etbt.charray, 0, sizeof(etbt.charray));
833 etbt.charray[0] = "test";
834
835 eet_test_setup_eddc(&eddc);
836 eddc.name = "Eet_Test_Ex_Type";
837 eddc.size = sizeof(Eet_Test_Ex_Type);
838
839 edd = eet_data_descriptor_file_new(&eddc);
840 fail_if(!edd);
841
842 _eet_build_ex_descriptor(edd);
843
844 transfert1 = eet_data_descriptor_encode(edd, &etbt, &size1);
845 fail_if(!transfert1 || size1 <= 0);
846
847 string1 = NULL;
848 eet_data_text_dump(transfert1, size1, append_string, &string1);
849 fail_if(!string1);
850
851 transfert2 = eet_data_text_undump(string1, string1 ? strlen(
852 string1) : 0, &size2);
853 fail_if(!transfert2 && size2 <= 0);
854
855 string2 = NULL;
856 eet_data_text_dump(transfert2, size2, append_string, &string2);
857 fail_if(!string2);
858
859 fail_if(strlen(string2) != strlen(string1));
860
861 result = eet_data_descriptor_decode(edd, transfert2, size2);
862 fail_if(!result);
863
864 fail_if(_eet_test_ex_check(result, 0) != 0);
865 fail_if(_eet_test_ex_check(eina_list_data_get(result->list), 1) != 0);
866 fail_if(eina_list_data_get(result->ilist) == NULL);
867 fail_if(*((int *)eina_list_data_get(result->ilist)) != 42);
868 fail_if(eina_list_data_get(result->slist) == NULL);
869 fail_if(strcmp(eina_list_data_get(result->slist), "test") != 0);
870 fail_if(eina_hash_find(result->shash, EET_TEST_KEY1) == NULL);
871 fail_if(strcmp(eina_hash_find(result->shash, EET_TEST_KEY1), "test") != 0);
872 fail_if(strcmp(result->charray[0], "test") != 0);
873
874 test = 0;
875 if (result->hash)
876 eina_hash_foreach(result->hash, func, &test);
877
878 fail_if(test != 0);
879 if (result->ihash)
880 eina_hash_foreach(result->ihash, func7, &test);
881
882 fail_if(test != 0);
883
884 eet_shutdown();
885}
886END_TEST
887START_TEST(eet_file_simple_write)
888{
889 const char *buffer = "Here is a string of data to save !";
890 Eet_File *ef;
891 char *test;
892 char *file = strdup("/tmp/eet_suite_testXXXXXX");
893 int size;
894
895 eet_init();
896
897 fail_if(!(file = tmpnam(file)));
898
899 fail_if(eet_mode_get(NULL) != EET_FILE_MODE_INVALID);
900
901 ef = eet_open(file, EET_FILE_MODE_WRITE);
902 fail_if(!ef);
903
904 fail_if(!eet_write(ef, "keys/tests", buffer, strlen(buffer) + 1, 1));
905 fail_if(!eet_alias(ef, "keys/alias", "keys/tests", 0));
906 fail_if(!eet_alias(ef, "keys/alias2", "keys/alias", 1));
907
908 fail_if(eet_mode_get(ef) != EET_FILE_MODE_WRITE);
909
910 fail_if(eet_list(ef, "*", &size) != NULL);
911 fail_if(eet_num_entries(ef) != -1);
912
913 eet_close(ef);
914
915 /* Test read of simple file */
916 ef = eet_open(file, EET_FILE_MODE_READ);
917 fail_if(!ef);
918
919 test = eet_read(ef, "keys/tests", &size);
920 fail_if(!test);
921 fail_if(size != (int)strlen(buffer) + 1);
922
923 fail_if(memcmp(test, buffer, strlen(buffer) + 1) != 0);
924
925 test = eet_read(ef, "keys/alias2", &size);
926 fail_if(!test);
927 fail_if(size != (int)strlen(buffer) + 1);
928
929 fail_if(eet_read_direct(ef, "key/alias2", &size));
930
931 fail_if(eet_mode_get(ef) != EET_FILE_MODE_READ);
932 fail_if(eet_num_entries(ef) != 3);
933
934 eet_close(ef);
935
936 /* Test eet cache system */
937 ef = eet_open(file, EET_FILE_MODE_READ);
938 fail_if(!ef);
939
940 test = eet_read(ef, "keys/tests", &size);
941 fail_if(!test);
942 fail_if(size != (int)strlen(buffer) + 1);
943
944 fail_if(memcmp(test, buffer, strlen(buffer) + 1) != 0);
945
946 eet_close(ef);
947
948 fail_if(unlink(file) != 0);
949
950 eet_shutdown();
951} /* START_TEST */
952
953END_TEST
954START_TEST(eet_file_data_test)
955{
956 Eet_Data_Descriptor *edd;
957 Eet_Test_Ex_Type *result;
958 Eet_Dictionary *ed;
959 Eet_File *ef;
960 char **list;
961 char *file = strdup("/tmp/eet_suite_testXXXXXX");
962 Eet_Data_Descriptor_Class eddc;
963 Eet_Test_Ex_Type etbt;
964 int size;
965 int test;
966
967 eet_init();
968
969 _eet_test_ex_set(&etbt, 0);
970 etbt.list = eina_list_prepend(etbt.list, _eet_test_ex_set(NULL, 1));
971 etbt.list = eina_list_prepend(etbt.list, _eet_test_ex_set(NULL, 1));
972 etbt.hash = eina_hash_string_superfast_new(NULL);
973 eina_hash_add(etbt.hash, EET_TEST_KEY1, _eet_test_ex_set(NULL, 2));
974 etbt.hash = eina_hash_string_superfast_new(NULL);
975 eina_hash_add(etbt.hash, EET_TEST_KEY2, _eet_test_ex_set(NULL, 2));
976 etbt.ilist = eina_list_prepend(etbt.ilist, &i42);
977 etbt.ilist = eina_list_prepend(etbt.ilist, &i42);
978 etbt.ihash = eina_hash_string_superfast_new(NULL);
979 eina_hash_add(etbt.ihash, EET_TEST_KEY1, &i7);
980 etbt.ihash = eina_hash_string_superfast_new(NULL);
981 eina_hash_add(etbt.ihash, EET_TEST_KEY2, &i7);
982 etbt.slist = eina_list_prepend(NULL, "test");
983 etbt.shash = eina_hash_string_superfast_new(NULL);
984 eina_hash_add(etbt.shash, EET_TEST_KEY1, "test");
985 memset(&etbt.charray, 0, sizeof(etbt.charray));
986 etbt.charray[0] = "test";
987
988 eet_test_setup_eddc(&eddc);
989 eddc.name = "Eet_Test_Ex_Type";
990 eddc.size = sizeof(Eet_Test_Ex_Type);
991
992 edd = eet_data_descriptor_file_new(&eddc);
993 fail_if(!edd);
994
995 _eet_build_ex_descriptor(edd);
996
997 fail_if(!(file = tmpnam(file)));
998
999 /* Insert an error in etbt. */
1000 etbt.i = 0;
1001
1002 /* Save the encoded data in a file. */
1003 ef = eet_open(file, EET_FILE_MODE_READ_WRITE);
1004 fail_if(!ef);
1005
1006 fail_if(!eet_data_write(ef, edd, EET_TEST_FILE_KEY1, &etbt, 0));
1007
1008 result = eet_data_read(ef, edd, EET_TEST_FILE_KEY1);
1009 fail_if(!result);
1010
1011 fail_if(eet_mode_get(ef) != EET_FILE_MODE_READ_WRITE);
1012
1013 /* Test string space. */
1014 ed = eet_dictionary_get(ef);
1015
1016 fail_if(!eet_dictionary_string_check(ed, result->str));
1017 fail_if(eet_dictionary_string_check(ed, result->istr));
1018
1019 eet_close(ef);
1020
1021 /* Attempt to replace etbt by the correct one. */
1022 etbt.i = EET_TEST_INT;
1023
1024 ef = eet_open(file, EET_FILE_MODE_READ_WRITE);
1025 fail_if(!ef);
1026
1027 fail_if(!eet_data_write(ef, edd, EET_TEST_FILE_KEY1, &etbt, 0));
1028
1029 result = eet_data_read(ef, edd, EET_TEST_FILE_KEY1);
1030 fail_if(!result);
1031
1032 /* Test the resulting data. */
1033 fail_if(_eet_test_ex_check(result, 0) != 0);
1034
1035 eet_close(ef);
1036
1037 /* Read back the data. */
1038 ef = eet_open(file, EET_FILE_MODE_READ_WRITE);
1039 fail_if(!ef);
1040
1041 fail_if(!eet_data_write(ef, edd, EET_TEST_FILE_KEY2, &etbt, 0));
1042
1043 result = eet_data_read(ef, edd, EET_TEST_FILE_KEY1);
1044 fail_if(!result);
1045
1046 /* Test string space. */
1047 ed = eet_dictionary_get(ef);
1048 fail_if(!ed);
1049
1050 fail_if(!eet_dictionary_string_check(ed, result->str));
1051 fail_if(eet_dictionary_string_check(ed, result->istr));
1052
1053 /* Test the resulting data. */
1054 fail_if(_eet_test_ex_check(result, 0) != 0);
1055 fail_if(_eet_test_ex_check(eina_list_data_get(result->list), 1) != 0);
1056 fail_if(eina_list_data_get(result->ilist) == NULL);
1057 fail_if(*((int *)eina_list_data_get(result->ilist)) != 42);
1058 fail_if(eina_list_data_get(result->slist) == NULL);
1059 fail_if(strcmp(eina_list_data_get(result->slist), "test") != 0);
1060 fail_if(eina_hash_find(result->shash, EET_TEST_KEY1) == NULL);
1061 fail_if(strcmp(eina_hash_find(result->shash, EET_TEST_KEY1), "test") != 0);
1062 fail_if(strcmp(result->charray[0], "test") != 0);
1063
1064 test = 0;
1065 if (result->hash)
1066 eina_hash_foreach(result->hash, func, &test);
1067
1068 fail_if(test != 0);
1069 if (result->ihash)
1070 eina_hash_foreach(result->ihash, func7, &test);
1071
1072 fail_if(test != 0);
1073
1074 list = eet_list(ef, "keys/*", &size);
1075 fail_if(eet_num_entries(ef) != 2);
1076 fail_if(size != 2);
1077 fail_if(!(strcmp(list[0],
1078 EET_TEST_FILE_KEY1) == 0 &&
1079 strcmp(list[1], EET_TEST_FILE_KEY2) == 0)
1080 && !(strcmp(list[0],
1081 EET_TEST_FILE_KEY2) == 0 &&
1082 strcmp(list[1], EET_TEST_FILE_KEY1) == 0));
1083 free(list);
1084
1085 fail_if(eet_delete(ef, NULL) != 0);
1086 fail_if(eet_delete(NULL, EET_TEST_FILE_KEY1) != 0);
1087 fail_if(eet_delete(ef, EET_TEST_FILE_KEY1) == 0);
1088
1089 list = eet_list(ef, "keys/*", &size);
1090 fail_if(size != 1);
1091 fail_if(eet_num_entries(ef) != 1);
1092
1093 /* Test some more wrong case */
1094 fail_if(eet_data_read(ef, edd, "plop") != NULL);
1095 fail_if(eet_data_read(ef, edd, EET_TEST_FILE_KEY1) != NULL);
1096
1097 /* Reinsert and reread data */
1098 fail_if(!eet_data_write(ef, edd, EET_TEST_FILE_KEY1, &etbt, 0));
1099 fail_if(eet_data_read(ef, edd, EET_TEST_FILE_KEY1) == NULL);
1100 fail_if(eet_read_direct(ef, EET_TEST_FILE_KEY1, &size) == NULL);
1101
1102 eet_close(ef);
1103
1104 fail_if(unlink(file) != 0);
1105
1106 eet_shutdown();
1107} /* START_TEST */
1108
1109END_TEST
1110START_TEST(eet_file_data_dump_test)
1111{
1112 Eet_Data_Descriptor *edd;
1113 Eet_Test_Ex_Type *result;
1114 Eet_Data_Descriptor_Class eddc;
1115 Eet_Test_Ex_Type etbt;
1116 Eet_File *ef;
1117 char *string1;
1118 char *file = strdup("/tmp/eet_suite_testXXXXXX");
1119 int test;
1120
1121 eet_init();
1122
1123 _eet_test_ex_set(&etbt, 0);
1124 etbt.list = eina_list_prepend(etbt.list, _eet_test_ex_set(NULL, 1));
1125 etbt.list = eina_list_prepend(etbt.list, _eet_test_ex_set(NULL, 1));
1126 etbt.hash = eina_hash_string_superfast_new(NULL);
1127 eina_hash_add(etbt.hash, EET_TEST_KEY1, _eet_test_ex_set(NULL, 2));
1128 eina_hash_add(etbt.hash, EET_TEST_KEY2, _eet_test_ex_set(NULL, 2));
1129 etbt.ilist = eina_list_prepend(etbt.ilist, &i42);
1130 etbt.ilist = eina_list_prepend(etbt.ilist, &i42);
1131 etbt.ihash = eina_hash_string_superfast_new(NULL);
1132 eina_hash_add(etbt.ihash, EET_TEST_KEY1, &i7);
1133 eina_hash_add(etbt.ihash, EET_TEST_KEY2, &i7);
1134 etbt.slist = eina_list_prepend(NULL, "test");
1135 etbt.shash = eina_hash_string_superfast_new(NULL);
1136 eina_hash_add(etbt.shash, EET_TEST_KEY1, "test");
1137 memset(&etbt.charray, 0, sizeof(etbt.charray));
1138 etbt.charray[0] = "test";
1139
1140 eet_eina_file_data_descriptor_class_set(&eddc, sizeof (eddc),
1141 "Eet_Test_Ex_Type",
1142 sizeof(Eet_Test_Ex_Type));
1143
1144 edd = eet_data_descriptor_file_new(&eddc);
1145 fail_if(!edd);
1146
1147 _eet_build_ex_descriptor(edd);
1148
1149 fail_if(!(file = tmpnam(file)));
1150
1151 /* Save the encoded data in a file. */
1152 ef = eet_open(file, EET_FILE_MODE_WRITE);
1153 fail_if(!ef);
1154
1155 fail_if(!eet_data_write(ef, edd, EET_TEST_FILE_KEY1, &etbt, 0));
1156
1157 eet_close(ef);
1158
1159 /* Use dump/undump in the middle */
1160 ef = eet_open(file, EET_FILE_MODE_READ_WRITE);
1161 fail_if(!ef);
1162
1163 string1 = NULL;
1164 fail_if(eet_data_dump(ef, EET_TEST_FILE_KEY1, append_string, &string1) != 1);
1165 fail_if(eet_delete(ef, EET_TEST_FILE_KEY1) == 0);
1166 fail_if(!eet_data_undump(ef, EET_TEST_FILE_KEY1, string1, strlen(string1), 1));
1167
1168 eet_close(ef);
1169
1170 /* Test the correctness of the reinsertion. */
1171 ef = eet_open(file, EET_FILE_MODE_READ);
1172 fail_if(!ef);
1173
1174 result = eet_data_read(ef, edd, EET_TEST_FILE_KEY1);
1175 fail_if(!result);
1176
1177 eet_close(ef);
1178
1179 /* Test the resulting data. */
1180 fail_if(_eet_test_ex_check(result, 0) != 0);
1181 fail_if(_eet_test_ex_check(eina_list_data_get(result->list), 1) != 0);
1182 fail_if(eina_list_data_get(result->ilist) == NULL);
1183 fail_if(*((int *)eina_list_data_get(result->ilist)) != 42);
1184 fail_if(eina_list_data_get(result->slist) == NULL);
1185 fail_if(strcmp(eina_list_data_get(result->slist), "test") != 0);
1186 fail_if(eina_hash_find(result->shash, EET_TEST_KEY1) == NULL);
1187 fail_if(strcmp(eina_hash_find(result->shash, EET_TEST_KEY1), "test") != 0);
1188 fail_if(strcmp(result->charray[0], "test") != 0);
1189
1190 test = 0;
1191 if (result->hash)
1192 eina_hash_foreach(result->hash, func, &test);
1193
1194 fail_if(test != 0);
1195 if (result->ihash)
1196 eina_hash_foreach(result->ihash, func7, &test);
1197
1198 fail_if(test != 0);
1199
1200 fail_if(unlink(file) != 0);
1201
1202 eet_shutdown();
1203} /* START_TEST */
1204
1205END_TEST
1206START_TEST(eet_image)
1207{
1208 Eet_File *ef;
1209 char *file = strdup("/tmp/eet_suite_testXXXXXX");
1210 unsigned int *data;
1211 int compress;
1212 int quality;
1213 int result;
1214 int lossy;
1215 int alpha;
1216 unsigned int w;
1217 unsigned int h;
1218
1219 eet_init();
1220
1221 fail_if(!(file = tmpnam(file)));
1222
1223 /* Save the encoded data in a file. */
1224 ef = eet_open(file, EET_FILE_MODE_READ_WRITE);
1225 fail_if(!ef);
1226
1227 result = eet_data_image_write(ef,
1228 EET_TEST_FILE_IMAGE "0",
1229 test_noalpha.color,
1230 test_noalpha.w,
1231 test_noalpha.h,
1232 test_noalpha.alpha,
1233 0,
1234 100,
1235 0);
1236 fail_if(result == 0);
1237
1238 result = eet_data_image_write(ef,
1239 EET_TEST_FILE_IMAGE "1",
1240 test_noalpha.color,
1241 test_noalpha.w,
1242 test_noalpha.h,
1243 test_noalpha.alpha,
1244 5,
1245 100,
1246 0);
1247 fail_if(result == 0);
1248
1249 result = eet_data_image_write(ef,
1250 EET_TEST_FILE_IMAGE "2",
1251 test_noalpha.color,
1252 test_noalpha.w,
1253 test_noalpha.h,
1254 test_noalpha.alpha,
1255 9,
1256 100,
1257 0);
1258 fail_if(result == 0);
1259
1260 result = eet_data_image_write(ef,
1261 EET_TEST_FILE_IMAGE "3",
1262 test_noalpha.color,
1263 test_noalpha.w,
1264 test_noalpha.h,
1265 test_noalpha.alpha,
1266 0,
1267 100,
1268 1);
1269 fail_if(result == 0);
1270
1271 result = eet_data_image_write(ef,
1272 EET_TEST_FILE_IMAGE "4",
1273 test_noalpha.color,
1274 test_noalpha.w,
1275 test_noalpha.h,
1276 test_noalpha.alpha,
1277 0,
1278 60,
1279 1);
1280 fail_if(result == 0);
1281
1282 result = eet_data_image_write(ef,
1283 EET_TEST_FILE_IMAGE "5",
1284 test_noalpha.color,
1285 test_noalpha.w,
1286 test_noalpha.h,
1287 test_noalpha.alpha,
1288 0,
1289 10,
1290 1);
1291 fail_if(result == 0);
1292
1293 result = eet_data_image_write(ef,
1294 EET_TEST_FILE_IMAGE "6",
1295 test_noalpha.color,
1296 test_noalpha.w,
1297 test_noalpha.h,
1298 test_noalpha.alpha,
1299 0,
1300 0,
1301 1);
1302 fail_if(result == 0);
1303
1304 result = eet_data_image_write(ef, EET_TEST_FILE_IMAGE "7", test_alpha.color,
1305 test_alpha.w, test_alpha.h, test_alpha.alpha,
1306 9, 100, 0);
1307 fail_if(result == 0);
1308
1309 result = eet_data_image_write(ef, EET_TEST_FILE_IMAGE "8", test_alpha.color,
1310 test_alpha.w, test_alpha.h, test_alpha.alpha,
1311 0, 80, 1);
1312 fail_if(result == 0);
1313
1314 result = eet_data_image_write(ef, EET_TEST_FILE_IMAGE "9", test_alpha.color,
1315 test_alpha.w, test_alpha.h, test_alpha.alpha,
1316 0, 100, 1);
1317 fail_if(result == 0);
1318
1319 data = eet_data_image_read(ef,
1320 EET_TEST_FILE_IMAGE "2",
1321 &w,
1322 &h,
1323 &alpha,
1324 &compress,
1325 &quality,
1326 &lossy);
1327 fail_if(data == NULL);
1328 fail_if(w != test_noalpha.w);
1329 fail_if(h != test_noalpha.h);
1330 fail_if(alpha != test_noalpha.alpha);
1331 fail_if(compress != 9);
1332 fail_if(lossy != 0);
1333 fail_if(data[0] != test_noalpha.color[0]);
1334 free(data);
1335
1336 result = eet_data_image_header_read(ef,
1337 EET_TEST_FILE_IMAGE "2",
1338 &w,
1339 &h,
1340 &alpha,
1341 &compress,
1342 &quality,
1343 &lossy);
1344 fail_if(result == 0);
1345 fail_if(w != test_noalpha.w);
1346 fail_if(h != test_noalpha.h);
1347 fail_if(alpha != test_noalpha.alpha);
1348 fail_if(compress != 9);
1349 fail_if(lossy != 0);
1350
1351 eet_close(ef);
1352
1353 /* Test read of image */
1354 ef = eet_open(file, EET_FILE_MODE_READ);
1355 fail_if(!ef);
1356
1357 result = eet_data_image_header_read(ef,
1358 EET_TEST_FILE_IMAGE "0",
1359 &w,
1360 &h,
1361 &alpha,
1362 &compress,
1363 &quality,
1364 &lossy);
1365 fail_if(result == 0);
1366 fail_if(w != test_noalpha.w);
1367 fail_if(h != test_noalpha.h);
1368 fail_if(alpha != test_noalpha.alpha);
1369 fail_if(compress != 0);
1370 fail_if(lossy != 0);
1371
1372 data = malloc(w * h * 4);
1373 fail_if(data == NULL);
1374 result = eet_data_image_read_to_surface(ef,
1375 EET_TEST_FILE_IMAGE "0",
1376 4,
1377 4,
1378 data,
1379 2,
1380 2,
1381 w * 4,
1382 &alpha,
1383 &compress,
1384 &quality,
1385 &lossy);
1386 fail_if(result != 1);
1387 fail_if(alpha != test_noalpha.alpha);
1388 fail_if(compress != 0);
1389 fail_if(quality != 100);
1390 fail_if(lossy != 0);
1391 fail_if(data[0] != test_noalpha.color[4 + 4 * w]);
1392 free(data);
1393
1394 data = malloc(w * h * 4);
1395 fail_if(data == NULL);
1396 result = eet_data_image_read_to_surface(ef,
1397 EET_TEST_FILE_IMAGE "0",
1398 0,
1399 0,
1400 data,
1401 w,
1402 h,
1403 w * 4,
1404 &alpha,
1405 &compress,
1406 &quality,
1407 &lossy);
1408 fail_if(result != 1);
1409 fail_if(alpha != test_noalpha.alpha);
1410 fail_if(compress != 0);
1411 fail_if(quality != 100);
1412 fail_if(lossy != 0);
1413 fail_if(data[0] != test_noalpha.color[0]);
1414 free(data);
1415
1416 data = eet_data_image_read(ef,
1417 EET_TEST_FILE_IMAGE "1",
1418 &w,
1419 &h,
1420 &alpha,
1421 &compress,
1422 &quality,
1423 &lossy);
1424 fail_if(data == NULL);
1425 fail_if(w != test_noalpha.w);
1426 fail_if(h != test_noalpha.h);
1427 fail_if(alpha != test_noalpha.alpha);
1428 fail_if(compress != 5);
1429 fail_if(quality != 100);
1430 fail_if(lossy != 0);
1431 fail_if(data[0] != test_noalpha.color[0]);
1432 free(data);
1433
1434 data = eet_data_image_read(ef,
1435 EET_TEST_FILE_IMAGE "2",
1436 &w,
1437 &h,
1438 &alpha,
1439 &compress,
1440 &quality,
1441 &lossy);
1442 fail_if(data == NULL);
1443 fail_if(w != test_noalpha.w);
1444 fail_if(h != test_noalpha.h);
1445 fail_if(alpha != test_noalpha.alpha);
1446 fail_if(compress != 9);
1447 fail_if(lossy != 0);
1448 fail_if(data[0] != test_noalpha.color[0]);
1449 free(data);
1450
1451 data = eet_data_image_read(ef,
1452 EET_TEST_FILE_IMAGE "3",
1453 &w,
1454 &h,
1455 &alpha,
1456 &compress,
1457 &quality,
1458 &lossy);
1459 fail_if(data == NULL);
1460 fail_if(w != test_noalpha.w);
1461 fail_if(h != test_noalpha.h);
1462 fail_if(alpha != test_noalpha.alpha);
1463 fail_if(lossy != 1);
1464 free(data);
1465
1466 data = eet_data_image_read(ef,
1467 EET_TEST_FILE_IMAGE "5",
1468 &w,
1469 &h,
1470 &alpha,
1471 &compress,
1472 &quality,
1473 &lossy);
1474 fail_if(data == NULL);
1475 fail_if(w != test_noalpha.w);
1476 fail_if(h != test_noalpha.h);
1477 fail_if(alpha != test_noalpha.alpha);
1478 fail_if(lossy != 1);
1479 free(data);
1480
1481 data = eet_data_image_read(ef,
1482 EET_TEST_FILE_IMAGE "6",
1483 &w,
1484 &h,
1485 &alpha,
1486 &compress,
1487 &quality,
1488 &lossy);
1489 fail_if(data == NULL);
1490 fail_if(w != test_noalpha.w);
1491 fail_if(h != test_noalpha.h);
1492 fail_if(alpha != test_noalpha.alpha);
1493 fail_if(lossy != 1);
1494 free(data);
1495
1496 result = eet_data_image_header_read(ef,
1497 EET_TEST_FILE_IMAGE "7",
1498 &w,
1499 &h,
1500 &alpha,
1501 &compress,
1502 &quality,
1503 &lossy);
1504 fail_if(result == 0);
1505 fail_if(w != test_alpha.w);
1506 fail_if(h != test_alpha.h);
1507 fail_if(alpha != test_alpha.alpha);
1508 fail_if(compress != 9);
1509 fail_if(lossy != 0);
1510
1511 data = eet_data_image_read(ef,
1512 EET_TEST_FILE_IMAGE "7",
1513 &w,
1514 &h,
1515 &alpha,
1516 &compress,
1517 &quality,
1518 &lossy);
1519 fail_if(data == NULL);
1520 fail_if(w != test_alpha.w);
1521 fail_if(h != test_alpha.h);
1522 fail_if(alpha != test_alpha.alpha);
1523 fail_if(compress != 9);
1524 fail_if(lossy != 0);
1525 fail_if(data[0] != test_alpha.color[0]);
1526 free(data);
1527
1528 result = eet_data_image_header_read(ef,
1529 EET_TEST_FILE_IMAGE "9",
1530 &w,
1531 &h,
1532 &alpha,
1533 &compress,
1534 &quality,
1535 &lossy);
1536 fail_if(result == 0);
1537 fail_if(w != test_alpha.w);
1538 fail_if(h != test_alpha.h);
1539 fail_if(alpha != test_alpha.alpha);
1540 fail_if(lossy != 1);
1541
1542 data = eet_data_image_read(ef,
1543 EET_TEST_FILE_IMAGE "9",
1544 &w,
1545 &h,
1546 &alpha,
1547 &compress,
1548 &quality,
1549 &lossy);
1550 fail_if(data == NULL);
1551 fail_if(w != test_alpha.w);
1552 fail_if(h != test_alpha.h);
1553 fail_if(alpha != test_alpha.alpha);
1554 fail_if(lossy != 1);
1555 free(data);
1556
1557 eet_close(ef);
1558
1559 fail_if(unlink(file) != 0);
1560
1561 eet_shutdown();
1562} /* START_TEST */
1563
1564END_TEST
1565
1566#define IM0 0x00112233
1567#define IM1 0x44556677
1568#define IM2 0x8899aabb
1569#define IM3 0xccddeeff
1570
1571START_TEST(eet_small_image)
1572{
1573 char *file = strdup("/tmp/eet_suite_testXXXXXX");
1574 unsigned int image[4];
1575 unsigned int *data;
1576 Eet_File *ef;
1577 unsigned int w;
1578 unsigned int h;
1579 int alpha;
1580 int compression;
1581 int quality;
1582 int lossy;
1583 int result;
1584
1585 image[0] = IM0;
1586 image[1] = IM1;
1587 image[2] = IM2;
1588 image[3] = IM3;
1589
1590 eet_init();
1591
1592 fail_if(!(file = tmpnam(file)));
1593
1594 ef = eet_open(file, EET_FILE_MODE_WRITE);
1595 fail_if(!ef);
1596
1597 result = eet_data_image_write(ef, "/images/test", image, 2, 2, 1, 9, 100, 0);
1598 fail_if(result == 0);
1599
1600 eet_close(ef);
1601
1602 ef = eet_open(file, EET_FILE_MODE_READ);
1603 fail_if(!ef);
1604
1605 data = (unsigned int *)eet_data_image_read(ef,
1606 "/images/test",
1607 &w,
1608 &h,
1609 &alpha,
1610 &compression,
1611 &quality,
1612 &lossy);
1613 fail_if(data == NULL);
1614
1615 eet_close(ef);
1616
1617 fail_if(unlink(file) != 0);
1618
1619 fail_if(data[0] != IM0);
1620 fail_if(data[1] != IM1);
1621 fail_if(data[2] != IM2);
1622 fail_if(data[3] != IM3);
1623
1624 free(data);
1625
1626 eet_shutdown();
1627} /* START_TEST */
1628
1629END_TEST
1630START_TEST(eet_identity_simple)
1631{
1632 const char *buffer = "Here is a string of data to save !";
1633 const void *tmp;
1634 Eet_File *ef;
1635 Eet_Key *k;
1636 FILE *noread;
1637 char *test;
1638 char *file = strdup("/tmp/eet_suite_testXXXXXX");
1639 int size;
1640 int fd;
1641
1642 eet_init();
1643
1644 fail_if(!(file = tmpnam(file)));
1645 fail_if(chdir(CERT_DIR));
1646 fail_if(!(noread = fopen("/dev/null", "w")));
1647
1648 /* Sign an eet file. */
1649 ef = eet_open(file, EET_FILE_MODE_WRITE);
1650 fail_if(!ef);
1651
1652 fail_if(!eet_write(ef, "keys/tests", buffer, strlen(buffer) + 1, 0));
1653
1654 k = eet_identity_open("cert.pem", "key.pem", NULL);
1655 fail_if(!k);
1656
1657 fail_if(eet_identity_set(ef, k) != EET_ERROR_NONE);
1658 eet_identity_print(k, noread);
1659
1660 eet_close(ef);
1661
1662 /* Open a signed file. */
1663 ef = eet_open(file, EET_FILE_MODE_READ);
1664 fail_if(!ef);
1665
1666 test = eet_read(ef, "keys/tests", &size);
1667 fail_if(!test);
1668 fail_if(size != (int)strlen(buffer) + 1);
1669
1670 fail_if(memcmp(test, buffer, strlen(buffer) + 1) != 0);
1671
1672 tmp = eet_identity_x509(ef, &size);
1673 fail_if(tmp == NULL);
1674
1675 eet_identity_certificate_print(tmp, size, noread);
1676
1677 eet_close(ef);
1678
1679 /* As we are changing file contain in less than 1s, this could get unnoticed
1680 by eet cache system. */
1681 eet_clearcache();
1682
1683 /* Corrupting the file. */
1684 fd = open(file, O_WRONLY);
1685 fail_if(fd < 0);
1686
1687 fail_if(lseek(fd, 200, SEEK_SET) != 200);
1688 fail_if(write(fd, "42", 2) != 2);
1689 fail_if(lseek(fd, 50, SEEK_SET) != 50);
1690 fail_if(write(fd, "42", 2) != 2);
1691 fail_if(lseek(fd, 88, SEEK_SET) != 88);
1692 fail_if(write(fd, "42", 2) != 2);
1693
1694 close(fd);
1695
1696 /* Attempt to open a modified file. */
1697 ef = eet_open(file, EET_FILE_MODE_READ);
1698 fail_if(ef);
1699
1700 fail_if(unlink(file) != 0);
1701
1702 eet_shutdown();
1703} /* START_TEST */
1704
1705END_TEST
1706START_TEST(eet_identity_open_simple)
1707{
1708 Eet_Key *k = NULL;
1709
1710 eet_init();
1711
1712 fail_if(chdir(CERT_DIR));
1713
1714 k = eet_identity_open("cert.pem", "key.pem", NULL);
1715 fail_if(!k);
1716
1717 if (k)
1718 eet_identity_close(k);
1719
1720 eet_shutdown();
1721} /* START_TEST */
1722
1723END_TEST
1724START_TEST(eet_identity_open_pkcs8)
1725{
1726 Eet_Key *k = NULL;
1727
1728 eet_init();
1729
1730 fail_if(chdir(CERT_DIR));
1731
1732 k = eet_identity_open("cert.pem", "key_enc_none.pem", NULL);
1733 fail_if(!k);
1734
1735 if (k)
1736 eet_identity_close(k);
1737
1738 eet_shutdown();
1739} /* START_TEST */
1740
1741END_TEST
1742
1743static int
1744pass_get(char *pass,
1745 int size,
1746 __UNUSED__ int rwflags,
1747 __UNUSED__ void *u)
1748{
1749 memset(pass, 0, size);
1750
1751 if ((int)strlen("password") > size)
1752 return 0;
1753
1754 snprintf(pass, size, "%s", "password");
1755 return strlen(pass);
1756} /* pass_get */
1757
1758static int
1759badpass_get(char *pass,
1760 int size,
1761 __UNUSED__ int rwflags,
1762 __UNUSED__ void *u)
1763{
1764 memset(pass, 0, size);
1765
1766 if ((int)strlen("bad password") > size)
1767 return 0;
1768
1769 snprintf(pass, size, "%s", "bad password");
1770 return strlen(pass);
1771} /* badpass_get */
1772
1773START_TEST(eet_identity_open_pkcs8_enc)
1774{
1775 Eet_Key *k = NULL;
1776
1777 eet_init();
1778
1779 fail_if(chdir(CERT_DIR));
1780
1781 k = eet_identity_open("cert.pem", "key_enc.pem", NULL);
1782 fail_if(k);
1783
1784 if (k)
1785 eet_identity_close(k);
1786
1787 k = eet_identity_open("cert.pem", "key_enc.pem", &badpass_get);
1788 fail_if(k);
1789
1790 if (k)
1791 eet_identity_close(k);
1792
1793 k = eet_identity_open("cert.pem", "key_enc.pem", &pass_get);
1794 fail_if(!k);
1795
1796 if (k)
1797 eet_identity_close(k);
1798
1799 eet_shutdown();
1800}
1801END_TEST
1802START_TEST(eet_cipher_decipher_simple)
1803{
1804 const char *buffer = "Here is a string of data to save !";
1805 const char *key = "This is a crypto key";
1806 const char *key_bad = "This is another crypto key";
1807 Eet_File *ef;
1808 char *test;
1809 char *file = strdup("/tmp/eet_suite_testXXXXXX");
1810 int size;
1811
1812 eet_init();
1813
1814 fail_if(!(file = tmpnam(file)));
1815 fail_if(chdir(CERT_DIR));
1816
1817 /* Crypt an eet file. */
1818 ef = eet_open(file, EET_FILE_MODE_WRITE);
1819 fail_if(!ef);
1820
1821 fail_if(!eet_write_cipher(ef, "keys/tests", buffer, strlen(buffer) + 1, 0,
1822 key));
1823
1824 eet_close(ef);
1825
1826 /* Decrypt an eet file. */
1827 ef = eet_open(file, EET_FILE_MODE_READ);
1828 fail_if(!ef);
1829
1830 test = eet_read_cipher(ef, "keys/tests", &size, key);
1831 fail_if(!test);
1832 fail_if(size != (int)strlen(buffer) + 1);
1833
1834 fail_if(memcmp(test, buffer, strlen(buffer) + 1) != 0);
1835
1836 eet_close(ef);
1837
1838 /* Decrypt an eet file. */
1839 ef = eet_open(file, EET_FILE_MODE_READ);
1840 fail_if(!ef);
1841
1842 test = eet_read_cipher(ef, "keys/tests", &size, key_bad);
1843
1844 if (size == (int)strlen(buffer) + 1)
1845 fail_if(memcmp(test, buffer, strlen(buffer) + 1) == 0);
1846
1847 eet_close(ef);
1848
1849 fail_if(unlink(file) != 0);
1850
1851 eet_shutdown();
1852} /* START_TEST */
1853
1854END_TEST
1855
1856#ifdef EINA_HAVE_THREADS
1857
1858static Eina_Bool open_worker_stop;
1859
1860# ifdef _EET_INCLUDED_PTHREAD
1861
1862static void *
1863open_close_worker(void *path)
1864{
1865 while (!open_worker_stop)
1866 {
1867 Eet_File *ef = eet_open((char const *)path, EET_FILE_MODE_READ);
1868 if (ef == NULL)
1869 pthread_exit("eet_open() failed");
1870 else
1871 {
1872 Eet_Error err_code = eet_close(ef);
1873 if (err_code != EET_ERROR_NONE)
1874 pthread_exit("eet_close() failed");
1875 }
1876 }
1877
1878 pthread_exit(NULL);
1879} /* open_close_worker */
1880
1881# else /* ifdef _EET_INCLUDED_PTHREAD */
1882
1883static unsigned int __stdcall
1884open_close_worker(void *path)
1885{
1886 while (!open_worker_stop)
1887 {
1888 Eet_File *ef = eet_open((char const *)path, EET_FILE_MODE_READ);
1889 if (ef == NULL)
1890 _endthreadex(-1);
1891 else
1892 {
1893 Eet_Error err_code = eet_close(ef);
1894 if (err_code != EET_ERROR_NONE)
1895 _endthreadex(-2);
1896 }
1897 }
1898
1899 _endthreadex(0);
1900} /* open_close_worker */
1901
1902# endif /* ifdef _EET_INCLUDED_PTHREAD */
1903
1904START_TEST(eet_cache_concurrency)
1905{
1906 char *file = strdup("/tmp/eet_suite_testXXXXXX");
1907 const char *buffer = "test data";
1908 Eet_File *ef;
1909 void *thread_ret;
1910 unsigned int n;
1911# ifdef _EET_INCLUDED_PTHREAD
1912 pthread_t thread;
1913# else /* ifdef _EET_INCLUDED_PTHREAD */
1914 uintptr_t thread;
1915 unsigned int thread_id;
1916 DWORD ret;
1917# endif /* ifdef _EET_INCLUDED_PTHREAD */
1918
1919 eet_init();
1920 eina_threads_init();
1921
1922 /* create a file to test with */
1923 fail_if(!(file = tmpnam(file)));
1924 ef = eet_open(file, EET_FILE_MODE_WRITE);
1925 fail_if(!ef);
1926 fail_if(!eet_write(ef, "keys/tests", buffer, strlen(buffer) + 1, 0));
1927
1928 /* start a thread that repeatedly opens and closes a file */
1929 open_worker_stop = 0;
1930# ifdef _EET_INCLUDED_PTHREAD
1931 pthread_create(&thread, NULL, open_close_worker, file);
1932# else /* ifdef _EET_INCLUDED_PTHREAD */
1933 thread = _beginthreadex(NULL, 0, open_close_worker, file, 0, &thread_id);
1934# endif /* ifdef _EET_INCLUDED_PTHREAD */
1935 /* clear the cache repeatedly in this thread */
1936 for (n = 0; n < 20000; ++n)
1937 {
1938 eet_clearcache();
1939 }
1940
1941 /* join the other thread, and fail if it returned an error message */
1942 open_worker_stop = 1;
1943# ifdef _EET_INCLUDED_PTHREAD
1944 fail_if(pthread_join(thread, &thread_ret) != 0);
1945 fail_unless(thread_ret == NULL, (char const *)thread_ret);
1946# else /* ifdef _EET_INCLUDED_PTHREAD */
1947 ret = WaitForSingleObject((HANDLE)thread, INFINITE);
1948 fail_if(ret != WAIT_OBJECT_0);
1949 fail_if(GetExitCodeThread((HANDLE)thread, &ret) == FALSE);
1950 fail_if(ret != 0);
1951# endif /* ifdef _EET_INCLUDED_PTHREAD */
1952
1953 fail_if(unlink(file) != 0);
1954
1955 eina_threads_shutdown();
1956 eet_shutdown();
1957}
1958END_TEST
1959
1960#endif /* EINA_HAVE_THREADS */
1961
1962typedef struct _Eet_Connection_Data Eet_Connection_Data;
1963struct _Eet_Connection_Data
1964{
1965 Eet_Connection *conn;
1966 Eet_Data_Descriptor *edd;
1967 Eina_Bool test;
1968};
1969
1970static Eina_Bool
1971_eet_connection_read(const void *eet_data,
1972 size_t size,
1973 void *user_data)
1974{
1975 Eet_Connection_Data *dt = user_data;
1976 Eet_Test_Ex_Type *result;
1977 Eet_Node *node;
1978 int test;
1979
1980 result = eet_data_descriptor_decode(dt->edd, eet_data, size);
1981 node = eet_data_node_decode_cipher(eet_data, NULL, size);
1982
1983 /* Test the resulting data. */
1984 fail_if(!node);
1985 fail_if(_eet_test_ex_check(result, 0) != 0);
1986 fail_if(_eet_test_ex_check(eina_list_data_get(result->list), 1) != 0);
1987 fail_if(eina_list_data_get(result->ilist) == NULL);
1988 fail_if(*((int *)eina_list_data_get(result->ilist)) != 42);
1989 fail_if(eina_list_data_get(result->slist) == NULL);
1990 fail_if(strcmp(eina_list_data_get(result->slist), "test") != 0);
1991 fail_if(eina_hash_find(result->shash, EET_TEST_KEY1) == NULL);
1992 fail_if(strcmp(eina_hash_find(result->shash, EET_TEST_KEY1), "test") != 0);
1993 fail_if(strcmp(result->charray[0], "test") != 0);
1994
1995 test = 0;
1996 if (result->hash)
1997 eina_hash_foreach(result->hash, func, &test);
1998
1999 fail_if(test != 0);
2000 if (result->ihash)
2001 eina_hash_foreach(result->ihash, func7, &test);
2002
2003 fail_if(test != 0);
2004
2005 if (!dt->test)
2006 {
2007 dt->test = EINA_TRUE;
2008 fail_if(!eet_connection_node_send(dt->conn, node, NULL));
2009 }
2010
2011 return EINA_TRUE;
2012} /* _eet_connection_read */
2013
2014static Eina_Bool
2015_eet_connection_write(const void *data,
2016 size_t size,
2017 void *user_data)
2018{
2019 Eet_Connection_Data *dt = user_data;
2020 int still;
2021
2022 if (!dt->test)
2023 {
2024 int step = size / 3;
2025
2026 eet_connection_received(dt->conn, data, step);
2027 eet_connection_received(dt->conn, (char *)data + step, step);
2028 size -= 2 * step;
2029 still = eet_connection_received(dt->conn, (char *)data + 2 * step, size);
2030 }
2031 else
2032 still = eet_connection_received(dt->conn, data, size);
2033
2034 fail_if(still);
2035
2036 return EINA_TRUE;
2037} /* _eet_connection_write */
2038
2039START_TEST(eet_connection_check)
2040{
2041 Eet_Connection *conn;
2042 Eet_Data_Descriptor *edd;
2043 Eet_Data_Descriptor_Class eddc;
2044 Eet_Connection_Data ecd;
2045 Eet_Test_Ex_Type etbt;
2046 Eina_Bool on_going;
2047
2048 eet_init();
2049
2050 _eet_test_ex_set(&etbt, 0);
2051 etbt.list = eina_list_prepend(etbt.list, _eet_test_ex_set(NULL, 1));
2052 etbt.list = eina_list_prepend(etbt.list, _eet_test_ex_set(NULL, 1));
2053 etbt.hash = eina_hash_string_superfast_new(NULL);
2054 eina_hash_add(etbt.hash, EET_TEST_KEY1, _eet_test_ex_set(NULL, 2));
2055 eina_hash_add(etbt.hash, EET_TEST_KEY2, _eet_test_ex_set(NULL, 2));
2056 etbt.ilist = eina_list_prepend(etbt.ilist, &i42);
2057 etbt.ilist = eina_list_prepend(etbt.ilist, &i42);
2058 etbt.ihash = eina_hash_string_superfast_new(NULL);
2059 eina_hash_add(etbt.ihash, EET_TEST_KEY1, &i7);
2060 eina_hash_add(etbt.ihash, EET_TEST_KEY2, &i7);
2061 etbt.slist = eina_list_prepend(NULL, "test");
2062 etbt.shash = eina_hash_string_superfast_new(NULL);
2063 eina_hash_add(etbt.shash, EET_TEST_KEY1, "test");
2064 memset(&etbt.charray, 0, sizeof(etbt.charray));
2065 etbt.charray[0] = "test";
2066
2067 eet_eina_file_data_descriptor_class_set(&eddc, sizeof (eddc),
2068 "Eet_Test_Ex_Type",
2069 sizeof(Eet_Test_Ex_Type));
2070
2071 edd = eet_data_descriptor_file_new(&eddc);
2072 fail_if(!edd);
2073
2074 _eet_build_ex_descriptor(edd);
2075
2076 /* Create a connection. */
2077 conn = eet_connection_new(_eet_connection_read, _eet_connection_write, &ecd);
2078 fail_if(!conn);
2079
2080 /* Init context. */
2081 ecd.test = EINA_FALSE;
2082 ecd.conn = conn;
2083 ecd.edd = edd;
2084
2085 /* Test the connection. */
2086 fail_if(!eet_connection_send(conn, edd, &etbt, NULL));
2087
2088 fail_if(!ecd.test);
2089
2090 fail_if(!eet_connection_close(conn, &on_going));
2091
2092 fail_if(on_going);
2093
2094 eet_shutdown();
2095}
2096END_TEST
2097
2098struct _Eet_5FP
2099{
2100 Eina_F32p32 fp32;
2101 Eina_F16p16 fp16;
2102 Eina_F8p24 fp8;
2103 Eina_F32p32 f1;
2104 Eina_F32p32 f0;
2105};
2106typedef struct _Eet_5FP Eet_5FP;
2107
2108struct _Eet_5DBL
2109{
2110 double fp32;
2111 double fp16;
2112 float fp8;
2113 double f1;
2114 double f0;
2115};
2116typedef struct _Eet_5DBL Eet_5DBL;
2117
2118START_TEST(eet_fp)
2119{
2120 Eet_Data_Descriptor_Class eddc;
2121 Eet_Data_Descriptor *edd_5FP;
2122 Eet_Data_Descriptor *edd_5DBL;
2123 Eet_5FP origin;
2124 Eet_5DBL *convert;
2125 Eet_5FP *build;
2126 void *blob;
2127 int size;
2128
2129 eet_init();
2130
2131 EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eddc, Eet_5FP);
2132 edd_5FP = eet_data_descriptor_stream_new(&eddc);
2133
2134 EET_DATA_DESCRIPTOR_ADD_BASIC(edd_5FP, Eet_5FP, "fp32", fp32, EET_T_F32P32);
2135 EET_DATA_DESCRIPTOR_ADD_BASIC(edd_5FP, Eet_5FP, "fp16", fp16, EET_T_F16P16);
2136 EET_DATA_DESCRIPTOR_ADD_BASIC(edd_5FP, Eet_5FP, "fp8", fp8, EET_T_F8P24);
2137 EET_DATA_DESCRIPTOR_ADD_BASIC(edd_5FP, Eet_5FP, "f1", f1, EET_T_F32P32);
2138 EET_DATA_DESCRIPTOR_ADD_BASIC(edd_5FP, Eet_5FP, "f0", f0, EET_T_F32P32);
2139
2140 eet_eina_stream_data_descriptor_class_set(&eddc, sizeof (eddc), "Eet_5FP", sizeof (Eet_5DBL));
2141 edd_5DBL = eet_data_descriptor_stream_new(&eddc);
2142
2143 EET_DATA_DESCRIPTOR_ADD_BASIC(edd_5DBL, Eet_5DBL, "fp32", fp32, EET_T_DOUBLE);
2144 EET_DATA_DESCRIPTOR_ADD_BASIC(edd_5DBL, Eet_5DBL, "fp16", fp16, EET_T_DOUBLE);
2145 EET_DATA_DESCRIPTOR_ADD_BASIC(edd_5DBL, Eet_5DBL, "fp8", fp8, EET_T_FLOAT);
2146 EET_DATA_DESCRIPTOR_ADD_BASIC(edd_5DBL, Eet_5DBL, "f1", f1, EET_T_DOUBLE);
2147 EET_DATA_DESCRIPTOR_ADD_BASIC(edd_5DBL, Eet_5DBL, "f0", f0, EET_T_DOUBLE);
2148
2149 origin.fp32 = eina_f32p32_double_from(1.125);
2150 origin.fp16 = eina_f16p16_int_from(2000);
2151 origin.fp8 = eina_f8p24_int_from(125);
2152 origin.f1 = eina_f32p32_int_from(1);
2153 origin.f0 = 0;
2154
2155 blob = eet_data_descriptor_encode(edd_5FP, &origin, &size);
2156 fail_if(!blob || size <= 0);
2157
2158 build = eet_data_descriptor_decode(edd_5FP, blob, size);
2159 fail_if(!build);
2160
2161 convert = eet_data_descriptor_decode(edd_5DBL, blob, size);
2162 fail_if(!convert);
2163
2164 fail_if(build->fp32 != eina_f32p32_double_from(1.125));
2165 fail_if(build->fp16 != eina_f16p16_int_from(2000));
2166 fail_if(build->fp8 != eina_f8p24_int_from(125));
2167 fail_if(build->f1 != eina_f32p32_int_from(1));
2168 fail_if(build->f0 != 0);
2169
2170 fail_if(convert->fp32 != 1.125);
2171 fail_if(convert->fp16 != 2000);
2172 fail_if(convert->fp8 != 125);
2173 fail_if(convert->f1 != 1);
2174 fail_if(convert->f0 != 0);
2175
2176 eet_shutdown();
2177}
2178END_TEST
2179START_TEST(eet_file_fp)
2180{
2181 char *file = strdup("/tmp/eet_suite_testXXXXXX");
2182 Eet_Data_Descriptor_Class eddc;
2183 Eet_Data_Descriptor *edd_5FP;
2184 Eet_Data_Descriptor *edd_5DBL;
2185 Eet_File *ef;
2186 Eet_5FP origin;
2187 Eet_5DBL *convert;
2188 Eet_5FP *build;
2189
2190 eet_init();
2191
2192 EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(&eddc, Eet_5FP);
2193 edd_5FP = eet_data_descriptor_file_new(&eddc);
2194
2195 EET_DATA_DESCRIPTOR_ADD_BASIC(edd_5FP, Eet_5FP, "fp32", fp32, EET_T_F32P32);
2196 EET_DATA_DESCRIPTOR_ADD_BASIC(edd_5FP, Eet_5FP, "fp16", fp16, EET_T_F16P16);
2197 EET_DATA_DESCRIPTOR_ADD_BASIC(edd_5FP, Eet_5FP, "fp8", fp8, EET_T_F8P24);
2198 EET_DATA_DESCRIPTOR_ADD_BASIC(edd_5FP, Eet_5FP, "f1", f1, EET_T_F32P32);
2199 EET_DATA_DESCRIPTOR_ADD_BASIC(edd_5FP, Eet_5FP, "f0", f0, EET_T_F32P32);
2200
2201 eet_eina_file_data_descriptor_class_set(&eddc, sizeof (eddc), "Eet_5FP", sizeof (Eet_5DBL));
2202 edd_5DBL = eet_data_descriptor_file_new(&eddc);
2203
2204 EET_DATA_DESCRIPTOR_ADD_BASIC(edd_5DBL, Eet_5DBL, "fp32", fp32, EET_T_DOUBLE);
2205 EET_DATA_DESCRIPTOR_ADD_BASIC(edd_5DBL, Eet_5DBL, "fp16", fp16, EET_T_DOUBLE);
2206 EET_DATA_DESCRIPTOR_ADD_BASIC(edd_5DBL, Eet_5DBL, "fp8", fp8, EET_T_FLOAT);
2207 EET_DATA_DESCRIPTOR_ADD_BASIC(edd_5DBL, Eet_5DBL, "f1", f1, EET_T_DOUBLE);
2208 EET_DATA_DESCRIPTOR_ADD_BASIC(edd_5DBL, Eet_5DBL, "f0", f0, EET_T_DOUBLE);
2209
2210 origin.fp32 = eina_f32p32_double_from(1.125);
2211 origin.fp16 = eina_f16p16_int_from(2000);
2212 origin.fp8 = eina_f8p24_int_from(125);
2213 origin.f1 = eina_f32p32_int_from(1);
2214 origin.f0 = 0;
2215
2216 fail_if(!(file = tmpnam(file)));
2217
2218 ef = eet_open(file, EET_FILE_MODE_READ_WRITE);
2219 fail_if(!ef);
2220
2221 fail_if(!eet_data_write(ef, edd_5FP, EET_TEST_FILE_KEY1, &origin, 1));
2222
2223 build = eet_data_read(ef, edd_5FP, EET_TEST_FILE_KEY1);
2224 fail_if(!build);
2225
2226 convert = eet_data_read(ef, edd_5DBL, EET_TEST_FILE_KEY1);
2227 fail_if(!convert);
2228
2229 fail_if(build->fp32 != eina_f32p32_double_from(1.125));
2230 fail_if(build->fp16 != eina_f16p16_int_from(2000));
2231 fail_if(build->fp8 != eina_f8p24_int_from(125));
2232 fail_if(build->f1 != eina_f32p32_int_from(1));
2233 fail_if(build->f0 != 0);
2234
2235 fail_if(convert->fp32 != 1.125);
2236 fail_if(convert->fp16 != 2000);
2237 fail_if(convert->fp8 != 125);
2238 fail_if(convert->f1 != 1);
2239 fail_if(convert->f0 != 0);
2240
2241 eet_close(ef);
2242
2243 fail_if(unlink(file) != 0);
2244
2245 eet_shutdown();
2246} /* START_TEST */
2247
2248END_TEST
2249
2250typedef struct _Eet_Union_Test Eet_Union_Test;
2251typedef struct _Eet_Variant_Test Eet_Variant_Test;
2252typedef struct _Eet_Variant_Type Eet_Variant_Type;
2253typedef struct _Eet_Inherit_Test1 Eet_Inherit_Test1;
2254typedef struct _Eet_Inherit_Test2 Eet_Inherit_Test2;
2255typedef struct _Eet_Inherit_Test3 Eet_Inherit_Test3;
2256typedef struct _Eet_St1 Eet_St1;
2257typedef struct _Eet_St2 Eet_St2;
2258typedef struct _Eet_St3 Eet_St3;
2259typedef struct _Eet_List Eet_List;
2260
2261typedef enum _Eet_Union
2262{
2263 EET_UNKNOWN,
2264 EET_ST1,
2265 EET_ST2,
2266 EET_ST3
2267} Eet_Union;
2268
2269struct
2270{
2271 Eet_Union u;
2272 const char *name;
2273} eet_mapping[] = {
2274 { EET_ST1, "ST1" },
2275 { EET_ST2, "ST2" },
2276 { EET_ST3, "ST3" },
2277 { EET_UNKNOWN, NULL }
2278};
2279
2280struct _Eet_St1
2281{
2282 double val1;
2283 int stuff;
2284 char *s1;
2285};
2286
2287struct _Eet_St2
2288{
2289 Eina_Bool b1;
2290 unsigned long long v1;
2291};
2292
2293struct _Eet_St3
2294{
2295 int boby;
2296};
2297
2298struct _Eet_Union_Test
2299{
2300 Eet_Union type;
2301
2302 union {
2303 Eet_St1 st1;
2304 Eet_St2 st2;
2305 Eet_St3 st3;
2306 } u;
2307};
2308
2309struct _Eet_Variant_Type
2310{
2311 const char *type;
2312 Eina_Bool unknow : 1;
2313};
2314
2315struct _Eet_Variant_Test
2316{
2317 Eet_Variant_Type t;
2318
2319 void *data;
2320 Eina_List *data_list;
2321};
2322
2323struct _Eet_Inherit_Test1
2324{
2325 Eet_Union type;
2326 Eet_St1 st1;
2327};
2328struct _Eet_Inherit_Test2
2329{
2330 Eet_Union type;
2331 Eet_St2 st2;
2332};
2333struct _Eet_Inherit_Test3
2334{
2335 Eet_Union type;
2336 Eet_St3 st3;
2337};
2338
2339struct _Eet_List
2340{
2341 Eina_List *list;
2342};
2343
2344static const char *
2345_eet_union_type_get(const void *data,
2346 Eina_Bool *unknow)
2347{
2348 const Eet_Union *u = data;
2349 int i;
2350
2351 if (unknow)
2352 *unknow = EINA_FALSE;
2353
2354 for (i = 0; eet_mapping[i].name != NULL; ++i)
2355 if (*u == eet_mapping[i].u)
2356 return eet_mapping[i].name;
2357
2358 if (unknow)
2359 *unknow = EINA_TRUE;
2360
2361 return NULL;
2362} /* _eet_union_type_get */
2363
2364static Eina_Bool
2365_eet_union_type_set(const char *type,
2366 void *data,
2367 Eina_Bool unknow)
2368{
2369 Eet_Union *u = data;
2370 int i;
2371
2372 if (unknow)
2373 return EINA_FALSE;
2374
2375 for (i = 0; eet_mapping[i].name != NULL; ++i)
2376 if (strcmp(eet_mapping[i].name, type) == 0)
2377 {
2378 *u = eet_mapping[i].u;
2379 return EINA_TRUE;
2380 }
2381
2382 return EINA_FALSE;
2383} /* _eet_union_type_set */
2384
2385static const char *
2386_eet_variant_type_get(const void *data,
2387 Eina_Bool *unknow)
2388{
2389 const Eet_Variant_Type *type = data;
2390 int i;
2391
2392 if (unknow)
2393 *unknow = type->unknow;
2394
2395 for (i = 0; eet_mapping[i].name != NULL; ++i)
2396 if (strcmp(type->type, eet_mapping[i].name) == 0)
2397 return eet_mapping[i].name;
2398
2399 if (unknow)
2400 *unknow = EINA_FALSE;
2401
2402 return type->type;
2403} /* _eet_variant_type_get */
2404
2405static Eina_Bool
2406_eet_variant_type_set(const char *type,
2407 void *data,
2408 Eina_Bool unknow)
2409{
2410 Eet_Variant_Type *vt = data;
2411
2412 vt->type = type;
2413 vt->unknow = unknow;
2414 return EINA_TRUE;
2415} /* _eet_variant_type_set */
2416
2417static Eet_Data_Descriptor *
2418_eet_st1_dd(void)
2419{
2420 Eet_Data_Descriptor_Class eddc;
2421 Eet_Data_Descriptor *res;
2422
2423 EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eddc, Eet_St1);
2424 res = eet_data_descriptor_stream_new(&eddc);
2425 EET_DATA_DESCRIPTOR_ADD_BASIC(res, Eet_St1, "val1", val1, EET_T_DOUBLE);
2426 EET_DATA_DESCRIPTOR_ADD_BASIC(res, Eet_St1, "stuff", stuff, EET_T_INT);
2427 EET_DATA_DESCRIPTOR_ADD_BASIC(res, Eet_St1, "s1", s1, EET_T_STRING);
2428
2429 return res;
2430} /* _eet_st1_dd */
2431
2432static void
2433_eet_st1_set(Eet_St1 *st1,
2434 int i)
2435{
2436 st1->val1 = EET_TEST_DOUBLE;
2437 st1->stuff = EET_TEST_INT + i;
2438 st1->s1 = EET_TEST_STRING;
2439} /* _eet_st1_set */
2440
2441static void
2442_eet_st1_cmp(Eet_St1 *st1,
2443 int i)
2444{
2445 double tmp;
2446
2447 fail_if(!st1);
2448
2449 tmp = st1->val1 - EET_TEST_DOUBLE;
2450 if (tmp < 0)
2451 tmp = -tmp;
2452
2453 fail_if(tmp > 0.005);
2454 fail_if(st1->stuff != EET_TEST_INT + i);
2455 fail_if(strcmp(st1->s1, EET_TEST_STRING));
2456} /* _eet_st1_cmp */
2457
2458static Eet_Data_Descriptor *
2459_eet_st2_dd(void)
2460{
2461 Eet_Data_Descriptor_Class eddc;
2462 Eet_Data_Descriptor *res;
2463
2464 EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eddc, Eet_St2);
2465 res = eet_data_descriptor_stream_new(&eddc);
2466 EET_DATA_DESCRIPTOR_ADD_BASIC(res, Eet_St2, "b1", b1, EET_T_UCHAR);
2467 EET_DATA_DESCRIPTOR_ADD_BASIC(res, Eet_St2, "v1", v1, EET_T_ULONG_LONG);
2468
2469 return res;
2470} /* _eet_st2_dd */
2471
2472static void
2473_eet_st2_set(Eet_St2 *st2,
2474 int i)
2475{
2476 st2->b1 = EINA_TRUE;
2477 st2->v1 = EET_TEST_LONG_LONG + i;
2478} /* _eet_st2_set */
2479
2480static void
2481_eet_st2_cmp(Eet_St2 *st2,
2482 int i)
2483{
2484 fail_if(!st2->b1);
2485 fail_if(st2->v1 != EET_TEST_LONG_LONG + i);
2486} /* _eet_st2_cmp */
2487
2488static Eet_Data_Descriptor *
2489_eet_st3_dd(void)
2490{
2491 Eet_Data_Descriptor_Class eddc;
2492 Eet_Data_Descriptor *res;
2493
2494 EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eddc, Eet_St3);
2495 res = eet_data_descriptor_stream_new(&eddc);
2496 EET_DATA_DESCRIPTOR_ADD_BASIC(res, Eet_St3, "boby", boby, EET_T_INT);
2497
2498 return res;
2499} /* _eet_st3_dd */
2500
2501static void
2502_eet_st3_set(Eet_St3 *st3,
2503 int i)
2504{
2505 st3->boby = EET_TEST_INT + i;
2506} /* _eet_st3_set */
2507
2508static void
2509_eet_st3_cmp(Eet_St3 *st3,
2510 int i)
2511{
2512 fail_if(st3->boby != EET_TEST_INT + i);
2513} /* _eet_st3_cmp */
2514
2515START_TEST(eet_test_union)
2516{
2517 Eet_Union_Test *eut;
2518 Eet_List *l;
2519 Eet_Data_Descriptor_Class eddc;
2520 Eet_Data_Descriptor *edd;
2521 Eet_Data_Descriptor *unified;
2522 Eet_Data_Descriptor *m;
2523 void *blob;
2524 int size;
2525 int i;
2526
2527 eina_init();
2528 eet_init();
2529
2530 EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eddc, Eet_Union_Test);
2531 edd = eet_data_descriptor_stream_new(&eddc);
2532
2533 EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eddc, Eet_Union_Test);
2534 m = eet_data_descriptor_stream_new(&eddc);
2535
2536 eddc.version = EET_DATA_DESCRIPTOR_CLASS_VERSION;
2537 eddc.func.type_get = _eet_union_type_get;
2538 eddc.func.type_set = _eet_union_type_set;
2539 unified = eet_data_descriptor_stream_new(&eddc);
2540
2541 EET_DATA_DESCRIPTOR_ADD_MAPPING(unified, "ST1", _eet_st1_dd());
2542 EET_DATA_DESCRIPTOR_ADD_MAPPING(unified, "ST2", _eet_st2_dd());
2543 EET_DATA_DESCRIPTOR_ADD_MAPPING(unified, "ST3", _eet_st3_dd());
2544
2545 EET_DATA_DESCRIPTOR_ADD_UNION(edd, Eet_Union_Test, "u", u, type, unified);
2546
2547 EET_DATA_DESCRIPTOR_ADD_LIST(m, Eet_List, "list", list, edd);
2548
2549 l = calloc(1, sizeof (Eet_List));
2550
2551#define EUT_NEW(Type_Index) \
2552 eut = calloc(1, sizeof (Eet_Union_Test)); \
2553 eut->type = EET_ST ## Type_Index; \
2554 _eet_st ## Type_Index ## _set(&(eut->u.st ## Type_Index), i);
2555
2556 for (i = 0; i < 3; ++i)
2557 {
2558 EUT_NEW(1);
2559 l->list = eina_list_append(l->list, eut);
2560
2561 EUT_NEW(2);
2562 l->list = eina_list_append(l->list, eut);
2563
2564 EUT_NEW(3);
2565 l->list = eina_list_append(l->list, eut);
2566 }
2567
2568 blob = eet_data_descriptor_encode(m, l, &size);
2569 fail_if(!blob || size <= 0);
2570
2571 l = eet_data_descriptor_decode(m, blob, size);
2572 fail_if(!l);
2573
2574 fail_if(eina_list_count(l->list) != 9);
2575
2576#define EUT_CMP(Type_Index) \
2577 eut = eina_list_nth(l->list, i * 3 + Type_Index - 1); \
2578 fail_if(eut->type != EET_ST ## Type_Index); \
2579 _eet_st ## Type_Index ## _cmp(&(eut->u.st ## Type_Index), i);
2580
2581 for (i = 0; i < 3; ++i)
2582 {
2583 EUT_CMP(1);
2584 EUT_CMP(2);
2585 EUT_CMP(3);
2586 }
2587
2588 eet_shutdown();
2589 eina_shutdown();
2590}
2591END_TEST
2592START_TEST(eet_test_variant)
2593{
2594 Eet_Variant_Test *evt;
2595 Eet_List *l;
2596 Eet_St1 *st1;
2597 Eet_St2 *st2;
2598 Eet_St3 *st3;
2599 Eet_Data_Descriptor_Class eddc;
2600 Eet_Data_Descriptor *edd;
2601 Eet_Data_Descriptor *unified;
2602 Eet_Data_Descriptor *m;
2603 void *blob;
2604 int size;
2605 int i;
2606
2607 eina_init();
2608 eet_init();
2609
2610 EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eddc, Eet_Variant_Test);
2611 edd = eet_data_descriptor_stream_new(&eddc);
2612
2613 EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eddc, Eet_Variant_Test);
2614 m = eet_data_descriptor_stream_new(&eddc);
2615
2616 eddc.version = EET_DATA_DESCRIPTOR_CLASS_VERSION;
2617 eddc.func.type_get = _eet_variant_type_get;
2618 eddc.func.type_set = _eet_variant_type_set;
2619 unified = eet_data_descriptor_stream_new(&eddc);
2620
2621 EET_DATA_DESCRIPTOR_ADD_MAPPING(unified, "ST1", _eet_st1_dd());
2622 EET_DATA_DESCRIPTOR_ADD_MAPPING(unified, "ST2", _eet_st2_dd());
2623 EET_DATA_DESCRIPTOR_ADD_MAPPING(unified, "ST3", _eet_st3_dd());
2624
2625 EET_DATA_DESCRIPTOR_ADD_VARIANT(edd,
2626 Eet_Variant_Test,
2627 "data",
2628 data,
2629 t,
2630 unified);
2631
2632 unified = eet_data_descriptor_stream_new(&eddc);
2633 eet_data_descriptor_element_add(unified, "ST1",
2634 EET_T_UNKNOW, EET_G_LIST,
2635 0, 0, NULL, _eet_st1_dd());
2636 eet_data_descriptor_element_add(unified, "ST2",
2637 EET_T_UNKNOW, EET_G_LIST,
2638 0, 0, NULL, _eet_st2_dd());
2639
2640 EET_DATA_DESCRIPTOR_ADD_VARIANT(edd, Eet_Variant_Test,
2641 "data_list", data_list, t, unified);
2642
2643 EET_DATA_DESCRIPTOR_ADD_LIST(m, Eet_List, "list", list, edd);
2644
2645 l = calloc(1, sizeof (Eet_List));
2646
2647#define EVT_NEW(Type_Index) \
2648 evt = calloc(1, sizeof (Eet_Variant_Test)); \
2649 evt->t.type = eet_mapping[Type_Index - 1].name; \
2650 st ## Type_Index = calloc(1, sizeof (Eet_St ## Type_Index)); \
2651 _eet_st ## Type_Index ## _set(st ## Type_Index, i); \
2652 evt->data = st ## Type_Index;
2653
2654 for (i = 0; i < 3; ++i)
2655 {
2656 EVT_NEW(1);
2657 l->list = eina_list_append(l->list, evt);
2658
2659 st1 = calloc(1, sizeof (Eet_St1));
2660 _eet_st1_set(st1, i);
2661 evt->data_list = eina_list_append(evt->data_list, st1);
2662
2663 EVT_NEW(2);
2664 l->list = eina_list_append(l->list, evt);
2665
2666 EVT_NEW(3);
2667 l->list = eina_list_append(l->list, evt);
2668 }
2669
2670 blob = eet_data_descriptor_encode(m, l, &size);
2671 fail_if(!blob || size <= 0);
2672
2673 l = eet_data_descriptor_decode(m, blob, size);
2674 fail_if(!l);
2675
2676 fail_if(eina_list_count(l->list) != 9);
2677
2678#define EVT_CMP(Type_Index) \
2679 evt = eina_list_nth(l->list, i * 3 + Type_Index - 1); \
2680 fail_if(strcmp(evt->t.type, eet_mapping[Type_Index - 1].name) != 0); \
2681 _eet_st ## Type_Index ## _cmp(evt->data, i);
2682
2683 for (i = 0; i < 3; ++i)
2684 {
2685 EVT_CMP(1);
2686
2687 fail_if(!evt->data_list);
2688 fail_if(eina_list_count(evt->data_list) != 1);
2689
2690 st1 = eina_list_data_get(evt->data_list);
2691 _eet_st1_cmp(st1, i);
2692
2693 EVT_CMP(2);
2694 EVT_CMP(3);
2695 }
2696
2697 eet_shutdown();
2698 eina_shutdown();
2699} /* START_TEST */
2700
2701END_TEST
2702
2703Suite *
2704eet_suite(void)
2705{
2706 Suite *s;
2707 TCase *tc;
2708
2709 s = suite_create("Eet");
2710
2711 tc = tcase_create("Eet_Init");
2712 tcase_add_test(tc, eet_test_init);
2713 suite_add_tcase(s, tc);
2714
2715 tc = tcase_create("Eet Data Encoding/Decoding");
2716 tcase_add_test(tc, eet_test_basic_data_type_encoding_decoding);
2717 tcase_add_test(tc, eet_test_data_type_encoding_decoding);
2718 tcase_add_test(tc, eet_test_data_type_dump_undump);
2719 tcase_add_test(tc, eet_fp);
2720 tcase_add_test(tc, eet_test_union);
2721 tcase_add_test(tc, eet_test_variant);
2722 suite_add_tcase(s, tc);
2723
2724 tc = tcase_create("Eet File");
2725 tcase_add_test(tc, eet_file_simple_write);
2726 tcase_add_test(tc, eet_file_data_test);
2727 tcase_add_test(tc, eet_file_data_dump_test);
2728 tcase_add_test(tc, eet_file_fp);
2729 suite_add_tcase(s, tc);
2730
2731 tc = tcase_create("Eet Image");
2732 tcase_add_test(tc, eet_image);
2733 tcase_add_test(tc, eet_small_image);
2734 suite_add_tcase(s, tc);
2735
2736#ifdef HAVE_SIGNATURE
2737 tc = tcase_create("Eet Identity");
2738 tcase_add_test(tc, eet_identity_simple);
2739 tcase_add_test(tc, eet_identity_open_simple);
2740 tcase_add_test(tc, eet_identity_open_pkcs8);
2741 tcase_add_test(tc, eet_identity_open_pkcs8_enc);
2742 suite_add_tcase(s, tc);
2743#endif /* ifdef HAVE_SIGNATURE */
2744
2745#ifdef HAVE_CIPHER
2746 tc = tcase_create("Eet Cipher");
2747 tcase_add_test(tc, eet_cipher_decipher_simple);
2748 suite_add_tcase(s, tc);
2749#endif /* ifdef HAVE_CIPHER */
2750
2751#ifdef EINA_HAVE_THREADS
2752 tc = tcase_create("Eet Cache");
2753 tcase_add_test(tc, eet_cache_concurrency);
2754 suite_add_tcase(s, tc);
2755#endif /* ifdef EFL_HAVE_THREADS */
2756
2757 tc = tcase_create("Eet Connection");
2758 tcase_add_test(tc, eet_connection_check);
2759 suite_add_tcase(s, tc);
2760
2761 return s;
2762} /* eet_suite */
2763
2764int
2765main(void)
2766{
2767 Suite *s;
2768 SRunner *sr;
2769 int failed_count;
2770
2771 s = eet_suite();
2772 sr = srunner_create(s);
2773 srunner_run_all(sr, CK_ENV);
2774 failed_count = srunner_ntests_failed(sr);
2775 srunner_free(sr);
2776
2777 return (failed_count == 0) ? EXIT_SUCCESS : EXIT_FAILURE;
2778} /* main */
2779
diff --git a/libraries/eet/src/tests/eet_suite.h b/libraries/eet/src/tests/eet_suite.h
deleted file mode 100644
index c5c91aa..0000000
--- a/libraries/eet/src/tests/eet_suite.h
+++ /dev/null
@@ -1,9 +0,0 @@
1#ifndef _EET_SUITE_H
2# define _EET_SUITE_H
3
4#include "Eet.h"
5
6void
7eet_test_setup_eddc(Eet_Data_Descriptor_Class *eddc);
8
9#endif /* _EET_SUITE_H */
diff --git a/libraries/eet/src/tests/key.pem b/libraries/eet/src/tests/key.pem
deleted file mode 100644
index 74763ca..0000000
--- a/libraries/eet/src/tests/key.pem
+++ /dev/null
@@ -1,15 +0,0 @@
1-----BEGIN RSA PRIVATE KEY-----
2MIICXAIBAAKBgQDIhOPOnkTinjxtP+t/Q+F00w0fV0kVqdcamc6uz/o41kRW2fzF
3lSFc5HODEZvN1DqJWz4++i4zNdHLHmlQISuxvQh6dnbq+GpVr3Qlzx+UPizzhUvY
4DMdCc/RGXhxzh2Si8iXSkpqLfs5bsCUy3tPNUUVMMzSnLeia1VRv+0piEwIDAQAB
5AoGAfLLHyNJ8HEIzae16UmawaqplWrw5YxOABbbo5aXJAledoDVoEKexW8dmXngw
64Eu/K3RmvVtwJ8CsexiqfX5jYMU+YKRbww6Vqr/punIUhiEHVarHMFKG9yo14qSa
7z2xPgXvC5p7/Rhci+rAUp36S5kIHch5sLhEEcJayymyzDyECQQD/5B3JdpcovrSI
8+nyZ8Iub2+I3f3uox6m1DKxHead26ICoIr7VCnPV5J1gLIB2MofVCbKhmy4PNi5a
90QdvazJfAkEAyJq9Y+9SQ4sCOVDrFklJxhXuZE4WbnR32XsBdnQ9dauo0E2vDVkv
106mHnzMWroTjLv4hH5nufE5NvMo8PNGB0zQJAFOKkf737JmsyRv/Szamxa14t/4Ob
11LzJkqo9HPGo0feMKJS74zmCVBb8sDR50ubD0HzI0bzZAMyOj8uuepLxmFwJAH+RR
125bhfeLN52AjgRvvBycckzjeH42mKwD2I/v794l43CV7ATLv4HSgRhQGMBqaT5dBR
13tffDU4Zl8EDEJwyKpQJBAJ2NNacURTyavU699QJOIdGAsA4KXici8H3PuuWMtHLR
14RKdPFeaCRn+9p7Tglf0rH9hUGOpUXHYD3+ECt6gnVDc=
15-----END RSA PRIVATE KEY-----
diff --git a/libraries/eet/src/tests/key_enc.pem b/libraries/eet/src/tests/key_enc.pem
deleted file mode 100644
index 83c1ba2..0000000
--- a/libraries/eet/src/tests/key_enc.pem
+++ /dev/null
@@ -1,17 +0,0 @@
1-----BEGIN ENCRYPTED PRIVATE KEY-----
2MIICxjBABgkqhkiG9w0BBQ0wMzAbBgkqhkiG9w0BBQwwDgQILLqDZE1i0Y8CAggA
3MBQGCCqGSIb3DQMHBAjwbnSdTCCDOASCAoB0rMuSIXrzqFQnCexMkC9A5jyd+HvC
42UV6EWIfFU4yBvp+2dfHg6RKUoZ0wGk8FxAkaAj+boVwf16PPXXQ70AQBb0iGeb4
5YLdjDF2zSoIK3SbsWrhAfJhSMbcMftEZnLTYxLSkTv5R8jb0IPybVNTqFf+KmGav
6DwyRVQrdAxIYdJSPwd61Fhs1VqzptmQ8DLKHy35X1fIro3py4jncBhsuqf6H3yj1
7ZFuzCPnwB8unASgbTPD43yObrjyWTjbTtp59WavVdnNS+m7QNW+OfxznHUUJXtMz
8/EniglUhR1Uf75wpMpQIPfC77Cary0Y4iLGQZiF1C0WjQzMBufckJFJVRFGfkkMl
9ijlaijLUYMqENJ6wsyK5lihsoBCzIDoqI375s9pdeln8sd33Yu+L/Gu4Xo8Bh5cM
106mlo9WUgw5KibmlZHGEAGdKxcvL0ywswuwQ6yhwcdvCAt6MfrWJNpksa9JmpXJi8
11c21lHwnoyG1DgSqY5VhRyitfnuY3Jegj+7njhooiAJM9w7fxpafN9oxiaJBvPFqd
12lfJ42Pj5rkjjVqXOJX7Cf7sF85tW7ygwdGWyXvHn2fhQ+vjaDtZalry//Xytet4r
13lvTerO6M6WVMk2yM7vdeBU7c74LVIJmwGR6d837OPax1V+Z9yq6zDuJAQ3l9mtmu
14gowV3xInTFRsnSOQcYW5y8dNnugR9FBh8f1NI7SPyW0reeVbPXXhRxg+TyogIXhh
15yAfWJ6dDLZ31EVCdqRKxK7b9u2r3dsuaiwT1jFg59Eu2AifFi0j7aDA1lGIKoj3C
16cPDwJd8weC+UoWpWX/O4KOpaU62Rwt5wRoOxELG6lHy7cOjZgLmwjg1G
17-----END ENCRYPTED PRIVATE KEY-----
diff --git a/libraries/eet/src/tests/key_enc_none.pem b/libraries/eet/src/tests/key_enc_none.pem
deleted file mode 100644
index 1163851..0000000
--- a/libraries/eet/src/tests/key_enc_none.pem
+++ /dev/null
@@ -1,16 +0,0 @@
1-----BEGIN PRIVATE KEY-----
2MIICdgIBADANBgkqhkiG9w0BAQEFAASCAmAwggJcAgEAAoGBAMiE486eROKePG0/
3639D4XTTDR9XSRWp1xqZzq7P+jjWRFbZ/MWVIVzkc4MRm83UOolbPj76LjM10cse
4aVAhK7G9CHp2dur4alWvdCXPH5Q+LPOFS9gMx0Jz9EZeHHOHZKLyJdKSmot+zluw
5JTLe081RRUwzNKct6JrVVG/7SmITAgMBAAECgYB8ssfI0nwcQjNp7XpSZrBqqmVa
6vDljE4AFtujlpckCV52gNWgQp7Fbx2ZeeDDgS78rdGa9W3AnwKx7GKp9fmNgxT5g
7pFvDDpWqv+m6chSGIQdVqscwUob3KjXipJrPbE+Be8Lmnv9GFyL6sBSnfpLmQgdy
8HmwuEQRwlrLKbLMPIQJBAP/kHcl2lyi+tIj6fJnwi5vb4jd/e6jHqbUMrEd5p3bo
9gKgivtUKc9XknWAsgHYyh9UJsqGbLg82LlrRB29rMl8CQQDImr1j71JDiwI5UOsW
10SUnGFe5kThZudHfZewF2dD11q6jQTa8NWS/qYefMxauhOMu/iEfme58Tk28yjw80
11YHTNAkAU4qR/vfsmazJG/9LNqbFrXi3/g5svMmSqj0c8ajR94wolLvjOYJUFvywN
12HnS5sPQfMjRvNkAzI6Py656kvGYXAkAf5FHluF94s3nYCOBG+8HJxyTON4fjaYrA
13PYj+/v3iXjcJXsBMu/gdKBGFAYwGppPl0FG198NThmXwQMQnDIqlAkEAnY01pxRF
14PJq9Tr31Ak4h0YCwDgpeJyLwfc+65Yy0ctFEp08V5oJGf72ntOCV/Ssf2FQY6lRc
15dgPf4QK3qCdUNw==
16-----END PRIVATE KEY-----