From ea4e8a0abbadc47ac9ba2dd2d97f8fe83f991759 Mon Sep 17 00:00:00 2001 From: Gustavo Sverzut Barbieri Date: Thu, 18 Mar 2010 20:16:56 +0000 Subject: [PATCH] eet: mega doc update, still stuff to do. * sync AUTHORS * add couple of groups, and change head.html to include "Modules" * Reorganize the Eet.h so header is better grouped and in an order that makes sense to the reader (as Eet.h gives the modules/group ordering). SVN revision: 47327 --- legacy/eet/AUTHORS | 4 +- legacy/eet/doc/Doxyfile | 6 +- legacy/eet/doc/eet.dox.in | 15 +- legacy/eet/doc/head.html | 2 +- legacy/eet/src/lib/Eet.h | 1659 ++++++++++++++++++++++++++------ legacy/eet/src/lib/eet_data.c | 78 +- legacy/eet/src/lib/eet_image.c | 46 +- 7 files changed, 1460 insertions(+), 350 deletions(-) diff --git a/legacy/eet/AUTHORS b/legacy/eet/AUTHORS index d1172a0e26..6ec31c0fc2 100644 --- a/legacy/eet/AUTHORS +++ b/legacy/eet/AUTHORS @@ -2,10 +2,10 @@ The Rasterman (Carsten Haitzler) David Goodlad Cedric Bail Arnaud de Turckheim -Luis Felipe Strano Moraes +Luis Felipe Strano Moraes Chidambar Zinnoury Vincent Torri -Gustavo Sverzut Barbieri +Gustavo Sverzut Barbieri Raphael Kubo da Costa Mathieu Taillefumier Albin "Lutin" Tonnerre diff --git a/legacy/eet/doc/Doxyfile b/legacy/eet/doc/Doxyfile index 43cb77d941..03bce5b57a 100644 --- a/legacy/eet/doc/Doxyfile +++ b/legacy/eet/doc/Doxyfile @@ -33,7 +33,7 @@ INLINE_INHERITED_MEMB = NO FULL_PATH_NAMES = NO STRIP_FROM_PATH = INTERNAL_DOCS = NO -STRIP_CODE_COMMENTS = YES +STRIP_CODE_COMMENTS = NO CASE_SENSE_NAMES = YES SHORT_NAMES = NO HIDE_SCOPE_NAMES = NO @@ -46,7 +46,7 @@ INHERIT_DOCS = YES INLINE_INFO = YES SORT_MEMBER_DOCS = YES DISTRIBUTE_GROUP_DOC = NO -TAB_SIZE = 2 +TAB_SIZE = 8 GENERATE_TODOLIST = YES GENERATE_TESTLIST = YES GENERATE_BUGLIST = YES @@ -78,7 +78,7 @@ REFERENCED_BY_RELATION = YES REFERENCES_RELATION = YES ALPHABETICAL_INDEX = YES COLS_IN_ALPHA_INDEX = 2 -IGNORE_PREFIX = +IGNORE_PREFIX = eet_ _eet_ Eet_ _Eet_ EET_ _EET_ GENERATE_TREEVIEW = NO TREEVIEW_WIDTH = 250 GENERATE_LATEX = YES diff --git a/legacy/eet/doc/eet.dox.in b/legacy/eet/doc/eet.dox.in index 81a2ee1d58..8847fb40ed 100644 --- a/legacy/eet/doc/eet.dox.in +++ b/legacy/eet/doc/eet.dox.in @@ -12,8 +12,19 @@ These routines are used for Eet Library interaction @image html e_big.png @version @PACKAGE_VERSION@ -@author Carsten Haitzler -@date 2000-2008 +@author Carsten Haitzler +@author David Goodlad +@author Cedric Bail +@author Arnaud de Turckheim +@author Luis Felipe Strano Moraes +@author Chidambar Zinnoury +@author Vincent Torri +@author Gustavo Sverzut Barbieri +@author Raphael Kubo da Costa +@author Mathieu Taillefumier +@author Albin "Lutin" Tonnerre +@author Adam Simpkins +@date 2000-2010 diff --git a/legacy/eet/doc/head.html b/legacy/eet/doc/head.html index 3b75ae29a0..44fc59494d 100644 --- a/legacy/eet/doc/head.html +++ b/legacy/eet/doc/head.html @@ -48,7 +48,7 @@
  • Todo
  • Files
  • -
  • Header
  • +
  • Modules
  • Globals
  • Related Pages
  • Main Page
  • diff --git a/legacy/eet/src/lib/Eet.h b/legacy/eet/src/lib/Eet.h index 08969e629d..a3f5bdbcd9 100644 --- a/legacy/eet/src/lib/Eet.h +++ b/legacy/eet/src/lib/Eet.h @@ -35,140 +35,51 @@ extern "C" { #endif -/** - * @file Eet.h - * @brief The file that provides the eet functions. - * - * This header provides the Eet management functions. - * - */ + /** + * @file Eet.h + * @brief The file that provides the eet functions. + * + * This header provides the Eet management functions. + * + */ -/***************************************************************************/ - -#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 inside 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: */ -#define EET_T_F16P16 15 /**< Data type: */ -#define EET_T_F8P24 16 /**< Data type: */ -#define EET_T_LAST 17 /**< Last data type */ - -#define EET_G_UNKNOWN 100 /**< Unknown group data encoding type */ -#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_LAST 105 /**< Last group type */ - -#define EET_I_LIMIT 128 /**< Other type exist but are reserved for internal purpose. */ - -/***************************************************************************/ - - typedef enum _Eet_File_Mode - { - EET_FILE_MODE_INVALID = -1, - EET_FILE_MODE_READ, - EET_FILE_MODE_WRITE, - EET_FILE_MODE_READ_WRITE - } Eet_File_Mode; + /** + * @defgroup Eet_Group Top level functions + * Functions that affect Eet as a whole. + * + * @{ + */ + /** + * @enum _Eet_Error + * All the error identifiers known by Eet. + */ typedef enum _Eet_Error { - EET_ERROR_NONE, - EET_ERROR_BAD_OBJECT, - EET_ERROR_EMPTY, - EET_ERROR_NOT_WRITABLE, - EET_ERROR_OUT_OF_MEMORY, - EET_ERROR_WRITE_ERROR, - EET_ERROR_WRITE_ERROR_FILE_TOO_BIG, - EET_ERROR_WRITE_ERROR_IO_ERROR, - EET_ERROR_WRITE_ERROR_OUT_OF_SPACE, - EET_ERROR_WRITE_ERROR_FILE_CLOSED, - EET_ERROR_MMAP_FAILED, - EET_ERROR_X509_ENCODING_FAILED, - EET_ERROR_SIGNATURE_FAILED, - EET_ERROR_INVALID_SIGNATURE, - EET_ERROR_NOT_SIGNED, - EET_ERROR_NOT_IMPLEMENTED, - EET_ERROR_PRNG_NOT_SEEDED, - EET_ERROR_ENCRYPT_FAILED, - EET_ERROR_DECRYPT_FAILED - } Eet_Error; + EET_ERROR_NONE, /**< No error, it's all fine! */ + EET_ERROR_BAD_OBJECT, /**< Given object or handle is NULL or invalid */ + EET_ERROR_EMPTY, /**< There was nothing to do */ + EET_ERROR_NOT_WRITABLE, /**< Could not write to file or fine is #EET_FILE_MODE_READ */ + EET_ERROR_OUT_OF_MEMORY, /**< Could not allocate memory */ + EET_ERROR_WRITE_ERROR, /**< Failed to write data to destination */ + EET_ERROR_WRITE_ERROR_FILE_TOO_BIG, /**< Failed to write file since it is too big */ + EET_ERROR_WRITE_ERROR_IO_ERROR, /**< Failed to write since generic Input/Output error */ + EET_ERROR_WRITE_ERROR_OUT_OF_SPACE, /**< Failed to write due out of space */ + EET_ERROR_WRITE_ERROR_FILE_CLOSED, /**< Failed to write because file was closed */ + EET_ERROR_MMAP_FAILED, /**< Could not mmap file */ + EET_ERROR_X509_ENCODING_FAILED, /**< Could not encode using X509 */ + EET_ERROR_SIGNATURE_FAILED, /**< Could not validate signature */ + EET_ERROR_INVALID_SIGNATURE, /**< Signature is invalid */ + EET_ERROR_NOT_SIGNED, /**< File or contents are not signed */ + EET_ERROR_NOT_IMPLEMENTED, /**< Function is not implemented */ + EET_ERROR_PRNG_NOT_SEEDED, /**< Could not introduce random seed */ + EET_ERROR_ENCRYPT_FAILED, /**< Could not encrypt contents */ + EET_ERROR_DECRYPT_FAILED /**< Could not decrypt contents */ + } Eet_Error; /**< Eet error identifiers */ - typedef struct _Eet_File Eet_File; - typedef struct _Eet_Dictionary Eet_Dictionary; - typedef struct _Eet_Data_Descriptor Eet_Data_Descriptor; - typedef struct _Eet_Key Eet_Key; - typedef struct _Eet_Node Eet_Node; - typedef struct _Eet_Node_Data Eet_Node_Data; - typedef struct _Eet_Node_Walk Eet_Node_Walk; - - typedef struct _Eet_Data_Descriptor_Class Eet_Data_Descriptor_Class; - - struct _Eet_Node_Data - { - union { - char c; - short s; - int i; - long long l; - float f; - double d; - unsigned char uc; - unsigned short us; - unsigned int ui; - unsigned long long ul; - const char *str; - } value; - }; - - struct _Eet_Node_Walk - { - void *(*struct_alloc)(const char *type, void *user_data); - void (*struct_add)(void *parent, const char *name, void *child, void *user_data); - void *(*array)(Eina_Bool variable, const char *name, int count, void *user_data); - void (*insert)(void *array, int index, void *child, void *user_data); - void *(*list)(const char *name, void *user_data); - void (*append)(void *list, void *child, void *user_data); - void *(*hash)(void *parent, const char *name, const char *key, void *value, void *user_data); - void *(*simple)(int type, Eet_Node_Data *data, void *user_data); - }; - -#define EET_DATA_DESCRIPTOR_CLASS_VERSION 2 - struct _Eet_Data_Descriptor_Class - { - int version; - const char *name; - int size; - struct { - void *(*mem_alloc) (size_t size); - void (*mem_free) (void *mem); - char *(*str_alloc) (const char *str); - void (*str_free) (const char *str); - void *(*list_next) (void *l); - void *(*list_append) (void *l, void *d); - void *(*list_data) (void *l); - void *(*list_free) (void *l); - void (*hash_foreach) (void *h, int (*func) (void *h, const char *k, void *dt, void *fdt), void *fdt); - void *(*hash_add) (void *h, const char *k, void *d); - void (*hash_free) (void *h); - char *(*str_direct_alloc) (const char *str); - void (*str_direct_free) (const char *str); - } func; - }; - -/***************************************************************************/ + /** + * @} + */ /** * Initialize the EET library. @@ -176,6 +87,7 @@ extern "C" { * @return The new init count. * * @since 1.0.0 + * @ingroup Eet_Group */ EAPI int eet_init(void); @@ -185,6 +97,7 @@ extern "C" { * @return The new init count. * * @since 1.0.0 + * @ingroup Eet_Group */ EAPI int eet_shutdown(void); @@ -197,15 +110,60 @@ extern "C" { * on disk. * * @since 1.0.0 + * @ingroup Eet_Group */ EAPI void eet_clearcache(void); + + /** + * @defgroup Eet_File_Group Eet File Main Functions + * + * Functions to create, destroy and do basic manipulation of + * #Eet_File handles. + * + * @{ + */ + + /** + * @enum _Eet_File_Mode + * Modes that a file can be opened. + */ + typedef enum _Eet_File_Mode + { + EET_FILE_MODE_INVALID = -1, + EET_FILE_MODE_READ, /**< File is read-only. */ + EET_FILE_MODE_WRITE, /**< File is write-only. */ + EET_FILE_MODE_READ_WRITE /**< File is for both read and write */ + } Eet_File_Mode; /**< Modes that a file can be opened. */ + + /** + * @typedef Eet_File + * Opaque handle that defines an Eet file (or memory). + * + * @see eet_open() + * @see eet_memopen_read() + * @see eet_close() + */ + typedef struct _Eet_File Eet_File; + + /** + * @typedef Eet_Dictionary + * Opaque handle that defines a file-backed (mmaped) dictionary of strings. + */ + typedef struct _Eet_Dictionary Eet_Dictionary; + + + /** + * @} + */ + /** * Open an eet file on disk, and returns a handle to it. - * @param file The file path to the eet file. eg: "/tmp/file.eet". - * @param mode The mode for opening. Either EET_FILE_MODE_READ, - * EET_FILE_MODE_WRITE or EET_FILE_MODE_READ_WRITE. + * @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, + * #EET_FILE_MODE_WRITE or #EET_FILE_MODE_READ_WRITE. * @return An opened eet file handle. + * @ingroup Eet_File_Group * * 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 @@ -278,6 +236,7 @@ extern "C" { * you do use eet_memopen_read. * * @since 1.1.0 + * @ingroup Eet_File_Group */ EAPI Eet_File *eet_memopen_read(const void *data, size_t size); @@ -287,6 +246,7 @@ extern "C" { * @return The mode ef was opened with. * * @since 1.0.0 + * @ingroup Eet_File_Group */ EAPI Eet_File_Mode eet_mode_get(Eet_File *ef); @@ -301,78 +261,10 @@ extern "C" { * If the eet file handle is not valid nothing will be done. * * @since 1.0.0 + * @ingroup Eet_File_Group */ EAPI Eet_Error eet_close(Eet_File *ef); - /** - * Callback used to request if needed the password of a private key. - * - * @since 1.2.0 - */ - typedef int (*Eet_Key_Password_Callback)(char *buffer, int size, int rwflag, void *data); - - /** - * Create an Eet_Key needed for signing an eet file. - * - * The certificate should provide the public that match the private key. - * No verification is done to ensure that. - * - * @since 1.2.0 - */ - 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 reference counter prevent it from being freed until all file using it are - * also closed. - * - * @since 1.2.0 - */ - EAPI void eet_identity_close(Eet_Key *key); - - /** - * Set a key to sign a file - * - * @since 1.2.0 - */ - EAPI Eet_Error eet_identity_set(Eet_File *ef, Eet_Key *key); - - /** - * Display both private and public key of an Eet_Key. - * - * @since 1.2.0 - */ - EAPI void eet_identity_print(Eet_Key *key, FILE *out); - - /** - * Get the x509 der certificate associated with an Eet_File. Will return NULL - * if the file is not signed. - * - * @since 1.2.0 - */ - EAPI const void *eet_identity_x509(Eet_File *ef, int *der_length); - - /** - * Get the raw signature associated with an Eet_File. Will return NULL - * if the file is not signed. - */ - EAPI const void *eet_identity_signature(Eet_File *ef, int *signature_length); - - /** - * 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 SHA1 of the file. - * - * @since 1.2.0 - */ - EAPI const void *eet_identity_sha1(Eet_File *ef, int *sha1_length); - - /** - * Display the x509 der certificate to out. - * - * @since 1.2.0 - */ - EAPI void eet_identity_certificate_print(const unsigned char *certificate, int der_length, FILE *out); - /** * Return a handle to the shared string dictionary of the Eet file * @param ef A valid eet file handle. @@ -382,7 +274,12 @@ extern "C" { * handle is @p ef, if a dictionary exists. NULL is returned otherwise or * if the file handle is known to be invalid. * + * @see eet_dictionary_string_check() to know if given string came + * from the dictionary or it was dynamically allocated using + * the #Eet_Data_Descriptor_Class instructrions. + * * @since 1.0.0 + * @ingroup Eet_File_Group */ EAPI Eet_Dictionary *eet_dictionary_get(Eet_File *ef); @@ -398,6 +295,7 @@ extern "C" { * not in the dictionary, 0 is returned. * * @since 1.0.0 + * @ingroup Eet_File_Group */ EAPI int eet_dictionary_string_check(Eet_Dictionary *ed, const char *string); @@ -418,9 +316,11 @@ extern "C" { * If the eet file handle is not valid NULL is returned and size_ret is * filled with 0. * + * @see eet_read_cipher() + * * @since 1.0.0 + * @ingroup Eet_File_Group */ - EAPI void *eet_read_cipher(Eet_File *ef, const char *name, int *size_ret, const char *cipher_key); EAPI void *eet_read(Eet_File *ef, const char *name, int *size_ret); /** @@ -441,6 +341,7 @@ extern "C" { * filled with 0. * * @since 1.0.0 + * @ingroup Eet_File_Group */ EAPI const void *eet_read_direct(Eet_File *ef, const char *name, int *size_ret); @@ -467,9 +368,11 @@ extern "C" { * a flush to disk (it will stay in ram till the eet file handle is * closed though). * + * @see eet_write_cipher() + * * @since 1.0.0 + * @ingroup Eet_File_Group */ - EAPI int eet_write_cipher(Eet_File *ef, const char *name, const void *data, int size, int compress, const char *cipher_key); EAPI int eet_write(Eet_File *ef, const char *name, const void *data, int size, int compress); /** @@ -488,6 +391,7 @@ extern "C" { * Name, must not be NULL, otherwise 0 will be returned. * * @since 1.0.0 + * @ingroup Eet_File_Group */ EAPI int eet_delete(Eet_File *ef, const char *name); @@ -519,6 +423,7 @@ extern "C" { * value of "*". * * @since 1.0.0 + * @ingroup Eet_File_Group */ EAPI char **eet_list(Eet_File *ef, const char *glob, int *count_ret); @@ -529,10 +434,84 @@ extern "C" { * cannot be read due to open mode restrictions. * * @since 1.0.0 + * @ingroup Eet_File_Group */ EAPI int eet_num_entries(Eet_File *ef); -/***************************************************************************/ + /** + * @defgroup Eet_File_Cipher_Group Eet File Ciphered Main Functions + * + * Most of the @ref Eet_File_Group have alternative versions that + * accounts for ciphers to protect their content. + * + * @see @ref Eet_Cipher_Group + * + * @ingroup Eet_File_Group + */ + + /** + * Read a specified entry from an eet file and return data using a cipher. + * @param ef A valid eet file handle opened for reading. + * @param name Name of the entry. eg: "/base/file_i_want". + * @param size_ret Number of bytes read from entry and returned. + * @param cipher_key The key to use as cipher. + * @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 + * 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. + * @param ef A valid eet file handle opened for writing. + * @param name Name of the entry. eg: "/base/file_i_want". + * @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); + + + /** + * @defgroup Eet_File_Image_Group Image Store and Load + * + * Eet efficiently stores and loads images, including alpha + * channels and lossy compressions. + */ /** * Read just the header data for an image and dont decode the pixels. @@ -565,9 +544,11 @@ extern "C" { * 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_cipher(Eet_File *ef, const char *name, const char *key, unsigned int *w, unsigned int *h, int *alpha, int *compress, int *quality, int *lossy); EAPI int eet_data_image_header_read(Eet_File *ef, const char *name, unsigned int *w, unsigned int *h, int *alpha, int *compress, int *quality, int *lossy); /** @@ -603,9 +584,11 @@ extern "C" { * when it is done with it. On failure NULL is returned and the parameter * values may not contain any sensible data. * + * @see eet_data_image_read_cipher() + * * @since 1.0.0 + * @ingroup Eet_File_Image_Group */ - EAPI void *eet_data_image_read_cipher(Eet_File *ef, const char *name, const char *key, unsigned int *w, unsigned int *h, int *alpha, int *compress, int *quality, 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 *lossy); /** @@ -643,9 +626,11 @@ extern "C" { * 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_read_to_surface_cipher() + * * @since 1.0.2 + * @ingroup Eet_File_Image_Group */ - EAPI int eet_data_image_read_to_surface_cipher(Eet_File *ef, const char *name, const char *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); 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); /** @@ -678,9 +663,11 @@ extern "C" { * On success this function returns the number of bytes that were required * to encode the image data, or on failure it returns 0. * + * @see eet_data_image_write_cipher() + * * @since 1.0.0 + * @ingroup Eet_File_Image_Group */ - EAPI int eet_data_image_write_cipher(Eet_File *ef, const char *name, const char *key, const void *data, unsigned int w, unsigned int h, int alpha, int compress, int quality, int lossy); EAPI int eet_data_image_write(Eet_File *ef, const char *name, const void *data, unsigned int w, unsigned int h, int alpha, int compress, int quality, int lossy); /** @@ -714,9 +701,11 @@ extern "C" { * On success the function returns 1 indicating the header was read and * decoded properly, or 0 on failure. * + * @see eet_data_image_header_decode_cipher() + * * @since 1.0.0 + * @ingroup Eet_File_Image_Group */ - EAPI int eet_data_image_header_decode_cipher(const void *data, const char *key, int size, unsigned int *w, unsigned int *h, int *alpha, int *compress, int *quality, int *lossy); EAPI int eet_data_image_header_decode(const void *data, int size, unsigned int *w, unsigned int *h, int *alpha, int *compress, int *quality, int *lossy); /** @@ -752,9 +741,11 @@ extern "C" { * when it is done with it. On failure NULL is returned and the parameter * values may not contain any sensible data. * + * @see eet_data_image_decode_cipher() + * * @since 1.0.0 + * @ingroup Eet_File_Image_Group */ - EAPI void *eet_data_image_decode_cipher(const void *data, const char *key, int size, unsigned int *w, unsigned int *h, int *alpha, int *compress, int *quality, int *lossy); EAPI void *eet_data_image_decode(const void *data, int size, unsigned int *w, unsigned int *h, int *alpha, int *compress, int *quality, int *lossy); /** @@ -792,9 +783,11 @@ extern "C" { * 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_decode_to_surface_cipher() + * * @since 1.0.2 + * @ingroup Eet_File_Image_Group */ - EAPI int eet_data_image_decode_to_surface_cipher(const void *data, const char *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); 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); /** @@ -826,44 +819,519 @@ extern "C" { * 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_cipher(const void *data, const char *key, unsigned int w, unsigned int h, int alpha, int compress, int quality, int lossy, int *size_ret); 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); -/***************************************************************************/ + /** + * @defgroup Eet_File_Image_Cipher_Group Image Store and Load using a Cipher + * + * Most of the @ref Eet_File_Image_Group have alternative versions + * that accounts for ciphers to protect their content. + * + * @see @ref Eet_Cipher_Group + * + * @ingroup Eet_File_Image_Group + */ /** - * 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. + * Read just the header data for an image and dont decode the pixels using a cipher. + * @param ef A valid eet file handle opened for reading. + * @param name Name of the entry. eg: "/base/file_i_want". + * @param cipher_key The key to use as cipher. + * @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 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 creates a new data descriptore and returns a handle to the - * new data descriptor. On creation it will be empty, containing no contents - * describing anything other than the shell of the data structure. + * 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 data. * - * 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. + * The other parameters of the image (width, height etc.) are placed into + * the values pointed to (they must be supplied). The pixel data is a linear + * 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 byte + * 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 denotes + * 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. * - * 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. + * On success the function returns 1 indicating the header was read and + * decoded properly, or 0 on failure. * - * 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. + * @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 *name, const char *cipher_key, unsigned int *w, unsigned int *h, int *alpha, int *compress, int *quality, int *lossy); + + /** + * 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 name Name of the entry. eg: "/base/file_i_want". + * @param cipher_key The key to use as cipher. + * @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 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 The image pixel data decoded + * + * 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 data. + * + * The other parameters of the image (width, height etc.) are placed into + * the values pointed to (they must be supplied). The pixel data is a linear + * 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 byte + * 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 denotes + * 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 a pointer to the image data decoded. The + * calling application is responsible for calling free() on the image data + * when it is done with it. On failure NULL is returned and the parameter + * values may not contain any sensible data. + * + * @see eet_data_image_read() + * + * @since 1.0.0 + * @ingroup Eet_File_Image_Cipher_Group + */ + EAPI void *eet_data_image_read_cipher(Eet_File *ef, const char *name, const char *cipher_key, unsigned int *w, unsigned int *h, int *alpha, int *compress, int *quality, int *lossy); + + /** + * 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 name Name of the entry. eg: "/base/file_i_want". + * @param cipher_key The key to use as cipher. + * @param src_x The starting x coordinate from where to dump the stream. + * @param src_y The starting y coordinate from where to dump the stream. + * @param d A pointer to the pixel surface. + * @param w The expected width in pixels of the pixel surface to decode. + * @param h The expected height in pixels of the pixel surface to decode. + * @param row_stride The length of a pixels line in the destination surface. + * @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 success, 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 data. + * + * The other parameters of the image (width, height etc.) are placed into + * the values pointed to (they must be supplied). The pixel data is a linear + * 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 byte + * 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 denotes + * 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, and 0 on failure. On failure the + * parameter values may not contain any sensible data. + * + * @see eet_data_image_read_to_surface() + * + * @since 1.0.2 + * @ingroup Eet_File_Image_Cipher_Group + */ + 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); + + /** + * Write image data to the named key in an eet file using a cipher. + * @param ef A valid eet file handle opened for writing. + * @param name Name of the entry. eg: "/base/file_i_want". + * @param cipher_key The key to use as cipher. + * @param data A pointer to the image pixel data. + * @param w The width of the image in pixels. + * @param h The height of the image in pixels. + * @param alpha The alpha channel flag. + * @param compress The compression amount. + * @param quality The quality encoding amount. + * @param lossy The lossiness flag. + * @return Success if the data was encoded and written or not. + * + * 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 + * actually written to encode the image data. + * + * 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 on + * 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 the number of bytes that were required + * to encode the image data, or on failure it returns 0. + * + * @see eet_data_image_write() + * + * @since 1.0.0 + * @ingroup Eet_File_Image_Cipher_Group + */ + EAPI int eet_data_image_write_cipher(Eet_File *ef, const char *name, const char *cipher_key, const void *data, unsigned int w, unsigned int h, int alpha, int compress, int quality, int lossy); + + + /** + * Decode Image data header only to get information using a cipher. + * @param data The encoded pixel data. + * @param cipher_key The key to use as cipher. + * @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 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 success, 0 on failure. + * + * This function takes encoded pixel data and decodes it into raw RGBA + * pixels on success. + * + * The other parameters of the image (width, height etc.) are placed into + * the values pointed to (they must be supplied). The pixel data is a linear + * array of pixels starting from the top-left of the image scanning row by + * 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 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 denotes + * 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_decode() + * + * @since 1.0.0 + * @ingroup Eet_File_Image_Cipher_Group + */ + EAPI int eet_data_image_header_decode_cipher(const void *data, const char *cipher_key, int size, unsigned int *w, unsigned int *h, int *alpha, int *compress, int *quality, int *lossy); + + /** + * Decode Image data into pixel data using a cipher. + * @param data The encoded pixel data. + * @param cipher_key The key to use as cipher. + * @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 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 The image pixel data decoded + * + * This function takes encoded pixel data and decodes it into raw RGBA + * pixels on success. + * + * The other parameters of the image (width, height etc.) are placed into + * the values pointed to (they must be supplied). The pixel data is a linear + * array of pixels starting from the top-left of the image scanning row by + * 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 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 denotes + * 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 a pointer to the image data decoded. The + * calling application is responsible for calling free() on the image data + * when it is done with it. On failure NULL is returned and the parameter + * values may not contain any sensible data. + * + * @see eet_data_image_decode() + * + * @since 1.0.0 + * @ingroup Eet_File_Image_Cipher_Group + */ + EAPI void *eet_data_image_decode_cipher(const void *data, const char *cipher_key, int size, unsigned int *w, unsigned int *h, int *alpha, int *compress, int *quality, int *lossy); + + /** + * Decode Image data into pixel data using a cipher. + * @param data The encoded pixel data. + * @param cipher_key The key to use as cipher. + * @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 src_y The starting y coordinate from where to dump the stream. + * @param d A pointer to the pixel surface. + * @param w The expected width in pixels of the pixel surface to decode. + * @param h The expected height in pixels of the pixel surface to decode. + * @param row_stride The length of a pixels line in the destination surface. + * @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 success, 0 otherwise. + * + * This function takes encoded pixel data and decodes it into raw RGBA + * pixels on success. + * + * The other parameters of the image (alpha, compress etc.) are placed into + * the values pointed to (they must be supplied). The pixel data is a linear + * array of pixels starting from the top-left of the image scanning row by + * 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 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 denotes + * 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, and 0 on failure. On failure the + * parameter values may not contain any sensible data. + * + * @see eet_data_image_decode_to_surface() + * + * @since 1.0.2 + * @ingroup Eet_File_Image_Cipher_Group + */ + EAPI int 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); + + /** + * Encode image data for storage or transmission using a cipher. + * @param data A pointer to the image pixel data. + * @param cipher_key The key to use as cipher. + * @param size_ret A pointer to an int to hold the size of the returned data. + * @param w The width of the image in pixels. + * @param h The height of the image in pixels. + * @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 and + * 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 on + * 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); + + + /** + * @defgroup Eet_Cipher_Group Cipher, Identity and Protection Mechanisms + * + * Eet allows one to protect entries of an #Eet_File + * individually. This may be used to ensure data was not tampered or + * 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 rwflag, void *data); + + /** + * Create an Eet_Key needed for signing an eet file. + * + * The certificate should provide the public that match the private key. + * No verification is done to ensure that. + * + * @param certificate_file The file where to find the certificate. + * @param private_key_file The file that contains the private key. + * @param cb Function to callback if password is required to unlock + * private 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); + + /** + * Close and release all ressource used by an Eet_Key. An + * reference counter prevent it from being freed until all file + * using it are also closed. + * + * @param key the key handle to close and free resources. + * + * @since 1.2.0 + * @ingroup Eet_Cipher_Group + */ + EAPI void eet_identity_close(Eet_Key *key); + + /** + * Set a key to sign a file + * + * @param ef the file to set the identity. + * @param key the key handle to set as identity. + * @return #EET_ERROR_BAD_OBJECT if @p ef is invalid or + * #EET_ERROR_NONE on success. + * + * @since 1.2.0 + * @ingroup Eet_Cipher_Group + */ + EAPI Eet_Error eet_identity_set(Eet_File *ef, Eet_Key *key); + + /** + * Display both private and public key of an Eet_Key. + * + * @param key the handle to print. + * @param out where to print. + * + * @since 1.2.0 + * @ingroup Eet_Cipher_Group + */ + EAPI void eet_identity_print(Eet_Key *key, FILE *out); + + /** + * Get the x509 der certificate associated with an Eet_File. Will return NULL + * if the file is not signed. + * + * @param ef The file handle to query. + * @param der_length The length of returned data, may be @c NULL. + * @return the x509 certificate or @c NULL on error. + * + * @since 1.2.0 + * @ingroup Eet_Cipher_Group + */ + EAPI const void *eet_identity_x509(Eet_File *ef, int *der_length); + + /** + * Get the raw signature associated with an Eet_File. Will return NULL + * 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. + * @return the raw signature or @c NULL on error. + * + * @ingroup Eet_Cipher_Group + */ + EAPI const void *eet_identity_signature(Eet_File *ef, int *signature_length); + + /** + * 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 + * SHA1 of the file. + * + * @param ef The file handle to query. + * @param sha1_length The length of returned data, may be @c NULL. + * @return the associated SHA1 or @c NULL on error. + * + * @since 1.2.0 + * @ingroup Eet_Cipher_Group + */ + EAPI const void *eet_identity_sha1(Eet_File *ef, int *sha1_length); + + /** + * Display the x509 der certificate to out. + * + * @param certificate the x509 certificate to print + * @param der_length The length the certificate. + * @param out where to print. + * + * @since 1.2.0 + * @ingroup Eet_Cipher_Group + */ + EAPI void eet_identity_certificate_print(const unsigned char *certificate, int der_length, FILE *out); + + + /** + * @defgroup Eet_Data_Group Eet Data Serialization + * + * Convenience functions to serialize and parse complex data + * structures to binary blobs. + * + * While Eet core just handles binary blobs, it is often required + * 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: * @@ -874,14 +1342,12 @@ extern "C" { * typedef struct _blah2 * { * char *string; - * } - * Blah2; + * } Blah2; * * typedef struct _blah3 * { * char *string; - * } - * Blah3; + * } Blah3; * * typedef struct _blah * { @@ -894,18 +1360,7 @@ extern "C" { * char *string; * Blah2 *blah2; * Eina_List *blah3; - * } - * Blah; - * - * Eina_Hash* - * eet_eina_hash_add(Eina_Hash *hash, const char *key, const void *data) - * { - * if (!hash) hash = eina_hash_string_superfast_new(NULL); - * if (!hash) return NULL; - * - * eina_hash_add(hash, key, data); - * return hash; - * } + * } Blah; * * int * main(int argc, char **argv) @@ -994,10 +1449,144 @@ extern "C" { * * 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 inside 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: */ +#define EET_T_F16P16 15 /**< Data type: */ +#define EET_T_F8P24 16 /**< Data type: */ +#define EET_T_LAST 17 /**< Last data type */ + +#define EET_G_UNKNOWN 100 /**< Unknown group data encoding type */ +#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_LAST 105 /**< Last group type */ + +#define EET_I_LIMIT 128 /**< Other type exist but are reserved for internal purpose. */ + + /** + * @typedef Eet_Data_Descriptor + * + * 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 + * The version of #Eet_Data_Descriptor_Class at the time of the + * distribution of the sources. One should define this to its + * version member so it is compatible with abi changes, or at least + * will not crash with them. + */ +#define EET_DATA_DESCRIPTOR_CLASS_VERSION 2 + + /** + * @typedef Eet_Data_Descriptor_Class + * + * Instructs Eet about memory management for different needs under + * serialization and parse process. + */ + typedef struct _Eet_Data_Descriptor_Class Eet_Data_Descriptor_Class; + + /** + * @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_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 string */ + void (*str_free) (const char *str); /**< how to free a string */ + void *(*list_next) (void *l); /**< how to iterate to the next element of a list. Receives and should return the list node. */ + void *(*list_append) (void *l, void *d); /**< how to append data @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 char *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 hash @p h */ + char *(*str_direct_alloc) (const char *str); /**< how to allocate 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 */ + } 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 contents + * 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) (void *h, const char *k, void *dt, void *fdt), void *fdt), void *(*func_hash_add) (void *h, const char *k, void *d), void (*func_hash_free) (void *h)); /* @@ -1013,7 +1602,7 @@ extern "C" { * This function creates a new data descriptore and returns a handle to the * new data descriptor. On creation it will be empty, containing no contents * describing anything other than the shell of the data structure. - * @param edd The data descriptor to free. + * @param eddc The data descriptor to free. * * You add structure members to the data descriptor using the macros * EET_DATA_DESCRIPTOR_ADD_BASIC(), EET_DATA_DESCRIPTOR_ADD_SUB() and @@ -1031,14 +1620,15 @@ extern "C" { * and duplicated in memory. * * @since 1.2.3 + * @ingroup Eet_Data_Group */ EAPI Eet_Data_Descriptor *eet_data_descriptor_stream_new(const Eet_Data_Descriptor_Class *eddc); - /** + /** * This function creates a new data descriptore and returns a handle to the * new data descriptor. On creation it will be empty, containing no contents * describing anything other than the shell of the data structure. - * @param edd The data descriptor to free. + * @param eddc The data descriptor to free. * * You add structure members to the data descriptor using the macros * EET_DATA_DESCRIPTOR_ADD_BASIC(), EET_DATA_DESCRIPTOR_ADD_SUB() and @@ -1059,19 +1649,23 @@ extern "C" { * 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 function is an helper that set all the parameter of an Eet_Data_Descriptor_Class - * correctly when you use Eina data type with a stream. - * @param class The Eet_Data_Descriptor_Class you want to set. + * This function is an helper that set all the parameter of an + * Eet_Data_Descriptor_Class correctly when you use Eina data type + * with a stream. + * @param eddc The Eet_Data_Descriptor_Class you want to set. * @param name The name 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 reason that could make - * it fail is if you did give wrong parameter). + * @return EINA_TRUE if the structure was correctly set (The only + * reason that could make it fail is if you did give wrong + * parameter). * * @since 1.2.3 + * @ingroup Eet_Data_Group */ EAPI Eina_Bool eet_eina_stream_data_descriptor_class_set(Eet_Data_Descriptor_Class *eddc, const char *name, int size); @@ -1079,13 +1673,14 @@ extern "C" { * This macro is an helper that set all the parameter of an * Eet_Data_Descriptor_Class correctly when you use Eina data type * with stream. - * @param class The Eet_Data_Descriptor_Class you want to set. - * @param type The type of the structure described by this class. + * @param Clas The Eet_Data_Descriptor_Class you want to set. + * @param Type The type of the structure described by this class. * @return EINA_TRUE if the structure was correctly set (The only * reason that could make it fail is if you did give wrong * parameter). * * @since 1.2.3 + * @ingroup Eet_Data_Group */ #define EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(Clas, Type) (eet_eina_stream_data_descriptor_class_set(Clas, #Type , sizeof (Type))) @@ -1093,7 +1688,7 @@ extern "C" { * This function is an helper that set all the parameter of an * Eet_Data_Descriptor_Class correctly when you use Eina data type * with a file. - * @param class The Eet_Data_Descriptor_Class you want to set. + * @param eddc The Eet_Data_Descriptor_Class you want to set. * @param name The name 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 @@ -1101,6 +1696,7 @@ extern "C" { * parameter). * * @since 1.2.3 + * @ingroup Eet_Data_Group */ EAPI Eina_Bool eet_eina_file_data_descriptor_class_set(Eet_Data_Descriptor_Class *eddc, const char *name, int size); @@ -1108,13 +1704,14 @@ extern "C" { * This macro is an helper that set all the parameter of an * Eet_Data_Descriptor_Class correctly when you use Eina data type * with file. - * @param class The Eet_Data_Descriptor_Class you want to set. - * @param type The type of the structure described by this class. + * @param Clas The Eet_Data_Descriptor_Class you want to set. + * @param Type The type of the structure described by this class. * @return EINA_TRUE if the structure was correctly set (The only * reason that could make it fail is if you did give wrong * parameter). * * @since 1.2.3 + * @ingroup Eet_Data_Group */ #define EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(Clas, Type) (eet_eina_file_data_descriptor_class_set(Clas, #Type , sizeof (Type))) @@ -1127,6 +1724,7 @@ extern "C" { * call the descriptor is no longer valid. * * @since 1.0.0 + * @ingroup Eet_Data_Group */ EAPI void eet_data_descriptor_free(Eet_Data_Descriptor *edd); @@ -1138,7 +1736,23 @@ extern "C" { * complex to use by hand and should be left to be used by the macros, and * thus is not documented. * + * @param edd The data descriptor handle to add element (member). + * @param name The name of element to be serialized. + * @param type The type of element to be serialized, like + * #EET_T_INT. If #EET_T_UNKNOW, then it is considered to be a + * 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 elements. + * @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, const char *name, int type, int group_type, int offset, /* int count_offset, */int count, const char *counter_name, Eet_Data_Descriptor *subtype); @@ -1164,9 +1778,11 @@ extern "C" { * 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_cipher(Eet_File *ef, Eet_Data_Descriptor *edd, const char *name, const char *key); EAPI void *eet_data_read(Eet_File *ef, Eet_Data_Descriptor *edd, const char *name); /** @@ -1181,9 +1797,11 @@ extern "C" { * This function is the reverse of eet_data_read(), saving a data structure * to an eet file. * + * @see eet_data_write_cipher() + * * @since 1.0.0 + * @ingroup Eet_Data_Group */ - EAPI int eet_data_write_cipher(Eet_File *ef, Eet_Data_Descriptor *edd, const char *name, const char *key, const void *data, int compress); EAPI int eet_data_write(Eet_File *ef, Eet_Data_Descriptor *edd, const char *name, const void *data, int compress); /** @@ -1228,9 +1846,11 @@ extern "C" { * } * @endcode * + * @see eet_data_text_dump_cipher() + * * @since 1.0.0 + * @ingroup Eet_Data_Group */ - EAPI int eet_data_text_dump_cipher(const void *data_in, const char *key, int size_in, void (*dumpfunc) (void *data, const char *str), void *dumpdata); EAPI int eet_data_text_dump(const void *data_in, int size_in, void (*dumpfunc) (void *data, const char *str), void *dumpdata); /** @@ -1247,9 +1867,11 @@ extern "C" { * in-memory data struct and encodes into a binary blob. @p text is a normal * C string. * + * @see eet_data_text_undump_cipher() + * * @since 1.0.0 + * @ingroup Eet_Data_Group */ - EAPI void *eet_data_text_undump_cipher(const char *text, const char *key, int textlen, int *size_ret); EAPI void *eet_data_text_undump(const char *text, int textlen, int *size_ret); /** @@ -1270,9 +1892,11 @@ extern "C" { * buffer and will be passed the pointer @p dumpdata as a parameter * as well as a string with new text to be appended. * + * @see eet_data_dump_cipher() + * * @since 1.0.0 + * @ingroup Eet_Data_Group */ - EAPI int eet_data_dump_cipher(Eet_File *ef, const char *name, const char *key, void (*dumpfunc) (void *data, const char *str), void *dumpdata); EAPI int eet_data_dump(Eet_File *ef, const char *name, void (*dumpfunc) (void *data, const char *str), void *dumpdata); /** @@ -1292,9 +1916,11 @@ extern "C" { * 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_undump_cipher() + * * @since 1.0.0 + * @ingroup Eet_Data_Group */ - EAPI int eet_data_undump_cipher(Eet_File *ef, const char *name, const char *key, const char *text, int textlen, int compress); EAPI int eet_data_undump(Eet_File *ef, const char *name, const char *text, int textlen, int compress); /** @@ -1319,9 +1945,11 @@ extern "C" { * * Please see eet_data_read() for more information. * + * @see eet_data_descriptor_decode_cipher() + * * @since 1.0.0 + * @ingroup Eet_Data_Group */ - EAPI void *eet_data_descriptor_decode_cipher(Eet_Data_Descriptor *edd, const void *data_in, const char *key, int size_in); EAPI void *eet_data_descriptor_decode(Eet_Data_Descriptor *edd, const void *data_in, int size_in); /** @@ -1348,9 +1976,11 @@ extern "C" { * * 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_cipher(Eet_Data_Descriptor *edd, const void *data_in, const char *key, int *size_ret); EAPI void *eet_data_descriptor_encode(Eet_Data_Descriptor *edd, const void *data_in, int *size_ret); /** @@ -1375,6 +2005,7 @@ extern "C" { * 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) \ { \ @@ -1401,6 +2032,7 @@ extern "C" { * this element. * * @since 1.0.0 + * @ingroup Eet_Data_Group */ #define EET_DATA_DESCRIPTOR_ADD_SUB(edd, struct_type, name, member, subtype) \ { \ @@ -1426,6 +2058,7 @@ extern "C" { * element that is in each member of the linked list to be stored. * * @since 1.0.0 + * @ingroup Eet_Data_Group */ #define EET_DATA_DESCRIPTOR_ADD_LIST(edd, struct_type, name, member, subtype) \ { \ @@ -1451,6 +2084,7 @@ extern "C" { * element that is in each member of the hash to be stored. * * @since 1.0.0 + * @ingroup Eet_Data_Group */ #define EET_DATA_DESCRIPTOR_ADD_HASH(edd, struct_type, name, member, subtype) \ { \ @@ -1477,6 +2111,7 @@ extern "C" { * 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, subtype) \ { \ @@ -1503,6 +2138,7 @@ extern "C" { * is in each member of the hash to be stored. * * @since 1.0.2 + * @ingroup Eet_Data_Group */ #define EET_DATA_DESCRIPTOR_ADD_VAR_ARRAY(edd, struct_type, name, member, subtype) \ { \ @@ -1513,42 +2149,499 @@ extern "C" { (char *)(&(___ett.member ## _count)) - (char *)(&(___ett)), /* 0, */NULL, subtype); \ } -/***************************************************************************/ + /** + * @defgroup Eet_Data_Cipher_Group Eet Data Serialization using A Ciphers + * + * Most of the @ref Eet_Data_Group have alternative versions that + * accounts for ciphers to protect their content. + * + * @see @ref Eet_Cipher_Group + * + * @ingroup Eet_Data_Group + */ + /** + * Read a data structure from an eet file and decodes it using a cipher. + * @param ef The eet file handle to read from. + * @param edd The data descriptor handle to use when decoding. + * @param name The key the data is stored under in the eet file. + * @param cipher_key The key to use as cipher. + * @return A pointer to the decoded data structure. + * + * 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 + * can save a programmer dozens of hours of work in writing configuration + * file parsing and writing code, as eet does all that work for the program + * and presents a program-friendly data structure, just as the programmer + * likes. Eet can handle members being added or deleted from the data in + * storage and safely zero-fills unfilled members if they were not found + * in the data. It checks sizes and headers whenever it reads data, allowing + * the programmer to not worry about corrupt data. + * + * Once a data structure has been described by the programmer with the + * 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() + * + * @since 1.0.0 + * @ingroup Eet_Data_Cipher_Group + */ + 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 + * using a cipher. + * @param ef The eet file handle to write to. + * @param edd The data descriptor to use when encoding. + * @param name The key to store the data under in the eet file. + * @param cipher_key The key to use as cipher. + * @param data A pointer to the data structure to ssave and encode. + * @param compress Compression flags for storage. + * @return bytes written on successful write, 0 on failure. + * + * This function is the reverse of eet_data_read(), saving a data structure + * to an eet file. + * + * @see eet_data_write_cipher() + * + * @since 1.0.0 + * @ingroup Eet_Data_Cipher_Group + */ + EAPI int eet_data_write_cipher(Eet_File *ef, 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. + * @param data_in The pointer to the data to decode into a struct. + * @param cipher_key The key to use as cipher. + * @param size_in The size of the data pointed to in bytes. + * @param dumpfunc The function to call passed a string when new + * 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 take a chunk of data encoded by + * eet_data_descriptor_encode() and convert it into human readable + * ascii text. It does this by calling the @p dumpfunc callback + * for all new text that is generated. This callback should append + * 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 + * appended. + * + * Example: + * + * @code + * void output(void *data, const char *string) + * { + * printf("%s", string); + * } + * + * 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_cipher(data, cipher_key, len, output, NULL); + * } + * @endcode + * + * @see eet_data_text_dump() + * + * @since 1.0.0 + * @ingroup Eet_Data_Cipher_Group + */ + EAPI int eet_data_text_dump_cipher(const void *data_in, const char *cipher_key, int size_in, void (*dumpfunc) (void *data, const char *str), void *dumpdata); + + /** + * Take an ascii encoding from eet_data_text_dump() and re-encode + * in binary using a cipher. + * @param text The pointer to the string data to parse and encode. + * @param cipher_key The key to use as cipher. + * @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 normal + * C string. + * + * @see eet_data_text_undump() + * + * @since 1.0.0 + * @ingroup Eet_Data_Cipher_Group + */ + EAPI void *eet_data_text_undump_cipher(const char *text, const char *cipher_key, int textlen, int *size_ret); + + /** + * Dump an eet encoded data structure from an eet file into ascii + * text using a cipher. + * @param ef A valid eet file handle. + * @param name Name of the entry. eg: "/base/file_i_want". + * @param cipher_key The key to use as cipher. + * @param dumpfunc The function to call passed a string when new + * 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 take an open and valid eet file from + * eet_open() request the data encoded by + * eet_data_descriptor_encode() corresponding to the key @p name + * and convert it into human readable ascii text. It does this by + * calling the @p dumpfunc callback for all new text that is + * generated. This callback should append 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 appended. + * + * @see eet_data_dump() + * + * @since 1.0.0 + * @ingroup Eet_Data_Cipher_Group + */ + EAPI int eet_data_dump_cipher(Eet_File *ef, const char *name, const char *cipher_key, void (*dumpfunc) (void *data, const char *str), void *dumpdata); + + /** + * Take an ascii encoding from eet_data_dump() and re-encode in + * binary using a cipher. + * @param ef A valid eet file handle. + * @param name Name of the entry. eg: "/base/file_i_want". + * @param cipher_key The key to use as cipher. + * @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 compress Compression flags (1 == compress, 0 = don't compress). + * @return 1 on success, 0 on failure + * + * This function will parse the string pointed to by @p text, + * encode it the same way eet_data_descriptor_encode() takes an + * in-memory data struct and encodes into a binary blob. + * + * 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_undump() + * + * @since 1.0.0 + * @ingroup Eet_Data_Cipher_Group + */ + EAPI int eet_data_undump_cipher(Eet_File *ef, const char *name, const char *cipher_key, const char *text, int textlen, int compress); + + /** + * Decode a data structure from an arbitary location in memory + * using a cipher. + * @param edd The data descriptor to use when decoding. + * @param data_in The pointer to the data to decode into a struct. + * @param cipher_key The key to use as cipher. + * @param size_in The size of the data pointed to in bytes. + * @return NULL on failure, or a valid decoded struct pointer on success. + * + * This function will decode a data structure that has been encoded using + * eet_data_descriptor_encode(), and return a data structure with all its + * elements filled out, if successful, or NULL on failure. + * + * The data to be decoded is stored at the memory pointed to by @p data_in, + * and is described by the descriptor pointed to by @p edd. The data size is + * passed in as the value to @p size_in, ande must be greater than 0 to + * succeed. + * + * This function is useful for decoding data structures delivered to the + * application by means other than an eet file, such as an IPC or socket + * connection, raw files, shared memory etc. + * + * Please see eet_data_read() for more information. + * + * @see eet_data_descriptor_decode() + * + * @since 1.0.0 + * @ingroup Eet_Data_Cipher_Group + */ + EAPI void *eet_data_descriptor_decode_cipher(Eet_Data_Descriptor *edd, const void *data_in, const char *cipher_key, int size_in); + + /** + * Encode a dsata struct to memory and return that encoded data + * using a cipher. + * @param edd The data descriptor to use when encoding. + * @param data_in The pointer to the struct to encode into data. + * @param cipher_key The key to use as cipher. + * @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() + * + * @since 1.0.0 + * @ingroup Eet_Data_Cipher_Group + */ + EAPI void *eet_data_descriptor_encode_cipher(Eet_Data_Descriptor *edd, const void *data_in, const char *cipher_key, int *size_ret); + + + /** + * @defgroup Eet_Node_Group Low-level Serialization Structures. + * + * Functions that create, destroy and manipulate serialization nodes + * used by @ref Eet_Data_Group. + * + * @{ + */ + + /** + * @typedef Eet_Node + * Opaque handle to manage serialization node. + */ + typedef struct _Eet_Node Eet_Node; + + /** + * @typedef Eet_Node_Data + * Contains an union that can fit any kind of node. + */ + typedef struct _Eet_Node_Data Eet_Node_Data; + + /** + * @struct _Eet_Node_Data + * Contains an union that can fit any kind of node. + */ + struct _Eet_Node_Data + { + union { + char c; + short s; + int i; + long long l; + float f; + double d; + unsigned char uc; + unsigned short us; + unsigned int ui; + unsigned long long ul; + const char *str; + } value; + }; + + /** + * @} + */ + + /** + * TODO FIX ME + * @ingroup Eet_Node_Group + */ EAPI Eet_Node *eet_node_char_new(const char *name, char c); + + /** + * TODO FIX ME + * @ingroup Eet_Node_Group + */ EAPI Eet_Node *eet_node_short_new(const char *name, short s); + + /** + * TODO FIX ME + * @ingroup Eet_Node_Group + */ EAPI Eet_Node *eet_node_int_new(const char *name, int i); + + /** + * TODO FIX ME + * @ingroup Eet_Node_Group + */ EAPI Eet_Node *eet_node_long_long_new(const char *name, long long l); + + /** + * TODO FIX ME + * @ingroup Eet_Node_Group + */ EAPI Eet_Node *eet_node_float_new(const char *name, float f); + + /** + * TODO FIX ME + * @ingroup Eet_Node_Group + */ EAPI Eet_Node *eet_node_double_new(const char *name, double d); + + /** + * TODO FIX ME + * @ingroup Eet_Node_Group + */ EAPI Eet_Node *eet_node_unsigned_char_new(const char *name, unsigned char uc); + + /** + * TODO FIX ME + * @ingroup Eet_Node_Group + */ EAPI Eet_Node *eet_node_unsigned_short_new(const char *name, unsigned short us); + + /** + * TODO FIX ME + * @ingroup Eet_Node_Group + */ EAPI Eet_Node *eet_node_unsigned_int_new(const char *name, unsigned int ui); + + /** + * TODO FIX ME + * @ingroup Eet_Node_Group + */ EAPI Eet_Node *eet_node_unsigned_long_long_new(const char *name, unsigned long long l); + + /** + * TODO FIX ME + * @ingroup Eet_Node_Group + */ EAPI Eet_Node *eet_node_string_new(const char *name, const char *str); + + /** + * TODO FIX ME + * @ingroup Eet_Node_Group + */ EAPI Eet_Node *eet_node_inlined_string_new(const char *name, const char *str); + + /** + * TODO FIX ME + * @ingroup Eet_Node_Group + */ EAPI Eet_Node *eet_node_null_new(const char *name); + + /** + * TODO FIX ME + * @ingroup Eet_Node_Group + */ EAPI Eet_Node *eet_node_list_new(const char *name, Eina_List *nodes); + + /** + * TODO FIX ME + * @ingroup Eet_Node_Group + */ EAPI Eet_Node *eet_node_array_new(const char *name, int count, Eina_List *nodes); + + /** + * TODO FIX ME + * @ingroup Eet_Node_Group + */ EAPI Eet_Node *eet_node_var_array_new(const char *name, Eina_List *nodes); + + /** + * TODO FIX ME + * @ingroup Eet_Node_Group + */ EAPI Eet_Node *eet_node_hash_new(const char *name, const char *key, Eet_Node *node); + + /** + * TODO FIX ME + * @ingroup Eet_Node_Group + */ EAPI Eet_Node *eet_node_struct_new(const char *name, Eina_List *nodes); + + /** + * TODO FIX ME + * @ingroup Eet_Node_Group + */ EAPI Eet_Node *eet_node_struct_child_new(const char *parent, Eet_Node *child); + + /** + * TODO FIX ME + * @ingroup Eet_Node_Group + */ EAPI void eet_node_list_append(Eet_Node *parent, const char *name, Eet_Node *child); + + /** + * TODO FIX ME + * @ingroup Eet_Node_Group + */ EAPI void eet_node_struct_append(Eet_Node *parent, const char *name, Eet_Node *child); + + /** + * TODO FIX ME + * @ingroup Eet_Node_Group + */ EAPI void eet_node_hash_add(Eet_Node *parent, const char *name, const char *key, Eet_Node *child); + + /** + * TODO FIX ME + * @ingroup Eet_Node_Group + */ EAPI void eet_node_dump(Eet_Node *n, int dumplevel, void (*dumpfunc) (void *data, const char *str), void *dumpdata); + + /** + * TODO FIX ME + * @ingroup Eet_Node_Group + */ EAPI void eet_node_del(Eet_Node *n); - EAPI void *eet_data_node_encode_cipher(Eet_Node *node, const char *key, int *size_ret); - EAPI void *eet_data_node_decode_cipher(const void *data_in, const char *key, int size_in); + /** + * TODO FIX ME + * @ingroup Eet_Node_Group + */ + EAPI void *eet_data_node_encode_cipher(Eet_Node *node, const char *cipher_key, int *size_ret); - EAPI Eet_Node *eet_data_node_read_cipher(Eet_File *ef, const char *name, const char *key); - EAPI int eet_data_node_write_cipher(Eet_File *ef, const char *name, const char *key, Eet_Node *node, int compress); + /** + * TODO FIX ME + * @ingroup Eet_Node_Group + */ + EAPI void *eet_data_node_decode_cipher(const void *data_in, const char *cipher_key, int size_in); + + /** + * TODO FIX ME + * @ingroup Eet_Node_Group + */ + EAPI Eet_Node *eet_data_node_read_cipher(Eet_File *ef, const char *name, const char *cipher_key); + + /** + * TODO FIX ME + * @ingroup Eet_Node_Group + */ + EAPI int 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 KNOW WHAT YOU ARE DOING. */ + + /** + * @typedef Eet_Node_Walk + * Describes how to walk trees of #Eet_Node. + */ + typedef struct _Eet_Node_Walk Eet_Node_Walk; + + /** + * @struct _Eet_Node_Walk + * Describes how to walk trees of #Eet_Node. + */ + struct _Eet_Node_Walk + { + void *(*struct_alloc)(const char *type, void *user_data); + void (*struct_add)(void *parent, const char *name, void *child, void *user_data); + void *(*array)(Eina_Bool variable, const char *name, int count, void *user_data); + void (*insert)(void *array, int index, void *child, void *user_data); + void *(*list)(const char *name, void *user_data); + void (*append)(void *list, void *child, void *user_data); + void *(*hash)(void *parent, const char *name, const char *key, void *value, void *user_data); + void *(*simple)(int type, Eet_Node_Data *data, void *user_data); + }; - /* EXPERIMENTAL: THIS API MAY CHANGE IN THE FUTUR, USE IT ONLY IF YOU KNOW WHAT YOU ARE DOING. */ EAPI void *eet_node_walk(void *parent, const char *name, Eet_Node *root, Eet_Node_Walk *cb, void *user_data); /***************************************************************************/ diff --git a/legacy/eet/src/lib/eet_data.c b/legacy/eet/src/lib/eet_data.c index 284c57fb07..f3095400e3 100644 --- a/legacy/eet/src/lib/eet_data.c +++ b/legacy/eet/src/lib/eet_data.c @@ -1434,7 +1434,7 @@ eet_data_descriptor_element_add(Eet_Data_Descriptor *edd, } EAPI void * -eet_data_read_cipher(Eet_File *ef, Eet_Data_Descriptor *edd, const char *name, const char *key) +eet_data_read_cipher(Eet_File *ef, Eet_Data_Descriptor *edd, const char *name, const char *cipher_key) { const Eet_Dictionary *ed = NULL; const void *data = NULL; @@ -1445,12 +1445,12 @@ eet_data_read_cipher(Eet_File *ef, Eet_Data_Descriptor *edd, const char *name, c ed = eet_dictionary_get(ef); - if (!key) + if (!cipher_key) data = eet_read_direct(ef, name, &size); if (!data) { required_free = 1; - data = eet_read_cipher(ef, name, &size, key); + data = eet_read_cipher(ef, name, &size, cipher_key); if (!data) return NULL; } @@ -1463,7 +1463,7 @@ eet_data_read_cipher(Eet_File *ef, Eet_Data_Descriptor *edd, const char *name, c } EAPI Eet_Node * -eet_data_node_read_cipher(Eet_File *ef, const char *name, const char *key) +eet_data_node_read_cipher(Eet_File *ef, const char *name, const char *cipher_key) { const Eet_Dictionary *ed = NULL; const void *data = NULL; @@ -1474,12 +1474,12 @@ eet_data_node_read_cipher(Eet_File *ef, const char *name, const char *key) ed = eet_dictionary_get(ef); - if (!key) + if (!cipher_key) data = eet_read_direct(ef, name, &size); if (!data) { required_free = 1; - data = eet_read_cipher(ef, name, &size, key); + data = eet_read_cipher(ef, name, &size, cipher_key); if (!data) return NULL; } @@ -1498,7 +1498,7 @@ eet_data_read(Eet_File *ef, Eet_Data_Descriptor *edd, const char *name) } EAPI int -eet_data_write_cipher(Eet_File *ef, Eet_Data_Descriptor *edd, const char *name, const char *key, const void *data, int compress) +eet_data_write_cipher(Eet_File *ef, Eet_Data_Descriptor *edd, const char *name, const char *cipher_key, const void *data, int compress) { Eet_Dictionary *ed; void *data_enc; @@ -1509,7 +1509,7 @@ eet_data_write_cipher(Eet_File *ef, Eet_Data_Descriptor *edd, const char *name, data_enc = _eet_data_descriptor_encode(ed, edd, data, &size); if (!data_enc) return 0; - val = eet_write_cipher(ef, name, data_enc, size, compress, key); + val = eet_write_cipher(ef, name, data_enc, size, compress, cipher_key); free(data_enc); return val; } @@ -1724,7 +1724,7 @@ _eet_freelist_all_unref(Eet_Free_Context *freelist_context) } static int -eet_data_descriptor_encode_hash_cb(void *hash __UNUSED__, const char *key, void *hdata, void *fdata) +eet_data_descriptor_encode_hash_cb(void *hash __UNUSED__, const char *cipher_key, void *hdata, void *fdata) { Eet_Dictionary *ed; Eet_Data_Encode_Hash_Info *edehi; @@ -1742,7 +1742,7 @@ eet_data_descriptor_encode_hash_cb(void *hash __UNUSED__, const char *key, void /* Store key */ data = eet_data_put_type(ed, EET_T_STRING, - &key, + &cipher_key, &size); if (data) { @@ -3038,7 +3038,7 @@ eet_data_put_hash(Eet_Dictionary *ed, Eet_Data_Descriptor *edd, Eet_Data_Element EAPI int eet_data_dump_cipher(Eet_File *ef, - const char *name, const char *key, + const char *name, const char *cipher_key, void (*dumpfunc) (void *data, const char *str), void *dumpdata) { @@ -3051,12 +3051,12 @@ eet_data_dump_cipher(Eet_File *ef, ed = eet_dictionary_get(ef); - if (!key) + if (!cipher_key) data = eet_read_direct(ef, name, &size); if (!data) { required_free = 1; - data = eet_read_cipher(ef, name, &size, key); + data = eet_read_cipher(ef, name, &size, cipher_key); if (!data) return 0; } @@ -3085,7 +3085,7 @@ eet_data_dump(Eet_File *ef, EAPI int eet_data_text_dump_cipher(const void *data_in, - const char *key, int size_in, + const char *cipher_key, int size_in, void (*dumpfunc) (void *data, const char *str), void *dumpdata) { @@ -3096,9 +3096,10 @@ eet_data_text_dump_cipher(const void *data_in, if (!data_in) return 0; - if (key) + if (cipher_key) { - if (eet_decipher(data_in, size_in, key, strlen(key), &ret, &ret_len)) + if (eet_decipher(data_in, size_in, cipher_key, + strlen(cipher_key), &ret, &ret_len)) { if (ret) free(ret); return 0; @@ -3116,7 +3117,7 @@ eet_data_text_dump_cipher(const void *data_in, eet_node_dump(result, 0, dumpfunc, dumpdata); eet_node_del(result); - if (key) free(ret); + if (cipher_key) free(ret); return result ? 1 : 0; } @@ -3132,19 +3133,20 @@ eet_data_text_dump(const void *data_in, EAPI void * eet_data_text_undump_cipher(const char *text, - const char *key, + const char *cipher_key, int textlen, int *size_ret) { void *ret = NULL; ret = _eet_data_dump_parse(NULL, size_ret, text, textlen); - if (ret && key) + if (ret && cipher_key) { void *ciphered = NULL; unsigned int ciphered_len; - if (eet_cipher(ret, *size_ret, key, strlen(key), &ciphered, &ciphered_len)) + if (eet_cipher(ret, *size_ret, cipher_key, + strlen(cipher_key), &ciphered, &ciphered_len)) { if (ciphered) free(ciphered); size_ret = 0; @@ -3169,7 +3171,7 @@ eet_data_text_undump(const char *text, EAPI int eet_data_undump_cipher(Eet_File *ef, const char *name, - const char *key, + const char *cipher_key, const char *text, int textlen, int compress) @@ -3183,7 +3185,7 @@ eet_data_undump_cipher(Eet_File *ef, data_enc = _eet_data_dump_parse(ed, &size, text, textlen); if (!data_enc) return 0; - val = eet_write_cipher(ef, name, data_enc, size, compress, key); + val = eet_write_cipher(ef, name, data_enc, size, compress, cipher_key); free(data_enc); return val; } @@ -3201,7 +3203,7 @@ eet_data_undump(Eet_File *ef, EAPI void * eet_data_descriptor_decode_cipher(Eet_Data_Descriptor *edd, const void *data_in, - const char *key, + const char *cipher_key, int size_in) { void *deciphered = (void*) data_in; @@ -3209,9 +3211,10 @@ eet_data_descriptor_decode_cipher(Eet_Data_Descriptor *edd, Eet_Free_Context context; unsigned int deciphered_len = size_in; - if (key && data_in) + if (cipher_key && data_in) { - if (eet_decipher(data_in, size_in, key, strlen(key), &deciphered, &deciphered_len)) + if (eet_decipher(data_in, size_in, cipher_key, + strlen(cipher_key), &deciphered, &deciphered_len)) { if (deciphered) free(deciphered); return NULL; @@ -3235,16 +3238,17 @@ eet_data_descriptor_decode(Eet_Data_Descriptor *edd, } EAPI void * -eet_data_node_decode_cipher(const void *data_in, const char *key, int size_in) +eet_data_node_decode_cipher(const void *data_in, const char *cipher_key, int size_in) { void *deciphered = (void*) data_in; Eet_Node *ret; Eet_Free_Context context; unsigned int deciphered_len = size_in; - if (key && data_in) + if (cipher_key && data_in) { - if (eet_decipher(data_in, size_in, key, strlen(key), &deciphered, &deciphered_len)) + if (eet_decipher(data_in, size_in, cipher_key, + strlen(cipher_key), &deciphered, &deciphered_len)) { if (deciphered) free(deciphered); return NULL; @@ -3310,7 +3314,7 @@ _eet_data_descriptor_encode(Eet_Dictionary *ed, } EAPI int -eet_data_node_write_cipher(Eet_File *ef, const char *name, const char *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) { Eet_Dictionary *ed; void *data_enc; @@ -3321,14 +3325,14 @@ eet_data_node_write_cipher(Eet_File *ef, const char *name, const char *key, Eet_ data_enc = _eet_data_dump_encode(EET_G_UNKNOWN, ed, node, &size); if (!data_enc) return 0; - val = eet_write_cipher(ef, name, data_enc, size, compress, key); + val = eet_write_cipher(ef, name, data_enc, size, compress, cipher_key); free(data_enc); return val; } EAPI void * eet_data_node_encode_cipher(Eet_Node *node, - const char *key, + const char *cipher_key, int *size_ret) { void *ret = NULL; @@ -3337,9 +3341,10 @@ eet_data_node_encode_cipher(Eet_Node *node, int size; ret = _eet_data_dump_encode(EET_G_UNKNOWN, NULL, node, &size); - if (key && ret) + if (cipher_key && ret) { - if (eet_cipher(ret, size, key, strlen(key), &ciphered, &ciphered_len)) + if (eet_cipher(ret, size, cipher_key, + strlen(cipher_key), &ciphered, &ciphered_len)) { if (ciphered) free(ciphered); if (size_ret) *size_ret = 0; @@ -3358,7 +3363,7 @@ eet_data_node_encode_cipher(Eet_Node *node, EAPI void * eet_data_descriptor_encode_cipher(Eet_Data_Descriptor *edd, const void *data_in, - const char *key, + const char *cipher_key, int *size_ret) { void *ret = NULL; @@ -3367,9 +3372,10 @@ eet_data_descriptor_encode_cipher(Eet_Data_Descriptor *edd, int size; ret = _eet_data_descriptor_encode(NULL, edd, data_in, &size); - if (key && ret) + if (cipher_key && ret) { - if (eet_cipher(ret, size, key, strlen(key), &ciphered, &ciphered_len)) + if (eet_cipher(ret, size, cipher_key, + strlen(cipher_key), &ciphered, &ciphered_len)) { if (ciphered) free(ciphered); if (size_ret) *size_ret = 0; diff --git a/legacy/eet/src/lib/eet_image.c b/legacy/eet/src/lib/eet_image.c index 48618d0fcf..5adbb12146 100644 --- a/legacy/eet/src/lib/eet_image.c +++ b/legacy/eet/src/lib/eet_image.c @@ -909,7 +909,7 @@ eet_data_image_jpeg_alpha_convert(int *size, const void *data, unsigned int w, u } EAPI int -eet_data_image_write_cipher(Eet_File *ef, const char *name, const char *key, +eet_data_image_write_cipher(Eet_File *ef, const char *name, const char *cipher_key, const void *data, unsigned int w, unsigned int h, int alpha, int comp, int quality, int lossy) { @@ -921,7 +921,7 @@ eet_data_image_write_cipher(Eet_File *ef, const char *name, const char *key, { int v; - v = eet_write_cipher(ef, name, d, size, 0, key); + v = eet_write_cipher(ef, name, d, size, 0, cipher_key); free(d); return v; } @@ -938,7 +938,7 @@ eet_data_image_write(Eet_File *ef, const char *name, EAPI void * -eet_data_image_read_cipher(Eet_File *ef, const char *name, const char *key, +eet_data_image_read_cipher(Eet_File *ef, const char *name, const char *cipher_key, unsigned int *w, unsigned int *h, int *alpha, int *comp, int *quality, int *lossy) { @@ -947,11 +947,11 @@ eet_data_image_read_cipher(Eet_File *ef, const char *name, const char *key, int free_data = 0; int size; - if (!key) + if (!cipher_key) data = (void *)eet_read_direct(ef, name, &size); if (!data) { - data = eet_read_cipher(ef, name, &size, key); + data = eet_read_cipher(ef, name, &size, cipher_key); free_data = 1; if (!data) return NULL; } @@ -973,7 +973,7 @@ eet_data_image_read(Eet_File *ef, const char *name, } EAPI int -eet_data_image_read_to_surface_cipher(Eet_File *ef, const char *name, const char *key, unsigned int src_x, unsigned int src_y, +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 *comp, int *quality, int *lossy) { @@ -982,11 +982,11 @@ eet_data_image_read_to_surface_cipher(Eet_File *ef, const char *name, const char int res = 1; int size; - if (!key) + if (!cipher_key) data = (void *)eet_read_direct(ef, name, &size); if (!data) { - data = eet_read_cipher(ef, name, &size, key); + data = eet_read_cipher(ef, name, &size, cipher_key); free_data = 1; if (!data) return 0; } @@ -1008,7 +1008,7 @@ eet_data_image_read_to_surface(Eet_File *ef, const char *name, unsigned int src_ } EAPI int -eet_data_image_header_read_cipher(Eet_File *ef, const char *name, const char *key, +eet_data_image_header_read_cipher(Eet_File *ef, const char *name, const char *cipher_key, unsigned int *w, unsigned int *h, int *alpha, int *comp, int *quality, int *lossy) { @@ -1017,11 +1017,11 @@ eet_data_image_header_read_cipher(Eet_File *ef, const char *name, const char *ke int free_data = 0; int d; - if (!key) + if (!cipher_key) data = (void *)eet_read_direct(ef, name, &size); if (!data) { - data = eet_read_cipher(ef, name, &size, key); + data = eet_read_cipher(ef, name, &size, cipher_key); free_data = 1; if (!data) return 0; } @@ -1043,7 +1043,7 @@ eet_data_image_header_read(Eet_File *ef, const char *name, EAPI void * -eet_data_image_encode_cipher(const void *data, const char *key, unsigned int w, unsigned int h, int alpha, int comp, int quality, int lossy, int *size_ret) +eet_data_image_encode_cipher(const void *data, const char *cipher_key, unsigned int w, unsigned int h, int alpha, int comp, int quality, int lossy, int *size_ret) { void *d = NULL; void *ciphered_d = NULL; @@ -1067,9 +1067,9 @@ eet_data_image_encode_cipher(const void *data, const char *key, unsigned int w, else d = eet_data_image_jpeg_alpha_convert(&size, data, w, h, alpha, quality); } - if (key) + if (cipher_key) { - if(!eet_cipher(d, size, key, strlen(key), &ciphered_d, &ciphered_sz)) + if(!eet_cipher(d, size, cipher_key, strlen(cipher_key), &ciphered_d, &ciphered_sz)) { if (d) free(d); d = ciphered_d; @@ -1090,15 +1090,15 @@ eet_data_image_encode(const void *data, int *size_ret, unsigned int w, unsigned } EAPI int -eet_data_image_header_decode_cipher(const void *data, const char *key, int size, unsigned int *w, unsigned int *h, int *alpha, int *comp, int *quality, int *lossy) +eet_data_image_header_decode_cipher(const void *data, const char *cipher_key, int size, unsigned int *w, unsigned int *h, int *alpha, int *comp, int *quality, int *lossy) { int header[8]; void *deciphered_d = NULL; unsigned int deciphered_sz = 0; - if (key) + if (cipher_key) { - if (!eet_decipher(data, size, key, strlen(key), &deciphered_d, &deciphered_sz)) + if (!eet_decipher(data, size, cipher_key, strlen(cipher_key), &deciphered_d, &deciphered_sz)) { data = deciphered_d; size = deciphered_sz; @@ -1306,7 +1306,7 @@ _eet_data_image_decode_inside(const void *data, int size, unsigned int src_x, un } EAPI void * -eet_data_image_decode_cipher(const void *data, const char *key, int size, unsigned int *w, unsigned int *h, int *alpha, int *comp, int *quality, int *lossy) +eet_data_image_decode_cipher(const void *data, const char *cipher_key, int size, unsigned int *w, unsigned int *h, int *alpha, int *comp, int *quality, int *lossy) { unsigned int *d = NULL; unsigned int iw, ih; @@ -1314,9 +1314,9 @@ eet_data_image_decode_cipher(const void *data, const char *key, int size, unsign void *deciphered_d = NULL; unsigned int deciphered_sz = 0; - if (key) + if (cipher_key) { - if (!eet_decipher(data, size, key, strlen(key), &deciphered_d, &deciphered_sz)) + if (!eet_decipher(data, size, cipher_key, strlen(cipher_key), &deciphered_d, &deciphered_sz)) { data = deciphered_d; size = deciphered_sz; @@ -1355,7 +1355,7 @@ eet_data_image_decode(const void *data, int size, unsigned int *w, unsigned int } EAPI int -eet_data_image_decode_to_surface_cipher(const void *data, const char *key, int size, unsigned int src_x, unsigned int src_y, +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 *comp, int *quality, int *lossy) { @@ -1364,9 +1364,9 @@ eet_data_image_decode_to_surface_cipher(const void *data, const char *key, int s void *deciphered_d = NULL; unsigned int deciphered_sz = 0; - if (key) + if (cipher_key) { - if (!eet_decipher(data, size, key, strlen(key), &deciphered_d, &deciphered_sz)) + if (!eet_decipher(data, size, cipher_key, strlen(cipher_key), &deciphered_d, &deciphered_sz)) { data = deciphered_d; size = deciphered_sz;