aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/libraries/eet/src/examples
diff options
context:
space:
mode:
authorDavid Walter Seikel2013-01-13 17:29:19 +1000
committerDavid Walter Seikel2013-01-13 17:29:19 +1000
commit07274513e984f0b5544586c74508ccd16e7dcafa (patch)
treeb32ff2a9136fbc1a4a6a0ed1e4d79cde0f5f16d9 /libraries/eet/src/examples
parentAdded Irrlicht 1.8, but without all the Windows binaries. (diff)
downloadSledjHamr-07274513e984f0b5544586c74508ccd16e7dcafa.zip
SledjHamr-07274513e984f0b5544586c74508ccd16e7dcafa.tar.gz
SledjHamr-07274513e984f0b5544586c74508ccd16e7dcafa.tar.bz2
SledjHamr-07274513e984f0b5544586c74508ccd16e7dcafa.tar.xz
Remove EFL, since it's been released now.
Diffstat (limited to 'libraries/eet/src/examples')
-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
9 files changed, 0 insertions, 3037 deletions
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