* Improve Eet_Data to make decoding of EET_G_UNION and EET_G_*ARRAY
faster and less memory heavy.
+
+2011-05-14 Cedric BAIL
+
+ * Use Eina_Lock.
+ * Sync GNUTLS initialisation with Eina.
+
+2011-05-17 Cedric BAIL
+
+ * Use Eina_File.
+ * Fix test forgetting to initialize eet.
+
+2011-05-23 Vincent Torri
+
+ * Fix compilation with libjpeg 8 on Windows.
+
+2011-06-10 Cedric BAIL
+
+ * Add EET_DATA_DESCRIPTOR_ADD_LIST_STRING helper to define List of char *.
#!/bin/sh
touch README
+touch ABOUT-NLS
echo "Running aclocal..." ; aclocal $ACLOCAL_FLAGS -I m4 || exit 1
echo "Running autoheader..." ; autoheader || exit 1
echo "Running libtoolize..." ; (libtoolize --copy --automake || glibtoolize --automake) || exit 1
echo "Running automake..." ; automake --add-missing --copy --gnu || exit 1
+W=0
+
+rm -f config.cache-env.tmp
+echo "OLD_PARM=\"$@\"" >> config.cache-env.tmp
+echo "OLD_CFLAGS=\"$CFLAGS\"" >> config.cache-env.tmp
+echo "OLD_PATH=\"$PATH\"" >> config.cache-env.tmp
+echo "OLD_PKG_CONFIG_PATH=\"$PKG_CONFIG_PATH\"" >> config.cache-env.tmp
+echo "OLD_LDFLAGS=\"$LDFLAGS\"" >> config.cache-env.tmp
+
+cmp config.cache-env.tmp config.cache-env >> /dev/null
+if [ $? -ne 0 ]; then
+ W=1;
+fi
+
+if [ $W -ne 0 ]; then
+ echo "Cleaning configure cache...";
+ rm -f config.cache config.cache-env
+ mv config.cache-env.tmp config.cache-env
+else
+ rm -f config.cache-env.tmp
+fi
+
if [ -z "$NOCONFIGURE" ]; then
./configure -C "$@"
fi
AC_MSG_CHECKING(whether to activate signature support in eet)
AC_MSG_RESULT(${have_signature})
-# pthread library
-
-EFL_CHECK_THREADS(["no"],
- [
- if test "x${_efl_have_posix_threads}" = "xyes" ; then
- have_threads="POSIX"
- else
- if test "x${_efl_have_win32_threads}" = "xyes" ; then
- have_threads="Win32"
- else
- have_threads="no"
- fi
- fi],
- [have_threads="no"])
-
-
### Checks for header files
AC_CHECK_HEADER([zlib.h],
[dummy="yes"],
[AC_MSG_ERROR("Cannot find jpeglib.h. Make sure your CFLAGS environment variable contains include lines for the location of this file")])
-AC_CHECK_HEADERS(netinet/in.h)
+AC_CHECK_HEADERS(netinet/in.h unistd.h)
EFL_CHECK_PATH_MAX
### Checks for types
Makefile
eet.pc
doc/Makefile
+doc/Doxyfile
doc/eet.dox
src/Makefile
src/lib/Makefile
echo " Cipher support.....: ${have_cipher}"
echo " Signature..........: ${have_signature}"
fi
-echo " Thread Support.......: ${have_threads}"
echo
echo " Old eet file format..: ${old_eet_file_format}"
echo
--- /dev/null
+PROJECT_NAME = Eet
+PROJECT_NUMBER = @PACKAGE_VERSION@
+OUTPUT_DIRECTORY = .
+INPUT = @srcdir@/eet.dox @srcdir@/examples.dox @srcdir@/src/lib
+IMAGE_PATH = img
+OUTPUT_LANGUAGE = English
+GENERATE_HTML = YES
+HTML_OUTPUT = html
+HTML_FILE_EXTENSION = .html
+HTML_HEADER = @srcdir@/head.html
+HTML_FOOTER = @srcdir@/foot.html
+HTML_STYLESHEET = @srcdir@/e.css
+HTML_ALIGN_MEMBERS = YES
+ENUM_VALUES_PER_LINE = 1
+GENERATE_HTMLHELP = NO
+CHM_FILE =
+HHC_LOCATION =
+GENERATE_CHI = NO
+BINARY_TOC = NO
+TOC_EXPAND = NO
+DISABLE_INDEX = YES
+EXTRACT_ALL = NO
+EXTRACT_PRIVATE = NO
+EXTRACT_STATIC = NO
+EXTRACT_LOCAL_CLASSES = NO
+HIDE_UNDOC_MEMBERS = YES
+HIDE_UNDOC_CLASSES = YES
+HIDE_FRIEND_COMPOUNDS = YES
+BRIEF_MEMBER_DESC = YES
+REPEAT_BRIEF = YES
+ALWAYS_DETAILED_SEC = NO
+INLINE_INHERITED_MEMB = NO
+FULL_PATH_NAMES = NO
+STRIP_FROM_PATH =
+INTERNAL_DOCS = NO
+STRIP_CODE_COMMENTS = NO
+CASE_SENSE_NAMES = YES
+SHORT_NAMES = NO
+HIDE_SCOPE_NAMES = NO
+VERBATIM_HEADERS = NO
+SHOW_INCLUDE_FILES = NO
+JAVADOC_AUTOBRIEF = YES
+MULTILINE_CPP_IS_BRIEF = NO
+DETAILS_AT_TOP = NO
+INHERIT_DOCS = YES
+INLINE_INFO = YES
+SORT_MEMBER_DOCS = YES
+DISTRIBUTE_GROUP_DOC = NO
+TAB_SIZE = 8
+GENERATE_TODOLIST = YES
+GENERATE_TESTLIST = YES
+GENERATE_BUGLIST = YES
+GENERATE_DEPRECATEDLIST= YES
+ALIASES =
+ENABLED_SECTIONS =
+MAX_INITIALIZER_LINES = 30
+OPTIMIZE_OUTPUT_FOR_C = YES
+OPTIMIZE_OUTPUT_JAVA = NO
+SHOW_USED_FILES = NO
+QUIET = NO
+WARNINGS = YES
+WARN_IF_UNDOCUMENTED = YES
+WARN_FORMAT = "$file:$line: $text"
+WARN_LOGFILE =
+FILE_PATTERNS =
+RECURSIVE = NO
+EXCLUDE =
+EXCLUDE_SYMLINKS = NO
+EXCLUDE_PATTERNS =
+EXAMPLE_PATH = @top_srcdir@/src/examples/
+EXAMPLE_PATTERNS =
+EXAMPLE_RECURSIVE = NO
+INPUT_FILTER =
+FILTER_SOURCE_FILES = NO
+SOURCE_BROWSER = NO
+INLINE_SOURCES = NO
+REFERENCED_BY_RELATION = YES
+REFERENCES_RELATION = YES
+ALPHABETICAL_INDEX = YES
+COLS_IN_ALPHA_INDEX = 2
+IGNORE_PREFIX = eet_ _eet_ Eet_ _Eet_ EET_ _EET_
+GENERATE_TREEVIEW = NO
+TREEVIEW_WIDTH = 250
+GENERATE_LATEX = YES
+LATEX_OUTPUT = latex
+LATEX_CMD_NAME = latex
+MAKEINDEX_CMD_NAME = makeindex
+COMPACT_LATEX = NO
+PAPER_TYPE = a4wide
+EXTRA_PACKAGES =
+LATEX_HEADER =
+PDF_HYPERLINKS = YES
+USE_PDFLATEX = NO
+LATEX_BATCHMODE = NO
+GENERATE_RTF = NO
+RTF_OUTPUT = rtf
+COMPACT_RTF = NO
+RTF_HYPERLINKS = NO
+RTF_STYLESHEET_FILE =
+RTF_EXTENSIONS_FILE =
+GENERATE_MAN = YES
+MAN_OUTPUT = man
+MAN_EXTENSION = .3
+MAN_LINKS = YES
+GENERATE_XML = NO
+XML_SCHEMA =
+XML_DTD =
+GENERATE_AUTOGEN_DEF = NO
+ENABLE_PREPROCESSING = YES
+MACRO_EXPANSION = NO
+EXPAND_ONLY_PREDEF = NO
+SEARCH_INCLUDES = NO
+INCLUDE_PATH =
+INCLUDE_FILE_PATTERNS =
+PREDEFINED =
+EXPAND_AS_DEFINED =
+SKIP_FUNCTION_MACROS = YES
+TAGFILES =
+GENERATE_TAGFILE =
+ALLEXTERNALS = NO
+EXTERNAL_GROUPS = YES
+PERL_PATH = /usr/bin/perl
+CLASS_DIAGRAMS = NO
+HIDE_UNDOC_RELATIONS = YES
+HAVE_DOT = NO
+CLASS_GRAPH = NO
+COLLABORATION_GRAPH = NO
+TEMPLATE_RELATIONS = NO
+INCLUDE_GRAPH = NO
+INCLUDED_BY_GRAPH = NO
+GRAPHICAL_HIERARCHY = NO
+DOT_IMAGE_FORMAT = png
+DOT_PATH =
+DOTFILE_DIRS =
+MAX_DOT_GRAPH_WIDTH = 512
+MAX_DOT_GRAPH_HEIGHT = 512
+GENERATE_LEGEND = YES
+DOT_CLEANUP = YES
+SEARCHENGINE = NO
doc: doc-clean
$(efl_doxygen)
- cp img/* html/
+ cp $(srcdir)/img/* html/
rm -rf $(PACKAGE_DOCNAME).tar*
mkdir -p $(PACKAGE_DOCNAME)/doc
cp -R html/ latex/ man/ $(PACKAGE_DOCNAME)/doc
tar cf $(PACKAGE_DOCNAME).tar $(PACKAGE_DOCNAME)/
bzip2 -9 $(PACKAGE_DOCNAME).tar
rm -rf $(PACKAGE_DOCNAME)/
- mv $(PACKAGE_DOCNAME).tar.bz2 $(top_srcdir)
+ mv $(PACKAGE_DOCNAME).tar.bz2 $(top_builddir)
clean-local: doc-clean
endif
-EXTRA_DIST = Doxyfile e.css foot.html head.html $(wildcard img/*.*) eet.dox.in
+EXTRA_DIST = $(srcdir)/Doxyfile \
+ $(srcdir)/e.css \
+ $(srcdir)/foot.html \
+ $(srcdir)/head.html \
+ $(srcdir)/$(wildcard $(srcdir)/img/*.*) \
+ $(srcdir)/eet.dox.in
-/**
-@file eet.dox
-@brief Eet Data Handling Library Public API Calls
-
-These routines are used for Eet Library interaction
-*/
-
-/**
-
-@mainpage Eet Library Documentation
-
-@image html e_big.png
-
-@version @PACKAGE_VERSION@
-@author Carsten Haitzler <raster@@rasterman.com>
-@author David Goodlad <dgoodlad@@gmail.com>
-@author Cedric Bail <cedric.bail@@free.fr>
-@author Arnaud de Turckheim <quarium@@gmail.com>
-@author Luis Felipe Strano Moraes <lfelipe@@profusion.mobi>
-@author Chidambar Zinnoury <illogict@@online.fr>
-@author Vincent Torri <vtorri@@univ-evry.fr>
-@author Gustavo Sverzut Barbieri <barbieri@@profusion.mobi>
-@author Raphael Kubo da Costa <kubo@@profusion.mobi>
-@author Mathieu Taillefumier <mathieu.taillefumier@@free.fr>
-@author Albin "Lutin" Tonnerre <albin.tonnerre@@gmail.com>
-@author Adam Simpkins <adam@@adamsimpkins.net>
-@date 2000-2011
-
-@section toc Table of Contents
-
-@li @ref intro
-@li @ref example
-@li @ref format
-@li @ref compiling
-@li @ref install
-@li @ref next_steps
-@li @ref intro_example
-
-@section intro What is Eet?
-
-It is a tiny library designed to write an arbitrary set of chunks of data
-to a file and optionally compress each chunk (very much like a zip file)
-and allow fast random-access reading of the file later on. It does not
-do zip as a zip itself has more complexity than is needed, and it was much
-simpler to implement this once here.
-
-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
-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.
-
-It also can encode and decode data structures in memory, as well as image
-data for saving to Eet files or sending across the network to other
-machines, or just writing to arbitrary files on the system. All data is
-encoded in a platform independent way and can be written and read by any
-architecture.
-
-@section example A simple example on using Eet
-
-Here is a simple example on how to use Eet to save a series of strings to a
-file and load them again. The advantage of using Eet over just fprintf() and
-fscanf() is that not only can these entries be strings, they need no special
-parsing to handle delimiter characters or escaping, they can be binary data,
-image data, data structures containing integers, strings, other data
-structures, linked lists and much more, without the programmer having to
-worry about parsing, and best of all, Eet is very fast.
-
-@code
-#include <Eet.h>
-
-int
-main(int argc, char **argv)
-{
- Eet_File *ef;
- int i;
- char buf[32];
- char *ret;
- int size;
- char *entries[] =
- {
- "Entry 1",
- "Big text string here compared to others",
- "Eet is cool"
- };
-
- eet_init();
-
- // blindly open an file for output and write strings with their NUL char
- ef = eet_open("test.eet", EET_FILE_MODE_WRITE);
- eet_write(ef, "Entry 1", entries[0], strlen(entries[0]) + 1, 0);
- eet_write(ef, "Entry 2", entries[1], strlen(entries[1]) + 1, 1);
- eet_write(ef, "Entry 3", entries[2], strlen(entries[2]) + 1, 0);
- eet_close(ef);
-
- // open the file again and blindly get the entries we wrote
- ef = eet_open("test.eet", EET_FILE_MODE_READ);
- ret = eet_read(ef, "Entry 1", &size);
- printf("%s\n", ret);
- ret = eet_read(ef, "Entry 2", &size);
- printf("%s\n", ret);
- ret = eet_read(ef, "Entry 3", &size);
- printf("%s\n", ret);
- eet_close(ef);
-
- eet_shutdown();
-}
-@endcode
-
-@section format What does an Eet file look like?
-
-The file format is very simple. There is a directory block at the start of
-the file listing entries and offsets into the file where they are stored,
-their sizes, compression flags etc. followed by all the entry data strung one
-element after the other.
-
-All Eet files start with t a 4 byte magic number. It is written using network
-byte-order (big endian, or from most significant byte first to least
-significant byte last) and is 0x1ee7ff00 (or byte by byte 0:1e 1:e7 2:ff
-3:00). The next 4 bytes are an integer (in big endian notation) indicating
-how many entries are stored in the Eet file. 0 indicates it is empty. This is
-a signed integer and thus values less than 0 are invalid, limiting the number
-of entries in an Eet file to 0x7fffffff entries at most. The next 4 bytes is
-the size of the directory table, in bytes, encoded in big-endian format. This
-is a signed integer and cannot be less than 0.
-
-The directory table for the file follows immediately, with a continuous list
-of all entries in the Eet file, their offset in the file etc. The order of
-these entries is not important, but convention would have them be from first
-to last entry in the file. Each directory entry consiste of 5 integers, one
-after the other, each stored as a signed, big endian integer. The first is
-the offset in the file that the data for this entry is stored at (based from
-the very start of the file, not relative to the end of the directory block).
-The second integer holds flags for the entry. currently only the least
-significant bit (bit 0) holds any useful information, and it is set to 1 if
-the entry is compressed using zlib compression calls, or 0 if it is not
-compressed. The next integer is the size of the entry in bytes stored in the
-file. The next integer is the size of the data when decompressed (if it was
-compressed) in bytes. This may be the same as the previous integer if the
-entry was not compressed. The final integer is the number of bytes used by
-the string identifier for the entry, without the NUL byte terminator, which
-is not stored. The next series of bytes is the string name of the entry, with
-the number of bytes being the same as specified in the last integer above.
-This list of entries continues until there are no more entries left to list.
-To read an entry from an Eet file, simply find the appropriate entry in the
-directory table, find it's offset and size, and read it into memory. If it is
-compressed, decompress it using zlib and then use that data.
-
-Here is a data map of an Eet file. All integers are encoded using big-endian
-notation (most significant byte first) and are signed. There is no alignment
-of data, so all data types follow immediately on, one after the other. All
-compressed data is compressed using the zlib compress2() function, and
-decompressed using the zlib uncompress() function. Please see zlib
-documentation for more information as to the encoding of compressed data.
-
-@verbatim
-HEADER:
-[INT] Magic number (0x1ee7ff00)
-[INT] Number of entries in the directory table
-[INT] The size of the directory table, in bytes
-
-DIRECTORY TABLE ENTRIES (as many as specified in the header):
-[INT] Offest from file start at which entry is stored (in bytes)
-[INT] Entry flags (1 = compressed, 0 = not compressed)
-[INT] Size of data chunk in file (in bytes)
-[INT] Size of the data chunk once decompressed (or the same as above, if not)
-[INT] The length of the string itendifier, in bytes, without NUL terminator
-[STR] Series of bytes for the string identifier, no NUL terminator
-... more directory entries
-
-DATA STORED, ONE AFTER ANOTHER:
-[DAT] DATA ENTRY 1...
-[DAT] DATA ENTRY 2...
-[DAT] DATA ENTRY 3...
-... more data chunks
-@endverbatim
-
-The contents of each entry in an Eet file has no defined format as such. It
-is an opaque chunk of data, that is up to the application to deocde, unless
-it is an image, ecoded by Eet, or a data structure encoded by Eet. The data
-itself for these entries can be encoded and decoded by Eet with extra helper
-functions in Eet. eet_data_image_read() and eet_data_image_write() are used
-to handle reading and writing image data from a known Eet file entry name.
-eet_data_read() and eet_data_write() are used to decode and encode program
-data structures from an Eet file, making the loading and saving of program
-information stored in data structures a simple 1 function call process.
-
-Please see src/lib/eet_data.c for information on the format of these
-specially encoded data entries in an Eet file (for now).
-
-
-@section compiling How to compile using Eet ?
-
-Eet is a library your application links to. The procedure for this is very
-simple. You simply have to compile your application with the appropriate
-compiler flags that the @p pkg-config script outputs. For example:
-
-Compiling C or C++ files into object files:
-
-@verbatim
-gcc -c -o main.o main.c `pkg-config --cflags eet`
-@endverbatim
-
-Linking object files into a binary executable:
-
-@verbatim
-gcc -o my_application main.o `pkg-config --libs eet`
-@endverbatim
-
-You simply have to make sure that pkg-config is in your shell's PATH (see
-the manual page for your appropriate shell) and eet.pc in /usr/lib/pkgconfig
-or its path is in the PKG_CONFIG_PATH environment variable. It's that simple
-to link and use Eet once you have written your code to use it.
-
-Since the program is linked to Eet, it is now able to use any advertised
-API calls to serialize your data.
-
-You should make sure you add any extra compile and link flags to your
-compile commands that your application may need as well. The above example
-is only guaranteed to make Eet add it's own requirements.
-
-
-@section install How is it installed?
-
-Simple:
-
-@verbatim
-./configure
-make
-su -
-...
-make install
-@endverbatim
-
-@section next_steps Next Steps
-
-After you understood what Eet is and installed it in your system you
-should proceed understanding the programming interface. We'd recommend
-you to take a while to learn Eina
-(http://docs.enlightenment.org/auto/eina/) as it is very convenient
-and optimized, and Eet provides integration with it.
-
-Recommended reading:
-
-@li @ref Eet_File_Group to know the basics to open and save files.
-@li @ref Eet_Data_Group to know the convenient way to serialize and
- parse your data structures automatically. Just create your
- descriptors and let Eet do the work for you.
-
-@section intro_example Introductory Examples
-
-@ref Examples
-
-@todo Document data format for images and data structures.
-
-*/
@pkgconfig_requires_private@: @requirement_eet@
Version: @VERSION@
Libs: -L${libdir} -leet
-Libs.private: @EET_LIBS@ @EFL_FNMATCH_LIBS@ @LIBGCRYPT_LIBS@ @EFL_PTHREAD_LIBS@ -ljpeg -lz -lm
+Libs.private: @EET_LIBS@ @EFL_FNMATCH_LIBS@ @LIBGCRYPT_LIBS@ -ljpeg -lz -lm
Cflags: -I${includedir}/eet-@VMAJ@
Cflags.private: @LIBGCRYPT_CFLAGS@
+/**
+@brief Eet Data Handling Library Public API Calls
+
+These routines are used for Eet Library interaction
+
+@mainpage Eet Library Documentation
+
+@image html e_big.png
+
+@version 1.0.0
+@author Carsten Haitzler <raster@@rasterman.com>
+@author David Goodlad <dgoodlad@@gmail.com>
+@author Cedric Bail <cedric.bail@@free.fr>
+@author Arnaud de Turckheim <quarium@@gmail.com>
+@author Luis Felipe Strano Moraes <lfelipe@@profusion.mobi>
+@author Chidambar Zinnoury <illogict@@online.fr>
+@author Vincent Torri <vtorri@@univ-evry.fr>
+@author Gustavo Sverzut Barbieri <barbieri@@profusion.mobi>
+@author Raphael Kubo da Costa <kubo@@profusion.mobi>
+@author Mathieu Taillefumier <mathieu.taillefumier@@free.fr>
+@author Albin "Lutin" Tonnerre <albin.tonnerre@@gmail.com>
+@author Adam Simpkins <adam@@adamsimpkins.net>
+@date 2000-2011
+
+@section toc Table of Contents
+
+@li @ref intro
+@li @ref example
+@li @ref format
+@li @ref compiling
+@li @ref install
+@li @ref next_steps
+@li @ref intro_example
+
+@section intro What is Eet?
+
+It is a tiny library designed to write an arbitrary set of chunks of data
+to a file and optionally compress each chunk (very much like a zip file)
+and allow fast random-access reading of the file later on. It does not
+do zip as a zip itself has more complexity than is needed, and it was much
+simpler to implement this once here.
+
+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
+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.
+
+It also can encode and decode data structures in memory, as well as image
+data for saving to Eet files or sending across the network to other
+machines, or just writing to arbitrary files on the system. All data is
+encoded in a platform independent way and can be written and read by any
+architecture.
+
+@section example A simple example on using Eet
+
+Here is a simple example on how to use Eet to save a series of strings to a
+file and load them again. The advantage of using Eet over just fprintf() and
+fscanf() is that not only can these entries be strings, they need no special
+parsing to handle delimiter characters or escaping, they can be binary data,
+image data, data structures containing integers, strings, other data
+structures, linked lists and much more, without the programmer having to
+worry about parsing, and best of all, Eet is very fast.
+
+@code
+#include <Eet.h>
+
+int
+main(int argc, char **argv)
+{
+ Eet_File *ef;
+ int i;
+ char buf[32];
+ char *ret;
+ int size;
+ char *entries[] =
+ {
+ "Entry 1",
+ "Big text string here compared to others",
+ "Eet is cool"
+ };
+
+ eet_init();
+
+ // blindly open an file for output and write strings with their NUL char
+ ef = eet_open("test.eet", EET_FILE_MODE_WRITE);
+ eet_write(ef, "Entry 1", entries[0], strlen(entries[0]) + 1, 0);
+ eet_write(ef, "Entry 2", entries[1], strlen(entries[1]) + 1, 1);
+ eet_write(ef, "Entry 3", entries[2], strlen(entries[2]) + 1, 0);
+ eet_close(ef);
+
+ // open the file again and blindly get the entries we wrote
+ ef = eet_open("test.eet", EET_FILE_MODE_READ);
+ ret = eet_read(ef, "Entry 1", &size);
+ printf("%s\n", ret);
+ ret = eet_read(ef, "Entry 2", &size);
+ printf("%s\n", ret);
+ ret = eet_read(ef, "Entry 3", &size);
+ printf("%s\n", ret);
+ eet_close(ef);
+
+ eet_shutdown();
+}
+@endcode
+
+@section format What does an Eet file look like?
+
+The file format is very simple. There is a directory block at the start of
+the file listing entries and offsets into the file where they are stored,
+their sizes, compression flags etc. followed by all the entry data strung one
+element after the other.
+
+All Eet files start with t a 4 byte magic number. It is written using network
+byte-order (big endian, or from most significant byte first to least
+significant byte last) and is 0x1ee7ff00 (or byte by byte 0:1e 1:e7 2:ff
+3:00). The next 4 bytes are an integer (in big endian notation) indicating
+how many entries are stored in the Eet file. 0 indicates it is empty. This is
+a signed integer and thus values less than 0 are invalid, limiting the number
+of entries in an Eet file to 0x7fffffff entries at most. The next 4 bytes is
+the size of the directory table, in bytes, encoded in big-endian format. This
+is a signed integer and cannot be less than 0.
+
+The directory table for the file follows immediately, with a continuous list
+of all entries in the Eet file, their offset in the file etc. The order of
+these entries is not important, but convention would have them be from first
+to last entry in the file. Each directory entry consiste of 5 integers, one
+after the other, each stored as a signed, big endian integer. The first is
+the offset in the file that the data for this entry is stored at (based from
+the very start of the file, not relative to the end of the directory block).
+The second integer holds flags for the entry. currently only the least
+significant bit (bit 0) holds any useful information, and it is set to 1 if
+the entry is compressed using zlib compression calls, or 0 if it is not
+compressed. The next integer is the size of the entry in bytes stored in the
+file. The next integer is the size of the data when decompressed (if it was
+compressed) in bytes. This may be the same as the previous integer if the
+entry was not compressed. The final integer is the number of bytes used by
+the string identifier for the entry, without the NUL byte terminator, which
+is not stored. The next series of bytes is the string name of the entry, with
+the number of bytes being the same as specified in the last integer above.
+This list of entries continues until there are no more entries left to list.
+To read an entry from an Eet file, simply find the appropriate entry in the
+directory table, find it's offset and size, and read it into memory. If it is
+compressed, decompress it using zlib and then use that data.
+
+Here is a data map of an Eet file. All integers are encoded using big-endian
+notation (most significant byte first) and are signed. There is no alignment
+of data, so all data types follow immediately on, one after the other. All
+compressed data is compressed using the zlib compress2() function, and
+decompressed using the zlib uncompress() function. Please see zlib
+documentation for more information as to the encoding of compressed data.
+
+@verbatim
+HEADER:
+[INT] Magic number (0x1ee7ff00)
+[INT] Number of entries in the directory table
+[INT] The size of the directory table, in bytes
+
+DIRECTORY TABLE ENTRIES (as many as specified in the header):
+[INT] Offest from file start at which entry is stored (in bytes)
+[INT] Entry flags (1 = compressed, 0 = not compressed)
+[INT] Size of data chunk in file (in bytes)
+[INT] Size of the data chunk once decompressed (or the same as above, if not)
+[INT] The length of the string itendifier, in bytes, without NUL terminator
+[STR] Series of bytes for the string identifier, no NUL terminator
+... more directory entries
+
+DATA STORED, ONE AFTER ANOTHER:
+[DAT] DATA ENTRY 1...
+[DAT] DATA ENTRY 2...
+[DAT] DATA ENTRY 3...
+... more data chunks
+@endverbatim
+
+The contents of each entry in an Eet file has no defined format as such. It
+is an opaque chunk of data, that is up to the application to deocde, unless
+it is an image, ecoded by Eet, or a data structure encoded by Eet. The data
+itself for these entries can be encoded and decoded by Eet with extra helper
+functions in Eet. eet_data_image_read() and eet_data_image_write() are used
+to handle reading and writing image data from a known Eet file entry name.
+eet_data_read() and eet_data_write() are used to decode and encode program
+data structures from an Eet file, making the loading and saving of program
+information stored in data structures a simple 1 function call process.
+
+Please see src/lib/eet_data.c for information on the format of these
+specially encoded data entries in an Eet file (for now).
+
+
+@section compiling How to compile using Eet ?
+
+Eet is a library your application links to. The procedure for this is very
+simple. You simply have to compile your application with the appropriate
+compiler flags that the @p pkg-config script outputs. For example:
+
+Compiling C or C++ files into object files:
+
+@verbatim
+gcc -c -o main.o main.c `pkg-config --cflags eet`
+@endverbatim
+
+Linking object files into a binary executable:
+
+@verbatim
+gcc -o my_application main.o `pkg-config --libs eet`
+@endverbatim
+
+You simply have to make sure that pkg-config is in your shell's PATH (see
+the manual page for your appropriate shell) and eet.pc in /usr/lib/pkgconfig
+or its path is in the PKG_CONFIG_PATH environment variable. It's that simple
+to link and use Eet once you have written your code to use it.
+
+Since the program is linked to Eet, it is now able to use any advertised
+API calls to serialize your data.
+
+You should make sure you add any extra compile and link flags to your
+compile commands that your application may need as well. The above example
+is only guaranteed to make Eet add it's own requirements.
+
+
+@section install How is it installed?
+
+Simple:
+
+@verbatim
+./configure
+make
+su -
+...
+make install
+@endverbatim
+
+@section next_steps Next Steps
+
+After you understood what Eet is and installed it in your system you
+should proceed understanding the programming interface. We'd recommend
+you to take a while to learn Eina
+(http://docs.enlightenment.org/auto/eina/) as it is very convenient
+and optimized, and Eet provides integration with it.
+
+Recommended reading:
+
+@li @ref Eet_File_Group to know the basics to open and save files.
+@li @ref Eet_Data_Group to know the convenient way to serialize and
+ parse your data structures automatically. Just create your
+ descriptors and let Eet do the work for you.
+
+@section intro_example Introductory Examples
+
+@ref Examples
+
+@todo Document data format for images and data structures.
+
+*/
+
#ifndef _EET_H
#define _EET_H
* Example:
*
* @code
+ * #include <Eina.h>
* #include <Eet.h>
- * #include <Evas.h>
*
* typedef struct _blah2
* {
} while (0)
/**
+ * Add a linked list of string to a data descriptor
+ * @param edd The data descriptor to add the type to.
+ * @param struct_type The type of the struct.
+ * @param name The string name to use to encode/decode this member
+ * (must be a constant global and never change).
+ * @param member The struct member itself to be encoded.
+ *
+ * This macro lets you easily add a linked list of char *. All the
+ * parameters are the same as for EET_DATA_DESCRIPTOR_ADD_BASIC().
+ *
+ * @since 1.5.0
+ * @ingroup Eet_Data_Group
+ */
+#define EET_DATA_DESCRIPTOR_ADD_LIST_STRING(edd, struct_type, name, member) \
+ do { \
+ struct_type ___ett; \
+ eet_data_descriptor_element_add(edd, name, EET_T_STRING, EET_G_LIST, \
+ (char *)(& (___ett.member)) - \
+ (char *)(& (___ett)), \
+ 0, /* 0, */ NULL, NULL); \
+ } while (0)
+
+/**
* Add a hash type to a data descriptor
* @param edd The data descriptor to add the type to.
* @param struct_type The type of the struct.
* types. All the parameters are the same as for
* EET_DATA_DESCRIPTOR_ADD_BASIC(), with the @p subtype being the
* exception. This must be the data descriptor of the element that
- * is in each member of the hash to be stored.
+ * is in each member of the hash to be stored. This assumes you have
+ * a struct member (of type EET_T_INT) called member_count (note the
+ * _count appended to the member) that holds the number of items in
+ * the array. This array will be allocated separately to the struct it
+ * is in.
*
* @since 1.0.2
* @ingroup Eet_Data_Group
libeet_la_SOURCES = $(base_sources)
endif
-libeet_la_CFLAGS = @EET_CFLAGS@ @DEBUG_CFLAGS@ @EFL_PTHREAD_CFLAGS@
+libeet_la_CFLAGS = @EET_CFLAGS@ @DEBUG_CFLAGS@
libeet_la_LIBADD = @GNUTLS_LIBS@ @OPENSSL_LIBS@ @EFL_COVERAGE_LIBS@ @EET_LIBS@ @EINA_LIBS@ @EVIL_LIBS@ -lz -ljpeg -lm
-libeet_la_LDFLAGS = -no-undefined @lt_enable_auto_import@ -version-info @version_info@ @release_info@ @EFL_PTHREAD_LIBS@
+libeet_la_LDFLAGS = -no-undefined @lt_enable_auto_import@ -version-info @version_info@ @release_info@
EXTRA_DIST = Eet_private.h
#include <sys/stat.h>
#include <sys/mman.h>
-#ifndef _MSC_VER
+#ifdef HAVE_UNISTD_H
# include <unistd.h>
-#endif /* ifndef _MSC_VER */
+#endif /* ifdef HAVE_UNISTD_H */
#ifdef HAVE_NETINET_IN_H
# include <netinet/in.h>
#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
*
if (!strcmp(tok3, "char:"))
{
n->type = EET_T_CHAR;
- sscanf(tok4, "%hhi",
+ sscanf(tok4, FMT_CHAR,
&(n->data.value.c));
}
else if (!strcmp(tok3, "short:"))
else if (!strcmp(tok3, "long_long:"))
{
n->type = EET_T_LONG_LONG;
- sscanf(tok4, "%lli",
+ sscanf(tok4, FMT_LONG_LONG,
&(n->data.value.l));
}
else if (!strcmp(tok3, "float:"))
else if (!strcmp(tok3, "uchar:"))
{
n->type = EET_T_UCHAR;
- sscanf(tok4, "%hhu",
+ sscanf(tok4, FMT_UCHAR,
&(n->data.value.uc));
}
else if (!strcmp(tok3, "ushort:"))
else if (!strcmp(tok3, "ulong_long:"))
{
n->type = EET_T_ULONG_LONG;
- sscanf(tok4, "%llu",
+ sscanf(tok4, FMT_ULONG_LONG,
&(n->data.value.ul));
}
else if (!strcmp(tok3, "string:"))
#ifdef _WIN32
# include <winsock2.h>
+# define HAVE_BOOLEAN
#endif /* ifdef _WIN32 */
#include <stdio.h>
#include <fcntl.h>
#include <zlib.h>
-#ifndef _MSC_VER
+#ifdef HAVE_UNISTD_H
# include <unistd.h>
-#endif /* ifndef _MSC_VER */
+#endif /* ifdef HAVE_UNISTD_H */
#ifdef HAVE_NETINET_IN_H
# include <netinet/in.h>
# include <Evil.h>
#endif /* ifdef HAVE_EVIL */
+#include <Eina.h>
+
#ifdef HAVE_GNUTLS
# include <gnutls/gnutls.h>
# include <gcrypt.h>
# include <openssl/evp.h>
#endif /* ifdef HAVE_OPENSSL */
-#ifdef EFL_HAVE_POSIX_THREADS
-# include <pthread.h>
+#ifdef EINA_HAVE_THREADS
# ifdef HAVE_GNUTLS
GCRY_THREAD_OPTION_PTHREAD_IMPL;
# endif /* ifdef HAVE_GNUTLS */
-#endif /* ifdef EFL_HAVE_POSIX_THREADS */
-
-#include <Eina.h>
+#endif /* ifdef EINA_HAVE_THREADS */
#include "Eet.h"
#include "Eet_private.h"
struct _Eet_File
{
char *path;
- FILE *readfp;
+ Eina_File *readfp;
Eet_File_Header *header;
Eet_Dictionary *ed;
Eet_Key *key;
int magic;
int references;
- int data_size;
+ unsigned long int data_size;
int x509_length;
unsigned int signature_length;
int sha1_length;
- time_t mtime;
-
-#ifdef EFL_HAVE_THREADS
-# ifdef EFL_HAVE_POSIX_THREADS
- pthread_mutex_t file_lock;
-# else /* ifdef EFL_HAVE_POSIX_THREADS */
- HANDLE file_lock;
-# endif /* ifdef EFL_HAVE_POSIX_THREADS */
-#endif /* ifdef EFL_HAVE_THREADS */
+ Eina_Lock file_lock;
unsigned char writes_pending : 1;
unsigned char delete_me_now : 1;
void *data;
Eet_File_Node *next; /* FIXME: make buckets linked lists */
- int offset;
- int dictionary_offset;
- int name_offset;
+ unsigned long int offset;
+ unsigned long int dictionary_offset;
+ unsigned long int name_offset;
- int name_size;
- int size;
- int data_size;
+ unsigned int name_size;
+ unsigned int size;
+ unsigned int data_size;
unsigned char free_name : 1;
unsigned char compression : 1;
static Eet_Error eet_internal_close(Eet_File *ef, Eina_Bool locked);
-#ifdef EFL_HAVE_THREADS
-
-# ifdef EFL_HAVE_POSIX_THREADS
-
-static pthread_mutex_t eet_cache_lock = PTHREAD_MUTEX_INITIALIZER;
-
-# define LOCK_CACHE pthread_mutex_lock(&eet_cache_lock)
-# define UNLOCK_CACHE pthread_mutex_unlock(&eet_cache_lock)
-
-# define INIT_FILE(File) pthread_mutex_init(&File->file_lock, NULL)
-# define LOCK_FILE(File) pthread_mutex_lock(&File->file_lock)
-# define UNLOCK_FILE(File) pthread_mutex_unlock(&File->file_lock)
-# define DESTROY_FILE(File) pthread_mutex_destroy(&File->file_lock)
-
-# else /* EFL_HAVE_WIN32_THREADS */
-
-static HANDLE eet_cache_lock = NULL;
-
-# define LOCK_CACHE WaitForSingleObject(eet_cache_lock, INFINITE)
-# define UNLOCK_CACHE ReleaseMutex(eet_cache_lock)
-
-# define INIT_FILE(File) File->file_lock = CreateMutex(NULL, FALSE, NULL)
-# define LOCK_FILE(File) WaitForSingleObject(File->file_lock, INFINITE)
-# define UNLOCK_FILE(File) ReleaseMutex(File->file_lock)
-# define DESTROY_FILE(File) CloseHandle(File->file_lock)
+static Eina_Lock eet_cache_lock;
-# endif /* EFL_HAVE_WIN32_THREADS */
+#define LOCK_CACHE eina_lock_take(&eet_cache_lock)
+#define UNLOCK_CACHE eina_lock_release(&eet_cache_lock)
-#else /* ifdef EFL_HAVE_THREADS */
-
-# define LOCK_CACHE do {} while (0)
-# define UNLOCK_CACHE do {} while (0)
-
-# define INIT_FILE(File) do {} while (0)
-# define LOCK_FILE(File) do {} while (0)
-# define UNLOCK_FILE(File) do {} while (0)
-# define DESTROY_FILE(File) do {} while (0)
-
-#endif /* EFL_HAVE_THREADS */
+#define INIT_FILE(File) eina_lock_new(&File->file_lock)
+#define LOCK_FILE(File) eina_lock_take(&File->file_lock)
+#define UNLOCK_FILE(File) eina_lock_release(&File->file_lock)
+#define DESTROY_FILE(File) eina_lock_free(&File->file_lock)
/* cache. i don't expect this to ever be large, so arrays will do */
static int eet_writers_num = 0;
goto shutdown_eina;
}
+ eina_lock_new(&eet_cache_lock);
+
if (!eet_node_init())
{
EINA_LOG_ERR("Eet: Eet_Node mempool creation failed");
"BIG FAT WARNING: I AM UNABLE TO REQUEST SECMEM, Cryptographic operation are at risk !");
}
-# ifdef EFL_HAVE_POSIX_THREADS
+# ifdef EINA_HAVE_THREADS
if (gcry_control(GCRYCTL_SET_THREAD_CBS, &gcry_threads_pthread))
WRN(
"YOU ARE USING PTHREADS, BUT I CANNOT INITIALIZE THREADSAFE GCRYPT OPERATIONS!");
-# endif /* ifdef EFL_HAVE_POSIX_THREADS */
+# endif /* ifdef EINA_HAVE_THREADS */
if (gnutls_global_init())
goto shutdown_eet;
#ifdef HAVE_GNUTLS
shutdown_eet:
-#endif
+#endif
eet_node_shutdown();
unregister_log_domain:
eina_log_domain_unregister(_eet_log_dom_global);
eet_clearcache();
eet_node_shutdown();
+
+ eina_lock_free(&eet_cache_lock);
+
#ifdef HAVE_GNUTLS
gnutls_global_deinit();
#endif /* ifdef HAVE_GNUTLS */
const int *data = (const int *)ef->data;
const char *start = (const char *)ef->data;
int idx = 0;
- int num_directory_entries;
- int bytes_directory_entries;
- int num_dictionary_entries;
- int bytes_dictionary_entries;
- int signature_base_offset;
- int i;
+ unsigned long int bytes_directory_entries;
+ unsigned long int bytes_dictionary_entries;
+ unsigned long int signature_base_offset;
+ unsigned long int num_directory_entries;
+ unsigned long int num_dictionary_entries;
+ unsigned int i;
idx += sizeof(int);
if (eet_test_close((int)ntohl(*data) != EET_MAGIC_FILE2, ef))
{
const char *name;
Eet_File_Node *efn;
- int name_offset;
- int name_size;
+ unsigned long int name_offset;
+ unsigned long int name_size;
int hash;
int flag;
for (j = 0; j < ef->ed->count; ++j)
{
+ unsigned int offset;
int hash;
- int offset;
GET_INT(hash, dico, idx);
GET_INT(offset, dico, idx);
{
const unsigned char *dyn_buf = NULL;
const unsigned char *p = NULL;
+ unsigned long int byte_entries;
+ unsigned long int num_entries;
+ unsigned int i;
int idx = 0;
- int num_entries;
- int byte_entries;
- int i;
WRN(
"EET file format of '%s' is deprecated. You should just open it one time with mode == EET_FILE_MODE_READ_WRITE to solve this issue.",
ef->references--;
/* if its still referenced - dont go any further */
if (ef->references > 0)
- goto on_error; /* flush any writes */
+ {
+ /* flush any writes */
+ if ((ef->mode == EET_FILE_MODE_WRITE) ||
+ (ef->mode == EET_FILE_MODE_READ_WRITE))
+ eet_sync(ef);
+ goto on_error;
+ }
err = eet_flush2(ef);
if (ef->mode == EET_FILE_MODE_READ)
eet_cache_del(ef, &eet_readers, &eet_readers_num, &eet_readers_alloc);
else if ((ef->mode == EET_FILE_MODE_WRITE) ||
- (
- ef
- ->
- mode == EET_FILE_MODE_READ_WRITE))
+ (ef->mode == EET_FILE_MODE_READ_WRITE))
eet_cache_del(ef, &eet_writers, &eet_writers_num, &eet_writers_alloc);
/* we can unlock the cache now */
eet_dictionary_free(ef->ed);
if (ef->sha1)
- free(ef->sha1);
-
- if (ef->data)
- munmap((void *)ef->data, ef->data_size);
+ free(ef->sha1);
if (ef->readfp)
- fclose(ef->readfp);
+ {
+ if (ef->data)
+ eina_file_map_free(ef->readfp, (void *) ef->data);
+
+ eina_file_close(ef->readfp);
+ }
/* zero out ram for struct - caution tactic against stale memory use */
memset(ef, 0, sizeof(Eet_File));
ef->references = 1;
ef->mode = EET_FILE_MODE_READ;
ef->header = NULL;
- ef->mtime = 0;
ef->delete_me_now = 1;
ef->readfp = NULL;
ef->data = data;
eet_open(const char *file,
Eet_File_Mode mode)
{
- FILE *fp;
+ Eina_File *fp;
Eet_File *ef;
int file_len;
- struct stat file_stat;
+ unsigned long int size;
if (!file)
return NULL;
if ((mode == EET_FILE_MODE_READ) || (mode == EET_FILE_MODE_READ_WRITE))
{
/* Prevent garbage in futur comparison. */
- file_stat.st_mtime = 0;
-
- fp = fopen(file, "rb");
+ fp = eina_file_open(file, EINA_FALSE);
if (!fp)
goto open_error;
- if (fstat(fileno(fp), &file_stat))
- {
- fclose(fp);
- fp = NULL;
-
- memset(&file_stat, 0, sizeof(file_stat));
+ size = eina_file_size_get(fp);
- goto open_error;
- }
-
- if (file_stat.st_size < ((int)sizeof(int) * 3))
+ if (size < ((int)sizeof(int) * 3))
{
- fclose(fp);
+ eina_file_close(fp);
fp = NULL;
- memset(&file_stat, 0, sizeof(file_stat));
+ size = 0;
goto open_error;
}
if (mode != EET_FILE_MODE_WRITE)
return NULL;
- memset(&file_stat, 0, sizeof(file_stat));
+ size = 0;
fp = NULL;
}
/* We found one */
- if (ef &&
- ((file_stat.st_mtime != ef->mtime) ||
- (file_stat.st_size != ef->data_size)))
+ if (ef && ef->readfp != fp)
{
ef->delete_me_now = 1;
ef->references++;
{
/* reference it up and return it */
if (fp)
- fclose(fp);
+ eina_file_close(fp);
ef->references++;
UNLOCK_CACHE;
ef->references = 1;
ef->mode = mode;
ef->header = NULL;
- ef->mtime = file_stat.st_mtime;
ef->writes_pending = 0;
ef->delete_me_now = 0;
ef->data = NULL;
if (eet_test_close(!ef->readfp, ef))
goto on_error;
- fcntl(fileno(ef->readfp), F_SETFD, FD_CLOEXEC);
/* if we opened for read or read-write */
if ((mode == EET_FILE_MODE_READ) || (mode == EET_FILE_MODE_READ_WRITE))
{
- ef->data_size = file_stat.st_size;
- ef->data = mmap(NULL, ef->data_size, PROT_READ,
- MAP_SHARED, fileno(ef->readfp), 0);
- if (eet_test_close((ef->data == MAP_FAILED), ef))
+ ef->data_size = size;
+ ef->data = eina_file_map_all(fp, EINA_FILE_SEQUENTIAL);
+ if (eet_test_close((ef->data == NULL), ef))
goto on_error;
ef = eet_internal_read(ef);
if (ef->references == 1)
{
if (ef->mode == EET_FILE_MODE_READ)
- eet_cache_add(ef, &eet_readers, &eet_readers_num, &eet_readers_alloc);
- else
- if ((ef->mode == EET_FILE_MODE_WRITE) ||
- (ef->mode == EET_FILE_MODE_READ_WRITE))
- eet_cache_add(ef, &eet_writers, &eet_writers_num, &eet_writers_alloc);
+ eet_cache_add(ef, &eet_readers, &eet_readers_num, &eet_readers_alloc);
+ else if ((ef->mode == EET_FILE_MODE_WRITE) ||
+ (ef->mode == EET_FILE_MODE_READ_WRITE))
+ eet_cache_add(ef, &eet_writers, &eet_writers_num, &eet_writers_alloc);
}
UNLOCK_CACHE;
{
Eet_File_Node *efn;
char *data = NULL;
- int size = 0;
+ unsigned long int size = 0;
if (size_ret)
*size_ret = 0;
if (!efn)
goto on_error;
- if (efn->offset < 0 && !efn->data)
+ /* trick to detect data in memory instead of mmaped from disk */
+ if (efn->offset > ef->data_size && !efn->data)
goto on_error;
/* get size (uncompressed, if compressed at all) */
efn->size = data_size;
efn->data_size = strlen(destination) + 1;
efn->data = data2;
- efn->offset = -1;
+ /* Put the offset above the limit to avoid direct access */
+ efn->offset = ef->data_size + 1;
exists_already = EINA_TRUE;
+
break;
}
}
efn->next = ef->header->directory->nodes[hash];
ef->header->directory->nodes[hash] = efn;
- efn->offset = -1;
+ /* Put the offset above the limit to avoid direct access */
+ efn->offset = ef->data_size + 1;
efn->alias = 1;
efn->ciphered = 0;
efn->compression = !!comp;
efn->size = data_size;
efn->data_size = size;
efn->data = data2;
- efn->offset = -1;
+ /* Put the offset above the limit to avoid direct access */
+ efn->offset = ef->data_size + 1;
exists_already = 1;
break;
}
efn->next = ef->header->directory->nodes[hash];
ef->header->directory->nodes[hash] = efn;
- efn->offset = -1;
+ /* Put the offset above the limit to avoid direct access */
+ efn->offset = ef->data_size + 1;
efn->alias = 0;
efn->ciphered = cipher_key ? 1 : 0;
efn->compression = !!comp;
void *buf,
int len)
{
- if (efn->offset < 0)
+ if (efn->offset > ef->data_size)
return 0;
- if (ef->data)
- {
- if ((efn->offset + len) > ef->data_size)
- return 0;
-
- memcpy(buf, ef->data + efn->offset, len);
- }
- else
- {
- if (!ef->readfp)
- return 0;
+ if (!ef->data)
+ return 0;
- /* seek to data location */
- if (fseek(ef->readfp, efn->offset, SEEK_SET) < 0)
- return 0;
+ if ((efn->offset + len) > ef->data_size)
+ return 0;
- /* read it */
- len = fread(buf, len, 1, ef->readfp);
- }
+ memcpy(buf, ef->data + efn->offset, len);
return len;
} /* read_data_from_disk */
#include <fcntl.h>
#include <unistd.h>
-#ifdef EFL_HAVE_POSIX_THREADS
+#include <Eina.h>
+
+#ifdef EINA_HAVE_THREADS
+#if ((!defined(_WIN32_WCE)) && (!defined(_WIN32)))
# include <pthread.h>
-#endif /* ifdef EFL_HAVE_POSIX_THREADS */
+# define _EET_INCLUDED_PTHREAD
+#endif
+#endif /* ifdef EINA_HAVE_THREADS */
#include <check.h>
-#include <Eina.h>
-
#include "eet_suite.h"
START_TEST(eet_test_init)
fail_if(!eet_data_write(ef, edd, EET_TEST_FILE_KEY1, &etbt, 0));
+ result = eet_data_read(ef, edd, EET_TEST_FILE_KEY1);
+ fail_if(!result);
+
+ /* Test the resulting data. */
+ fail_if(_eet_test_ex_check(result, 0) != 0);
+
eet_close(ef);
/* Read back the data. */
unsigned int w;
unsigned int h;
+ eet_init();
+
fail_if(!(file = tmpnam(file)));
/* Save the encoded data in a file. */
END_TEST
-#ifdef EFL_HAVE_THREADS
+#ifdef EINA_HAVE_THREADS
static Eina_Bool open_worker_stop;
-# ifdef EFL_HAVE_POSIX_THREADS
+# ifdef _EET_INCLUDED_PTHREAD
static void *
open_close_worker(void * path)
pthread_exit(NULL);
} /* open_close_worker */
-# else /* ifdef EFL_HAVE_POSIX_THREADS */
+# else /* ifdef _EET_INCLUDED_PTHREAD */
static unsigned int __stdcall
open_close_worker(void * path)
_endthreadex(0);
} /* open_close_worker */
-# endif /* ifdef EFL_HAVE_POSIX_THREADS */
+# endif /* ifdef _EET_INCLUDED_PTHREAD */
START_TEST(eet_cache_concurrency)
{
Eet_File * ef;
void * thread_ret;
unsigned int n;
-# ifdef EFL_HAVE_POSIX_THREADS
+# ifdef _EET_INCLUDED_PTHREAD
pthread_t thread;
-# else /* ifdef EFL_HAVE_POSIX_THREADS */
+# else /* ifdef _EET_INCLUDED_PTHREAD */
uintptr_t thread;
unsigned int thread_id;
DWORD ret;
-# endif /* ifdef EFL_HAVE_POSIX_THREADS */
+# endif /* ifdef _EET_INCLUDED_PTHREAD */
eet_init();
+ eina_threads_init();
/* create a file to test with */
fail_if(!(file = tmpnam(file)));
/* start a thread that repeatedly opens and closes a file */
open_worker_stop = 0;
-# ifdef EFL_HAVE_POSIX_THREADS
+# ifdef _EET_INCLUDED_PTHREAD
pthread_create(&thread, NULL, open_close_worker, file);
-# else /* ifdef EFL_HAVE_POSIX_THREADS */
+# else /* ifdef _EET_INCLUDED_PTHREAD */
thread = _beginthreadex(NULL, 0, open_close_worker, file, 0, &thread_id);
-# endif /* ifdef EFL_HAVE_POSIX_THREADS */
+# endif /* ifdef _EET_INCLUDED_PTHREAD */
/* clear the cache repeatedly in this thread */
for (n = 0; n < 50000; ++n)
{
/* join the other thread, and fail if it returned an error message */
open_worker_stop = 1;
-# ifdef EFL_HAVE_POSIX_THREADS
+# ifdef _EET_INCLUDED_PTHREAD
fail_if(pthread_join(thread, &thread_ret) != 0);
fail_unless(thread_ret == NULL, (char const *)thread_ret);
-# else /* ifdef EFL_HAVE_POSIX_THREADS */
+# else /* ifdef _EET_INCLUDED_PTHREAD */
ret = WaitForSingleObject((HANDLE)thread, INFINITE);
fail_if(ret != WAIT_OBJECT_0);
fail_if(GetExitCodeThread((HANDLE)thread, &ret) == FALSE);
fail_if(ret != 0);
-# endif /* ifdef EFL_HAVE_POSIX_THREADS */
+# endif /* ifdef _EET_INCLUDED_PTHREAD */
fail_if(unlink(file) != 0);
+
+ eina_threads_shutdown();
eet_shutdown();
}
END_TEST
-#endif /* EFL_HAVE_THREADS */
+#endif /* EINA_HAVE_THREADS */
typedef struct _Eet_Connection_Data Eet_Connection_Data;
struct _Eet_Connection_Data
suite_add_tcase(s, tc);
#endif /* ifdef HAVE_CIPHER */
-#ifdef EFL_HAVE_THREADS
+#ifdef EINA_HAVE_THREADS
tc = tcase_create("Eet Cache");
tcase_add_test(tc, eet_cache_concurrency);
suite_add_tcase(s, tc);