From 825a3d837a33f226c879cd02ad15c3fba57e8b2c Mon Sep 17 00:00:00 2001 From: David Walter Seikel Date: Mon, 23 Jan 2012 23:30:42 +1000 Subject: Update the EFL to what I'm actually using, coz I'm using some stuff not yet released. --- libraries/eet/src/Makefile.in | 2 - libraries/eet/src/bin/Makefile.in | 2 - libraries/eet/src/bin/eet_main.c | 88 +++++++--- libraries/eet/src/examples/Makefile.am | 4 +- libraries/eet/src/examples/Makefile.in | 64 +++---- libraries/eet/src/lib/Eet.h | 17 +- libraries/eet/src/lib/Eet_private.h | 135 +++++++++++++++ libraries/eet/src/lib/Makefile.am | 1 + libraries/eet/src/lib/Makefile.in | 27 ++- libraries/eet/src/lib/eet_alloc.c | 93 +++++++++++ libraries/eet/src/lib/eet_cipher.c | 26 +-- libraries/eet/src/lib/eet_connection.c | 129 ++++++-------- libraries/eet/src/lib/eet_data.c | 238 +++++++++++++------------- libraries/eet/src/lib/eet_dictionary.c | 55 +++--- libraries/eet/src/lib/eet_image.c | 74 ++++---- libraries/eet/src/lib/eet_lib.c | 297 ++++++++++----------------------- libraries/eet/src/lib/eet_node.c | 58 +++---- libraries/eet/src/lib/eet_utils.c | 2 +- libraries/eet/src/tests/Makefile.am | 1 + libraries/eet/src/tests/Makefile.in | 3 +- libraries/eet/src/tests/eet_suite.c | 42 ++--- 21 files changed, 749 insertions(+), 609 deletions(-) create mode 100644 libraries/eet/src/lib/eet_alloc.c (limited to 'libraries/eet/src') diff --git a/libraries/eet/src/Makefile.in b/libraries/eet/src/Makefile.in index 0a28065..8b2aa37 100644 --- a/libraries/eet/src/Makefile.in +++ b/libraries/eet/src/Makefile.in @@ -182,8 +182,6 @@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ PKG_CONFIG = @PKG_CONFIG@ -PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ -PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ RANLIB = @RANLIB@ SED = @SED@ SET_MAKE = @SET_MAKE@ diff --git a/libraries/eet/src/bin/Makefile.in b/libraries/eet/src/bin/Makefile.in index 9273fac..4a899f5 100644 --- a/libraries/eet/src/bin/Makefile.in +++ b/libraries/eet/src/bin/Makefile.in @@ -177,8 +177,6 @@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ PKG_CONFIG = @PKG_CONFIG@ -PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ -PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ RANLIB = @RANLIB@ SED = @SED@ SET_MAKE = @SET_MAKE@ diff --git a/libraries/eet/src/bin/eet_main.c b/libraries/eet/src/bin/eet_main.c index 7ab5555..0d577ad 100644 --- a/libraries/eet/src/bin/eet_main.c +++ b/libraries/eet/src/bin/eet_main.c @@ -77,7 +77,7 @@ do_eet_extract(const char *file, Eet_File *ef; void *data; int size = 0; - FILE *f; + FILE *f = stdout; ef = eet_open(file, EET_FILE_MODE_READ); if (!ef) @@ -93,20 +93,23 @@ do_eet_extract(const char *file, exit(-1); } - f = fopen(out, "wb"); - if (!f) + if (out) { - ERR("cannot open %s", out); - exit(-1); + f = fopen(out, "wb"); + if (!f) + { + ERR("cannot open %s", out); + exit(-1); + } } if (fwrite(data, size, 1, f) != 1) { - ERR("cannot write to %s", out); + ERR("cannot write to %s", out ? out : "standard output"); exit(-1); } - fclose(f); + if (out) fclose(f); free(data); eet_close(ef); } /* do_eet_extract */ @@ -125,7 +128,7 @@ do_eet_decode(const char *file, const char *crypto_key) { Eet_File *ef; - FILE *f; + FILE *f = stdout; ef = eet_open(file, EET_FILE_MODE_READ); if (!ef) @@ -134,20 +137,23 @@ do_eet_decode(const char *file, exit(-1); } - f = fopen(out, "wb"); - if (!f) + if (out) { - ERR("cannot open %s", out); - exit(-1); + f = fopen(out, "wb"); + if (!f) + { + ERR("cannot open %s", out); + exit(-1); + } } if (!eet_data_dump_cipher(ef, key, crypto_key, do_eet_decode_dump, f)) { - ERR("cannot write to %s", out); + ERR("cannot write to %s", out ? out : "standard output"); exit(-1); } - fclose(f); + if (out) fclose(f); eet_close(ef); } /* do_eet_decode */ @@ -352,9 +358,9 @@ main(int argc, help: printf( "Usage:\n" - " eet -l FILE.EET list all keys in FILE.EET\n" - " eet -x FILE.EET KEY OUT-FILE [CRYPTO_KEY] extract data stored in KEY in FILE.EET and write to OUT-FILE\n" - " eet -d FILE.EET KEY OUT-FILE [CRYPTO_KEY] extract and decode data stored in KEY in FILE.EET and write to OUT-FILE\n" + " eet -l FILE.EET list all keys in FILE.EET\n" + " eet -x FILE.EET KEY [OUT-FILE] [CRYPTO_KEY] extract data stored in KEY in FILE.EET and write to OUT-FILE or standard output\n" + " eet -d FILE.EET KEY [OUT-FILE] [CRYPTO_KEY] extract and decode data stored in KEY in FILE.EET and write to OUT-FILE or standard output\n" " eet -i FILE.EET KEY IN-FILE COMPRESS [CRYPTO_KEY] insert data to KEY in FILE.EET from IN-FILE and if COMPRESS is 1, compress it\n" " eet -e FILE.EET KEY IN-FILE COMPRESS [CRYPTO_KEY] insert and encode to KEY in FILE.EET from IN-FILE and if COMPRESS is 1, compress it\n" " eet -r FILE.EET KEY remove KEY in FILE.EET\n" @@ -369,19 +375,47 @@ help: goto help; else if ((!strcmp(argv[1], "-l")) && (argc > 2)) do_eet_list(argv[2]); - else if ((!strcmp(argv[1], "-x")) && (argc > 4)) + else if ((!strcmp(argv[1], "-x")) && (argc > 3)) { - if (argc > 5) - do_eet_extract(argv[2], argv[3], argv[4], argv[5]); - else - do_eet_extract(argv[2], argv[3], argv[4], NULL); + switch (argc) + { + case 4: + { + do_eet_extract(argv[2], argv[3], NULL, NULL); + break; + } + case 5: + { + do_eet_extract(argv[2], argv[3], argv[4], NULL); + break; + } + default: + { + do_eet_extract(argv[2], argv[3], argv[4], argv[5]); + break; + } + } } - else if ((!strcmp(argv[1], "-d")) && (argc > 4)) + else if ((!strcmp(argv[1], "-d")) && (argc > 3)) { - if (argc > 5) - do_eet_decode(argv[2], argv[3], argv[4], argv[5]); - else - do_eet_decode(argv[2], argv[3], argv[4], NULL); + switch (argc) + { + case 4: + { + do_eet_decode(argv[2], argv[3], NULL, NULL); + break; + } + case 5: + { + do_eet_decode(argv[2], argv[3], argv[4], NULL); + break; + } + default: + { + do_eet_decode(argv[2], argv[3], argv[4], argv[5]); + break; + } + } } else if ((!strcmp(argv[1], "-i")) && (argc > 5)) { diff --git a/libraries/eet/src/examples/Makefile.am b/libraries/eet/src/examples/Makefile.am index 8279445..6c5a324 100644 --- a/libraries/eet/src/examples/Makefile.am +++ b/libraries/eet/src/examples/Makefile.am @@ -1,6 +1,6 @@ MAINTAINERCLEANFILES = Makefile.in -pkglibdir = $(datadir)/$(PACKAGE)/examples +examplesdir = $(datadir)/$(PACKAGE)/examples if BUILD_EXAMPLES AM_CPPFLAGS = \ @@ -8,7 +8,7 @@ AM_CPPFLAGS = \ -I$(top_srcdir)/src/lib \ @EINA_CFLAGS@ -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 +examples_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 eet_basic_SOURCES = eet-basic.c eet_basic_LDADD = $(top_builddir)/src/lib/libeet.la @EINA_LIBS@ diff --git a/libraries/eet/src/examples/Makefile.in b/libraries/eet/src/examples/Makefile.in index d24b728..5830132 100644 --- a/libraries/eet/src/examples/Makefile.in +++ b/libraries/eet/src/examples/Makefile.in @@ -19,6 +19,7 @@ VPATH = @srcdir@ pkgdatadir = $(datadir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ pkglibexecdir = $(libexecdir)/@PACKAGE@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd install_sh_DATA = $(install_sh) -c -m 644 @@ -34,7 +35,7 @@ PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ -@BUILD_EXAMPLES_TRUE@pkglib_PROGRAMS = eet_basic$(EXEEXT) \ +@BUILD_EXAMPLES_TRUE@examples_PROGRAMS = eet_basic$(EXEEXT) \ @BUILD_EXAMPLES_TRUE@ eet_file$(EXEEXT) \ @BUILD_EXAMPLES_TRUE@ eet_data_simple$(EXEEXT) \ @BUILD_EXAMPLES_TRUE@ eet_data_nested$(EXEEXT) \ @@ -70,8 +71,8 @@ mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = -am__installdirs = "$(DESTDIR)$(pkglibdir)" "$(DESTDIR)$(filesdir)" -PROGRAMS = $(pkglib_PROGRAMS) +am__installdirs = "$(DESTDIR)$(examplesdir)" "$(DESTDIR)$(filesdir)" +PROGRAMS = $(examples_PROGRAMS) am__eet_basic_SOURCES_DIST = eet-basic.c @BUILD_EXAMPLES_TRUE@am_eet_basic_OBJECTS = eet-basic.$(OBJEXT) eet_basic_OBJECTS = $(am_eet_basic_OBJECTS) @@ -184,7 +185,6 @@ DATA = $(files_DATA) ETAGS = etags CTAGS = ctags DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) -pkglibdir = $(datadir)/$(PACKAGE)/examples ACLOCAL = @ACLOCAL@ ALLOCA = @ALLOCA@ AMTAR = @AMTAR@ @@ -265,8 +265,6 @@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ PKG_CONFIG = @PKG_CONFIG@ -PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ -PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ RANLIB = @RANLIB@ SED = @SED@ SET_MAKE = @SET_MAKE@ @@ -335,6 +333,7 @@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ version_info = @version_info@ MAINTAINERCLEANFILES = Makefile.in +examplesdir = $(datadir)/$(PACKAGE)/examples @BUILD_EXAMPLES_TRUE@AM_CPPFLAGS = \ @BUILD_EXAMPLES_TRUE@-I. \ @BUILD_EXAMPLES_TRUE@-I$(top_srcdir)/src/lib \ @@ -390,10 +389,10 @@ $(top_srcdir)/configure: $(am__configure_deps) $(ACLOCAL_M4): $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(am__aclocal_m4_deps): -install-pkglibPROGRAMS: $(pkglib_PROGRAMS) +install-examplesPROGRAMS: $(examples_PROGRAMS) @$(NORMAL_INSTALL) - test -z "$(pkglibdir)" || $(MKDIR_P) "$(DESTDIR)$(pkglibdir)" - @list='$(pkglib_PROGRAMS)'; test -n "$(pkglibdir)" || list=; \ + test -z "$(examplesdir)" || $(MKDIR_P) "$(DESTDIR)$(examplesdir)" + @list='$(examples_PROGRAMS)'; test -n "$(examplesdir)" || list=; \ for p in $$list; do echo "$$p $$p"; done | \ sed 's/$(EXEEXT)$$//' | \ while read p p1; do if test -f $$p || test -f $$p1; \ @@ -410,23 +409,23 @@ install-pkglibPROGRAMS: $(pkglib_PROGRAMS) while read type dir files; do \ if test "$$dir" = .; then dir=; else dir=/$$dir; fi; \ test -z "$$files" || { \ - echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL_PROGRAM) $$files '$(DESTDIR)$(pkglibdir)$$dir'"; \ - $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL_PROGRAM) $$files "$(DESTDIR)$(pkglibdir)$$dir" || exit $$?; \ + echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL_PROGRAM) $$files '$(DESTDIR)$(examplesdir)$$dir'"; \ + $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL_PROGRAM) $$files "$(DESTDIR)$(examplesdir)$$dir" || exit $$?; \ } \ ; done -uninstall-pkglibPROGRAMS: +uninstall-examplesPROGRAMS: @$(NORMAL_UNINSTALL) - @list='$(pkglib_PROGRAMS)'; test -n "$(pkglibdir)" || list=; \ + @list='$(examples_PROGRAMS)'; test -n "$(examplesdir)" || list=; \ files=`for p in $$list; do echo "$$p"; done | \ sed -e 'h;s,^.*/,,;s/$(EXEEXT)$$//;$(transform)' \ -e 's/$$/$(EXEEXT)/' `; \ test -n "$$list" || exit 0; \ - echo " ( cd '$(DESTDIR)$(pkglibdir)' && rm -f" $$files ")"; \ - cd "$(DESTDIR)$(pkglibdir)" && rm -f $$files + echo " ( cd '$(DESTDIR)$(examplesdir)' && rm -f" $$files ")"; \ + cd "$(DESTDIR)$(examplesdir)" && rm -f $$files -clean-pkglibPROGRAMS: - @list='$(pkglib_PROGRAMS)'; test -n "$$list" || exit 0; \ +clean-examplesPROGRAMS: + @list='$(examples_PROGRAMS)'; test -n "$$list" || exit 0; \ echo " rm -f" $$list; \ rm -f $$list || exit $$?; \ test -n "$(EXEEXT)" || exit 0; \ @@ -605,7 +604,7 @@ check-am: all-am check: check-am all-am: Makefile $(PROGRAMS) $(DATA) installdirs: - for dir in "$(DESTDIR)$(pkglibdir)" "$(DESTDIR)$(filesdir)"; do \ + for dir in "$(DESTDIR)$(examplesdir)" "$(DESTDIR)$(filesdir)"; do \ test -z "$$dir" || $(MKDIR_P) "$$dir"; \ done install: install-am @@ -636,7 +635,7 @@ maintainer-clean-generic: -test -z "$(MAINTAINERCLEANFILES)" || rm -f $(MAINTAINERCLEANFILES) clean: clean-am -clean-am: clean-generic clean-libtool clean-pkglibPROGRAMS \ +clean-am: clean-examplesPROGRAMS clean-generic clean-libtool \ mostlyclean-am distclean: distclean-am @@ -657,13 +656,13 @@ info: info-am info-am: -install-data-am: install-filesDATA +install-data-am: install-examplesPROGRAMS install-filesDATA install-dvi: install-dvi-am install-dvi-am: -install-exec-am: install-pkglibPROGRAMS +install-exec-am: install-html: install-html-am @@ -703,24 +702,25 @@ ps: ps-am ps-am: -uninstall-am: uninstall-filesDATA uninstall-pkglibPROGRAMS +uninstall-am: uninstall-examplesPROGRAMS uninstall-filesDATA .MAKE: install-am install-strip -.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \ - clean-libtool clean-pkglibPROGRAMS ctags distclean \ - distclean-compile distclean-generic distclean-libtool \ - distclean-tags distdir dvi dvi-am html html-am info info-am \ - install install-am install-data install-data-am install-dvi \ - install-dvi-am install-exec install-exec-am install-filesDATA \ - install-html install-html-am install-info install-info-am \ - install-man install-pdf install-pdf-am install-pkglibPROGRAMS \ +.PHONY: CTAGS GTAGS all all-am check check-am clean \ + clean-examplesPROGRAMS clean-generic clean-libtool ctags \ + distclean distclean-compile distclean-generic \ + distclean-libtool distclean-tags distdir dvi dvi-am html \ + html-am info info-am install install-am install-data \ + install-data-am install-dvi install-dvi-am \ + install-examplesPROGRAMS install-exec install-exec-am \ + install-filesDATA install-html install-html-am install-info \ + install-info-am install-man install-pdf install-pdf-am \ install-ps install-ps-am install-strip installcheck \ installcheck-am installdirs maintainer-clean \ maintainer-clean-generic mostlyclean mostlyclean-compile \ mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \ - tags uninstall uninstall-am uninstall-filesDATA \ - uninstall-pkglibPROGRAMS + tags uninstall uninstall-am uninstall-examplesPROGRAMS \ + uninstall-filesDATA # Tell versions [3.59,3.63) of GNU make to not export all variables. diff --git a/libraries/eet/src/lib/Eet.h b/libraries/eet/src/lib/Eet.h index 8fda1e0..2df7fbf 100644 --- a/libraries/eet/src/lib/Eet.h +++ b/libraries/eet/src/lib/Eet.h @@ -188,7 +188,7 @@ extern "C" { */ #define EET_VERSION_MAJOR 1 -#define EET_VERSION_MINOR 4 +#define EET_VERSION_MINOR 6 /** * @typedef Eet_Version * @@ -755,7 +755,7 @@ eet_delete(Eet_File *ef, /** * Alias a specific section to another one. Destination may exist or not, - * no check are done. + * no checks are done. * @param ef A valid eet file handle opened for writing. * @param name Name of the new entry. eg: "/base/file_i_want". * @param destination Actual source of the aliased entry eg: "/base/the_real_stuff_i_want". @@ -775,6 +775,19 @@ eet_alias(Eet_File *ef, int compress); /** + * Retrieve the filename of an Eet_File + * @param ef A valid eet file handle opened for writing. + * @return The stringshared file string opened with eet_open(), or NULL on error + * + * @note This function will return NULL for files opened with eet_memopen_read() + * + * @since 1.6 + * @ingroup Eet_File_Group + */ +EAPI const char * +eet_file_get(Eet_File *ef); + +/** * Retrieve the destination name of an alias * @param ef A valid eet file handle opened for writing * @param name Name of the entry. eg: "/base/file_i_want" diff --git a/libraries/eet/src/lib/Eet_private.h b/libraries/eet/src/lib/Eet_private.h index 83f4c18..c04daf0 100644 --- a/libraries/eet/src/lib/Eet_private.h +++ b/libraries/eet/src/lib/Eet_private.h @@ -66,6 +66,126 @@ struct _Eet_Node Eet_Node_Data data; }; +typedef struct _Eet_File_Header Eet_File_Header; +typedef struct _Eet_File_Node Eet_File_Node; +typedef struct _Eet_File_Directory Eet_File_Directory; + +struct _Eet_File +{ + const char *path; + Eina_File *readfp; + Eet_File_Header *header; + Eet_Dictionary *ed; + Eet_Key *key; + const unsigned char *data; + const void *x509_der; + const void *signature; + void *sha1; + + Eet_File_Mode mode; + + int magic; + int references; + + unsigned long int data_size; + int x509_length; + unsigned int signature_length; + int sha1_length; + + Eina_Lock file_lock; + + unsigned char writes_pending : 1; + unsigned char delete_me_now : 1; +}; + +struct _Eet_File_Header +{ + int magic; + Eet_File_Directory *directory; +}; + +struct _Eet_File_Directory +{ + int size; + Eet_File_Node **nodes; +}; + +struct _Eet_File_Node +{ + char *name; + void *data; + Eet_File_Node *next; /* FIXME: make buckets linked lists */ + + unsigned long int offset; + unsigned long int dictionary_offset; + unsigned long int name_offset; + + unsigned int name_size; + unsigned int size; + unsigned int data_size; + + unsigned char free_name : 1; + unsigned char compression : 1; + unsigned char ciphered : 1; + unsigned char alias : 1; +}; + +#if 0 +/* Version 2 */ +/* NB: all int's are stored in network byte order on disk */ +/* file format: */ +int magic; /* magic number ie 0x1ee7ff00 */ +int num_directory_entries; /* number of directory entries to follow */ +int bytes_directory_entries; /* bytes of directory entries to follow */ +struct +{ + int offset; /* bytes offset into file for data chunk */ + int flags; /* flags - for now 0 = uncompressed and clear, 1 = compressed and clear, 2 = uncompressed and ciphered, 3 = compressed and ciphered */ + int size; /* size of the data chunk */ + int data_size; /* size of the (uncompressed) data chunk */ + int name_size; /* length in bytes of the name field */ + char name[name_size]; /* name string (variable length) and \0 terminated */ +} directory[num_directory_entries]; +/* and now startes the data stream... */ +#endif /* if 0 */ + +#if 0 +/* Version 3 */ +/* NB: all int's are stored in network byte order on disk */ +/* file format: */ +int magic; /* magic number ie 0x1ee70f42 */ +int num_directory_entries; /* number of directory entries to follow */ +int num_dictionary_entries; /* number of dictionary entries to follow */ +struct +{ + int data_offset; /* bytes offset into file for data chunk */ + int size; /* size of the data chunk */ + int data_size; /* size of the (uncompressed) data chunk */ + int name_offset; /* bytes offset into file for name string */ + int name_size; /* length in bytes of the name field */ + int flags; /* bit flags - for now: + bit 0 => compresion on/off + bit 1 => ciphered on/off + bit 2 => alias + */ +} directory[num_directory_entries]; +struct +{ + int hash; + int offset; + int size; + int prev; + int next; +} dictionary[num_dictionary_entries]; +/* now start the string stream. */ +/* and right after them the data stream. */ +int magic_sign; /* Optional, only if the eet file is signed. */ +int signature_length; /* Signature length. */ +int x509_length; /* Public certificate that signed the file. */ +char signature[signature_length]; /* The signature. */ +char x509[x509_length]; /* The public certificate. */ +#endif /* if 0 */ + /* * variable and macros used for the eina_log module */ @@ -178,6 +298,21 @@ Eet_Node * void eet_node_free(Eet_Node *node); + +#define GENERIC_ALLOC_FREE_HEADER(TYPE, Type) \ + TYPE *Type##_malloc(unsigned int); \ + TYPE *Type##_calloc(unsigned int); \ + void Type##_mp_free(TYPE *e); + +GENERIC_ALLOC_FREE_HEADER(Eet_File_Directory, eet_file_directory); +GENERIC_ALLOC_FREE_HEADER(Eet_File_Node, eet_file_node); +GENERIC_ALLOC_FREE_HEADER(Eet_File_Header, eet_file_header); +GENERIC_ALLOC_FREE_HEADER(Eet_Dictionary, eet_dictionary); +GENERIC_ALLOC_FREE_HEADER(Eet_File, eet_file); + +Eina_Bool eet_mempool_init(void); +void eet_mempool_shutdown(void); + #ifndef PATH_MAX # define PATH_MAX 4096 #endif /* ifndef PATH_MAX */ diff --git a/libraries/eet/src/lib/Makefile.am b/libraries/eet/src/lib/Makefile.am index 4633749..ae60168 100644 --- a/libraries/eet/src/lib/Makefile.am +++ b/libraries/eet/src/lib/Makefile.am @@ -22,6 +22,7 @@ includesdir = $(includedir)/eet-@VMAJ@ lib_LTLIBRARIES = libeet.la base_sources = \ +eet_alloc.c \ eet_lib.c \ eet_data.c \ eet_image.c \ diff --git a/libraries/eet/src/lib/Makefile.in b/libraries/eet/src/lib/Makefile.in index f80bcd8..2a3fec0 100644 --- a/libraries/eet/src/lib/Makefile.in +++ b/libraries/eet/src/lib/Makefile.in @@ -80,13 +80,14 @@ am__base_list = \ am__installdirs = "$(DESTDIR)$(libdir)" "$(DESTDIR)$(includesdir)" LTLIBRARIES = $(lib_LTLIBRARIES) libeet_la_DEPENDENCIES = -am__libeet_la_SOURCES_DIST = eet_lib.c eet_data.c eet_image.c \ - eet_cipher.c eet_dictionary.c eet_node.c eet_utils.c \ - eet_connection.c -am__objects_1 = libeet_la-eet_lib.lo libeet_la-eet_data.lo \ - libeet_la-eet_image.lo libeet_la-eet_cipher.lo \ - libeet_la-eet_dictionary.lo libeet_la-eet_node.lo \ - libeet_la-eet_utils.lo libeet_la-eet_connection.lo +am__libeet_la_SOURCES_DIST = eet_alloc.c eet_lib.c eet_data.c \ + eet_image.c eet_cipher.c eet_dictionary.c eet_node.c \ + eet_utils.c eet_connection.c +am__objects_1 = libeet_la-eet_alloc.lo libeet_la-eet_lib.lo \ + libeet_la-eet_data.lo libeet_la-eet_image.lo \ + libeet_la-eet_cipher.lo libeet_la-eet_dictionary.lo \ + libeet_la-eet_node.lo libeet_la-eet_utils.lo \ + libeet_la-eet_connection.lo @EET_AMALGAMATION_FALSE@am_libeet_la_OBJECTS = $(am__objects_1) @EET_AMALGAMATION_TRUE@nodist_libeet_la_OBJECTS = \ @EET_AMALGAMATION_TRUE@ libeet_la-eet_amalgamation.lo @@ -210,8 +211,6 @@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ PKG_CONFIG = @PKG_CONFIG@ -PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ -PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ RANLIB = @RANLIB@ SED = @SED@ SET_MAKE = @SET_MAKE@ @@ -299,6 +298,7 @@ includes_HEADERS = Eet.h includesdir = $(includedir)/eet-@VMAJ@ lib_LTLIBRARIES = libeet.la base_sources = \ +eet_alloc.c \ eet_lib.c \ eet_data.c \ eet_image.c \ @@ -388,6 +388,7 @@ mostlyclean-compile: distclean-compile: -rm -f *.tab.c +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libeet_la-eet_alloc.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libeet_la-eet_amalgamation.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libeet_la-eet_cipher.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libeet_la-eet_connection.Plo@am__quote@ @@ -422,6 +423,14 @@ distclean-compile: @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $< +libeet_la-eet_alloc.lo: eet_alloc.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libeet_la_CFLAGS) $(CFLAGS) -MT libeet_la-eet_alloc.lo -MD -MP -MF $(DEPDIR)/libeet_la-eet_alloc.Tpo -c -o libeet_la-eet_alloc.lo `test -f 'eet_alloc.c' || echo '$(srcdir)/'`eet_alloc.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libeet_la-eet_alloc.Tpo $(DEPDIR)/libeet_la-eet_alloc.Plo +@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='eet_alloc.c' object='libeet_la-eet_alloc.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libeet_la_CFLAGS) $(CFLAGS) -c -o libeet_la-eet_alloc.lo `test -f 'eet_alloc.c' || echo '$(srcdir)/'`eet_alloc.c + libeet_la-eet_lib.lo: eet_lib.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libeet_la_CFLAGS) $(CFLAGS) -MT libeet_la-eet_lib.lo -MD -MP -MF $(DEPDIR)/libeet_la-eet_lib.Tpo -c -o libeet_la-eet_lib.lo `test -f 'eet_lib.c' || echo '$(srcdir)/'`eet_lib.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libeet_la-eet_lib.Tpo $(DEPDIR)/libeet_la-eet_lib.Plo diff --git a/libraries/eet/src/lib/eet_alloc.c b/libraries/eet/src/lib/eet_alloc.c new file mode 100644 index 0000000..85351ad --- /dev/null +++ b/libraries/eet/src/lib/eet_alloc.c @@ -0,0 +1,93 @@ +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + +#include +#include "Eet.h" +#include "Eet_private.h" + +typedef struct _Eet_Mempool Eet_Mempool; +struct _Eet_Mempool +{ + const char *name; + Eina_Mempool *mp; + size_t size; +}; + +#define GENERIC_ALLOC_FREE(TYPE, Type) \ + Eet_Mempool Type##_mp = { #TYPE, NULL, sizeof (TYPE) }; \ + \ + TYPE * \ + Type##_malloc(unsigned int num) \ + { \ + return eina_mempool_malloc(Type##_mp.mp, num * sizeof (TYPE)); \ + } \ + TYPE * \ + Type##_calloc(unsigned int num) \ + { \ + return eina_mempool_calloc(Type##_mp.mp, num * sizeof (TYPE)); \ + } \ + void \ + Type##_mp_free(TYPE *e) \ + { \ + eina_mempool_free(Type##_mp.mp, e); \ + } + +GENERIC_ALLOC_FREE(Eet_File_Directory, eet_file_directory); +GENERIC_ALLOC_FREE(Eet_File_Node, eet_file_node); +GENERIC_ALLOC_FREE(Eet_File_Header, eet_file_header); +GENERIC_ALLOC_FREE(Eet_Dictionary, eet_dictionary); +GENERIC_ALLOC_FREE(Eet_File, eet_file); + +static Eet_Mempool *mempool_array[] = { + &eet_file_directory_mp, + &eet_file_node_mp, + &eet_file_header_mp, + &eet_dictionary_mp, + &eet_file_mp, +}; + +Eina_Bool +eet_mempool_init(void) +{ + const char *choice; + unsigned int i; + + choice = getenv("EINA_MEMPOOL"); + if ((!choice) || (!choice[0])) + choice = "chained_mempool"; + + for (i = 0; i < sizeof (mempool_array) / sizeof (mempool_array[0]); ++i) + { + retry: + mempool_array[i]->mp = eina_mempool_add(choice, mempool_array[i]->name, NULL, mempool_array[i]->size, 64); + if (!mempool_array[i]->mp) + { + if (!strcmp(choice, "pass_through")) + { + ERR("Falling back to pass through ! Previously tried '%s' mempool.", choice); + choice = "pass_through"; + goto retry; + } + else + { + ERR("Impossible to allocate mempool '%s' !", choice); + return EINA_FALSE; + } + } + } + return EINA_TRUE; +} + +void +eet_mempool_shutdown(void) +{ + unsigned int i; + + for (i = 0; i < sizeof (mempool_array) / sizeof (mempool_array[0]); ++i) + { + eina_mempool_del(mempool_array[i]->mp); + mempool_array[i]->mp = NULL; + } +} + diff --git a/libraries/eet/src/lib/eet_cipher.c b/libraries/eet/src/lib/eet_cipher.c index 89ee65d..37a0899 100644 --- a/libraries/eet/src/lib/eet_cipher.c +++ b/libraries/eet/src/lib/eet_cipher.c @@ -275,7 +275,7 @@ on_error: cb = NULL; #endif /* ifdef HAVE_SIGNATURE */ return NULL; -} /* eet_identity_open */ +} EAPI void eet_identity_close(Eet_Key *key) @@ -295,7 +295,7 @@ eet_identity_close(Eet_Key *key) #else key = NULL; #endif /* ifdef HAVE_SIGNATURE */ -} /* eet_identity_close */ +} EAPI void eet_identity_print(Eet_Key *key, @@ -419,7 +419,7 @@ on_error: out = NULL; ERR("You need to compile signature support in EET."); #endif /* ifdef HAVE_SIGNATURE */ -} /* eet_identity_print */ +} void eet_identity_ref(Eet_Key *key) @@ -428,7 +428,7 @@ eet_identity_ref(Eet_Key *key) return; key->references++; -} /* eet_identity_ref */ +} void eet_identity_unref(Eet_Key *key) @@ -438,7 +438,7 @@ eet_identity_unref(Eet_Key *key) key->references--; eet_identity_close(key); -} /* eet_identity_unref */ +} void * eet_identity_compute_sha1(const void *data_base, @@ -479,7 +479,7 @@ eet_identity_compute_sha1(const void *data_base, #endif /* ifdef HAVE_SIGNATURE */ return result; -} /* eet_identity_compute_sha1 */ +} Eet_Error eet_identity_sign(FILE *fp, @@ -650,7 +650,7 @@ on_error: key = NULL; return EET_ERROR_NOT_IMPLEMENTED; #endif /* ifdef HAVE_SIGNATURE */ -} /* eet_identity_sign */ +} const void * eet_identity_check(const void *data_base, @@ -830,7 +830,7 @@ eet_identity_check(const void *data_base, x509_length = NULL; return NULL; #endif /* ifdef HAVE_SIGNATURE */ -} /* eet_identity_check */ +} EAPI void eet_identity_certificate_print(const unsigned char *certificate, @@ -896,7 +896,7 @@ on_error: out = NULL; ERR("You need to compile signature support in EET."); #endif /* ifdef HAVE_SIGNATURE */ -} /* eet_identity_certificate_print */ +} Eet_Error eet_cipher(const void *data, @@ -1073,7 +1073,7 @@ on_error: (void)result_length; return EET_ERROR_NOT_IMPLEMENTED; #endif /* ifdef HAVE_CIPHER */ -} /* eet_cipher */ +} Eet_Error eet_decipher(const void *data, @@ -1224,7 +1224,7 @@ on_error: (void)result_length; return EET_ERROR_NOT_IMPLEMENTED; #endif /* ifdef HAVE_CIPHER */ -} /* eet_decipher */ +} #ifdef HAVE_CIPHER # ifdef HAVE_GNUTLS @@ -1265,7 +1265,7 @@ eet_hmac_sha1(const void *key, gcry_md_close(mdh); return 0; -} /* eet_hmac_sha1 */ +} # endif /* ifdef HAVE_GNUTLS */ @@ -1337,6 +1337,6 @@ eet_pbkdf2_sha1(const char *key, HMAC_cleanup(&hctx); # endif /* ifdef HAVE_GNUTLS */ return 0; -} /* eet_pbkdf2_sha1 */ +} #endif /* ifdef HAVE_CIPHER */ diff --git a/libraries/eet/src/lib/eet_connection.c b/libraries/eet/src/lib/eet_connection.c index 6171b7e..7b6b934 100644 --- a/libraries/eet/src/lib/eet_connection.c +++ b/libraries/eet/src/lib/eet_connection.c @@ -35,6 +35,8 @@ void *alloca(size_t); #include "Eet.h" #include "Eet_private.h" +/* max message size: 1Mb - raised from original 64Kb */ +#define MAX_MSG_SIZE (1024 * 1024) #define MAGIC_EET_DATA_PACKET 0x4270ACE1 struct _Eet_Connection @@ -56,74 +58,62 @@ eet_connection_new(Eet_Read_Cb *eet_read_cb, const void *user_data) { Eet_Connection *conn; - - if (!eet_read_cb || !eet_write_cb) - return NULL; - + + if ((!eet_read_cb) || (!eet_write_cb)) return NULL; + conn = calloc(1, sizeof (Eet_Connection)); - if (!conn) - return NULL; - + if (!conn) return NULL; conn->eet_read_cb = eet_read_cb; conn->eet_write_cb = eet_write_cb; conn->user_data = (void *)user_data; - return conn; -} /* eet_connection_new */ +} EAPI int eet_connection_received(Eet_Connection *conn, const void *data, size_t size) { - if ((!conn) || (!data) || (!size)) - return size; - - do { + if ((!conn) || (!data) || (!size)) return size; + do + { size_t copy_size; - + if (conn->size == 0) { const int *msg; size_t packet_size; - - if (size < sizeof (int) * 2) - break; + + if (size < (sizeof(int) * 2)) break; msg = data; /* Check the magic */ - if (ntohl(msg[0]) != MAGIC_EET_DATA_PACKET) - break; + if (ntohl(msg[0]) != MAGIC_EET_DATA_PACKET) break; packet_size = ntohl(msg[1]); - /* Message should always be under 64K */ - if (packet_size > 64 * 1024) - break; + /* Message should always be under MAX_MSG_SIZE */ + if (packet_size > MAX_MSG_SIZE) break; data = (void *)(msg + 2); - size -= sizeof (int) * 2; + size -= sizeof(int) * 2; if ((size_t)packet_size <= size) { - /* Not a partial receive, go the quick way. */ - if (!conn->eet_read_cb(data, packet_size, conn->user_data)) - break; - - data = (void *)((char *)data + packet_size); - size -= packet_size; - - conn->received = 0; - continue; + /* Not a partial receive, go the quick way. */ + if (!conn->eet_read_cb(data, packet_size, conn->user_data)) + break; + + data = (void *)((char *)data + packet_size); + size -= packet_size; + conn->received = 0; + continue; } - conn->size = packet_size; if (conn->allocated < conn->size) { void *tmp; - + tmp = realloc(conn->buffer, conn->size); - if (!tmp) - break; - + if (!tmp) break; conn->buffer = tmp; conn->allocated = conn->size; } @@ -132,33 +122,33 @@ eet_connection_received(Eet_Connection *conn, /* Partial receive */ copy_size = (conn->size - conn->received >= - size) ? size : conn->size - conn->received; + size) ? size : conn->size - conn->received; memcpy((char *)conn->buffer + conn->received, data, copy_size); - + conn->received += copy_size; data = (void *)((char *)data + copy_size); size -= copy_size; - + if (conn->received == conn->size) { size_t data_size; - + data_size = conn->size; conn->size = 0; conn->received = 0; - /* Completed a packet. */ if (!conn->eet_read_cb(conn->buffer, data_size, conn->user_data)) { - /* Something goes wrong. Stop now. */ - size += data_size; - break; + /* Something goes wrong. Stop now. */ + size += data_size; + break; } } - } while (size > 0); - + } + while (size > 0); + return size; -} /* eet_connection_received */ +} static Eina_Bool _eet_connection_raw_send(Eet_Connection *conn, @@ -167,21 +157,17 @@ _eet_connection_raw_send(Eet_Connection *conn, { int *message; - /* Message should never be above 64K */ - if (data_size > 64 * 1024) - return EINA_FALSE; - - message = alloca(data_size + sizeof (int) * 2); + /* Message should always be under MAX_MSG_SIZE */ + if (data_size > MAX_MSG_SIZE) return EINA_FALSE; + message = alloca(data_size + (sizeof(int) * 2)); message[0] = htonl(MAGIC_EET_DATA_PACKET); message[1] = htonl(data_size); - memcpy(message + 2, data, data_size); - conn->eet_write_cb(message, - data_size + sizeof (int) * 2, + data_size + (sizeof(int) * 2), conn->user_data); return EINA_TRUE; -} /* _eet_connection_raw_send */ +} EAPI Eina_Bool eet_connection_send(Eet_Connection *conn, @@ -197,15 +183,11 @@ eet_connection_send(Eet_Connection *conn, data_in, cipher_key, &data_size); - if (!flat_data) - return EINA_FALSE; - - if (_eet_connection_raw_send(conn, flat_data, data_size)) - ret = EINA_TRUE; - + if (!flat_data) return EINA_FALSE; + if (_eet_connection_raw_send(conn, flat_data, data_size)) ret = EINA_TRUE; free(flat_data); return ret; -} /* eet_connection_send */ +} EAPI Eina_Bool eet_connection_node_send(Eet_Connection *conn, @@ -217,15 +199,12 @@ eet_connection_node_send(Eet_Connection *conn, Eina_Bool ret = EINA_FALSE; data = eet_data_node_encode_cipher(node, cipher_key, &data_size); - if (!data) - return EINA_FALSE; - + if (!data) return EINA_FALSE; if (_eet_connection_raw_send(conn, data, data_size)) ret = EINA_TRUE; - free(data); return ret; -} /* eet_connection_node_send */ +} EAPI void * eet_connection_close(Eet_Connection *conn, @@ -233,17 +212,11 @@ eet_connection_close(Eet_Connection *conn, { void *user_data; - if (!conn) - return NULL; - - if (on_going) - *on_going = conn->received == 0 ? EINA_FALSE : EINA_TRUE; - + if (!conn) return NULL; + if (on_going) *on_going = conn->received == 0 ? EINA_FALSE : EINA_TRUE; user_data = conn->user_data; - free(conn->buffer); free(conn); - return user_data; -} /* eet_connection_close */ +} diff --git a/libraries/eet/src/lib/eet_data.c b/libraries/eet/src/lib/eet_data.c index 23b0b97..56b9ee0 100644 --- a/libraries/eet/src/lib/eet_data.c +++ b/libraries/eet/src/lib/eet_data.c @@ -651,7 +651,7 @@ eet_data_get_char(const Eet_Dictionary *ed __UNUSED__, *d = *s; CONV8(*d); return sizeof(char); -} /* eet_data_get_char */ +} static void * eet_data_put_char(Eet_Dictionary *ed __UNUSED__, @@ -669,7 +669,7 @@ eet_data_put_char(Eet_Dictionary *ed __UNUSED__, CONV8(*d); *size_ret = sizeof(char); return d; -} /* eet_data_put_char */ +} /* SHORT TYPE */ static int @@ -687,7 +687,7 @@ eet_data_get_short(const Eet_Dictionary *ed __UNUSED__, d = (short *)dst; CONV16(*d); return sizeof(short); -} /* eet_data_get_short */ +} static void * eet_data_put_short(Eet_Dictionary *ed __UNUSED__, @@ -705,7 +705,7 @@ eet_data_put_short(Eet_Dictionary *ed __UNUSED__, CONV16(*d); *size_ret = sizeof(short); return d; -} /* eet_data_put_short */ +} /* INT TYPE */ static inline int @@ -723,7 +723,7 @@ eet_data_get_int(const Eet_Dictionary *ed __UNUSED__, d = (int *)dst; CONV32(*d); return sizeof(int); -} /* eet_data_get_int */ +} static void * eet_data_put_int(Eet_Dictionary *ed __UNUSED__, @@ -741,7 +741,7 @@ eet_data_put_int(Eet_Dictionary *ed __UNUSED__, CONV32(*d); *size_ret = sizeof(int); return d; -} /* eet_data_put_int */ +} /* LONG LONG TYPE */ static int @@ -759,7 +759,7 @@ eet_data_get_long_long(const Eet_Dictionary *ed __UNUSED__, d = (unsigned long long *)dst; CONV64(*d); return sizeof(unsigned long long); -} /* eet_data_get_long_long */ +} static void * eet_data_put_long_long(Eet_Dictionary *ed __UNUSED__, @@ -777,7 +777,7 @@ eet_data_put_long_long(Eet_Dictionary *ed __UNUSED__, CONV64(*d); *size_ret = sizeof(unsigned long long); return d; -} /* eet_data_put_long_long */ +} /* STRING TYPE */ static inline int @@ -796,7 +796,7 @@ eet_data_get_string_hash(const Eet_Dictionary *ed, } return -1; -} /* eet_data_get_string_hash */ +} static inline int eet_data_get_string(const Eet_Dictionary *ed, @@ -833,7 +833,7 @@ eet_data_get_string(const Eet_Dictionary *ed, *d = s; return strlen(s) + 1; -} /* eet_data_get_string */ +} static void * eet_data_put_string(Eet_Dictionary *ed, @@ -871,7 +871,7 @@ eet_data_put_string(Eet_Dictionary *ed, memcpy(d, s, len + 1); *size_ret = len + 1; return d; -} /* eet_data_put_string */ +} /* ALWAYS INLINED STRING TYPE */ static int @@ -881,7 +881,7 @@ eet_data_get_istring(const Eet_Dictionary *ed __UNUSED__, void *dst) { return eet_data_get_string(NULL, src, src_end, dst); -} /* eet_data_get_istring */ +} static void * eet_data_put_istring(Eet_Dictionary *ed __UNUSED__, @@ -889,7 +889,7 @@ eet_data_put_istring(Eet_Dictionary *ed __UNUSED__, int *size_ret) { return eet_data_put_string(NULL, src, size_ret); -} /* eet_data_put_istring */ +} /* ALWAYS NULL TYPE */ static int @@ -904,7 +904,7 @@ eet_data_get_null(const Eet_Dictionary *ed __UNUSED__, *d = NULL; return 1; -} /* eet_data_get_null */ +} static void * eet_data_put_null(Eet_Dictionary *ed __UNUSED__, @@ -913,7 +913,7 @@ eet_data_put_null(Eet_Dictionary *ed __UNUSED__, { *size_ret = 0; return NULL; -} /* eet_data_put_null */ +} /** * Fast lookups of simple doubles/floats. @@ -941,7 +941,7 @@ _eet_data_float_cache_get(const char *s, } return 0; -} /* _eet_data_float_cache_get */ +} static inline int _eet_data_double_cache_get(const char *s, @@ -963,7 +963,7 @@ _eet_data_double_cache_get(const char *s, } return 0; -} /* _eet_data_double_cache_get */ +} /* FLOAT TYPE */ static int @@ -1006,7 +1006,7 @@ eet_data_get_float(const Eet_Dictionary *ed, return -1; return 1; -} /* eet_data_get_float */ +} static void * eet_data_put_float(Eet_Dictionary *ed, @@ -1038,7 +1038,7 @@ eet_data_put_float(Eet_Dictionary *ed, return NULL; return eet_data_put_int(ed, &idx, size_ret); -} /* eet_data_put_float */ +} /* DOUBLE TYPE */ static int @@ -1082,7 +1082,7 @@ eet_data_get_double(const Eet_Dictionary *ed, return -1; return 1; -} /* eet_data_get_double */ +} static void * eet_data_put_double(Eet_Dictionary *ed, @@ -1115,7 +1115,7 @@ eet_data_put_double(Eet_Dictionary *ed, return NULL; return eet_data_put_int(ed, &idx, size_ret); -} /* eet_data_put_double */ +} static int eet_data_get_f32p32(const Eet_Dictionary *ed, @@ -1151,7 +1151,7 @@ eet_data_get_f32p32(const Eet_Dictionary *ed, return -1; return 1; -} /* eet_data_get_f32p32 */ +} static void * eet_data_put_f32p32(Eet_Dictionary *ed, @@ -1184,7 +1184,7 @@ eet_data_put_f32p32(Eet_Dictionary *ed, return NULL; return eet_data_put_int(ed, &idx, size_ret); -} /* eet_data_put_f32p32 */ +} static int eet_data_get_f16p16(const Eet_Dictionary *ed, @@ -1202,7 +1202,7 @@ eet_data_get_f16p16(const Eet_Dictionary *ed, *fp = eina_f32p32_to_f16p16(tmp); return 1; -} /* eet_data_get_f16p16 */ +} static void * eet_data_put_f16p16(Eet_Dictionary *ed, @@ -1213,7 +1213,7 @@ eet_data_put_f16p16(Eet_Dictionary *ed, tmp = eina_f16p16_to_f32p32((Eina_F16p16)(*(Eina_F16p16 *)src)); return eet_data_put_f32p32(ed, &tmp, size_ret); -} /* eet_data_put_f16p16 */ +} static int eet_data_get_f8p24(const Eet_Dictionary *ed, @@ -1231,7 +1231,7 @@ eet_data_get_f8p24(const Eet_Dictionary *ed, *fp = eina_f32p32_to_f8p24(tmp); return 1; -} /* eet_data_get_f8p24 */ +} static void * eet_data_put_f8p24(Eet_Dictionary *ed, @@ -1242,7 +1242,7 @@ eet_data_put_f8p24(Eet_Dictionary *ed, tmp = eina_f8p24_to_f32p32((Eina_F8p24)(*(Eina_F8p24 *)src)); return eet_data_put_f32p32(ed, &tmp, size_ret); -} /* eet_data_put_f8p24 */ +} static inline int eet_data_get_type(const Eet_Dictionary *ed, @@ -1255,7 +1255,7 @@ eet_data_get_type(const Eet_Dictionary *ed, ret = eet_basic_codec[type - 1].get(ed, src, src_end, dest); return ret; -} /* eet_data_get_type */ +} static inline void * eet_data_put_type(Eet_Dictionary *ed, @@ -1267,7 +1267,7 @@ eet_data_put_type(Eet_Dictionary *ed, ret = eet_basic_codec[type - 1].put(ed, src, size_ret); return ret; -} /* eet_data_put_type */ +} static inline Eina_Bool eet_data_type_match(int type1, @@ -1301,10 +1301,10 @@ eet_data_type_match(int type1, default: break; - } /* switch */ + } return EINA_FALSE; -} /* eet_data_type_match */ +} /* chunk format... * @@ -1359,7 +1359,7 @@ case EET_I_ ## Type: chnk->type = EET_T_ ## Type; break; default: return; - } /* switch */ + } } else if (chnk->type > EET_T_LAST) { @@ -1409,7 +1409,7 @@ case EET_I_ ## Type: chnk->type = EET_T_ ## Type; break; } return; -} /* eet_data_chunk_get */ +} static inline Eet_Data_Chunk * eet_data_chunk_new(void *data, @@ -1441,7 +1441,7 @@ eet_data_chunk_new(void *data, chnk->type = type; chnk->group_type = group_type; return chnk; -} /* eet_data_chunk_new */ +} static inline void eet_data_chunk_free(Eet_Data_Chunk *chnk) @@ -1450,7 +1450,7 @@ eet_data_chunk_free(Eet_Data_Chunk *chnk) free(chnk->name); free(chnk); -} /* eet_data_chunk_free */ +} static inline Eet_Data_Stream * eet_data_stream_new(void) @@ -1462,7 +1462,7 @@ eet_data_stream_new(void) return NULL; return ds; -} /* eet_data_stream_new */ +} static inline void eet_data_stream_free(Eet_Data_Stream *ds) @@ -1471,13 +1471,13 @@ eet_data_stream_free(Eet_Data_Stream *ds) free(ds->data); free(ds); -} /* eet_data_stream_free */ +} static inline void eet_data_stream_flush(Eet_Data_Stream *ds) { free(ds); -} /* eet_data_stream_flush */ +} static inline void eet_data_stream_write(Eet_Data_Stream *ds, @@ -1502,7 +1502,7 @@ eet_data_stream_write(Eet_Data_Stream *ds, p = ds->data; memcpy(p + ds->pos, data, size); ds->pos += size; -} /* eet_data_stream_write */ +} static void eet_data_chunk_put(Eet_Dictionary *ed, @@ -1541,7 +1541,7 @@ case EET_T_ ## Type: type += EET_I_ ## Type; break; default: return; - } /* switch */ + } buf[3] = type; } @@ -1578,7 +1578,7 @@ case EET_T_ ## Type: type += EET_I_ ## Type; break; free(string); on_error: free(size); -} /* eet_data_chunk_put */ +} /*---*/ @@ -1611,7 +1611,7 @@ _eet_descriptor_hash_new(Eet_Data_Descriptor *edd) edd->elements.hash.buckets[hash].next = bucket; } } -} /* _eet_descriptor_hash_new */ +} static void _eet_descriptor_hash_free(Eet_Data_Descriptor *edd) @@ -1632,7 +1632,7 @@ _eet_descriptor_hash_free(Eet_Data_Descriptor *edd) } if (edd->elements.hash.buckets) free(edd->elements.hash.buckets); -} /* _eet_descriptor_hash_free */ +} static Eet_Data_Element * _eet_descriptor_hash_find(Eet_Data_Descriptor *edd, @@ -1677,31 +1677,31 @@ _eet_descriptor_hash_find(Eet_Data_Descriptor *edd, bucket = bucket->next; } return NULL; -} /* _eet_descriptor_hash_find */ +} static void * _eet_mem_alloc(size_t size) { return calloc(1, size); -} /* _eet_mem_alloc */ +} static void _eet_mem_free(void *mem) { free(mem); -} /* _eet_mem_free */ +} static char * _eet_str_alloc(const char *str) { return strdup(str); -} /* _eet_str_alloc */ +} static void _eet_str_free(const char *str) { free((char *)str); -} /* _eet_str_free */ +} static Eina_Hash * _eet_eina_hash_add_alloc(Eina_Hash *hash, @@ -1716,7 +1716,7 @@ _eet_eina_hash_add_alloc(Eina_Hash *hash, eina_hash_add(hash, key, data); return hash; -} /* _eet_eina_hash_add_alloc */ +} static Eina_Hash * _eet_eina_hash_direct_add_alloc(Eina_Hash *hash, @@ -1731,18 +1731,18 @@ _eet_eina_hash_direct_add_alloc(Eina_Hash *hash, eina_hash_direct_add(hash, key, data); return hash; -} /* _eet_eina_hash_direct_add_alloc */ +} static char * _eet_str_direct_alloc(const char *str) { return (char *)str; -} /* _eet_str_direct_alloc */ +} static void _eet_str_direct_free(const char *str __UNUSED__) { -} /* _eet_str_direct_free */ +} static void _eet_eina_hash_foreach(void *hash, @@ -1751,14 +1751,14 @@ _eet_eina_hash_foreach(void *hash, { if (hash) eina_hash_foreach(hash, cb, fdata); -} /* _eet_eina_hash_foreach */ +} static void _eet_eina_hash_free(void *hash) { if (hash) eina_hash_free(hash); -} /* _eet_eina_hash_free */ +} /*---*/ EAPI Eina_Bool @@ -1792,7 +1792,7 @@ eet_eina_stream_data_descriptor_class_set(Eet_Data_Descriptor_Class *eddc, eddc->func.array_free = _eet_mem_free; return EINA_TRUE; -} /* eet_eina_stream_data_descriptor_class_set */ +} EAPI Eina_Bool eet_eina_file_data_descriptor_class_set(Eet_Data_Descriptor_Class *eddc, @@ -1811,7 +1811,7 @@ eet_eina_file_data_descriptor_class_set(Eet_Data_Descriptor_Class *eddc, eddc->func.str_direct_free = _eet_str_direct_free; return EINA_TRUE; -} /* eet_eina_file_data_descriptor_class_set */ +} static Eet_Data_Descriptor * _eet_data_descriptor_new(const Eet_Data_Descriptor_Class *eddc, @@ -1872,7 +1872,7 @@ _eet_data_descriptor_new(const Eet_Data_Descriptor_Class *eddc, } return edd; -} /* _eet_data_descriptor_new */ +} EAPI Eet_Data_Descriptor * eet_data_descriptor_new(const char *name, @@ -1905,31 +1905,31 @@ eet_data_descriptor_new(const char *name, eddc.func.hash_free = func_hash_free; return _eet_data_descriptor_new(&eddc, 0); -} /* eet_data_descriptor_new */ +} EAPI Eet_Data_Descriptor * eet_data_descriptor2_new(const Eet_Data_Descriptor_Class *eddc) { return _eet_data_descriptor_new(eddc, 1); -} /* eet_data_descriptor2_new */ +} EAPI Eet_Data_Descriptor * eet_data_descriptor3_new(const Eet_Data_Descriptor_Class *eddc) { return _eet_data_descriptor_new(eddc, 2); -} /* eet_data_descriptor3_new */ +} EAPI Eet_Data_Descriptor * eet_data_descriptor_stream_new(const Eet_Data_Descriptor_Class *eddc) { return _eet_data_descriptor_new(eddc, 1); -} /* eet_data_descriptor_stream_new */ +} EAPI Eet_Data_Descriptor * eet_data_descriptor_file_new(const Eet_Data_Descriptor_Class *eddc) { return _eet_data_descriptor_new(eddc, 2); -} /* eet_data_descriptor_file_new */ +} EAPI void eet_data_descriptor_free(Eet_Data_Descriptor *edd) @@ -1942,7 +1942,7 @@ eet_data_descriptor_free(Eet_Data_Descriptor *edd) free(edd->elements.set); free(edd); -} /* eet_data_descriptor_free */ +} EAPI void eet_data_descriptor_element_add(Eet_Data_Descriptor *edd, @@ -2039,7 +2039,7 @@ eet_data_descriptor_element_add(Eet_Data_Descriptor *edd, ede->counter_name = counter_name; ede->subtype = subtype; -} /* eet_data_descriptor_element_add */ +} EAPI void * eet_data_read_cipher(Eet_File *ef, @@ -2075,7 +2075,7 @@ eet_data_read_cipher(Eet_File *ef, free((void *)data); return data_dec; -} /* eet_data_read_cipher */ +} EAPI Eet_Node * eet_data_node_read_cipher(Eet_File *ef, @@ -2110,7 +2110,7 @@ eet_data_node_read_cipher(Eet_File *ef, free((void *)data); return result; -} /* eet_data_node_read_cipher */ +} EAPI void * eet_data_read(Eet_File *ef, @@ -2118,7 +2118,7 @@ eet_data_read(Eet_File *ef, const char *name) { return eet_data_read_cipher(ef, edd, name, NULL); -} /* eet_data_read */ +} EAPI int eet_data_write_cipher(Eet_File *ef, @@ -2142,7 +2142,7 @@ eet_data_write_cipher(Eet_File *ef, val = eet_write_cipher(ef, name, data_enc, size, compress, cipher_key); free(data_enc); return val; -} /* eet_data_write_cipher */ +} EAPI int eet_data_write(Eet_File *ef, @@ -2152,7 +2152,7 @@ eet_data_write(Eet_File *ef, int compress) { return eet_data_write_cipher(ef, edd, name, NULL, data, compress); -} /* eet_data_write */ +} static void eet_free_context_init(Eet_Free_Context *context) @@ -2222,7 +2222,7 @@ _eet_free_hash(void *data) #endif /* if defined (_WIN64) || ((!defined (_WIN32)) && (LONG_BIT != 32)) */ return hash & 0xFF; -} /* _eet_free_hash */ +} static void _eet_free_add(Eet_Free *ef, @@ -2240,7 +2240,7 @@ _eet_free_add(Eet_Free *ef, return; eina_array_push(&ef->list[hash], data); -} /* _eet_free_add */ +} #if 0 static void @@ -2274,19 +2274,19 @@ _eet_free_reset(Eet_Free *ef) for (i = 0; i < EET_FREE_COUNT; ++i) eina_array_clean(&ef->list[i]); -} /* _eet_free_reset */ +} static void _eet_free_ref(Eet_Free *ef) { ef->ref++; -} /* _eet_free_ref */ +} static void _eet_free_unref(Eet_Free *ef) { ef->ref--; -} /* _eet_free_unref */ +} #define _eet_freelist_add(Ctx, Data) _eet_free_add(&Ctx->freelist, Data); #define _eet_freelist_del(Ctx, Data) _eet_free_del(&Ctx->freelist, Data); @@ -2316,7 +2316,7 @@ _eet_freelist_free(Eet_Free_Context *context, free(track); } _eet_free_reset(&context->freelist); -} /* _eet_freelist_free */ +} #define _eet_freelist_array_add(Ctx, Data) _eet_free_add(&Ctx->freelist_array, Data); #define _eet_freelist_array_del(Ctx, Data) _eet_free_del(&Ctx->freelist_array, Data); @@ -2351,7 +2351,7 @@ _eet_freelist_array_free(Eet_Free_Context *context, free(track); } _eet_free_reset(&context->freelist_array); -} /* _eet_freelist_array_free */ +} #define _eet_freelist_list_add(Ctx, Data) _eet_free_add(&Ctx->freelist_list, Data); #define _eet_freelist_list_del(Ctx, Data) _eet_free_del(&Ctx->freelist_list, Data); @@ -2379,7 +2379,7 @@ _eet_freelist_list_free(Eet_Free_Context *context, edd->func.list_free(*((void **)(track))); } _eet_free_reset(&context->freelist_list); -} /* _eet_freelist_list_free */ +} #define _eet_freelist_str_add(Ctx, Data) _eet_free_add(&Ctx->freelist_str, Data); #define _eet_freelist_str_del(Ctx, Data) _eet_free_del(&Ctx->freelist_str, Data); @@ -2409,7 +2409,7 @@ _eet_freelist_str_free(Eet_Free_Context *context, free(track); } _eet_free_reset(&context->freelist_str); -} /* _eet_freelist_str_free */ +} #define _eet_freelist_direct_str_add(Ctx, Data) _eet_free_add(&Ctx->freelist_direct_str, Data); #define _eet_freelist_direct_str_del(Ctx, Data) _eet_free_del(&Ctx->freelist_direct_str, Data); @@ -2439,7 +2439,7 @@ _eet_freelist_direct_str_free(Eet_Free_Context *context, free(track); } _eet_free_reset(&context->freelist_direct_str); -} /* _eet_freelist_direct_str_free */ +} #define _eet_freelist_hash_add(Ctx, Data) _eet_free_add(&Ctx->freelist_hash, Data); #define _eet_freelist_hash_del(Ctx, Data) _eet_free_del(&Ctx->freelist_hash, Data); @@ -2469,7 +2469,7 @@ _eet_freelist_hash_free(Eet_Free_Context *context, free(track); } _eet_free_reset(&context->freelist_hash); -} /* _eet_freelist_hash_free */ +} static void _eet_freelist_all_ref(Eet_Free_Context *freelist_context) @@ -2479,7 +2479,7 @@ _eet_freelist_all_ref(Eet_Free_Context *freelist_context) _eet_freelist_list_ref(freelist_context); _eet_freelist_hash_ref(freelist_context); _eet_freelist_direct_str_ref(freelist_context); -} /* _eet_freelist_all_ref */ +} static void _eet_freelist_all_unref(Eet_Free_Context *freelist_context) @@ -2489,7 +2489,7 @@ _eet_freelist_all_unref(Eet_Free_Context *freelist_context) _eet_freelist_list_unref(freelist_context); _eet_freelist_hash_unref(freelist_context); _eet_freelist_direct_str_unref(freelist_context); -} /* _eet_freelist_all_unref */ +} static int eet_data_descriptor_encode_hash_cb(void *hash __UNUSED__, @@ -2556,7 +2556,7 @@ eet_data_descriptor_encode_hash_cb(void *hash __UNUSED__, } return 1; -} /* eet_data_descriptor_encode_hash_cb */ +} static char * _eet_data_dump_token_get(const char *src, @@ -2639,7 +2639,7 @@ _eet_data_dump_token_get(const char *src, free(tok); return NULL; -} /* _eet_data_dump_token_get */ +} static void eet_data_encode(Eet_Dictionary *ed, @@ -2663,7 +2663,7 @@ eet_data_encode(Eet_Dictionary *ed, eet_data_chunk_put(ed, echnk, ds); eet_data_chunk_free(echnk); free(data); -} /* eet_data_encode */ +} static void * _eet_data_dump_encode(int parent_type, @@ -2976,7 +2976,7 @@ case Eet_Type: \ eet_data_chunk_free(chnk); return cdata; -} /* _eet_data_dump_encode */ +} static void * _eet_data_dump_parse(Eet_Dictionary *ed, @@ -3238,7 +3238,7 @@ _eet_data_dump_parse(Eet_Dictionary *ed, } return cdata; -} /* _eet_data_dump_parse */ +} #define NEXT_CHUNK(P, Size, Echnk, Ed) \ { \ @@ -3352,7 +3352,7 @@ _eet_data_descriptor_decode(Eet_Free_Context *context, case EET_G_VARIANT: default: goto error; - } /* switch */ + } } while (size > 0) @@ -3477,7 +3477,7 @@ error: /* FIXME: Warn that something goes wrong here. */ return NULL; -} /* _eet_data_descriptor_decode */ +} static int eet_data_get_list(Eet_Free_Context *context, @@ -3544,7 +3544,7 @@ eet_data_get_list(Eet_Free_Context *context, on_error: return 0; -} /* eet_data_get_list */ +} static int eet_data_get_hash(Eet_Free_Context *context, @@ -3629,7 +3629,7 @@ eet_data_get_hash(Eet_Free_Context *context, on_error: return 0; -} /* eet_data_get_hash */ +} /* var arrays and fixed arrays have to * get all chunks at once. for fixed arrays @@ -3793,7 +3793,7 @@ on_error: eet_node_del(tmp); return 0; -} /* eet_data_get_array */ +} static void eet_data_put_union(Eet_Dictionary *ed, @@ -3849,7 +3849,7 @@ eet_data_put_union(Eet_Dictionary *ed, break; } -} /* eet_data_put_union */ +} static int eet_data_get_union(Eet_Free_Context *context, @@ -3947,7 +3947,7 @@ eet_data_get_union(Eet_Free_Context *context, on_error: return 0; -} /* eet_data_get_union */ +} static void eet_data_put_variant(Eet_Dictionary *ed, @@ -4058,7 +4058,7 @@ eet_data_put_variant(Eet_Dictionary *ed, break; } -} /* eet_data_put_variant */ +} static int eet_data_get_variant(Eet_Free_Context *context, @@ -4213,7 +4213,7 @@ eet_data_get_variant(Eet_Free_Context *context, on_error: return 0; -} /* eet_data_get_variant */ +} static Eet_Node * eet_data_node_simple_type(int type, @@ -4249,8 +4249,8 @@ case Eet_Type: \ default: ERR("Unknow type passed to eet_data_node_simple_type"); return NULL; - } /* switch */ -} /* eet_data_node_simple_type */ + } +} static int eet_data_get_unknown(Eet_Free_Context *context, @@ -4366,7 +4366,7 @@ eet_data_get_unknown(Eet_Free_Context *context, } return 1; -} /* eet_data_get_unknown */ +} static void eet_data_put_array(Eet_Dictionary *ed, @@ -4442,7 +4442,7 @@ eet_data_put_array(Eet_Dictionary *ed, offset += subsize; } -} /* eet_data_put_array */ +} static void eet_data_put_unknown(Eet_Dictionary *ed, @@ -4471,7 +4471,7 @@ eet_data_put_unknown(Eet_Dictionary *ed, size, ede->type, ede->group_type); -} /* eet_data_put_unknown */ +} static void eet_data_put_list(Eet_Dictionary *ed, @@ -4512,7 +4512,7 @@ eet_data_put_list(Eet_Dictionary *ed, ede->group_type); } } -} /* eet_data_put_list */ +} static void eet_data_put_hash(Eet_Dictionary *ed, @@ -4529,7 +4529,7 @@ eet_data_put_hash(Eet_Dictionary *ed, fdata.ede = ede; fdata.ed = ed; edd->func.hash_foreach(l, eet_data_descriptor_encode_hash_cb, &fdata); -} /* eet_data_put_hash */ +} EAPI int eet_data_dump_cipher(Eet_File *ef, @@ -4570,7 +4570,7 @@ eet_data_dump_cipher(Eet_File *ef, free((void *)data); return result ? 1 : 0; -} /* eet_data_dump_cipher */ +} EAPI int eet_data_dump(Eet_File *ef, @@ -4579,7 +4579,7 @@ eet_data_dump(Eet_File *ef, void *dumpdata) { return eet_data_dump_cipher(ef, name, NULL, dumpfunc, dumpdata); -} /* eet_data_dump */ +} EAPI int eet_data_text_dump_cipher(const void *data_in, @@ -4624,7 +4624,7 @@ eet_data_text_dump_cipher(const void *data_in, free(ret); return result ? 1 : 0; -} /* eet_data_text_dump_cipher */ +} EAPI int eet_data_text_dump(const void *data_in, @@ -4633,7 +4633,7 @@ eet_data_text_dump(const void *data_in, void *dumpdata) { return eet_data_text_dump_cipher(data_in, NULL, size_in, dumpfunc, dumpdata); -} /* eet_data_text_dump */ +} EAPI void * eet_data_text_undump_cipher(const char *text, @@ -4666,7 +4666,7 @@ eet_data_text_undump_cipher(const char *text, } return ret; -} /* eet_data_text_undump_cipher */ +} EAPI void * eet_data_text_undump(const char *text, @@ -4674,7 +4674,7 @@ eet_data_text_undump(const char *text, int *size_ret) { return eet_data_text_undump_cipher(text, NULL, textlen, size_ret); -} /* eet_data_text_undump */ +} EAPI int eet_data_undump_cipher(Eet_File *ef, @@ -4698,7 +4698,7 @@ eet_data_undump_cipher(Eet_File *ef, val = eet_write_cipher(ef, name, data_enc, size, compress, cipher_key); free(data_enc); return val; -} /* eet_data_undump_cipher */ +} EAPI int eet_data_undump(Eet_File *ef, @@ -4708,7 +4708,7 @@ eet_data_undump(Eet_File *ef, int compress) { return eet_data_undump_cipher(ef, name, NULL, text, textlen, compress); -} /* eet_data_undump */ +} EAPI void * eet_data_descriptor_decode_cipher(Eet_Data_Descriptor *edd, @@ -4744,7 +4744,7 @@ eet_data_descriptor_decode_cipher(Eet_Data_Descriptor *edd, free(deciphered); return ret; -} /* eet_data_descriptor_decode_cipher */ +} EAPI void * eet_data_descriptor_decode(Eet_Data_Descriptor *edd, @@ -4752,7 +4752,7 @@ eet_data_descriptor_decode(Eet_Data_Descriptor *edd, int size_in) { return eet_data_descriptor_decode_cipher(edd, data_in, NULL, size_in); -} /* eet_data_descriptor_decode */ +} EAPI Eet_Node * eet_data_node_decode_cipher(const void *data_in, @@ -4787,7 +4787,7 @@ eet_data_node_decode_cipher(const void *data_in, free(deciphered); return ret; -} /* eet_data_node_decode_cipher */ +} static void * _eet_data_descriptor_encode(Eet_Dictionary *ed, @@ -4849,7 +4849,7 @@ _eet_data_descriptor_encode(Eet_Dictionary *ed, eet_data_chunk_free(chnk); return cdata; -} /* _eet_data_descriptor_encode */ +} EAPI int eet_data_node_write_cipher(Eet_File *ef, @@ -4872,7 +4872,7 @@ eet_data_node_write_cipher(Eet_File *ef, val = eet_write_cipher(ef, name, data_enc, size, compress, cipher_key); free(data_enc); return val; -} /* eet_data_node_write_cipher */ +} EAPI void * eet_data_node_encode_cipher(Eet_Node *node, @@ -4909,7 +4909,7 @@ eet_data_node_encode_cipher(Eet_Node *node, *size_ret = size; return ret; -} /* eet_data_node_encode_cipher */ +} EAPI void * eet_data_descriptor_encode_cipher(Eet_Data_Descriptor *edd, @@ -4947,7 +4947,7 @@ eet_data_descriptor_encode_cipher(Eet_Data_Descriptor *edd, *size_ret = size; return ret; -} /* eet_data_descriptor_encode_cipher */ +} EAPI void * eet_data_descriptor_encode(Eet_Data_Descriptor *edd, @@ -4955,7 +4955,7 @@ eet_data_descriptor_encode(Eet_Data_Descriptor *edd, int *size_ret) { return eet_data_descriptor_encode_cipher(edd, data_in, NULL, size_ret); -} /* eet_data_descriptor_encode */ +} EAPI void * eet_data_xattr_cipher_get(const char *filename, diff --git a/libraries/eet/src/lib/eet_dictionary.c b/libraries/eet/src/lib/eet_dictionary.c index 60d0ec1..287860d 100644 --- a/libraries/eet/src/lib/eet_dictionary.c +++ b/libraries/eet/src/lib/eet_dictionary.c @@ -16,34 +16,33 @@ eet_dictionary_add(void) { Eet_Dictionary *new; - new = calloc(1, sizeof (Eet_Dictionary)); + new = eet_dictionary_calloc(1); if (!new) return NULL; memset(new->hash, -1, sizeof (int) * 256); return new; -} /* eet_dictionary_add */ +} void eet_dictionary_free(Eet_Dictionary *ed) { - if (ed) - { - int i; + int i; - for (i = 0; i < ed->count; ++i) - if (ed->all[i].allocated) - eina_stringshare_del(ed->all[i].str); + if (!ed) return; - if (ed->all) - free(ed->all); + for (i = 0; i < ed->count; ++i) + if (ed->all[i].allocated) + eina_stringshare_del(ed->all[i].str); - if (ed->converts) eina_hash_free(ed->converts); + if (ed->all) + free(ed->all); - free(ed); - } -} /* eet_dictionary_free */ + if (ed->converts) eina_hash_free(ed->converts); + + eet_dictionary_mp_free(ed); +} static int _eet_dictionary_lookup(Eet_Dictionary *ed, @@ -77,7 +76,7 @@ _eet_dictionary_lookup(Eet_Dictionary *ed, return prev; return current; -} /* _eet_dictionary_lookup */ +} int eet_dictionary_string_add(Eet_Dictionary *ed, @@ -110,7 +109,7 @@ eet_dictionary_string_add(Eet_Dictionary *ed, total = ed->total + 8; - new = realloc(ed->all, sizeof (Eet_String) * total); + new = realloc(ed->all, total * sizeof(Eet_String)); if (!new) return -1; @@ -152,7 +151,7 @@ eet_dictionary_string_add(Eet_Dictionary *ed, } return ed->count++; -} /* eet_dictionary_string_add */ +} int eet_dictionary_string_get_size(const Eet_Dictionary *ed, @@ -168,7 +167,7 @@ eet_dictionary_string_get_size(const Eet_Dictionary *ed, return ed->all[idx].len; return 0; -} /* eet_dictionary_string_get_size */ +} int eet_dictionary_string_get_hash(const Eet_Dictionary *ed, @@ -184,7 +183,7 @@ eet_dictionary_string_get_hash(const Eet_Dictionary *ed, return ed->all[idx].hash; return -1; -} /* eet_dictionary_string_get_hash */ +} const char * eet_dictionary_string_get_char(const Eet_Dictionary *ed, @@ -210,7 +209,7 @@ eet_dictionary_string_get_char(const Eet_Dictionary *ed, } return NULL; -} /* eet_dictionary_string_get_char */ +} static inline Eina_Bool _eet_dictionary_string_get_me_cache(const char *s, @@ -227,7 +226,7 @@ _eet_dictionary_string_get_me_cache(const char *s, } return EINA_FALSE; -} /* _eet_dictionary_string_get_me_cache */ +} static inline Eina_Bool _eet_dictionary_string_get_float_cache(const char *s, @@ -248,7 +247,7 @@ _eet_dictionary_string_get_float_cache(const char *s, } return EINA_FALSE; -} /* _eet_dictionary_string_get_float_cache */ +} static inline Eina_Bool _eet_dictionary_string_get_double_cache(const char *s, @@ -269,7 +268,7 @@ _eet_dictionary_string_get_double_cache(const char *s, } return EINA_FALSE; -} /* _eet_dictionary_string_get_double_cache */ +} static inline Eina_Bool _eet_dictionary_test(const Eet_Dictionary *ed, @@ -289,7 +288,7 @@ _eet_dictionary_test(const Eet_Dictionary *ed, return EINA_FALSE; return EINA_TRUE; -} /* _eet_dictionary_test */ +} static Eet_Convert * eet_dictionary_convert_get(const Eet_Dictionary *ed, @@ -351,7 +350,7 @@ eet_dictionary_string_get_float(const Eet_Dictionary *ed, *result = convert->f; return EINA_TRUE; -} /* eet_dictionary_string_get_float */ +} Eina_Bool eet_dictionary_string_get_double(const Eet_Dictionary *ed, @@ -387,7 +386,7 @@ eet_dictionary_string_get_double(const Eet_Dictionary *ed, *result = convert->d; return EINA_TRUE; -} /* eet_dictionary_string_get_double */ +} Eina_Bool eet_dictionary_string_get_fp(const Eet_Dictionary *ed, @@ -416,7 +415,7 @@ eet_dictionary_string_get_fp(const Eet_Dictionary *ed, *result = convert->fp; return EINA_TRUE; -} /* eet_dictionary_string_get_fp */ +} EAPI int eet_dictionary_string_check(Eet_Dictionary *ed, @@ -435,5 +434,5 @@ eet_dictionary_string_check(Eet_Dictionary *ed, return 1; return 0; -} /* eet_dictionary_string_check */ +} diff --git a/libraries/eet/src/lib/eet_image.c b/libraries/eet/src/lib/eet_image.c index 79f6f90..8c6c03c 100644 --- a/libraries/eet/src/lib/eet_image.c +++ b/libraries/eet/src/lib/eet_image.c @@ -66,7 +66,7 @@ _eet_jpeg_membuf_src_init(j_decompress_ptr cinfo) { /* FIXME: Use attribute unused */ (void)cinfo; -} /* _eet_jpeg_membuf_src_init */ +} static boolean _eet_jpeg_membuf_src_fill(j_decompress_ptr cinfo) @@ -78,7 +78,7 @@ _eet_jpeg_membuf_src_fill(j_decompress_ptr cinfo) src->pub.next_input_byte = jpeg_eoi; return TRUE; -} /* _eet_jpeg_membuf_src_fill */ +} static void _eet_jpeg_membuf_src_skip(j_decompress_ptr cinfo, @@ -88,7 +88,7 @@ _eet_jpeg_membuf_src_skip(j_decompress_ptr cinfo, src->pub.bytes_in_buffer -= num_bytes; src->pub.next_input_byte += num_bytes; -} /* _eet_jpeg_membuf_src_skip */ +} static void _eet_jpeg_membuf_src_term(j_decompress_ptr cinfo) @@ -97,7 +97,7 @@ _eet_jpeg_membuf_src_term(j_decompress_ptr cinfo) free(src); cinfo->src = NULL; -} /* _eet_jpeg_membuf_src_term */ +} static int eet_jpeg_membuf_src(j_decompress_ptr cinfo, @@ -124,7 +124,7 @@ eet_jpeg_membuf_src(j_decompress_ptr cinfo, src->pub.next_input_byte = src->buf; return 0; -} /* eet_jpeg_membuf_src */ +} struct jpeg_membuf_dst { @@ -144,7 +144,7 @@ _eet_jpeg_membuf_dst_init(j_compress_ptr cinfo) { /* FIXME: Use eina attribute */ (void)cinfo; -} /* _eet_jpeg_membuf_dst_init */ +} static boolean _eet_jpeg_membuf_dst_flush(j_compress_ptr cinfo) @@ -168,7 +168,7 @@ _eet_jpeg_membuf_dst_flush(j_compress_ptr cinfo) dst->len *= 2; return FALSE; -} /* _eet_jpeg_membuf_dst_flush */ +} static void _eet_jpeg_membuf_dst_term(j_compress_ptr cinfo) @@ -189,7 +189,7 @@ _eet_jpeg_membuf_dst_term(j_compress_ptr cinfo) free(dst); cinfo->dest = NULL; -} /* _eet_jpeg_membuf_dst_term */ +} static int eet_jpeg_membuf_dst(j_compress_ptr cinfo, @@ -223,7 +223,7 @@ eet_jpeg_membuf_dst(j_compress_ptr cinfo, dst->failed = 0; return 0; -} /* eet_jpeg_membuf_dst */ +} /*---*/ @@ -336,7 +336,7 @@ _JPEGFatalErrorHandler(j_common_ptr cinfo) /* cinfo->err->output_message(cinfo);*/ longjmp(errmgr->setjmp_buffer, 1); return; -} /* _JPEGFatalErrorHandler */ +} static void _JPEGErrorHandler(j_common_ptr cinfo __UNUSED__) @@ -347,7 +347,7 @@ _JPEGErrorHandler(j_common_ptr cinfo __UNUSED__) /* cinfo->err->output_message(cinfo);*/ /* longjmp(errmgr->setjmp_buffer, 1);*/ return; -} /* _JPEGErrorHandler */ +} static void _JPEGErrorHandler2(j_common_ptr cinfo __UNUSED__, @@ -359,7 +359,7 @@ _JPEGErrorHandler2(j_common_ptr cinfo __UNUSED__, /* cinfo->err->output_message(cinfo);*/ /* longjmp(errmgr->setjmp_buffer, 1);*/ return; -} /* _JPEGErrorHandler2 */ +} static int eet_data_image_jpeg_header_decode(const void *data, @@ -405,7 +405,7 @@ eet_data_image_jpeg_header_decode(const void *data, return 0; return 1; -} /* eet_data_image_jpeg_header_decode */ +} static int eet_data_image_jpeg_rgb_decode(const void *data, @@ -558,7 +558,7 @@ eet_data_image_jpeg_rgb_decode(const void *data, jpeg_finish_decompress(&cinfo); jpeg_destroy_decompress(&cinfo); return 1; -} /* eet_data_image_jpeg_rgb_decode */ +} static void * eet_data_image_jpeg_alpha_decode(const void *data, @@ -667,7 +667,7 @@ eet_data_image_jpeg_alpha_decode(const void *data, jpeg_finish_decompress(&cinfo); jpeg_destroy_decompress(&cinfo); return d; -} /* eet_data_image_jpeg_alpha_decode */ +} static void * eet_data_image_lossless_convert(int *size, @@ -715,7 +715,7 @@ eet_data_image_lossless_convert(int *size, *size = ((w * h * 4) + (8 * 4)); return d; } -} /* eet_data_image_lossless_convert */ +} static void * eet_data_image_lossless_compressed_convert(int *size, @@ -789,7 +789,7 @@ eet_data_image_lossless_compressed_convert(int *size, free(comp); return d; } -} /* eet_data_image_lossless_compressed_convert */ +} static void * eet_data_image_jpeg_convert(int *size, @@ -872,7 +872,7 @@ eet_data_image_jpeg_convert(int *size, *size = sz; return d; -} /* eet_data_image_jpeg_convert */ +} static void * eet_data_image_jpeg_alpha_convert(int *size, @@ -1063,7 +1063,7 @@ eet_data_image_jpeg_alpha_convert(int *size, free(d2); *size = 12 + sz1 + sz2; return d; -} /* eet_data_image_jpeg_alpha_convert */ +} EAPI int eet_data_image_write_cipher(Eet_File *ef, @@ -1091,7 +1091,7 @@ eet_data_image_write_cipher(Eet_File *ef, } return 0; -} /* eet_data_image_write_cipher */ +} EAPI int eet_data_image_write(Eet_File *ef, @@ -1114,7 +1114,7 @@ eet_data_image_write(Eet_File *ef, comp, quality, lossy); -} /* eet_data_image_write */ +} EAPI void * eet_data_image_read_cipher(Eet_File *ef, @@ -1149,7 +1149,7 @@ eet_data_image_read_cipher(Eet_File *ef, free(data); return d; -} /* eet_data_image_read_cipher */ +} EAPI void * eet_data_image_read(Eet_File *ef, @@ -1163,7 +1163,7 @@ eet_data_image_read(Eet_File *ef, { return eet_data_image_read_cipher(ef, name, NULL, w, h, alpha, comp, quality, lossy); -} /* eet_data_image_read */ +} EAPI int eet_data_image_read_to_surface_cipher(Eet_File *ef, @@ -1204,7 +1204,7 @@ eet_data_image_read_to_surface_cipher(Eet_File *ef, free(data); return res; -} /* eet_data_image_read_to_surface_cipher */ +} EAPI int eet_data_image_read_to_surface(Eet_File *ef, @@ -1225,7 +1225,7 @@ eet_data_image_read_to_surface(Eet_File *ef, w, h, row_stride, alpha, comp, quality, lossy); -} /* eet_data_image_read_to_surface */ +} EAPI int eet_data_image_header_read_cipher(Eet_File *ef, @@ -1260,7 +1260,7 @@ eet_data_image_header_read_cipher(Eet_File *ef, free(data); return d; -} /* eet_data_image_header_read_cipher */ +} EAPI int eet_data_image_header_read(Eet_File *ef, @@ -1275,7 +1275,7 @@ eet_data_image_header_read(Eet_File *ef, return eet_data_image_header_read_cipher(ef, name, NULL, w, h, alpha, comp, quality, lossy); -} /* eet_data_image_header_read */ +} EAPI void * eet_data_image_encode_cipher(const void *data, @@ -1333,7 +1333,7 @@ eet_data_image_encode_cipher(const void *data, *size_ret = size; return d; -} /* eet_data_image_encode_cipher */ +} EAPI void * eet_data_image_encode(const void *data, @@ -1347,7 +1347,7 @@ eet_data_image_encode(const void *data, { return eet_data_image_encode_cipher(data, NULL, w, h, alpha, comp, quality, lossy, size_ret); -} /* eet_data_image_encode */ +} EAPI int eet_data_image_header_decode_cipher(const void *data, @@ -1499,7 +1499,7 @@ eet_data_image_header_decode_cipher(const void *data, } return 0; -} /* eet_data_image_header_decode_cipher */ +} EAPI int eet_data_image_header_decode(const void *data, @@ -1520,7 +1520,7 @@ eet_data_image_header_decode(const void *data, comp, quality, lossy); -} /* eet_data_image_header_decode */ +} static void _eet_data_image_copy_buffer(const unsigned int *src, @@ -1544,7 +1544,7 @@ _eet_data_image_copy_buffer(const unsigned int *src, for (y = 0; y < h; ++y, src += src_w, over += row_stride) memcpy(over, src, w * 4); } -} /* _eet_data_image_copy_buffer */ +} static int _eet_data_image_decode_inside(const void *data, @@ -1647,7 +1647,7 @@ _eet_data_image_decode_inside(const void *data, abort(); return 1; -} /* _eet_data_image_decode_inside */ +} EAPI void * eet_data_image_decode_cipher(const void *data, @@ -1714,7 +1714,7 @@ eet_data_image_decode_cipher(const void *data, *lossy = ilossy; return d; -} /* eet_data_image_decode_cipher */ +} EAPI void * eet_data_image_decode(const void *data, @@ -1728,7 +1728,7 @@ eet_data_image_decode(const void *data, { return eet_data_image_decode_cipher(data, NULL, size, w, h, alpha, comp, quality, lossy); -} /* eet_data_image_decode */ +} EAPI int eet_data_image_decode_to_surface_cipher(const void *data, @@ -1795,7 +1795,7 @@ eet_data_image_decode_to_surface_cipher(const void *data, *lossy = ilossy; return 1; -} /* eet_data_image_decode_to_surface_cipher */ +} EAPI int eet_data_image_decode_to_surface(const void *data, @@ -1816,5 +1816,5 @@ eet_data_image_decode_to_surface(const void *data, w, h, row_stride, alpha, comp, quality, lossy); -} /* eet_data_image_decode_to_surface */ +} diff --git a/libraries/eet/src/lib/eet_lib.c b/libraries/eet/src/lib/eet_lib.c index a0d6435..04feebe 100644 --- a/libraries/eet/src/lib/eet_lib.c +++ b/libraries/eet/src/lib/eet_lib.c @@ -82,126 +82,6 @@ EAPI Eet_Version *eet_version = &_version; #define EET_MAGIC_FILE2 0x1ee70f42 -typedef struct _Eet_File_Header Eet_File_Header; -typedef struct _Eet_File_Node Eet_File_Node; -typedef struct _Eet_File_Directory Eet_File_Directory; - -struct _Eet_File -{ - char *path; - Eina_File *readfp; - Eet_File_Header *header; - Eet_Dictionary *ed; - Eet_Key *key; - const unsigned char *data; - const void *x509_der; - const void *signature; - void *sha1; - - Eet_File_Mode mode; - - int magic; - int references; - - unsigned long int data_size; - int x509_length; - unsigned int signature_length; - int sha1_length; - - Eina_Lock file_lock; - - unsigned char writes_pending : 1; - unsigned char delete_me_now : 1; -}; - -struct _Eet_File_Header -{ - int magic; - Eet_File_Directory *directory; -}; - -struct _Eet_File_Directory -{ - int size; - Eet_File_Node **nodes; -}; - -struct _Eet_File_Node -{ - char *name; - void *data; - Eet_File_Node *next; /* FIXME: make buckets linked lists */ - - unsigned long int offset; - unsigned long int dictionary_offset; - unsigned long int name_offset; - - unsigned int name_size; - unsigned int size; - unsigned int data_size; - - unsigned char free_name : 1; - unsigned char compression : 1; - unsigned char ciphered : 1; - unsigned char alias : 1; -}; - -#if 0 -/* Version 2 */ -/* NB: all int's are stored in network byte order on disk */ -/* file format: */ -int magic; /* magic number ie 0x1ee7ff00 */ -int num_directory_entries; /* number of directory entries to follow */ -int bytes_directory_entries; /* bytes of directory entries to follow */ -struct -{ - int offset; /* bytes offset into file for data chunk */ - int flags; /* flags - for now 0 = uncompressed and clear, 1 = compressed and clear, 2 = uncompressed and ciphered, 3 = compressed and ciphered */ - int size; /* size of the data chunk */ - int data_size; /* size of the (uncompressed) data chunk */ - int name_size; /* length in bytes of the name field */ - char name[name_size]; /* name string (variable length) and \0 terminated */ -} directory[num_directory_entries]; -/* and now startes the data stream... */ -#endif /* if 0 */ - -#if 0 -/* Version 3 */ -/* NB: all int's are stored in network byte order on disk */ -/* file format: */ -int magic; /* magic number ie 0x1ee70f42 */ -int num_directory_entries; /* number of directory entries to follow */ -int num_dictionary_entries; /* number of dictionary entries to follow */ -struct -{ - int data_offset; /* bytes offset into file for data chunk */ - int size; /* size of the data chunk */ - int data_size; /* size of the (uncompressed) data chunk */ - int name_offset; /* bytes offset into file for name string */ - int name_size; /* length in bytes of the name field */ - int flags; /* bit flags - for now: - bit 0 => compresion on/off - bit 1 => ciphered on/off - bit 2 => alias - */ -} directory[num_directory_entries]; -struct -{ - int hash; - int offset; - int size; - int prev; - int next; -} dictionary[num_dictionary_entries]; -/* now start the string stream. */ -/* and right after them the data stream. */ -int magic_sign; /* Optional, only if the eet file is signed. */ -int signature_length; /* Signature length. */ -int x509_length; /* Public certificate that signed the file. */ -char signature[signature_length]; /* The signature. */ -char x509[x509_length]; /* The public certificate. */ -#endif /* if 0 */ - #define EET_FILE2_HEADER_COUNT 3 #define EET_FILE2_DIRECTORY_ENTRY_COUNT 6 #define EET_FILE2_DICTIONARY_ENTRY_COUNT 5 @@ -280,7 +160,7 @@ eet_check_pointer(const Eet_File *ef) return 1; return 0; -} /* eet_check_pointer */ +} static inline int eet_check_header(const Eet_File *ef) @@ -292,7 +172,7 @@ eet_check_header(const Eet_File *ef) return 1; return 0; -} /* eet_check_header */ +} static inline int eet_test_close(int test, @@ -305,7 +185,7 @@ eet_test_close(int test, } return test; -} /* eet_test_close */ +} /* find an eet file in the currently in use cache */ static Eet_File * @@ -326,7 +206,7 @@ eet_cache_find(const char *path, /* not found */ return NULL; -} /* eet_cache_find */ +} /* add to end of cache */ /* this should only be called when the cache lock is already held */ @@ -382,7 +262,7 @@ eet_cache_add(Eet_File *ef, *cache = new_cache; *cache_num = new_cache_num; *cache_alloc = new_cache_alloc; -} /* eet_cache_add */ +} /* delete from cache */ /* this should only be called when the cache lock is already held */ @@ -437,7 +317,7 @@ eet_cache_del(Eet_File *ef, *cache = new_cache; *cache_num = new_cache_num; *cache_alloc = new_cache_alloc; -} /* eet_cache_del */ +} /* internal string match. null friendly, catches same ptr */ static int @@ -452,7 +332,7 @@ eet_string_match(const char *s1, return 1; return !strcmp(s1, s2); -} /* eet_string_match */ +} /* flush out writes to a v2 eet file */ static Eet_Error @@ -494,7 +374,7 @@ eet_flush2(Eet_File *ef) if (!fp) return EET_ERROR_NOT_WRITABLE; - fcntl(fileno(fp), F_SETFD, FD_CLOEXEC); + fcntl(fd, F_SETFD, FD_CLOEXEC); } else return EET_ERROR_NOT_WRITABLE; @@ -627,14 +507,6 @@ eet_flush2(Eet_File *ef) /* flush all write to the file. */ fflush(fp); -// this is going to really cause trouble. if ANYTHING this needs to go into a -// thread spawned off - but even then... -// in this case... ext4 is "wrong". (yes we can jump up and down and point posix -// manual pages at eachother, but ext4 broke behavior that has been in place -// for decades and that 1000's of apps rely on daily - that is that one operation -// to disk is committed to disk BEFORE following operations, so the fs retains -// a consistent state -// fsync(fileno(fp)); /* append signature if required */ if (ef->key) @@ -665,13 +537,13 @@ write_error: case EPIPE: error = EET_ERROR_WRITE_ERROR_FILE_CLOSED; break; default: error = EET_ERROR_WRITE_ERROR; break; - } /* switch */ + } } sign_error: fclose(fp); return error; -} /* eet_flush2 */ +} EAPI int eet_init(void) @@ -680,10 +552,7 @@ eet_init(void) return eet_init_count; if (!eina_init()) - { - fprintf(stderr, "Eet: Eina init failed"); - return --eet_init_count; - } + return --eet_init_count; _eet_log_dom_global = eina_log_domain_register("eet", EET_DEFAULT_LOG_COLOR); if (_eet_log_dom_global < 0) @@ -694,12 +563,18 @@ eet_init(void) eina_lock_new(&eet_cache_lock); - if (!eet_node_init()) + if (!eet_mempool_init()) { EINA_LOG_ERR("Eet: Eet_Node mempool creation failed"); goto unregister_log_domain; } + if (!eet_node_init()) + { + EINA_LOG_ERR("Eet: Eet_Node mempool creation failed"); + goto shutdown_mempool; + } + #ifdef HAVE_GNUTLS /* Before the library can be used, it must initialize itself if needed. */ if (gcry_control(GCRYCTL_ANY_INITIALIZATION_P) == 0) @@ -741,13 +616,15 @@ eet_init(void) shutdown_eet: #endif eet_node_shutdown(); +shutdown_mempool: + eet_mempool_shutdown(); unregister_log_domain: eina_log_domain_unregister(_eet_log_dom_global); _eet_log_dom_global = -1; shutdown_eina: eina_shutdown(); return --eet_init_count; -} /* eet_init */ +} EAPI int eet_shutdown(void) @@ -757,6 +634,7 @@ eet_shutdown(void) eet_clearcache(); eet_node_shutdown(); + eet_mempool_shutdown(); eina_lock_free(&eet_cache_lock); @@ -772,7 +650,7 @@ eet_shutdown(void) eina_shutdown(); return eet_init_count; -} /* eet_shutdown */ +} EAPI Eet_Error eet_sync(Eet_File *ef) @@ -795,7 +673,7 @@ eet_sync(Eet_File *ef) UNLOCK_FILE(ef); return ret; -} /* eet_sync */ +} EAPI void eet_clearcache(void) @@ -853,7 +731,7 @@ eet_clearcache(void) } UNLOCK_CACHE; -} /* eet_clearcache */ +} /* FIXME: MMAP race condition in READ_WRITE_MODE */ static Eet_File * @@ -902,14 +780,14 @@ eet_internal_read2(Eet_File *ef) return NULL; /* allocate header */ - ef->header = calloc(1, sizeof(Eet_File_Header)); + ef->header = eet_file_header_calloc(1); if (eet_test_close(!ef->header, ef)) return NULL; ef->header->magic = EET_MAGIC_FILE_HEADER; /* allocate directory block in ram */ - ef->header->directory = calloc(1, sizeof(Eet_File_Directory)); + ef->header->directory = eet_file_directory_calloc(1); if (eet_test_close(!ef->header->directory, ef)) return NULL; @@ -939,10 +817,10 @@ eet_internal_read2(Eet_File *ef) /* out directory block is inconsistent - we have overrun our */ /* dynamic block buffer before we finished scanning dir entries */ - efn = malloc(sizeof(Eet_File_Node)); + efn = eet_file_node_malloc(1); if (eet_test_close(!efn, ef)) { - if (efn) free(efn); /* yes i know - we only get here if + if (efn) eet_file_node_mp_free(efn); /* yes i know - we only get here if * efn is null/0 -> trying to shut up * warning tools like cppcheck */ return NULL; @@ -963,7 +841,7 @@ eet_internal_read2(Eet_File *ef) #define EFN_TEST(Test, Ef, Efn) \ if (eet_test_close(Test, Ef)) \ { \ - free(Efn); \ + eet_file_node_mp_free(Efn); \ return NULL; \ } @@ -1022,11 +900,11 @@ eet_internal_read2(Eet_File *ef) ef)) return NULL; - ef->ed = calloc(1, sizeof (Eet_Dictionary)); + ef->ed = eet_dictionary_calloc(1); if (eet_test_close(!ef->ed, ef)) return NULL; - ef->ed->all = calloc(num_dictionary_entries, sizeof (Eet_String)); + ef->ed->all = calloc(1, num_dictionary_entries * sizeof(Eet_String)); if (eet_test_close(!ef->ed->all, ef)) return NULL; @@ -1112,7 +990,7 @@ eet_internal_read2(Eet_File *ef) } return ef; -} /* eet_internal_read2 */ +} #if EET_OLD_EET_FILE_FORMAT static Eet_File * @@ -1162,14 +1040,14 @@ eet_internal_read1(Eet_File *ef) return NULL; /* allocate header */ - ef->header = calloc(1, sizeof(Eet_File_Header)); + ef->header = eet_file_header_calloc(1); if (eet_test_close(!ef->header, ef)) return NULL; ef->header->magic = EET_MAGIC_FILE_HEADER; /* allocate directory block in ram */ - ef->header->directory = calloc(1, sizeof(Eet_File_Directory)); + ef->header->directory = eet_file_directory_calloc(1); if (eet_test_close(!ef->header->directory, ef)) return NULL; @@ -1204,10 +1082,10 @@ eet_internal_read1(Eet_File *ef) return NULL; /* allocate all the ram needed for this stored node accounting */ - efn = malloc (sizeof(Eet_File_Node)); + efn = eet_file_node_malloc(1); if (eet_test_close(!efn, ef)) { - if (efn) free(efn); /* yes i know - we only get here if + if (efn) eet_file_node_mp_free(efn); /* yes i know - we only get here if * efn is null/0 -> trying to shut up * warning tools like cppcheck */ return NULL; @@ -1227,21 +1105,21 @@ eet_internal_read1(Eet_File *ef) /* invalid size */ if (eet_test_close(efn->size <= 0, ef)) { - free(efn); + eet_file_node_mp_free(efn); return NULL; } /* invalid name_size */ if (eet_test_close(name_size <= 0, ef)) { - free(efn); + eet_file_node_mp_free(efn); return NULL; } /* reading name would mean falling off end of dyn_buf - invalid */ if (eet_test_close((p + 16 + name_size) > (dyn_buf + byte_entries), ef)) { - free(efn); + eet_file_node_mp_free(efn); return NULL; } @@ -1257,7 +1135,7 @@ eet_internal_read1(Eet_File *ef) efn->name = malloc(sizeof(char) * name_size + 1); if (eet_test_close(!efn->name, ef)) { - free(efn); + eet_file_node_mp_free(efn); return NULL; } @@ -1294,7 +1172,7 @@ eet_internal_read1(Eet_File *ef) p += HEADER_SIZE + name_size; } return ef; -} /* eet_internal_read1 */ +} #endif /* if EET_OLD_EET_FILE_FORMAT */ @@ -1329,10 +1207,10 @@ eet_internal_read(Eet_File *ef) ef->delete_me_now = 1; eet_internal_close(ef, EINA_TRUE); break; - } /* switch */ + } return NULL; -} /* eet_internal_read */ +} static Eet_Error eet_internal_close(Eet_File *ef, @@ -1405,16 +1283,16 @@ eet_internal_close(Eet_File *ef, if (efn->free_name) free(efn->name); - free(efn); + eet_file_node_mp_free(efn); } } free(ef->header->directory->nodes); } - free(ef->header->directory); + eet_file_directory_mp_free(ef->header->directory); } - free(ef->header); + eet_file_header_mp_free(ef->header); } eet_dictionary_free(ef->ed); @@ -1434,7 +1312,8 @@ eet_internal_close(Eet_File *ef, memset(ef, 0, sizeof(Eet_File)); /* free it */ - free(ef); + eina_stringshare_del(ef->path); + eet_file_mp_free(ef); return err; on_error: @@ -1442,7 +1321,7 @@ on_error: UNLOCK_CACHE; return EET_ERROR_NONE; -} /* eet_internal_close */ +} EAPI Eet_File * eet_memopen_read(const void *data, @@ -1453,7 +1332,7 @@ eet_memopen_read(const void *data, if (!data || size == 0) return NULL; - ef = malloc (sizeof (Eet_File)); + ef = eet_file_malloc(1); if (!ef) return NULL; @@ -1477,7 +1356,14 @@ eet_memopen_read(const void *data, ef = eet_internal_read(ef); UNLOCK_CACHE; return ef; -} /* eet_memopen_read */ +} + +EAPI const char * +eet_file_get(Eet_File *ef) +{ + if (eet_check_pointer(ef)) return NULL; + return ef->path; +} EAPI Eet_File * eet_open(const char *file, @@ -1578,7 +1464,7 @@ open_error: file_len = strlen(file) + 1; /* Allocate struct for eet file and have it zero'd out */ - ef = malloc(sizeof(Eet_File) + file_len); + ef = eet_file_malloc(1); if (!ef) goto on_error; @@ -1586,8 +1472,7 @@ open_error: INIT_FILE(ef); ef->key = NULL; ef->readfp = fp; - ef->path = ((char *)ef) + sizeof(Eet_File); - memcpy(ef->path, file, file_len); + ef->path = eina_stringshare_add_length(file, file_len); ef->magic = EET_MAGIC_FILE; ef->references = 1; ef->mode = mode; @@ -1641,7 +1526,7 @@ empty_file: on_error: UNLOCK_CACHE; return NULL; -} /* eet_open */ +} EAPI Eet_File_Mode eet_mode_get(Eet_File *ef) @@ -1651,7 +1536,7 @@ eet_mode_get(Eet_File *ef) return EET_FILE_MODE_INVALID; else return ef->mode; -} /* eet_mode_get */ +} EAPI const void * eet_identity_x509(Eet_File *ef, @@ -1664,7 +1549,7 @@ eet_identity_x509(Eet_File *ef, *der_length = ef->x509_length; return ef->x509_der; -} /* eet_identity_x509 */ +} EAPI const void * eet_identity_signature(Eet_File *ef, @@ -1677,7 +1562,7 @@ eet_identity_signature(Eet_File *ef, *signature_length = ef->signature_length; return ef->signature; -} /* eet_identity_signature */ +} EAPI const void * eet_identity_sha1(Eet_File *ef, @@ -1692,7 +1577,7 @@ eet_identity_sha1(Eet_File *ef, *sha1_length = ef->sha1_length; return ef->sha1; -} /* eet_identity_sha1 */ +} EAPI Eet_Error eet_identity_set(Eet_File *ef, @@ -1712,13 +1597,13 @@ eet_identity_set(Eet_File *ef, ef->writes_pending = 1; return EET_ERROR_NONE; -} /* eet_identity_set */ +} EAPI Eet_Error eet_close(Eet_File *ef) { return eet_internal_close(ef, EINA_FALSE); -} /* eet_close */ +} EAPI void * eet_read_cipher(Eet_File *ef, @@ -1889,7 +1774,7 @@ on_error: UNLOCK_FILE(ef); free(data); return NULL; -} /* eet_read_cipher */ +} EAPI void * eet_read(Eet_File *ef, @@ -1897,7 +1782,7 @@ eet_read(Eet_File *ef, int *size_ret) { return eet_read_cipher(ef, name, size_ret, NULL); -} /* eet_read */ +} EAPI const void * eet_read_direct(Eet_File *ef, @@ -1995,7 +1880,7 @@ eet_read_direct(Eet_File *ef, on_error: UNLOCK_FILE(ef); return NULL; -} /* eet_read_direct */ +} EAPI const char * eet_alias_get(Eet_File *ef, @@ -2102,16 +1987,16 @@ eet_alias(Eet_File *ef, if (!ef->header) { /* allocate header */ - ef->header = calloc(1, sizeof(Eet_File_Header)); + ef->header = eet_file_header_calloc(1); if (!ef->header) goto on_error; ef->header->magic = EET_MAGIC_FILE_HEADER; /* allocate directory block in ram */ - ef->header->directory = calloc(1, sizeof(Eet_File_Directory)); + ef->header->directory = eet_file_directory_calloc(1); if (!ef->header->directory) { - free(ef->header); + eet_file_header_mp_free(ef->header); ef->header = NULL; goto on_error; } @@ -2124,7 +2009,7 @@ eet_alias(Eet_File *ef, (1 << ef->header->directory->size)); if (!ef->header->directory->nodes) { - free(ef->header->directory); + eet_file_directory_mp_free(ef->header->directory); ef->header = NULL; goto on_error; } @@ -2198,7 +2083,7 @@ eet_alias(Eet_File *ef, } if (!exists_already) { - efn = malloc(sizeof(Eet_File_Node)); + efn = eet_file_node_malloc(1); if (!efn) { free(data2); @@ -2230,7 +2115,7 @@ eet_alias(Eet_File *ef, on_error: UNLOCK_FILE(ef); return EINA_FALSE; -} /* eet_alias */ +} EAPI int eet_write_cipher(Eet_File *ef, @@ -2262,16 +2147,16 @@ eet_write_cipher(Eet_File *ef, if (!ef->header) { /* allocate header */ - ef->header = calloc(1, sizeof(Eet_File_Header)); + ef->header = eet_file_header_calloc(1); if (!ef->header) goto on_error; ef->header->magic = EET_MAGIC_FILE_HEADER; /* allocate directory block in ram */ - ef->header->directory = calloc(1, sizeof(Eet_File_Directory)); + ef->header->directory = eet_file_directory_calloc(1); if (!ef->header->directory) { - free(ef->header); + eet_file_header_mp_free(ef->header); ef->header = NULL; goto on_error; } @@ -2284,7 +2169,7 @@ eet_write_cipher(Eet_File *ef, (1 << ef->header->directory->size)); if (!ef->header->directory->nodes) { - free(ef->header->directory); + eet_file_directory_mp_free(ef->header->directory); ef->header = NULL; goto on_error; } @@ -2382,7 +2267,7 @@ eet_write_cipher(Eet_File *ef, } if (!exists_already) { - efn = malloc(sizeof(Eet_File_Node)); + efn = eet_file_node_malloc(1); if (!efn) { free(data2); @@ -2413,7 +2298,7 @@ eet_write_cipher(Eet_File *ef, on_error: UNLOCK_FILE(ef); return 0; -} /* eet_write_cipher */ +} EAPI int eet_write(Eet_File *ef, @@ -2423,7 +2308,7 @@ eet_write(Eet_File *ef, int comp) { return eet_write_cipher(ef, name, data, size, comp, NULL); -} /* eet_write */ +} EAPI int eet_delete(Eet_File *ef, @@ -2472,7 +2357,7 @@ eet_delete(Eet_File *ef, if (efn->free_name) free(efn->name); - free(efn); + eet_file_node_mp_free(efn); exists_already = 1; break; } @@ -2485,7 +2370,7 @@ eet_delete(Eet_File *ef, /* update access time */ return exists_already; -} /* eet_delete */ +} EAPI Eet_Dictionary * eet_dictionary_get(Eet_File *ef) @@ -2494,7 +2379,7 @@ eet_dictionary_get(Eet_File *ef) return NULL; return ef->ed; -} /* eet_dictionary_get */ +} EAPI char ** eet_list(Eet_File *ef, @@ -2578,7 +2463,7 @@ on_error: *count_ret = 0; return NULL; -} /* eet_list */ +} EAPI int eet_num_entries(Eet_File *ef) @@ -2605,7 +2490,7 @@ eet_num_entries(Eet_File *ef) UNLOCK_FILE(ef); return ret; -} /* eet_num_entries */ +} static Eet_File_Node * find_node_by_name(Eet_File *ef, @@ -2624,7 +2509,7 @@ find_node_by_name(Eet_File *ef, } return NULL; -} /* find_node_by_name */ +} static int read_data_from_disk(Eet_File *ef, @@ -2644,5 +2529,5 @@ read_data_from_disk(Eet_File *ef, memcpy(buf, ef->data + efn->offset, len); return len; -} /* read_data_from_disk */ +} diff --git a/libraries/eet/src/lib/eet_node.c b/libraries/eet/src/lib/eet_node.c index d90ef83..11d7cc0 100644 --- a/libraries/eet/src/lib/eet_node.c +++ b/libraries/eet/src/lib/eet_node.c @@ -27,13 +27,13 @@ eet_node_new(void) memset(result, 0, sizeof (Eet_Node)); return result; -} /* eet_node_new */ +} void eet_node_free(Eet_Node *node) { eina_mempool_free(_eet_node_mp, node); -} /* eet_node_free */ +} static Eet_Node * _eet_node_new(const char *name, @@ -49,7 +49,7 @@ _eet_node_new(const char *name, n->name = eina_stringshare_add(name); return n; -} /* _eet_node_new */ +} static void _eet_node_append(Eet_Node *n, @@ -63,7 +63,7 @@ _eet_node_append(Eet_Node *n, value->next = n->values; n->values = value; } -} /* _eet_node_append */ +} #define EET_NODE_NEW(Eet_type, Name, Value, Type) \ EAPI Eet_Node * \ @@ -133,7 +133,7 @@ eet_node_list_new(const char *name, _eet_node_append(n, nodes); return n; -} /* eet_node_list_new */ +} Eet_Node * eet_node_array_new(const char *name, @@ -151,7 +151,7 @@ eet_node_array_new(const char *name, _eet_node_append(n, nodes); return n; -} /* eet_node_array_new */ +} Eet_Node * eet_node_var_array_new(const char *name, @@ -168,7 +168,7 @@ eet_node_var_array_new(const char *name, _eet_node_append(n, nodes); return n; -} /* eet_node_var_array_new */ +} Eet_Node * eet_node_hash_new(const char *name, @@ -191,7 +191,7 @@ eet_node_hash_new(const char *name, _eet_node_append(n, nodes); return n; -} /* eet_node_hash_new */ +} Eet_Node * eet_node_struct_new(const char *name, @@ -206,7 +206,7 @@ eet_node_struct_new(const char *name, _eet_node_append(n, nodes); return n; -} /* eet_node_struct_new */ +} Eet_Node * eet_node_struct_child_new(const char *parent, @@ -226,7 +226,7 @@ eet_node_struct_child_new(const char *parent, _eet_node_append(n, eina_list_prepend(NULL, child)); return n; -} /* eet_node_struct_child_new */ +} Eet_Node * eet_node_children_get(Eet_Node *node) @@ -289,7 +289,7 @@ eet_node_list_append(Eet_Node *parent, parent->values = nn; eina_stringshare_del(tmp); -} /* eet_node_list_append */ +} void eet_node_struct_append(Eet_Node *parent, @@ -338,7 +338,7 @@ eet_node_struct_append(Eet_Node *parent, } eina_stringshare_del(tmp); -} /* eet_node_struct_append */ +} void eet_node_hash_add(Eet_Node *parent, @@ -356,7 +356,7 @@ eet_node_hash_add(Eet_Node *parent, /* And add it to the parent. */ nn->next = parent->values; parent->values = nn; -} /* eet_node_hash_add */ +} int eet_node_type_get(Eet_Node *node) @@ -420,11 +420,11 @@ eet_node_del(Eet_Node *n) case EET_T_USHORT: case EET_T_UINT: break; - } /* switch */ + } eina_stringshare_del(n->name); eet_node_free(n); -} /* eet_node_del */ +} static const char *eet_node_dump_g_name[6] = { "struct", @@ -458,7 +458,7 @@ eet_node_dump_level(int level, int i; for (i = 0; i < level; i++) dumpfunc(dumpdata, " "); -} /* eet_node_dump_level */ +} static char * eet_node_string_escape(const char *str) @@ -499,7 +499,7 @@ eet_node_string_escape(const char *str) } *sp = 0; return s; -} /* eet_node_string_escape */ +} static void eet_node_dump_string_escape(void *dumpdata, @@ -514,7 +514,7 @@ eet_node_dump_string_escape(void *dumpdata, dumpfunc(dumpdata, s); free(s); -} /* eet_node_dump_string_escape */ +} static void eet_node_dump_simple_type(Eet_Node *n, @@ -578,10 +578,10 @@ case Eet_Type: \ default: dumpfunc(dumpdata, "???: ???"); break; - } /* switch */ + } dumpfunc(dumpdata, ";\n"); -} /* eet_node_dump_simple_type */ +} static void eet_node_dump_group_start(int level, @@ -602,7 +602,7 @@ eet_node_dump_group_start(int level, dumpfunc(dumpdata, eet_node_dump_g_name[chnk_type - EET_G_UNKNOWN]); dumpfunc(dumpdata, " {\n"); -} /* eet_node_dump_group_start */ +} static void eet_node_dump_group_end(int level, @@ -611,7 +611,7 @@ eet_node_dump_group_end(int level, { eet_node_dump_level(level, dumpfunc, dumpdata); dumpfunc(dumpdata, "}\n"); -} /* eet_node_dump_group_end */ +} void eet_node_dump(Eet_Node *n, @@ -676,8 +676,8 @@ eet_node_dump(Eet_Node *n, case EET_T_ULONG_LONG: eet_node_dump_simple_type(n, dumplevel, dumpfunc, dumpdata); break; - } /* switch */ -} /* eet_node_dump */ + } +} void * eet_node_walk(void *parent, @@ -759,13 +759,13 @@ eet_node_walk(void *parent, case EET_T_ULONG_LONG: me = cb->simple(root->type, &root->data, user_data); break; - } /* switch */ + } if (parent) cb->struct_add(parent, name, me, user_data); return me; -} /* eet_node_walk */ +} int eet_node_init(void) @@ -778,7 +778,7 @@ eet_node_init(void) #else choice = "chained_mempool"; #endif - tmp = getenv("EET_MEMPOOL"); + tmp = getenv("EINA_MEMPOOL"); if (tmp && tmp[0]) choice = tmp; @@ -786,12 +786,12 @@ eet_node_init(void) eina_mempool_add(choice, "eet-node-alloc", NULL, sizeof(Eet_Node), 1024); return _eet_node_mp ? 1 : 0; -} /* eet_node_init */ +} void eet_node_shutdown(void) { eina_mempool_del(_eet_node_mp); _eet_node_mp = NULL; -} /* eet_node_shutdown */ +} diff --git a/libraries/eet/src/lib/eet_utils.c b/libraries/eet/src/lib/eet_utils.c index 8e591a2..b04ad1b 100644 --- a/libraries/eet/src/lib/eet_utils.c +++ b/libraries/eet/src/lib/eet_utils.c @@ -32,5 +32,5 @@ _eet_hash_gen(const char *key, hash_num &= mask; /* return it */ return hash_num; -} /* _eet_hash_gen */ +} diff --git a/libraries/eet/src/tests/Makefile.am b/libraries/eet/src/tests/Makefile.am index c90a1d5..61158f7 100644 --- a/libraries/eet/src/tests/Makefile.am +++ b/libraries/eet/src/tests/Makefile.am @@ -2,6 +2,7 @@ MAINTAINERCLEANFILES = Makefile.in AM_CPPFLAGS = \ -I$(top_srcdir)/src/lib \ +-DTESTS_SRC_DIR=\"$(top_srcdir)/src/tests\" \ @CHECK_CFLAGS@ \ @EINA_CFLAGS@ diff --git a/libraries/eet/src/tests/Makefile.in b/libraries/eet/src/tests/Makefile.in index bb15127..791f9fd 100644 --- a/libraries/eet/src/tests/Makefile.in +++ b/libraries/eet/src/tests/Makefile.in @@ -174,8 +174,6 @@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ PKG_CONFIG = @PKG_CONFIG@ -PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ -PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ RANLIB = @RANLIB@ SED = @SED@ SET_MAKE = @SET_MAKE@ @@ -246,6 +244,7 @@ version_info = @version_info@ MAINTAINERCLEANFILES = Makefile.in AM_CPPFLAGS = \ -I$(top_srcdir)/src/lib \ +-DTESTS_SRC_DIR=\"$(top_srcdir)/src/tests\" \ @CHECK_CFLAGS@ \ @EINA_CFLAGS@ diff --git a/libraries/eet/src/tests/eet_suite.c b/libraries/eet/src/tests/eet_suite.c index 5230c86..3bbc912 100644 --- a/libraries/eet/src/tests/eet_suite.c +++ b/libraries/eet/src/tests/eet_suite.c @@ -24,6 +24,8 @@ #include "eet_suite.h" +#define CERT_DIR ((*TESTS_SRC_DIR == '/') ? TESTS_SRC_DIR : "src/tests/" TESTS_SRC_DIR) + START_TEST(eet_test_init) { int ret; @@ -211,21 +213,21 @@ _eet_test_basic_check(Eet_Test_Basic_Type *result, fail_if(result->empty != NULL); if (i == 0) { - Eet_Test_Basic_Type *tmp; - - tmp = result->with; - fail_if(tmp == NULL); - - fail_if(tmp->c != EET_TEST_CHAR); - fail_if(tmp->s != EET_TEST_SHORT); - fail_if(tmp->i != EET_TEST_INT + i + 1); - fail_if(tmp->l != (long long)EET_TEST_LONG_LONG); - fail_if(strcmp(tmp->str, EET_TEST_STRING) != 0); - fail_if(strcmp(tmp->istr, EET_TEST_STRING) != 0); - fail_if(tmp->uc != EET_TEST_CHAR); - fail_if(tmp->us != EET_TEST_SHORT); - fail_if(tmp->ui != EET_TEST_INT); - fail_if(tmp->ul != EET_TEST_LONG_LONG); + Eet_Test_Basic_Type *tmp2; + + tmp2 = result->with; + fail_if(tmp2 == NULL); + + fail_if(tmp2->c != EET_TEST_CHAR); + fail_if(tmp2->s != EET_TEST_SHORT); + fail_if(tmp2->i != EET_TEST_INT + i + 1); + fail_if(tmp2->l != (long long)EET_TEST_LONG_LONG); + fail_if(strcmp(tmp2->str, EET_TEST_STRING) != 0); + fail_if(strcmp(tmp2->istr, EET_TEST_STRING) != 0); + fail_if(tmp2->uc != EET_TEST_CHAR); + fail_if(tmp2->us != EET_TEST_SHORT); + fail_if(tmp2->ui != EET_TEST_INT); + fail_if(tmp2->ul != EET_TEST_LONG_LONG); } else fail_if(result->with != NULL); @@ -1640,7 +1642,7 @@ START_TEST(eet_identity_simple) eet_init(); fail_if(!(file = tmpnam(file))); - fail_if(chdir("src/tests")); + fail_if(chdir(CERT_DIR)); fail_if(!(noread = fopen("/dev/null", "w"))); /* Sign an eet file. */ @@ -1707,7 +1709,7 @@ START_TEST(eet_identity_open_simple) eet_init(); - fail_if(chdir("src/tests")); + fail_if(chdir(CERT_DIR)); k = eet_identity_open("cert.pem", "key.pem", NULL); fail_if(!k); @@ -1725,7 +1727,7 @@ START_TEST(eet_identity_open_pkcs8) eet_init(); - fail_if(chdir("src/tests")); + fail_if(chdir(CERT_DIR)); k = eet_identity_open("cert.pem", "key_enc_none.pem", NULL); fail_if(!k); @@ -1774,7 +1776,7 @@ START_TEST(eet_identity_open_pkcs8_enc) eet_init(); - fail_if(chdir("src/tests")); + fail_if(chdir(CERT_DIR)); k = eet_identity_open("cert.pem", "key_enc.pem", NULL); fail_if(k); @@ -1810,7 +1812,7 @@ START_TEST(eet_cipher_decipher_simple) eet_init(); fail_if(!(file = tmpnam(file))); - fail_if(chdir("src/tests")); + fail_if(chdir(CERT_DIR)); /* Crypt an eet file. */ ef = eet_open(file, EET_FILE_MODE_WRITE); -- cgit v1.1