From c963d75dfdeec11f82e79e727062fbf89afa2c04 Mon Sep 17 00:00:00 2001 From: David Walter Seikel Date: Sun, 22 Apr 2012 09:19:23 +1000 Subject: Update EFL to latest beta. --- libraries/eet/src/Makefile.in | 4 ++ libraries/eet/src/bin/Makefile.am | 2 +- libraries/eet/src/bin/Makefile.in | 6 ++- libraries/eet/src/bin/eet_main.c | 60 ++++++++++++++++++++++++++++ libraries/eet/src/examples/Makefile.in | 4 ++ libraries/eet/src/lib/Eet.h | 17 ++++++-- libraries/eet/src/lib/Makefile.in | 4 ++ libraries/eet/src/lib/eet_alloc.c | 2 +- libraries/eet/src/lib/eet_cipher.c | 71 +++++++++++++++++++++++++++------- libraries/eet/src/lib/eet_data.c | 21 ++-------- libraries/eet/src/lib/eet_dictionary.c | 6 +++ libraries/eet/src/lib/eet_image.c | 19 +++++---- libraries/eet/src/tests/Makefile.in | 4 ++ libraries/eet/src/tests/eet_suite.c | 2 +- 14 files changed, 178 insertions(+), 44 deletions(-) (limited to 'libraries/eet/src') diff --git a/libraries/eet/src/Makefile.in b/libraries/eet/src/Makefile.in index 8b2aa37..bfdc4f6 100644 --- a/libraries/eet/src/Makefile.in +++ b/libraries/eet/src/Makefile.in @@ -143,6 +143,8 @@ EINA_LIBS = @EINA_LIBS@ EVIL_CFLAGS = @EVIL_CFLAGS@ EVIL_LIBS = @EVIL_LIBS@ EXEEXT = @EXEEXT@ +EXOTIC_CFLAGS = @EXOTIC_CFLAGS@ +EXOTIC_LIBS = @EXOTIC_LIBS@ FGREP = @FGREP@ GNUTLS_CFLAGS = @GNUTLS_CFLAGS@ GNUTLS_LIBS = @GNUTLS_LIBS@ @@ -182,6 +184,8 @@ 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.am b/libraries/eet/src/bin/Makefile.am index ba7d67e..89c68f1 100644 --- a/libraries/eet/src/bin/Makefile.am +++ b/libraries/eet/src/bin/Makefile.am @@ -17,5 +17,5 @@ EXTRA_PROGRAMS = eet eet_SOURCES = eet_main.c eet_CFLAGS = @EET_CFLAGS@ -eet_LDADD = $(top_builddir)/src/lib/libeet.la @EINA_LIBS@ @EVIL_LIBS@ +eet_LDADD = $(top_builddir)/src/lib/libeet.la @EINA_LIBS@ @EVIL_LIBS@ @EXOTIC_LIBS@ eet_LDFLAGS = @lt_enable_auto_import@ diff --git a/libraries/eet/src/bin/Makefile.in b/libraries/eet/src/bin/Makefile.in index 4a899f5..a7e94cb 100644 --- a/libraries/eet/src/bin/Makefile.in +++ b/libraries/eet/src/bin/Makefile.in @@ -138,6 +138,8 @@ EINA_LIBS = @EINA_LIBS@ EVIL_CFLAGS = @EVIL_CFLAGS@ EVIL_LIBS = @EVIL_LIBS@ EXEEXT = @EXEEXT@ +EXOTIC_CFLAGS = @EXOTIC_CFLAGS@ +EXOTIC_LIBS = @EXOTIC_LIBS@ FGREP = @FGREP@ GNUTLS_CFLAGS = @GNUTLS_CFLAGS@ GNUTLS_LIBS = @GNUTLS_LIBS@ @@ -177,6 +179,8 @@ 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@ @@ -259,7 +263,7 @@ AM_CPPFLAGS = \ bin_PROGRAMS = @EET_PRG@ eet_SOURCES = eet_main.c eet_CFLAGS = @EET_CFLAGS@ -eet_LDADD = $(top_builddir)/src/lib/libeet.la @EINA_LIBS@ @EVIL_LIBS@ +eet_LDADD = $(top_builddir)/src/lib/libeet.la @EINA_LIBS@ @EVIL_LIBS@ @EXOTIC_LIBS@ eet_LDFLAGS = @lt_enable_auto_import@ all: all-am diff --git a/libraries/eet/src/bin/eet_main.c b/libraries/eet/src/bin/eet_main.c index 0d577ad..8a93d11 100644 --- a/libraries/eet/src/bin/eet_main.c +++ b/libraries/eet/src/bin/eet_main.c @@ -69,6 +69,63 @@ do_eet_list(const char *file) } /* do_eet_list */ static void +do_eet_stats(const char *file) +{ + int i, num; + int count[2] = { 0, 0 }; + int size[2] = { 0, 0 }; + char **list; + Eet_File *ef; + Eet_Dictionary *ed; + + ef = eet_open(file, EET_FILE_MODE_READ); + if (!ef) + { + ERR("cannot open for reading: %s", file); + exit(-1); + } + + printf("*** sections stats ***\n"); + list = eet_list(ef, "*", &num); + if (list) + { + for (i = 0; i < num; i++) + { + const void *ro = NULL; + void *rw = NULL; + int tsize; + + ro = eet_read_direct(ef, list[i], &tsize); + if (!ro) rw = eet_read(ef, list[i], &tsize); + printf(rw ? "%s of size %i is compressed.\n" : "%s of size %i is not compressed.\n", list[i], tsize); + count[rw ? 0 : 1]++; + size[rw ? 0 : 1] += tsize; + free(rw); + } + free(list); + } + + printf("*** dictionary ***\n"); + ed = eet_dictionary_get(ef); + if (ed) + { + printf("%i strings inside the dictionary.\n", eet_dictionary_count(ed)); + } + else + { + printf("no dictionary in this file.\n"); + } + printf("*** global ***\n"); + printf("%i sections\n", num); + printf("- %i of them are compressed (%02.2f%%) expanding in %i bytes.\n", + count[0], (float) count[0] * 100 / (float) num, size[0]); + printf("- %i of them are directly mappable in memory (%02.2f%%) representing %i bytes.\n", + count[1], (float) count[1] * 100 / (float) num, size[1]); + + eet_close(ef); +} + +static void do_eet_extract(const char *file, const char *key, const char *out, @@ -366,6 +423,7 @@ help: " eet -r FILE.EET KEY remove KEY in FILE.EET\n" " eet -c FILE.EET report and check the signature information of an eet file\n" " eet -s FILE.EET PRIVATE_KEY PUBLIC_KEY sign FILE.EET with PRIVATE_KEY and attach PUBLIC_KEY as it's certificate\n" + " eet -t FILE.EET give some statistic about a file\n" ); eet_shutdown(); return -1; @@ -437,6 +495,8 @@ help: do_eet_check(argv[2]); else if ((!strcmp(argv[1], "-s")) && (argc > 4)) do_eet_sign(argv[2], argv[3], argv[4]); + else if ((!strcmp(argv[1], "-t")) && (argc > 2)) + do_eet_stats(argv[2]); else goto help; diff --git a/libraries/eet/src/examples/Makefile.in b/libraries/eet/src/examples/Makefile.in index 5830132..1e979ab 100644 --- a/libraries/eet/src/examples/Makefile.in +++ b/libraries/eet/src/examples/Makefile.in @@ -226,6 +226,8 @@ EINA_LIBS = @EINA_LIBS@ EVIL_CFLAGS = @EVIL_CFLAGS@ EVIL_LIBS = @EVIL_LIBS@ EXEEXT = @EXEEXT@ +EXOTIC_CFLAGS = @EXOTIC_CFLAGS@ +EXOTIC_LIBS = @EXOTIC_LIBS@ FGREP = @FGREP@ GNUTLS_CFLAGS = @GNUTLS_CFLAGS@ GNUTLS_LIBS = @GNUTLS_LIBS@ @@ -265,6 +267,8 @@ 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/lib/Eet.h b/libraries/eet/src/lib/Eet.h index 2df7fbf..7495090 100644 --- a/libraries/eet/src/lib/Eet.h +++ b/libraries/eet/src/lib/Eet.h @@ -6,7 +6,7 @@ @mainpage Eet Library Documentation @version 1.5.0 - @date 2000-2011 + @date 2000-2012 Please see the @ref authors page for contact details. @@ -30,7 +30,7 @@ Eet is extremely fast, small and simple. Eet files can be very small and highly compressed, making them very optimal for just sending across the internet without having to archive, compress or decompress and install them. - They allow for lightning-fast random-acess reads once created, making them + They allow for lightning-fast random-access reads once created, making them perfect for storing data that is written once (or rarely) and read many times, but the program does not want to have to read it all in at once. @@ -577,7 +577,7 @@ EAPI Eet_File_Mode eet_mode_get(Eet_File *ef); /** - * Close an eet file handle and flush and writes pending. + * Close an eet file handle and flush pending writes. * @param ef A valid eet file handle. * * This function will flush any pending writes to disk if the eet file @@ -645,6 +645,17 @@ eet_dictionary_string_check(Eet_Dictionary *ed, const char *string); /** + * Return the number of strings inside a dictionary + * @param ed A valid dictionary handle + * @return the number of strings inside a dictionary + * + * @since 1.6.0 + * @ingroup Eet_File_Group + */ +EAPI int +eet_dictionary_count(const Eet_Dictionary *ed); + +/** * Read a specified entry from an eet file and return data * @param ef A valid eet file handle opened for reading. * @param name Name of the entry. eg: "/base/file_i_want". diff --git a/libraries/eet/src/lib/Makefile.in b/libraries/eet/src/lib/Makefile.in index 2a3fec0..c0367b3 100644 --- a/libraries/eet/src/lib/Makefile.in +++ b/libraries/eet/src/lib/Makefile.in @@ -172,6 +172,8 @@ EINA_LIBS = @EINA_LIBS@ EVIL_CFLAGS = @EVIL_CFLAGS@ EVIL_LIBS = @EVIL_LIBS@ EXEEXT = @EXEEXT@ +EXOTIC_CFLAGS = @EXOTIC_CFLAGS@ +EXOTIC_LIBS = @EXOTIC_LIBS@ FGREP = @FGREP@ GNUTLS_CFLAGS = @GNUTLS_CFLAGS@ GNUTLS_LIBS = @GNUTLS_LIBS@ @@ -211,6 +213,8 @@ 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/lib/eet_alloc.c b/libraries/eet/src/lib/eet_alloc.c index 85351ad..29e276c 100644 --- a/libraries/eet/src/lib/eet_alloc.c +++ b/libraries/eet/src/lib/eet_alloc.c @@ -3,6 +3,7 @@ #endif #include + #include "Eet.h" #include "Eet_private.h" @@ -90,4 +91,3 @@ eet_mempool_shutdown(void) mempool_array[i]->mp = NULL; } } - diff --git a/libraries/eet/src/lib/eet_cipher.c b/libraries/eet/src/lib/eet_cipher.c index 37a0899..2425e22 100644 --- a/libraries/eet/src/lib/eet_cipher.c +++ b/libraries/eet/src/lib/eet_cipher.c @@ -56,6 +56,9 @@ void *alloca(size_t); #ifdef HAVE_CIPHER # ifdef HAVE_GNUTLS +# if defined EET_USE_NEW_PUBKEY_VERIFY_HASH || defined EET_USE_NEW_PRIVKEY_SIGN_DATA +# include +# endif # include # include # else /* ifdef HAVE_GNUTLS */ @@ -497,6 +500,10 @@ eet_identity_sign(FILE *fp, gnutls_datum_t datum = { NULL, 0 }; size_t sign_len = 0; size_t cert_len = 0; +#ifdef EET_USE_NEW_PRIVKEY_SIGN_DATA + gnutls_datum_t signum = { NULL, 0 }; + gnutls_privkey_t privkey; +#endif # else /* ifdef HAVE_GNUTLS */ EVP_MD_CTX md_ctx; unsigned int sign_len = 0; @@ -528,6 +535,28 @@ eet_identity_sign(FILE *fp, datum.size = st_buf.st_size; /* Get the signature length */ +#ifdef EET_USE_NEW_PRIVKEY_SIGN_DATA + if (gnutls_privkey_init(&privkey) < 0) + { + err = EET_ERROR_SIGNATURE_FAILED; + goto on_error; + } + + if (gnutls_privkey_import_x509(privkey, key->private_key, 0) < 0) + { + err = EET_ERROR_SIGNATURE_FAILED; + goto on_error; + } + + if (gnutls_privkey_sign_data(privkey, GNUTLS_DIG_SHA1, 0, &datum, &signum) < 0) + { + err = EET_ERROR_SIGNATURE_FAILED; + goto on_error; + } + + sign = signum.data; + sign_len = signum.size; +#else if (gnutls_x509_privkey_sign_data(key->private_key, GNUTLS_DIG_SHA1, 0, &datum, sign, &sign_len) && !sign_len) @@ -550,6 +579,7 @@ eet_identity_sign(FILE *fp, goto on_error; } +#endif /* Get the certificate length */ if (gnutls_x509_crt_export(key->certificate, GNUTLS_X509_FMT_DER, cert, @@ -696,6 +726,10 @@ eet_identity_check(const void *data_base, gnutls_datum_t datum; gnutls_datum_t signature; # if EET_USE_NEW_GNUTLS_API +# if EET_USE_NEW_PUBKEY_VERIFY_HASH + gnutls_pubkey_t pubkey; + gnutls_digest_algorithm_t hash_algo; +# endif unsigned char *hash; gcry_md_hd_t md; int err; @@ -724,28 +758,32 @@ eet_identity_check(const void *data_base, hash = gcry_md_read(md, GCRY_MD_SHA1); if (!hash) - { - gcry_md_close(md); - return NULL; - } + goto on_error; datum.size = gcry_md_get_algo_dlen(GCRY_MD_SHA1); datum.data = hash; +# ifdef EET_USE_NEW_PUBKEY_VERIFY_HASH + if (gnutls_pubkey_init(&pubkey) < 0) + goto on_error; + + if (gnutls_pubkey_import_x509(pubkey, cert, 0) < 0) + goto on_error; + + if (gnutls_pubkey_get_verify_algorithm(pubkey, &signature, &hash_algo) < 0) + goto on_error; + + if (gnutls_pubkey_verify_hash(pubkey, 0, &datum, &signature) < 0) + goto on_error; +# else if (!gnutls_x509_crt_verify_hash(cert, 0, &datum, &signature)) - { - gcry_md_close(md); - return NULL; - } + goto on_error; +# endif if (sha1) { *sha1 = malloc(datum.size); - if (!*sha1) - { - gcry_md_close(md); - return NULL; - } + if (!*sha1) goto on_error; memcpy(*sha1, hash, datum.size); *sha1_length = datum.size; @@ -818,6 +856,13 @@ eet_identity_check(const void *data_base, *raw_signature_length = sign_len; return cert_der; +# ifdef HAVE_GNUTLS +# if EET_USE_NEW_GNUTLS_API + on_error: + gcry_md_close(md); + return NULL; +# endif +# endif #else /* ifdef HAVE_SIGNATURE */ data_base = NULL; data_length = 0; diff --git a/libraries/eet/src/lib/eet_data.c b/libraries/eet/src/lib/eet_data.c index 56b9ee0..d502f44 100644 --- a/libraries/eet/src/lib/eet_data.c +++ b/libraries/eet/src/lib/eet_data.c @@ -21,18 +21,6 @@ #include "Eet.h" #include "Eet_private.h" -#ifdef _WIN32 -# define FMT_CHAR "%c" -# define FMT_UCHAR "%c" -# define FMT_LONG_LONG "%I64i" -# define FMT_ULONG_LONG "%I64u" -#else -# define FMT_CHAR "%hhi" -# define FMT_UCHAR "%hhu" -# define FMT_LONG_LONG "%lli" -# define FMT_ULONG_LONG "%llu" -#endif - /* * routines for doing data -> struct and struct -> data conversion * @@ -3108,7 +3096,7 @@ _eet_data_dump_parse(Eet_Dictionary *ed, if (!strcmp(tok3, "char:")) { n->type = EET_T_CHAR; - sscanf(tok4, FMT_CHAR, + sscanf(tok4, "%hhi", &(n->data.value.c)); } else if (!strcmp(tok3, "short:")) @@ -3126,7 +3114,7 @@ _eet_data_dump_parse(Eet_Dictionary *ed, else if (!strcmp(tok3, "long_long:")) { n->type = EET_T_LONG_LONG; - sscanf(tok4, FMT_LONG_LONG, + sscanf(tok4, "%lli", &(n->data.value.l)); } else if (!strcmp(tok3, "float:")) @@ -3144,7 +3132,7 @@ _eet_data_dump_parse(Eet_Dictionary *ed, else if (!strcmp(tok3, "uchar:")) { n->type = EET_T_UCHAR; - sscanf(tok4, FMT_UCHAR, + sscanf(tok4, "%hhu", &(n->data.value.uc)); } else if (!strcmp(tok3, "ushort:")) @@ -3162,7 +3150,7 @@ _eet_data_dump_parse(Eet_Dictionary *ed, else if (!strcmp(tok3, "ulong_long:")) { n->type = EET_T_ULONG_LONG; - sscanf(tok4, FMT_ULONG_LONG, + sscanf(tok4, "%llu", &(n->data.value.ul)); } else if (!strcmp(tok3, "string:")) @@ -4996,4 +4984,3 @@ eet_data_xattr_cipher_set(const char *filename, return ret; } - diff --git a/libraries/eet/src/lib/eet_dictionary.c b/libraries/eet/src/lib/eet_dictionary.c index 287860d..c79239b 100644 --- a/libraries/eet/src/lib/eet_dictionary.c +++ b/libraries/eet/src/lib/eet_dictionary.c @@ -169,6 +169,12 @@ eet_dictionary_string_get_size(const Eet_Dictionary *ed, return 0; } +EAPI int +eet_dictionary_count(const Eet_Dictionary *ed) +{ + return ed->count; +} + int eet_dictionary_string_get_hash(const Eet_Dictionary *ed, int idx) diff --git a/libraries/eet/src/lib/eet_image.c b/libraries/eet/src/lib/eet_image.c index 8c6c03c..b622236 100644 --- a/libraries/eet/src/lib/eet_image.c +++ b/libraries/eet/src/lib/eet_image.c @@ -246,7 +246,7 @@ eet_data_image_jpeg_rgb_decode(const void *data, unsigned int w, unsigned int h, unsigned int row_stride); -static void * +static int eet_data_image_jpeg_alpha_decode(const void *data, int size, unsigned int src_x, @@ -560,7 +560,7 @@ eet_data_image_jpeg_rgb_decode(const void *data, return 1; } -static void * +static int eet_data_image_jpeg_alpha_decode(const void *data, int size, unsigned int src_x, @@ -577,6 +577,10 @@ eet_data_image_jpeg_alpha_decode(const void *data, unsigned int x, y, l, scans; unsigned int i, iw; + /* FIXME: handle src_x, src_y and row_stride correctly */ + if (!d) + return 0; + memset(&cinfo, 0, sizeof (struct jpeg_decompress_struct)); cinfo.err = jpeg_std_error(&(jerr.pub)); @@ -584,14 +588,14 @@ eet_data_image_jpeg_alpha_decode(const void *data, jerr.pub.emit_message = _JPEGErrorHandler2; jerr.pub.output_message = _JPEGErrorHandler; if (setjmp(jerr.setjmp_buffer)) - return NULL; + return 0; jpeg_create_decompress(&cinfo); if (eet_jpeg_membuf_src(&cinfo, data, (size_t)size)) { jpeg_destroy_decompress(&cinfo); - return NULL; + return 0; } jpeg_read_header(&cinfo, TRUE); @@ -609,7 +613,7 @@ eet_data_image_jpeg_alpha_decode(const void *data, cinfo.src = NULL; jpeg_destroy_decompress(&cinfo); - return NULL; + return 0; } /* end head decoding */ @@ -620,11 +624,12 @@ eet_data_image_jpeg_alpha_decode(const void *data, cinfo.src = NULL; jpeg_destroy_decompress(&cinfo); - return NULL; + return 0; } tdata = alloca(w * 16 * 3); ptr2 = d; + if (cinfo.output_components == 1) { for (i = 0; i < (unsigned int)cinfo.rec_outbuf_height; i++) @@ -666,7 +671,7 @@ eet_data_image_jpeg_alpha_decode(const void *data, /* end data decoding */ jpeg_finish_decompress(&cinfo); jpeg_destroy_decompress(&cinfo); - return d; + return 1; } static void * diff --git a/libraries/eet/src/tests/Makefile.in b/libraries/eet/src/tests/Makefile.in index 791f9fd..e17a54e 100644 --- a/libraries/eet/src/tests/Makefile.in +++ b/libraries/eet/src/tests/Makefile.in @@ -135,6 +135,8 @@ EINA_LIBS = @EINA_LIBS@ EVIL_CFLAGS = @EVIL_CFLAGS@ EVIL_LIBS = @EVIL_LIBS@ EXEEXT = @EXEEXT@ +EXOTIC_CFLAGS = @EXOTIC_CFLAGS@ +EXOTIC_LIBS = @EXOTIC_LIBS@ FGREP = @FGREP@ GNUTLS_CFLAGS = @GNUTLS_CFLAGS@ GNUTLS_LIBS = @GNUTLS_LIBS@ @@ -174,6 +176,8 @@ 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/tests/eet_suite.c b/libraries/eet/src/tests/eet_suite.c index 3bbc912..91ef2a7 100644 --- a/libraries/eet/src/tests/eet_suite.c +++ b/libraries/eet/src/tests/eet_suite.c @@ -1933,7 +1933,7 @@ START_TEST(eet_cache_concurrency) thread = _beginthreadex(NULL, 0, open_close_worker, file, 0, &thread_id); # endif /* ifdef _EET_INCLUDED_PTHREAD */ /* clear the cache repeatedly in this thread */ - for (n = 0; n < 50000; ++n) + for (n = 0; n < 20000; ++n) { eet_clearcache(); } -- cgit v1.1