Eet.h   Eet.h 
#ifndef _EET_H #ifndef _EET_H
#define _EET_H #define _EET_H
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h> #include <stdio.h>
#include <Eina.h> #include <Eina.h>
#ifdef EAPI #ifdef EAPI
# undef EAPI # undef EAPI
#endif #endif /* ifdef EAPI */
#ifdef _WIN32 #ifdef _WIN32
# ifdef EFL_EET_BUILD # ifdef EFL_EET_BUILD
# ifdef DLL_EXPORT # ifdef DLL_EXPORT
# define EAPI __declspec(dllexport) # define EAPI __declspec(dllexport)
# else # else /* ifdef DLL_EXPORT */
# define EAPI # define EAPI
# endif /* ! DLL_EXPORT */ # endif /* ! DLL_EXPORT */
# else # else /* ifdef EFL_EET_BUILD */
# define EAPI __declspec(dllimport) # define EAPI __declspec(dllimport)
# endif /* ! EFL_EET_BUILD */ # endif /* ! EFL_EET_BUILD */
#else #else /* ifdef _WIN32 */
# ifdef __GNUC__ # ifdef __GNUC__
# if __GNUC__ >= 4 # if __GNUC__ >= 4
# define EAPI __attribute__ ((visibility("default"))) # define EAPI __attribute__ ((visibility("default")))
# else # else /* if __GNUC__ >= 4 */
# define EAPI # define EAPI
# endif # endif /* if __GNUC__ >= 4 */
# else # else /* ifdef __GNUC__ */
# define EAPI # define EAPI
# endif # endif /* ifdef __GNUC__ */
#endif /* ! _WIN32 */ #endif /* ! _WIN32 */
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif /* ifdef __cplusplus */
/** /**
* @file Eet.h * @file Eet.h
* @brief The file that provides the eet functions. * @brief The file that provides the eet functions.
* *
* This header provides the Eet management functions. * This header provides the Eet management functions.
* *
*/ */
#define EET_VERSION_MAJOR 1 #define EET_VERSION_MAJOR 1
#define EET_VERSION_MINOR 3 #define EET_VERSION_MINOR 4
/** /**
* @typedef Eet_Version * @typedef Eet_Version
* *
* This is the Eet version information structure that can be used at * This is the Eet version information structure that can be used at
* runtiime to detect which version of eet is being used and adapt * runtiime to detect which version of eet is being used and adapt
* appropriately as follows for example: * appropriately as follows for example:
* *
* @code * @code
* #if defined(EET_VERSION_MAJOR) && (EET_VERSION_MAJOR >= 1) && defined( * #if defined(EET_VERSION_MAJOR) && (EET_VERSION_MAJOR >= 1) && defined(EE
EET_VERSION_MINOR) && (EET_VERSION_MINOR > 2) T_VERSION_MINOR) && (EET_VERSION_MINOR > 2)
* printf("Eet version: %i.%i.%i\n", * printf("Eet version: %i.%i.%i\n",
* eet_version->major, * eet_version->major,
* eet_version->minor, * eet_version->minor,
* eet_version->micro); * eet_version->micro);
* if (eet_version->revision > 0) * if (eet_version->revision > 0)
* { * {
* printf(" Built from SVN revision # %i\n", eet_version->revision); * printf(" Built from SVN revision # %i\n", eet_version->revision);
* } * }
* #endif * #endif
* @endcode * @endcode
* *
* Note the #if check can be dropped if your program refuses to compile o * Note the #if check can be dropped if your program refuses to compile or
r * work with an Eet version less than 1.3.0.
* work with an Eet version less than 1.3.0. */
*/ typedef struct _Eet_Version
typedef struct _Eet_Version {
{ int major; /** < major (binary or source incompatible changes) */
int major; /** < major (binary or source incompatible changes) */ int minor; /** < minor (new features, bugfixes, major improvements versi
int minor; /** < minor (new features, bugfixes, major improvements on) */
version) */ int micro; /** < micro (bugfix, internal improvements, no new features v
int micro; /** < micro (bugfix, internal improvements, no new featu ersion) */
res version) */ int revision; /** < svn revision (0 if a proper rlease or the svn revsio
int revision; /** < svn revision (0 if a proper rlease or the svn r n number Eet is built from) */
evsion number Eet is built from) */ } Eet_Version;
} Eet_Version;
EAPI extern Eet_Version *eet_version; EAPI extern Eet_Version *eet_version;
/** /**
* @defgroup Eet_Group Top level functions * @defgroup Eet_Group Top level functions
* Functions that affect Eet as a whole. * Functions that affect Eet as a whole.
* *
* @{ * @{
*/ */
/** /**
* @enum _Eet_Error * @enum _Eet_Error
* All the error identifiers known by Eet. * All the error identifiers known by Eet.
*/ */
typedef enum _Eet_Error typedef enum _Eet_Error
{ {
EET_ERROR_NONE, /**< No error, it's all fine! */ EET_ERROR_NONE, /**< No error, it's all fine! */
EET_ERROR_BAD_OBJECT, /**< Given object or handle is NULL or invalid EET_ERROR_BAD_OBJECT, /**< Given object or handle is NULL or invalid */
*/ EET_ERROR_EMPTY, /**< There was nothing to do */
EET_ERROR_EMPTY, /**< There was nothing to do */ EET_ERROR_NOT_WRITABLE, /**< Could not write to file or fine is #EET_FIL
EET_ERROR_NOT_WRITABLE, /**< Could not write to file or fine is #EET E_MODE_READ */
_FILE_MODE_READ */ EET_ERROR_OUT_OF_MEMORY, /**< Could not allocate memory */
EET_ERROR_OUT_OF_MEMORY, /**< Could not allocate memory */ EET_ERROR_WRITE_ERROR, /**< Failed to write data to destination */
EET_ERROR_WRITE_ERROR, /**< Failed to write data to destination */ EET_ERROR_WRITE_ERROR_FILE_TOO_BIG, /**< Failed to write file since it i
EET_ERROR_WRITE_ERROR_FILE_TOO_BIG, /**< Failed to write file since s too big */
it is too big */ EET_ERROR_WRITE_ERROR_IO_ERROR, /**< Failed to write since generic Input
EET_ERROR_WRITE_ERROR_IO_ERROR, /**< Failed to write since generic I /Output error */
nput/Output error */ EET_ERROR_WRITE_ERROR_OUT_OF_SPACE, /**< Failed to write due out of spac
EET_ERROR_WRITE_ERROR_OUT_OF_SPACE, /**< Failed to write due out of e */
space */ EET_ERROR_WRITE_ERROR_FILE_CLOSED, /**< Failed to write because file was
EET_ERROR_WRITE_ERROR_FILE_CLOSED, /**< Failed to write because file closed */
was closed */ EET_ERROR_MMAP_FAILED, /**< Could not mmap file */
EET_ERROR_MMAP_FAILED, /**< Could not mmap file */ EET_ERROR_X509_ENCODING_FAILED, /**< Could not encode using X509 */
EET_ERROR_X509_ENCODING_FAILED, /**< Could not encode using X509 */ EET_ERROR_SIGNATURE_FAILED, /**< Could not validate signature */
EET_ERROR_SIGNATURE_FAILED, /**< Could not validate signature */ EET_ERROR_INVALID_SIGNATURE, /**< Signature is invalid */
EET_ERROR_INVALID_SIGNATURE, /**< Signature is invalid */ EET_ERROR_NOT_SIGNED, /**< File or contents are not signed */
EET_ERROR_NOT_SIGNED, /**< File or contents are not signed */ EET_ERROR_NOT_IMPLEMENTED, /**< Function is not implemented */
EET_ERROR_NOT_IMPLEMENTED, /**< Function is not implemented */ EET_ERROR_PRNG_NOT_SEEDED, /**< Could not introduce random seed */
EET_ERROR_PRNG_NOT_SEEDED, /**< Could not introduce random seed */ EET_ERROR_ENCRYPT_FAILED, /**< Could not encrypt contents */
EET_ERROR_ENCRYPT_FAILED, /**< Could not encrypt contents */ EET_ERROR_DECRYPT_FAILED /**< Could not decrypt contents */
EET_ERROR_DECRYPT_FAILED /**< Could not decrypt contents */ } Eet_Error; /**< Eet error identifiers */
} Eet_Error; /**< Eet error identifiers */
/** /**
* @} * @}
*/ */
/** /**
* Initialize the EET library. * Initialize the EET library.
* *
* @return The new init count. * @return The new init count.
* *
* @since 1.0.0 * @since 1.0.0
* @ingroup Eet_Group * @ingroup Eet_Group
*/ */
EAPI int eet_init(void); EAPI int
eet_init(void);
/** /**
* Shut down the EET library. * Shut down the EET library.
* *
* @return The new init count. * @return The new init count.
* *
* @since 1.0.0 * @since 1.0.0
* @ingroup Eet_Group * @ingroup Eet_Group
*/ */
EAPI int eet_shutdown(void); EAPI int
eet_shutdown(void);
/** /**
* Clear eet cache * Clear eet cache
* *
* Eet didn't free items by default. If you are under memory * Eet didn't free items by default. If you are under memory
* presure, just call this function to recall all memory that are * presure, just call this function to recall all memory that are
* not yet referenced anymore. The cache take care of modification * not yet referenced anymore. The cache take care of modification
* on disk. * on disk.
* *
* @since 1.0.0 * @since 1.0.0
* @ingroup Eet_Group * @ingroup Eet_Group
*/ */
EAPI void eet_clearcache(void); EAPI void
eet_clearcache(void);
/** /**
* @defgroup Eet_File_Group Eet File Main Functions * @defgroup Eet_File_Group Eet File Main Functions
* *
* Functions to create, destroy and do basic manipulation of * Functions to create, destroy and do basic manipulation of
* #Eet_File handles. * #Eet_File handles.
* *
* @{ * @{
*/ */
/** /**
* @enum _Eet_File_Mode * @enum _Eet_File_Mode
* Modes that a file can be opened. * Modes that a file can be opened.
*/ */
typedef enum _Eet_File_Mode typedef enum _Eet_File_Mode
{ {
EET_FILE_MODE_INVALID = -1, EET_FILE_MODE_INVALID = -1,
EET_FILE_MODE_READ, /**< File is read-only. */ EET_FILE_MODE_READ, /**< File is read-only. */
EET_FILE_MODE_WRITE, /**< File is write-only. */ EET_FILE_MODE_WRITE, /**< File is write-only. */
EET_FILE_MODE_READ_WRITE /**< File is for both read and write */ EET_FILE_MODE_READ_WRITE /**< File is for both read and write */
} Eet_File_Mode; /**< Modes that a file can be opened. */ } Eet_File_Mode; /**< Modes that a file can be opened. */
/** /**
* @typedef Eet_File * @typedef Eet_File
* Opaque handle that defines an Eet file (or memory). * Opaque handle that defines an Eet file (or memory).
* *
* @see eet_open() * @see eet_open()
* @see eet_memopen_read() * @see eet_memopen_read()
* @see eet_close() * @see eet_close()
*/ */
typedef struct _Eet_File Eet_File; typedef struct _Eet_File Eet_File;
/** /**
* @typedef Eet_Dictionary * @typedef Eet_Dictionary
* Opaque handle that defines a file-backed (mmaped) dictionary of string * Opaque handle that defines a file-backed (mmaped) dictionary of strings.
s. */
*/ typedef struct _Eet_Dictionary Eet_Dictionary;
typedef struct _Eet_Dictionary Eet_Dictionary;
/** /**
* @} * @}
*/ */
/** /**
* Open an eet file on disk, and returns a handle to it. * Open an eet file on disk, and returns a handle to it.
* @param file The file path to the eet file. eg: @c "/tmp/file.eet". * @param file The file path to the eet file. eg: @c "/tmp/file.eet".
* @param mode The mode for opening. Either #EET_FILE_MODE_READ, * @param mode The mode for opening. Either #EET_FILE_MODE_READ,
* #EET_FILE_MODE_WRITE or #EET_FILE_MODE_READ_WRITE. * #EET_FILE_MODE_WRITE or #EET_FILE_MODE_READ_WRITE.
* @return An opened eet file handle. * @return An opened eet file handle.
* @ingroup Eet_File_Group * @ingroup Eet_File_Group
* *
* This function will open an exiting eet file for reading, and build * This function will open an exiting eet file for reading, and build
* the directory table in memory and return a handle to the file, if it * the directory table in memory and return a handle to the file, if it
* exists and can be read, and no memory errors occur on the way, otherw * exists and can be read, and no memory errors occur on the way, otherwise
ise * NULL will be returned.
* NULL will be returned. *
* * It will also open an eet file for writing. This will, if successful,
* It will also open an eet file for writing. This will, if successful, * delete the original file and replace it with a new empty file, till
* delete the original file and replace it with a new empty file, till * the eet file handle is closed or flushed. If it cannot be opened for
* the eet file handle is closed or flushed. If it cannot be opened for * writing or a memory error occurs, NULL is returned.
* writing or a memory error occurs, NULL is returned. *
* * You can also open the file for read/write. If you then write a key that
* You can also open the file for read/write. If you then write a key th * does not exist it will be created, if the key exists it will be replaced
at * by the new data.
* does not exist it will be created, if the key exists it will be repla *
ced * Example:
* by the new data. * @code
* * #include <Eet.h>
* Example: * #include <stdio.h>
* @code * #include <string.h>
* #include <Eet.h> *
* #include <stdio.h> * int
* #include <string.h> * main(int argc, char **argv)
* * {
* int * Eet_File *ef;
* main(int argc, char **argv) * char buf[1024], *ret, **list;
* { * int size, num, i;
* Eet_File *ef; *
* char buf[1024], *ret, **list; * eet_init();
* int size, num, i; *
* * strcpy(buf, "Here is a string of data to save!");
* eet_init(); *
* * ef = eet_open("/tmp/my_file.eet", EET_FILE_MODE_WRITE);
* strcpy(buf, "Here is a string of data to save!"); * if (!ef) return -1;
* * if (!eet_write(ef, "/key/to_store/at", buf, 1024, 1))
* ef = eet_open("/tmp/my_file.eet", EET_FILE_MODE_WRITE); * fprintf(stderr, "Error writing data!\n");
* if (!ef) return -1; * eet_close(ef);
* if (!eet_write(ef, "/key/to_store/at", buf, 1024, 1)) *
* fprintf(stderr, "Error writing data!\n"); * ef = eet_open("/tmp/my_file.eet", EET_FILE_MODE_READ);
* eet_close(ef); * if (!ef) return -1;
* * list = eet_list(ef, "*", &num);
* ef = eet_open("/tmp/my_file.eet", EET_FILE_MODE_READ); * if (list)
* if (!ef) return -1; * {
* list = eet_list(ef, "*", &num); * for (i = 0; i < num; i++)
* if (list) * printf("Key stored: %s\n", list[i]);
* { * free(list);
* for (i = 0; i < num; i++) * }
* printf("Key stored: %s\n", list[i]); * ret = eet_read(ef, "/key/to_store/at", &size);
* free(list); * if (ret)
* } * {
* ret = eet_read(ef, "/key/to_store/at", &size); * printf("Data read (%i bytes):\n%s\n", size, ret);
* if (ret) * free(ret);
* { * }
* printf("Data read (%i bytes):\n%s\n", size, ret); * eet_close(ef);
* free(ret); *
* } * eet_shutdown();
* eet_close(ef); *
* * return 0;
* eet_shutdown(); * }
* * @endcode
* return 0; *
* } * @since 1.0.0
* @endcode */
* EAPI Eet_File *
* @since 1.0.0 eet_open(const char *file,
*/ Eet_File_Mode mode);
EAPI Eet_File *eet_open(const char *file, Eet_File_Mode mode);
/** /**
* Open an eet file directly from a memory location. The data are not co * Open an eet file directly from a memory location. The data is not copied
pied, ,
* so you must keep them around as long as the eet file is open. Their i * so you must keep it around as long as the eet file is open. There is
s * currently no cache for this kind of Eet_File, so it's reopened every tim
* currently no cache for this kind of Eet_File, so it's reopen every ti e
me * you use eet_memopen_read.
* you do use eet_memopen_read. *
* * @since 1.1.0
* @since 1.1.0 * @ingroup Eet_File_Group
* @ingroup Eet_File_Group */
*/ EAPI Eet_File *
EAPI Eet_File *eet_memopen_read(const void *data, size_t size); eet_memopen_read(const void *data,
size_t size);
/** /**
* Get the mode an Eet_File was opened with. * Get the mode an Eet_File was opened with.
* @param ef A valid eet file handle. * @param ef A valid eet file handle.
* @return The mode ef was opened with. * @return The mode ef was opened with.
* *
* @since 1.0.0 * @since 1.0.0
* @ingroup Eet_File_Group * @ingroup Eet_File_Group
*/ */
EAPI Eet_File_Mode eet_mode_get(Eet_File *ef); 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 and writes pending.
* @param ef A valid eet file handle. * @param ef A valid eet file handle.
* *
* This function will flush any pending writes to disk if the eet file * This function will flush any pending writes to disk if the eet file
* was opened for write, and free all data associated with the file hand * was opened for write, and free all data associated with the file handle
le * and file, and close the file.
* and file, and close the file. *
* * If the eet file handle is not valid nothing will be done.
* If the eet file handle is not valid nothing will be done. *
* * @since 1.0.0
* @since 1.0.0 * @ingroup Eet_File_Group
* @ingroup Eet_File_Group */
*/ EAPI Eet_Error
EAPI Eet_Error eet_close(Eet_File *ef); eet_close(Eet_File *ef);
/** /**
* Sync content of an eet file handle, flushing pending writes. * Sync content of an eet file handle, flushing pending writes.
* @param ef A valid eet file handle. * @param ef A valid eet file handle.
* *
* This function will flush any pending writes to disk. The eet file mus * This function will flush any pending writes to disk. The eet file must
t * be opened for write.
* be opened for write. *
* * If the eet file handle is not valid nothing will be done.
* If the eet file handle is not valid nothing will be done. *
* * @since 1.2.4
* @since 1.2.4 * @ingroup Eet_File_Group
* @ingroup Eet_File_Group */
*/ EAPI Eet_Error
EAPI Eet_Error eet_sync(Eet_File *ef); eet_sync(Eet_File *ef);
/** /**
* Return a handle to the shared string dictionary of the Eet file * Return a handle to the shared string dictionary of the Eet file
* @param ef A valid eet file handle. * @param ef A valid eet file handle.
* @return A handle to the dictionary of the file * @return A handle to the dictionary of the file
* *
* This function returns a handle to the dictionary of an Eet file whose * This function returns a handle to the dictionary of an Eet file whose
* handle is @p ef, if a dictionary exists. NULL is returned otherwise o * handle is @p ef, if a dictionary exists. NULL is returned otherwise or
r * if the file handle is known to be invalid.
* if the file handle is known to be invalid. *
* * @see eet_dictionary_string_check() to know if given string came
* @see eet_dictionary_string_check() to know if given string came * from the dictionary or it was dynamically allocated using
* from the dictionary or it was dynamically allocated using * the #Eet_Data_Descriptor_Class instructrions.
* the #Eet_Data_Descriptor_Class instructrions. *
* * @since 1.0.0
* @since 1.0.0 * @ingroup Eet_File_Group
* @ingroup Eet_File_Group */
*/ EAPI Eet_Dictionary *
EAPI Eet_Dictionary *eet_dictionary_get(Eet_File *ef); eet_dictionary_get(Eet_File *ef);
/** /**
* Check if a given string comes from a given dictionary * Check if a given string comes from a given dictionary
* @param ed A valid dictionary handle * @param ed A valid dictionary handle
* @param string A valid 0 byte terminated C string * @param string A valid 0 byte terminated C string
* @return 1 if it is in the dictionary, 0 otherwise * @return 1 if it is in the dictionary, 0 otherwise
* *
* This checks the given dictionary to see if the given string is actual * This checks the given dictionary to see if the given string is actually
ly * inside that dictionary (i.e. comes from it) and returns 1 if it does.
* inside that dictionary (i.e. comes from it) and returns 1 if it does. * If the dictionary handle is invlide, the string is NULL or the string is
* If the dictionary handle is invlide, the string is NULL or the string * not in the dictionary, 0 is returned.
is *
* not in the dictionary, 0 is returned. * @since 1.0.0
* * @ingroup Eet_File_Group
* @since 1.0.0 */
* @ingroup Eet_File_Group EAPI int
*/ eet_dictionary_string_check(Eet_Dictionary *ed,
EAPI int eet_dictionary_string_check(Eet_Dictionary *ed, const char *str const char *string);
ing);
/** /**
* Read a specified entry from an eet file and return data * Read a specified entry from an eet file and return data
* @param ef A valid eet file handle opened for reading. * @param ef A valid eet file handle opened for reading.
* @param name Name of the entry. eg: "/base/file_i_want". * @param name Name of the entry. eg: "/base/file_i_want".
* @param size_ret Number of bytes read from entry and returned. * @param size_ret Number of bytes read from entry and returned.
* @return The data stored in that entry in the eet file. * @return The data stored in that entry in the eet file.
* *
* This function finds an entry in the eet file that is stored under the * This function finds an entry in the eet file that is stored under the
* name specified, and returns that data, decompressed, if successful. * name specified, and returns that data, decompressed, if successful.
* NULL is returned if the lookup fails or if memory errors are * NULL is returned if the lookup fails or if memory errors are
* encountered. It is the job of the calling program to call free() on * encountered. It is the job of the calling program to call free() on
* the returned data. The number of bytes in the returned data chunk are * the returned data. The number of bytes in the returned data chunk are
* placed in size_ret. * placed in size_ret.
* *
* If the eet file handle is not valid NULL is returned and size_ret is * If the eet file handle is not valid NULL is returned and size_ret is
* filled with 0. * filled with 0.
* *
* @see eet_read_cipher() * @see eet_read_cipher()
* *
* @since 1.0.0 * @since 1.0.0
* @ingroup Eet_File_Group * @ingroup Eet_File_Group
*/ */
EAPI void *eet_read(Eet_File *ef, const char *name, int *size_ret); EAPI void *
eet_read(Eet_File *ef,
const char *name,
int *size_ret);
/** /**
* Read a specified entry from an eet file and return data * Read a specified entry from an eet file and return data
* @param ef A valid eet file handle opened for reading. * @param ef A valid eet file handle opened for reading.
* @param name Name of the entry. eg: "/base/file_i_want". * @param name Name of the entry. eg: "/base/file_i_want".
* @param size_ret Number of bytes read from entry and returned. * @param size_ret Number of bytes read from entry and returned.
* @return The data stored in that entry in the eet file. * @return The data stored in that entry in the eet file.
* *
* This function finds an entry in the eet file that is stored under the * This function finds an entry in the eet file that is stored under the
* name specified, and returns that data if not compressed and successfu * name specified, and returns that data if not compressed and successful.
l. * NULL is returned if the lookup fails or if memory errors are
* NULL is returned if the lookup fails or if memory errors are * encountered or if the data is comrpessed. The calling program must never
* encountered or if the data is comrpessed. The calling program must ne * call free() on the returned data. The number of bytes in the returned
ver * data chunk are placed in size_ret.
* call free() on the returned data. The number of bytes in the returned *
* data chunk are placed in size_ret. * If the eet file handle is not valid NULL is returned and size_ret is
* * filled with 0.
* If the eet file handle is not valid NULL is returned and size_ret is *
* filled with 0. * @since 1.0.0
* * @ingroup Eet_File_Group
* @since 1.0.0 */
* @ingroup Eet_File_Group EAPI const void *
*/ eet_read_direct(Eet_File *ef,
EAPI const void *eet_read_direct(Eet_File *ef, const char *name, int *si const char *name,
ze_ret); int *size_ret);
/** /**
* Write a specified entry to an eet file handle * Write a specified entry to an eet file handle
* @param ef A valid eet file handle opened for writing. * @param ef A valid eet file handle opened for writing.
* @param name Name of the entry. eg: "/base/file_i_want". * @param name Name of the entry. eg: "/base/file_i_want".
* @param data Pointer to the data to be stored. * @param data Pointer to the data to be stored.
* @param size Length in bytes in the data to be stored. * @param size Length in bytes in the data to be stored.
* @param compress Compression flags (1 == compress, 0 = don't compress) * @param compress Compression flags (1 == compress, 0 = don't compress).
. * @return bytes written on successful write, 0 on failure.
* @return bytes written on successful write, 0 on failure. *
* * This function will write the specified chunk of data to the eet file
* This function will write the specified chunk of data to the eet file * and return greater than 0 on success. 0 will be returned on failure.
* and return greater than 0 on success. 0 will be returned on failure. *
* * The eet file handle must be a valid file handle for an eet file opened
* The eet file handle must be a valid file handle for an eet file opene * for writing. If it is not, 0 will be returned and no action will be
d * performed.
* for writing. If it is not, 0 will be returned and no action will be *
* performed. * Name, and data must not be NULL, and size must be > 0. If these
* * conditions are not met, 0 will be returned.
* Name, and data must not be NULL, and size must be > 0. If these *
* conditions are not met, 0 will be returned. * The data will be copied (and optionally compressed) in ram, pending
* * a flush to disk (it will stay in ram till the eet file handle is
* The data will be copied (and optionally compressed) in ram, pending * closed though).
* a flush to disk (it will stay in ram till the eet file handle is *
* closed though). * @see eet_write_cipher()
* *
* @see eet_write_cipher() * @since 1.0.0
* * @ingroup Eet_File_Group
* @since 1.0.0 */
* @ingroup Eet_File_Group EAPI int
*/ eet_write(Eet_File *ef,
EAPI int eet_write(Eet_File *ef, const char *name, const void *data, int const char *name,
size, int compress); const void *data,
int size,
int compress);
/** /**
* Delete a specified entry from an Eet file being written or re-written * Delete a specified entry from an Eet file being written or re-written
* @param ef A valid eet file handle opened for writing. * @param ef A valid eet file handle opened for writing.
* @param name Name of the entry. eg: "/base/file_i_want". * @param name Name of the entry. eg: "/base/file_i_want".
* @return Success or failure of the delete. * @return Success or failure of the delete.
* *
* This function will delete the specified chunk of data from the eet fi * This function will delete the specified chunk of data from the eet file
le * and return greater than 0 on success. 0 will be returned on failure.
* and return greater than 0 on success. 0 will be returned on failure. *
* * The eet file handle must be a valid file handle for an eet file opened
* The eet file handle must be a valid file handle for an eet file opene * for writing. If it is not, 0 will be returned and no action will be
d * performed.
* for writing. If it is not, 0 will be returned and no action will be *
* performed. * Name, must not be NULL, otherwise 0 will be returned.
* *
* Name, must not be NULL, otherwise 0 will be returned. * @since 1.0.0
* * @ingroup Eet_File_Group
* @since 1.0.0 */
* @ingroup Eet_File_Group EAPI int
*/ eet_delete(Eet_File *ef,
EAPI int eet_delete(Eet_File *ef, const char *name); const char *name);
/** /**
* List all entries in eet file matching shell glob. * Alias a specific section to another one. Destination may exist or not,
* @param ef A valid eet file handle. * no check are done.
* @param glob A shell glob to match against. * @param ef A valid eet file handle opened for writing.
* @param count_ret Number of entries found to match. * @param name Name of the entry. eg: "/base/file_i_want".
* @return Pointer to an array of strings. * @param destination Destionation of the alias. eg: "/base/the_real_stuff_
* i_want".
* This function will list all entries in the eet file matching the * @param compress Compression flags (1 == compress, 0 = don't compress).
* supplied shell glob and return an allocated list of their names, if * @return EINA_TRUE on success, EINA_FALSE on failure.
* there are any, and if no memory errors occur. *
* * Name and Destination must not be NULL, otherwhise EINA_FALSE will be ret
* The eet file handle must be valid and glob must not be NULL, or NULL urned.
* will be returned and count_ret will be filled with 0. *
* * @since 1.3.3
* The calling program must call free() on the array returned, but NOT * @ingroup Eet_File_Group
* on the string pointers in the array. They are taken as read-only */
* internals from the eet file handle. They are only valid as long as EAPI Eina_Bool
* the file handle is not closed. When it is closed those pointers in th eet_alias(Eet_File *ef,
e const char *name,
* array are now not valid and should not be used. const char *destination,
* int compress);
* On success the array returned will have a list of string pointers
* that are the names of the entries that matched, and count_ret will ha
ve
* the number of entries in this array placed in it.
*
* Hint: an easy way to list all entries in an eet file is to use a glob
* value of "*".
*
* @since 1.0.0
* @ingroup Eet_File_Group
*/
EAPI char **eet_list(Eet_File *ef, const char *glob, int *count_ret);
/** /**
* Return the number of entries in the specified eet file. * List all entries in eet file matching shell glob.
* @param ef A valid eet file handle. * @param ef A valid eet file handle.
* @return Number of entries in ef or -1 if the number of entries * @param glob A shell glob to match against.
* cannot be read due to open mode restrictions. * @param count_ret Number of entries found to match.
* * @return Pointer to an array of strings.
* @since 1.0.0 *
* @ingroup Eet_File_Group * This function will list all entries in the eet file matching the
*/ * supplied shell glob and return an allocated list of their names, if
EAPI int eet_num_entries(Eet_File *ef); * there are any, and if no memory errors occur.
*
* The eet file handle must be valid and glob must not be NULL, or NULL
* will be returned and count_ret will be filled with 0.
*
* The calling program must call free() on the array returned, but NOT
* on the string pointers in the array. They are taken as read-only
* internals from the eet file handle. They are only valid as long as
* the file handle is not closed. When it is closed those pointers in the
* array are now not valid and should not be used.
*
* On success the array returned will have a list of string pointers
* that are the names of the entries that matched, and count_ret will have
* the number of entries in this array placed in it.
*
* Hint: an easy way to list all entries in an eet file is to use a glob
* value of "*".
*
* @since 1.0.0
* @ingroup Eet_File_Group
*/
EAPI char **
eet_list(Eet_File *ef,
const char *glob,
int *count_ret);
/** /**
* @defgroup Eet_File_Cipher_Group Eet File Ciphered Main Functions * Return the number of entries in the specified eet file.
* * @param ef A valid eet file handle.
* Most of the @ref Eet_File_Group have alternative versions that * @return Number of entries in ef or -1 if the number of entries
* accounts for ciphers to protect their content. * cannot be read due to open mode restrictions.
* *
* @see @ref Eet_Cipher_Group * @since 1.0.0
* * @ingroup Eet_File_Group
* @ingroup Eet_File_Group */
*/ EAPI int
eet_num_entries(Eet_File *ef);
/** /**
* Read a specified entry from an eet file and return data using a ciphe * @defgroup Eet_File_Cipher_Group Eet File Ciphered Main Functions
r. *
* @param ef A valid eet file handle opened for reading. * Most of the @ref Eet_File_Group have alternative versions that
* @param name Name of the entry. eg: "/base/file_i_want". * accounts for ciphers to protect their content.
* @param size_ret Number of bytes read from entry and returned. *
* @param cipher_key The key to use as cipher. * @see @ref Eet_Cipher_Group
* @return The data stored in that entry in the eet file. *
* * @ingroup Eet_File_Group
* This function finds an entry in the eet file that is stored under the */
* name specified, and returns that data, decompressed, if successful.
* NULL is returned if the lookup fails or if memory errors are
* encountered. It is the job of the calling program to call free() on
* the returned data. The number of bytes in the returned data chunk are
* placed in size_ret.
*
* If the eet file handle is not valid NULL is returned and size_ret is
* filled with 0.
*
* @see eet_read()
*
* @since 1.0.0
* @ingroup Eet_File_Cipher_Group
*/
EAPI void *eet_read_cipher(Eet_File *ef, const char *name, int *size_ret
, const char *cipher_key);
/** /**
* Write a specified entry to an eet file handle using a cipher. * Read a specified entry from an eet file and return data using a cipher.
* @param ef A valid eet file handle opened for writing. * @param ef A valid eet file handle opened for reading.
* @param name Name of the entry. eg: "/base/file_i_want". * @param name Name of the entry. eg: "/base/file_i_want".
* @param data Pointer to the data to be stored. * @param size_ret Number of bytes read from entry and returned.
* @param size Length in bytes in the data to be stored. * @param cipher_key The key to use as cipher.
* @param compress Compression flags (1 == compress, 0 = don't compress) * @return The data stored in that entry in the eet file.
. *
* @param cipher_key The key to use as cipher. * This function finds an entry in the eet file that is stored under the
* @return bytes written on successful write, 0 on failure. * name specified, and returns that data, decompressed, if successful.
* * NULL is returned if the lookup fails or if memory errors are
* This function will write the specified chunk of data to the eet file * encountered. It is the job of the calling program to call free() on
* and return greater than 0 on success. 0 will be returned on failure. * the returned data. The number of bytes in the returned data chunk are
* * placed in size_ret.
* The eet file handle must be a valid file handle for an eet file opene *
d * If the eet file handle is not valid NULL is returned and size_ret is
* for writing. If it is not, 0 will be returned and no action will be * filled with 0.
* performed. *
* * @see eet_read()
* Name, and data must not be NULL, and size must be > 0. If these *
* conditions are not met, 0 will be returned. * @since 1.0.0
* * @ingroup Eet_File_Cipher_Group
* The data will be copied (and optionally compressed) in ram, pending */
* a flush to disk (it will stay in ram till the eet file handle is EAPI void *
* closed though). eet_read_cipher(Eet_File *ef,
* const char *name,
* @see eet_write() int *size_ret,
* const char *cipher_key);
* @since 1.0.0
* @ingroup Eet_File_Cipher_Group
*/
EAPI int eet_write_cipher(Eet_File *ef, const char *name, const void *da
ta, int size, int compress, const char *cipher_key);
/** /**
* @defgroup Eet_File_Image_Group Image Store and Load * Write a specified entry to an eet file handle using a cipher.
* * @param ef A valid eet file handle opened for writing.
* Eet efficiently stores and loads images, including alpha * @param name Name of the entry. eg: "/base/file_i_want".
* channels and lossy compressions. * @param data Pointer to the data to be stored.
*/ * @param size Length in bytes in the data to be stored.
* @param compress Compression flags (1 == compress, 0 = don't compress).
* @param cipher_key The key to use as cipher.
* @return bytes written on successful write, 0 on failure.
*
* This function will write the specified chunk of data to the eet file
* and return greater than 0 on success. 0 will be returned on failure.
*
* The eet file handle must be a valid file handle for an eet file opened
* for writing. If it is not, 0 will be returned and no action will be
* performed.
*
* Name, and data must not be NULL, and size must be > 0. If these
* conditions are not met, 0 will be returned.
*
* The data will be copied (and optionally compressed) in ram, pending
* a flush to disk (it will stay in ram till the eet file handle is
* closed though).
*
* @see eet_write()
*
* @since 1.0.0
* @ingroup Eet_File_Cipher_Group
*/
EAPI int
eet_write_cipher(Eet_File *ef,
const char *name,
const void *data,
int size,
int compress,
const char *cipher_key);
/** /**
* Read just the header data for an image and dont decode the pixels. * @defgroup Eet_File_Image_Group Image Store and Load
* @param ef A valid eet file handle opened for reading. *
* @param name Name of the entry. eg: "/base/file_i_want". * Eet efficiently stores and loads images, including alpha
* @param w A pointer to the unsigned int to hold the width in pixels. * channels and lossy compressions.
* @param h A pointer to the unsigned int to hold the height in pixels. */
* @param alpha A pointer to the int to hold the alpha flag.
* @param compress A pointer to the int to hold the compression amount.
* @param quality A pointer to the int to hold the quality amount.
* @param lossy A pointer to the int to hold the lossiness flag.
* @return 1 on successfull decode, 0 otherwise
*
* This function reads an image from an eet file stored under the named
* key in the eet file and return a pointer to the decompressed pixel da
ta.
*
* The other parameters of the image (width, height etc.) are placed int
o
* the values pointed to (they must be supplied). The pixel data is a li
near
* array of pixels starting from the top-left of the image scanning row
by
* row from left to right. Each pile is a 32bit value, with the high byt
e
* being the alpha channel, the next being red, then green, and the low
byte
* being blue. The width and height are measured in pixels and will be
* greater than 0 when returned. The alpha flag is either 0 or 1. 0 deno
tes
* that the alpha channel is not used. 1 denotes that it is significant.
* Compress is filled with the compression value/amount the image was
* stored with. The quality value is filled with the quality encoding of
* the image file (0 - 100). The lossy flags is either 0 or 1 as to if
* the image was encoded lossily or not.
*
* On success the function returns 1 indicating the header was read and
* decoded properly, or 0 on failure.
*
* @see eet_data_image_header_read_cipher()
*
* @since 1.0.0
* @ingroup Eet_File_Image_Group
*/
EAPI int eet_data_image_header_read(Eet_File *ef, const char *name, unsi
gned int *w, unsigned int *h, int *alpha, int *compress, int *quality, int
*lossy);
/** /**
* Read image data from the named key in the eet file. * Read just the header data for an image and dont decode the pixels.
* @param ef A valid eet file handle opened for reading. * @param ef A valid eet file handle opened for reading.
* @param name Name of the entry. eg: "/base/file_i_want". * @param name Name of the entry. eg: "/base/file_i_want".
* @param w A pointer to the unsigned int to hold the width in pixels. * @param w A pointer to the unsigned int to hold the width in pixels.
* @param h A pointer to the unsigned int to hold the height in pixels. * @param h A pointer to the unsigned int to hold the height in pixels.
* @param alpha A pointer to the int to hold the alpha flag. * @param alpha A pointer to the int to hold the alpha flag.
* @param compress A pointer to the int to hold the compression amount. * @param compress A pointer to the int to hold the compression amount.
* @param quality A pointer to the int to hold the quality amount. * @param quality A pointer to the int to hold the quality amount.
* @param lossy A pointer to the int to hold the lossiness flag. * @param lossy A pointer to the int to hold the lossiness flag.
* @return The image pixel data decoded * @return 1 on successful decode, 0 otherwise
* *
* This function reads an image from an eet file stored under the named * This function reads an image from an eet file stored under the named
* key in the eet file and return a pointer to the decompressed pixel da * key in the eet file and return a pointer to the decompressed pixel data.
ta. *
* * The other parameters of the image (width, height etc.) are placed into
* The other parameters of the image (width, height etc.) are placed int * the values pointed to (they must be supplied). The pixel data is a linea
o r
* the values pointed to (they must be supplied). The pixel data is a li * array of pixels starting from the top-left of the image scanning row by
near * row from left to right. Each pile is a 32bit value, with the high byte
* array of pixels starting from the top-left of the image scanning row * being the alpha channel, the next being red, then green, and the low byt
by e
* row from left to right. Each pile is a 32bit value, with the high byt * being blue. The width and height are measured in pixels and will be
e * greater than 0 when returned. The alpha flag is either 0 or 1. 0 denotes
* being the alpha channel, the next being red, then green, and the low * that the alpha channel is not used. 1 denotes that it is significant.
byte * Compress is filled with the compression value/amount the image was
* being blue. The width and height are measured in pixels and will be * stored with. The quality value is filled with the quality encoding of
* greater than 0 when returned. The alpha flag is either 0 or 1. 0 deno * the image file (0 - 100). The lossy flags is either 0 or 1 as to if
tes * the image was encoded lossily or not.
* that the alpha channel is not used. 1 denotes that it is significant. *
* Compress is filled with the compression value/amount the image was * On success the function returns 1 indicating the header was read and
* stored with. The quality value is filled with the quality encoding of * decoded properly, or 0 on failure.
* the image file (0 - 100). The lossy flags is either 0 or 1 as to if *
* the image was encoded lossily or not. * @see eet_data_image_header_read_cipher()
* *
* On success the function returns a pointer to the image data decoded. * @since 1.0.0
The * @ingroup Eet_File_Image_Group
* calling application is responsible for calling free() on the image da */
ta EAPI int
* when it is done with it. On failure NULL is returned and the paramete eet_data_image_header_read(Eet_File *ef,
r const char *name,
* values may not contain any sensible data. unsigned int *w,
* unsigned int *h,
* @see eet_data_image_read_cipher() int *alpha,
* int *compress,
* @since 1.0.0 int *quality,
* @ingroup Eet_File_Image_Group int *lossy);
*/
EAPI void *eet_data_image_read(Eet_File *ef, const char *name, unsigned
int *w, unsigned int *h, int *alpha, int *compress, int *quality, int *loss
y);
/** /**
* Read image data from the named key in the eet file. * Read image data from the named key in the eet file.
* @param ef A valid eet file handle opened for reading. * @param ef A valid eet file handle opened for reading.
* @param name Name of the entry. eg: "/base/file_i_want". * @param name Name of the entry. eg: "/base/file_i_want".
* @param src_x The starting x coordinate from where to dump the stream. * @param w A pointer to the unsigned int to hold the width in pixels.
* @param src_y The starting y coordinate from where to dump the stream. * @param h A pointer to the unsigned int to hold the height in pixels.
* @param d A pointer to the pixel surface. * @param alpha A pointer to the int to hold the alpha flag.
* @param w The expected width in pixels of the pixel surface to decode. * @param compress A pointer to the int to hold the compression amount.
* @param h The expected height in pixels of the pixel surface to decode * @param quality A pointer to the int to hold the quality amount.
. * @param lossy A pointer to the int to hold the lossiness flag.
* @param row_stride The length of a pixels line in the destination surf * @return The image pixel data decoded
ace. *
* @param alpha A pointer to the int to hold the alpha flag. * This function reads an image from an eet file stored under the named
* @param compress A pointer to the int to hold the compression amount. * key in the eet file and return a pointer to the decompressed pixel data.
* @param quality A pointer to the int to hold the quality amount. *
* @param lossy A pointer to the int to hold the lossiness flag. * The other parameters of the image (width, height etc.) are placed into
* @return 1 on success, 0 otherwise. * the values pointed to (they must be supplied). The pixel data is a linea
* r
* This function reads an image from an eet file stored under the named * array of pixels starting from the top-left of the image scanning row by
* key in the eet file and return a pointer to the decompressed pixel da * row from left to right. Each pile is a 32bit value, with the high byte
ta. * being the alpha channel, the next being red, then green, and the low byt
* e
* The other parameters of the image (width, height etc.) are placed int * being blue. The width and height are measured in pixels and will be
o * greater than 0 when returned. The alpha flag is either 0 or 1. 0 denotes
* the values pointed to (they must be supplied). The pixel data is a li * that the alpha channel is not used. 1 denotes that it is significant.
near * Compress is filled with the compression value/amount the image was
* array of pixels starting from the top-left of the image scanning row * stored with. The quality value is filled with the quality encoding of
by * the image file (0 - 100). The lossy flags is either 0 or 1 as to if
* row from left to right. Each pile is a 32bit value, with the high byt * the image was encoded lossily or not.
e *
* being the alpha channel, the next being red, then green, and the low * On success the function returns a pointer to the image data decoded. The
byte * calling application is responsible for calling free() on the image data
* being blue. The width and height are measured in pixels and will be * when it is done with it. On failure NULL is returned and the parameter
* greater than 0 when returned. The alpha flag is either 0 or 1. 0 deno * values may not contain any sensible data.
tes *
* that the alpha channel is not used. 1 denotes that it is significant. * @see eet_data_image_read_cipher()
* Compress is filled with the compression value/amount the image was *
* stored with. The quality value is filled with the quality encoding of * @since 1.0.0
* the image file (0 - 100). The lossy flags is either 0 or 1 as to if * @ingroup Eet_File_Image_Group
* the image was encoded lossily or not. */
* EAPI void *
* On success the function returns 1, and 0 on failure. On failure the eet_data_image_read(Eet_File *ef,
* parameter values may not contain any sensible data. const char *name,
* unsigned int *w,
* @see eet_data_image_read_to_surface_cipher() unsigned int *h,
* int *alpha,
* @since 1.0.2 int *compress,
* @ingroup Eet_File_Image_Group int *quality,
*/ int *lossy);
EAPI int eet_data_image_read_to_surface(Eet_File *ef, const char *name,
unsigned int src_x, unsigned int src_y, unsigned int *d, unsigned int w, un
signed int h, unsigned int row_stride, int *alpha, int *compress, int *qual
ity, int *lossy);
/** /**
* Write image data to the named key in an eet file. * Read image data from the named key in the eet file.
* @param ef A valid eet file handle opened for writing. * @param ef A valid eet file handle opened for reading.
* @param name Name of the entry. eg: "/base/file_i_want". * @param name Name of the entry. eg: "/base/file_i_want".
* @param data A pointer to the image pixel data. * @param src_x The starting x coordinate from where to dump the stream.
* @param w The width of the image in pixels. * @param src_y The starting y coordinate from where to dump the stream.
* @param h The height of the image in pixels. * @param d A pointer to the pixel surface.
* @param alpha The alpha channel flag. * @param w The expected width in pixels of the pixel surface to decode.
* @param compress The compression amount. * @param h The expected height in pixels of the pixel surface to decode.
* @param quality The quality encoding amount. * @param row_stride The length of a pixels line in the destination surface
* @param lossy The lossiness flag. .
* @return Success if the data was encoded and written or not. * @param alpha A pointer to the int to hold the alpha flag.
* * @param compress A pointer to the int to hold the compression amount.
* This function takes image pixel data and encodes it in an eet file * @param quality A pointer to the int to hold the quality amount.
* stored under the supplied name key, and returns how many bytes were * @param lossy A pointer to the int to hold the lossiness flag.
* actually written to encode the image data. * @return 1 on success, 0 otherwise.
* *
* The data expected is the same format as returned by eet_data_image_re * This function reads an image from an eet file stored under the named
ad. * key in the eet file and return a pointer to the decompressed pixel data.
* If this is not the case weird things may happen. Width and height mus *
t * The other parameters of the image (width, height etc.) are placed into
* be between 1 and 8000 pixels. The alpha flags can be 0 or 1 (0 meanin * the values pointed to (they must be supplied). The pixel data is a linea
g r
* the alpha values are not useful and 1 meaning they are). Compress can * array of pixels starting from the top-left of the image scanning row by
* be from 0 to 9 (0 meaning no compression, 9 meaning full compression) * row from left to right. Each pile is a 32bit value, with the high byte
. * being the alpha channel, the next being red, then green, and the low byt
* This is only used if the image is not lossily encoded. Quality is use e
d on * being blue. The width and height are measured in pixels and will be
* lossy compression and should be a value from 0 to 100. The lossy flag * greater than 0 when returned. The alpha flag is either 0 or 1. 0 denotes
* can be 0 or 1. 0 means encode losslessly and 1 means to encode with * that the alpha channel is not used. 1 denotes that it is significant.
* image quality loss (but then have a much smaller encoding). * Compress is filled with the compression value/amount the image was
* * stored with. The quality value is filled with the quality encoding of
* On success this function returns the number of bytes that were requir * the image file (0 - 100). The lossy flags is either 0 or 1 as to if
ed * the image was encoded lossily or not.
* to encode the image data, or on failure it returns 0. *
* * On success the function returns 1, and 0 on failure. On failure the
* @see eet_data_image_write_cipher() * parameter values may not contain any sensible data.
* *
* @since 1.0.0 * @see eet_data_image_read_to_surface_cipher()
* @ingroup Eet_File_Image_Group *
*/ * @since 1.0.2
EAPI int eet_data_image_write(Eet_File *ef, const char *name, const void * @ingroup Eet_File_Image_Group
*data, unsigned int w, unsigned int h, int alpha, int compress, int qualit */
y, int lossy); EAPI int
eet_data_image_read_to_surface(Eet_File *ef,
const char *name,
unsigned int src_x,
unsigned int src_y,
unsigned int *d,
unsigned int w,
unsigned int h,
unsigned int row_stride,
int *alpha,
int *compress,
int *quality,
int *lossy);
/** /**
* Decode Image data header only to get information. * Write image data to the named key in an eet file.
* @param data The encoded pixel data. * @param ef A valid eet file handle opened for writing.
* @param size The size, in bytes, of the encoded pixel data. * @param name Name of the entry. eg: "/base/file_i_want".
* @param w A pointer to the unsigned int to hold the width in pixels. * @param data A pointer to the image pixel data.
* @param h A pointer to the unsigned int to hold the height in pixels. * @param w The width of the image in pixels.
* @param alpha A pointer to the int to hold the alpha flag. * @param h The height of the image in pixels.
* @param compress A pointer to the int to hold the compression amount. * @param alpha The alpha channel flag.
* @param quality A pointer to the int to hold the quality amount. * @param compress The compression amount.
* @param lossy A pointer to the int to hold the lossiness flag. * @param quality The quality encoding amount.
* @return 1 on success, 0 on failure. * @param lossy The lossiness flag.
* * @return Success if the data was encoded and written or not.
* This function takes encoded pixel data and decodes it into raw RGBA *
* pixels on success. * This function takes image pixel data and encodes it in an eet file
* * stored under the supplied name key, and returns how many bytes were
* The other parameters of the image (width, height etc.) are placed int * actually written to encode the image data.
o *
* the values pointed to (they must be supplied). The pixel data is a li * The data expected is the same format as returned by eet_data_image_read.
near * If this is not the case weird things may happen. Width and height must
* array of pixels starting from the top-left of the image scanning row * be between 1 and 8000 pixels. The alpha flags can be 0 or 1 (0 meaning
by * the alpha values are not useful and 1 meaning they are). Compress can
* row from left to right. Each pixel is a 32bit value, with the high by * be from 0 to 9 (0 meaning no compression, 9 meaning full compression).
te * This is only used if the image is not lossily encoded. Quality is used o
* being the alpha channel, the next being red, then green, and the low n
byte * lossy compression and should be a value from 0 to 100. The lossy flag
* being blue. The width and height are measured in pixels and will be * can be 0 or 1. 0 means encode losslessly and 1 means to encode with
* greater than 0 when returned. The alpha flag is either 0 or 1. 0 deno * image quality loss (but then have a much smaller encoding).
tes *
* that the alpha channel is not used. 1 denotes that it is significant. * On success this function returns the number of bytes that were required
* Compress is filled with the compression value/amount the image was * to encode the image data, or on failure it returns 0.
* stored with. The quality value is filled with the quality encoding of *
* the image file (0 - 100). The lossy flags is either 0 or 1 as to if * @see eet_data_image_write_cipher()
* the image was encoded lossily or not. *
* * @since 1.0.0
* On success the function returns 1 indicating the header was read and * @ingroup Eet_File_Image_Group
* decoded properly, or 0 on failure. */
* EAPI int
* @see eet_data_image_header_decode_cipher() eet_data_image_write(Eet_File *ef,
* const char *name,
* @since 1.0.0 const void *data,
* @ingroup Eet_File_Image_Group unsigned int w,
*/ unsigned int h,
EAPI int eet_data_image_header_decode(const void *data, int size, unsign int alpha,
ed int *w, unsigned int *h, int *alpha, int *compress, int *quality, int *l int compress,
ossy); int quality,
int lossy);
/** /**
* Decode Image data into pixel data. * Decode Image data header only to get information.
* @param data The encoded pixel data. * @param data The encoded pixel data.
* @param size The size, in bytes, of the encoded pixel data. * @param size The size, in bytes, of the encoded pixel data.
* @param w A pointer to the unsigned int to hold the width in pixels. * @param w A pointer to the unsigned int to hold the width in pixels.
* @param h A pointer to the unsigned int to hold the height in pixels. * @param h A pointer to the unsigned int to hold the height in pixels.
* @param alpha A pointer to the int to hold the alpha flag. * @param alpha A pointer to the int to hold the alpha flag.
* @param compress A pointer to the int to hold the compression amount. * @param compress A pointer to the int to hold the compression amount.
* @param quality A pointer to the int to hold the quality amount. * @param quality A pointer to the int to hold the quality amount.
* @param lossy A pointer to the int to hold the lossiness flag. * @param lossy A pointer to the int to hold the lossiness flag.
* @return The image pixel data decoded * @return 1 on success, 0 on failure.
* *
* This function takes encoded pixel data and decodes it into raw RGBA * This function takes encoded pixel data and decodes it into raw RGBA
* pixels on success. * pixels on success.
* *
* The other parameters of the image (width, height etc.) are placed int * The other parameters of the image (width, height etc.) are placed into
o * the values pointed to (they must be supplied). The pixel data is a linea
* the values pointed to (they must be supplied). The pixel data is a li r
near * array of pixels starting from the top-left of the image scanning row by
* array of pixels starting from the top-left of the image scanning row * row from left to right. Each pixel is a 32bit value, with the high byte
by * being the alpha channel, the next being red, then green, and the low byt
* row from left to right. Each pixel is a 32bit value, with the high by e
te * being blue. The width and height are measured in pixels and will be
* being the alpha channel, the next being red, then green, and the low * greater than 0 when returned. The alpha flag is either 0 or 1. 0 denotes
byte * that the alpha channel is not used. 1 denotes that it is significant.
* being blue. The width and height are measured in pixels and will be * Compress is filled with the compression value/amount the image was
* greater than 0 when returned. The alpha flag is either 0 or 1. 0 deno * stored with. The quality value is filled with the quality encoding of
tes * the image file (0 - 100). The lossy flags is either 0 or 1 as to if
* that the alpha channel is not used. 1 denotes that it is significant. * the image was encoded lossily or not.
* Compress is filled with the compression value/amount the image was *
* stored with. The quality value is filled with the quality encoding of * On success the function returns 1 indicating the header was read and
* the image file (0 - 100). The lossy flags is either 0 or 1 as to if * decoded properly, or 0 on failure.
* the image was encoded lossily or not. *
* * @see eet_data_image_header_decode_cipher()
* On success the function returns a pointer to the image data decoded. *
The * @since 1.0.0
* calling application is responsible for calling free() on the image da * @ingroup Eet_File_Image_Group
ta */
* when it is done with it. On failure NULL is returned and the paramete EAPI int
r eet_data_image_header_decode(const void *data,
* values may not contain any sensible data. int size,
* unsigned int *w,
* @see eet_data_image_decode_cipher() unsigned int *h,
* int *alpha,
* @since 1.0.0 int *compress,
* @ingroup Eet_File_Image_Group int *quality,
*/ int *lossy);
EAPI void *eet_data_image_decode(const void *data, int size, unsigned in
t *w, unsigned int *h, int *alpha, int *compress, int *quality, int *lossy)
;
/** /**
* Decode Image data into pixel data. * Decode Image data into pixel data.
* @param data The encoded pixel data. * @param data The encoded pixel data.
* @param size The size, in bytes, of the encoded pixel data. * @param size The size, in bytes, of the encoded pixel data.
* @param src_x The starting x coordinate from where to dump the stream. * @param w A pointer to the unsigned int to hold the width in pixels.
* @param src_y The starting y coordinate from where to dump the stream. * @param h A pointer to the unsigned int to hold the height in pixels.
* @param d A pointer to the pixel surface. * @param alpha A pointer to the int to hold the alpha flag.
* @param w The expected width in pixels of the pixel surface to decode. * @param compress A pointer to the int to hold the compression amount.
* @param h The expected height in pixels of the pixel surface to decode * @param quality A pointer to the int to hold the quality amount.
. * @param lossy A pointer to the int to hold the lossiness flag.
* @param row_stride The length of a pixels line in the destination surf * @return The image pixel data decoded
ace. *
* @param alpha A pointer to the int to hold the alpha flag. * This function takes encoded pixel data and decodes it into raw RGBA
* @param compress A pointer to the int to hold the compression amount. * pixels on success.
* @param quality A pointer to the int to hold the quality amount. *
* @param lossy A pointer to the int to hold the lossiness flag. * The other parameters of the image (width, height etc.) are placed into
* @return 1 on success, 0 otherwise. * the values pointed to (they must be supplied). The pixel data is a linea
* r
* This function takes encoded pixel data and decodes it into raw RGBA * array of pixels starting from the top-left of the image scanning row by
* pixels on success. * row from left to right. Each pixel is a 32bit value, with the high byte
* * being the alpha channel, the next being red, then green, and the low byt
* The other parameters of the image (alpha, compress etc.) are placed i e
nto * being blue. The width and height are measured in pixels and will be
* the values pointed to (they must be supplied). The pixel data is a li * greater than 0 when returned. The alpha flag is either 0 or 1. 0 denotes
near * that the alpha channel is not used. 1 denotes that it is significant.
* array of pixels starting from the top-left of the image scanning row * Compress is filled with the compression value/amount the image was
by * stored with. The quality value is filled with the quality encoding of
* row from left to right. Each pixel is a 32bit value, with the high by * the image file (0 - 100). The lossy flags is either 0 or 1 as to if
te * the image was encoded lossily or not.
* being the alpha channel, the next being red, then green, and the low *
byte * On success the function returns a pointer to the image data decoded. The
* being blue. The width and height are measured in pixels and will be * calling application is responsible for calling free() on the image data
* greater than 0 when returned. The alpha flag is either 0 or 1. 0 deno * when it is done with it. On failure NULL is returned and the parameter
tes * values may not contain any sensible data.
* that the alpha channel is not used. 1 denotes that it is significant. *
* Compress is filled with the compression value/amount the image was * @see eet_data_image_decode_cipher()
* stored with. The quality value is filled with the quality encoding of *
* the image file (0 - 100). The lossy flags is either 0 or 1 as to if * @since 1.0.0
* the image was encoded lossily or not. * @ingroup Eet_File_Image_Group
* */
* On success the function returns 1, and 0 on failure. On failure the EAPI void *
* parameter values may not contain any sensible data. eet_data_image_decode(const void *data,
* int size,
* @see eet_data_image_decode_to_surface_cipher() unsigned int *w,
* unsigned int *h,
* @since 1.0.2 int *alpha,
* @ingroup Eet_File_Image_Group int *compress,
*/ int *quality,
EAPI int eet_data_image_decode_to_surface(const void *data, int size, un int *lossy);
signed int src_x, unsigned int src_y, unsigned int *d, unsigned int w, unsi
gned int h, unsigned int row_stride, int *alpha, int *compress, int *qualit
y, int *lossy);
/** /**
* Encode image data for storage or transmission. * Decode Image data into pixel data.
* @param data A pointer to the image pixel data. * @param data The encoded pixel data.
* @param size_ret A pointer to an int to hold the size of the returned * @param size The size, in bytes, of the encoded pixel data.
data. * @param src_x The starting x coordinate from where to dump the stream.
* @param w The width of the image in pixels. * @param src_y The starting y coordinate from where to dump the stream.
* @param h The height of the image in pixels. * @param d A pointer to the pixel surface.
* @param alpha The alpha channel flag. * @param w The expected width in pixels of the pixel surface to decode.
* @param compress The compression amount. * @param h The expected height in pixels of the pixel surface to decode.
* @param quality The quality encoding amount. * @param row_stride The length of a pixels line in the destination surface
* @param lossy The lossiness flag. .
* @return The encoded image data. * @param alpha A pointer to the int to hold the alpha flag.
* * @param compress A pointer to the int to hold the compression amount.
* This function stakes image pixel data and encodes it with compression * @param quality A pointer to the int to hold the quality amount.
and * @param lossy A pointer to the int to hold the lossiness flag.
* possible loss of quality (as a trade off for size) for storage or * @return 1 on success, 0 otherwise.
* transmission to another system. *
* * This function takes encoded pixel data and decodes it into raw RGBA
* The data expected is the same format as returned by eet_data_image_re * pixels on success.
ad. *
* If this is not the case weird things may happen. Width and height mus * The other parameters of the image (alpha, compress etc.) are placed into
t * the values pointed to (they must be supplied). The pixel data is a linea
* be between 1 and 8000 pixels. The alpha flags can be 0 or 1 (0 meanin r
g * array of pixels starting from the top-left of the image scanning row by
* the alpha values are not useful and 1 meaning they are). Compress can * row from left to right. Each pixel is a 32bit value, with the high byte
* be from 0 to 9 (0 meaning no compression, 9 meaning full compression) * being the alpha channel, the next being red, then green, and the low byt
. e
* This is only used if the image is not lossily encoded. Quality is use * being blue. The width and height are measured in pixels and will be
d on * greater than 0 when returned. The alpha flag is either 0 or 1. 0 denotes
* lossy compression and should be a value from 0 to 100. The lossy flag * that the alpha channel is not used. 1 denotes that it is significant.
* can be 0 or 1. 0 means encode losslessly and 1 means to encode with * Compress is filled with the compression value/amount the image was
* image quality loss (but then have a much smaller encoding). * stored with. The quality value is filled with the quality encoding of
* * the image file (0 - 100). The lossy flags is either 0 or 1 as to if
* On success this function returns a pointer to the encoded data that y * the image was encoded lossily or not.
ou *
* can free with free() when no longer needed. * On success the function returns 1, and 0 on failure. On failure the
* * parameter values may not contain any sensible data.
* @see eet_data_image_encode_cipher() *
* * @see eet_data_image_decode_to_surface_cipher()
* @since 1.0.0 *
* @ingroup Eet_File_Image_Group * @since 1.0.2
*/ * @ingroup Eet_File_Image_Group
EAPI void *eet_data_image_encode(const void *data, int *size_ret, unsign */
ed int w, unsigned int h, int alpha, int compress, int quality, int lossy); EAPI int
eet_data_image_decode_to_surface(const void *data,
int size,
unsigned int src_x,
unsigned int src_y,
unsigned int *d,
unsigned int w,
unsigned int h,
unsigned int row_stride,
int *alpha,
int *compress,
int *quality,
int *lossy);
/** /**
* @defgroup Eet_File_Image_Cipher_Group Image Store and Load using a Ci * Encode image data for storage or transmission.
pher * @param data A pointer to the image pixel data.
* * @param size_ret A pointer to an int to hold the size of the returned dat
* Most of the @ref Eet_File_Image_Group have alternative versions a.
* that accounts for ciphers to protect their content. * @param w The width of the image in pixels.
* * @param h The height of the image in pixels.
* @see @ref Eet_Cipher_Group * @param alpha The alpha channel flag.
* * @param compress The compression amount.
* @ingroup Eet_File_Image_Group * @param quality The quality encoding amount.
*/ * @param lossy The lossiness flag.
* @return The encoded image data.
*
* This function stakes image pixel data and encodes it with compression an
d
* possible loss of quality (as a trade off for size) for storage or
* transmission to another system.
*
* The data expected is the same format as returned by eet_data_image_read.
* If this is not the case weird things may happen. Width and height must
* be between 1 and 8000 pixels. The alpha flags can be 0 or 1 (0 meaning
* the alpha values are not useful and 1 meaning they are). Compress can
* be from 0 to 9 (0 meaning no compression, 9 meaning full compression).
* This is only used if the image is not lossily encoded. Quality is used o
n
* lossy compression and should be a value from 0 to 100. The lossy flag
* can be 0 or 1. 0 means encode losslessly and 1 means to encode with
* image quality loss (but then have a much smaller encoding).
*
* On success this function returns a pointer to the encoded data that you
* can free with free() when no longer needed.
*
* @see eet_data_image_encode_cipher()
*
* @since 1.0.0
* @ingroup Eet_File_Image_Group
*/
EAPI void *
eet_data_image_encode(const void *data,
int *size_ret,
unsigned int w,
unsigned int h,
int alpha,
int compress,
int quality,
int lossy);
/** /**
* Read just the header data for an image and dont decode the pixels usi * @defgroup Eet_File_Image_Cipher_Group Image Store and Load using a Ciphe
ng a cipher. r
* @param ef A valid eet file handle opened for reading. *
* @param name Name of the entry. eg: "/base/file_i_want". * Most of the @ref Eet_File_Image_Group have alternative versions
* @param cipher_key The key to use as cipher. * that accounts for ciphers to protect their content.
* @param w A pointer to the unsigned int to hold the width in pixels. *
* @param h A pointer to the unsigned int to hold the height in pixels. * @see @ref Eet_Cipher_Group
* @param alpha A pointer to the int to hold the alpha flag. *
* @param compress A pointer to the int to hold the compression amount. * @ingroup Eet_File_Image_Group
* @param quality A pointer to the int to hold the quality amount. */
* @param lossy A pointer to the int to hold the lossiness flag.
* @return 1 on successfull decode, 0 otherwise
*
* This function reads an image from an eet file stored under the named
* key in the eet file and return a pointer to the decompressed pixel da
ta.
*
* The other parameters of the image (width, height etc.) are placed int
o
* the values pointed to (they must be supplied). The pixel data is a li
near
* array of pixels starting from the top-left of the image scanning row
by
* row from left to right. Each pile is a 32bit value, with the high byt
e
* being the alpha channel, the next being red, then green, and the low
byte
* being blue. The width and height are measured in pixels and will be
* greater than 0 when returned. The alpha flag is either 0 or 1. 0 deno
tes
* that the alpha channel is not used. 1 denotes that it is significant.
* Compress is filled with the compression value/amount the image was
* stored with. The quality value is filled with the quality encoding of
* the image file (0 - 100). The lossy flags is either 0 or 1 as to if
* the image was encoded lossily or not.
*
* On success the function returns 1 indicating the header was read and
* decoded properly, or 0 on failure.
*
* @see eet_data_image_header_read()
*
* @since 1.0.0
* @ingroup Eet_File_Image_Cipher_Group
*/
EAPI int eet_data_image_header_read_cipher(Eet_File *ef, const char *nam
e, const char *cipher_key, unsigned int *w, unsigned int *h, int *alpha, in
t *compress, int *quality, int *lossy);
/** /**
* Read image data from the named key in the eet file using a cipher. * Read just the header data for an image and dont decode the pixels using
* @param ef A valid eet file handle opened for reading. a cipher.
* @param name Name of the entry. eg: "/base/file_i_want". * @param ef A valid eet file handle opened for reading.
* @param cipher_key The key to use as cipher. * @param name Name of the entry. eg: "/base/file_i_want".
* @param w A pointer to the unsigned int to hold the width in pixels. * @param cipher_key The key to use as cipher.
* @param h A pointer to the unsigned int to hold the height in pixels. * @param w A pointer to the unsigned int to hold the width in pixels.
* @param alpha A pointer to the int to hold the alpha flag. * @param h A pointer to the unsigned int to hold the height in pixels.
* @param compress A pointer to the int to hold the compression amount. * @param alpha A pointer to the int to hold the alpha flag.
* @param quality A pointer to the int to hold the quality amount. * @param compress A pointer to the int to hold the compression amount.
* @param lossy A pointer to the int to hold the lossiness flag. * @param quality A pointer to the int to hold the quality amount.
* @return The image pixel data decoded * @param lossy A pointer to the int to hold the lossiness flag.
* * @return 1 on successful decode, 0 otherwise
* This function reads an image from an eet file stored under the named *
* key in the eet file and return a pointer to the decompressed pixel da * This function reads an image from an eet file stored under the named
ta. * key in the eet file and return a pointer to the decompressed pixel data.
* *
* The other parameters of the image (width, height etc.) are placed int * The other parameters of the image (width, height etc.) are placed into
o * the values pointed to (they must be supplied). The pixel data is a linea
* the values pointed to (they must be supplied). The pixel data is a li r
near * array of pixels starting from the top-left of the image scanning row by
* array of pixels starting from the top-left of the image scanning row * row from left to right. Each pile is a 32bit value, with the high byte
by * being the alpha channel, the next being red, then green, and the low byt
* row from left to right. Each pile is a 32bit value, with the high byt e
e * being blue. The width and height are measured in pixels and will be
* being the alpha channel, the next being red, then green, and the low * greater than 0 when returned. The alpha flag is either 0 or 1. 0 denotes
byte * that the alpha channel is not used. 1 denotes that it is significant.
* being blue. The width and height are measured in pixels and will be * Compress is filled with the compression value/amount the image was
* greater than 0 when returned. The alpha flag is either 0 or 1. 0 deno * stored with. The quality value is filled with the quality encoding of
tes * the image file (0 - 100). The lossy flags is either 0 or 1 as to if
* that the alpha channel is not used. 1 denotes that it is significant. * the image was encoded lossily or not.
* Compress is filled with the compression value/amount the image was *
* stored with. The quality value is filled with the quality encoding of * On success the function returns 1 indicating the header was read and
* the image file (0 - 100). The lossy flags is either 0 or 1 as to if * decoded properly, or 0 on failure.
* the image was encoded lossily or not. *
* * @see eet_data_image_header_read()
* On success the function returns a pointer to the image data decoded. *
The * @since 1.0.0
* calling application is responsible for calling free() on the image da * @ingroup Eet_File_Image_Cipher_Group
ta */
* when it is done with it. On failure NULL is returned and the paramete EAPI int
r eet_data_image_header_read_cipher(Eet_File *ef,
* values may not contain any sensible data. const char *name,
* const char *cipher_key,
* @see eet_data_image_read() unsigned int *w,
* unsigned int *h,
* @since 1.0.0 int *alpha,
* @ingroup Eet_File_Image_Cipher_Group int *compress,
*/ int *quality,
EAPI void *eet_data_image_read_cipher(Eet_File *ef, const char *name, co int *lossy);
nst char *cipher_key, unsigned int *w, unsigned int *h, int *alpha, int *co
mpress, int *quality, int *lossy);
/** /**
* Read image data from the named key in the eet file using a cipher. * Read image data from the named key in the eet file using a cipher.
* @param ef A valid eet file handle opened for reading. * @param ef A valid eet file handle opened for reading.
* @param name Name of the entry. eg: "/base/file_i_want". * @param name Name of the entry. eg: "/base/file_i_want".
* @param cipher_key The key to use as cipher. * @param cipher_key The key to use as cipher.
* @param src_x The starting x coordinate from where to dump the stream. * @param w A pointer to the unsigned int to hold the width in pixels.
* @param src_y The starting y coordinate from where to dump the stream. * @param h A pointer to the unsigned int to hold the height in pixels.
* @param d A pointer to the pixel surface. * @param alpha A pointer to the int to hold the alpha flag.
* @param w The expected width in pixels of the pixel surface to decode. * @param compress A pointer to the int to hold the compression amount.
* @param h The expected height in pixels of the pixel surface to decode * @param quality A pointer to the int to hold the quality amount.
. * @param lossy A pointer to the int to hold the lossiness flag.
* @param row_stride The length of a pixels line in the destination surf * @return The image pixel data decoded
ace. *
* @param alpha A pointer to the int to hold the alpha flag. * This function reads an image from an eet file stored under the named
* @param compress A pointer to the int to hold the compression amount. * key in the eet file and return a pointer to the decompressed pixel data.
* @param quality A pointer to the int to hold the quality amount. *
* @param lossy A pointer to the int to hold the lossiness flag. * The other parameters of the image (width, height etc.) are placed into
* @return 1 on success, 0 otherwise. * the values pointed to (they must be supplied). The pixel data is a linea
* r
* This function reads an image from an eet file stored under the named * array of pixels starting from the top-left of the image scanning row by
* key in the eet file and return a pointer to the decompressed pixel da * row from left to right. Each pile is a 32bit value, with the high byte
ta. * being the alpha channel, the next being red, then green, and the low byt
* e
* The other parameters of the image (width, height etc.) are placed int * being blue. The width and height are measured in pixels and will be
o * greater than 0 when returned. The alpha flag is either 0 or 1. 0 denotes
* the values pointed to (they must be supplied). The pixel data is a li * that the alpha channel is not used. 1 denotes that it is significant.
near * Compress is filled with the compression value/amount the image was
* array of pixels starting from the top-left of the image scanning row * stored with. The quality value is filled with the quality encoding of
by * the image file (0 - 100). The lossy flags is either 0 or 1 as to if
* row from left to right. Each pile is a 32bit value, with the high byt * the image was encoded lossily or not.
e *
* being the alpha channel, the next being red, then green, and the low * On success the function returns a pointer to the image data decoded. The
byte * calling application is responsible for calling free() on the image data
* being blue. The width and height are measured in pixels and will be * when it is done with it. On failure NULL is returned and the parameter
* greater than 0 when returned. The alpha flag is either 0 or 1. 0 deno * values may not contain any sensible data.
tes *
* that the alpha channel is not used. 1 denotes that it is significant. * @see eet_data_image_read()
* Compress is filled with the compression value/amount the image was *
* stored with. The quality value is filled with the quality encoding of * @since 1.0.0
* the image file (0 - 100). The lossy flags is either 0 or 1 as to if * @ingroup Eet_File_Image_Cipher_Group
* the image was encoded lossily or not. */
* EAPI void *
* On success the function returns 1, and 0 on failure. On failure the eet_data_image_read_cipher(Eet_File *ef,
* parameter values may not contain any sensible data. const char *name,
* const char *cipher_key,
* @see eet_data_image_read_to_surface() unsigned int *w,
* unsigned int *h,
* @since 1.0.2 int *alpha,
* @ingroup Eet_File_Image_Cipher_Group int *compress,
*/ int *quality,
EAPI int eet_data_image_read_to_surface_cipher(Eet_File *ef, const char int *lossy);
*name, const char *cipher_key, unsigned int src_x, unsigned int src_y, unsi
gned int *d, unsigned int w, unsigned int h, unsigned int row_stride, int *
alpha, int *compress, int *quality, int *lossy);
/** /**
* Write image data to the named key in an eet file using a cipher. * Read image data from the named key in the eet file using a cipher.
* @param ef A valid eet file handle opened for writing. * @param ef A valid eet file handle opened for reading.
* @param name Name of the entry. eg: "/base/file_i_want". * @param name Name of the entry. eg: "/base/file_i_want".
* @param cipher_key The key to use as cipher. * @param cipher_key The key to use as cipher.
* @param data A pointer to the image pixel data. * @param src_x The starting x coordinate from where to dump the stream.
* @param w The width of the image in pixels. * @param src_y The starting y coordinate from where to dump the stream.
* @param h The height of the image in pixels. * @param d A pointer to the pixel surface.
* @param alpha The alpha channel flag. * @param w The expected width in pixels of the pixel surface to decode.
* @param compress The compression amount. * @param h The expected height in pixels of the pixel surface to decode.
* @param quality The quality encoding amount. * @param row_stride The length of a pixels line in the destination surface
* @param lossy The lossiness flag. .
* @return Success if the data was encoded and written or not. * @param alpha A pointer to the int to hold the alpha flag.
* * @param compress A pointer to the int to hold the compression amount.
* This function takes image pixel data and encodes it in an eet file * @param quality A pointer to the int to hold the quality amount.
* stored under the supplied name key, and returns how many bytes were * @param lossy A pointer to the int to hold the lossiness flag.
* actually written to encode the image data. * @return 1 on success, 0 otherwise.
* *
* The data expected is the same format as returned by eet_data_image_re * This function reads an image from an eet file stored under the named
ad. * key in the eet file and return a pointer to the decompressed pixel data.
* If this is not the case weird things may happen. Width and height mus *
t * The other parameters of the image (width, height etc.) are placed into
* be between 1 and 8000 pixels. The alpha flags can be 0 or 1 (0 meanin * the values pointed to (they must be supplied). The pixel data is a linea
g r
* the alpha values are not useful and 1 meaning they are). Compress can * array of pixels starting from the top-left of the image scanning row by
* be from 0 to 9 (0 meaning no compression, 9 meaning full compression) * row from left to right. Each pile is a 32bit value, with the high byte
. * being the alpha channel, the next being red, then green, and the low byt
* This is only used if the image is not lossily encoded. Quality is use e
d on * being blue. The width and height are measured in pixels and will be
* lossy compression and should be a value from 0 to 100. The lossy flag * greater than 0 when returned. The alpha flag is either 0 or 1. 0 denotes
* can be 0 or 1. 0 means encode losslessly and 1 means to encode with * that the alpha channel is not used. 1 denotes that it is significant.
* image quality loss (but then have a much smaller encoding). * Compress is filled with the compression value/amount the image was
* * stored with. The quality value is filled with the quality encoding of
* On success this function returns the number of bytes that were requir * the image file (0 - 100). The lossy flags is either 0 or 1 as to if
ed * the image was encoded lossily or not.
* to encode the image data, or on failure it returns 0. *
* * On success the function returns 1, and 0 on failure. On failure the
* @see eet_data_image_write() * parameter values may not contain any sensible data.
* *
* @since 1.0.0 * @see eet_data_image_read_to_surface()
* @ingroup Eet_File_Image_Cipher_Group *
*/ * @since 1.0.2
EAPI int eet_data_image_write_cipher(Eet_File *ef, const char *name, con * @ingroup Eet_File_Image_Cipher_Group
st char *cipher_key, const void *data, unsigned int w, unsigned int h, int */
alpha, int compress, int quality, int lossy); EAPI int
eet_data_image_read_to_surface_cipher(Eet_File *ef,
const char *name,
const char *cipher_key,
unsigned int src_x,
unsigned int src_y,
unsigned int *d,
unsigned int w,
unsigned int h,
unsigned int row_stride,
int *alpha,
int *compress,
int *quality,
int *lossy);
/** /**
* Decode Image data header only to get information using a cipher. * Write image data to the named key in an eet file using a cipher.
* @param data The encoded pixel data. * @param ef A valid eet file handle opened for writing.
* @param cipher_key The key to use as cipher. * @param name Name of the entry. eg: "/base/file_i_want".
* @param size The size, in bytes, of the encoded pixel data. * @param cipher_key The key to use as cipher.
* @param w A pointer to the unsigned int to hold the width in pixels. * @param data A pointer to the image pixel data.
* @param h A pointer to the unsigned int to hold the height in pixels. * @param w The width of the image in pixels.
* @param alpha A pointer to the int to hold the alpha flag. * @param h The height of the image in pixels.
* @param compress A pointer to the int to hold the compression amount. * @param alpha The alpha channel flag.
* @param quality A pointer to the int to hold the quality amount. * @param compress The compression amount.
* @param lossy A pointer to the int to hold the lossiness flag. * @param quality The quality encoding amount.
* @return 1 on success, 0 on failure. * @param lossy The lossiness flag.
* * @return Success if the data was encoded and written or not.
* This function takes encoded pixel data and decodes it into raw RGBA *
* pixels on success. * This function takes image pixel data and encodes it in an eet file
* * stored under the supplied name key, and returns how many bytes were
* The other parameters of the image (width, height etc.) are placed int * actually written to encode the image data.
o *
* the values pointed to (they must be supplied). The pixel data is a li * The data expected is the same format as returned by eet_data_image_read.
near * If this is not the case weird things may happen. Width and height must
* array of pixels starting from the top-left of the image scanning row * be between 1 and 8000 pixels. The alpha flags can be 0 or 1 (0 meaning
by * the alpha values are not useful and 1 meaning they are). Compress can
* row from left to right. Each pixel is a 32bit value, with the high by * be from 0 to 9 (0 meaning no compression, 9 meaning full compression).
te * This is only used if the image is not lossily encoded. Quality is used o
* being the alpha channel, the next being red, then green, and the low n
byte * lossy compression and should be a value from 0 to 100. The lossy flag
* being blue. The width and height are measured in pixels and will be * can be 0 or 1. 0 means encode losslessly and 1 means to encode with
* greater than 0 when returned. The alpha flag is either 0 or 1. 0 deno * image quality loss (but then have a much smaller encoding).
tes *
* that the alpha channel is not used. 1 denotes that it is significant. * On success this function returns the number of bytes that were required
* Compress is filled with the compression value/amount the image was * to encode the image data, or on failure it returns 0.
* stored with. The quality value is filled with the quality encoding of *
* the image file (0 - 100). The lossy flags is either 0 or 1 as to if * @see eet_data_image_write()
* the image was encoded lossily or not. *
* * @since 1.0.0
* On success the function returns 1 indicating the header was read and * @ingroup Eet_File_Image_Cipher_Group
* decoded properly, or 0 on failure. */
* EAPI int
* @see eet_data_image_header_decode() eet_data_image_write_cipher(Eet_File *ef,
* const char *name,
* @since 1.0.0 const char *cipher_key,
* @ingroup Eet_File_Image_Cipher_Group const void *data,
*/ unsigned int w,
EAPI int eet_data_image_header_decode_cipher(const void *data, const cha unsigned int h,
r *cipher_key, int size, unsigned int *w, unsigned int *h, int *alpha, int int alpha,
*compress, int *quality, int *lossy); int compress,
int quality,
int lossy);
/** /**
* Decode Image data into pixel data using a cipher. * Decode Image data header only to get information using a cipher.
* @param data The encoded pixel data. * @param data The encoded pixel data.
* @param cipher_key The key to use as cipher. * @param cipher_key The key to use as cipher.
* @param size The size, in bytes, of the encoded pixel data. * @param size The size, in bytes, of the encoded pixel data.
* @param w A pointer to the unsigned int to hold the width in pixels. * @param w A pointer to the unsigned int to hold the width in pixels.
* @param h A pointer to the unsigned int to hold the height in pixels. * @param h A pointer to the unsigned int to hold the height in pixels.
* @param alpha A pointer to the int to hold the alpha flag. * @param alpha A pointer to the int to hold the alpha flag.
* @param compress A pointer to the int to hold the compression amount. * @param compress A pointer to the int to hold the compression amount.
* @param quality A pointer to the int to hold the quality amount. * @param quality A pointer to the int to hold the quality amount.
* @param lossy A pointer to the int to hold the lossiness flag. * @param lossy A pointer to the int to hold the lossiness flag.
* @return The image pixel data decoded * @return 1 on success, 0 on failure.
* *
* This function takes encoded pixel data and decodes it into raw RGBA * This function takes encoded pixel data and decodes it into raw RGBA
* pixels on success. * pixels on success.
* *
* The other parameters of the image (width, height etc.) are placed int * The other parameters of the image (width, height etc.) are placed into
o * the values pointed to (they must be supplied). The pixel data is a linea
* the values pointed to (they must be supplied). The pixel data is a li r
near * array of pixels starting from the top-left of the image scanning row by
* array of pixels starting from the top-left of the image scanning row * row from left to right. Each pixel is a 32bit value, with the high byte
by * being the alpha channel, the next being red, then green, and the low byt
* row from left to right. Each pixel is a 32bit value, with the high by e
te * being blue. The width and height are measured in pixels and will be
* being the alpha channel, the next being red, then green, and the low * greater than 0 when returned. The alpha flag is either 0 or 1. 0 denotes
byte * that the alpha channel is not used. 1 denotes that it is significant.
* being blue. The width and height are measured in pixels and will be * Compress is filled with the compression value/amount the image was
* greater than 0 when returned. The alpha flag is either 0 or 1. 0 deno * stored with. The quality value is filled with the quality encoding of
tes * the image file (0 - 100). The lossy flags is either 0 or 1 as to if
* that the alpha channel is not used. 1 denotes that it is significant. * the image was encoded lossily or not.
* Compress is filled with the compression value/amount the image was *
* stored with. The quality value is filled with the quality encoding of * On success the function returns 1 indicating the header was read and
* the image file (0 - 100). The lossy flags is either 0 or 1 as to if * decoded properly, or 0 on failure.
* the image was encoded lossily or not. *
* * @see eet_data_image_header_decode()
* On success the function returns a pointer to the image data decoded. *
The * @since 1.0.0
* calling application is responsible for calling free() on the image da * @ingroup Eet_File_Image_Cipher_Group
ta */
* when it is done with it. On failure NULL is returned and the paramete EAPI int
r eet_data_image_header_decode_cipher(const void *data,
* values may not contain any sensible data. const char *cipher_key,
* int size,
* @see eet_data_image_decode() unsigned int *w,
* unsigned int *h,
* @since 1.0.0 int *alpha,
* @ingroup Eet_File_Image_Cipher_Group int *compress,
*/ int *quality,
EAPI void *eet_data_image_decode_cipher(const void *data, const char *ci int *lossy);
pher_key, int size, unsigned int *w, unsigned int *h, int *alpha, int *comp
ress, int *quality, int *lossy);
/** /**
* Decode Image data into pixel data using a cipher. * Decode Image data into pixel data using a cipher.
* @param data The encoded pixel data. * @param data The encoded pixel data.
* @param cipher_key The key to use as cipher. * @param cipher_key The key to use as cipher.
* @param size The size, in bytes, of the encoded pixel data. * @param size The size, in bytes, of the encoded pixel data.
* @param src_x The starting x coordinate from where to dump the stream. * @param w A pointer to the unsigned int to hold the width in pixels.
* @param src_y The starting y coordinate from where to dump the stream. * @param h A pointer to the unsigned int to hold the height in pixels.
* @param d A pointer to the pixel surface. * @param alpha A pointer to the int to hold the alpha flag.
* @param w The expected width in pixels of the pixel surface to decode. * @param compress A pointer to the int to hold the compression amount.
* @param h The expected height in pixels of the pixel surface to decode * @param quality A pointer to the int to hold the quality amount.
. * @param lossy A pointer to the int to hold the lossiness flag.
* @param row_stride The length of a pixels line in the destination surf * @return The image pixel data decoded
ace. *
* @param alpha A pointer to the int to hold the alpha flag. * This function takes encoded pixel data and decodes it into raw RGBA
* @param compress A pointer to the int to hold the compression amount. * pixels on success.
* @param quality A pointer to the int to hold the quality amount. *
* @param lossy A pointer to the int to hold the lossiness flag. * The other parameters of the image (width, height etc.) are placed into
* @return 1 on success, 0 otherwise. * the values pointed to (they must be supplied). The pixel data is a linea
* r
* This function takes encoded pixel data and decodes it into raw RGBA * array of pixels starting from the top-left of the image scanning row by
* pixels on success. * row from left to right. Each pixel is a 32bit value, with the high byte
* * being the alpha channel, the next being red, then green, and the low byt
* The other parameters of the image (alpha, compress etc.) are placed i e
nto * being blue. The width and height are measured in pixels and will be
* the values pointed to (they must be supplied). The pixel data is a li * greater than 0 when returned. The alpha flag is either 0 or 1. 0 denotes
near * that the alpha channel is not used. 1 denotes that it is significant.
* array of pixels starting from the top-left of the image scanning row * Compress is filled with the compression value/amount the image was
by * stored with. The quality value is filled with the quality encoding of
* row from left to right. Each pixel is a 32bit value, with the high by * the image file (0 - 100). The lossy flags is either 0 or 1 as to if
te * the image was encoded lossily or not.
* being the alpha channel, the next being red, then green, and the low *
byte * On success the function returns a pointer to the image data decoded. The
* being blue. The width and height are measured in pixels and will be * calling application is responsible for calling free() on the image data
* greater than 0 when returned. The alpha flag is either 0 or 1. 0 deno * when it is done with it. On failure NULL is returned and the parameter
tes * values may not contain any sensible data.
* that the alpha channel is not used. 1 denotes that it is significant. *
* Compress is filled with the compression value/amount the image was * @see eet_data_image_decode()
* stored with. The quality value is filled with the quality encoding of *
* the image file (0 - 100). The lossy flags is either 0 or 1 as to if * @since 1.0.0
* the image was encoded lossily or not. * @ingroup Eet_File_Image_Cipher_Group
* */
* On success the function returns 1, and 0 on failure. On failure the EAPI void *
* parameter values may not contain any sensible data. eet_data_image_decode_cipher(const void *data,
* const char *cipher_key,
* @see eet_data_image_decode_to_surface() int size,
* unsigned int *w,
* @since 1.0.2 unsigned int *h,
* @ingroup Eet_File_Image_Cipher_Group int *alpha,
*/ int *compress,
EAPI int eet_data_image_decode_to_surface_cipher(const void *data, const int *quality,
char *cipher_key, int size, unsigned int src_x, unsigned int src_y, unsign int *lossy);
ed int *d, unsigned int w, unsigned int h, unsigned int row_stride, int *al
pha, int *compress, int *quality, int *lossy);
/** /**
* Encode image data for storage or transmission using a cipher. * Decode Image data into pixel data using a cipher.
* @param data A pointer to the image pixel data. * @param data The encoded pixel data.
* @param cipher_key The key to use as cipher. * @param cipher_key The key to use as cipher.
* @param size_ret A pointer to an int to hold the size of the returned * @param size The size, in bytes, of the encoded pixel data.
data. * @param src_x The starting x coordinate from where to dump the stream.
* @param w The width of the image in pixels. * @param src_y The starting y coordinate from where to dump the stream.
* @param h The height of the image in pixels. * @param d A pointer to the pixel surface.
* @param alpha The alpha channel flag. * @param w The expected width in pixels of the pixel surface to decode.
* @param compress The compression amount. * @param h The expected height in pixels of the pixel surface to decode.
* @param quality The quality encoding amount. * @param row_stride The length of a pixels line in the destination surface
* @param lossy The lossiness flag. .
* @return The encoded image data. * @param alpha A pointer to the int to hold the alpha flag.
* * @param compress A pointer to the int to hold the compression amount.
* This function stakes image pixel data and encodes it with compression * @param quality A pointer to the int to hold the quality amount.
and * @param lossy A pointer to the int to hold the lossiness flag.
* possible loss of quality (as a trade off for size) for storage or * @return 1 on success, 0 otherwise.
* transmission to another system. *
* * This function takes encoded pixel data and decodes it into raw RGBA
* The data expected is the same format as returned by eet_data_image_re * pixels on success.
ad. *
* If this is not the case weird things may happen. Width and height mus * The other parameters of the image (alpha, compress etc.) are placed into
t * the values pointed to (they must be supplied). The pixel data is a linea
* be between 1 and 8000 pixels. The alpha flags can be 0 or 1 (0 meanin r
g * array of pixels starting from the top-left of the image scanning row by
* the alpha values are not useful and 1 meaning they are). Compress can * row from left to right. Each pixel is a 32bit value, with the high byte
* be from 0 to 9 (0 meaning no compression, 9 meaning full compression) * being the alpha channel, the next being red, then green, and the low byt
. e
* This is only used if the image is not lossily encoded. Quality is use * being blue. The width and height are measured in pixels and will be
d on * greater than 0 when returned. The alpha flag is either 0 or 1. 0 denotes
* lossy compression and should be a value from 0 to 100. The lossy flag * that the alpha channel is not used. 1 denotes that it is significant.
* can be 0 or 1. 0 means encode losslessly and 1 means to encode with * Compress is filled with the compression value/amount the image was
* image quality loss (but then have a much smaller encoding). * stored with. The quality value is filled with the quality encoding of
* * the image file (0 - 100). The lossy flags is either 0 or 1 as to if
* On success this function returns a pointer to the encoded data that y * the image was encoded lossily or not.
ou *
* can free with free() when no longer needed. * On success the function returns 1, and 0 on failure. On failure the
* * parameter values may not contain any sensible data.
* @see eet_data_image_encode() *
* * @see eet_data_image_decode_to_surface()
* @since 1.0.0 *
* @ingroup Eet_File_Image_Cipher_Group * @since 1.0.2
*/ * @ingroup Eet_File_Image_Cipher_Group
EAPI void *eet_data_image_encode_cipher(const void *data, const char *ci */
pher_key, unsigned int w, unsigned int h, int alpha, int compress, int qual EAPI int
ity, int lossy, int *size_ret); eet_data_image_decode_to_surface_cipher(const void *data,
const char *cipher_key,
int size,
unsigned int src_x,
unsigned int src_y,
unsigned int *d,
unsigned int w,
unsigned int h,
unsigned int row_stride,
int *alpha,
int *compress,
int *quality,
int *lossy);
/** /**
* @defgroup Eet_Cipher_Group Cipher, Identity and Protection Mechanisms * Encode image data for storage or transmission using a cipher.
* * @param data A pointer to the image pixel data.
* Eet allows one to protect entries of an #Eet_File * @param cipher_key The key to use as cipher.
* individually. This may be used to ensure data was not tampered or * @param size_ret A pointer to an int to hold the size of the returned dat
* that third party does not read your data. a.
* * @param w The width of the image in pixels.
* @see @ref Eet_File_Cipher_Group * @param h The height of the image in pixels.
* @see @ref Eet_File_Image_Cipher_Group * @param alpha The alpha channel flag.
* * @param compress The compression amount.
* @{ * @param quality The quality encoding amount.
*/ * @param lossy The lossiness flag.
* @return The encoded image data.
*
* This function stakes image pixel data and encodes it with compression an
d
* possible loss of quality (as a trade off for size) for storage or
* transmission to another system.
*
* The data expected is the same format as returned by eet_data_image_read.
* If this is not the case weird things may happen. Width and height must
* be between 1 and 8000 pixels. The alpha flags can be 0 or 1 (0 meaning
* the alpha values are not useful and 1 meaning they are). Compress can
* be from 0 to 9 (0 meaning no compression, 9 meaning full compression).
* This is only used if the image is not lossily encoded. Quality is used o
n
* lossy compression and should be a value from 0 to 100. The lossy flag
* can be 0 or 1. 0 means encode losslessly and 1 means to encode with
* image quality loss (but then have a much smaller encoding).
*
* On success this function returns a pointer to the encoded data that you
* can free with free() when no longer needed.
*
* @see eet_data_image_encode()
*
* @since 1.0.0
* @ingroup Eet_File_Image_Cipher_Group
*/
EAPI void *
eet_data_image_encode_cipher(const void *data,
const char *cipher_key,
unsigned int w,
unsigned int h,
int alpha,
int compress,
int quality,
int lossy,
int *size_ret);
/** /**
* @typedef Eet_Key * @defgroup Eet_Cipher_Group Cipher, Identity and Protection Mechanisms
* Opaque handle that defines an identity (also known as key) *
* in Eet's cipher system. * Eet allows one to protect entries of an #Eet_File
*/ * individually. This may be used to ensure data was not tampered or
typedef struct _Eet_Key Eet_Key; * that third party does not read your data.
*
* @see @ref Eet_File_Cipher_Group
* @see @ref Eet_File_Image_Cipher_Group
*
* @{
*/
/** /**
* @} * @typedef Eet_Key
*/ * Opaque handle that defines an identity (also known as key)
* in Eet's cipher system.
*/
typedef struct _Eet_Key Eet_Key;
/** /**
* Callback used to request if needed the password of a private key. * @}
* */
* @param buffer the buffer where to store the password.
* @param size the maximum password size (size of buffer, including '@\0
').
* @param rwflag if the buffer is also readable or just writable.
* @param data currently unused, may contain some context in future.
* @return 1 on success and password was set to @p buffer, 0 on failure.
*
* @since 1.2.0
* @ingroup Eet_Cipher_Group
*/
typedef int (*Eet_Key_Password_Callback)(char *buffer, int size, int rwf
lag, void *data);
/** /**
* Create an Eet_Key needed for signing an eet file. * Callback used to request if needed the password of a private key.
* *
* The certificate should provide the public that match the private key. * @param buffer the buffer where to store the password.
* No verification is done to ensure that. * @param size the maximum password size (size of buffer, including '@\0').
* * @param rwflag if the buffer is also readable or just writable.
* @param certificate_file The file where to find the certificate. * @param data currently unused, may contain some context in future.
* @param private_key_file The file that contains the private key. * @return 1 on success and password was set to @p buffer, 0 on failure.
* @param cb Function to callback if password is required to unlock *
* private key. * @since 1.2.0
* @return A key handle to use, or @c NULL on failure. * @ingroup Eet_Cipher_Group
* */
* @see eet_identity_close() typedef int (*Eet_Key_Password_Callback) (char *buffer, int size, int rwfla
* g, void *data);
* @since 1.2.0
* @ingroup Eet_Cipher_Group
*/
EAPI Eet_Key* eet_identity_open(const char *certificate_file, const char
*private_key_file, Eet_Key_Password_Callback cb);
/** /**
* Close and release all ressource used by an Eet_Key. An * Create an Eet_Key needed for signing an eet file.
* reference counter prevent it from being freed until all file *
* using it are also closed. * The certificate should provide the public that match the private key.
* * No verification is done to ensure that.
* @param key the key handle to close and free resources. *
* * @param certificate_file The file where to find the certificate.
* @since 1.2.0 * @param private_key_file The file that contains the private key.
* @ingroup Eet_Cipher_Group * @param cb Function to callback if password is required to unlock
*/ * private key.
EAPI void eet_identity_close(Eet_Key *key); * @return A key handle to use, or @c NULL on failure.
*
* @see eet_identity_close()
*
* @since 1.2.0
* @ingroup Eet_Cipher_Group
*/
EAPI Eet_Key *
eet_identity_open(const char *certificate_file,
const char *private_key_file,
Eet_Key_Password_Callback cb);
/** /**
* Set a key to sign a file * Close and release all ressource used by an Eet_Key. An
* * reference counter prevent it from being freed until all file
* @param ef the file to set the identity. * using it are also closed.
* @param key the key handle to set as identity. *
* @return #EET_ERROR_BAD_OBJECT if @p ef is invalid or * @param key the key handle to close and free resources.
* #EET_ERROR_NONE on success. *
* * @since 1.2.0
* @since 1.2.0 * @ingroup Eet_Cipher_Group
* @ingroup Eet_Cipher_Group */
*/ EAPI void
EAPI Eet_Error eet_identity_set(Eet_File *ef, Eet_Key *key); eet_identity_close(Eet_Key *key);
/** /**
* Display both private and public key of an Eet_Key. * Set a key to sign a file
* *
* @param key the handle to print. * @param ef the file to set the identity.
* @param out where to print. * @param key the key handle to set as identity.
* * @return #EET_ERROR_BAD_OBJECT if @p ef is invalid or
* @since 1.2.0 * #EET_ERROR_NONE on success.
* @ingroup Eet_Cipher_Group *
*/ * @since 1.2.0
EAPI void eet_identity_print(Eet_Key *key, FILE *out); * @ingroup Eet_Cipher_Group
*/
EAPI Eet_Error
eet_identity_set(Eet_File *ef,
Eet_Key *key);
/** /**
* Get the x509 der certificate associated with an Eet_File. Will return * Display both private and public key of an Eet_Key.
NULL *
* if the file is not signed. * @param key the handle to print.
* * @param out where to print.
* @param ef The file handle to query. *
* @param der_length The length of returned data, may be @c NULL. * @since 1.2.0
* @return the x509 certificate or @c NULL on error. * @ingroup Eet_Cipher_Group
* */
* @since 1.2.0 EAPI void
* @ingroup Eet_Cipher_Group eet_identity_print(Eet_Key *key,
*/ FILE *out);
EAPI const void *eet_identity_x509(Eet_File *ef, int *der_length);
/** /**
* Get the raw signature associated with an Eet_File. Will return NULL * Get the x509 der certificate associated with an Eet_File. Will return NU
* if the file is not signed. LL
* * if the file is not signed.
* @param ef The file handle to query. *
* @param signature_length The length of returned data, may be @c NULL. * @param ef The file handle to query.
* @return the raw signature or @c NULL on error. * @param der_length The length of returned data, may be @c NULL.
* * @return the x509 certificate or @c NULL on error.
* @ingroup Eet_Cipher_Group *
*/ * @since 1.2.0
EAPI const void *eet_identity_signature(Eet_File *ef, int *signature_len * @ingroup Eet_Cipher_Group
gth); */
EAPI const void *
eet_identity_x509(Eet_File *ef,
int *der_length);
/** /**
* Get the SHA1 associated with a file. Could be the one used to * Get the raw signature associated with an Eet_File. Will return NULL
* sign the data or if the data where not signed, it will be the * if the file is not signed.
* SHA1 of the file. *
* * @param ef The file handle to query.
* @param ef The file handle to query. * @param signature_length The length of returned data, may be @c NULL.
* @param sha1_length The length of returned data, may be @c NULL. * @return the raw signature or @c NULL on error.
* @return the associated SHA1 or @c NULL on error. *
* * @ingroup Eet_Cipher_Group
* @since 1.2.0 */
* @ingroup Eet_Cipher_Group EAPI const void *
*/ eet_identity_signature(Eet_File *ef,
EAPI const void *eet_identity_sha1(Eet_File *ef, int *sha1_length); int *signature_length);
/** /**
* Display the x509 der certificate to out. * Get the SHA1 associated with a file. Could be the one used to
* * sign the data or if the data where not signed, it will be the
* @param certificate the x509 certificate to print * SHA1 of the file.
* @param der_length The length the certificate. *
* @param out where to print. * @param ef The file handle to query.
* * @param sha1_length The length of returned data, may be @c NULL.
* @since 1.2.0 * @return the associated SHA1 or @c NULL on error.
* @ingroup Eet_Cipher_Group *
*/ * @since 1.2.0
EAPI void eet_identity_certificate_print(const unsigned char *certificat * @ingroup Eet_Cipher_Group
e, int der_length, FILE *out); */
EAPI const void *
eet_identity_sha1(Eet_File *ef,
int *sha1_length);
/** /**
* @defgroup Eet_Data_Group Eet Data Serialization * Display the x509 der certificate to out.
* *
* Convenience functions to serialize and parse complex data * @param certificate the x509 certificate to print
* structures to binary blobs. * @param der_length The length the certificate.
* * @param out where to print.
* While Eet core just handles binary blobs, it is often required *
* to save some structured data of different types, such as * @since 1.2.0
* strings, integers, lists, hashes and so on. * @ingroup Eet_Cipher_Group
* */
* Eet can serialize and then parse data types given some EAPI void
* construction instructions. These are defined in two levels: eet_identity_certificate_print(const unsigned char *certificate,
* int der_length,
* - #Eet_Data_Descriptor_Class to tell generic memory handling, FILE *out);
* such as the size of the type, how to allocate memory, strings,
* lists, hashes and so on.
*
* - #Eet_Data_Descriptor to tell inside such type, the members and
* their offsets inside the memory blob, their types and
* names. These members can be simple types or other
* #Eet_Data_Descriptor, allowing hierarchical types to be
* defined.
*
* Given that C provides no introspection, this process can be
* quite cumbersome, so we provide lots of macros and convenience
* functions to aid creating the types.
*
* Example:
*
* @code
* #include <Eet.h>
* #include <Evas.h>
*
* typedef struct _blah2
* {
* char *string;
* } Blah2;
*
* typedef struct _blah3
* {
* char *string;
* } Blah3;
*
* typedef struct _blah
* {
* char character;
* short sixteen;
* int integer;
* long long lots;
* float floating;
* double floating_lots;
* char *string;
* Blah2 *blah2;
* Eina_List *blah3;
* } Blah;
*
* int
* main(int argc, char **argv)
* {
* Blah blah;
* Blah2 blah2;
* Blah3 blah3;
* Eet_Data_Descriptor *edd, *edd2, *edd3;
* Eet_Data_Descriptor_Class eddc, eddc2, eddc3;
* void *data;
* int size;
* FILE *f;
* Blah *blah_in;
*
* eet_init();
*
* EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eddc3, Blah3);
* edd3 = eet_data_descriptor_stream_new(&eddc3);
* EET_DATA_DESCRIPTOR_ADD_BASIC(edd3, Blah3, "string3", string, EET_
T_STRING);
*
* EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eddc2, Blah2);
* edd2 = eet_data_descriptor_stream_new(&eddc2);
* EET_DATA_DESCRIPTOR_ADD_BASIC(edd2, Blah2, "string2", string, EET_
T_STRING);
*
* EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eddc, Blah);
* edd = eet_data_descriptor_stream_new(&eddc);
* EET_DATA_DESCRIPTOR_ADD_BASIC(edd, Blah, "character", character, E
ET_T_CHAR);
* EET_DATA_DESCRIPTOR_ADD_BASIC(edd, Blah, "sixteen", sixteen, EET_T
_SHORT);
* EET_DATA_DESCRIPTOR_ADD_BASIC(edd, Blah, "integer", integer, EET_T
_INT);
* EET_DATA_DESCRIPTOR_ADD_BASIC(edd, Blah, "lots", lots, EET_T_LONG_
LONG);
* EET_DATA_DESCRIPTOR_ADD_BASIC(edd, Blah, "floating", floating, EET
_T_FLOAT);
* EET_DATA_DESCRIPTOR_ADD_BASIC(edd, Blah, "floating_lots", floating
_lots, EET_T_DOUBLE);
* EET_DATA_DESCRIPTOR_ADD_BASIC(edd, Blah, "string", string, EET_T_S
TRING);
* EET_DATA_DESCRIPTOR_ADD_SUB(edd, Blah, "blah2", blah2, edd2);
* EET_DATA_DESCRIPTOR_ADD_LIST(edd, Blah, "blah3", blah3, edd3);
*
* blah3.string = "PANTS";
*
* blah2.string = "subtype string here!";
*
* blah.character = '7';
* blah.sixteen = 0x7777;
* blah.integer = 0xc0def00d;
* blah.lots = 0xdeadbeef31337777;
* blah.floating = 3.141592654;
* blah.floating_lots = 0.777777777777777;
* blah.string = "bite me like a turnip";
* blah.blah2 = &blah2;
* blah.blah3 = eina_list_append(NULL, &blah3);
* blah.blah3 = eina_list_append(blah.blah3, &blah3);
* blah.blah3 = eina_list_append(blah.blah3, &blah3);
* blah.blah3 = eina_list_append(blah.blah3, &blah3);
* blah.blah3 = eina_list_append(blah.blah3, &blah3);
* blah.blah3 = eina_list_append(blah.blah3, &blah3);
* blah.blah3 = eina_list_append(blah.blah3, &blah3);
*
* data = eet_data_descriptor_encode(edd, &blah, &size);
* printf("-----DECODING\n");
* blah_in = eet_data_descriptor_decode(edd, data, size);
*
* printf("-----DECODED!\n");
* printf("%c\n", blah_in->character);
* printf("%x\n", (int)blah_in->sixteen);
* printf("%x\n", blah_in->integer);
* printf("%lx\n", blah_in->lots);
* printf("%f\n", (double)blah_in->floating);
* printf("%f\n", (double)blah_in->floating_lots);
* printf("%s\n", blah_in->string);
* printf("%p\n", blah_in->blah2);
* printf(" %s\n", blah_in->blah2->string);
* {
* Eina_List *l;
* Blah3 *blah3_in;
*
* EINA_LIST_FOREACH(blah_in->blah3, l, blah3_in)
* {
* printf("%p\n", blah3_in);
* printf(" %s\n", blah3_in->string);
* }
* }
* eet_data_descriptor_free(edd);
* eet_data_descriptor_free(edd2);
* eet_data_descriptor_free(edd3);
*
* eet_shutdown();
*
* return 0;
* }
* @endcode
*
* @{
*/
#define EET_T_UNKNOW 0 /**< Unknown data encoding type */
#define EET_T_CHAR 1 /**< Data type: char */
#define EET_T_SHORT 2 /**< Data type: short */
#define EET_T_INT 3 /**< Data type: int */
#define EET_T_LONG_LONG 4 /**< Data type: long long */
#define EET_T_FLOAT 5 /**< Data type: float */
#define EET_T_DOUBLE 6 /**< Data type: double */
#define EET_T_UCHAR 7 /**< Data type: unsigned char */
#define EET_T_USHORT 8 /**< Data type: unsigned short */
#define EET_T_UINT 9 /**< Data type: unsigned int */
#define EET_T_ULONG_LONG 10 /**< Data type: unsigned long long */
#define EET_T_STRING 11 /**< Data type: char * */
#define EET_T_INLINED_STRING 12 /**< Data type: char * (but compressed i
nside the resulting eet) */
#define EET_T_NULL 13 /**< Data type: (void *) (only use it if
you know why) */
#define EET_T_F32P32 14 /**< Data type: fixed point 32.32 */
#define EET_T_F16P16 15 /**< Data type: fixed point 16.16 */
#define EET_T_F8P24 16 /**< Data type: fixed point 8.24 */
#define EET_T_LAST 18 /**< Last data type */
#define EET_G_UNKNOWN 100 /**< Unknown group data encoding type */ /**
#define EET_G_ARRAY 101 /**< Fixed size array group type */ * @defgroup Eet_Data_Group Eet Data Serialization
#define EET_G_VAR_ARRAY 102 /**< Variable size array group type */ *
#define EET_G_LIST 103 /**< Linked list group type */ * Convenience functions to serialize and parse complex data
#define EET_G_HASH 104 /**< Hash table group type */ * structures to binary blobs.
#define EET_G_UNION 105 /**< Union group type */ *
#define EET_G_VARIANT 106 /**< Selectable subtype group */ * While Eet core just handles binary blobs, it is often required
#define EET_G_LAST 107 /**< Last group type */ * to save some structured data of different types, such as
* strings, integers, lists, hashes and so on.
*
* Eet can serialize and then parse data types given some
* construction instructions. These are defined in two levels:
*
* - #Eet_Data_Descriptor_Class to tell generic memory handling,
* such as the size of the type, how to allocate memory, strings,
* lists, hashes and so on.
*
* - #Eet_Data_Descriptor to tell inside such type, the members and
* their offsets inside the memory blob, their types and
* names. These members can be simple types or other
* #Eet_Data_Descriptor, allowing hierarchical types to be
* defined.
*
* Given that C provides no introspection, this process can be
* quite cumbersome, so we provide lots of macros and convenience
* functions to aid creating the types.
*
* Example:
*
* @code
* #include <Eet.h>
* #include <Evas.h>
*
* typedef struct _blah2
* {
* char *string;
* } Blah2;
*
* typedef struct _blah3
* {
* char *string;
* } Blah3;
*
* typedef struct _blah
* {
* char character;
* short sixteen;
* int integer;
* long long lots;
* float floating;
* double floating_lots;
* char *string;
* Blah2 *blah2;
* Eina_List *blah3;
* } Blah;
*
* int
* main(int argc, char **argv)
* {
* Blah blah;
* Blah2 blah2;
* Blah3 blah3;
* Eet_Data_Descriptor *edd, *edd2, *edd3;
* Eet_Data_Descriptor_Class eddc, eddc2, eddc3;
* void *data;
* int size;
* FILE *f;
* Blah *blah_in;
*
* eet_init();
*
* EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eddc3, Blah3);
* edd3 = eet_data_descriptor_stream_new(&eddc3);
* EET_DATA_DESCRIPTOR_ADD_BASIC(edd3, Blah3, "string3", string, EET_T_S
TRING);
*
* EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eddc2, Blah2);
* edd2 = eet_data_descriptor_stream_new(&eddc2);
* EET_DATA_DESCRIPTOR_ADD_BASIC(edd2, Blah2, "string2", string, EET_T_S
TRING);
*
* EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eddc, Blah);
* edd = eet_data_descriptor_stream_new(&eddc);
* EET_DATA_DESCRIPTOR_ADD_BASIC(edd, Blah, "character", character, EET_
T_CHAR);
* EET_DATA_DESCRIPTOR_ADD_BASIC(edd, Blah, "sixteen", sixteen, EET_T_SH
ORT);
* EET_DATA_DESCRIPTOR_ADD_BASIC(edd, Blah, "integer", integer, EET_T_IN
T);
* EET_DATA_DESCRIPTOR_ADD_BASIC(edd, Blah, "lots", lots, EET_T_LONG_LON
G);
* EET_DATA_DESCRIPTOR_ADD_BASIC(edd, Blah, "floating", floating, EET_T_
FLOAT);
* EET_DATA_DESCRIPTOR_ADD_BASIC(edd, Blah, "floating_lots", floating_lo
ts, EET_T_DOUBLE);
* EET_DATA_DESCRIPTOR_ADD_BASIC(edd, Blah, "string", string, EET_T_STRI
NG);
* EET_DATA_DESCRIPTOR_ADD_SUB(edd, Blah, "blah2", blah2, edd2);
* EET_DATA_DESCRIPTOR_ADD_LIST(edd, Blah, "blah3", blah3, edd3);
*
* blah3.string = "PANTS";
*
* blah2.string = "subtype string here!";
*
* blah.character = '7';
* blah.sixteen = 0x7777;
* blah.integer = 0xc0def00d;
* blah.lots = 0xdeadbeef31337777;
* blah.floating = 3.141592654;
* blah.floating_lots = 0.777777777777777;
* blah.string = "bite me like a turnip";
* blah.blah2 = &blah2;
* blah.blah3 = eina_list_append(NULL, &blah3);
* blah.blah3 = eina_list_append(blah.blah3, &blah3);
* blah.blah3 = eina_list_append(blah.blah3, &blah3);
* blah.blah3 = eina_list_append(blah.blah3, &blah3);
* blah.blah3 = eina_list_append(blah.blah3, &blah3);
* blah.blah3 = eina_list_append(blah.blah3, &blah3);
* blah.blah3 = eina_list_append(blah.blah3, &blah3);
*
* data = eet_data_descriptor_encode(edd, &blah, &size);
* printf("-----DECODING\n");
* blah_in = eet_data_descriptor_decode(edd, data, size);
*
* printf("-----DECODED!\n");
* printf("%c\n", blah_in->character);
* printf("%x\n", (int)blah_in->sixteen);
* printf("%x\n", blah_in->integer);
* printf("%lx\n", blah_in->lots);
* printf("%f\n", (double)blah_in->floating);
* printf("%f\n", (double)blah_in->floating_lots);
* printf("%s\n", blah_in->string);
* printf("%p\n", blah_in->blah2);
* printf(" %s\n", blah_in->blah2->string);
* {
* Eina_List *l;
* Blah3 *blah3_in;
*
* EINA_LIST_FOREACH(blah_in->blah3, l, blah3_in)
* {
* printf("%p\n", blah3_in);
* printf(" %s\n", blah3_in->string);
* }
* }
* eet_data_descriptor_free(edd);
* eet_data_descriptor_free(edd2);
* eet_data_descriptor_free(edd3);
*
* eet_shutdown();
*
* return 0;
* }
* @endcode
*
* @{
*/
#define EET_T_UNKNOW 0 /**< Unknown data encoding type */
#define EET_T_CHAR 1 /**< Data type: char */
#define EET_T_SHORT 2 /**< Data type: short */
#define EET_T_INT 3 /**< Data type: int */
#define EET_T_LONG_LONG 4 /**< Data type: long long */
#define EET_T_FLOAT 5 /**< Data type: float */
#define EET_T_DOUBLE 6 /**< Data type: double */
#define EET_T_UCHAR 7 /**< Data type: unsigned char */
#define EET_T_USHORT 8 /**< Data type: unsigned short */
#define EET_T_UINT 9 /**< Data type: unsigned int */
#define EET_T_ULONG_LONG 10 /**< Data type: unsigned long long */
#define EET_T_STRING 11 /**< Data type: char * */
#define EET_T_INLINED_STRING 12 /**< Data type: char * (but compressed insi
de the resulting eet) */
#define EET_T_NULL 13 /**< Data type: (void *) (only use it if yo
u know why) */
#define EET_T_F32P32 14 /**< Data type: fixed point 32.32 */
#define EET_T_F16P16 15 /**< Data type: fixed point 16.16 */
#define EET_T_F8P24 16 /**< Data type: fixed point 8.24 */
#define EET_T_LAST 18 /**< Last data type */
#define EET_I_LIMIT 128 /**< Other type exist but are reserved for int #define EET_G_UNKNOWN 100 /**< Unknown group data encoding type */
ernal purpose. */ #define EET_G_ARRAY 101 /**< Fixed size array group type */
#define EET_G_VAR_ARRAY 102 /**< Variable size array group type */
#define EET_G_LIST 103 /**< Linked list group type */
#define EET_G_HASH 104 /**< Hash table group type */
#define EET_G_UNION 105 /**< Union group type */
#define EET_G_VARIANT 106 /**< Selectable subtype group */
#define EET_G_LAST 107 /**< Last group type */
/** #define EET_I_LIMIT 128 /**< Other type exist but are reserved for
* @typedef Eet_Data_Descriptor internal purpose. */
*
* Opaque handle that have information on a type members.
*
* The members are added by means of
* EET_DATA_DESCRIPTOR_ADD_BASIC(), EET_DATA_DESCRIPTOR_ADD_SUB(),
* EET_DATA_DESCRIPTOR_ADD_LIST(), EET_DATA_DESCRIPTOR_ADD_HASH()
* or eet_data_descriptor_element_add().
*
* @see eet_data_descriptor_stream_new()
* @see eet_data_descriptor_file_new()
* @see eet_data_descriptor_free()
*/
typedef struct _Eet_Data_Descriptor Eet_Data_Descriptor;
/** /**
* @def EET_DATA_DESCRIPTOR_CLASS_VERSION * @typedef Eet_Data_Descriptor
* The version of #Eet_Data_Descriptor_Class at the time of the *
* distribution of the sources. One should define this to its * Opaque handle that have information on a type members.
* version member so it is compatible with abi changes, or at least *
* will not crash with them. * The members are added by means of
*/ * EET_DATA_DESCRIPTOR_ADD_BASIC(), EET_DATA_DESCRIPTOR_ADD_SUB(),
#define EET_DATA_DESCRIPTOR_CLASS_VERSION 3 * EET_DATA_DESCRIPTOR_ADD_LIST(), EET_DATA_DESCRIPTOR_ADD_HASH()
* or eet_data_descriptor_element_add().
*
* @see eet_data_descriptor_stream_new()
* @see eet_data_descriptor_file_new()
* @see eet_data_descriptor_free()
*/
typedef struct _Eet_Data_Descriptor Eet_Data_Descriptor;
/** /**
* @typedef Eet_Data_Descriptor_Class * @def EET_DATA_DESCRIPTOR_CLASS_VERSION
* * The version of #Eet_Data_Descriptor_Class at the time of the
* Instructs Eet about memory management for different needs under * distribution of the sources. One should define this to its
* serialization and parse process. * version member so it is compatible with abi changes, or at least
*/ * will not crash with them.
typedef struct _Eet_Data_Descriptor_Class Eet_Data_Descriptor_Class; */
#define EET_DATA_DESCRIPTOR_CLASS_VERSION 4
/** /**
* @struct _Eet_Data_Descriptor_Class * @typedef Eet_Data_Descriptor_Class
* *
* Instructs Eet about memory management for different needs under * Instructs Eet about memory management for different needs under
* serialization and parse process. * serialization and parse process.
* */
* If using Eina data types, it is advised to use the helpers typedef struct _Eet_Data_Descriptor_Class Eet_Data_Descriptor_Class;
* EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET() and
* EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET().
*/
struct _Eet_Data_Descriptor_Class
{
int version; /**< ABI version as #EET_DATA_DESCRIPTOR_CLASS_
VERSION */
const char *name; /**< Name of data type to be serialized */
int size; /**< Size in bytes of data type to be serialized *
/
struct {
void *(*mem_alloc) (size_t size); /**< how to allocate memory (
usually malloc()) */
void (*mem_free) (void *mem); /**< how to free memory (usually
free()) */
char *(*str_alloc) (const char *str); /**< how to allocate a s
tring */
void (*str_free) (const char *str); /**< how to free a string
*/
void *(*list_next) (void *l); /**< how to iterate to the next e
lement of a list. Receives and should return the list node. */
void *(*list_append) (void *l, void *d); /**< how to append dat
a @p d to list which head node is @p l */
void *(*list_data) (void *l); /**< retrieves the data from node
@p l */
void *(*list_free) (void *l); /**< free all the nodes from the
list which head node is @p l */
void (*hash_foreach) (void *h, int (*func) (void *h, const cha
r *k, void *dt, void *fdt), void *fdt); /**< iterates over all elements in
the hash @p h in no specific order */
void *(*hash_add) (void *h, const char *k, void *d); /**< add a
new data @p d as key @p k in hash @p h */
void (*hash_free) (void *h); /**< free all entries from the ha
sh @p h */
char *(*str_direct_alloc) (const char *str); /**< how to alloc
ate a string directly from file backed/mmaped region pointed by @p str */
void (*str_direct_free) (const char *str); /**< how to free a
string returned by str_direct_alloc */
const char *(*type_get) (const void *data, Eina_Bool *unknow); /* typedef int (*Eet_Descriptor_Hash_Foreach_Callback_Callback)(void *
*< convert any kind of data type to a name that define an Eet_Data_Element. h, const char *k, void *dt, void *fdt);
*/
Eina_Bool (*type_set) (const char *type, void *data, Eina_Bool u
nknow); /**< set the type at a particular adress */
} func;
};
/** typedef void *(*Eet_Descriptor_Mem_Alloc_Callback)(size_t size);
* @} typedef void (*Eet_Descriptor_Mem_Free_Callback)(void *mem);
*/ typedef char *(*Eet_Descriptor_Str_Alloc_Callback)(const char *str);
typedef void (*Eet_Descriptor_Str_Free_Callback)(const char *str);
typedef void *(*Eet_Descriptor_List_Next_Callback)(void *l);
typedef void *(*Eet_Descriptor_List_Append_Callback)(void *l, void *d
);
typedef void *(*Eet_Descriptor_List_Data_Callback)(void *l);
typedef void *(*Eet_Descriptor_List_Free_Callback)(void *l);
typedef void (*Eet_Descriptor_Hash_Foreach_Callback)(void *h, Eet_De
scriptor_Hash_Foreach_Callback_Callback func, void *fdt);
typedef void *(*Eet_Descriptor_Hash_Add_Callback)(void *h, const char
*k, void *d);
typedef void (*Eet_Descriptor_Hash_Free_Callback)(void *h);
typedef char *(*Eet_Descriptor_Str_Direct_Alloc_Callback)(const char
*str);
typedef void (*Eet_Descriptor_Str_Direct_Free_Callback)(const char *
str);
typedef const char *(*Eet_Descriptor_Type_Get_Callback)(const void *data, E
ina_Bool *unknow);
typedef Eina_Bool (*Eet_Descriptor_Type_Set_Callback)(const char *type, v
oid *data, Eina_Bool unknow);
typedef void *(*Eet_Descriptor_Array_Alloc_Callback)(size_t size);
typedef void (*Eet_Descriptor_Array_Free_Callback)(void *mem);
/**
* @struct _Eet_Data_Descriptor_Class
*
* Instructs Eet about memory management for different needs under
* serialization and parse process.
*
* If using Eina data types, it is advised to use the helpers
* EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET() and
* EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET().
*/
struct _Eet_Data_Descriptor_Class
{
int version; /**< ABI version as #EET_DATA_DESCRIPTOR_CLASS_VER
SION */
const char *name; /**< Name of data type to be serialized */
int size; /**< Size in bytes of data type to be serialized */
struct {
Eet_Descriptor_Mem_Alloc_Callback mem_alloc; /**< how to allocate memo
ry (usually malloc()) */
Eet_Descriptor_Mem_Free_Callback mem_free; /**< how to free memory (us
ually free()) */
Eet_Descriptor_Str_Alloc_Callback str_alloc; /**< how to allocate a st
ring */
Eet_Descriptor_Str_Free_Callback str_free; /**< how to free a string *
/
Eet_Descriptor_List_Next_Callback list_next; /**< how to iterate to th
e next element of a list. Receives and should return the list node. */
Eet_Descriptor_List_Append_Callback list_append; /**< how to append da
ta @p d to list which head node is @p l */
Eet_Descriptor_List_Data_Callback list_data; /**< retrieves the data f
rom node @p l */
Eet_Descriptor_List_Free_Callback list_free; /**< free all the nodes f
rom the list which head node is @p l */
Eet_Descriptor_Hash_Foreach_Callback hash_foreach; /**< iterates over
all elements in the hash @p h in no specific order */
Eet_Descriptor_Hash_Add_Callback hash_add; /**< add a new data @p d as
key @p k in hash @p h */
Eet_Descriptor_Hash_Free_Callback hash_free; /**< free all entries fro
m the hash @p h */
Eet_Descriptor_Str_Direct_Alloc_Callback str_direct_alloc; /**< how to
allocate a string directly from file backed/mmaped region pointed by @p st
r */
Eet_Descriptor_Str_Direct_Free_Callback str_direct_free; /**< how to f
ree a string returned by str_direct_alloc */
Eet_Descriptor_Type_Get_Callback type_get; /**< convert any kind of da
ta type to a name that define an Eet_Data_Element. */
Eet_Descriptor_Type_Set_Callback type_set; /**< set the type at a part
icular address */
Eet_Descriptor_Array_Alloc_Callback array_alloc; /**< how to allocate
memory for array (usually malloc()) */
Eet_Descriptor_Array_Free_Callback array_free; /**< how to free memory
for array (usually free()) */
} func;
};
/** /**
* Create a new empty data structure descriptor. * @}
* @param name The string name of this data structure (most be a */
* global constant and never change).
* @param size The size of the struct (in bytes).
* @param func_list_next The function to get the next list node.
* @param func_list_append The function to append a member to a list.
* @param func_list_data The function to get the data from a list node.
* @param func_list_free The function to free an entire linked list.
* @param func_hash_foreach The function to iterate through all
* hash table entries.
* @param func_hash_add The function to add a member to a hash table.
* @param func_hash_free The function to free an entire hash table.
* @return A new empty data descriptor.
*
* This function creates a new data descriptore and returns a handle to
the
* new data descriptor. On creation it will be empty, containing no cont
ents
* describing anything other than the shell of the data structure.
*
* You add structure members to the data descriptor using the macros
* EET_DATA_DESCRIPTOR_ADD_BASIC(), EET_DATA_DESCRIPTOR_ADD_SUB() and
* EET_DATA_DESCRIPTOR_ADD_LIST(), depending on what type of member you
are
* adding to the description.
*
* Once you have described all the members of a struct you want loaded,
or
* saved eet can load and save those members for you, encode them into
* endian-independant serialised data chunks for transmission across a
* a network or more.
*
* The function pointers to the list and hash table functions are only
* needed if you use those data types, else you can pass NULL instead.
*
* @since 1.0.0
* @ingroup Eet_Data_Group
*
* @deprecated use eet_data_descriptor_stream_new() or
* eet_data_descriptor_file_new()
*/
EINA_DEPRECATED EAPI Eet_Data_Descriptor *eet_data_descriptor_new(const
char *name, int size, void *(*func_list_next) (void *l), void *(*func_list_
append) (void *l, void *d), void *(*func_list_data) (void *l), void *(*func
_list_free) (void *l), void (*func_hash_foreach) (void *h, int (*func) (vo
id *h, const char *k, void *dt, void *fdt), void *fdt), void *(*func_hash_a
dd) (void *h, const char *k, void *d), void (*func_hash_free) (void *h));
/*
* FIXME:
*
* moving to this api from the old above. this will break things when th
e
* move happens - but be warned
*/
EINA_DEPRECATED EAPI Eet_Data_Descriptor *eet_data_descriptor2_new(const
Eet_Data_Descriptor_Class *eddc);
EINA_DEPRECATED EAPI Eet_Data_Descriptor *eet_data_descriptor3_new(const
Eet_Data_Descriptor_Class *eddc);
/** /**
* This function creates a new data descriptore and returns a handle to * Create a new empty data structure descriptor.
the * @param name The string name of this data structure (most be a
* new data descriptor. On creation it will be empty, containing no cont * global constant and never change).
ents * @param size The size of the struct (in bytes).
* describing anything other than the shell of the data structure. * @param func_list_next The function to get the next list node.
* @param eddc The data descriptor to free. * @param func_list_append The function to append a member to a list.
* * @param func_list_data The function to get the data from a list node.
* You add structure members to the data descriptor using the macros * @param func_list_free The function to free an entire linked list.
* EET_DATA_DESCRIPTOR_ADD_BASIC(), EET_DATA_DESCRIPTOR_ADD_SUB() and * @param func_hash_foreach The function to iterate through all
* EET_DATA_DESCRIPTOR_ADD_LIST(), depending on what type of member you * hash table entries.
are * @param func_hash_add The function to add a member to a hash table.
* adding to the description. * @param func_hash_free The function to free an entire hash table.
* * @return A new empty data descriptor.
* Once you have described all the members of a struct you want loaded, *
or * This function creates a new data descriptore and returns a handle to the
* saved eet can load and save those members for you, encode them into * new data descriptor. On creation it will be empty, containing no content
* endian-independant serialised data chunks for transmission across a s
* a network or more. * describing anything other than the shell of the data structure.
* *
* This function specially ignore str_direct_alloc and str_direct_free. * You add structure members to the data descriptor using the macros
It * EET_DATA_DESCRIPTOR_ADD_BASIC(), EET_DATA_DESCRIPTOR_ADD_SUB() and
* is usefull when the eet_data you are reading don't have a dictionnary * EET_DATA_DESCRIPTOR_ADD_LIST(), depending on what type of member you are
* like network stream or ipc. It also mean that all string will be allo * adding to the description.
cated *
* and duplicated in memory. * Once you have described all the members of a struct you want loaded, or
* * saved eet can load and save those members for you, encode them into
* @since 1.2.3 * endian-independent serialised data chunks for transmission across a
* @ingroup Eet_Data_Group * a network or more.
*/ *
EAPI Eet_Data_Descriptor *eet_data_descriptor_stream_new(const Eet_Data_ * The function pointers to the list and hash table functions are only
Descriptor_Class *eddc); * needed if you use those data types, else you can pass NULL instead.
*
* @since 1.0.0
* @ingroup Eet_Data_Group
*
* @deprecated use eet_data_descriptor_stream_new() or
* eet_data_descriptor_file_new()
*/
EINA_DEPRECATED EAPI Eet_Data_Descriptor *
eet_data_descriptor_new(const char *name,
int size,
Eet_Descriptor_List_Next_Callback func_list_next,
Eet_Descriptor_List_Append_Callback func_list_appen
d,
Eet_Descriptor_List_Data_Callback func_list_data,
Eet_Descriptor_List_Free_Callback func_list_free,
Eet_Descriptor_Hash_Foreach_Callback func_hash_fore
ach,
Eet_Descriptor_Hash_Add_Callback func_hash_add,
Eet_Descriptor_Hash_Free_Callback func_hash_free);
/*
* FIXME:
*
* moving to this api from the old above. this will break things when the
* move happens - but be warned
*/
EINA_DEPRECATED EAPI Eet_Data_Descriptor *
eet_data_descriptor2_new(const Eet_Data_Descriptor_Class *eddc);
EINA_DEPRECATED EAPI Eet_Data_Descriptor *
eet_data_descriptor3_new(const Eet_Data_Descriptor_Class *eddc);
/** /**
* This function creates a new data descriptore and returns a handle to * This function creates a new data descriptore and returns a handle to the
the * new data descriptor. On creation it will be empty, containing no content
* new data descriptor. On creation it will be empty, containing no cont s
ents * describing anything other than the shell of the data structure.
* describing anything other than the shell of the data structure. * @param eddc The data descriptor to free.
* @param eddc The data descriptor to free. *
* * You add structure members to the data descriptor using the macros
* You add structure members to the data descriptor using the macros * EET_DATA_DESCRIPTOR_ADD_BASIC(), EET_DATA_DESCRIPTOR_ADD_SUB() and
* EET_DATA_DESCRIPTOR_ADD_BASIC(), EET_DATA_DESCRIPTOR_ADD_SUB() and * EET_DATA_DESCRIPTOR_ADD_LIST(), depending on what type of member you are
* EET_DATA_DESCRIPTOR_ADD_LIST(), depending on what type of member you * adding to the description.
are *
* adding to the description. * Once you have described all the members of a struct you want loaded, or
* * saved eet can load and save those members for you, encode them into
* Once you have described all the members of a struct you want loaded, * endian-independent serialised data chunks for transmission across a
or * a network or more.
* saved eet can load and save those members for you, encode them into *
* endian-independant serialised data chunks for transmission across a * This function specially ignore str_direct_alloc and str_direct_free. It
* a network or more. * is useful when the eet_data you are reading don't have a dictionnary
* * like network stream or ipc. It also mean that all string will be allocat
* This function use str_direct_alloc and str_direct_free. It is ed
* usefull when the eet_data you are reading come from a file and * and duplicated in memory.
* have a dictionnary. This will reduce memory use, improve the *
* possibility for the OS to page this string out. But be carrefull * @since 1.2.3
* all EET_T_STRING are pointer to a mmapped area and it will point * @ingroup Eet_Data_Group
* to nowhere if you close the file. So as long as you use this */
* strings, you need to have the Eet_File open. EAPI Eet_Data_Descriptor *
* eet_data_descriptor_stream_new(const Eet_Data_Descriptor_Class *eddc);
* @since 1.2.3
* @ingroup Eet_Data_Group
*/
EAPI Eet_Data_Descriptor *eet_data_descriptor_file_new(const Eet_Data_De
scriptor_Class *eddc);
/** /**
* This function is an helper that set all the parameter of an * This function creates a new data descriptore and returns a handle to the
* Eet_Data_Descriptor_Class correctly when you use Eina data type * new data descriptor. On creation it will be empty, containing no content
* with a stream. s
* @param eddc The Eet_Data_Descriptor_Class you want to set. * describing anything other than the shell of the data structure.
* @param name The name of the structure described by this class. * @param eddc The data descriptor to free.
* @param size The size of the structure described by this class. *
* @return EINA_TRUE if the structure was correctly set (The only * You add structure members to the data descriptor using the macros
* reason that could make it fail is if you did give wrong * EET_DATA_DESCRIPTOR_ADD_BASIC(), EET_DATA_DESCRIPTOR_ADD_SUB() and
* parameter). * EET_DATA_DESCRIPTOR_ADD_LIST(), depending on what type of member you are
* * adding to the description.
* @since 1.2.3 *
* @ingroup Eet_Data_Group * Once you have described all the members of a struct you want loaded, or
*/ * saved eet can load and save those members for you, encode them into
EAPI Eina_Bool eet_eina_stream_data_descriptor_class_set(Eet_Data_Descri * endian-independent serialised data chunks for transmission across a
ptor_Class *eddc, const char *name, int size); * a network or more.
*
* This function use str_direct_alloc and str_direct_free. It is
* useful when the eet_data you are reading come from a file and
* have a dictionnary. This will reduce memory use, improve the
* possibility for the OS to page this string out. But be carrefull
* all EET_T_STRING are pointer to a mmapped area and it will point
* to nowhere if you close the file. So as long as you use this
* strings, you need to have the Eet_File open.
*
* @since 1.2.3
* @ingroup Eet_Data_Group
*/
EAPI Eet_Data_Descriptor *
eet_data_descriptor_file_new(const Eet_Data_Descriptor_Class *eddc);
/** /**
* This macro is an helper that set all the parameter of an * This function is an helper that set all the parameter of an
* Eet_Data_Descriptor_Class correctly when you use Eina data type * Eet_Data_Descriptor_Class correctly when you use Eina data type
* with stream. * with a stream.
* @param Clas The Eet_Data_Descriptor_Class you want to set. * @param eddc The Eet_Data_Descriptor_Class you want to set.
* @param Type The type of the structure described by this class. * @param name The name of the structure described by this class.
* @return EINA_TRUE if the structure was correctly set (The only * @param eddc_size The size of the Eet_Data_Descriptor_Class at the compil
* reason that could make it fail is if you did give wrong ation time.
* parameter). * @param size The size of the structure described by this class.
* * @return EINA_TRUE if the structure was correctly set (The only
* @since 1.2.3 * reason that could make it fail is if you did give wrong
* @ingroup Eet_Data_Group * parameter).
*/ *
#define EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(Clas, Type) (eet_eina_str * @since 1.2.3
eam_data_descriptor_class_set(Clas, #Type , sizeof (Type))) * @ingroup Eet_Data_Group
*/
EAPI Eina_Bool
eet_eina_stream_data_descriptor_class_set(Eet_Data_Descriptor_Class *eddc,
unsigned int eddc_si
ze,
const char *name,
int size);
/** /**
* This function is an helper that set all the parameter of an * This macro is an helper that set all the parameter of an
* Eet_Data_Descriptor_Class correctly when you use Eina data type * Eet_Data_Descriptor_Class correctly when you use Eina data type
* with a file. * with stream.
* @param eddc The Eet_Data_Descriptor_Class you want to set. * @param clas The Eet_Data_Descriptor_Class you want to set.
* @param name The name of the structure described by this class. * @param type The type of the structure described by this class.
* @param size The size of the structure described by this class. * @return EINA_TRUE if the structure was correctly set (The only
* @return EINA_TRUE if the structure was correctly set (The only * reason that could make it fail is if you did give wrong
* reason that could make it fail is if you did give wrong * parameter).
* parameter). *
* * @since 1.2.3
* @since 1.2.3 * @ingroup Eet_Data_Group
* @ingroup Eet_Data_Group */
*/ #define EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(clas, type)\
EAPI Eina_Bool eet_eina_file_data_descriptor_class_set(Eet_Data_Descript (eet_eina_stream_data_descriptor_class_set(clas, sizeof (*(clas)), # typ
or_Class *eddc, const char *name, int size); e, sizeof(type)))
/** /**
* This macro is an helper that set all the parameter of an * This function is an helper that set all the parameter of an
* Eet_Data_Descriptor_Class correctly when you use Eina data type * Eet_Data_Descriptor_Class correctly when you use Eina data type
* with file. * with a file.
* @param Clas The Eet_Data_Descriptor_Class you want to set. * @param eddc The Eet_Data_Descriptor_Class you want to set.
* @param Type The type of the structure described by this class. * @param eddc_size The size of the Eet_Data_Descriptor_Class at the compil
* @return EINA_TRUE if the structure was correctly set (The only ation time.
* reason that could make it fail is if you did give wrong * @param name The name of the structure described by this class.
* parameter). * @param size The size of the structure described by this class.
* * @return EINA_TRUE if the structure was correctly set (The only
* @since 1.2.3 * reason that could make it fail is if you did give wrong
* @ingroup Eet_Data_Group * parameter).
*/ *
#define EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(Clas, Type) (eet_eina_file_ * @since 1.2.3
data_descriptor_class_set(Clas, #Type , sizeof (Type))) * @ingroup Eet_Data_Group
*/
EAPI Eina_Bool
eet_eina_file_data_descriptor_class_set(Eet_Data_Descriptor_Class *eddc,
unsigned int eddc_siz
e,
const char *name,
int size);
/** /**
* This function frees a data descriptor when it is not needed anymore. * This macro is an helper that set all the parameter of an
* @param edd The data descriptor to free. * Eet_Data_Descriptor_Class correctly when you use Eina data type
* * with file.
* This function takes a data descriptor handle as a parameter and frees * @param clas The Eet_Data_Descriptor_Class you want to set.
all * @param type The type of the structure described by this class.
* data allocated for the data descriptor and the handle itself. After t * @return EINA_TRUE if the structure was correctly set (The only
his * reason that could make it fail is if you did give wrong
* call the descriptor is no longer valid. * parameter).
* *
* @since 1.0.0 * @since 1.2.3
* @ingroup Eet_Data_Group * @ingroup Eet_Data_Group
*/ */
EAPI void eet_data_descriptor_free(Eet_Data_Descriptor *edd); #define EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(clas, type)\
(eet_eina_file_data_descriptor_class_set(clas, sizeof (*(clas)), # type,
sizeof(type)))
/** /**
* This function is an internal used by macros. * This function frees a data descriptor when it is not needed anymore.
* * @param edd The data descriptor to free.
* This function is used by macros EET_DATA_DESCRIPTOR_ADD_BASIC(), *
* EET_DATA_DESCRIPTOR_ADD_SUB() and EET_DATA_DESCRIPTOR_ADD_LIST(). It * This function takes a data descriptor handle as a parameter and frees al
is l
* complex to use by hand and should be left to be used by the macros, a * data allocated for the data descriptor and the handle itself. After this
nd * call the descriptor is no longer valid.
* thus is not documented. *
* * @since 1.0.0
* @param edd The data descriptor handle to add element (member). * @ingroup Eet_Data_Group
* @param name The name of element to be serialized. */
* @param type The type of element to be serialized, like EAPI void
* #EET_T_INT. If #EET_T_UNKNOW, then it is considered to be a eet_data_descriptor_free(Eet_Data_Descriptor *edd);
* group, list or hash.
* @param group_type If element type is #EET_T_UNKNOW, then the @p
* group_type will speficy if it is a list (#EET_G_LIST),
* array (#EET_G_ARRAY) and so on. If #EET_G_UNKNOWN, then
* the member is a subtype (pointer to another type defined by
* another #Eet_Data_Descriptor).
* @param offset byte offset inside the source memory to be serialized.
* @param count number of elements (if #EET_G_ARRAY or #EET_G_VAR_ARRAY)
.
* @param counter_name variable that defines the name of number of eleme
nts.
* @param subtype If contains a subtype, then its data descriptor.
*
* @since 1.0.0
* @ingroup Eet_Data_Group
*/
EAPI void eet_data_descriptor_element_add(Eet_Data_Descriptor *edd, cons
t char *name, int type, int group_type, int offset, /* int count_offset, *
/int count, const char *counter_name, Eet_Data_Descriptor *subtype);
/** /**
* Read a data structure from an eet file and decodes it. * This function is an internal used by macros.
* @param ef The eet file handle to read from. *
* @param edd The data descriptor handle to use when decoding. * This function is used by macros EET_DATA_DESCRIPTOR_ADD_BASIC(),
* @param name The key the data is stored under in the eet file. * EET_DATA_DESCRIPTOR_ADD_SUB() and EET_DATA_DESCRIPTOR_ADD_LIST(). It is
* @return A pointer to the decoded data structure. * complex to use by hand and should be left to be used by the macros, and
* * thus is not documented.
* This function decodes a data structure stored in an eet file, returni *
ng * @param edd The data descriptor handle to add element (member).
* a pointer to it if it decoded successfully, or NULL on failure. This * @param name The name of element to be serialized.
* can save a programmer dozens of hours of work in writing configuratio * @param type The type of element to be serialized, like
n * #EET_T_INT. If #EET_T_UNKNOW, then it is considered to be a
* file parsing and writing code, as eet does all that work for the prog * group, list or hash.
ram * @param group_type If element type is #EET_T_UNKNOW, then the @p
* and presents a program-friendly data structure, just as the programme * group_type will speficy if it is a list (#EET_G_LIST),
r * array (#EET_G_ARRAY) and so on. If #EET_G_UNKNOWN, then
* likes. Eet can handle members being added or deleted from the data in * the member is a subtype (pointer to another type defined by
* storage and safely zero-fills unfilled members if they were not found * another #Eet_Data_Descriptor).
* in the data. It checks sizes and headers whenever it reads data, allo * @param offset byte offset inside the source memory to be serialized.
wing * @param count number of elements (if #EET_G_ARRAY or #EET_G_VAR_ARRAY).
* the programmer to not worry about corrupt data. * @param counter_name variable that defines the name of number of elements
* .
* Once a data structure has been described by the programmer with the * @param subtype If contains a subtype, then its data descriptor.
* fields they wish to save or load, storing or retrieving a data struct *
ure * @since 1.0.0
* from an eet file, or from a chunk of memory is as simple as a single * @ingroup Eet_Data_Group
* function call. */
* EAPI void
* @see eet_data_read_cipher() eet_data_descriptor_element_add(Eet_Data_Descriptor *edd,
* const char *name,
* @since 1.0.0 int type,
* @ingroup Eet_Data_Group int group_type,
*/ int offset,
EAPI void *eet_data_read(Eet_File *ef, Eet_Data_Descriptor *edd, const c /* int count_offset, */
har *name); int count,
const char *counter_name,
Eet_Data_Descriptor *subtype);
/** /**
* Write a data structure from memory and store in an eet file. * Read a data structure from an eet file and decodes it.
* @param ef The eet file handle to write to. * @param ef The eet file handle to read from.
* @param edd The data descriptor to use when encoding. * @param edd The data descriptor handle to use when decoding.
* @param name The key to store the data under in the eet file. * @param name The key the data is stored under in the eet file.
* @param data A pointer to the data structure to ssave and encode. * @return A pointer to the decoded data structure.
* @param compress Compression flags for storage. *
* @return bytes written on successful write, 0 on failure. * This function decodes a data structure stored in an eet file, returning
* * a pointer to it if it decoded successfully, or NULL on failure. This
* This function is the reverse of eet_data_read(), saving a data struct * can save a programmer dozens of hours of work in writing configuration
ure * file parsing and writing code, as eet does all that work for the program
* to an eet file. * and presents a program-friendly data structure, just as the programmer
* * likes. Eet can handle members being added or deleted from the data in
* @see eet_data_write_cipher() * storage and safely zero-fills unfilled members if they were not found
* * in the data. It checks sizes and headers whenever it reads data, allowin
* @since 1.0.0 g
* @ingroup Eet_Data_Group * the programmer to not worry about corrupt data.
*/ *
EAPI int eet_data_write(Eet_File *ef, Eet_Data_Descriptor *edd, const ch * Once a data structure has been described by the programmer with the
ar *name, const void *data, int compress); * fields they wish to save or load, storing or retrieving a data structure
* from an eet file, or from a chunk of memory is as simple as a single
* function call.
*
* @see eet_data_read_cipher()
*
* @since 1.0.0
* @ingroup Eet_Data_Group
*/
EAPI void *
eet_data_read(Eet_File *ef,
Eet_Data_Descriptor *edd,
const char *name);
/** /**
* Dump an eet encoded data structure into ascii text * Write a data structure from memory and store in an eet file.
* @param data_in The pointer to the data to decode into a struct. * @param ef The eet file handle to write to.
* @param size_in The size of the data pointed to in bytes. * @param edd The data descriptor to use when encoding.
* @param dumpfunc The function to call passed a string when new * @param name The key to store the data under in the eet file.
* data is converted to text * @param data A pointer to the data structure to ssave and encode.
* @param dumpdata The data to pass to the @p dumpfunc callback. * @param compress Compression flags for storage.
* @return 1 on success, 0 on failure * @return bytes written on successful write, 0 on failure.
* *
* This function will take a chunk of data encoded by * This function is the reverse of eet_data_read(), saving a data structure
* eet_data_descriptor_encode() and convert it into human readable * to an eet file.
* ascii text. It does this by calling the @p dumpfunc callback *
* for all new text that is generated. This callback should append * @see eet_data_write_cipher()
* to any existing text buffer and will be passed the pointer @p *
* dumpdata as a parameter as well as a string with new text to be * @since 1.0.0
* appended. * @ingroup Eet_Data_Group
* */
* Example: EAPI int
* eet_data_write(Eet_File *ef,
* @code Eet_Data_Descriptor *edd,
* void output(void *data, const char *string) const char *name,
* { const void *data,
* printf("%s", string); int compress);
* }
*
* void dump(const char *file)
* {
* FILE *f;
* int len;
* void *data;
*
* f = fopen(file, "r");
* fseek(f, 0, SEEK_END);
* len = ftell(f);
* rewind(f);
* data = malloc(len);
* fread(data, len, 1, f);
* fclose(f);
* eet_data_text_dump(data, len, output, NULL);
* }
* @endcode
*
* @see eet_data_text_dump_cipher()
*
* @since 1.0.0
* @ingroup Eet_Data_Group
*/
EAPI int eet_data_text_dump(const void *data_in, int size_in, void (*dum
pfunc) (void *data, const char *str), void *dumpdata);
/** typedef void (*Eet_Dump_Callback)(void *data, const char *str);
* Take an ascii encoding from eet_data_text_dump() and re-encode in bin
ary.
* @param text The pointer to the string data to parse and encode.
* @param textlen The size of the string in bytes (not including 0
* byte terminator).
* @param size_ret This gets filled in with the encoded data blob
* size in bytes.
* @return The encoded data on success, NULL on failure.
*
* This function will parse the string pointed to by @p text and return
* an encoded data lump the same way eet_data_descriptor_encode() takes
an
* in-memory data struct and encodes into a binary blob. @p text is a no
rmal
* C string.
*
* @see eet_data_text_undump_cipher()
*
* @since 1.0.0
* @ingroup Eet_Data_Group
*/
EAPI void *eet_data_text_undump(const char *text, int textlen, int *size
_ret);
/** /**
* Dump an eet encoded data structure from an eet file into ascii text * Dump an eet encoded data structure into ascii text
* @param ef A valid eet file handle. * @param data_in The pointer to the data to decode into a struct.
* @param name Name of the entry. eg: "/base/file_i_want". * @param size_in The size of the data pointed to in bytes.
* @param dumpfunc The function to call passed a string when new * @param dumpfunc The function to call passed a string when new
* data is converted to text * data is converted to text
* @param dumpdata The data to pass to the @p dumpfunc callback. * @param dumpdata The data to pass to the @p dumpfunc callback.
* @return 1 on success, 0 on failure * @return 1 on success, 0 on failure
* *
* This function will take an open and valid eet file from * This function will take a chunk of data encoded by
* eet_open() request the data encoded by * eet_data_descriptor_encode() and convert it into human readable
* eet_data_descriptor_encode() corresponding to the key @p name * ascii text. It does this by calling the @p dumpfunc callback
* and convert it into human readable ascii text. It does this by * for all new text that is generated. This callback should append
* calling the @p dumpfunc callback for all new text that is * to any existing text buffer and will be passed the pointer @p
* generated. This callback should append to any existing text * dumpdata as a parameter as well as a string with new text to be
* buffer and will be passed the pointer @p dumpdata as a parameter * appended.
* as well as a string with new text to be appended. *
* * Example:
* @see eet_data_dump_cipher() *
* * @code
* @since 1.0.0 * void output(void *data, const char *string)
* @ingroup Eet_Data_Group * {
*/ * printf("%s", string);
EAPI int eet_data_dump(Eet_File *ef, const char *name, void (*dumpfunc) * }
(void *data, const char *str), void *dumpdata); *
* void dump(const char *file)
* {
* FILE *f;
* int len;
* void *data;
*
* f = fopen(file, "r");
* fseek(f, 0, SEEK_END);
* len = ftell(f);
* rewind(f);
* data = malloc(len);
* fread(data, len, 1, f);
* fclose(f);
* eet_data_text_dump(data, len, output, NULL);
* }
* @endcode
*
* @see eet_data_text_dump_cipher()
*
* @since 1.0.0
* @ingroup Eet_Data_Group
*/
EAPI int
eet_data_text_dump(const void *data_in,
int size_in,
Eet_Dump_Callback dumpfunc,
void *dumpdata);
/** /**
* Take an ascii encoding from eet_data_dump() and re-encode in binary. * Take an ascii encoding from eet_data_text_dump() and re-encode in binary
* @param ef A valid eet file handle. .
* @param name Name of the entry. eg: "/base/file_i_want". * @param text The pointer to the string data to parse and encode.
* @param text The pointer to the string data to parse and encode. * @param textlen The size of the string in bytes (not including 0
* @param textlen The size of the string in bytes (not including 0 * byte terminator).
* byte terminator). * @param size_ret This gets filled in with the encoded data blob
* @param compress Compression flags (1 == compress, 0 = don't compress) * size in bytes.
. * @return The encoded data on success, NULL on failure.
* @return 1 on success, 0 on failure *
* * This function will parse the string pointed to by @p text and return
* This function will parse the string pointed to by @p text, * an encoded data lump the same way eet_data_descriptor_encode() takes an
* encode it the same way eet_data_descriptor_encode() takes an * in-memory data struct and encodes into a binary blob. @p text is a norma
* in-memory data struct and encodes into a binary blob. l
* * C string.
* The data (optionally compressed) will be in ram, pending a flush to *
* disk (it will stay in ram till the eet file handle is closed though). * @see eet_data_text_undump_cipher()
* *
* @see eet_data_undump_cipher() * @since 1.0.0
* * @ingroup Eet_Data_Group
* @since 1.0.0 */
* @ingroup Eet_Data_Group EAPI void *
*/ eet_data_text_undump(const char *text,
EAPI int eet_data_undump(Eet_File *ef, const char *name, const char *tex int textlen,
t, int textlen, int compress); int *size_ret);
/** /**
* Decode a data structure from an arbitary location in memory. * Dump an eet encoded data structure from an eet file into ascii text
* @param edd The data descriptor to use when decoding. * @param ef A valid eet file handle.
* @param data_in The pointer to the data to decode into a struct. * @param name Name of the entry. eg: "/base/file_i_want".
* @param size_in The size of the data pointed to in bytes. * @param dumpfunc The function to call passed a string when new
* @return NULL on failure, or a valid decoded struct pointer on success * data is converted to text
. * @param dumpdata The data to pass to the @p dumpfunc callback.
* * @return 1 on success, 0 on failure
* This function will decode a data structure that has been encoded usin *
g * This function will take an open and valid eet file from
* eet_data_descriptor_encode(), and return a data structure with all it * eet_open() request the data encoded by
s * eet_data_descriptor_encode() corresponding to the key @p name
* elements filled out, if successful, or NULL on failure. * and convert it into human readable ascii text. It does this by
* * calling the @p dumpfunc callback for all new text that is
* The data to be decoded is stored at the memory pointed to by @p data_ * generated. This callback should append to any existing text
in, * buffer and will be passed the pointer @p dumpdata as a parameter
* and is described by the descriptor pointed to by @p edd. The data siz * as well as a string with new text to be appended.
e is *
* passed in as the value to @p size_in, ande must be greater than 0 to * @see eet_data_dump_cipher()
* succeed. *
* * @since 1.0.0
* This function is useful for decoding data structures delivered to the * @ingroup Eet_Data_Group
* application by means other than an eet file, such as an IPC or socket */
* connection, raw files, shared memory etc. EAPI int
* eet_data_dump(Eet_File *ef,
* Please see eet_data_read() for more information. const char *name,
* Eet_Dump_Callback dumpfunc,
* @see eet_data_descriptor_decode_cipher() void *dumpdata);
*
* @since 1.0.0
* @ingroup Eet_Data_Group
*/
EAPI void *eet_data_descriptor_decode(Eet_Data_Descriptor *edd, const vo
id *data_in, int size_in);
/** /**
* Encode a dsata struct to memory and return that encoded data. * Take an ascii encoding from eet_data_dump() and re-encode in binary.
* @param edd The data descriptor to use when encoding. * @param ef A valid eet file handle.
* @param data_in The pointer to the struct to encode into data. * @param name Name of the entry. eg: "/base/file_i_want".
* @param size_ret pointer to the an int to be filled with the decoded s * @param text The pointer to the string data to parse and encode.
ize. * @param textlen The size of the string in bytes (not including 0
* @return NULL on failure, or a valid encoded data chunk on success. * byte terminator).
* * @param compress Compression flags (1 == compress, 0 = don't compress).
* This function takes a data structutre in memory and encodes it into a * @return 1 on success, 0 on failure
* serialised chunk of data that can be decoded again by *
* eet_data_descriptor_decode(). This is useful for being able to transm * This function will parse the string pointed to by @p text,
it * encode it the same way eet_data_descriptor_encode() takes an
* data structures across sockets, pipes, IPC or shared file mechanisms, * in-memory data struct and encodes into a binary blob.
* without having to worry about memory space, machine type, endianess e *
tc. * The data (optionally compressed) will be in ram, pending a flush to
* * disk (it will stay in ram till the eet file handle is closed though).
* The parameter @p edd must point to a valid data descriptor, and *
* @p data_in must point to the right data structure to encode. If not, * @see eet_data_undump_cipher()
the *
* encoding may fail. * @since 1.0.0
* * @ingroup Eet_Data_Group
* On success a non NULL valid pointer is returned and what @p size_ret */
* points to is set to the size of this decoded data, in bytes. When the EAPI int
* encoded data is no longer needed, call free() on it. On failure NULL eet_data_undump(Eet_File *ef,
is const char *name,
* returned and what @p size_ret points to is set to 0. const char *text,
* int textlen,
* Please see eet_data_write() for more information. int compress);
*
* @see eet_data_descriptor_encode_cipher()
*
* @since 1.0.0
* @ingroup Eet_Data_Group
*/
EAPI void *eet_data_descriptor_encode(Eet_Data_Descriptor *edd, const vo
id *data_in, int *size_ret);
/** /**
* Add a basic data element to a data descriptor. * Decode a data structure from an arbitrary location in memory.
* @param edd The data descriptor to add the type to. * @param edd The data descriptor to use when decoding.
* @param struct_type The type of the struct. * @param data_in The pointer to the data to decode into a struct.
* @param name The string name to use to encode/decode this member * @param size_in The size of the data pointed to in bytes.
* (must be a constant global and never change). * @return NULL on failure, or a valid decoded struct pointer on success.
* @param member The struct member itself to be encoded. *
* @param type The type of the member to encode. * This function will decode a data structure that has been encoded using
* * eet_data_descriptor_encode(), and return a data structure with all its
* This macro is a convenience macro provided to add a member to * elements filled out, if successful, or NULL on failure.
* the data descriptor @p edd. The type of the structure is *
* provided as the @p struct_type parameter (for example: struct * The data to be decoded is stored at the memory pointed to by @p data_in,
* my_struct). The @p name parameter defines a string that will be * and is described by the descriptor pointed to by @p edd. The data size i
* used to uniquely name that member of the struct (it is suggested s
* to use the struct member itself). The @p member parameter is * passed in as the value to @p size_in, ande must be greater than 0 to
* the actual struct member itself (for eet_dictionary_string_check * succeed.
* example: values), and @p type is the basic data type of the *
* member which must be one of: EET_T_CHAR, EET_T_SHORT, EET_T_INT, * This function is useful for decoding data structures delivered to the
* EET_T_LONG_LONG, EET_T_FLOAT, EET_T_DOUBLE, EET_T_UCHAR, * application by means other than an eet file, such as an IPC or socket
* EET_T_USHORT, EET_T_UINT, EET_T_ULONG_LONG or EET_T_STRING. * connection, raw files, shared memory etc.
* *
* @since 1.0.0 * Please see eet_data_read() for more information.
* @ingroup Eet_Data_Group *
*/ * @see eet_data_descriptor_decode_cipher()
*
* @since 1.0.0
* @ingroup Eet_Data_Group
*/
EAPI void *
eet_data_descriptor_decode(Eet_Data_Descriptor *edd,
const void *data_in,
int size_in);
/**
* Encode a dsata struct to memory and return that encoded data.
* @param edd The data descriptor to use when encoding.
* @param data_in The pointer to the struct to encode into data.
* @param size_ret pointer to the an int to be filled with the decoded size
.
* @return NULL on failure, or a valid encoded data chunk on success.
*
* This function takes a data structutre in memory and encodes it into a
* serialised chunk of data that can be decoded again by
* eet_data_descriptor_decode(). This is useful for being able to transmit
* data structures across sockets, pipes, IPC or shared file mechanisms,
* without having to worry about memory space, machine type, endianess etc.
*
* The parameter @p edd must point to a valid data descriptor, and
* @p data_in must point to the right data structure to encode. If not, the
* encoding may fail.
*
* On success a non NULL valid pointer is returned and what @p size_ret
* points to is set to the size of this decoded data, in bytes. When the
* encoded data is no longer needed, call free() on it. On failure NULL is
* returned and what @p size_ret points to is set to 0.
*
* Please see eet_data_write() for more information.
*
* @see eet_data_descriptor_encode_cipher()
*
* @since 1.0.0
* @ingroup Eet_Data_Group
*/
EAPI void *
eet_data_descriptor_encode(Eet_Data_Descriptor *edd,
const void *data_in,
int *size_ret);
/**
* Add a basic data element 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.
* @param type The type of the member to encode.
*
* This macro is a convenience macro provided to add a member to
* the data descriptor @p edd. The type of the structure is
* provided as the @p struct_type parameter (for example: struct
* my_struct). The @p name parameter defines a string that will be
* used to uniquely name that member of the struct (it is suggested
* to use the struct member itself). The @p member parameter is
* the actual struct member itself (for eet_dictionary_string_check
* example: values), and @p type is the basic data type of the
* member which must be one of: EET_T_CHAR, EET_T_SHORT, EET_T_INT,
* EET_T_LONG_LONG, EET_T_FLOAT, EET_T_DOUBLE, EET_T_UCHAR,
* EET_T_USHORT, EET_T_UINT, EET_T_ULONG_LONG or EET_T_STRING.
*
* @since 1.0.0
* @ingroup Eet_Data_Group
*/
#define EET_DATA_DESCRIPTOR_ADD_BASIC(edd, struct_type, name, member, type) \ #define EET_DATA_DESCRIPTOR_ADD_BASIC(edd, struct_type, name, member, type) \
{ \ do { \
struct_type ___ett; \ struct_type ___ett; \
\ eet_data_descriptor_element_add(edd, name, type, EET_G_UNKNOWN, \
eet_data_descriptor_element_add(edd, name, type, EET_G_UNKNOWN, \ (char *)(& (___ett.member)) - \
(char *)(&(___ett.member)) - (char * (char *)(& (___ett)), \
)(&(___ett)), \ 0, /* 0, */ NULL, NULL); \
0, /* 0, */NULL, NULL); \ } while(0)
}
/** /**
* Add a sub-element type to a data descriptor * Add a sub-element type to a data descriptor
* @param edd The data descriptor to add the type to. * @param edd The data descriptor to add the type to.
* @param struct_type The type of the struct. * @param struct_type The type of the struct.
* @param name The string name to use to encode/decode this member * @param name The string name to use to encode/decode this member
* (must be a constant global and never change). * (must be a constant global and never change).
* @param member The struct member itself to be encoded. * @param member The struct member itself to be encoded.
* @param subtype The type of sub-type struct to add. * @param subtype The type of sub-type struct to add.
* *
* This macro lets you easily add a sub-type (a struct that's pointed to * This macro lets you easily add a sub-type (a struct that's pointed to
* by this one). All the parameters are the same as for * by this one). All the parameters are the same as for
* EET_DATA_DESCRIPTOR_ADD_BASIC(), with the @p subtype being the except * EET_DATA_DESCRIPTOR_ADD_BASIC(), with the @p subtype being the exception
ion. .
* This must be the data descriptor of the struct that is pointed to by * This must be the data descriptor of the struct that is pointed to by
* this element. * this element.
* *
* @since 1.0.0 * @since 1.0.0
* @ingroup Eet_Data_Group * @ingroup Eet_Data_Group
*/ */
#define EET_DATA_DESCRIPTOR_ADD_SUB(edd, struct_type, name, member, subtype ) \ #define EET_DATA_DESCRIPTOR_ADD_SUB(edd, struct_type, name, member, subtype ) \
{ \ do { \
struct_type ___ett; \ struct_type ___ett; \
\ eet_data_descriptor_element_add(edd, name, EET_T_UNKNOW, EET_G_UNKNOW
eet_data_descriptor_element_add(edd, name, EET_T_UNKNOW, EET_G_UNKNO N, \
WN, \ (char *)(& (___ett.member)) - \
(char *)(&(___ett.member)) - (char * (char *)(& (___ett)), \
)(&(___ett)), \ 0, /* 0, */ NULL, subtype); \
0, /* 0, */NULL, subtype); \ } while (0)
}
/** /**
* Add a linked list type to a data descriptor * Add a linked list type to a data descriptor
* @param edd The data descriptor to add the type to. * @param edd The data descriptor to add the type to.
* @param struct_type The type of the struct. * @param struct_type The type of the struct.
* @param name The string name to use to encode/decode this member * @param name The string name to use to encode/decode this member
* (must be a constant global and never change). * (must be a constant global and never change).
* @param member The struct member itself to be encoded. * @param member The struct member itself to be encoded.
* @param subtype The type of linked list member to add. * @param subtype The type of linked list member to add.
* *
* This macro lets you easily add a linked list of other data types. All * This macro lets you easily add a linked list of other data types. All th
the e
* parameters are the same as for EET_DATA_DESCRIPTOR_ADD_BASIC(), with * parameters are the same as for EET_DATA_DESCRIPTOR_ADD_BASIC(), with the
the * @p subtype being the exception. This must be the data descriptor of the
* @p subtype being the exception. This must be the data descriptor of t * element that is in each member of the linked list to be stored.
he *
* element that is in each member of the linked list to be stored. * @since 1.0.0
* * @ingroup Eet_Data_Group
* @since 1.0.0 */
* @ingroup Eet_Data_Group
*/
#define EET_DATA_DESCRIPTOR_ADD_LIST(edd, struct_type, name, member, subtyp e) \ #define EET_DATA_DESCRIPTOR_ADD_LIST(edd, struct_type, name, member, subtyp e) \
{ \ do { \
struct_type ___ett; \ struct_type ___ett; \
\ eet_data_descriptor_element_add(edd, name, EET_T_UNKNOW, EET_G_LIST,
eet_data_descriptor_element_add(edd, name, EET_T_UNKNOW, EET_G_LIST, \
\ (char *)(& (___ett.member)) - \
(char *)(&(___ett.member)) - (char * (char *)(& (___ett)), \
)(&(___ett)), \ 0, /* 0, */ NULL, subtype); \
0, /* 0, */NULL, subtype); \ } while (0)
}
/** /**
* Add a hash type to a data descriptor * Add a hash type to a data descriptor
* @param edd The data descriptor to add the type to. * @param edd The data descriptor to add the type to.
* @param struct_type The type of the struct. * @param struct_type The type of the struct.
* @param name The string name to use to encode/decode this member * @param name The string name to use to encode/decode this member
* (must be a constant global and never change). * (must be a constant global and never change).
* @param member The struct member itself to be encoded. * @param member The struct member itself to be encoded.
* @param subtype The type of hash member to add. * @param subtype The type of hash member to add.
* *
* This macro lets you easily add a hash of other data types. All the * This macro lets you easily add a hash of other data types. All the
* parameters are the same as for EET_DATA_DESCRIPTOR_ADD_BASIC(), with * parameters are the same as for EET_DATA_DESCRIPTOR_ADD_BASIC(), with the
the * @p subtype being the exception. This must be the data descriptor of the
* @p subtype being the exception. This must be the data descriptor of t * element that is in each member of the hash to be stored.
he *
* element that is in each member of the hash to be stored. * @since 1.0.0
* * @ingroup Eet_Data_Group
* @since 1.0.0 */
* @ingroup Eet_Data_Group
*/
#define EET_DATA_DESCRIPTOR_ADD_HASH(edd, struct_type, name, member, subtyp e) \ #define EET_DATA_DESCRIPTOR_ADD_HASH(edd, struct_type, name, member, subtyp e) \
{ \ do { \
struct_type ___ett; \ struct_type ___ett; \
\ eet_data_descriptor_element_add(edd, name, EET_T_UNKNOW, EET_G_HASH,
eet_data_descriptor_element_add(edd, name, EET_T_UNKNOW, EET_G_HASH, \
\ (char *)(& (___ett.member)) - \
(char *)(&(___ett.member)) - (char * (char *)(& (___ett)), \
)(&(___ett)), \ 0, /* 0, */ NULL, subtype); \
0, /* 0, */NULL, subtype); \ } while (0)
}
/** /**
* Add a fixed size array type to a data descriptor * Add a hash of string to a data descriptor
* @param edd The data descriptor to add the type to. * @param edd The data descriptor to add the type to.
* @param struct_type The type of the struct. * @param struct_type The type of the struct.
* @param name The string name to use to encode/decode this member * @param name The string name to use to encode/decode this member
* (must be a constant global and never change). * (must be a constant global and never change).
* @param member The struct member itself to be encoded. * @param member The struct member itself to be encoded.
* @param subtype The type of hash member to add. *
* * This macro lets you easily add a hash of string. All the
* This macro lets you easily add a fixed size array of other data * parameters are the same as for EET_DATA_DESCRIPTOR_ADD_BASIC().
* types. All the parameters are the same as for *
* EET_DATA_DESCRIPTOR_ADD_BASIC(), with the @p subtype being the * @since 1.3.4
* exception. This must be the data descriptor of the element that * @ingroup Eet_Data_Group
* is in each member of the hash to be stored. */
* #define EET_DATA_DESCRIPTOR_ADD_HASH_STRING(edd, struct_type, name, member)
* @since 1.0.2 \
* @ingroup Eet_Data_Group do { \
*/ struct_type ___ett; \
eet_data_descriptor_element_add(edd, name, EET_T_STRING, EET_G_HASH,
\
(char *)(& (___ett.member)) - \
(char *)(& (___ett)), \
0, /* 0, */ NULL, NULL); \
} while (0)
/**
* Add a fixed size array type 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.
* @param subtype The type of hash member to add.
*
* This macro lets you easily add a fixed size array of other data
* 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.
*
* @since 1.0.2
* @ingroup Eet_Data_Group
*/
#define EET_DATA_DESCRIPTOR_ADD_ARRAY(edd, struct_type, name, member, subty pe) \ #define EET_DATA_DESCRIPTOR_ADD_ARRAY(edd, struct_type, name, member, subty pe) \
{ \ do { \
struct_type ___ett; \ struct_type ___ett; \
\ eet_data_descriptor_element_add(edd, name, EET_T_UNKNOW, EET_G_ARRAY,
eet_data_descriptor_element_add(edd, name, EET_T_UNKNOW, EET_G_ARRAY \
, \ (char *)(& (___ett.member)) - \
(char *)(&(___ett.member)) - (char * (char *)(& (___ett)), \
)(&(___ett)), \ /* 0, */ sizeof(___ett.member) / \
/* 0, */sizeof(___ett.member)/sizeo sizeof(___ett.member[0]), NULL, subty
f(___ett.member[0]), NULL, subtype); \ pe); \
} } while (0)
/** /**
* Add a variable size array type to a data descriptor * Add a variable size array type to a data descriptor
* @param edd The data descriptor to add the type to. * @param edd The data descriptor to add the type to.
* @param struct_type The type of the struct. * @param struct_type The type of the struct.
* @param name The string name to use to encode/decode this member * @param name The string name to use to encode/decode this member
* (must be a constant global and never change). * (must be a constant global and never change).
* @param member The struct member itself to be encoded. * @param member The struct member itself to be encoded.
* @param subtype The type of hash member to add. * @param subtype The type of hash member to add.
* *
* This macro lets you easily add a fixed size array of other data * This macro lets you easily add a fixed size array of other data
* types. All the parameters are the same as for * types. All the parameters are the same as for
* EET_DATA_DESCRIPTOR_ADD_BASIC(), with the @p subtype being the * EET_DATA_DESCRIPTOR_ADD_BASIC(), with the @p subtype being the
* exception. This must be the data descriptor of the element that * 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.
* *
* @since 1.0.2 * @since 1.0.2
* @ingroup Eet_Data_Group * @ingroup Eet_Data_Group
*/ */
#define EET_DATA_DESCRIPTOR_ADD_VAR_ARRAY(edd, struct_type, name, member, s ubtype) \ #define EET_DATA_DESCRIPTOR_ADD_VAR_ARRAY(edd, struct_type, name, member, s ubtype) \
{ \ do { \
struct_type ___ett; \ struct_type ___ett; \
\ eet_data_descriptor_element_add(edd, \
eet_data_descriptor_element_add(edd, name, EET_T_UNKNOW, EET_G_VAR_A name, \
RRAY, \ EET_T_UNKNOW, \
(char *)(&(___ett.member)) - (char * EET_G_VAR_ARRAY, \
)(&(___ett)), \ (char *)(& (___ett.member)) - \
(char *)(&(___ett.member ## _count)) (char *)(& (___ett)), \
- (char *)(&(___ett)), /* 0, */NULL, subtype); \ (char *)(& (___ett.member ## _count))
} - \
(char *)(& (___ett)), \
/* 0, */ NULL, \
subtype); \
} while (0)
/** /**
* Add an union type to a data descriptor * Add a variable size array type to a data descriptor
* @param edd The data descriptor to add the type to. * @param edd The data descriptor to add the type to.
* @param struct_type The type of the struct. * @param struct_type The type of the struct.
* @param name The string name to use to encode/decode this member * @param name The string name to use to encode/decode this member
* (must be a constant global and never change). * (must be a constant global and never change).
* @param member The struct member itself to be encoded. * @param member The struct member itself to be encoded.
* @param type_member The member that give hints on what is in the union *
. * This macro lets you easily add a fixed size array of string. All
* @param unified_type Describe all possible type the union could handle * the parameters are the same as for EET_DATA_DESCRIPTOR_ADD_BASIC().
. *
* * @since 1.4.0
* This macro lets you easily add an union with a member that specify wh * @ingroup Eet_Data_Group
at is inside. */
* The @p unified_type is an Eet_Data_Descriptor, but only the entry tha #define EET_DATA_DESCRIPTOR_ADD_VAR_ARRAY_STRING(edd, struct_type, name, me
t match the name mber) \
* returned by type_get will be used for each serialized data. The type_ do { \
get and type_set struct_type ___ett; \
* callback of unified_type should be defined. eet_data_descriptor_element_add(edd, \
* name, \
* @since 1.2.4 EET_T_STRING, \
* @ingroup Eet_Data_Group EET_G_VAR_ARRAY, \
* @see Eet_Data_Descriptor_Class (char *)(& (___ett.member)) - \
*/ (char *)(& (___ett)), \
(char *)(& (___ett.member ## _count))
- \
(char *)(& (___ett)), \
/* 0, */ NULL, \
NULL); \
} while (0)
/**
* Add an union type 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.
* @param type_member The member that give hints on what is in the union.
* @param unified_type Describe all possible type the union could handle.
*
* This macro lets you easily add an union with a member that specify what
is inside.
* The @p unified_type is an Eet_Data_Descriptor, but only the entry that m
atch the name
* returned by type_get will be used for each serialized data. The type_get
and type_set
* callback of unified_type should be defined.
*
* @since 1.2.4
* @ingroup Eet_Data_Group
* @see Eet_Data_Descriptor_Class
*/
#define EET_DATA_DESCRIPTOR_ADD_UNION(edd, struct_type, name, member, type_ member, unified_type) \ #define EET_DATA_DESCRIPTOR_ADD_UNION(edd, struct_type, name, member, type_ member, unified_type) \
{ \ do { \
struct_type ___ett; \ struct_type ___ett; \
\ eet_data_descriptor_element_add(edd, name, EET_T_UNKNOW, EET_G_UNION,
eet_data_descriptor_element_add(edd, name, EET_T_UNKNOW, EET_G_UNIO \
N, \ (char *)(& (___ett.member)) - \
(char *) (&(___ett.member)) - (char (char *)(& (___ett)), \
*)(&(___ett)), \ (char *)(& (___ett.type_member)) - \
(char *) (&(___ett.type_member)) - (char *)(& (___ett)), \
(char *)(&(___ett)), \ NULL, unified_type); \
NULL, unified_type); \ } while (0)
}
/** /**
* Add a automatically selectable type to a data descriptor * Add a automatically selectable type to a data descriptor
* @param edd The data descriptor to add the type to. * @param edd The data descriptor to add the type to.
* @param struct_type The type of the struct. * @param struct_type The type of the struct.
* @param name The string name to use to encode/decode this member * @param name The string name to use to encode/decode this member
* (must be a constant global and never change). * (must be a constant global and never change).
* @param member The struct member itself to be encoded. * @param member The struct member itself to be encoded.
* @param type_member The member that give hints on what is in the union * @param type_member The member that give hints on what is in the union.
. * @param unified_type Describe all possible type the union could handle.
* @param unified_type Describe all possible type the union could handle *
. * This macro lets you easily define what the content of @p member points t
* o depending of
* This macro lets you easily define what the content of @p member point * the content of @p type_member. The type_get and type_set callback of uni
s to depending of fied_type should
* the content of @p type_member. The type_get and type_set callback of * be defined. If the the type is not know at the time of restoring it, eet
unified_type should will still call
* be defined. If the the type is not know at the time of restoring it, * type_set of @p unified_type but the pointer will be set to a serialized
eet will still call binary representation
* type_set of @p unified_type but the pointer will be set to a serializ * of what eet know. This make it possible, to save this pointer again by j
ed binary representation ust returning the string
* of what eet know. This make it possible, to save this pointer again b * given previously and telling it by setting unknow to EINA_TRUE.
y just returning the string *
* given previously and telling it by setting unknow to EINA_TRUE. * @since 1.2.4
* * @ingroup Eet_Data_Group
* @since 1.2.4 * @see Eet_Data_Descriptor_Class
* @ingroup Eet_Data_Group */
* @see Eet_Data_Descriptor_Class
*/
#define EET_DATA_DESCRIPTOR_ADD_VARIANT(edd, struct_type, name, member, typ e_member, unified_type) \ #define EET_DATA_DESCRIPTOR_ADD_VARIANT(edd, struct_type, name, member, typ e_member, unified_type) \
{ \ do { \
struct_type ___ett; \ struct_type ___ett; \
\ eet_data_descriptor_element_add(edd, name, EET_T_UNKNOW, EET_G_VARIAN
eet_data_descriptor_element_add(edd, name, EET_T_UNKNOW, EET_G_VARI T, \
ANT, \ (char *)(& (___ett.member)) - \
(char *) (&(___ett.member)) - (char (char *)(& (___ett)), \
*)(&(___ett)), \ (char *)(& (___ett.type_member)) - \
(char *) (&(___ett.type_member)) - (char *)(& (___ett)), \
(char *)(&(___ett)), \ NULL, unified_type); \
NULL, unified_type); \ } while (0)
}
/** /**
* Add a mapping to a data descriptor that will be used by union, varian * Add a mapping to a data descriptor that will be used by union, variant o
t or inherited type r inherited type
* @param unified_type The data descriptor to add the mapping to. * @param unified_type The data descriptor to add the mapping to.
* @param name The string name to get/set type. * @param name The string name to get/set type.
* @param subtype The matching data descriptor. * @param subtype The matching data descriptor.
* *
* @since 1.2.4 * @since 1.2.4
* @ingroup Eet_Data_Group * @ingroup Eet_Data_Group
* @see Eet_Data_Descriptor_Class * @see Eet_Data_Descriptor_Class
*/ */
#define EET_DATA_DESCRIPTOR_ADD_MAPPING(unified_type, name, subtype) \ #define EET_DATA_DESCRIPTOR_ADD_MAPPING(unified_type, name, subtype) \
eet_data_descriptor_element_add(unified_type, name, EET_T_UNKNOW, EET_G_U eet_data_descriptor_element_add(unified_type, \
NKNOWN, 0, 0, NULL, subtype); name, \
EET_T_UNKNOW, \
EET_G_UNKNOWN, \
0, \
0, \
NULL, \
subtype)
/** /**
* @defgroup Eet_Data_Cipher_Group Eet Data Serialization using A Cipher * @defgroup Eet_Data_Cipher_Group Eet Data Serialization using A Ciphers
s *
* * Most of the @ref Eet_Data_Group have alternative versions that
* Most of the @ref Eet_Data_Group have alternative versions that * accounts for ciphers to protect their content.
* accounts for ciphers to protect their content. *
* * @see @ref Eet_Cipher_Group
* @see @ref Eet_Cipher_Group *
* * @ingroup Eet_Data_Group
* @ingroup Eet_Data_Group */
*/
/** /**
* Read a data structure from an eet file and decodes it using a cipher. * Read a data structure from an eet file and decodes it using a cipher.
* @param ef The eet file handle to read from. * @param ef The eet file handle to read from.
* @param edd The data descriptor handle to use when decoding. * @param edd The data descriptor handle to use when decoding.
* @param name The key the data is stored under in the eet file. * @param name The key the data is stored under in the eet file.
* @param cipher_key The key to use as cipher. * @param cipher_key The key to use as cipher.
* @return A pointer to the decoded data structure. * @return A pointer to the decoded data structure.
* *
* This function decodes a data structure stored in an eet file, returni * This function decodes a data structure stored in an eet file, returning
ng * a pointer to it if it decoded successfully, or NULL on failure. This
* a pointer to it if it decoded successfully, or NULL on failure. This * can save a programmer dozens of hours of work in writing configuration
* can save a programmer dozens of hours of work in writing configuratio * file parsing and writing code, as eet does all that work for the program
n * and presents a program-friendly data structure, just as the programmer
* file parsing and writing code, as eet does all that work for the prog * likes. Eet can handle members being added or deleted from the data in
ram * storage and safely zero-fills unfilled members if they were not found
* and presents a program-friendly data structure, just as the programme * in the data. It checks sizes and headers whenever it reads data, allowin
r g
* likes. Eet can handle members being added or deleted from the data in * the programmer to not worry about corrupt data.
* storage and safely zero-fills unfilled members if they were not found *
* in the data. It checks sizes and headers whenever it reads data, allo * Once a data structure has been described by the programmer with the
wing * fields they wish to save or load, storing or retrieving a data structure
* the programmer to not worry about corrupt data. * from an eet file, or from a chunk of memory is as simple as a single
* * function call.
* Once a data structure has been described by the programmer with the *
* fields they wish to save or load, storing or retrieving a data struct * @see eet_data_read()
ure *
* from an eet file, or from a chunk of memory is as simple as a single * @since 1.0.0
* function call. * @ingroup Eet_Data_Cipher_Group
* */
* @see eet_data_read() EAPI void *
* eet_data_read_cipher(Eet_File *ef,
* @since 1.0.0 Eet_Data_Descriptor *edd,
* @ingroup Eet_Data_Cipher_Group const char *name,
*/ const char *cipher_key);
EAPI void *eet_data_read_cipher(Eet_File *ef, Eet_Data_Descriptor *edd,
const char *name, const char *cipher_key);
/** /**
* Write a data structure from memory and store in an eet file * Write a data structure from memory and store in an eet file
* using a cipher. * using a cipher.
* @param ef The eet file handle to write to. * @param ef The eet file handle to write to.
* @param edd The data descriptor to use when encoding. * @param edd The data descriptor to use when encoding.
* @param name The key to store the data under in the eet file. * @param name The key to store the data under in the eet file.
* @param cipher_key The key to use as cipher. * @param cipher_key The key to use as cipher.
* @param data A pointer to the data structure to ssave and encode. * @param data A pointer to the data structure to ssave and encode.
* @param compress Compression flags for storage. * @param compress Compression flags for storage.
* @return bytes written on successful write, 0 on failure. * @return bytes written on successful write, 0 on failure.
* *
* This function is the reverse of eet_data_read(), saving a data struct * This function is the reverse of eet_data_read(), saving a data structure
ure * to an eet file.
* to an eet file. *
* * @see eet_data_write_cipher()
* @see eet_data_write_cipher() *
* * @since 1.0.0
* @since 1.0.0 * @ingroup Eet_Data_Cipher_Group
* @ingroup Eet_Data_Cipher_Group */
*/ EAPI int
EAPI int eet_data_write_cipher(Eet_File *ef, Eet_Data_Descriptor *edd, c eet_data_write_cipher(Eet_File *ef,
onst char *name, const char *cipher_key, const void *data, int compress); Eet_Data_Descriptor *edd,
const char *name,
const char *cipher_key,
const void *data,
int compress);
/** /**
* Dump an eet encoded data structure into ascii text using a cipher. * Dump an eet encoded data structure into ascii text using a cipher.
* @param data_in The pointer to the data to decode into a struct. * @param data_in The pointer to the data to decode into a struct.
* @param cipher_key The key to use as cipher. * @param cipher_key The key to use as cipher.
* @param size_in The size of the data pointed to in bytes. * @param size_in The size of the data pointed to in bytes.
* @param dumpfunc The function to call passed a string when new * @param dumpfunc The function to call passed a string when new
* data is converted to text * data is converted to text
* @param dumpdata The data to pass to the @p dumpfunc callback. * @param dumpdata The data to pass to the @p dumpfunc callback.
* @return 1 on success, 0 on failure * @return 1 on success, 0 on failure
* *
* This function will take a chunk of data encoded by * This function will take a chunk of data encoded by
* eet_data_descriptor_encode() and convert it into human readable * eet_data_descriptor_encode() and convert it into human readable
* ascii text. It does this by calling the @p dumpfunc callback * ascii text. It does this by calling the @p dumpfunc callback
* for all new text that is generated. This callback should append * for all new text that is generated. This callback should append
* to any existing text buffer and will be passed the pointer @p * to any existing text buffer and will be passed the pointer @p
* dumpdata as a parameter as well as a string with new text to be * dumpdata as a parameter as well as a string with new text to be
* appended. * appended.
* *
* Example: * Example:
* *
* @code * @code
* void output(void *data, const char *string) * void output(void *data, const char *string)
* { * {
* printf("%s", string); * printf("%s", string);
* } * }
* *
* void dump(const char *file) * void dump(const char *file)
* { * {
* FILE *f; * FILE *f;
* int len; * int len;
* void *data; * void *data;
* *
* f = fopen(file, "r"); * f = fopen(file, "r");
* fseek(f, 0, SEEK_END); * fseek(f, 0, SEEK_END);
* len = ftell(f); * len = ftell(f);
* rewind(f); * rewind(f);
* data = malloc(len); * data = malloc(len);
* fread(data, len, 1, f); * fread(data, len, 1, f);
* fclose(f); * fclose(f);
* eet_data_text_dump_cipher(data, cipher_key, len, output, NULL); * eet_data_text_dump_cipher(data, cipher_key, len, output, NULL);
* } * }
* @endcode * @endcode
* *
* @see eet_data_text_dump() * @see eet_data_text_dump()
* *
* @since 1.0.0 * @since 1.0.0
* @ingroup Eet_Data_Cipher_Group * @ingroup Eet_Data_Cipher_Group
*/ */
EAPI int eet_data_text_dump_cipher(const void *data_in, const char *ciph EAPI int
er_key, int size_in, void (*dumpfunc) (void *data, const char *str), void * eet_data_text_dump_cipher(const void *data_in,
dumpdata); const char *cipher_key,
int size_in,
Eet_Dump_Callback dumpfunc,
void *dumpdata);
/** /**
* Take an ascii encoding from eet_data_text_dump() and re-encode * Take an ascii encoding from eet_data_text_dump() and re-encode
* in binary using a cipher. * in binary using a cipher.
* @param text The pointer to the string data to parse and encode. * @param text The pointer to the string data to parse and encode.
* @param cipher_key The key to use as cipher. * @param cipher_key The key to use as cipher.
* @param textlen The size of the string in bytes (not including 0 * @param textlen The size of the string in bytes (not including 0
* byte terminator). * byte terminator).
* @param size_ret This gets filled in with the encoded data blob * @param size_ret This gets filled in with the encoded data blob
* size in bytes. * size in bytes.
* @return The encoded data on success, NULL on failure. * @return The encoded data on success, NULL on failure.
* *
* This function will parse the string pointed to by @p text and return * This function will parse the string pointed to by @p text and return
* an encoded data lump the same way eet_data_descriptor_encode() takes * an encoded data lump the same way eet_data_descriptor_encode() takes an
an * in-memory data struct and encodes into a binary blob. @p text is a norma
* in-memory data struct and encodes into a binary blob. @p text is a no l
rmal * C string.
* C string. *
* * @see eet_data_text_undump()
* @see eet_data_text_undump() *
* * @since 1.0.0
* @since 1.0.0 * @ingroup Eet_Data_Cipher_Group
* @ingroup Eet_Data_Cipher_Group */
*/ EAPI void *
EAPI void *eet_data_text_undump_cipher(const char *text, const char *cip eet_data_text_undump_cipher(const char *text,
her_key, int textlen, int *size_ret); const char *cipher_key,
int textlen,
int *size_ret);
/** /**
* Dump an eet encoded data structure from an eet file into ascii * Dump an eet encoded data structure from an eet file into ascii
* text using a cipher. * text using a cipher.
* @param ef A valid eet file handle. * @param ef A valid eet file handle.
* @param name Name of the entry. eg: "/base/file_i_want". * @param name Name of the entry. eg: "/base/file_i_want".
* @param cipher_key The key to use as cipher. * @param cipher_key The key to use as cipher.
* @param dumpfunc The function to call passed a string when new * @param dumpfunc The function to call passed a string when new
* data is converted to text * data is converted to text
* @param dumpdata The data to pass to the @p dumpfunc callback. * @param dumpdata The data to pass to the @p dumpfunc callback.
* @return 1 on success, 0 on failure * @return 1 on success, 0 on failure
* *
* This function will take an open and valid eet file from * This function will take an open and valid eet file from
* eet_open() request the data encoded by * eet_open() request the data encoded by
* eet_data_descriptor_encode() corresponding to the key @p name * eet_data_descriptor_encode() corresponding to the key @p name
* and convert it into human readable ascii text. It does this by * and convert it into human readable ascii text. It does this by
* calling the @p dumpfunc callback for all new text that is * calling the @p dumpfunc callback for all new text that is
* generated. This callback should append to any existing text * generated. This callback should append to any existing text
* buffer and will be passed the pointer @p dumpdata as a parameter * buffer and will be passed the pointer @p dumpdata as a parameter
* as well as a string with new text to be appended. * as well as a string with new text to be appended.
* *
* @see eet_data_dump() * @see eet_data_dump()
* *
* @since 1.0.0 * @since 1.0.0
* @ingroup Eet_Data_Cipher_Group * @ingroup Eet_Data_Cipher_Group
*/ */
EAPI int eet_data_dump_cipher(Eet_File *ef, const char *name, const char EAPI int
*cipher_key, void (*dumpfunc) (void *data, const char *str), void *dumpdat eet_data_dump_cipher(Eet_File *ef,
a); const char *name,
const char *cipher_key,
Eet_Dump_Callback dumpfunc,
void *dumpdata);
/** /**
* Take an ascii encoding from eet_data_dump() and re-encode in * Take an ascii encoding from eet_data_dump() and re-encode in
* binary using a cipher. * binary using a cipher.
* @param ef A valid eet file handle. * @param ef A valid eet file handle.
* @param name Name of the entry. eg: "/base/file_i_want". * @param name Name of the entry. eg: "/base/file_i_want".
* @param cipher_key The key to use as cipher. * @param cipher_key The key to use as cipher.
* @param text The pointer to the string data to parse and encode. * @param text The pointer to the string data to parse and encode.
* @param textlen The size of the string in bytes (not including 0 * @param textlen The size of the string in bytes (not including 0
* byte terminator). * byte terminator).
* @param compress Compression flags (1 == compress, 0 = don't compress) * @param compress Compression flags (1 == compress, 0 = don't compress).
. * @return 1 on success, 0 on failure
* @return 1 on success, 0 on failure *
* * This function will parse the string pointed to by @p text,
* This function will parse the string pointed to by @p text, * encode it the same way eet_data_descriptor_encode() takes an
* encode it the same way eet_data_descriptor_encode() takes an * in-memory data struct and encodes into a binary blob.
* in-memory data struct and encodes into a binary blob. *
* * The data (optionally compressed) will be in ram, pending a flush to
* The data (optionally compressed) will be in ram, pending a flush to * disk (it will stay in ram till the eet file handle is closed though).
* disk (it will stay in ram till the eet file handle is closed though). *
* * @see eet_data_undump()
* @see eet_data_undump() *
* * @since 1.0.0
* @since 1.0.0 * @ingroup Eet_Data_Cipher_Group
* @ingroup Eet_Data_Cipher_Group */
*/ EAPI int
EAPI int eet_data_undump_cipher(Eet_File *ef, const char *name, const ch eet_data_undump_cipher(Eet_File *ef,
ar *cipher_key, const char *text, int textlen, int compress); const char *name,
const char *cipher_key,
const char *text,
int textlen,
int compress);
/** /**
* Decode a data structure from an arbitary location in memory * Decode a data structure from an arbitrary location in memory
* using a cipher. * using a cipher.
* @param edd The data descriptor to use when decoding. * @param edd The data descriptor to use when decoding.
* @param data_in The pointer to the data to decode into a struct. * @param data_in The pointer to the data to decode into a struct.
* @param cipher_key The key to use as cipher. * @param cipher_key The key to use as cipher.
* @param size_in The size of the data pointed to in bytes. * @param size_in The size of the data pointed to in bytes.
* @return NULL on failure, or a valid decoded struct pointer on success * @return NULL on failure, or a valid decoded struct pointer on success.
. *
* * This function will decode a data structure that has been encoded using
* This function will decode a data structure that has been encoded usin * eet_data_descriptor_encode(), and return a data structure with all its
g * elements filled out, if successful, or NULL on failure.
* eet_data_descriptor_encode(), and return a data structure with all it *
s * The data to be decoded is stored at the memory pointed to by @p data_in,
* elements filled out, if successful, or NULL on failure. * and is described by the descriptor pointed to by @p edd. The data size i
* s
* The data to be decoded is stored at the memory pointed to by @p data_ * passed in as the value to @p size_in, ande must be greater than 0 to
in, * succeed.
* and is described by the descriptor pointed to by @p edd. The data siz *
e is * This function is useful for decoding data structures delivered to the
* passed in as the value to @p size_in, ande must be greater than 0 to * application by means other than an eet file, such as an IPC or socket
* succeed. * connection, raw files, shared memory etc.
* *
* This function is useful for decoding data structures delivered to the * Please see eet_data_read() for more information.
* application by means other than an eet file, such as an IPC or socket *
* connection, raw files, shared memory etc. * @see eet_data_descriptor_decode()
* *
* Please see eet_data_read() for more information. * @since 1.0.0
* * @ingroup Eet_Data_Cipher_Group
* @see eet_data_descriptor_decode() */
* EAPI void *
* @since 1.0.0 eet_data_descriptor_decode_cipher(Eet_Data_Descriptor *edd,
* @ingroup Eet_Data_Cipher_Group const void *data_in,
*/ const char *cipher_key,
EAPI void *eet_data_descriptor_decode_cipher(Eet_Data_Descriptor *edd, c int size_in);
onst void *data_in, const char *cipher_key, int size_in);
/** /**
* Encode a data struct to memory and return that encoded data * Encode a data struct to memory and return that encoded data
* using a cipher. * using a cipher.
* @param edd The data descriptor to use when encoding. * @param edd The data descriptor to use when encoding.
* @param data_in The pointer to the struct to encode into data. * @param data_in The pointer to the struct to encode into data.
* @param cipher_key The key to use as cipher. * @param cipher_key The key to use as cipher.
* @param size_ret pointer to the an int to be filled with the decoded s * @param size_ret pointer to the an int to be filled with the decoded size
ize. .
* @return NULL on failure, or a valid encoded data chunk on success. * @return NULL on failure, or a valid encoded data chunk on success.
* *
* This function takes a data structutre in memory and encodes it into a * This function takes a data structutre in memory and encodes it into a
* serialised chunk of data that can be decoded again by * serialised chunk of data that can be decoded again by
* eet_data_descriptor_decode(). This is useful for being able to transm * eet_data_descriptor_decode(). This is useful for being able to transmit
it * data structures across sockets, pipes, IPC or shared file mechanisms,
* data structures across sockets, pipes, IPC or shared file mechanisms, * without having to worry about memory space, machine type, endianess etc.
* without having to worry about memory space, machine type, endianess e *
tc. * The parameter @p edd must point to a valid data descriptor, and
* * @p data_in must point to the right data structure to encode. If not, the
* The parameter @p edd must point to a valid data descriptor, and * encoding may fail.
* @p data_in must point to the right data structure to encode. If not, *
the * On success a non NULL valid pointer is returned and what @p size_ret
* encoding may fail. * points to is set to the size of this decoded data, in bytes. When the
* * encoded data is no longer needed, call free() on it. On failure NULL is
* On success a non NULL valid pointer is returned and what @p size_ret * returned and what @p size_ret points to is set to 0.
* points to is set to the size of this decoded data, in bytes. When the *
* encoded data is no longer needed, call free() on it. On failure NULL * Please see eet_data_write() for more information.
is *
* returned and what @p size_ret points to is set to 0. * @see eet_data_descriptor_encode()
* *
* Please see eet_data_write() for more information. * @since 1.0.0
* * @ingroup Eet_Data_Cipher_Group
* @see eet_data_descriptor_encode() */
* EAPI void *
* @since 1.0.0 eet_data_descriptor_encode_cipher(Eet_Data_Descriptor *edd,
* @ingroup Eet_Data_Cipher_Group const void *data_in,
*/ const char *cipher_key,
EAPI void *eet_data_descriptor_encode_cipher(Eet_Data_Descriptor *edd, c int *size_ret);
onst void *data_in, const char *cipher_key, int *size_ret);
/** /**
* @defgroup Eet_Node_Group Low-level Serialization Structures. * @defgroup Eet_Node_Group Low-level Serialization Structures.
* *
* Functions that create, destroy and manipulate serialization nodes * Functions that create, destroy and manipulate serialization nodes
* used by @ref Eet_Data_Group. * used by @ref Eet_Data_Group.
* *
* @{ * @{
*/ */
/** /**
* @typedef Eet_Node * @typedef Eet_Node
* Opaque handle to manage serialization node. * Opaque handle to manage serialization node.
*/ */
typedef struct _Eet_Node Eet_Node; typedef struct _Eet_Node Eet_Node;
/** /**
* @typedef Eet_Node_Data * @typedef Eet_Node_Data
* Contains an union that can fit any kind of node. * Contains an union that can fit any kind of node.
*/ */
typedef struct _Eet_Node_Data Eet_Node_Data; typedef struct _Eet_Node_Data Eet_Node_Data;
/** /**
* @struct _Eet_Node_Data * @struct _Eet_Node_Data
* Contains an union that can fit any kind of node. * Contains an union that can fit any kind of node.
*/ */
struct _Eet_Node_Data struct _Eet_Node_Data
{ {
union { union {
char c; char c;
short s; short s;
int i; int i;
long long l; long long l;
float f; float f;
double d; double d;
unsigned char uc; unsigned char uc;
unsigned short us; unsigned short us;
unsigned int ui; unsigned int ui;
unsigned long long ul; unsigned long long ul;
const char *str; const char *str;
} value; } value;
}; };
/** /**
* @} * @}
*/ */
/** /**
* TODO FIX ME * TODO FIX ME
* @ingroup Eet_Node_Group * @ingroup Eet_Node_Group
*/ */
EAPI Eet_Node *eet_node_char_new(const char *name, char c); EAPI Eet_Node *
eet_node_char_new(const char *name,
char c);
/** /**
* TODO FIX ME * TODO FIX ME
* @ingroup Eet_Node_Group * @ingroup Eet_Node_Group
*/ */
EAPI Eet_Node *eet_node_short_new(const char *name, short s); EAPI Eet_Node *
eet_node_short_new(const char *name,
short s);
/** /**
* TODO FIX ME * TODO FIX ME
* @ingroup Eet_Node_Group * @ingroup Eet_Node_Group
*/ */
EAPI Eet_Node *eet_node_int_new(const char *name, int i); EAPI Eet_Node *
eet_node_int_new(const char *name,
int i);
/** /**
* TODO FIX ME * TODO FIX ME
* @ingroup Eet_Node_Group * @ingroup Eet_Node_Group
*/ */
EAPI Eet_Node *eet_node_long_long_new(const char *name, long long l); EAPI Eet_Node *
eet_node_long_long_new(const char *name,
long long l);
/** /**
* TODO FIX ME * TODO FIX ME
* @ingroup Eet_Node_Group * @ingroup Eet_Node_Group
*/ */
EAPI Eet_Node *eet_node_float_new(const char *name, float f); EAPI Eet_Node *
eet_node_float_new(const char *name,
float f);
/** /**
* TODO FIX ME * TODO FIX ME
* @ingroup Eet_Node_Group * @ingroup Eet_Node_Group
*/ */
EAPI Eet_Node *eet_node_double_new(const char *name, double d); EAPI Eet_Node *
eet_node_double_new(const char *name,
double d);
/** /**
* TODO FIX ME * TODO FIX ME
* @ingroup Eet_Node_Group * @ingroup Eet_Node_Group
*/ */
EAPI Eet_Node *eet_node_unsigned_char_new(const char *name, unsigned cha EAPI Eet_Node *
r uc); eet_node_unsigned_char_new(const char *name,
unsigned char uc);
/** /**
* TODO FIX ME * TODO FIX ME
* @ingroup Eet_Node_Group * @ingroup Eet_Node_Group
*/ */
EAPI Eet_Node *eet_node_unsigned_short_new(const char *name, unsigned sh EAPI Eet_Node *
ort us); eet_node_unsigned_short_new(const char *name,
unsigned short us);
/** /**
* TODO FIX ME * TODO FIX ME
* @ingroup Eet_Node_Group * @ingroup Eet_Node_Group
*/ */
EAPI Eet_Node *eet_node_unsigned_int_new(const char *name, unsigned int EAPI Eet_Node *
ui); eet_node_unsigned_int_new(const char *name,
unsigned int ui);
/** /**
* TODO FIX ME * TODO FIX ME
* @ingroup Eet_Node_Group * @ingroup Eet_Node_Group
*/ */
EAPI Eet_Node *eet_node_unsigned_long_long_new(const char *name, unsigne EAPI Eet_Node *
d long long l); eet_node_unsigned_long_long_new(const char *name,
unsigned long long l);
/** /**
* TODO FIX ME * TODO FIX ME
* @ingroup Eet_Node_Group * @ingroup Eet_Node_Group
*/ */
EAPI Eet_Node *eet_node_string_new(const char *name, const char *str); EAPI Eet_Node *
eet_node_string_new(const char *name,
const char *str);
/** /**
* TODO FIX ME * TODO FIX ME
* @ingroup Eet_Node_Group * @ingroup Eet_Node_Group
*/ */
EAPI Eet_Node *eet_node_inlined_string_new(const char *name, const char EAPI Eet_Node *
*str); eet_node_inlined_string_new(const char *name,
const char *str);
/** /**
* TODO FIX ME * TODO FIX ME
* @ingroup Eet_Node_Group * @ingroup Eet_Node_Group
*/ */
EAPI Eet_Node *eet_node_null_new(const char *name); EAPI Eet_Node *
eet_node_null_new(const char *name);
/** /**
* TODO FIX ME * TODO FIX ME
* @ingroup Eet_Node_Group * @ingroup Eet_Node_Group
*/ */
EAPI Eet_Node *eet_node_list_new(const char *name, Eina_List *nodes); EAPI Eet_Node *
eet_node_list_new(const char *name,
Eina_List *nodes);
/** /**
* TODO FIX ME * TODO FIX ME
* @ingroup Eet_Node_Group * @ingroup Eet_Node_Group
*/ */
EAPI Eet_Node *eet_node_array_new(const char *name, int count, Eina_List EAPI Eet_Node *
*nodes); eet_node_array_new(const char *name,
int count,
Eina_List *nodes);
/** /**
* TODO FIX ME * TODO FIX ME
* @ingroup Eet_Node_Group * @ingroup Eet_Node_Group
*/ */
EAPI Eet_Node *eet_node_var_array_new(const char *name, Eina_List *nodes EAPI Eet_Node *
); eet_node_var_array_new(const char *name,
Eina_List *nodes);
/** /**
* TODO FIX ME * TODO FIX ME
* @ingroup Eet_Node_Group * @ingroup Eet_Node_Group
*/ */
EAPI Eet_Node *eet_node_hash_new(const char *name, const char *key, Eet_ EAPI Eet_Node *
Node *node); eet_node_hash_new(const char *name,
const char *key,
Eet_Node *node);
/** /**
* TODO FIX ME * TODO FIX ME
* @ingroup Eet_Node_Group * @ingroup Eet_Node_Group
*/ */
EAPI Eet_Node *eet_node_struct_new(const char *name, Eina_List *nodes); EAPI Eet_Node *
eet_node_struct_new(const char *name,
Eina_List *nodes);
/** /**
* TODO FIX ME * TODO FIX ME
* @ingroup Eet_Node_Group * @ingroup Eet_Node_Group
*/ */
EAPI Eet_Node *eet_node_struct_child_new(const char *parent, Eet_Node *c EAPI Eet_Node *
hild); eet_node_struct_child_new(const char *parent,
Eet_Node *child);
/** /**
* TODO FIX ME * TODO FIX ME
* @ingroup Eet_Node_Group * @ingroup Eet_Node_Group
*/ */
EAPI void eet_node_list_append(Eet_Node *parent, const char *name, Eet_N EAPI void
ode *child); eet_node_list_append(Eet_Node *parent,
const char *name,
Eet_Node *child);
/** /**
* TODO FIX ME * TODO FIX ME
* @ingroup Eet_Node_Group * @ingroup Eet_Node_Group
*/ */
EAPI void eet_node_struct_append(Eet_Node *parent, const char *name, Eet EAPI void
_Node *child); eet_node_struct_append(Eet_Node *parent,
const char *name,
Eet_Node *child);
/** /**
* TODO FIX ME * TODO FIX ME
* @ingroup Eet_Node_Group * @ingroup Eet_Node_Group
*/ */
EAPI void eet_node_hash_add(Eet_Node *parent, const char *name, const ch EAPI void
ar *key, Eet_Node *child); eet_node_hash_add(Eet_Node *parent,
const char *name,
const char *key,
Eet_Node *child);
/** /**
* TODO FIX ME * TODO FIX ME
* @ingroup Eet_Node_Group * @ingroup Eet_Node_Group
*/ */
EAPI void eet_node_dump(Eet_Node *n, int dumplevel, void (*dumpfunc) (vo EAPI void
id *data, const char *str), void *dumpdata); eet_node_dump(Eet_Node *n,
int dumplevel,
Eet_Dump_Callback dumpfunc,
void *dumpdata);
/** /**
* TODO FIX ME * TODO FIX ME
* @ingroup Eet_Node_Group * @ingroup Eet_Node_Group
*/ */
EAPI void eet_node_del(Eet_Node *n); EAPI void
eet_node_del(Eet_Node *n);
/** /**
* TODO FIX ME * TODO FIX ME
* @ingroup Eet_Node_Group * @ingroup Eet_Node_Group
*/ */
EAPI void *eet_data_node_encode_cipher(Eet_Node *node, const char *ciphe EAPI void *
r_key, int *size_ret); eet_data_node_encode_cipher(Eet_Node *node,
const char *cipher_key,
int *size_ret);
/** /**
* TODO FIX ME * TODO FIX ME
* @ingroup Eet_Node_Group * @ingroup Eet_Node_Group
*/ */
EAPI Eet_Node *eet_data_node_decode_cipher(const void *data_in, const ch EAPI Eet_Node *
ar *cipher_key, int size_in); eet_data_node_decode_cipher(const void *data_in,
const char *cipher_key,
int size_in);
/** /**
* TODO FIX ME * TODO FIX ME
* @ingroup Eet_Node_Group * @ingroup Eet_Node_Group
*/ */
EAPI Eet_Node *eet_data_node_read_cipher(Eet_File *ef, const char *name, EAPI Eet_Node *
const char *cipher_key); eet_data_node_read_cipher(Eet_File *ef,
const char *name,
const char *cipher_key);
/** /**
* TODO FIX ME * TODO FIX ME
* @ingroup Eet_Node_Group * @ingroup Eet_Node_Group
*/ */
EAPI int eet_data_node_write_cipher(Eet_File *ef, const char *name, cons EAPI int
t char *cipher_key, Eet_Node *node, int compress); eet_data_node_write_cipher(Eet_File *ef,
const char *name,
const char *cipher_key,
Eet_Node *node,
int compress);
/* EXPERIMENTAL: THIS API MAY CHANGE IN THE FUTURE, USE IT ONLY IF YOU KN OW WHAT YOU ARE DOING. */ /* EXPERIMENTAL: THIS API MAY CHANGE IN THE FUTURE, USE IT ONLY IF YOU KNOW WHAT YOU ARE DOING. */
/** /**
* @typedef Eet_Node_Walk * @typedef Eet_Node_Walk
* Describes how to walk trees of #Eet_Node. * Describes how to walk trees of #Eet_Node.
*/ */
typedef struct _Eet_Node_Walk Eet_Node_Walk; typedef struct _Eet_Node_Walk Eet_Node_Walk;
/** typedef void *(*Eet_Node_Walk_Struct_Alloc_Callback)(const char *type, void
* @struct _Eet_Node_Walk *user_data);
* Describes how to walk trees of #Eet_Node. typedef void (*Eet_Node_Walk_Struct_Add_Callback)(void *parent, const char
*/ *name, void *child, void *user_data);
struct _Eet_Node_Walk typedef void *(*Eet_Node_Walk_Array_Callback)(Eina_Bool variable, const cha
{ r *name, int count, void *user_data);
void *(*struct_alloc)(const char *type, void *user_data); typedef void (*Eet_Node_Walk_Insert_Callback)(void *array, int index, void
void (*struct_add)(void *parent, const char *name, void *child, void *child, void *user_data);
*user_data); typedef void *(*Eet_Node_Walk_List_Callback)(const char *name, void *user_d
void *(*array)(Eina_Bool variable, const char *name, int count, void ata);
*user_data); typedef void (*Eet_Node_Walk_Append_Callback)(void *list, void *child, voi
void (*insert)(void *array, int index, void *child, void *user_data); d *user_data);
void *(*list)(const char *name, void *user_data); typedef void *(*Eet_Node_Walk_Hash_Callback)(void *parent, const char *name
void (*append)(void *list, void *child, void *user_data); , const char *key, void *value, void *user_data);
void *(*hash)(void *parent, const char *name, const char *key, void * typedef void *(*Eet_Node_Walk_Simple_Callback)(int type, Eet_Node_Data *dat
value, void *user_data); a, void *user_data);
void *(*simple)(int type, Eet_Node_Data *data, void *user_data);
};
EAPI void *eet_node_walk(void *parent, const char *name, Eet_Node *root, /**
Eet_Node_Walk *cb, void *user_data); * @struct _Eet_Node_Walk
* Describes how to walk trees of #Eet_Node.
*/
struct _Eet_Node_Walk
{
Eet_Node_Walk_Struct_Alloc_Callback struct_alloc;
Eet_Node_Walk_Struct_Add_Callback struct_add;
Eet_Node_Walk_Array_Callback array;
Eet_Node_Walk_Insert_Callback insert;
Eet_Node_Walk_List_Callback list;
Eet_Node_Walk_Append_Callback append;
Eet_Node_Walk_Hash_Callback hash;
Eet_Node_Walk_Simple_Callback simple;
};
/*******/ EAPI void *
eet_node_walk(void *parent,
const char *name,
Eet_Node *root,
Eet_Node_Walk *cb,
void *user_data);
/** /*******/
* @defgroup Eet_Connection_Group Helper function to use eet over a netwo
rk link
*
* Function that reconstruct and prepare packet of @ref Eet_Data_Group to
be send.
*
*/
/** /**
* @typedef Eet_Connection * @defgroup Eet_Connection_Group Helper function to use eet over a network
* Opaque handle to track paquet for a specific connection. link
* *
* @ingroup Eet_Connection_Group * Function that reconstruct and prepare packet of @ref Eet_Data_Group to b
*/ e send.
typedef struct _Eet_Connection Eet_Connection; *
*/
/** /**
* @typedef Eet_Read_Cb * @typedef Eet_Connection
* Called back when an @ref Eet_Data_Group has been received completly an * Opaque handle to track paquet for a specific connection.
d could be used. *
* * @ingroup Eet_Connection_Group
* @ingroup Eet_Connection_Group */
*/ typedef struct _Eet_Connection Eet_Connection;
typedef Eina_Bool Eet_Read_Cb(const void *eet_data, size_t size, void *u
ser_data);
/** /**
* @typedef Eet_Write_Cb * @typedef Eet_Read_Cb
* Called back when a packet containing @ref Eet_Data_Group data is ready * Called back when an @ref Eet_Data_Group has been received completly and
to be send. could be used.
* *
* @ingroup Eet_Connection_Group * @ingroup Eet_Connection_Group
*/ */
typedef Eina_Bool Eet_Write_Cb(const void *data, size_t size, void *user typedef Eina_Bool Eet_Read_Cb (const void *eet_data, size_t size, void *use
_data); r_data);
/** /**
* Instanciate a new connection to track. * @typedef Eet_Write_Cb
* @oaram eet_read_cb Function to call when one Eet_Data packet has been * Called back when a packet containing @ref Eet_Data_Group data is ready t
fully assemble. o be send.
* @param eet_write_cb Function to call when one Eet_Data packet is ready *
to be send over the wire. * @ingroup Eet_Connection_Group
* @param user_data Pointer provided to both functions to be used as a co */
ntext handler. typedef Eina_Bool Eet_Write_Cb (const void *data, size_t size, void *user_d
* @return NULL on failure, or a valid Eet_Connection handler. ata);
*
* For every connection to track you will need a separate Eet_Connection
provider.
*
* @since 1.2.4
* @ingroup Eet_Connection_Group
*/
EAPI Eet_Connection *eet_connection_new(Eet_Read_Cb *eet_read_cb, Eet_Wr
ite_Cb *eet_write_cb, const void *user_data);
/** /**
* Process a raw packet received over the link * Instanciate a new connection to track.
* @oaram conn Connection handler to track. * @param eet_read_cb Function to call when one Eet_Data packet has been fu
* @param data Raw data packet. lly assemble.
* @param size The size of that packet. * @param eet_write_cb Function to call when one Eet_Data packet is ready t
* @return 0 on complete success, any other value indicate where in the s o be send over the wire.
tream it got wrong (It could be before that packet). * @param user_data Pointer provided to both functions to be used as a cont
* ext handler.
* Every time you receive a packet related to your connection, you should * @return NULL on failure, or a valid Eet_Connection handler.
pass *
* it to that function so that it could process and assemble packet has y * For every connection to track you will need a separate Eet_Connection pr
ou ovider.
* receive it. It will automatically call Eet_Read_Cb when one is fully r *
eceived. * @since 1.2.4
* * @ingroup Eet_Connection_Group
* @since 1.2.4 */
* @ingroup Eet_Connection_Group EAPI Eet_Connection *
*/ eet_connection_new(Eet_Read_Cb *eet_read_cb,
EAPI int eet_connection_received(Eet_Connection *conn, const void *data, Eet_Write_Cb *eet_write_cb,
size_t size); const void *user_data);
/** /**
* Convert a complex structure and prepare it to be send. * Process a raw packet received over the link
* @oaram conn Connection handler to track. * @param conn Connection handler to track.
* @param edd The data descriptor to use when encoding. * @param data Raw data packet.
* @param data_in The pointer to the struct to encode into data. * @param size The size of that packet.
* @param cipher_key The key to use as cipher. * @return 0 on complete success, any other value indicate where in the str
* @return EINA_TRUE if the data where correctly send, EINA_FALSE if they eam it got wrong (It could be before that packet).
don't. *
* * Every time you receive a packet related to your connection, you should p
* This function serialize data_in with edd, assemble the packet and call ass
* Eet_Write_Cb when ready. The data passed Eet_Write_Cb are temporary al * it to that function so that it could process and assemble packet has you
located * receive it. It will automatically call Eet_Read_Cb when one is fully rec
* and will vanish just after the return of the callback. eived.
* *
* @see eet_data_descriptor_encode_cipher * @since 1.2.4
* * @ingroup Eet_Connection_Group
* @since 1.2.4 */
* @ingroup Eet_Connection_Group EAPI int
*/ eet_connection_received(Eet_Connection *conn,
EAPI Eina_Bool eet_connection_send(Eet_Connection *conn, Eet_Data_Descri const void *data,
ptor *edd, const void *data_in, const char *cipher_key); size_t size);
/** /**
* Convert a Eet_Node tree and prepare it to be send. * Convert a complex structure and prepare it to be send.
* @oaram conn Connection handler to track. * @param conn Connection handler to track.
* @param node The data tree to use when encoding. * @param edd The data descriptor to use when encoding.
* @param cipher_key The key to use as cipher. * @param data_in The pointer to the struct to encode into data.
* @return EINA_TRUE if the data where correctly send, EINA_FALSE if they * @param cipher_key The key to use as cipher.
don't. * @return EINA_TRUE if the data where correctly send, EINA_FALSE if they d
* on't.
* This function serialize node, assemble the packet and call *
* Eet_Write_Cb when ready. The data passed Eet_Write_Cb are temporary al * This function serialize data_in with edd, assemble the packet and call
located * Eet_Write_Cb when ready. The data passed Eet_Write_Cb are temporary allo
* and will vanish just after the return of the callback. cated
* * and will vanish just after the return of the callback.
* @see eet_data_node_encode_cipher *
* * @see eet_data_descriptor_encode_cipher
* @since 1.2.4 *
* @ingroup Eet_Connection_Group * @since 1.2.4
*/ * @ingroup Eet_Connection_Group
EAPI Eina_Bool eet_connection_node_send(Eet_Connection *conn, Eet_Node * */
node, const char *cipher_key); EAPI Eina_Bool
eet_connection_send(Eet_Connection *conn,
Eet_Data_Descriptor *edd,
const void *data_in,
const char *cipher_key);
/** /**
* Close a connection and lost its track. * Convert a Eet_Node tree and prepare it to be send.
* @oaram conn Connection handler to close. * @param conn Connection handler to track.
* @param on_going Signal if a partial packet wasn't completed. * @param node The data tree to use when encoding.
* @return the user_data passed to both callback. * @param cipher_key The key to use as cipher.
* * @return EINA_TRUE if the data where correctly send, EINA_FALSE if they d
* @since 1.2.4 on't.
* @ingroup Eet_Connection_Group *
*/ * This function serialize node, assemble the packet and call
EAPI void *eet_connection_close(Eet_Connection *conn, Eina_Bool *on_goin * Eet_Write_Cb when ready. The data passed Eet_Write_Cb are temporary allo
g); cated
* and will vanish just after the return of the callback.
*
* @see eet_data_node_encode_cipher
*
* @since 1.2.4
* @ingroup Eet_Connection_Group
*/
EAPI Eina_Bool
eet_connection_node_send(Eet_Connection *conn,
Eet_Node *node,
const char *cipher_key);
/**
* Close a connection and lost its track.
* @param conn Connection handler to close.
* @param on_going Signal if a partial packet wasn't completed.
* @return the user_data passed to both callback.
*
* @since 1.2.4
* @ingroup Eet_Connection_Group
*/
EAPI void *
eet_connection_close(Eet_Connection *conn,
Eina_Bool *on_going);
/************************************************************************** */ /************************************************************************** */
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif /* ifdef __cplusplus */
#endif #endif /* ifndef _EET_H */
 End of changes. 170 change blocks. 
3104 lines changed or deleted 3370 lines changed or added

This html diff was produced by rfcdiff 1.41. The latest version is available from http://tools.ietf.org/tools/rfcdiff/