diff options
Diffstat (limited to 'libraries/eet/src/examples')
-rw-r--r-- | libraries/eet/src/examples/Makefile.am | 50 | ||||
-rw-r--r-- | libraries/eet/src/examples/Makefile.in | 728 | ||||
-rw-r--r-- | libraries/eet/src/examples/eet-basic.c | 40 | ||||
-rw-r--r-- | libraries/eet/src/examples/eet-data-cipher_decipher.c | 119 | ||||
-rw-r--r-- | libraries/eet/src/examples/eet-data-file_descriptor_01.c | 529 | ||||
-rw-r--r-- | libraries/eet/src/examples/eet-data-file_descriptor_02.c | 944 | ||||
-rw-r--r-- | libraries/eet/src/examples/eet-data-nested.c | 272 | ||||
-rw-r--r-- | libraries/eet/src/examples/eet-data-simple.c | 224 | ||||
-rw-r--r-- | libraries/eet/src/examples/eet-file.c | 127 |
9 files changed, 3033 insertions, 0 deletions
diff --git a/libraries/eet/src/examples/Makefile.am b/libraries/eet/src/examples/Makefile.am new file mode 100644 index 0000000..8279445 --- /dev/null +++ b/libraries/eet/src/examples/Makefile.am | |||
@@ -0,0 +1,50 @@ | |||
1 | MAINTAINERCLEANFILES = Makefile.in | ||
2 | |||
3 | pkglibdir = $(datadir)/$(PACKAGE)/examples | ||
4 | |||
5 | if BUILD_EXAMPLES | ||
6 | AM_CPPFLAGS = \ | ||
7 | -I. \ | ||
8 | -I$(top_srcdir)/src/lib \ | ||
9 | @EINA_CFLAGS@ | ||
10 | |||
11 | pkglib_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 | |||
13 | eet_basic_SOURCES = eet-basic.c | ||
14 | eet_basic_LDADD = $(top_builddir)/src/lib/libeet.la @EINA_LIBS@ | ||
15 | |||
16 | eet_file_SOURCES = eet-file.c | ||
17 | eet_file_LDADD = $(top_builddir)/src/lib/libeet.la @EINA_LIBS@ | ||
18 | |||
19 | eet_data_simple_SOURCES = eet-data-simple.c | ||
20 | eet_data_simple_LDADD = $(top_builddir)/src/lib/libeet.la @EINA_LIBS@ | ||
21 | |||
22 | eet_data_nested_SOURCES = eet-data-nested.c | ||
23 | eet_data_nested_LDADD = $(top_builddir)/src/lib/libeet.la @EINA_LIBS@ | ||
24 | |||
25 | eet_data_file_descriptor_01_SOURCES = eet-data-file_descriptor_01.c | ||
26 | eet_data_file_descriptor_01_LDADD = $(top_builddir)/src/lib/libeet.la @EINA_LIBS@ | ||
27 | |||
28 | eet_data_file_descriptor_02_SOURCES = eet-data-file_descriptor_02.c | ||
29 | eet_data_file_descriptor_02_LDADD = $(top_builddir)/src/lib/libeet.la @EINA_LIBS@ | ||
30 | |||
31 | eet_data_cipher_decipher_SOURCES = eet-data-cipher_decipher.c | ||
32 | eet_data_cipher_decipher_LDADD = $(top_builddir)/src/lib/libeet.la @EINA_LIBS@ | ||
33 | |||
34 | endif | ||
35 | |||
36 | filesdir = $(datadir)/$(PACKAGE)/examples | ||
37 | files_DATA = | ||
38 | |||
39 | if INSTALL_EXAMPLES | ||
40 | |||
41 | files_DATA += \ | ||
42 | eet-basic.c \ | ||
43 | eet-file.c \ | ||
44 | eet-data-simple.c \ | ||
45 | eet-data-nested.c \ | ||
46 | eet-data-file_descriptor_01.c \ | ||
47 | eet-data-file_descriptor_02.c \ | ||
48 | eet-data-cipher_decipher.c | ||
49 | |||
50 | endif | ||
diff --git a/libraries/eet/src/examples/Makefile.in b/libraries/eet/src/examples/Makefile.in new file mode 100644 index 0000000..d24b728 --- /dev/null +++ b/libraries/eet/src/examples/Makefile.in | |||
@@ -0,0 +1,728 @@ | |||
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 | |||
19 | VPATH = @srcdir@ | ||
20 | pkgdatadir = $(datadir)/@PACKAGE@ | ||
21 | pkgincludedir = $(includedir)/@PACKAGE@ | ||
22 | pkglibexecdir = $(libexecdir)/@PACKAGE@ | ||
23 | am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd | ||
24 | install_sh_DATA = $(install_sh) -c -m 644 | ||
25 | install_sh_PROGRAM = $(install_sh) -c | ||
26 | install_sh_SCRIPT = $(install_sh) -c | ||
27 | INSTALL_HEADER = $(INSTALL_DATA) | ||
28 | transform = $(program_transform_name) | ||
29 | NORMAL_INSTALL = : | ||
30 | PRE_INSTALL = : | ||
31 | POST_INSTALL = : | ||
32 | NORMAL_UNINSTALL = : | ||
33 | PRE_UNINSTALL = : | ||
34 | POST_UNINSTALL = : | ||
35 | build_triplet = @build@ | ||
36 | host_triplet = @host@ | ||
37 | @BUILD_EXAMPLES_TRUE@pkglib_PROGRAMS = eet_basic$(EXEEXT) \ | ||
38 | @BUILD_EXAMPLES_TRUE@ eet_file$(EXEEXT) \ | ||
39 | @BUILD_EXAMPLES_TRUE@ eet_data_simple$(EXEEXT) \ | ||
40 | @BUILD_EXAMPLES_TRUE@ eet_data_nested$(EXEEXT) \ | ||
41 | @BUILD_EXAMPLES_TRUE@ eet_data_file_descriptor_01$(EXEEXT) \ | ||
42 | @BUILD_EXAMPLES_TRUE@ eet_data_file_descriptor_02$(EXEEXT) \ | ||
43 | @BUILD_EXAMPLES_TRUE@ eet_data_cipher_decipher$(EXEEXT) | ||
44 | @INSTALL_EXAMPLES_TRUE@am__append_1 = \ | ||
45 | @INSTALL_EXAMPLES_TRUE@eet-basic.c \ | ||
46 | @INSTALL_EXAMPLES_TRUE@eet-file.c \ | ||
47 | @INSTALL_EXAMPLES_TRUE@eet-data-simple.c \ | ||
48 | @INSTALL_EXAMPLES_TRUE@eet-data-nested.c \ | ||
49 | @INSTALL_EXAMPLES_TRUE@eet-data-file_descriptor_01.c \ | ||
50 | @INSTALL_EXAMPLES_TRUE@eet-data-file_descriptor_02.c \ | ||
51 | @INSTALL_EXAMPLES_TRUE@eet-data-cipher_decipher.c | ||
52 | |||
53 | subdir = src/examples | ||
54 | DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in | ||
55 | ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 | ||
56 | am__aclocal_m4_deps = $(top_srcdir)/m4/ac_attribute.m4 \ | ||
57 | $(top_srcdir)/m4/ac_path_generic.m4 \ | ||
58 | $(top_srcdir)/m4/efl_binary.m4 \ | ||
59 | $(top_srcdir)/m4/efl_compiler_flag.m4 \ | ||
60 | $(top_srcdir)/m4/efl_coverage.m4 \ | ||
61 | $(top_srcdir)/m4/efl_doxygen.m4 \ | ||
62 | $(top_srcdir)/m4/efl_fnmatch.m4 \ | ||
63 | $(top_srcdir)/m4/efl_path_max.m4 $(top_srcdir)/m4/efl_tests.m4 \ | ||
64 | $(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \ | ||
65 | $(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \ | ||
66 | $(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/configure.ac | ||
67 | am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ | ||
68 | $(ACLOCAL_M4) | ||
69 | mkinstalldirs = $(install_sh) -d | ||
70 | CONFIG_HEADER = $(top_builddir)/config.h | ||
71 | CONFIG_CLEAN_FILES = | ||
72 | CONFIG_CLEAN_VPATH_FILES = | ||
73 | am__installdirs = "$(DESTDIR)$(pkglibdir)" "$(DESTDIR)$(filesdir)" | ||
74 | PROGRAMS = $(pkglib_PROGRAMS) | ||
75 | am__eet_basic_SOURCES_DIST = eet-basic.c | ||
76 | @BUILD_EXAMPLES_TRUE@am_eet_basic_OBJECTS = eet-basic.$(OBJEXT) | ||
77 | eet_basic_OBJECTS = $(am_eet_basic_OBJECTS) | ||
78 | @BUILD_EXAMPLES_TRUE@eet_basic_DEPENDENCIES = \ | ||
79 | @BUILD_EXAMPLES_TRUE@ $(top_builddir)/src/lib/libeet.la | ||
80 | AM_V_lt = $(am__v_lt_$(V)) | ||
81 | am__v_lt_ = $(am__v_lt_$(AM_DEFAULT_VERBOSITY)) | ||
82 | am__v_lt_0 = --silent | ||
83 | am__eet_data_cipher_decipher_SOURCES_DIST = \ | ||
84 | eet-data-cipher_decipher.c | ||
85 | @BUILD_EXAMPLES_TRUE@am_eet_data_cipher_decipher_OBJECTS = \ | ||
86 | @BUILD_EXAMPLES_TRUE@ eet-data-cipher_decipher.$(OBJEXT) | ||
87 | eet_data_cipher_decipher_OBJECTS = \ | ||
88 | $(am_eet_data_cipher_decipher_OBJECTS) | ||
89 | @BUILD_EXAMPLES_TRUE@eet_data_cipher_decipher_DEPENDENCIES = \ | ||
90 | @BUILD_EXAMPLES_TRUE@ $(top_builddir)/src/lib/libeet.la | ||
91 | am__eet_data_file_descriptor_01_SOURCES_DIST = \ | ||
92 | eet-data-file_descriptor_01.c | ||
93 | @BUILD_EXAMPLES_TRUE@am_eet_data_file_descriptor_01_OBJECTS = \ | ||
94 | @BUILD_EXAMPLES_TRUE@ eet-data-file_descriptor_01.$(OBJEXT) | ||
95 | eet_data_file_descriptor_01_OBJECTS = \ | ||
96 | $(am_eet_data_file_descriptor_01_OBJECTS) | ||
97 | @BUILD_EXAMPLES_TRUE@eet_data_file_descriptor_01_DEPENDENCIES = \ | ||
98 | @BUILD_EXAMPLES_TRUE@ $(top_builddir)/src/lib/libeet.la | ||
99 | am__eet_data_file_descriptor_02_SOURCES_DIST = \ | ||
100 | eet-data-file_descriptor_02.c | ||
101 | @BUILD_EXAMPLES_TRUE@am_eet_data_file_descriptor_02_OBJECTS = \ | ||
102 | @BUILD_EXAMPLES_TRUE@ eet-data-file_descriptor_02.$(OBJEXT) | ||
103 | eet_data_file_descriptor_02_OBJECTS = \ | ||
104 | $(am_eet_data_file_descriptor_02_OBJECTS) | ||
105 | @BUILD_EXAMPLES_TRUE@eet_data_file_descriptor_02_DEPENDENCIES = \ | ||
106 | @BUILD_EXAMPLES_TRUE@ $(top_builddir)/src/lib/libeet.la | ||
107 | am__eet_data_nested_SOURCES_DIST = eet-data-nested.c | ||
108 | @BUILD_EXAMPLES_TRUE@am_eet_data_nested_OBJECTS = \ | ||
109 | @BUILD_EXAMPLES_TRUE@ eet-data-nested.$(OBJEXT) | ||
110 | eet_data_nested_OBJECTS = $(am_eet_data_nested_OBJECTS) | ||
111 | @BUILD_EXAMPLES_TRUE@eet_data_nested_DEPENDENCIES = \ | ||
112 | @BUILD_EXAMPLES_TRUE@ $(top_builddir)/src/lib/libeet.la | ||
113 | am__eet_data_simple_SOURCES_DIST = eet-data-simple.c | ||
114 | @BUILD_EXAMPLES_TRUE@am_eet_data_simple_OBJECTS = \ | ||
115 | @BUILD_EXAMPLES_TRUE@ eet-data-simple.$(OBJEXT) | ||
116 | eet_data_simple_OBJECTS = $(am_eet_data_simple_OBJECTS) | ||
117 | @BUILD_EXAMPLES_TRUE@eet_data_simple_DEPENDENCIES = \ | ||
118 | @BUILD_EXAMPLES_TRUE@ $(top_builddir)/src/lib/libeet.la | ||
119 | am__eet_file_SOURCES_DIST = eet-file.c | ||
120 | @BUILD_EXAMPLES_TRUE@am_eet_file_OBJECTS = eet-file.$(OBJEXT) | ||
121 | eet_file_OBJECTS = $(am_eet_file_OBJECTS) | ||
122 | @BUILD_EXAMPLES_TRUE@eet_file_DEPENDENCIES = \ | ||
123 | @BUILD_EXAMPLES_TRUE@ $(top_builddir)/src/lib/libeet.la | ||
124 | DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) | ||
125 | depcomp = $(SHELL) $(top_srcdir)/depcomp | ||
126 | am__depfiles_maybe = depfiles | ||
127 | am__mv = mv -f | ||
128 | COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ | ||
129 | $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) | ||
130 | LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ | ||
131 | $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \ | ||
132 | $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ | ||
133 | $(AM_CFLAGS) $(CFLAGS) | ||
134 | AM_V_CC = $(am__v_CC_$(V)) | ||
135 | am__v_CC_ = $(am__v_CC_$(AM_DEFAULT_VERBOSITY)) | ||
136 | am__v_CC_0 = @echo " CC " $@; | ||
137 | AM_V_at = $(am__v_at_$(V)) | ||
138 | am__v_at_ = $(am__v_at_$(AM_DEFAULT_VERBOSITY)) | ||
139 | am__v_at_0 = @ | ||
140 | CCLD = $(CC) | ||
141 | LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ | ||
142 | $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ | ||
143 | $(AM_LDFLAGS) $(LDFLAGS) -o $@ | ||
144 | AM_V_CCLD = $(am__v_CCLD_$(V)) | ||
145 | am__v_CCLD_ = $(am__v_CCLD_$(AM_DEFAULT_VERBOSITY)) | ||
146 | am__v_CCLD_0 = @echo " CCLD " $@; | ||
147 | AM_V_GEN = $(am__v_GEN_$(V)) | ||
148 | am__v_GEN_ = $(am__v_GEN_$(AM_DEFAULT_VERBOSITY)) | ||
149 | am__v_GEN_0 = @echo " GEN " $@; | ||
150 | SOURCES = $(eet_basic_SOURCES) $(eet_data_cipher_decipher_SOURCES) \ | ||
151 | $(eet_data_file_descriptor_01_SOURCES) \ | ||
152 | $(eet_data_file_descriptor_02_SOURCES) \ | ||
153 | $(eet_data_nested_SOURCES) $(eet_data_simple_SOURCES) \ | ||
154 | $(eet_file_SOURCES) | ||
155 | DIST_SOURCES = $(am__eet_basic_SOURCES_DIST) \ | ||
156 | $(am__eet_data_cipher_decipher_SOURCES_DIST) \ | ||
157 | $(am__eet_data_file_descriptor_01_SOURCES_DIST) \ | ||
158 | $(am__eet_data_file_descriptor_02_SOURCES_DIST) \ | ||
159 | $(am__eet_data_nested_SOURCES_DIST) \ | ||
160 | $(am__eet_data_simple_SOURCES_DIST) \ | ||
161 | $(am__eet_file_SOURCES_DIST) | ||
162 | am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; | ||
163 | am__vpath_adj = case $$p in \ | ||
164 | $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ | ||
165 | *) f=$$p;; \ | ||
166 | esac; | ||
167 | am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; | ||
168 | am__install_max = 40 | ||
169 | am__nobase_strip_setup = \ | ||
170 | srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` | ||
171 | am__nobase_strip = \ | ||
172 | for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" | ||
173 | am__nobase_list = $(am__nobase_strip_setup); \ | ||
174 | for p in $$list; do echo "$$p $$p"; done | \ | ||
175 | sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ | ||
176 | $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ | ||
177 | if (++n[$$2] == $(am__install_max)) \ | ||
178 | { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ | ||
179 | END { for (dir in files) print dir, files[dir] }' | ||
180 | am__base_list = \ | ||
181 | sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ | ||
182 | sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | ||
183 | DATA = $(files_DATA) | ||
184 | ETAGS = etags | ||
185 | CTAGS = ctags | ||
186 | DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) | ||
187 | pkglibdir = $(datadir)/$(PACKAGE)/examples | ||
188 | ACLOCAL = @ACLOCAL@ | ||
189 | ALLOCA = @ALLOCA@ | ||
190 | AMTAR = @AMTAR@ | ||
191 | AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ | ||
192 | AR = @AR@ | ||
193 | AS = @AS@ | ||
194 | AUTOCONF = @AUTOCONF@ | ||
195 | AUTOHEADER = @AUTOHEADER@ | ||
196 | AUTOMAKE = @AUTOMAKE@ | ||
197 | AWK = @AWK@ | ||
198 | CC = @CC@ | ||
199 | CCDEPMODE = @CCDEPMODE@ | ||
200 | CFLAGS = @CFLAGS@ | ||
201 | CHECK_CFLAGS = @CHECK_CFLAGS@ | ||
202 | CHECK_LIBS = @CHECK_LIBS@ | ||
203 | CPP = @CPP@ | ||
204 | CPPFLAGS = @CPPFLAGS@ | ||
205 | CYGPATH_W = @CYGPATH_W@ | ||
206 | DEBUG_CFLAGS = @DEBUG_CFLAGS@ | ||
207 | DEFS = @DEFS@ | ||
208 | DEPDIR = @DEPDIR@ | ||
209 | DLLTOOL = @DLLTOOL@ | ||
210 | DSYMUTIL = @DSYMUTIL@ | ||
211 | DUMPBIN = @DUMPBIN@ | ||
212 | ECHO_C = @ECHO_C@ | ||
213 | ECHO_N = @ECHO_N@ | ||
214 | ECHO_T = @ECHO_T@ | ||
215 | EET_CFLAGS = @EET_CFLAGS@ | ||
216 | EET_CPPFLAGS = @EET_CPPFLAGS@ | ||
217 | EET_LIBS = @EET_LIBS@ | ||
218 | EET_PRG = @EET_PRG@ | ||
219 | EFL_COVERAGE_CFLAGS = @EFL_COVERAGE_CFLAGS@ | ||
220 | EFL_COVERAGE_LIBS = @EFL_COVERAGE_LIBS@ | ||
221 | EFL_EET_BUILD = @EFL_EET_BUILD@ | ||
222 | EFL_FNMATCH_LIBS = @EFL_FNMATCH_LIBS@ | ||
223 | EGREP = @EGREP@ | ||
224 | EINA_CFLAGS = @EINA_CFLAGS@ | ||
225 | EINA_LIBS = @EINA_LIBS@ | ||
226 | EVIL_CFLAGS = @EVIL_CFLAGS@ | ||
227 | EVIL_LIBS = @EVIL_LIBS@ | ||
228 | EXEEXT = @EXEEXT@ | ||
229 | FGREP = @FGREP@ | ||
230 | GNUTLS_CFLAGS = @GNUTLS_CFLAGS@ | ||
231 | GNUTLS_LIBS = @GNUTLS_LIBS@ | ||
232 | GREP = @GREP@ | ||
233 | INSTALL = @INSTALL@ | ||
234 | INSTALL_DATA = @INSTALL_DATA@ | ||
235 | INSTALL_PROGRAM = @INSTALL_PROGRAM@ | ||
236 | INSTALL_SCRIPT = @INSTALL_SCRIPT@ | ||
237 | INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ | ||
238 | LD = @LD@ | ||
239 | LDFLAGS = @LDFLAGS@ | ||
240 | LIBGCRYPT_CFLAGS = @LIBGCRYPT_CFLAGS@ | ||
241 | LIBGCRYPT_CONFIG = @LIBGCRYPT_CONFIG@ | ||
242 | LIBGCRYPT_LIBS = @LIBGCRYPT_LIBS@ | ||
243 | LIBOBJS = @LIBOBJS@ | ||
244 | LIBS = @LIBS@ | ||
245 | LIBTOOL = @LIBTOOL@ | ||
246 | LIPO = @LIPO@ | ||
247 | LN_S = @LN_S@ | ||
248 | LTLIBOBJS = @LTLIBOBJS@ | ||
249 | MAKEINFO = @MAKEINFO@ | ||
250 | MKDIR_P = @MKDIR_P@ | ||
251 | NM = @NM@ | ||
252 | NMEDIT = @NMEDIT@ | ||
253 | OBJDUMP = @OBJDUMP@ | ||
254 | OBJEXT = @OBJEXT@ | ||
255 | OPENSSL_CFLAGS = @OPENSSL_CFLAGS@ | ||
256 | OPENSSL_LIBS = @OPENSSL_LIBS@ | ||
257 | OTOOL = @OTOOL@ | ||
258 | OTOOL64 = @OTOOL64@ | ||
259 | PACKAGE = @PACKAGE@ | ||
260 | PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ | ||
261 | PACKAGE_NAME = @PACKAGE_NAME@ | ||
262 | PACKAGE_STRING = @PACKAGE_STRING@ | ||
263 | PACKAGE_TARNAME = @PACKAGE_TARNAME@ | ||
264 | PACKAGE_URL = @PACKAGE_URL@ | ||
265 | PACKAGE_VERSION = @PACKAGE_VERSION@ | ||
266 | PATH_SEPARATOR = @PATH_SEPARATOR@ | ||
267 | PKG_CONFIG = @PKG_CONFIG@ | ||
268 | PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ | ||
269 | PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ | ||
270 | RANLIB = @RANLIB@ | ||
271 | SED = @SED@ | ||
272 | SET_MAKE = @SET_MAKE@ | ||
273 | SHELL = @SHELL@ | ||
274 | STRIP = @STRIP@ | ||
275 | VERSION = @VERSION@ | ||
276 | VMAJ = @VMAJ@ | ||
277 | abs_builddir = @abs_builddir@ | ||
278 | abs_srcdir = @abs_srcdir@ | ||
279 | abs_top_builddir = @abs_top_builddir@ | ||
280 | abs_top_srcdir = @abs_top_srcdir@ | ||
281 | ac_ct_CC = @ac_ct_CC@ | ||
282 | ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ | ||
283 | am__include = @am__include@ | ||
284 | am__leading_dot = @am__leading_dot@ | ||
285 | am__quote = @am__quote@ | ||
286 | am__tar = @am__tar@ | ||
287 | am__untar = @am__untar@ | ||
288 | bindir = @bindir@ | ||
289 | build = @build@ | ||
290 | build_alias = @build_alias@ | ||
291 | build_cpu = @build_cpu@ | ||
292 | build_os = @build_os@ | ||
293 | build_vendor = @build_vendor@ | ||
294 | builddir = @builddir@ | ||
295 | datadir = @datadir@ | ||
296 | datarootdir = @datarootdir@ | ||
297 | docdir = @docdir@ | ||
298 | dvidir = @dvidir@ | ||
299 | efl_doxygen = @efl_doxygen@ | ||
300 | efl_have_doxygen = @efl_have_doxygen@ | ||
301 | exec_prefix = @exec_prefix@ | ||
302 | have_lcov = @have_lcov@ | ||
303 | host = @host@ | ||
304 | host_alias = @host_alias@ | ||
305 | host_cpu = @host_cpu@ | ||
306 | host_os = @host_os@ | ||
307 | host_vendor = @host_vendor@ | ||
308 | htmldir = @htmldir@ | ||
309 | includedir = @includedir@ | ||
310 | infodir = @infodir@ | ||
311 | install_sh = @install_sh@ | ||
312 | libdir = @libdir@ | ||
313 | libexecdir = @libexecdir@ | ||
314 | localedir = @localedir@ | ||
315 | localstatedir = @localstatedir@ | ||
316 | lt_ECHO = @lt_ECHO@ | ||
317 | lt_enable_auto_import = @lt_enable_auto_import@ | ||
318 | mandir = @mandir@ | ||
319 | mkdir_p = @mkdir_p@ | ||
320 | oldincludedir = @oldincludedir@ | ||
321 | pdfdir = @pdfdir@ | ||
322 | pkgconfig_requires_private = @pkgconfig_requires_private@ | ||
323 | prefix = @prefix@ | ||
324 | program_transform_name = @program_transform_name@ | ||
325 | psdir = @psdir@ | ||
326 | release_info = @release_info@ | ||
327 | requirement_eet = @requirement_eet@ | ||
328 | sbindir = @sbindir@ | ||
329 | sharedstatedir = @sharedstatedir@ | ||
330 | srcdir = @srcdir@ | ||
331 | sysconfdir = @sysconfdir@ | ||
332 | target_alias = @target_alias@ | ||
333 | top_build_prefix = @top_build_prefix@ | ||
334 | top_builddir = @top_builddir@ | ||
335 | top_srcdir = @top_srcdir@ | ||
336 | version_info = @version_info@ | ||
337 | MAINTAINERCLEANFILES = Makefile.in | ||
338 | @BUILD_EXAMPLES_TRUE@AM_CPPFLAGS = \ | ||
339 | @BUILD_EXAMPLES_TRUE@-I. \ | ||
340 | @BUILD_EXAMPLES_TRUE@-I$(top_srcdir)/src/lib \ | ||
341 | @BUILD_EXAMPLES_TRUE@@EINA_CFLAGS@ | ||
342 | |||
343 | @BUILD_EXAMPLES_TRUE@eet_basic_SOURCES = eet-basic.c | ||
344 | @BUILD_EXAMPLES_TRUE@eet_basic_LDADD = $(top_builddir)/src/lib/libeet.la @EINA_LIBS@ | ||
345 | @BUILD_EXAMPLES_TRUE@eet_file_SOURCES = eet-file.c | ||
346 | @BUILD_EXAMPLES_TRUE@eet_file_LDADD = $(top_builddir)/src/lib/libeet.la @EINA_LIBS@ | ||
347 | @BUILD_EXAMPLES_TRUE@eet_data_simple_SOURCES = eet-data-simple.c | ||
348 | @BUILD_EXAMPLES_TRUE@eet_data_simple_LDADD = $(top_builddir)/src/lib/libeet.la @EINA_LIBS@ | ||
349 | @BUILD_EXAMPLES_TRUE@eet_data_nested_SOURCES = eet-data-nested.c | ||
350 | @BUILD_EXAMPLES_TRUE@eet_data_nested_LDADD = $(top_builddir)/src/lib/libeet.la @EINA_LIBS@ | ||
351 | @BUILD_EXAMPLES_TRUE@eet_data_file_descriptor_01_SOURCES = eet-data-file_descriptor_01.c | ||
352 | @BUILD_EXAMPLES_TRUE@eet_data_file_descriptor_01_LDADD = $(top_builddir)/src/lib/libeet.la @EINA_LIBS@ | ||
353 | @BUILD_EXAMPLES_TRUE@eet_data_file_descriptor_02_SOURCES = eet-data-file_descriptor_02.c | ||
354 | @BUILD_EXAMPLES_TRUE@eet_data_file_descriptor_02_LDADD = $(top_builddir)/src/lib/libeet.la @EINA_LIBS@ | ||
355 | @BUILD_EXAMPLES_TRUE@eet_data_cipher_decipher_SOURCES = eet-data-cipher_decipher.c | ||
356 | @BUILD_EXAMPLES_TRUE@eet_data_cipher_decipher_LDADD = $(top_builddir)/src/lib/libeet.la @EINA_LIBS@ | ||
357 | filesdir = $(datadir)/$(PACKAGE)/examples | ||
358 | files_DATA = $(am__append_1) | ||
359 | all: all-am | ||
360 | |||
361 | .SUFFIXES: | ||
362 | .SUFFIXES: .c .lo .o .obj | ||
363 | $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) | ||
364 | @for dep in $?; do \ | ||
365 | case '$(am__configure_deps)' in \ | ||
366 | *$$dep*) \ | ||
367 | ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ | ||
368 | && { if test -f $@; then exit 0; else break; fi; }; \ | ||
369 | exit 1;; \ | ||
370 | esac; \ | ||
371 | done; \ | ||
372 | echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu src/examples/Makefile'; \ | ||
373 | $(am__cd) $(top_srcdir) && \ | ||
374 | $(AUTOMAKE) --gnu src/examples/Makefile | ||
375 | .PRECIOUS: Makefile | ||
376 | Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status | ||
377 | @case '$?' in \ | ||
378 | *config.status*) \ | ||
379 | cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ | ||
380 | *) \ | ||
381 | echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ | ||
382 | cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ | ||
383 | esac; | ||
384 | |||
385 | $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) | ||
386 | cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh | ||
387 | |||
388 | $(top_srcdir)/configure: $(am__configure_deps) | ||
389 | cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh | ||
390 | $(ACLOCAL_M4): $(am__aclocal_m4_deps) | ||
391 | cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh | ||
392 | $(am__aclocal_m4_deps): | ||
393 | install-pkglibPROGRAMS: $(pkglib_PROGRAMS) | ||
394 | @$(NORMAL_INSTALL) | ||
395 | test -z "$(pkglibdir)" || $(MKDIR_P) "$(DESTDIR)$(pkglibdir)" | ||
396 | @list='$(pkglib_PROGRAMS)'; test -n "$(pkglibdir)" || list=; \ | ||
397 | for p in $$list; do echo "$$p $$p"; done | \ | ||
398 | sed 's/$(EXEEXT)$$//' | \ | ||
399 | while read p p1; do if test -f $$p || test -f $$p1; \ | ||
400 | then echo "$$p"; echo "$$p"; else :; fi; \ | ||
401 | done | \ | ||
402 | sed -e 'p;s,.*/,,;n;h' -e 's|.*|.|' \ | ||
403 | -e 'p;x;s,.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/' | \ | ||
404 | sed 'N;N;N;s,\n, ,g' | \ | ||
405 | $(AWK) 'BEGIN { files["."] = ""; dirs["."] = 1 } \ | ||
406 | { d=$$3; if (dirs[d] != 1) { print "d", d; dirs[d] = 1 } \ | ||
407 | if ($$2 == $$4) files[d] = files[d] " " $$1; \ | ||
408 | else { print "f", $$3 "/" $$4, $$1; } } \ | ||
409 | END { for (d in files) print "f", d, files[d] }' | \ | ||
410 | while read type dir files; do \ | ||
411 | if test "$$dir" = .; then dir=; else dir=/$$dir; fi; \ | ||
412 | test -z "$$files" || { \ | ||
413 | echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL_PROGRAM) $$files '$(DESTDIR)$(pkglibdir)$$dir'"; \ | ||
414 | $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL_PROGRAM) $$files "$(DESTDIR)$(pkglibdir)$$dir" || exit $$?; \ | ||
415 | } \ | ||
416 | ; done | ||
417 | |||
418 | uninstall-pkglibPROGRAMS: | ||
419 | @$(NORMAL_UNINSTALL) | ||
420 | @list='$(pkglib_PROGRAMS)'; test -n "$(pkglibdir)" || list=; \ | ||
421 | files=`for p in $$list; do echo "$$p"; done | \ | ||
422 | sed -e 'h;s,^.*/,,;s/$(EXEEXT)$$//;$(transform)' \ | ||
423 | -e 's/$$/$(EXEEXT)/' `; \ | ||
424 | test -n "$$list" || exit 0; \ | ||
425 | echo " ( cd '$(DESTDIR)$(pkglibdir)' && rm -f" $$files ")"; \ | ||
426 | cd "$(DESTDIR)$(pkglibdir)" && rm -f $$files | ||
427 | |||
428 | clean-pkglibPROGRAMS: | ||
429 | @list='$(pkglib_PROGRAMS)'; test -n "$$list" || exit 0; \ | ||
430 | echo " rm -f" $$list; \ | ||
431 | rm -f $$list || exit $$?; \ | ||
432 | test -n "$(EXEEXT)" || exit 0; \ | ||
433 | list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \ | ||
434 | echo " rm -f" $$list; \ | ||
435 | rm -f $$list | ||
436 | eet_basic$(EXEEXT): $(eet_basic_OBJECTS) $(eet_basic_DEPENDENCIES) | ||
437 | @rm -f eet_basic$(EXEEXT) | ||
438 | $(AM_V_CCLD)$(LINK) $(eet_basic_OBJECTS) $(eet_basic_LDADD) $(LIBS) | ||
439 | eet_data_cipher_decipher$(EXEEXT): $(eet_data_cipher_decipher_OBJECTS) $(eet_data_cipher_decipher_DEPENDENCIES) | ||
440 | @rm -f eet_data_cipher_decipher$(EXEEXT) | ||
441 | $(AM_V_CCLD)$(LINK) $(eet_data_cipher_decipher_OBJECTS) $(eet_data_cipher_decipher_LDADD) $(LIBS) | ||
442 | eet_data_file_descriptor_01$(EXEEXT): $(eet_data_file_descriptor_01_OBJECTS) $(eet_data_file_descriptor_01_DEPENDENCIES) | ||
443 | @rm -f eet_data_file_descriptor_01$(EXEEXT) | ||
444 | $(AM_V_CCLD)$(LINK) $(eet_data_file_descriptor_01_OBJECTS) $(eet_data_file_descriptor_01_LDADD) $(LIBS) | ||
445 | eet_data_file_descriptor_02$(EXEEXT): $(eet_data_file_descriptor_02_OBJECTS) $(eet_data_file_descriptor_02_DEPENDENCIES) | ||
446 | @rm -f eet_data_file_descriptor_02$(EXEEXT) | ||
447 | $(AM_V_CCLD)$(LINK) $(eet_data_file_descriptor_02_OBJECTS) $(eet_data_file_descriptor_02_LDADD) $(LIBS) | ||
448 | eet_data_nested$(EXEEXT): $(eet_data_nested_OBJECTS) $(eet_data_nested_DEPENDENCIES) | ||
449 | @rm -f eet_data_nested$(EXEEXT) | ||
450 | $(AM_V_CCLD)$(LINK) $(eet_data_nested_OBJECTS) $(eet_data_nested_LDADD) $(LIBS) | ||
451 | eet_data_simple$(EXEEXT): $(eet_data_simple_OBJECTS) $(eet_data_simple_DEPENDENCIES) | ||
452 | @rm -f eet_data_simple$(EXEEXT) | ||
453 | $(AM_V_CCLD)$(LINK) $(eet_data_simple_OBJECTS) $(eet_data_simple_LDADD) $(LIBS) | ||
454 | eet_file$(EXEEXT): $(eet_file_OBJECTS) $(eet_file_DEPENDENCIES) | ||
455 | @rm -f eet_file$(EXEEXT) | ||
456 | $(AM_V_CCLD)$(LINK) $(eet_file_OBJECTS) $(eet_file_LDADD) $(LIBS) | ||
457 | |||
458 | mostlyclean-compile: | ||
459 | -rm -f *.$(OBJEXT) | ||
460 | |||
461 | distclean-compile: | ||
462 | -rm -f *.tab.c | ||
463 | |||
464 | @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eet-basic.Po@am__quote@ | ||
465 | @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eet-data-cipher_decipher.Po@am__quote@ | ||
466 | @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eet-data-file_descriptor_01.Po@am__quote@ | ||
467 | @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eet-data-file_descriptor_02.Po@am__quote@ | ||
468 | @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eet-data-nested.Po@am__quote@ | ||
469 | @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eet-data-simple.Po@am__quote@ | ||
470 | @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eet-file.Po@am__quote@ | ||
471 | |||
472 | .c.o: | ||
473 | @am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< | ||
474 | @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po | ||
475 | @am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ | ||
476 | @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ | ||
477 | @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ | ||
478 | @am__fastdepCC_FALSE@ $(COMPILE) -c $< | ||
479 | |||
480 | .c.obj: | ||
481 | @am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` | ||
482 | @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po | ||
483 | @am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ | ||
484 | @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ | ||
485 | @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ | ||
486 | @am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'` | ||
487 | |||
488 | .c.lo: | ||
489 | @am__fastdepCC_TRUE@ $(AM_V_CC)$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< | ||
490 | @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo | ||
491 | @am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ | ||
492 | @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ | ||
493 | @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ | ||
494 | @am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $< | ||
495 | |||
496 | mostlyclean-libtool: | ||
497 | -rm -f *.lo | ||
498 | |||
499 | clean-libtool: | ||
500 | -rm -rf .libs _libs | ||
501 | install-filesDATA: $(files_DATA) | ||
502 | @$(NORMAL_INSTALL) | ||
503 | test -z "$(filesdir)" || $(MKDIR_P) "$(DESTDIR)$(filesdir)" | ||
504 | @list='$(files_DATA)'; test -n "$(filesdir)" || list=; \ | ||
505 | for p in $$list; do \ | ||
506 | if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ | ||
507 | echo "$$d$$p"; \ | ||
508 | done | $(am__base_list) | \ | ||
509 | while read files; do \ | ||
510 | echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(filesdir)'"; \ | ||
511 | $(INSTALL_DATA) $$files "$(DESTDIR)$(filesdir)" || exit $$?; \ | ||
512 | done | ||
513 | |||
514 | uninstall-filesDATA: | ||
515 | @$(NORMAL_UNINSTALL) | ||
516 | @list='$(files_DATA)'; test -n "$(filesdir)" || list=; \ | ||
517 | files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \ | ||
518 | test -n "$$files" || exit 0; \ | ||
519 | echo " ( cd '$(DESTDIR)$(filesdir)' && rm -f" $$files ")"; \ | ||
520 | cd "$(DESTDIR)$(filesdir)" && rm -f $$files | ||
521 | |||
522 | ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) | ||
523 | list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ | ||
524 | unique=`for i in $$list; do \ | ||
525 | if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ | ||
526 | done | \ | ||
527 | $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ | ||
528 | END { if (nonempty) { for (i in files) print i; }; }'`; \ | ||
529 | mkid -fID $$unique | ||
530 | tags: TAGS | ||
531 | |||
532 | TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ | ||
533 | $(TAGS_FILES) $(LISP) | ||
534 | set x; \ | ||
535 | here=`pwd`; \ | ||
536 | list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ | ||
537 | unique=`for i in $$list; do \ | ||
538 | if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ | ||
539 | done | \ | ||
540 | $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ | ||
541 | END { if (nonempty) { for (i in files) print i; }; }'`; \ | ||
542 | shift; \ | ||
543 | if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ | ||
544 | test -n "$$unique" || unique=$$empty_fix; \ | ||
545 | if test $$# -gt 0; then \ | ||
546 | $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ | ||
547 | "$$@" $$unique; \ | ||
548 | else \ | ||
549 | $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ | ||
550 | $$unique; \ | ||
551 | fi; \ | ||
552 | fi | ||
553 | ctags: CTAGS | ||
554 | CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ | ||
555 | $(TAGS_FILES) $(LISP) | ||
556 | list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ | ||
557 | unique=`for i in $$list; do \ | ||
558 | if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ | ||
559 | done | \ | ||
560 | $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ | ||
561 | END { if (nonempty) { for (i in files) print i; }; }'`; \ | ||
562 | test -z "$(CTAGS_ARGS)$$unique" \ | ||
563 | || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ | ||
564 | $$unique | ||
565 | |||
566 | GTAGS: | ||
567 | here=`$(am__cd) $(top_builddir) && pwd` \ | ||
568 | && $(am__cd) $(top_srcdir) \ | ||
569 | && gtags -i $(GTAGS_ARGS) "$$here" | ||
570 | |||
571 | distclean-tags: | ||
572 | -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags | ||
573 | |||
574 | distdir: $(DISTFILES) | ||
575 | @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ | ||
576 | topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ | ||
577 | list='$(DISTFILES)'; \ | ||
578 | dist_files=`for file in $$list; do echo $$file; done | \ | ||
579 | sed -e "s|^$$srcdirstrip/||;t" \ | ||
580 | -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ | ||
581 | case $$dist_files in \ | ||
582 | */*) $(MKDIR_P) `echo "$$dist_files" | \ | ||
583 | sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ | ||
584 | sort -u` ;; \ | ||
585 | esac; \ | ||
586 | for file in $$dist_files; do \ | ||
587 | if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ | ||
588 | if test -d $$d/$$file; then \ | ||
589 | dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ | ||
590 | if test -d "$(distdir)/$$file"; then \ | ||
591 | find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ | ||
592 | fi; \ | ||
593 | if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ | ||
594 | cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ | ||
595 | find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ | ||
596 | fi; \ | ||
597 | cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ | ||
598 | else \ | ||
599 | test -f "$(distdir)/$$file" \ | ||
600 | || cp -p $$d/$$file "$(distdir)/$$file" \ | ||
601 | || exit 1; \ | ||
602 | fi; \ | ||
603 | done | ||
604 | check-am: all-am | ||
605 | check: check-am | ||
606 | all-am: Makefile $(PROGRAMS) $(DATA) | ||
607 | installdirs: | ||
608 | for dir in "$(DESTDIR)$(pkglibdir)" "$(DESTDIR)$(filesdir)"; do \ | ||
609 | test -z "$$dir" || $(MKDIR_P) "$$dir"; \ | ||
610 | done | ||
611 | install: install-am | ||
612 | install-exec: install-exec-am | ||
613 | install-data: install-data-am | ||
614 | uninstall: uninstall-am | ||
615 | |||
616 | install-am: all-am | ||
617 | @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am | ||
618 | |||
619 | installcheck: installcheck-am | ||
620 | install-strip: | ||
621 | $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ | ||
622 | install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ | ||
623 | `test -z '$(STRIP)' || \ | ||
624 | echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install | ||
625 | mostlyclean-generic: | ||
626 | |||
627 | clean-generic: | ||
628 | |||
629 | distclean-generic: | ||
630 | -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) | ||
631 | -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) | ||
632 | |||
633 | maintainer-clean-generic: | ||
634 | @echo "This command is intended for maintainers to use" | ||
635 | @echo "it deletes files that may require special tools to rebuild." | ||
636 | -test -z "$(MAINTAINERCLEANFILES)" || rm -f $(MAINTAINERCLEANFILES) | ||
637 | clean: clean-am | ||
638 | |||
639 | clean-am: clean-generic clean-libtool clean-pkglibPROGRAMS \ | ||
640 | mostlyclean-am | ||
641 | |||
642 | distclean: distclean-am | ||
643 | -rm -rf ./$(DEPDIR) | ||
644 | -rm -f Makefile | ||
645 | distclean-am: clean-am distclean-compile distclean-generic \ | ||
646 | distclean-tags | ||
647 | |||
648 | dvi: dvi-am | ||
649 | |||
650 | dvi-am: | ||
651 | |||
652 | html: html-am | ||
653 | |||
654 | html-am: | ||
655 | |||
656 | info: info-am | ||
657 | |||
658 | info-am: | ||
659 | |||
660 | install-data-am: install-filesDATA | ||
661 | |||
662 | install-dvi: install-dvi-am | ||
663 | |||
664 | install-dvi-am: | ||
665 | |||
666 | install-exec-am: install-pkglibPROGRAMS | ||
667 | |||
668 | install-html: install-html-am | ||
669 | |||
670 | install-html-am: | ||
671 | |||
672 | install-info: install-info-am | ||
673 | |||
674 | install-info-am: | ||
675 | |||
676 | install-man: | ||
677 | |||
678 | install-pdf: install-pdf-am | ||
679 | |||
680 | install-pdf-am: | ||
681 | |||
682 | install-ps: install-ps-am | ||
683 | |||
684 | install-ps-am: | ||
685 | |||
686 | installcheck-am: | ||
687 | |||
688 | maintainer-clean: maintainer-clean-am | ||
689 | -rm -rf ./$(DEPDIR) | ||
690 | -rm -f Makefile | ||
691 | maintainer-clean-am: distclean-am maintainer-clean-generic | ||
692 | |||
693 | mostlyclean: mostlyclean-am | ||
694 | |||
695 | mostlyclean-am: mostlyclean-compile mostlyclean-generic \ | ||
696 | mostlyclean-libtool | ||
697 | |||
698 | pdf: pdf-am | ||
699 | |||
700 | pdf-am: | ||
701 | |||
702 | ps: ps-am | ||
703 | |||
704 | ps-am: | ||
705 | |||
706 | uninstall-am: uninstall-filesDATA uninstall-pkglibPROGRAMS | ||
707 | |||
708 | .MAKE: install-am install-strip | ||
709 | |||
710 | .PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \ | ||
711 | clean-libtool clean-pkglibPROGRAMS ctags distclean \ | ||
712 | distclean-compile distclean-generic distclean-libtool \ | ||
713 | distclean-tags distdir dvi dvi-am html html-am info info-am \ | ||
714 | install install-am install-data install-data-am install-dvi \ | ||
715 | install-dvi-am install-exec install-exec-am install-filesDATA \ | ||
716 | install-html install-html-am install-info install-info-am \ | ||
717 | install-man install-pdf install-pdf-am install-pkglibPROGRAMS \ | ||
718 | install-ps install-ps-am install-strip installcheck \ | ||
719 | installcheck-am installdirs maintainer-clean \ | ||
720 | maintainer-clean-generic mostlyclean mostlyclean-compile \ | ||
721 | mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \ | ||
722 | tags uninstall uninstall-am uninstall-filesDATA \ | ||
723 | uninstall-pkglibPROGRAMS | ||
724 | |||
725 | |||
726 | # Tell versions [3.59,3.63) of GNU make to not export all variables. | ||
727 | # Otherwise a system limit (for SysV at least) may be exceeded. | ||
728 | .NOEXPORT: | ||
diff --git a/libraries/eet/src/examples/eet-basic.c b/libraries/eet/src/examples/eet-basic.c new file mode 100644 index 0000000..05ff397 --- /dev/null +++ b/libraries/eet/src/examples/eet-basic.c | |||
@@ -0,0 +1,40 @@ | |||
1 | #include <Eet.h> | ||
2 | |||
3 | int | ||
4 | main(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 new file mode 100644 index 0000000..2ef965c --- /dev/null +++ b/libraries/eet/src/examples/eet-data-cipher_decipher.c | |||
@@ -0,0 +1,119 @@ | |||
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 | |||
13 | int | ||
14 | main(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 | |||
109 | error: | ||
110 | if (unlink(file) != 0) | ||
111 | { | ||
112 | fprintf( | ||
113 | stderr, "ERROR: could not unlink file (%s).\n", file); | ||
114 | } | ||
115 | |||
116 | panic: | ||
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 new file mode 100644 index 0000000..4b5b75f --- /dev/null +++ b/libraries/eet/src/examples/eet-data-file_descriptor_01.c | |||
@@ -0,0 +1,529 @@ | |||
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 | ||
13 | typedef 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 | |||
24 | typedef struct | ||
25 | { | ||
26 | const char *dm_to; | ||
27 | const char *message; | ||
28 | } My_Post; | ||
29 | |||
30 | typedef 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 | |||
39 | typedef 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 | ||
48 | static 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. | ||
53 | static Eet_Data_Descriptor *_my_cache_descriptor; | ||
54 | static Eet_Data_Descriptor *_my_account_descriptor; | ||
55 | static Eet_Data_Descriptor *_my_message_descriptor; | ||
56 | static Eet_Data_Descriptor *_my_post_descriptor; | ||
57 | |||
58 | // keep file handle alive, so mmap()ed strings are all alive as well | ||
59 | static Eet_File *_my_cache_file = NULL; | ||
60 | static Eet_Dictionary *_my_cache_dict = NULL; | ||
61 | |||
62 | static 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 | |||
129 | static 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() | ||
140 | static 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 | |||
152 | static 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 | |||
166 | static 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 | |||
175 | static 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 | |||
194 | static 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 | |||
201 | static 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 | |||
215 | static 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 | |||
233 | static 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 | |||
249 | static 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 | |||
259 | static 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 | |||
268 | static 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 | |||
275 | static 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 | |||
311 | static 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 | |||
365 | int | ||
366 | main(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 | |||
520 | end: | ||
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 new file mode 100644 index 0000000..65ba79e --- /dev/null +++ b/libraries/eet/src/examples/eet-data-file_descriptor_02.c | |||
@@ -0,0 +1,944 @@ | |||
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 | |||
13 | typedef enum _Example_Data_Type Example_Data_Type; | ||
14 | typedef struct _Example_Variant_Type Example_Variant_Type; | ||
15 | typedef struct _Example_Variant Example_Variant; | ||
16 | typedef struct _Example_Union Example_Union; | ||
17 | typedef struct _Example_Struct1 Example_Struct1; | ||
18 | typedef struct _Example_Struct2 Example_Struct2; | ||
19 | typedef struct _Example_Struct3 Example_Struct3; | ||
20 | typedef struct _Example_Lists Example_Lists; | ||
21 | |||
22 | enum _Example_Data_Type | ||
23 | { | ||
24 | EET_UNKNOWN = 0, | ||
25 | EET_STRUCT1, | ||
26 | EET_STRUCT2, | ||
27 | EET_STRUCT3 | ||
28 | }; | ||
29 | |||
30 | struct | ||
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 | |||
41 | struct _Example_Struct1 | ||
42 | { | ||
43 | double val1; | ||
44 | int stuff; | ||
45 | const char *s1; | ||
46 | }; | ||
47 | |||
48 | struct _Example_Struct2 | ||
49 | { | ||
50 | Eina_Bool b1; | ||
51 | unsigned long long v1; | ||
52 | }; | ||
53 | |||
54 | struct _Example_Struct3 | ||
55 | { | ||
56 | int body; | ||
57 | }; | ||
58 | |||
59 | struct _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 | |||
70 | struct _Example_Variant_Type | ||
71 | { | ||
72 | const char *type; | ||
73 | Eina_Bool unknow : 1; | ||
74 | }; | ||
75 | |||
76 | struct _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 | |||
85 | struct _Example_Lists | ||
86 | { | ||
87 | Eina_List *union_list; | ||
88 | Eina_List *variant_list; | ||
89 | }; | ||
90 | |||
91 | static 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 | |||
102 | static 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 | |||
111 | static void | ||
112 | _st3_set(Example_Struct3 *st3, | ||
113 | int v1) | ||
114 | { | ||
115 | st3->body = v1; | ||
116 | } /* _st3_set */ | ||
117 | |||
118 | static 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 | |||
140 | static 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 | |||
161 | static 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 | |||
181 | static 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 | |||
193 | static 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 | |||
211 | static 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 | |||
227 | static 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 | */ | ||
245 | static 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 | */ | ||
250 | static Eet_Data_Descriptor *_lists_descriptor; | ||
251 | static Eet_Data_Descriptor *_struct_1_descriptor; | ||
252 | static Eet_Data_Descriptor *_struct_2_descriptor; | ||
253 | static Eet_Data_Descriptor *_struct_3_descriptor; | ||
254 | static Eet_Data_Descriptor *_union_descriptor; | ||
255 | static Eet_Data_Descriptor *_variant_descriptor; | ||
256 | static Eet_Data_Descriptor *_union_unified_descriptor; | ||
257 | static Eet_Data_Descriptor *_variant_unified_descriptor; | ||
258 | |||
259 | /* keep file handle alive, so mmap()ed strings are all alive as | ||
260 | * well */ | ||
261 | static Eet_File *_cache_file = NULL; | ||
262 | static Eet_Dictionary *_cache_dict = NULL; | ||
263 | |||
264 | static 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 | |||
326 | static 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 | */ | ||
342 | static 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 | |||
354 | static 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 | |||
373 | static 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 | |||
391 | static 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 | |||
408 | static 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 | |||
431 | static 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 | |||
459 | static 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 | |||
480 | static 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 | |||
493 | static 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 | |||
505 | static 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 | |||
518 | static 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 | |||
533 | static 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 | |||
560 | static 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 | |||
606 | static 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 | |||
633 | static 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 | |||
672 | int | ||
673 | main(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 | |||
897 | cont: | ||
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 | |||
935 | end: | ||
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 new file mode 100644 index 0000000..a6b0e12 --- /dev/null +++ b/libraries/eet/src/examples/eet-data-nested.c | |||
@@ -0,0 +1,272 @@ | |||
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. | ||
17 | typedef 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 | |||
27 | typedef 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 | ||
36 | static 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. | ||
41 | static Eet_Data_Descriptor *_my_conf_descriptor; | ||
42 | static Eet_Data_Descriptor *_my_conf_sub_descriptor; | ||
43 | |||
44 | static 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 | |||
92 | static 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 | |||
99 | static 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 | |||
124 | static 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 | |||
138 | static 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 | |||
163 | end: | ||
164 | eet_close(ef); | ||
165 | return my_conf; | ||
166 | } /* _my_conf_load */ | ||
167 | |||
168 | static 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 | |||
213 | int | ||
214 | main(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 | |||
265 | end: | ||
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 new file mode 100644 index 0000000..1951fc0 --- /dev/null +++ b/libraries/eet/src/examples/eet-data-simple.c | |||
@@ -0,0 +1,224 @@ | |||
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. | ||
17 | typedef 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 | ||
29 | static 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. | ||
34 | static Eet_Data_Descriptor *_my_conf_descriptor; | ||
35 | |||
36 | static 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 | |||
70 | static void | ||
71 | _my_conf_descriptor_shutdown(void) | ||
72 | { | ||
73 | eet_data_descriptor_free(_my_conf_descriptor); | ||
74 | } /* _my_conf_descriptor_shutdown */ | ||
75 | |||
76 | static 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 | |||
91 | static 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 | |||
98 | static 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 | |||
123 | end: | ||
124 | eet_close(ef); | ||
125 | return my_conf; | ||
126 | } /* _my_conf_load */ | ||
127 | |||
128 | static 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 | |||
173 | int | ||
174 | main(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 | |||
217 | end: | ||
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 new file mode 100644 index 0000000..740c179 --- /dev/null +++ b/libraries/eet/src/examples/eet-file.c | |||
@@ -0,0 +1,127 @@ | |||
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 | |||
8 | static int | ||
9 | create_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 | |||
66 | int | ||
67 | main(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 | |||