summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGustavo Sverzut Barbieri <barbieri@gmail.com>2010-03-18 20:16:56 +0000
committerGustavo Sverzut Barbieri <barbieri@gmail.com>2010-03-18 20:16:56 +0000
commitea4e8a0abbadc47ac9ba2dd2d97f8fe83f991759 (patch)
tree46f2009f0be77a87cc9797761a5b85b784009004
parentdb38ac7b300535430c736ee8ed33c89562a4e5f6 (diff)
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
-rw-r--r--legacy/eet/AUTHORS4
-rw-r--r--legacy/eet/doc/Doxyfile6
-rw-r--r--legacy/eet/doc/eet.dox.in15
-rw-r--r--legacy/eet/doc/head.html2
-rw-r--r--legacy/eet/src/lib/Eet.h1659
-rw-r--r--legacy/eet/src/lib/eet_data.c78
-rw-r--r--legacy/eet/src/lib/eet_image.c46
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) <raster@rasterman.com>
2David Goodlad <dgoodlad@gmail.com> 2David Goodlad <dgoodlad@gmail.com>
3Cedric Bail <cedric.bail@free.fr> 3Cedric Bail <cedric.bail@free.fr>
4Arnaud de Turckheim <quarium@gmail.com> 4Arnaud de Turckheim <quarium@gmail.com>
5Luis Felipe Strano Moraes <luis.strano@gmail.com> 5Luis Felipe Strano Moraes <lfelipe@profusion.mobi>
6Chidambar Zinnoury <illogict@online.fr> 6Chidambar Zinnoury <illogict@online.fr>
7Vincent Torri <vtorri@univ-evry.fr> 7Vincent Torri <vtorri@univ-evry.fr>
8Gustavo Sverzut Barbieri <barbieri@gmail.com> 8Gustavo Sverzut Barbieri <barbieri@profusion.mobi>
9Raphael Kubo da Costa <kubo@profusion.mobi> 9Raphael Kubo da Costa <kubo@profusion.mobi>
10Mathieu Taillefumier <mathieu.taillefumier@free.fr> 10Mathieu Taillefumier <mathieu.taillefumier@free.fr>
11Albin "Lutin" Tonnerre <albin.tonnerre@gmail.com> 11Albin "Lutin" Tonnerre <albin.tonnerre@gmail.com>
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
33FULL_PATH_NAMES = NO 33FULL_PATH_NAMES = NO
34STRIP_FROM_PATH = 34STRIP_FROM_PATH =
35INTERNAL_DOCS = NO 35INTERNAL_DOCS = NO
36STRIP_CODE_COMMENTS = YES 36STRIP_CODE_COMMENTS = NO
37CASE_SENSE_NAMES = YES 37CASE_SENSE_NAMES = YES
38SHORT_NAMES = NO 38SHORT_NAMES = NO
39HIDE_SCOPE_NAMES = NO 39HIDE_SCOPE_NAMES = NO
@@ -46,7 +46,7 @@ INHERIT_DOCS = YES
46INLINE_INFO = YES 46INLINE_INFO = YES
47SORT_MEMBER_DOCS = YES 47SORT_MEMBER_DOCS = YES
48DISTRIBUTE_GROUP_DOC = NO 48DISTRIBUTE_GROUP_DOC = NO
49TAB_SIZE = 2 49TAB_SIZE = 8
50GENERATE_TODOLIST = YES 50GENERATE_TODOLIST = YES
51GENERATE_TESTLIST = YES 51GENERATE_TESTLIST = YES
52GENERATE_BUGLIST = YES 52GENERATE_BUGLIST = YES
@@ -78,7 +78,7 @@ REFERENCED_BY_RELATION = YES
78REFERENCES_RELATION = YES 78REFERENCES_RELATION = YES
79ALPHABETICAL_INDEX = YES 79ALPHABETICAL_INDEX = YES
80COLS_IN_ALPHA_INDEX = 2 80COLS_IN_ALPHA_INDEX = 2
81IGNORE_PREFIX = 81IGNORE_PREFIX = eet_ _eet_ Eet_ _Eet_ EET_ _EET_
82GENERATE_TREEVIEW = NO 82GENERATE_TREEVIEW = NO
83TREEVIEW_WIDTH = 250 83TREEVIEW_WIDTH = 250
84GENERATE_LATEX = YES 84GENERATE_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
12@image html e_big.png 12@image html e_big.png
13 13
14@version @PACKAGE_VERSION@ 14@version @PACKAGE_VERSION@
15@author Carsten Haitzler <raster\@rasterman.com> 15@author Carsten Haitzler <raster@@rasterman.com>
16@date 2000-2008 16@author David Goodlad <dgoodlad@@gmail.com>
17@author Cedric Bail <cedric.bail@@free.fr>
18@author Arnaud de Turckheim <quarium@@gmail.com>
19@author Luis Felipe Strano Moraes <lfelipe@@profusion.mobi>
20@author Chidambar Zinnoury <illogict@@online.fr>
21@author Vincent Torri <vtorri@@univ-evry.fr>
22@author Gustavo Sverzut Barbieri <barbieri@@profusion.mobi>
23@author Raphael Kubo da Costa <kubo@@profusion.mobi>
24@author Mathieu Taillefumier <mathieu.taillefumier@@free.fr>
25@author Albin "Lutin" Tonnerre <albin.tonnerre@@gmail.com>
26@author Adam Simpkins <adam@@adamsimpkins.net>
27@date 2000-2010
17 28
18 29
19 30
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 @@
48 <ul class="current"> 48 <ul class="current">
49 <li><a href="todo.html">Todo</a></li> 49 <li><a href="todo.html">Todo</a></li>
50 <li><a href="files.html">Files</a></li> 50 <li><a href="files.html">Files</a></li>
51 <li><a href="Eet_8h.html">Header</a></li> 51 <li><a href="modules.html">Modules</a></li>
52 <li><a href="globals.html">Globals</a></li> 52 <li><a href="globals.html">Globals</a></li>
53 <li><a href="pages.html">Related Pages</a></li> 53 <li><a href="pages.html">Related Pages</a></li>
54 <li class="current"><a href="index.html">Main Page</a></li> 54 <li class="current"><a href="index.html">Main Page</a></li>
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 @@
35extern "C" { 35extern "C" {
36#endif 36#endif
37 37
38/** 38 /**
39 * @file Eet.h 39 * @file Eet.h
40 * @brief The file that provides the eet functions. 40 * @brief The file that provides the eet functions.
41 * 41 *
42 * This header provides the Eet management functions. 42 * This header provides the Eet management functions.
43 * 43 *
44 */ 44 */
45
46/***************************************************************************/
47
48#define EET_T_UNKNOW 0 /**< Unknown data encoding type */
49#define EET_T_CHAR 1 /**< Data type: char */
50#define EET_T_SHORT 2 /**< Data type: short */
51#define EET_T_INT 3 /**< Data type: int */
52#define EET_T_LONG_LONG 4 /**< Data type: long long */
53#define EET_T_FLOAT 5 /**< Data type: float */
54#define EET_T_DOUBLE 6 /**< Data type: double */
55#define EET_T_UCHAR 7 /**< Data type: unsigned char */
56#define EET_T_USHORT 8 /**< Data type: unsigned short */
57#define EET_T_UINT 9 /**< Data type: unsigned int */
58#define EET_T_ULONG_LONG 10 /**< Data type: unsigned long long */
59#define EET_T_STRING 11 /**< Data type: char * */
60#define EET_T_INLINED_STRING 12 /**< Data type: char * (but compressed inside the resulting eet) */
61#define EET_T_NULL 13 /**< Data type: (void *) (only use it if you know why) */
62#define EET_T_F32P32 14 /**< Data type: */
63#define EET_T_F16P16 15 /**< Data type: */
64#define EET_T_F8P24 16 /**< Data type: */
65#define EET_T_LAST 17 /**< Last data type */
66
67#define EET_G_UNKNOWN 100 /**< Unknown group data encoding type */
68#define EET_G_ARRAY 101 /**< Fixed size array group type */
69#define EET_G_VAR_ARRAY 102 /**< Variable size array group type */
70#define EET_G_LIST 103 /**< Linked list group type */
71#define EET_G_HASH 104 /**< Hash table group type */
72#define EET_G_LAST 105 /**< Last group type */
73
74#define EET_I_LIMIT 128 /**< Other type exist but are reserved for internal purpose. */
75
76/***************************************************************************/
77 45
78 typedef enum _Eet_File_Mode 46 /**
79 { 47 * @defgroup Eet_Group Top level functions
80 EET_FILE_MODE_INVALID = -1, 48 * Functions that affect Eet as a whole.
81 EET_FILE_MODE_READ, 49 *
82 EET_FILE_MODE_WRITE, 50 * @{
83 EET_FILE_MODE_READ_WRITE 51 */
84 } Eet_File_Mode;
85 52
53 /**
54 * @enum _Eet_Error
55 * All the error identifiers known by Eet.
56 */
86 typedef enum _Eet_Error 57 typedef enum _Eet_Error
87 { 58 {
88 EET_ERROR_NONE, 59 EET_ERROR_NONE, /**< No error, it's all fine! */
89 EET_ERROR_BAD_OBJECT, 60 EET_ERROR_BAD_OBJECT, /**< Given object or handle is NULL or invalid */
90 EET_ERROR_EMPTY, 61 EET_ERROR_EMPTY, /**< There was nothing to do */
91 EET_ERROR_NOT_WRITABLE, 62 EET_ERROR_NOT_WRITABLE, /**< Could not write to file or fine is #EET_FILE_MODE_READ */
92 EET_ERROR_OUT_OF_MEMORY, 63 EET_ERROR_OUT_OF_MEMORY, /**< Could not allocate memory */
93 EET_ERROR_WRITE_ERROR, 64 EET_ERROR_WRITE_ERROR, /**< Failed to write data to destination */
94 EET_ERROR_WRITE_ERROR_FILE_TOO_BIG, 65 EET_ERROR_WRITE_ERROR_FILE_TOO_BIG, /**< Failed to write file since it is too big */
95 EET_ERROR_WRITE_ERROR_IO_ERROR, 66 EET_ERROR_WRITE_ERROR_IO_ERROR, /**< Failed to write since generic Input/Output error */
96 EET_ERROR_WRITE_ERROR_OUT_OF_SPACE, 67 EET_ERROR_WRITE_ERROR_OUT_OF_SPACE, /**< Failed to write due out of space */
97 EET_ERROR_WRITE_ERROR_FILE_CLOSED, 68 EET_ERROR_WRITE_ERROR_FILE_CLOSED, /**< Failed to write because file was closed */
98 EET_ERROR_MMAP_FAILED, 69 EET_ERROR_MMAP_FAILED, /**< Could not mmap file */
99 EET_ERROR_X509_ENCODING_FAILED, 70 EET_ERROR_X509_ENCODING_FAILED, /**< Could not encode using X509 */
100 EET_ERROR_SIGNATURE_FAILED, 71 EET_ERROR_SIGNATURE_FAILED, /**< Could not validate signature */
101 EET_ERROR_INVALID_SIGNATURE, 72 EET_ERROR_INVALID_SIGNATURE, /**< Signature is invalid */
102 EET_ERROR_NOT_SIGNED, 73 EET_ERROR_NOT_SIGNED, /**< File or contents are not signed */
103 EET_ERROR_NOT_IMPLEMENTED, 74 EET_ERROR_NOT_IMPLEMENTED, /**< Function is not implemented */
104 EET_ERROR_PRNG_NOT_SEEDED, 75 EET_ERROR_PRNG_NOT_SEEDED, /**< Could not introduce random seed */
105 EET_ERROR_ENCRYPT_FAILED, 76 EET_ERROR_ENCRYPT_FAILED, /**< Could not encrypt contents */
106 EET_ERROR_DECRYPT_FAILED 77 EET_ERROR_DECRYPT_FAILED /**< Could not decrypt contents */
107 } Eet_Error; 78 } Eet_Error; /**< Eet error identifiers */
108
109 typedef struct _Eet_File Eet_File;
110 typedef struct _Eet_Dictionary Eet_Dictionary;
111 typedef struct _Eet_Data_Descriptor Eet_Data_Descriptor;
112 typedef struct _Eet_Key Eet_Key;
113 typedef struct _Eet_Node Eet_Node;
114 typedef struct _Eet_Node_Data Eet_Node_Data;
115 typedef struct _Eet_Node_Walk Eet_Node_Walk;
116
117 typedef struct _Eet_Data_Descriptor_Class Eet_Data_Descriptor_Class;
118
119 struct _Eet_Node_Data
120 {
121 union {
122 char c;
123 short s;
124 int i;
125 long long l;
126 float f;
127 double d;
128 unsigned char uc;
129 unsigned short us;
130 unsigned int ui;
131 unsigned long long ul;
132 const char *str;
133 } value;
134 };
135
136 struct _Eet_Node_Walk
137 {
138 void *(*struct_alloc)(const char *type, void *user_data);
139 void (*struct_add)(void *parent, const char *name, void *child, void *user_data);
140 void *(*array)(Eina_Bool variable, const char *name, int count, void *user_data);
141 void (*insert)(void *array, int index, void *child, void *user_data);
142 void *(*list)(const char *name, void *user_data);
143 void (*append)(void *list, void *child, void *user_data);
144 void *(*hash)(void *parent, const char *name, const char *key, void *value, void *user_data);
145 void *(*simple)(int type, Eet_Node_Data *data, void *user_data);
146 };
147
148#define EET_DATA_DESCRIPTOR_CLASS_VERSION 2
149 struct _Eet_Data_Descriptor_Class
150 {
151 int version;
152 const char *name;
153 int size;
154 struct {
155 void *(*mem_alloc) (size_t size);
156 void (*mem_free) (void *mem);
157 char *(*str_alloc) (const char *str);
158 void (*str_free) (const char *str);
159 void *(*list_next) (void *l);
160 void *(*list_append) (void *l, void *d);
161 void *(*list_data) (void *l);
162 void *(*list_free) (void *l);
163 void (*hash_foreach) (void *h, int (*func) (void *h, const char *k, void *dt, void *fdt), void *fdt);
164 void *(*hash_add) (void *h, const char *k, void *d);
165 void (*hash_free) (void *h);
166 char *(*str_direct_alloc) (const char *str);
167 void (*str_direct_free) (const char *str);
168 } func;
169 };
170 79
171/***************************************************************************/ 80 /**
81 * @}
82 */
172 83
173 /** 84 /**
174 * Initialize the EET library. 85 * Initialize the EET library.
@@ -176,6 +87,7 @@ extern "C" {
176 * @return The new init count. 87 * @return The new init count.
177 * 88 *
178 * @since 1.0.0 89 * @since 1.0.0
90 * @ingroup Eet_Group
179 */ 91 */
180 EAPI int eet_init(void); 92 EAPI int eet_init(void);
181 93
@@ -185,6 +97,7 @@ extern "C" {
185 * @return The new init count. 97 * @return The new init count.
186 * 98 *
187 * @since 1.0.0 99 * @since 1.0.0
100 * @ingroup Eet_Group
188 */ 101 */
189 EAPI int eet_shutdown(void); 102 EAPI int eet_shutdown(void);
190 103
@@ -197,15 +110,60 @@ extern "C" {
197 * on disk. 110 * on disk.
198 * 111 *
199 * @since 1.0.0 112 * @since 1.0.0
113 * @ingroup Eet_Group
200 */ 114 */
201 EAPI void eet_clearcache(void); 115 EAPI void eet_clearcache(void);
202 116
117
118 /**
119 * @defgroup Eet_File_Group Eet File Main Functions
120 *
121 * Functions to create, destroy and do basic manipulation of
122 * #Eet_File handles.
123 *
124 * @{
125 */
126
127 /**
128 * @enum _Eet_File_Mode
129 * Modes that a file can be opened.
130 */
131 typedef enum _Eet_File_Mode
132 {
133 EET_FILE_MODE_INVALID = -1,
134 EET_FILE_MODE_READ, /**< File is read-only. */
135 EET_FILE_MODE_WRITE, /**< File is write-only. */
136 EET_FILE_MODE_READ_WRITE /**< File is for both read and write */
137 } Eet_File_Mode; /**< Modes that a file can be opened. */
138
139 /**
140 * @typedef Eet_File
141 * Opaque handle that defines an Eet file (or memory).
142 *
143 * @see eet_open()
144 * @see eet_memopen_read()
145 * @see eet_close()
146 */
147 typedef struct _Eet_File Eet_File;
148
149 /**
150 * @typedef Eet_Dictionary
151 * Opaque handle that defines a file-backed (mmaped) dictionary of strings.
152 */
153 typedef struct _Eet_Dictionary Eet_Dictionary;
154
155
156 /**
157 * @}
158 */
159
203 /** 160 /**
204 * Open an eet file on disk, and returns a handle to it. 161 * Open an eet file on disk, and returns a handle to it.
205 * @param file The file path to the eet file. eg: "/tmp/file.eet". 162 * @param file The file path to the eet file. eg: @c "/tmp/file.eet".
206 * @param mode The mode for opening. Either EET_FILE_MODE_READ, 163 * @param mode The mode for opening. Either #EET_FILE_MODE_READ,
207 * EET_FILE_MODE_WRITE or EET_FILE_MODE_READ_WRITE. 164 * #EET_FILE_MODE_WRITE or #EET_FILE_MODE_READ_WRITE.
208 * @return An opened eet file handle. 165 * @return An opened eet file handle.
166 * @ingroup Eet_File_Group
209 * 167 *
210 * This function will open an exiting eet file for reading, and build 168 * This function will open an exiting eet file for reading, and build
211 * the directory table in memory and return a handle to the file, if it 169 * the directory table in memory and return a handle to the file, if it
@@ -278,6 +236,7 @@ extern "C" {
278 * you do use eet_memopen_read. 236 * you do use eet_memopen_read.
279 * 237 *
280 * @since 1.1.0 238 * @since 1.1.0
239 * @ingroup Eet_File_Group
281 */ 240 */
282 EAPI Eet_File *eet_memopen_read(const void *data, size_t size); 241 EAPI Eet_File *eet_memopen_read(const void *data, size_t size);
283 242
@@ -287,6 +246,7 @@ extern "C" {
287 * @return The mode ef was opened with. 246 * @return The mode ef was opened with.
288 * 247 *
289 * @since 1.0.0 248 * @since 1.0.0
249 * @ingroup Eet_File_Group
290 */ 250 */
291 EAPI Eet_File_Mode eet_mode_get(Eet_File *ef); 251 EAPI Eet_File_Mode eet_mode_get(Eet_File *ef);
292 252
@@ -301,78 +261,10 @@ extern "C" {
301 * If the eet file handle is not valid nothing will be done. 261 * If the eet file handle is not valid nothing will be done.
302 * 262 *
303 * @since 1.0.0 263 * @since 1.0.0
264 * @ingroup Eet_File_Group
304 */ 265 */
305 EAPI Eet_Error eet_close(Eet_File *ef); 266 EAPI Eet_Error eet_close(Eet_File *ef);
306 267
307 /**
308 * Callback used to request if needed the password of a private key.
309 *
310 * @since 1.2.0
311 */
312 typedef int (*Eet_Key_Password_Callback)(char *buffer, int size, int rwflag, void *data);
313
314 /**
315 * Create an Eet_Key needed for signing an eet file.
316 *
317 * The certificate should provide the public that match the private key.
318 * No verification is done to ensure that.
319 *
320 * @since 1.2.0
321 */
322 EAPI Eet_Key* eet_identity_open(const char *certificate_file, const char *private_key_file, Eet_Key_Password_Callback cb);
323
324 /**
325 * Close and release all ressource used by an Eet_Key.
326 * An reference counter prevent it from being freed until all file using it are
327 * also closed.
328 *
329 * @since 1.2.0
330 */
331 EAPI void eet_identity_close(Eet_Key *key);
332
333 /**
334 * Set a key to sign a file
335 *
336 * @since 1.2.0
337 */
338 EAPI Eet_Error eet_identity_set(Eet_File *ef, Eet_Key *key);
339
340 /**
341 * Display both private and public key of an Eet_Key.
342 *
343 * @since 1.2.0
344 */
345 EAPI void eet_identity_print(Eet_Key *key, FILE *out);
346
347 /**
348 * Get the x509 der certificate associated with an Eet_File. Will return NULL
349 * if the file is not signed.
350 *
351 * @since 1.2.0
352 */
353 EAPI const void *eet_identity_x509(Eet_File *ef, int *der_length);
354
355 /**
356 * Get the raw signature associated with an Eet_File. Will return NULL
357 * if the file is not signed.
358 */
359 EAPI const void *eet_identity_signature(Eet_File *ef, int *signature_length);
360
361 /**
362 * Get the SHA1 associated with a file. Could be the one used to sign the data
363 * or if the data where not signed, it will be the SHA1 of the file.
364 *
365 * @since 1.2.0
366 */
367 EAPI const void *eet_identity_sha1(Eet_File *ef, int *sha1_length);
368
369 /**
370 * Display the x509 der certificate to out.
371 *
372 * @since 1.2.0
373 */
374 EAPI void eet_identity_certificate_print(const unsigned char *certificate, int der_length, FILE *out);
375
376 /** 268 /**
377 * Return a handle to the shared string dictionary of the Eet file 269 * Return a handle to the shared string dictionary of the Eet file
378 * @param ef A valid eet file handle. 270 * @param ef A valid eet file handle.
@@ -382,7 +274,12 @@ extern "C" {
382 * handle is @p ef, if a dictionary exists. NULL is returned otherwise or 274 * handle is @p ef, if a dictionary exists. NULL is returned otherwise or
383 * if the file handle is known to be invalid. 275 * if the file handle is known to be invalid.
384 * 276 *
277 * @see eet_dictionary_string_check() to know if given string came
278 * from the dictionary or it was dynamically allocated using
279 * the #Eet_Data_Descriptor_Class instructrions.
280 *
385 * @since 1.0.0 281 * @since 1.0.0
282 * @ingroup Eet_File_Group
386 */ 283 */
387 EAPI Eet_Dictionary *eet_dictionary_get(Eet_File *ef); 284 EAPI Eet_Dictionary *eet_dictionary_get(Eet_File *ef);
388 285
@@ -398,6 +295,7 @@ extern "C" {
398 * not in the dictionary, 0 is returned. 295 * not in the dictionary, 0 is returned.
399 * 296 *
400 * @since 1.0.0 297 * @since 1.0.0
298 * @ingroup Eet_File_Group
401 */ 299 */
402 EAPI int eet_dictionary_string_check(Eet_Dictionary *ed, const char *string); 300 EAPI int eet_dictionary_string_check(Eet_Dictionary *ed, const char *string);
403 301
@@ -418,9 +316,11 @@ extern "C" {
418 * If the eet file handle is not valid NULL is returned and size_ret is 316 * If the eet file handle is not valid NULL is returned and size_ret is
419 * filled with 0. 317 * filled with 0.
420 * 318 *
319 * @see eet_read_cipher()
320 *
421 * @since 1.0.0 321 * @since 1.0.0
322 * @ingroup Eet_File_Group
422 */ 323 */
423 EAPI void *eet_read_cipher(Eet_File *ef, const char *name, int *size_ret, const char *cipher_key);
424 EAPI void *eet_read(Eet_File *ef, const char *name, int *size_ret); 324 EAPI void *eet_read(Eet_File *ef, const char *name, int *size_ret);
425 325
426 /** 326 /**
@@ -441,6 +341,7 @@ extern "C" {
441 * filled with 0. 341 * filled with 0.
442 * 342 *
443 * @since 1.0.0 343 * @since 1.0.0
344 * @ingroup Eet_File_Group
444 */ 345 */
445 EAPI const void *eet_read_direct(Eet_File *ef, const char *name, int *size_ret); 346 EAPI const void *eet_read_direct(Eet_File *ef, const char *name, int *size_ret);
446 347
@@ -467,9 +368,11 @@ extern "C" {
467 * a flush to disk (it will stay in ram till the eet file handle is 368 * a flush to disk (it will stay in ram till the eet file handle is
468 * closed though). 369 * closed though).
469 * 370 *
371 * @see eet_write_cipher()
372 *
470 * @since 1.0.0 373 * @since 1.0.0
374 * @ingroup Eet_File_Group
471 */ 375 */
472 EAPI int eet_write_cipher(Eet_File *ef, const char *name, const void *data, int size, int compress, const char *cipher_key);
473 EAPI int eet_write(Eet_File *ef, const char *name, const void *data, int size, int compress); 376 EAPI int eet_write(Eet_File *ef, const char *name, const void *data, int size, int compress);
474 377
475 /** 378 /**
@@ -488,6 +391,7 @@ extern "C" {
488 * Name, must not be NULL, otherwise 0 will be returned. 391 * Name, must not be NULL, otherwise 0 will be returned.
489 * 392 *
490 * @since 1.0.0 393 * @since 1.0.0
394 * @ingroup Eet_File_Group
491 */ 395 */
492 EAPI int eet_delete(Eet_File *ef, const char *name); 396 EAPI int eet_delete(Eet_File *ef, const char *name);
493 397
@@ -519,6 +423,7 @@ extern "C" {
519 * value of "*". 423 * value of "*".
520 * 424 *
521 * @since 1.0.0 425 * @since 1.0.0
426 * @ingroup Eet_File_Group
522 */ 427 */
523 EAPI char **eet_list(Eet_File *ef, const char *glob, int *count_ret); 428 EAPI char **eet_list(Eet_File *ef, const char *glob, int *count_ret);
524 429
@@ -529,10 +434,84 @@ extern "C" {
529 * cannot be read due to open mode restrictions. 434 * cannot be read due to open mode restrictions.
530 * 435 *
531 * @since 1.0.0 436 * @since 1.0.0
437 * @ingroup Eet_File_Group
532 */ 438 */
533 EAPI int eet_num_entries(Eet_File *ef); 439 EAPI int eet_num_entries(Eet_File *ef);
534 440
535/***************************************************************************/ 441 /**
442 * @defgroup Eet_File_Cipher_Group Eet File Ciphered Main Functions
443 *
444 * Most of the @ref Eet_File_Group have alternative versions that
445 * accounts for ciphers to protect their content.
446 *
447 * @see @ref Eet_Cipher_Group
448 *
449 * @ingroup Eet_File_Group
450 */
451
452 /**
453 * Read a specified entry from an eet file and return data using a cipher.
454 * @param ef A valid eet file handle opened for reading.
455 * @param name Name of the entry. eg: "/base/file_i_want".
456 * @param size_ret Number of bytes read from entry and returned.
457 * @param cipher_key The key to use as cipher.
458 * @return The data stored in that entry in the eet file.
459 *
460 * This function finds an entry in the eet file that is stored under the
461 * name specified, and returns that data, decompressed, if successful.
462 * NULL is returned if the lookup fails or if memory errors are
463 * encountered. It is the job of the calling program to call free() on
464 * the returned data. The number of bytes in the returned data chunk are
465 * placed in size_ret.
466 *
467 * If the eet file handle is not valid NULL is returned and size_ret is
468 * filled with 0.
469 *
470 * @see eet_read()
471 *
472 * @since 1.0.0
473 * @ingroup Eet_File_Cipher_Group
474 */
475 EAPI void *eet_read_cipher(Eet_File *ef, const char *name, int *size_ret, const char *cipher_key);
476
477 /**
478 * Write a specified entry to an eet file handle using a cipher.
479 * @param ef A valid eet file handle opened for writing.
480 * @param name Name of the entry. eg: "/base/file_i_want".
481 * @param data Pointer to the data to be stored.
482 * @param size Length in bytes in the data to be stored.
483 * @param compress Compression flags (1 == compress, 0 = don't compress).
484 * @param cipher_key The key to use as cipher.
485 * @return bytes written on successful write, 0 on failure.
486 *
487 * This function will write the specified chunk of data to the eet file
488 * and return greater than 0 on success. 0 will be returned on failure.
489 *
490 * The eet file handle must be a valid file handle for an eet file opened
491 * for writing. If it is not, 0 will be returned and no action will be
492 * performed.
493 *
494 * Name, and data must not be NULL, and size must be > 0. If these
495 * conditions are not met, 0 will be returned.
496 *
497 * The data will be copied (and optionally compressed) in ram, pending
498 * a flush to disk (it will stay in ram till the eet file handle is
499 * closed though).
500 *
501 * @see eet_write()
502 *
503 * @since 1.0.0
504 * @ingroup Eet_File_Cipher_Group
505 */
506 EAPI int eet_write_cipher(Eet_File *ef, const char *name, const void *data, int size, int compress, const char *cipher_key);
507
508
509 /**
510 * @defgroup Eet_File_Image_Group Image Store and Load
511 *
512 * Eet efficiently stores and loads images, including alpha
513 * channels and lossy compressions.
514 */
536 515
537 /** 516 /**
538 * Read just the header data for an image and dont decode the pixels. 517 * Read just the header data for an image and dont decode the pixels.
@@ -565,9 +544,11 @@ extern "C" {
565 * On success the function returns 1 indicating the header was read and 544 * On success the function returns 1 indicating the header was read and
566 * decoded properly, or 0 on failure. 545 * decoded properly, or 0 on failure.
567 * 546 *
547 * @see eet_data_image_header_read_cipher()
548 *
568 * @since 1.0.0 549 * @since 1.0.0
550 * @ingroup Eet_File_Image_Group
569 */ 551 */
570 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);
571 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); 552 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);
572 553
573 /** 554 /**
@@ -603,9 +584,11 @@ extern "C" {
603 * when it is done with it. On failure NULL is returned and the parameter 584 * when it is done with it. On failure NULL is returned and the parameter
604 * values may not contain any sensible data. 585 * values may not contain any sensible data.
605 * 586 *
587 * @see eet_data_image_read_cipher()
588 *
606 * @since 1.0.0 589 * @since 1.0.0
590 * @ingroup Eet_File_Image_Group
607 */ 591 */
608 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);
609 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); 592 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);
610 593
611 /** 594 /**
@@ -643,9 +626,11 @@ extern "C" {
643 * On success the function returns 1, and 0 on failure. On failure the 626 * On success the function returns 1, and 0 on failure. On failure the
644 * parameter values may not contain any sensible data. 627 * parameter values may not contain any sensible data.
645 * 628 *
629 * @see eet_data_image_read_to_surface_cipher()
630 *
646 * @since 1.0.2 631 * @since 1.0.2
632 * @ingroup Eet_File_Image_Group
647 */ 633 */
648 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);
649 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); 634 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);
650 635
651 /** 636 /**
@@ -678,9 +663,11 @@ extern "C" {
678 * On success this function returns the number of bytes that were required 663 * On success this function returns the number of bytes that were required
679 * to encode the image data, or on failure it returns 0. 664 * to encode the image data, or on failure it returns 0.
680 * 665 *
666 * @see eet_data_image_write_cipher()
667 *
681 * @since 1.0.0 668 * @since 1.0.0
669 * @ingroup Eet_File_Image_Group
682 */ 670 */
683 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);
684 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); 671 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);
685 672
686 /** 673 /**
@@ -714,9 +701,11 @@ extern "C" {
714 * On success the function returns 1 indicating the header was read and 701 * On success the function returns 1 indicating the header was read and
715 * decoded properly, or 0 on failure. 702 * decoded properly, or 0 on failure.
716 * 703 *
704 * @see eet_data_image_header_decode_cipher()
705 *
717 * @since 1.0.0 706 * @since 1.0.0
707 * @ingroup Eet_File_Image_Group
718 */ 708 */
719 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);
720 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); 709 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);
721 710
722 /** 711 /**
@@ -752,9 +741,11 @@ extern "C" {
752 * when it is done with it. On failure NULL is returned and the parameter 741 * when it is done with it. On failure NULL is returned and the parameter
753 * values may not contain any sensible data. 742 * values may not contain any sensible data.
754 * 743 *
744 * @see eet_data_image_decode_cipher()
745 *
755 * @since 1.0.0 746 * @since 1.0.0
747 * @ingroup Eet_File_Image_Group
756 */ 748 */
757 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);
758 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); 749 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);
759 750
760 /** 751 /**
@@ -792,9 +783,11 @@ extern "C" {
792 * On success the function returns 1, and 0 on failure. On failure the 783 * On success the function returns 1, and 0 on failure. On failure the
793 * parameter values may not contain any sensible data. 784 * parameter values may not contain any sensible data.
794 * 785 *
786 * @see eet_data_image_decode_to_surface_cipher()
787 *
795 * @since 1.0.2 788 * @since 1.0.2
789 * @ingroup Eet_File_Image_Group
796 */ 790 */
797 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);
798 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); 791 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);
799 792
800 /** 793 /**
@@ -826,44 +819,519 @@ extern "C" {
826 * On success this function returns a pointer to the encoded data that you 819 * On success this function returns a pointer to the encoded data that you
827 * can free with free() when no longer needed. 820 * can free with free() when no longer needed.
828 * 821 *
822 * @see eet_data_image_encode_cipher()
823 *
829 * @since 1.0.0 824 * @since 1.0.0
825 * @ingroup Eet_File_Image_Group
830 */ 826 */
831 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);
832 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); 827 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);
833 828
834/***************************************************************************/ 829 /**
830 * @defgroup Eet_File_Image_Cipher_Group Image Store and Load using a Cipher
831 *
832 * Most of the @ref Eet_File_Image_Group have alternative versions
833 * that accounts for ciphers to protect their content.
834 *
835 * @see @ref Eet_Cipher_Group
836 *
837 * @ingroup Eet_File_Image_Group
838 */
835 839
836 /** 840 /**
837 * Create a new empty data structure descriptor. 841 * Read just the header data for an image and dont decode the pixels using a cipher.
838 * @param name The string name of this data structure (most be a 842 * @param ef A valid eet file handle opened for reading.
839 * global constant and never change). 843 * @param name Name of the entry. eg: "/base/file_i_want".
840 * @param size The size of the struct (in bytes). 844 * @param cipher_key The key to use as cipher.
841 * @param func_list_next The function to get the next list node. 845 * @param w A pointer to the unsigned int to hold the width in pixels.
842 * @param func_list_append The function to append a member to a list. 846 * @param h A pointer to the unsigned int to hold the height in pixels.
843 * @param func_list_data The function to get the data from a list node. 847 * @param alpha A pointer to the int to hold the alpha flag.
844 * @param func_list_free The function to free an entire linked list. 848 * @param compress A pointer to the int to hold the compression amount.
845 * @param func_hash_foreach The function to iterate through all 849 * @param quality A pointer to the int to hold the quality amount.
846 * hash table entries. 850 * @param lossy A pointer to the int to hold the lossiness flag.
847 * @param func_hash_add The function to add a member to a hash table. 851 * @return 1 on successfull decode, 0 otherwise
848 * @param func_hash_free The function to free an entire hash table.
849 * @return A new empty data descriptor.
850 * 852 *
851 * This function creates a new data descriptore and returns a handle to the 853 * This function reads an image from an eet file stored under the named
852 * new data descriptor. On creation it will be empty, containing no contents 854 * key in the eet file and return a pointer to the decompressed pixel data.
853 * describing anything other than the shell of the data structure.
854 * 855 *
855 * You add structure members to the data descriptor using the macros 856 * The other parameters of the image (width, height etc.) are placed into
856 * EET_DATA_DESCRIPTOR_ADD_BASIC(), EET_DATA_DESCRIPTOR_ADD_SUB() and 857 * the values pointed to (they must be supplied). The pixel data is a linear
857 * EET_DATA_DESCRIPTOR_ADD_LIST(), depending on what type of member you are 858 * array of pixels starting from the top-left of the image scanning row by
858 * adding to the description. 859 * row from left to right. Each pile is a 32bit value, with the high byte
860 * being the alpha channel, the next being red, then green, and the low byte
861 * being blue. The width and height are measured in pixels and will be
862 * greater than 0 when returned. The alpha flag is either 0 or 1. 0 denotes
863 * that the alpha channel is not used. 1 denotes that it is significant.
864 * Compress is filled with the compression value/amount the image was
865 * stored with. The quality value is filled with the quality encoding of
866 * the image file (0 - 100). The lossy flags is either 0 or 1 as to if
867 * the image was encoded lossily or not.
859 * 868 *
860 * Once you have described all the members of a struct you want loaded, or 869 * On success the function returns 1 indicating the header was read and
861 * saved eet can load and save those members for you, encode them into 870 * decoded properly, or 0 on failure.
862 * endian-independant serialised data chunks for transmission across a
863 * a network or more.
864 * 871 *
865 * The function pointers to the list and hash table functions are only 872 * @see eet_data_image_header_read()
866 * needed if you use those data types, else you can pass NULL instead. 873 *
874 * @since 1.0.0
875 * @ingroup Eet_File_Image_Cipher_Group
876 */
877 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);
878
879 /**
880 * Read image data from the named key in the eet file using a cipher.
881 * @param ef A valid eet file handle opened for reading.
882 * @param name Name of the entry. eg: "/base/file_i_want".
883 * @param cipher_key The key to use as cipher.
884 * @param w A pointer to the unsigned int to hold the width in pixels.
885 * @param h A pointer to the unsigned int to hold the height in pixels.
886 * @param alpha A pointer to the int to hold the alpha flag.
887 * @param compress A pointer to the int to hold the compression amount.
888 * @param quality A pointer to the int to hold the quality amount.
889 * @param lossy A pointer to the int to hold the lossiness flag.
890 * @return The image pixel data decoded
891 *
892 * This function reads an image from an eet file stored under the named
893 * key in the eet file and return a pointer to the decompressed pixel data.
894 *
895 * The other parameters of the image (width, height etc.) are placed into
896 * the values pointed to (they must be supplied). The pixel data is a linear
897 * array of pixels starting from the top-left of the image scanning row by
898 * row from left to right. Each pile is a 32bit value, with the high byte
899 * being the alpha channel, the next being red, then green, and the low byte
900 * being blue. The width and height are measured in pixels and will be
901 * greater than 0 when returned. The alpha flag is either 0 or 1. 0 denotes
902 * that the alpha channel is not used. 1 denotes that it is significant.
903 * Compress is filled with the compression value/amount the image was
904 * stored with. The quality value is filled with the quality encoding of
905 * the image file (0 - 100). The lossy flags is either 0 or 1 as to if
906 * the image was encoded lossily or not.
907 *
908 * On success the function returns a pointer to the image data decoded. The
909 * calling application is responsible for calling free() on the image data
910 * when it is done with it. On failure NULL is returned and the parameter
911 * values may not contain any sensible data.
912 *
913 * @see eet_data_image_read()
914 *
915 * @since 1.0.0
916 * @ingroup Eet_File_Image_Cipher_Group
917 */
918 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);
919
920 /**
921 * Read image data from the named key in the eet file using a cipher.
922 * @param ef A valid eet file handle opened for reading.
923 * @param name Name of the entry. eg: "/base/file_i_want".
924 * @param cipher_key The key to use as cipher.
925 * @param src_x The starting x coordinate from where to dump the stream.
926 * @param src_y The starting y coordinate from where to dump the stream.
927 * @param d A pointer to the pixel surface.
928 * @param w The expected width in pixels of the pixel surface to decode.
929 * @param h The expected height in pixels of the pixel surface to decode.
930 * @param row_stride The length of a pixels line in the destination surface.
931 * @param alpha A pointer to the int to hold the alpha flag.
932 * @param compress A pointer to the int to hold the compression amount.
933 * @param quality A pointer to the int to hold the quality amount.
934 * @param lossy A pointer to the int to hold the lossiness flag.
935 * @return 1 on success, 0 otherwise.
936 *
937 * This function reads an image from an eet file stored under the named
938 * key in the eet file and return a pointer to the decompressed pixel data.
939 *
940 * The other parameters of the image (width, height etc.) are placed into
941 * the values pointed to (they must be supplied). The pixel data is a linear
942 * array of pixels starting from the top-left of the image scanning row by
943 * row from left to right. Each pile is a 32bit value, with the high byte
944 * being the alpha channel, the next being red, then green, and the low byte
945 * being blue. The width and height are measured in pixels and will be
946 * greater than 0 when returned. The alpha flag is either 0 or 1. 0 denotes
947 * that the alpha channel is not used. 1 denotes that it is significant.
948 * Compress is filled with the compression value/amount the image was
949 * stored with. The quality value is filled with the quality encoding of
950 * the image file (0 - 100). The lossy flags is either 0 or 1 as to if
951 * the image was encoded lossily or not.
952 *
953 * On success the function returns 1, and 0 on failure. On failure the
954 * parameter values may not contain any sensible data.
955 *
956 * @see eet_data_image_read_to_surface()
957 *
958 * @since 1.0.2
959 * @ingroup Eet_File_Image_Cipher_Group
960 */
961 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);
962
963 /**
964 * Write image data to the named key in an eet file using a cipher.
965 * @param ef A valid eet file handle opened for writing.
966 * @param name Name of the entry. eg: "/base/file_i_want".
967 * @param cipher_key The key to use as cipher.
968 * @param data A pointer to the image pixel data.
969 * @param w The width of the image in pixels.
970 * @param h The height of the image in pixels.
971 * @param alpha The alpha channel flag.
972 * @param compress The compression amount.
973 * @param quality The quality encoding amount.
974 * @param lossy The lossiness flag.
975 * @return Success if the data was encoded and written or not.
976 *
977 * This function takes image pixel data and encodes it in an eet file
978 * stored under the supplied name key, and returns how many bytes were
979 * actually written to encode the image data.
980 *
981 * The data expected is the same format as returned by eet_data_image_read.
982 * If this is not the case weird things may happen. Width and height must
983 * be between 1 and 8000 pixels. The alpha flags can be 0 or 1 (0 meaning
984 * the alpha values are not useful and 1 meaning they are). Compress can
985 * be from 0 to 9 (0 meaning no compression, 9 meaning full compression).
986 * This is only used if the image is not lossily encoded. Quality is used on
987 * lossy compression and should be a value from 0 to 100. The lossy flag
988 * can be 0 or 1. 0 means encode losslessly and 1 means to encode with
989 * image quality loss (but then have a much smaller encoding).
990 *
991 * On success this function returns the number of bytes that were required
992 * to encode the image data, or on failure it returns 0.
993 *
994 * @see eet_data_image_write()
995 *
996 * @since 1.0.0
997 * @ingroup Eet_File_Image_Cipher_Group
998 */
999 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);
1000
1001
1002 /**
1003 * Decode Image data header only to get information using a cipher.
1004 * @param data The encoded pixel data.
1005 * @param cipher_key The key to use as cipher.
1006 * @param size The size, in bytes, of the encoded pixel data.
1007 * @param w A pointer to the unsigned int to hold the width in pixels.
1008 * @param h A pointer to the unsigned int to hold the height in pixels.
1009 * @param alpha A pointer to the int to hold the alpha flag.
1010 * @param compress A pointer to the int to hold the compression amount.
1011 * @param quality A pointer to the int to hold the quality amount.
1012 * @param lossy A pointer to the int to hold the lossiness flag.
1013 * @return 1 on success, 0 on failure.
1014 *
1015 * This function takes encoded pixel data and decodes it into raw RGBA
1016 * pixels on success.
1017 *
1018 * The other parameters of the image (width, height etc.) are placed into
1019 * the values pointed to (they must be supplied). The pixel data is a linear
1020 * array of pixels starting from the top-left of the image scanning row by
1021 * row from left to right. Each pixel is a 32bit value, with the high byte
1022 * being the alpha channel, the next being red, then green, and the low byte
1023 * being blue. The width and height are measured in pixels and will be
1024 * greater than 0 when returned. The alpha flag is either 0 or 1. 0 denotes
1025 * that the alpha channel is not used. 1 denotes that it is significant.
1026 * Compress is filled with the compression value/amount the image was
1027 * stored with. The quality value is filled with the quality encoding of
1028 * the image file (0 - 100). The lossy flags is either 0 or 1 as to if
1029 * the image was encoded lossily or not.
1030 *
1031 * On success the function returns 1 indicating the header was read and
1032 * decoded properly, or 0 on failure.
1033 *
1034 * @see eet_data_image_header_decode()
1035 *
1036 * @since 1.0.0
1037 * @ingroup Eet_File_Image_Cipher_Group
1038 */
1039 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);
1040
1041 /**
1042 * Decode Image data into pixel data using a cipher.
1043 * @param data The encoded pixel data.
1044 * @param cipher_key The key to use as cipher.
1045 * @param size The size, in bytes, of the encoded pixel data.
1046 * @param w A pointer to the unsigned int to hold the width in pixels.
1047 * @param h A pointer to the unsigned int to hold the height in pixels.
1048 * @param alpha A pointer to the int to hold the alpha flag.
1049 * @param compress A pointer to the int to hold the compression amount.
1050 * @param quality A pointer to the int to hold the quality amount.
1051 * @param lossy A pointer to the int to hold the lossiness flag.
1052 * @return The image pixel data decoded
1053 *
1054 * This function takes encoded pixel data and decodes it into raw RGBA
1055 * pixels on success.
1056 *
1057 * The other parameters of the image (width, height etc.) are placed into
1058 * the values pointed to (they must be supplied). The pixel data is a linear
1059 * array of pixels starting from the top-left of the image scanning row by
1060 * row from left to right. Each pixel is a 32bit value, with the high byte
1061 * being the alpha channel, the next being red, then green, and the low byte
1062 * being blue. The width and height are measured in pixels and will be
1063 * greater than 0 when returned. The alpha flag is either 0 or 1. 0 denotes
1064 * that the alpha channel is not used. 1 denotes that it is significant.
1065 * Compress is filled with the compression value/amount the image was
1066 * stored with. The quality value is filled with the quality encoding of
1067 * the image file (0 - 100). The lossy flags is either 0 or 1 as to if
1068 * the image was encoded lossily or not.
1069 *
1070 * On success the function returns a pointer to the image data decoded. The
1071 * calling application is responsible for calling free() on the image data
1072 * when it is done with it. On failure NULL is returned and the parameter
1073 * values may not contain any sensible data.
1074 *
1075 * @see eet_data_image_decode()
1076 *
1077 * @since 1.0.0
1078 * @ingroup Eet_File_Image_Cipher_Group
1079 */
1080 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);
1081
1082 /**
1083 * Decode Image data into pixel data using a cipher.
1084 * @param data The encoded pixel data.
1085 * @param cipher_key The key to use as cipher.
1086 * @param size The size, in bytes, of the encoded pixel data.
1087 * @param src_x The starting x coordinate from where to dump the stream.
1088 * @param src_y The starting y coordinate from where to dump the stream.
1089 * @param d A pointer to the pixel surface.
1090 * @param w The expected width in pixels of the pixel surface to decode.
1091 * @param h The expected height in pixels of the pixel surface to decode.
1092 * @param row_stride The length of a pixels line in the destination surface.
1093 * @param alpha A pointer to the int to hold the alpha flag.
1094 * @param compress A pointer to the int to hold the compression amount.
1095 * @param quality A pointer to the int to hold the quality amount.
1096 * @param lossy A pointer to the int to hold the lossiness flag.
1097 * @return 1 on success, 0 otherwise.
1098 *
1099 * This function takes encoded pixel data and decodes it into raw RGBA
1100 * pixels on success.
1101 *
1102 * The other parameters of the image (alpha, compress etc.) are placed into
1103 * the values pointed to (they must be supplied). The pixel data is a linear
1104 * array of pixels starting from the top-left of the image scanning row by
1105 * row from left to right. Each pixel is a 32bit value, with the high byte
1106 * being the alpha channel, the next being red, then green, and the low byte
1107 * being blue. The width and height are measured in pixels and will be
1108 * greater than 0 when returned. The alpha flag is either 0 or 1. 0 denotes
1109 * that the alpha channel is not used. 1 denotes that it is significant.
1110 * Compress is filled with the compression value/amount the image was
1111 * stored with. The quality value is filled with the quality encoding of
1112 * the image file (0 - 100). The lossy flags is either 0 or 1 as to if
1113 * the image was encoded lossily or not.
1114 *
1115 * On success the function returns 1, and 0 on failure. On failure the
1116 * parameter values may not contain any sensible data.
1117 *
1118 * @see eet_data_image_decode_to_surface()
1119 *
1120 * @since 1.0.2
1121 * @ingroup Eet_File_Image_Cipher_Group
1122 */
1123 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);
1124
1125 /**
1126 * Encode image data for storage or transmission using a cipher.
1127 * @param data A pointer to the image pixel data.
1128 * @param cipher_key The key to use as cipher.
1129 * @param size_ret A pointer to an int to hold the size of the returned data.
1130 * @param w The width of the image in pixels.
1131 * @param h The height of the image in pixels.
1132 * @param alpha The alpha channel flag.
1133 * @param compress The compression amount.
1134 * @param quality The quality encoding amount.
1135 * @param lossy The lossiness flag.
1136 * @return The encoded image data.
1137 *
1138 * This function stakes image pixel data and encodes it with compression and
1139 * possible loss of quality (as a trade off for size) for storage or
1140 * transmission to another system.
1141 *
1142 * The data expected is the same format as returned by eet_data_image_read.
1143 * If this is not the case weird things may happen. Width and height must
1144 * be between 1 and 8000 pixels. The alpha flags can be 0 or 1 (0 meaning
1145 * the alpha values are not useful and 1 meaning they are). Compress can
1146 * be from 0 to 9 (0 meaning no compression, 9 meaning full compression).
1147 * This is only used if the image is not lossily encoded. Quality is used on
1148 * lossy compression and should be a value from 0 to 100. The lossy flag
1149 * can be 0 or 1. 0 means encode losslessly and 1 means to encode with
1150 * image quality loss (but then have a much smaller encoding).
1151 *
1152 * On success this function returns a pointer to the encoded data that you
1153 * can free with free() when no longer needed.
1154 *
1155 * @see eet_data_image_encode()
1156 *
1157 * @since 1.0.0
1158 * @ingroup Eet_File_Image_Cipher_Group
1159 */
1160 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);
1161
1162
1163 /**
1164 * @defgroup Eet_Cipher_Group Cipher, Identity and Protection Mechanisms
1165 *
1166 * Eet allows one to protect entries of an #Eet_File
1167 * individually. This may be used to ensure data was not tampered or
1168 * that third party does not read your data.
1169 *
1170 * @see @ref Eet_File_Cipher_Group
1171 * @see @ref Eet_File_Image_Cipher_Group
1172 *
1173 * @{
1174 */
1175
1176 /**
1177 * @typedef Eet_Key
1178 * Opaque handle that defines an identity (also known as key)
1179 * in Eet's cipher system.
1180 */
1181 typedef struct _Eet_Key Eet_Key;
1182
1183 /**
1184 * @}
1185 */
1186
1187
1188 /**
1189 * Callback used to request if needed the password of a private key.
1190 *
1191 * @param buffer the buffer where to store the password.
1192 * @param size the maximum password size (size of buffer, including '@\0').
1193 * @param rwflag if the buffer is also readable or just writable.
1194 * @param data currently unused, may contain some context in future.
1195 * @return 1 on success and password was set to @p buffer, 0 on failure.
1196 *
1197 * @since 1.2.0
1198 * @ingroup Eet_Cipher_Group
1199 */
1200 typedef int (*Eet_Key_Password_Callback)(char *buffer, int size, int rwflag, void *data);
1201
1202 /**
1203 * Create an Eet_Key needed for signing an eet file.
1204 *
1205 * The certificate should provide the public that match the private key.
1206 * No verification is done to ensure that.
1207 *
1208 * @param certificate_file The file where to find the certificate.
1209 * @param private_key_file The file that contains the private key.
1210 * @param cb Function to callback if password is required to unlock
1211 * private key.
1212 * @return A key handle to use, or @c NULL on failure.
1213 *
1214 * @see eet_identity_close()
1215 *
1216 * @since 1.2.0
1217 * @ingroup Eet_Cipher_Group
1218 */
1219 EAPI Eet_Key* eet_identity_open(const char *certificate_file, const char *private_key_file, Eet_Key_Password_Callback cb);
1220
1221 /**
1222 * Close and release all ressource used by an Eet_Key. An
1223 * reference counter prevent it from being freed until all file
1224 * using it are also closed.
1225 *
1226 * @param key the key handle to close and free resources.
1227 *
1228 * @since 1.2.0
1229 * @ingroup Eet_Cipher_Group
1230 */
1231 EAPI void eet_identity_close(Eet_Key *key);
1232
1233 /**
1234 * Set a key to sign a file
1235 *
1236 * @param ef the file to set the identity.
1237 * @param key the key handle to set as identity.
1238 * @return #EET_ERROR_BAD_OBJECT if @p ef is invalid or
1239 * #EET_ERROR_NONE on success.
1240 *
1241 * @since 1.2.0
1242 * @ingroup Eet_Cipher_Group
1243 */
1244 EAPI Eet_Error eet_identity_set(Eet_File *ef, Eet_Key *key);
1245
1246 /**
1247 * Display both private and public key of an Eet_Key.
1248 *
1249 * @param key the handle to print.
1250 * @param out where to print.
1251 *
1252 * @since 1.2.0
1253 * @ingroup Eet_Cipher_Group
1254 */
1255 EAPI void eet_identity_print(Eet_Key *key, FILE *out);
1256
1257 /**
1258 * Get the x509 der certificate associated with an Eet_File. Will return NULL
1259 * if the file is not signed.
1260 *
1261 * @param ef The file handle to query.
1262 * @param der_length The length of returned data, may be @c NULL.
1263 * @return the x509 certificate or @c NULL on error.
1264 *
1265 * @since 1.2.0
1266 * @ingroup Eet_Cipher_Group
1267 */
1268 EAPI const void *eet_identity_x509(Eet_File *ef, int *der_length);
1269
1270 /**
1271 * Get the raw signature associated with an Eet_File. Will return NULL
1272 * if the file is not signed.
1273 *
1274 * @param ef The file handle to query.
1275 * @param signature_length The length of returned data, may be @c NULL.
1276 * @return the raw signature or @c NULL on error.
1277 *
1278 * @ingroup Eet_Cipher_Group
1279 */
1280 EAPI const void *eet_identity_signature(Eet_File *ef, int *signature_length);
1281
1282 /**
1283 * Get the SHA1 associated with a file. Could be the one used to
1284 * sign the data or if the data where not signed, it will be the
1285 * SHA1 of the file.
1286 *
1287 * @param ef The file handle to query.
1288 * @param sha1_length The length of returned data, may be @c NULL.
1289 * @return the associated SHA1 or @c NULL on error.
1290 *
1291 * @since 1.2.0
1292 * @ingroup Eet_Cipher_Group
1293 */
1294 EAPI const void *eet_identity_sha1(Eet_File *ef, int *sha1_length);
1295
1296 /**
1297 * Display the x509 der certificate to out.
1298 *
1299 * @param certificate the x509 certificate to print
1300 * @param der_length The length the certificate.
1301 * @param out where to print.
1302 *
1303 * @since 1.2.0
1304 * @ingroup Eet_Cipher_Group
1305 */
1306 EAPI void eet_identity_certificate_print(const unsigned char *certificate, int der_length, FILE *out);
1307
1308
1309 /**
1310 * @defgroup Eet_Data_Group Eet Data Serialization
1311 *
1312 * Convenience functions to serialize and parse complex data
1313 * structures to binary blobs.
1314 *
1315 * While Eet core just handles binary blobs, it is often required
1316 * to save some structured data of different types, such as
1317 * strings, integers, lists, hashes and so on.
1318 *
1319 * Eet can serialize and then parse data types given some
1320 * construction instructions. These are defined in two levels:
1321 *
1322 * - #Eet_Data_Descriptor_Class to tell generic memory handling,
1323 * such as the size of the type, how to allocate memory, strings,
1324 * lists, hashes and so on.
1325 *
1326 * - #Eet_Data_Descriptor to tell inside such type, the members and
1327 * their offsets inside the memory blob, their types and
1328 * names. These members can be simple types or other
1329 * #Eet_Data_Descriptor, allowing hierarchical types to be
1330 * defined.
1331 *
1332 * Given that C provides no introspection, this process can be
1333 * quite cumbersome, so we provide lots of macros and convenience
1334 * functions to aid creating the types.
867 * 1335 *
868 * Example: 1336 * Example:
869 * 1337 *
@@ -874,14 +1342,12 @@ extern "C" {
874 * typedef struct _blah2 1342 * typedef struct _blah2
875 * { 1343 * {
876 * char *string; 1344 * char *string;
877 * } 1345 * } Blah2;
878 * Blah2;
879 * 1346 *
880 * typedef struct _blah3 1347 * typedef struct _blah3
881 * { 1348 * {
882 * char *string; 1349 * char *string;
883 * } 1350 * } Blah3;
884 * Blah3;
885 * 1351 *
886 * typedef struct _blah 1352 * typedef struct _blah
887 * { 1353 * {
@@ -894,18 +1360,7 @@ extern "C" {
894 * char *string; 1360 * char *string;
895 * Blah2 *blah2; 1361 * Blah2 *blah2;
896 * Eina_List *blah3; 1362 * Eina_List *blah3;
897 * } 1363 * } Blah;
898 * Blah;
899 *
900 * Eina_Hash*
901 * eet_eina_hash_add(Eina_Hash *hash, const char *key, const void *data)
902 * {
903 * if (!hash) hash = eina_hash_string_superfast_new(NULL);
904 * if (!hash) return NULL;
905 *
906 * eina_hash_add(hash, key, data);
907 * return hash;
908 * }
909 * 1364 *
910 * int 1365 * int
911 * main(int argc, char **argv) 1366 * main(int argc, char **argv)
@@ -994,10 +1449,144 @@ extern "C" {
994 * 1449 *
995 * return 0; 1450 * return 0;
996 * } 1451 * }
997 *
998 * @endcode 1452 * @endcode
999 * 1453 *
1454 * @{
1455 */
1456#define EET_T_UNKNOW 0 /**< Unknown data encoding type */
1457#define EET_T_CHAR 1 /**< Data type: char */
1458#define EET_T_SHORT 2 /**< Data type: short */
1459#define EET_T_INT 3 /**< Data type: int */
1460#define EET_T_LONG_LONG 4 /**< Data type: long long */
1461#define EET_T_FLOAT 5 /**< Data type: float */
1462#define EET_T_DOUBLE 6 /**< Data type: double */
1463#define EET_T_UCHAR 7 /**< Data type: unsigned char */
1464#define EET_T_USHORT 8 /**< Data type: unsigned short */
1465#define EET_T_UINT 9 /**< Data type: unsigned int */
1466#define EET_T_ULONG_LONG 10 /**< Data type: unsigned long long */
1467#define EET_T_STRING 11 /**< Data type: char * */
1468#define EET_T_INLINED_STRING 12 /**< Data type: char * (but compressed inside the resulting eet) */
1469#define EET_T_NULL 13 /**< Data type: (void *) (only use it if you know why) */
1470#define EET_T_F32P32 14 /**< Data type: */
1471#define EET_T_F16P16 15 /**< Data type: */
1472#define EET_T_F8P24 16 /**< Data type: */
1473#define EET_T_LAST 17 /**< Last data type */
1474
1475#define EET_G_UNKNOWN 100 /**< Unknown group data encoding type */
1476#define EET_G_ARRAY 101 /**< Fixed size array group type */
1477#define EET_G_VAR_ARRAY 102 /**< Variable size array group type */
1478#define EET_G_LIST 103 /**< Linked list group type */
1479#define EET_G_HASH 104 /**< Hash table group type */
1480#define EET_G_LAST 105 /**< Last group type */
1481
1482#define EET_I_LIMIT 128 /**< Other type exist but are reserved for internal purpose. */
1483
1484 /**
1485 * @typedef Eet_Data_Descriptor
1486 *
1487 * Opaque handle that have information on a type members.
1488 *
1489 * The members are added by means of
1490 * EET_DATA_DESCRIPTOR_ADD_BASIC(), EET_DATA_DESCRIPTOR_ADD_SUB(),
1491 * EET_DATA_DESCRIPTOR_ADD_LIST(), EET_DATA_DESCRIPTOR_ADD_HASH()
1492 * or eet_data_descriptor_element_add().
1493 *
1494 * @see eet_data_descriptor_stream_new()
1495 * @see eet_data_descriptor_file_new()
1496 * @see eet_data_descriptor_free()
1497 */
1498 typedef struct _Eet_Data_Descriptor Eet_Data_Descriptor;
1499
1500 /**
1501 * @def EET_DATA_DESCRIPTOR_CLASS_VERSION
1502 * The version of #Eet_Data_Descriptor_Class at the time of the
1503 * distribution of the sources. One should define this to its
1504 * version member so it is compatible with abi changes, or at least
1505 * will not crash with them.
1506 */
1507#define EET_DATA_DESCRIPTOR_CLASS_VERSION 2
1508
1509 /**
1510 * @typedef Eet_Data_Descriptor_Class
1511 *
1512 * Instructs Eet about memory management for different needs under
1513 * serialization and parse process.
1514 */
1515 typedef struct _Eet_Data_Descriptor_Class Eet_Data_Descriptor_Class;
1516
1517 /**
1518 * @struct _Eet_Data_Descriptor_Class
1519 *
1520 * Instructs Eet about memory management for different needs under
1521 * serialization and parse process.
1522 *
1523 * If using Eina data types, it is advised to use the helpers
1524 * EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET() and
1525 * EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET().
1526 */
1527 struct _Eet_Data_Descriptor_Class
1528 {
1529 int version; /**< ABI version as #EET_DATA_DESCRIPTOR_CLASS_VERSION */
1530 const char *name; /**< Name of data type to be serialized */
1531 int size; /**< Size in bytes of data type to be serialized */
1532 struct {
1533 void *(*mem_alloc) (size_t size); /**< how to allocate memory (usually malloc()) */
1534 void (*mem_free) (void *mem); /**< how to free memory (usually free()) */
1535 char *(*str_alloc) (const char *str); /**< how to allocate a string */
1536 void (*str_free) (const char *str); /**< how to free a string */
1537 void *(*list_next) (void *l); /**< how to iterate to the next element of a list. Receives and should return the list node. */
1538 void *(*list_append) (void *l, void *d); /**< how to append data @p d to list which head node is @p l */
1539 void *(*list_data) (void *l); /**< retrieves the data from node @p l */
1540 void *(*list_free) (void *l); /**< free all the nodes from the list which head node is @p l */
1541 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 */
1542 void *(*hash_add) (void *h, const char *k, void *d); /**< add a new data @p d as key @p k in hash @p h */
1543 void (*hash_free) (void *h); /**< free all entries from the hash @p h */
1544 char *(*str_direct_alloc) (const char *str); /**< how to allocate a string directly from file backed/mmaped region pointed by @p str */
1545 void (*str_direct_free) (const char *str); /**< how to free a string returned by str_direct_alloc */
1546 } func;
1547 };
1548
1549 /**
1550 * @}
1551 */
1552
1553 /**
1554 * Create a new empty data structure descriptor.
1555 * @param name The string name of this data structure (most be a
1556 * global constant and never change).
1557 * @param size The size of the struct (in bytes).
1558 * @param func_list_next The function to get the next list node.
1559 * @param func_list_append The function to append a member to a list.
1560 * @param func_list_data The function to get the data from a list node.
1561 * @param func_list_free The function to free an entire linked list.
1562 * @param func_hash_foreach The function to iterate through all
1563 * hash table entries.
1564 * @param func_hash_add The function to add a member to a hash table.
1565 * @param func_hash_free The function to free an entire hash table.
1566 * @return A new empty data descriptor.
1567 *
1568 * This function creates a new data descriptore and returns a handle to the
1569 * new data descriptor. On creation it will be empty, containing no contents
1570 * describing anything other than the shell of the data structure.
1571 *
1572 * You add structure members to the data descriptor using the macros
1573 * EET_DATA_DESCRIPTOR_ADD_BASIC(), EET_DATA_DESCRIPTOR_ADD_SUB() and
1574 * EET_DATA_DESCRIPTOR_ADD_LIST(), depending on what type of member you are
1575 * adding to the description.
1576 *
1577 * Once you have described all the members of a struct you want loaded, or
1578 * saved eet can load and save those members for you, encode them into
1579 * endian-independant serialised data chunks for transmission across a
1580 * a network or more.
1581 *
1582 * The function pointers to the list and hash table functions are only
1583 * needed if you use those data types, else you can pass NULL instead.
1584 *
1000 * @since 1.0.0 1585 * @since 1.0.0
1586 * @ingroup Eet_Data_Group
1587 *
1588 * @deprecated use eet_data_descriptor_stream_new() or
1589 * eet_data_descriptor_file_new()
1001 */ 1590 */
1002 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)); 1591 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));
1003 /* 1592 /*
@@ -1013,7 +1602,7 @@ extern "C" {
1013 * This function creates a new data descriptore and returns a handle to the 1602 * This function creates a new data descriptore and returns a handle to the
1014 * new data descriptor. On creation it will be empty, containing no contents 1603 * new data descriptor. On creation it will be empty, containing no contents
1015 * describing anything other than the shell of the data structure. 1604 * describing anything other than the shell of the data structure.
1016 * @param edd The data descriptor to free. 1605 * @param eddc The data descriptor to free.
1017 * 1606 *
1018 * You add structure members to the data descriptor using the macros 1607 * You add structure members to the data descriptor using the macros
1019 * EET_DATA_DESCRIPTOR_ADD_BASIC(), EET_DATA_DESCRIPTOR_ADD_SUB() and 1608 * EET_DATA_DESCRIPTOR_ADD_BASIC(), EET_DATA_DESCRIPTOR_ADD_SUB() and
@@ -1031,14 +1620,15 @@ extern "C" {
1031 * and duplicated in memory. 1620 * and duplicated in memory.
1032 * 1621 *
1033 * @since 1.2.3 1622 * @since 1.2.3
1623 * @ingroup Eet_Data_Group
1034 */ 1624 */
1035 EAPI Eet_Data_Descriptor *eet_data_descriptor_stream_new(const Eet_Data_Descriptor_Class *eddc); 1625 EAPI Eet_Data_Descriptor *eet_data_descriptor_stream_new(const Eet_Data_Descriptor_Class *eddc);
1036 1626
1037 /** 1627 /**
1038 * This function creates a new data descriptore and returns a handle to the 1628 * This function creates a new data descriptore and returns a handle to the
1039 * new data descriptor. On creation it will be empty, containing no contents 1629 * new data descriptor. On creation it will be empty, containing no contents
1040 * describing anything other than the shell of the data structure. 1630 * describing anything other than the shell of the data structure.
1041 * @param edd The data descriptor to free. 1631 * @param eddc The data descriptor to free.
1042 * 1632 *
1043 * You add structure members to the data descriptor using the macros 1633 * You add structure members to the data descriptor using the macros
1044 * EET_DATA_DESCRIPTOR_ADD_BASIC(), EET_DATA_DESCRIPTOR_ADD_SUB() and 1634 * EET_DATA_DESCRIPTOR_ADD_BASIC(), EET_DATA_DESCRIPTOR_ADD_SUB() and
@@ -1059,19 +1649,23 @@ extern "C" {
1059 * strings, you need to have the Eet_File open. 1649 * strings, you need to have the Eet_File open.
1060 * 1650 *
1061 * @since 1.2.3 1651 * @since 1.2.3
1652 * @ingroup Eet_Data_Group
1062 */ 1653 */
1063 EAPI Eet_Data_Descriptor *eet_data_descriptor_file_new(const Eet_Data_Descriptor_Class *eddc); 1654 EAPI Eet_Data_Descriptor *eet_data_descriptor_file_new(const Eet_Data_Descriptor_Class *eddc);
1064 1655
1065 /** 1656 /**
1066 * This function is an helper that set all the parameter of an Eet_Data_Descriptor_Class 1657 * This function is an helper that set all the parameter of an
1067 * correctly when you use Eina data type with a stream. 1658 * Eet_Data_Descriptor_Class correctly when you use Eina data type
1068 * @param class The Eet_Data_Descriptor_Class you want to set. 1659 * with a stream.
1660 * @param eddc The Eet_Data_Descriptor_Class you want to set.
1069 * @param name The name of the structure described by this class. 1661 * @param name The name of the structure described by this class.
1070 * @param size The size of the structure described by this class. 1662 * @param size The size of the structure described by this class.
1071 * @return EINA_TRUE if the structure was correctly set (The only reason that could make 1663 * @return EINA_TRUE if the structure was correctly set (The only
1072 * it fail is if you did give wrong parameter). 1664 * reason that could make it fail is if you did give wrong
1665 * parameter).
1073 * 1666 *
1074 * @since 1.2.3 1667 * @since 1.2.3
1668 * @ingroup Eet_Data_Group
1075 */ 1669 */
1076 EAPI Eina_Bool eet_eina_stream_data_descriptor_class_set(Eet_Data_Descriptor_Class *eddc, const char *name, int size); 1670 EAPI Eina_Bool eet_eina_stream_data_descriptor_class_set(Eet_Data_Descriptor_Class *eddc, const char *name, int size);
1077 1671
@@ -1079,13 +1673,14 @@ extern "C" {
1079 * This macro is an helper that set all the parameter of an 1673 * This macro is an helper that set all the parameter of an
1080 * Eet_Data_Descriptor_Class correctly when you use Eina data type 1674 * Eet_Data_Descriptor_Class correctly when you use Eina data type
1081 * with stream. 1675 * with stream.
1082 * @param class The Eet_Data_Descriptor_Class you want to set. 1676 * @param Clas The Eet_Data_Descriptor_Class you want to set.
1083 * @param type The type of the structure described by this class. 1677 * @param Type The type of the structure described by this class.
1084 * @return EINA_TRUE if the structure was correctly set (The only 1678 * @return EINA_TRUE if the structure was correctly set (The only
1085 * reason that could make it fail is if you did give wrong 1679 * reason that could make it fail is if you did give wrong
1086 * parameter). 1680 * parameter).
1087 * 1681 *
1088 * @since 1.2.3 1682 * @since 1.2.3
1683 * @ingroup Eet_Data_Group
1089 */ 1684 */
1090#define EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(Clas, Type) (eet_eina_stream_data_descriptor_class_set(Clas, #Type , sizeof (Type))) 1685#define EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(Clas, Type) (eet_eina_stream_data_descriptor_class_set(Clas, #Type , sizeof (Type)))
1091 1686
@@ -1093,7 +1688,7 @@ extern "C" {
1093 * This function is an helper that set all the parameter of an 1688 * This function is an helper that set all the parameter of an
1094 * Eet_Data_Descriptor_Class correctly when you use Eina data type 1689 * Eet_Data_Descriptor_Class correctly when you use Eina data type
1095 * with a file. 1690 * with a file.
1096 * @param class The Eet_Data_Descriptor_Class you want to set. 1691 * @param eddc The Eet_Data_Descriptor_Class you want to set.
1097 * @param name The name of the structure described by this class. 1692 * @param name The name of the structure described by this class.
1098 * @param size The size of the structure described by this class. 1693 * @param size The size of the structure described by this class.
1099 * @return EINA_TRUE if the structure was correctly set (The only 1694 * @return EINA_TRUE if the structure was correctly set (The only
@@ -1101,6 +1696,7 @@ extern "C" {
1101 * parameter). 1696 * parameter).
1102 * 1697 *
1103 * @since 1.2.3 1698 * @since 1.2.3
1699 * @ingroup Eet_Data_Group
1104 */ 1700 */
1105 EAPI Eina_Bool eet_eina_file_data_descriptor_class_set(Eet_Data_Descriptor_Class *eddc, const char *name, int size); 1701 EAPI Eina_Bool eet_eina_file_data_descriptor_class_set(Eet_Data_Descriptor_Class *eddc, const char *name, int size);
1106 1702
@@ -1108,13 +1704,14 @@ extern "C" {
1108 * This macro is an helper that set all the parameter of an 1704 * This macro is an helper that set all the parameter of an
1109 * Eet_Data_Descriptor_Class correctly when you use Eina data type 1705 * Eet_Data_Descriptor_Class correctly when you use Eina data type
1110 * with file. 1706 * with file.
1111 * @param class The Eet_Data_Descriptor_Class you want to set. 1707 * @param Clas The Eet_Data_Descriptor_Class you want to set.
1112 * @param type The type of the structure described by this class. 1708 * @param Type The type of the structure described by this class.
1113 * @return EINA_TRUE if the structure was correctly set (The only 1709 * @return EINA_TRUE if the structure was correctly set (The only
1114 * reason that could make it fail is if you did give wrong 1710 * reason that could make it fail is if you did give wrong
1115 * parameter). 1711 * parameter).
1116 * 1712 *
1117 * @since 1.2.3 1713 * @since 1.2.3
1714 * @ingroup Eet_Data_Group
1118 */ 1715 */
1119#define EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(Clas, Type) (eet_eina_file_data_descriptor_class_set(Clas, #Type , sizeof (Type))) 1716#define EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(Clas, Type) (eet_eina_file_data_descriptor_class_set(Clas, #Type , sizeof (Type)))
1120 1717
@@ -1127,6 +1724,7 @@ extern "C" {
1127 * call the descriptor is no longer valid. 1724 * call the descriptor is no longer valid.
1128 * 1725 *
1129 * @since 1.0.0 1726 * @since 1.0.0
1727 * @ingroup Eet_Data_Group
1130 */ 1728 */
1131 EAPI void eet_data_descriptor_free(Eet_Data_Descriptor *edd); 1729 EAPI void eet_data_descriptor_free(Eet_Data_Descriptor *edd);
1132 1730
@@ -1138,7 +1736,23 @@ extern "C" {
1138 * complex to use by hand and should be left to be used by the macros, and 1736 * complex to use by hand and should be left to be used by the macros, and
1139 * thus is not documented. 1737 * thus is not documented.
1140 * 1738 *
1739 * @param edd The data descriptor handle to add element (member).
1740 * @param name The name of element to be serialized.
1741 * @param type The type of element to be serialized, like
1742 * #EET_T_INT. If #EET_T_UNKNOW, then it is considered to be a
1743 * group, list or hash.
1744 * @param group_type If element type is #EET_T_UNKNOW, then the @p
1745 * group_type will speficy if it is a list (#EET_G_LIST),
1746 * array (#EET_G_ARRAY) and so on. If #EET_G_UNKNOWN, then
1747 * the member is a subtype (pointer to another type defined by
1748 * another #Eet_Data_Descriptor).
1749 * @param offset byte offset inside the source memory to be serialized.
1750 * @param count number of elements (if #EET_G_ARRAY or #EET_G_VAR_ARRAY).
1751 * @param counter_name variable that defines the name of number of elements.
1752 * @param subtype If contains a subtype, then its data descriptor.
1753 *
1141 * @since 1.0.0 1754 * @since 1.0.0
1755 * @ingroup Eet_Data_Group
1142 */ 1756 */
1143 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); 1757 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);
1144 1758
@@ -1164,9 +1778,11 @@ extern "C" {
1164 * from an eet file, or from a chunk of memory is as simple as a single 1778 * from an eet file, or from a chunk of memory is as simple as a single
1165 * function call. 1779 * function call.
1166 * 1780 *
1781 * @see eet_data_read_cipher()
1782 *
1167 * @since 1.0.0 1783 * @since 1.0.0
1784 * @ingroup Eet_Data_Group
1168 */ 1785 */
1169 EAPI void *eet_data_read_cipher(Eet_File *ef, Eet_Data_Descriptor *edd, const char *name, const char *key);
1170 EAPI void *eet_data_read(Eet_File *ef, Eet_Data_Descriptor *edd, const char *name); 1786 EAPI void *eet_data_read(Eet_File *ef, Eet_Data_Descriptor *edd, const char *name);
1171 1787
1172 /** 1788 /**
@@ -1181,9 +1797,11 @@ extern "C" {
1181 * This function is the reverse of eet_data_read(), saving a data structure 1797 * This function is the reverse of eet_data_read(), saving a data structure
1182 * to an eet file. 1798 * to an eet file.
1183 * 1799 *
1800 * @see eet_data_write_cipher()
1801 *
1184 * @since 1.0.0 1802 * @since 1.0.0
1803 * @ingroup Eet_Data_Group
1185 */ 1804 */
1186 EAPI int eet_data_write_cipher(Eet_File *ef, Eet_Data_Descriptor *edd, const char *name, const char *key, const void *data, int compress);
1187 EAPI int eet_data_write(Eet_File *ef, Eet_Data_Descriptor *edd, const char *name, const void *data, int compress); 1805 EAPI int eet_data_write(Eet_File *ef, Eet_Data_Descriptor *edd, const char *name, const void *data, int compress);
1188 1806
1189 /** 1807 /**
@@ -1228,9 +1846,11 @@ extern "C" {
1228 * } 1846 * }
1229 * @endcode 1847 * @endcode
1230 * 1848 *
1849 * @see eet_data_text_dump_cipher()
1850 *
1231 * @since 1.0.0 1851 * @since 1.0.0
1852 * @ingroup Eet_Data_Group
1232 */ 1853 */
1233 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);
1234 EAPI int eet_data_text_dump(const void *data_in, int size_in, void (*dumpfunc) (void *data, const char *str), void *dumpdata); 1854 EAPI int eet_data_text_dump(const void *data_in, int size_in, void (*dumpfunc) (void *data, const char *str), void *dumpdata);
1235 1855
1236 /** 1856 /**
@@ -1247,9 +1867,11 @@ extern "C" {
1247 * in-memory data struct and encodes into a binary blob. @p text is a normal 1867 * in-memory data struct and encodes into a binary blob. @p text is a normal
1248 * C string. 1868 * C string.
1249 * 1869 *
1870 * @see eet_data_text_undump_cipher()
1871 *
1250 * @since 1.0.0 1872 * @since 1.0.0
1873 * @ingroup Eet_Data_Group
1251 */ 1874 */
1252 EAPI void *eet_data_text_undump_cipher(const char *text, const char *key, int textlen, int *size_ret);
1253 EAPI void *eet_data_text_undump(const char *text, int textlen, int *size_ret); 1875 EAPI void *eet_data_text_undump(const char *text, int textlen, int *size_ret);
1254 1876
1255 /** 1877 /**
@@ -1270,9 +1892,11 @@ extern "C" {
1270 * buffer and will be passed the pointer @p dumpdata as a parameter 1892 * buffer and will be passed the pointer @p dumpdata as a parameter
1271 * as well as a string with new text to be appended. 1893 * as well as a string with new text to be appended.
1272 * 1894 *
1895 * @see eet_data_dump_cipher()
1896 *
1273 * @since 1.0.0 1897 * @since 1.0.0
1898 * @ingroup Eet_Data_Group
1274 */ 1899 */
1275 EAPI int eet_data_dump_cipher(Eet_File *ef, const char *name, const char *key, void (*dumpfunc) (void *data, const char *str), void *dumpdata);
1276 EAPI int eet_data_dump(Eet_File *ef, const char *name, void (*dumpfunc) (void *data, const char *str), void *dumpdata); 1900 EAPI int eet_data_dump(Eet_File *ef, const char *name, void (*dumpfunc) (void *data, const char *str), void *dumpdata);
1277 1901
1278 /** 1902 /**
@@ -1292,9 +1916,11 @@ extern "C" {
1292 * The data (optionally compressed) will be in ram, pending a flush to 1916 * The data (optionally compressed) will be in ram, pending a flush to
1293 * disk (it will stay in ram till the eet file handle is closed though). 1917 * disk (it will stay in ram till the eet file handle is closed though).
1294 * 1918 *
1919 * @see eet_data_undump_cipher()
1920 *
1295 * @since 1.0.0 1921 * @since 1.0.0
1922 * @ingroup Eet_Data_Group
1296 */ 1923 */
1297 EAPI int eet_data_undump_cipher(Eet_File *ef, const char *name, const char *key, const char *text, int textlen, int compress);
1298 EAPI int eet_data_undump(Eet_File *ef, const char *name, const char *text, int textlen, int compress); 1924 EAPI int eet_data_undump(Eet_File *ef, const char *name, const char *text, int textlen, int compress);
1299 1925
1300 /** 1926 /**
@@ -1319,9 +1945,11 @@ extern "C" {
1319 * 1945 *
1320 * Please see eet_data_read() for more information. 1946 * Please see eet_data_read() for more information.
1321 * 1947 *
1948 * @see eet_data_descriptor_decode_cipher()
1949 *
1322 * @since 1.0.0 1950 * @since 1.0.0
1951 * @ingroup Eet_Data_Group
1323 */ 1952 */
1324 EAPI void *eet_data_descriptor_decode_cipher(Eet_Data_Descriptor *edd, const void *data_in, const char *key, int size_in);
1325 EAPI void *eet_data_descriptor_decode(Eet_Data_Descriptor *edd, const void *data_in, int size_in); 1953 EAPI void *eet_data_descriptor_decode(Eet_Data_Descriptor *edd, const void *data_in, int size_in);
1326 1954
1327 /** 1955 /**
@@ -1348,9 +1976,11 @@ extern "C" {
1348 * 1976 *
1349 * Please see eet_data_write() for more information. 1977 * Please see eet_data_write() for more information.
1350 * 1978 *
1979 * @see eet_data_descriptor_encode_cipher()
1980 *
1351 * @since 1.0.0 1981 * @since 1.0.0
1982 * @ingroup Eet_Data_Group
1352 */ 1983 */
1353 EAPI void *eet_data_descriptor_encode_cipher(Eet_Data_Descriptor *edd, const void *data_in, const char *key, int *size_ret);
1354 EAPI void *eet_data_descriptor_encode(Eet_Data_Descriptor *edd, const void *data_in, int *size_ret); 1984 EAPI void *eet_data_descriptor_encode(Eet_Data_Descriptor *edd, const void *data_in, int *size_ret);
1355 1985
1356 /** 1986 /**
@@ -1375,6 +2005,7 @@ extern "C" {
1375 * EET_T_USHORT, EET_T_UINT, EET_T_ULONG_LONG or EET_T_STRING. 2005 * EET_T_USHORT, EET_T_UINT, EET_T_ULONG_LONG or EET_T_STRING.
1376 * 2006 *
1377 * @since 1.0.0 2007 * @since 1.0.0
2008 * @ingroup Eet_Data_Group
1378 */ 2009 */
1379#define EET_DATA_DESCRIPTOR_ADD_BASIC(edd, struct_type, name, member, type) \ 2010#define EET_DATA_DESCRIPTOR_ADD_BASIC(edd, struct_type, name, member, type) \
1380 { \ 2011 { \
@@ -1401,6 +2032,7 @@ extern "C" {
1401 * this element. 2032 * this element.
1402 * 2033 *
1403 * @since 1.0.0 2034 * @since 1.0.0
2035 * @ingroup Eet_Data_Group
1404 */ 2036 */
1405#define EET_DATA_DESCRIPTOR_ADD_SUB(edd, struct_type, name, member, subtype) \ 2037#define EET_DATA_DESCRIPTOR_ADD_SUB(edd, struct_type, name, member, subtype) \
1406 { \ 2038 { \
@@ -1426,6 +2058,7 @@ extern "C" {
1426 * element that is in each member of the linked list to be stored. 2058 * element that is in each member of the linked list to be stored.
1427 * 2059 *
1428 * @since 1.0.0 2060 * @since 1.0.0
2061 * @ingroup Eet_Data_Group
1429 */ 2062 */
1430#define EET_DATA_DESCRIPTOR_ADD_LIST(edd, struct_type, name, member, subtype) \ 2063#define EET_DATA_DESCRIPTOR_ADD_LIST(edd, struct_type, name, member, subtype) \
1431 { \ 2064 { \
@@ -1451,6 +2084,7 @@ extern "C" {
1451 * element that is in each member of the hash to be stored. 2084 * element that is in each member of the hash to be stored.
1452 * 2085 *
1453 * @since 1.0.0 2086 * @since 1.0.0
2087 * @ingroup Eet_Data_Group
1454 */ 2088 */
1455#define EET_DATA_DESCRIPTOR_ADD_HASH(edd, struct_type, name, member, subtype) \ 2089#define EET_DATA_DESCRIPTOR_ADD_HASH(edd, struct_type, name, member, subtype) \
1456 { \ 2090 { \
@@ -1477,6 +2111,7 @@ extern "C" {
1477 * is in each member of the hash to be stored. 2111 * is in each member of the hash to be stored.
1478 * 2112 *
1479 * @since 1.0.2 2113 * @since 1.0.2
2114 * @ingroup Eet_Data_Group
1480 */ 2115 */
1481#define EET_DATA_DESCRIPTOR_ADD_ARRAY(edd, struct_type, name, member, subtype) \ 2116#define EET_DATA_DESCRIPTOR_ADD_ARRAY(edd, struct_type, name, member, subtype) \
1482 { \ 2117 { \
@@ -1503,6 +2138,7 @@ extern "C" {
1503 * is in each member of the hash to be stored. 2138 * is in each member of the hash to be stored.
1504 * 2139 *
1505 * @since 1.0.2 2140 * @since 1.0.2
2141 * @ingroup Eet_Data_Group
1506 */ 2142 */
1507#define EET_DATA_DESCRIPTOR_ADD_VAR_ARRAY(edd, struct_type, name, member, subtype) \ 2143#define EET_DATA_DESCRIPTOR_ADD_VAR_ARRAY(edd, struct_type, name, member, subtype) \
1508 { \ 2144 { \
@@ -1513,42 +2149,499 @@ extern "C" {
1513 (char *)(&(___ett.member ## _count)) - (char *)(&(___ett)), /* 0, */NULL, subtype); \ 2149 (char *)(&(___ett.member ## _count)) - (char *)(&(___ett)), /* 0, */NULL, subtype); \
1514 } 2150 }
1515 2151
1516/***************************************************************************/ 2152 /**
2153 * @defgroup Eet_Data_Cipher_Group Eet Data Serialization using A Ciphers
2154 *
2155 * Most of the @ref Eet_Data_Group have alternative versions that
2156 * accounts for ciphers to protect their content.
2157 *
2158 * @see @ref Eet_Cipher_Group
2159 *
2160 * @ingroup Eet_Data_Group
2161 */
2162
2163 /**
2164 * Read a data structure from an eet file and decodes it using a cipher.
2165 * @param ef The eet file handle to read from.
2166 * @param edd The data descriptor handle to use when decoding.
2167 * @param name The key the data is stored under in the eet file.
2168 * @param cipher_key The key to use as cipher.
2169 * @return A pointer to the decoded data structure.
2170 *
2171 * This function decodes a data structure stored in an eet file, returning
2172 * a pointer to it if it decoded successfully, or NULL on failure. This
2173 * can save a programmer dozens of hours of work in writing configuration
2174 * file parsing and writing code, as eet does all that work for the program
2175 * and presents a program-friendly data structure, just as the programmer
2176 * likes. Eet can handle members being added or deleted from the data in
2177 * storage and safely zero-fills unfilled members if they were not found
2178 * in the data. It checks sizes and headers whenever it reads data, allowing
2179 * the programmer to not worry about corrupt data.
2180 *
2181 * Once a data structure has been described by the programmer with the
2182 * fields they wish to save or load, storing or retrieving a data structure
2183 * from an eet file, or from a chunk of memory is as simple as a single
2184 * function call.
2185 *
2186 * @see eet_data_read()
2187 *
2188 * @since 1.0.0
2189 * @ingroup Eet_Data_Cipher_Group
2190 */
2191 EAPI void *eet_data_read_cipher(Eet_File *ef, Eet_Data_Descriptor *edd, const char *name, const char *cipher_key);
1517 2192
2193 /**
2194 * Write a data structure from memory and store in an eet file
2195 * using a cipher.
2196 * @param ef The eet file handle to write to.
2197 * @param edd The data descriptor to use when encoding.
2198 * @param name The key to store the data under in the eet file.
2199 * @param cipher_key The key to use as cipher.
2200 * @param data A pointer to the data structure to ssave and encode.
2201 * @param compress Compression flags for storage.
2202 * @return bytes written on successful write, 0 on failure.
2203 *
2204 * This function is the reverse of eet_data_read(), saving a data structure
2205 * to an eet file.
2206 *
2207 * @see eet_data_write_cipher()
2208 *
2209 * @since 1.0.0
2210 * @ingroup Eet_Data_Cipher_Group
2211 */
2212 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);
2213
2214 /**
2215 * Dump an eet encoded data structure into ascii text using a cipher.
2216 * @param data_in The pointer to the data to decode into a struct.
2217 * @param cipher_key The key to use as cipher.
2218 * @param size_in The size of the data pointed to in bytes.
2219 * @param dumpfunc The function to call passed a string when new
2220 * data is converted to text
2221 * @param dumpdata The data to pass to the @p dumpfunc callback.
2222 * @return 1 on success, 0 on failure
2223 *
2224 * This function will take a chunk of data encoded by
2225 * eet_data_descriptor_encode() and convert it into human readable
2226 * ascii text. It does this by calling the @p dumpfunc callback
2227 * for all new text that is generated. This callback should append
2228 * to any existing text buffer and will be passed the pointer @p
2229 * dumpdata as a parameter as well as a string with new text to be
2230 * appended.
2231 *
2232 * Example:
2233 *
2234 * @code
2235 * void output(void *data, const char *string)
2236 * {
2237 * printf("%s", string);
2238 * }
2239 *
2240 * void dump(const char *file)
2241 * {
2242 * FILE *f;
2243 * int len;
2244 * void *data;
2245 *
2246 * f = fopen(file, "r");
2247 * fseek(f, 0, SEEK_END);
2248 * len = ftell(f);
2249 * rewind(f);
2250 * data = malloc(len);
2251 * fread(data, len, 1, f);
2252 * fclose(f);
2253 * eet_data_text_dump_cipher(data, cipher_key, len, output, NULL);
2254 * }
2255 * @endcode
2256 *
2257 * @see eet_data_text_dump()
2258 *
2259 * @since 1.0.0
2260 * @ingroup Eet_Data_Cipher_Group
2261 */
2262 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);
2263
2264 /**
2265 * Take an ascii encoding from eet_data_text_dump() and re-encode
2266 * in binary using a cipher.
2267 * @param text The pointer to the string data to parse and encode.
2268 * @param cipher_key The key to use as cipher.
2269 * @param textlen The size of the string in bytes (not including 0
2270 * byte terminator).
2271 * @param size_ret This gets filled in with the encoded data blob
2272 * size in bytes.
2273 * @return The encoded data on success, NULL on failure.
2274 *
2275 * This function will parse the string pointed to by @p text and return
2276 * an encoded data lump the same way eet_data_descriptor_encode() takes an
2277 * in-memory data struct and encodes into a binary blob. @p text is a normal
2278 * C string.
2279 *
2280 * @see eet_data_text_undump()
2281 *
2282 * @since 1.0.0
2283 * @ingroup Eet_Data_Cipher_Group
2284 */
2285 EAPI void *eet_data_text_undump_cipher(const char *text, const char *cipher_key, int textlen, int *size_ret);
2286
2287 /**
2288 * Dump an eet encoded data structure from an eet file into ascii
2289 * text using a cipher.
2290 * @param ef A valid eet file handle.
2291 * @param name Name of the entry. eg: "/base/file_i_want".
2292 * @param cipher_key The key to use as cipher.
2293 * @param dumpfunc The function to call passed a string when new
2294 * data is converted to text
2295 * @param dumpdata The data to pass to the @p dumpfunc callback.
2296 * @return 1 on success, 0 on failure
2297 *
2298 * This function will take an open and valid eet file from
2299 * eet_open() request the data encoded by
2300 * eet_data_descriptor_encode() corresponding to the key @p name
2301 * and convert it into human readable ascii text. It does this by
2302 * calling the @p dumpfunc callback for all new text that is
2303 * generated. This callback should append to any existing text
2304 * buffer and will be passed the pointer @p dumpdata as a parameter
2305 * as well as a string with new text to be appended.
2306 *
2307 * @see eet_data_dump()
2308 *
2309 * @since 1.0.0
2310 * @ingroup Eet_Data_Cipher_Group
2311 */
2312 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);
2313
2314 /**
2315 * Take an ascii encoding from eet_data_dump() and re-encode in
2316 * binary using a cipher.
2317 * @param ef A valid eet file handle.
2318 * @param name Name of the entry. eg: "/base/file_i_want".
2319 * @param cipher_key The key to use as cipher.
2320 * @param text The pointer to the string data to parse and encode.
2321 * @param textlen The size of the string in bytes (not including 0
2322 * byte terminator).
2323 * @param compress Compression flags (1 == compress, 0 = don't compress).
2324 * @return 1 on success, 0 on failure
2325 *
2326 * This function will parse the string pointed to by @p text,
2327 * encode it the same way eet_data_descriptor_encode() takes an
2328 * in-memory data struct and encodes into a binary blob.
2329 *
2330 * The data (optionally compressed) will be in ram, pending a flush to
2331 * disk (it will stay in ram till the eet file handle is closed though).
2332 *
2333 * @see eet_data_undump()
2334 *
2335 * @since 1.0.0
2336 * @ingroup Eet_Data_Cipher_Group
2337 */
2338 EAPI int eet_data_undump_cipher(Eet_File *ef, const char *name, const char *cipher_key, const char *text, int textlen, int compress);
2339
2340 /**
2341 * Decode a data structure from an arbitary location in memory
2342 * using a cipher.
2343 * @param edd The data descriptor to use when decoding.
2344 * @param data_in The pointer to the data to decode into a struct.
2345 * @param cipher_key The key to use as cipher.
2346 * @param size_in The size of the data pointed to in bytes.
2347 * @return NULL on failure, or a valid decoded struct pointer on success.
2348 *
2349 * This function will decode a data structure that has been encoded using
2350 * eet_data_descriptor_encode(), and return a data structure with all its
2351 * elements filled out, if successful, or NULL on failure.
2352 *
2353 * The data to be decoded is stored at the memory pointed to by @p data_in,
2354 * and is described by the descriptor pointed to by @p edd. The data size is
2355 * passed in as the value to @p size_in, ande must be greater than 0 to
2356 * succeed.
2357 *
2358 * This function is useful for decoding data structures delivered to the
2359 * application by means other than an eet file, such as an IPC or socket
2360 * connection, raw files, shared memory etc.
2361 *
2362 * Please see eet_data_read() for more information.
2363 *
2364 * @see eet_data_descriptor_decode()
2365 *
2366 * @since 1.0.0
2367 * @ingroup Eet_Data_Cipher_Group
2368 */
2369 EAPI void *eet_data_descriptor_decode_cipher(Eet_Data_Descriptor *edd, const void *data_in, const char *cipher_key, int size_in);
2370
2371 /**
2372 * Encode a dsata struct to memory and return that encoded data
2373 * using a cipher.
2374 * @param edd The data descriptor to use when encoding.
2375 * @param data_in The pointer to the struct to encode into data.
2376 * @param cipher_key The key to use as cipher.
2377 * @param size_ret pointer to the an int to be filled with the decoded size.
2378 * @return NULL on failure, or a valid encoded data chunk on success.
2379 *
2380 * This function takes a data structutre in memory and encodes it into a
2381 * serialised chunk of data that can be decoded again by
2382 * eet_data_descriptor_decode(). This is useful for being able to transmit
2383 * data structures across sockets, pipes, IPC or shared file mechanisms,
2384 * without having to worry about memory space, machine type, endianess etc.
2385 *
2386 * The parameter @p edd must point to a valid data descriptor, and
2387 * @p data_in must point to the right data structure to encode. If not, the
2388 * encoding may fail.
2389 *
2390 * On success a non NULL valid pointer is returned and what @p size_ret
2391 * points to is set to the size of this decoded data, in bytes. When the
2392 * encoded data is no longer needed, call free() on it. On failure NULL is
2393 * returned and what @p size_ret points to is set to 0.
2394 *
2395 * Please see eet_data_write() for more information.
2396 *
2397 * @see eet_data_descriptor_encode()
2398 *
2399 * @since 1.0.0
2400 * @ingroup Eet_Data_Cipher_Group
2401 */
2402 EAPI void *eet_data_descriptor_encode_cipher(Eet_Data_Descriptor *edd, const void *data_in, const char *cipher_key, int *size_ret);
2403
2404
2405 /**
2406 * @defgroup Eet_Node_Group Low-level Serialization Structures.
2407 *
2408 * Functions that create, destroy and manipulate serialization nodes
2409 * used by @ref Eet_Data_Group.
2410 *
2411 * @{
2412 */
2413
2414 /**
2415 * @typedef Eet_Node
2416 * Opaque handle to manage serialization node.
2417 */
2418 typedef struct _Eet_Node Eet_Node;
2419
2420 /**
2421 * @typedef Eet_Node_Data
2422 * Contains an union that can fit any kind of node.
2423 */
2424 typedef struct _Eet_Node_Data Eet_Node_Data;
2425
2426 /**
2427 * @struct _Eet_Node_Data
2428 * Contains an union that can fit any kind of node.
2429 */
2430 struct _Eet_Node_Data
2431 {
2432 union {
2433 char c;
2434 short s;
2435 int i;
2436 long long l;
2437 float f;
2438 double d;
2439 unsigned char uc;
2440 unsigned short us;
2441 unsigned int ui;
2442 unsigned long long ul;
2443 const char *str;
2444 } value;
2445 };
2446
2447 /**
2448 * @}
2449 */
2450
2451 /**
2452 * TODO FIX ME
2453 * @ingroup Eet_Node_Group
2454 */
1518 EAPI Eet_Node *eet_node_char_new(const char *name, char c); 2455 EAPI Eet_Node *eet_node_char_new(const char *name, char c);
2456
2457 /**
2458 * TODO FIX ME
2459 * @ingroup Eet_Node_Group
2460 */
1519 EAPI Eet_Node *eet_node_short_new(const char *name, short s); 2461 EAPI Eet_Node *eet_node_short_new(const char *name, short s);
2462
2463 /**
2464 * TODO FIX ME
2465 * @ingroup Eet_Node_Group
2466 */
1520 EAPI Eet_Node *eet_node_int_new(const char *name, int i); 2467 EAPI Eet_Node *eet_node_int_new(const char *name, int i);
2468
2469 /**
2470 * TODO FIX ME
2471 * @ingroup Eet_Node_Group
2472 */
1521 EAPI Eet_Node *eet_node_long_long_new(const char *name, long long l); 2473 EAPI Eet_Node *eet_node_long_long_new(const char *name, long long l);
2474
2475 /**
2476 * TODO FIX ME
2477 * @ingroup Eet_Node_Group
2478 */
1522 EAPI Eet_Node *eet_node_float_new(const char *name, float f); 2479 EAPI Eet_Node *eet_node_float_new(const char *name, float f);
2480
2481 /**
2482 * TODO FIX ME
2483 * @ingroup Eet_Node_Group
2484 */
1523 EAPI Eet_Node *eet_node_double_new(const char *name, double d); 2485 EAPI Eet_Node *eet_node_double_new(const char *name, double d);
2486
2487 /**
2488 * TODO FIX ME
2489 * @ingroup Eet_Node_Group
2490 */
1524 EAPI Eet_Node *eet_node_unsigned_char_new(const char *name, unsigned char uc); 2491 EAPI Eet_Node *eet_node_unsigned_char_new(const char *name, unsigned char uc);
2492
2493 /**
2494 * TODO FIX ME
2495 * @ingroup Eet_Node_Group
2496 */
1525 EAPI Eet_Node *eet_node_unsigned_short_new(const char *name, unsigned short us); 2497 EAPI Eet_Node *eet_node_unsigned_short_new(const char *name, unsigned short us);
2498
2499 /**
2500 * TODO FIX ME
2501 * @ingroup Eet_Node_Group
2502 */
1526 EAPI Eet_Node *eet_node_unsigned_int_new(const char *name, unsigned int ui); 2503 EAPI Eet_Node *eet_node_unsigned_int_new(const char *name, unsigned int ui);
2504
2505 /**
2506 * TODO FIX ME
2507 * @ingroup Eet_Node_Group
2508 */
1527 EAPI Eet_Node *eet_node_unsigned_long_long_new(const char *name, unsigned long long l); 2509 EAPI Eet_Node *eet_node_unsigned_long_long_new(const char *name, unsigned long long l);
2510
2511 /**
2512 * TODO FIX ME
2513 * @ingroup Eet_Node_Group
2514 */
1528 EAPI Eet_Node *eet_node_string_new(const char *name, const char *str); 2515 EAPI Eet_Node *eet_node_string_new(const char *name, const char *str);
2516
2517 /**
2518 * TODO FIX ME
2519 * @ingroup Eet_Node_Group
2520 */
1529 EAPI Eet_Node *eet_node_inlined_string_new(const char *name, const char *str); 2521 EAPI Eet_Node *eet_node_inlined_string_new(const char *name, const char *str);
2522
2523 /**
2524 * TODO FIX ME
2525 * @ingroup Eet_Node_Group
2526 */
1530 EAPI Eet_Node *eet_node_null_new(const char *name); 2527 EAPI Eet_Node *eet_node_null_new(const char *name);
2528
2529 /**
2530 * TODO FIX ME
2531 * @ingroup Eet_Node_Group
2532 */
1531 EAPI Eet_Node *eet_node_list_new(const char *name, Eina_List *nodes); 2533 EAPI Eet_Node *eet_node_list_new(const char *name, Eina_List *nodes);
2534
2535 /**
2536 * TODO FIX ME
2537 * @ingroup Eet_Node_Group
2538 */
1532 EAPI Eet_Node *eet_node_array_new(const char *name, int count, Eina_List *nodes); 2539 EAPI Eet_Node *eet_node_array_new(const char *name, int count, Eina_List *nodes);
2540
2541 /**
2542 * TODO FIX ME
2543 * @ingroup Eet_Node_Group
2544 */
1533 EAPI Eet_Node *eet_node_var_array_new(const char *name, Eina_List *nodes); 2545 EAPI Eet_Node *eet_node_var_array_new(const char *name, Eina_List *nodes);
2546
2547 /**
2548 * TODO FIX ME
2549 * @ingroup Eet_Node_Group
2550 */
1534 EAPI Eet_Node *eet_node_hash_new(const char *name, const char *key, Eet_Node *node); 2551 EAPI Eet_Node *eet_node_hash_new(const char *name, const char *key, Eet_Node *node);
2552
2553 /**
2554 * TODO FIX ME
2555 * @ingroup Eet_Node_Group
2556 */
1535 EAPI Eet_Node *eet_node_struct_new(const char *name, Eina_List *nodes); 2557 EAPI Eet_Node *eet_node_struct_new(const char *name, Eina_List *nodes);
2558
2559 /**
2560 * TODO FIX ME
2561 * @ingroup Eet_Node_Group
2562 */
1536 EAPI Eet_Node *eet_node_struct_child_new(const char *parent, Eet_Node *child); 2563 EAPI Eet_Node *eet_node_struct_child_new(const char *parent, Eet_Node *child);
1537 2564
2565
2566 /**
2567 * TODO FIX ME
2568 * @ingroup Eet_Node_Group
2569 */
1538 EAPI void eet_node_list_append(Eet_Node *parent, const char *name, Eet_Node *child); 2570 EAPI void eet_node_list_append(Eet_Node *parent, const char *name, Eet_Node *child);
2571
2572 /**
2573 * TODO FIX ME
2574 * @ingroup Eet_Node_Group
2575 */
1539 EAPI void eet_node_struct_append(Eet_Node *parent, const char *name, Eet_Node *child); 2576 EAPI void eet_node_struct_append(Eet_Node *parent, const char *name, Eet_Node *child);
2577
2578 /**
2579 * TODO FIX ME
2580 * @ingroup Eet_Node_Group
2581 */
1540 EAPI void eet_node_hash_add(Eet_Node *parent, const char *name, const char *key, Eet_Node *child); 2582 EAPI void eet_node_hash_add(Eet_Node *parent, const char *name, const char *key, Eet_Node *child);
1541 2583
2584
2585 /**
2586 * TODO FIX ME
2587 * @ingroup Eet_Node_Group
2588 */
1542 EAPI void eet_node_dump(Eet_Node *n, int dumplevel, void (*dumpfunc) (void *data, const char *str), void *dumpdata); 2589 EAPI void eet_node_dump(Eet_Node *n, int dumplevel, void (*dumpfunc) (void *data, const char *str), void *dumpdata);
2590
2591 /**
2592 * TODO FIX ME
2593 * @ingroup Eet_Node_Group
2594 */
1543 EAPI void eet_node_del(Eet_Node *n); 2595 EAPI void eet_node_del(Eet_Node *n);
1544 2596
1545 EAPI void *eet_data_node_encode_cipher(Eet_Node *node, const char *key, int *size_ret); 2597 /**
1546 EAPI void *eet_data_node_decode_cipher(const void *data_in, const char *key, int size_in); 2598 * TODO FIX ME
2599 * @ingroup Eet_Node_Group
2600 */
2601 EAPI void *eet_data_node_encode_cipher(Eet_Node *node, const char *cipher_key, int *size_ret);
2602
2603 /**
2604 * TODO FIX ME
2605 * @ingroup Eet_Node_Group
2606 */
2607 EAPI void *eet_data_node_decode_cipher(const void *data_in, const char *cipher_key, int size_in);
1547 2608
1548 EAPI Eet_Node *eet_data_node_read_cipher(Eet_File *ef, const char *name, const char *key); 2609 /**
1549 EAPI int eet_data_node_write_cipher(Eet_File *ef, const char *name, const char *key, Eet_Node *node, int compress); 2610 * TODO FIX ME
2611 * @ingroup Eet_Node_Group
2612 */
2613 EAPI Eet_Node *eet_data_node_read_cipher(Eet_File *ef, const char *name, const char *cipher_key);
2614
2615 /**
2616 * TODO FIX ME
2617 * @ingroup Eet_Node_Group
2618 */
2619 EAPI int eet_data_node_write_cipher(Eet_File *ef, const char *name, const char *cipher_key, Eet_Node *node, int compress);
2620
2621 /* EXPERIMENTAL: THIS API MAY CHANGE IN THE FUTURE, USE IT ONLY IF YOU KNOW WHAT YOU ARE DOING. */
2622
2623 /**
2624 * @typedef Eet_Node_Walk
2625 * Describes how to walk trees of #Eet_Node.
2626 */
2627 typedef struct _Eet_Node_Walk Eet_Node_Walk;
2628
2629 /**
2630 * @struct _Eet_Node_Walk
2631 * Describes how to walk trees of #Eet_Node.
2632 */
2633 struct _Eet_Node_Walk
2634 {
2635 void *(*struct_alloc)(const char *type, void *user_data);
2636 void (*struct_add)(void *parent, const char *name, void *child, void *user_data);
2637 void *(*array)(Eina_Bool variable, const char *name, int count, void *user_data);
2638 void (*insert)(void *array, int index, void *child, void *user_data);
2639 void *(*list)(const char *name, void *user_data);
2640 void (*append)(void *list, void *child, void *user_data);
2641 void *(*hash)(void *parent, const char *name, const char *key, void *value, void *user_data);
2642 void *(*simple)(int type, Eet_Node_Data *data, void *user_data);
2643 };
1550 2644
1551 /* EXPERIMENTAL: THIS API MAY CHANGE IN THE FUTUR, USE IT ONLY IF YOU KNOW WHAT YOU ARE DOING. */
1552 EAPI void *eet_node_walk(void *parent, const char *name, Eet_Node *root, Eet_Node_Walk *cb, void *user_data); 2645 EAPI void *eet_node_walk(void *parent, const char *name, Eet_Node *root, Eet_Node_Walk *cb, void *user_data);
1553 2646
1554/***************************************************************************/ 2647/***************************************************************************/
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,
1434} 1434}
1435 1435
1436EAPI void * 1436EAPI void *
1437eet_data_read_cipher(Eet_File *ef, Eet_Data_Descriptor *edd, const char *name, const char *key) 1437eet_data_read_cipher(Eet_File *ef, Eet_Data_Descriptor *edd, const char *name, const char *cipher_key)
1438{ 1438{
1439 const Eet_Dictionary *ed = NULL; 1439 const Eet_Dictionary *ed = NULL;
1440 const void *data = NULL; 1440 const void *data = NULL;
@@ -1445,12 +1445,12 @@ eet_data_read_cipher(Eet_File *ef, Eet_Data_Descriptor *edd, const char *name, c
1445 1445
1446 ed = eet_dictionary_get(ef); 1446 ed = eet_dictionary_get(ef);
1447 1447
1448 if (!key) 1448 if (!cipher_key)
1449 data = eet_read_direct(ef, name, &size); 1449 data = eet_read_direct(ef, name, &size);
1450 if (!data) 1450 if (!data)
1451 { 1451 {
1452 required_free = 1; 1452 required_free = 1;
1453 data = eet_read_cipher(ef, name, &size, key); 1453 data = eet_read_cipher(ef, name, &size, cipher_key);
1454 if (!data) return NULL; 1454 if (!data) return NULL;
1455 } 1455 }
1456 1456
@@ -1463,7 +1463,7 @@ eet_data_read_cipher(Eet_File *ef, Eet_Data_Descriptor *edd, const char *name, c
1463} 1463}
1464 1464
1465EAPI Eet_Node * 1465EAPI Eet_Node *
1466eet_data_node_read_cipher(Eet_File *ef, const char *name, const char *key) 1466eet_data_node_read_cipher(Eet_File *ef, const char *name, const char *cipher_key)
1467{ 1467{
1468 const Eet_Dictionary *ed = NULL; 1468 const Eet_Dictionary *ed = NULL;
1469 const void *data = NULL; 1469 const void *data = NULL;
@@ -1474,12 +1474,12 @@ eet_data_node_read_cipher(Eet_File *ef, const char *name, const char *key)
1474 1474
1475 ed = eet_dictionary_get(ef); 1475 ed = eet_dictionary_get(ef);
1476 1476
1477 if (!key) 1477 if (!cipher_key)
1478 data = eet_read_direct(ef, name, &size); 1478 data = eet_read_direct(ef, name, &size);
1479 if (!data) 1479 if (!data)
1480 { 1480 {
1481 required_free = 1; 1481 required_free = 1;
1482 data = eet_read_cipher(ef, name, &size, key); 1482 data = eet_read_cipher(ef, name, &size, cipher_key);
1483 if (!data) return NULL; 1483 if (!data) return NULL;
1484 } 1484 }
1485 1485
@@ -1498,7 +1498,7 @@ eet_data_read(Eet_File *ef, Eet_Data_Descriptor *edd, const char *name)
1498} 1498}
1499 1499
1500EAPI int 1500EAPI int
1501eet_data_write_cipher(Eet_File *ef, Eet_Data_Descriptor *edd, const char *name, const char *key, const void *data, int compress) 1501eet_data_write_cipher(Eet_File *ef, Eet_Data_Descriptor *edd, const char *name, const char *cipher_key, const void *data, int compress)
1502{ 1502{
1503 Eet_Dictionary *ed; 1503 Eet_Dictionary *ed;
1504 void *data_enc; 1504 void *data_enc;
@@ -1509,7 +1509,7 @@ eet_data_write_cipher(Eet_File *ef, Eet_Data_Descriptor *edd, const char *name,
1509 1509
1510 data_enc = _eet_data_descriptor_encode(ed, edd, data, &size); 1510 data_enc = _eet_data_descriptor_encode(ed, edd, data, &size);
1511 if (!data_enc) return 0; 1511 if (!data_enc) return 0;
1512 val = eet_write_cipher(ef, name, data_enc, size, compress, key); 1512 val = eet_write_cipher(ef, name, data_enc, size, compress, cipher_key);
1513 free(data_enc); 1513 free(data_enc);
1514 return val; 1514 return val;
1515} 1515}
@@ -1724,7 +1724,7 @@ _eet_freelist_all_unref(Eet_Free_Context *freelist_context)
1724} 1724}
1725 1725
1726static int 1726static int
1727eet_data_descriptor_encode_hash_cb(void *hash __UNUSED__, const char *key, void *hdata, void *fdata) 1727eet_data_descriptor_encode_hash_cb(void *hash __UNUSED__, const char *cipher_key, void *hdata, void *fdata)
1728{ 1728{
1729 Eet_Dictionary *ed; 1729 Eet_Dictionary *ed;
1730 Eet_Data_Encode_Hash_Info *edehi; 1730 Eet_Data_Encode_Hash_Info *edehi;
@@ -1742,7 +1742,7 @@ eet_data_descriptor_encode_hash_cb(void *hash __UNUSED__, const char *key, void
1742 /* Store key */ 1742 /* Store key */
1743 data = eet_data_put_type(ed, 1743 data = eet_data_put_type(ed,
1744 EET_T_STRING, 1744 EET_T_STRING,
1745 &key, 1745 &cipher_key,
1746 &size); 1746 &size);
1747 if (data) 1747 if (data)
1748 { 1748 {
@@ -3038,7 +3038,7 @@ eet_data_put_hash(Eet_Dictionary *ed, Eet_Data_Descriptor *edd, Eet_Data_Element
3038 3038
3039EAPI int 3039EAPI int
3040eet_data_dump_cipher(Eet_File *ef, 3040eet_data_dump_cipher(Eet_File *ef,
3041 const char *name, const char *key, 3041 const char *name, const char *cipher_key,
3042 void (*dumpfunc) (void *data, const char *str), 3042 void (*dumpfunc) (void *data, const char *str),
3043 void *dumpdata) 3043 void *dumpdata)
3044{ 3044{
@@ -3051,12 +3051,12 @@ eet_data_dump_cipher(Eet_File *ef,
3051 3051
3052 ed = eet_dictionary_get(ef); 3052 ed = eet_dictionary_get(ef);
3053 3053
3054 if (!key) 3054 if (!cipher_key)
3055 data = eet_read_direct(ef, name, &size); 3055 data = eet_read_direct(ef, name, &size);
3056 if (!data) 3056 if (!data)
3057 { 3057 {
3058 required_free = 1; 3058 required_free = 1;
3059 data = eet_read_cipher(ef, name, &size, key); 3059 data = eet_read_cipher(ef, name, &size, cipher_key);
3060 if (!data) return 0; 3060 if (!data) return 0;
3061 } 3061 }
3062 3062
@@ -3085,7 +3085,7 @@ eet_data_dump(Eet_File *ef,
3085 3085
3086EAPI int 3086EAPI int
3087eet_data_text_dump_cipher(const void *data_in, 3087eet_data_text_dump_cipher(const void *data_in,
3088 const char *key, int size_in, 3088 const char *cipher_key, int size_in,
3089 void (*dumpfunc) (void *data, const char *str), 3089 void (*dumpfunc) (void *data, const char *str),
3090 void *dumpdata) 3090 void *dumpdata)
3091{ 3091{
@@ -3096,9 +3096,10 @@ eet_data_text_dump_cipher(const void *data_in,
3096 3096
3097 if (!data_in) return 0; 3097 if (!data_in) return 0;
3098 3098
3099 if (key) 3099 if (cipher_key)
3100 { 3100 {
3101 if (eet_decipher(data_in, size_in, key, strlen(key), &ret, &ret_len)) 3101 if (eet_decipher(data_in, size_in, cipher_key,
3102 strlen(cipher_key), &ret, &ret_len))
3102 { 3103 {
3103 if (ret) free(ret); 3104 if (ret) free(ret);
3104 return 0; 3105 return 0;
@@ -3116,7 +3117,7 @@ eet_data_text_dump_cipher(const void *data_in,
3116 eet_node_dump(result, 0, dumpfunc, dumpdata); 3117 eet_node_dump(result, 0, dumpfunc, dumpdata);
3117 3118
3118 eet_node_del(result); 3119 eet_node_del(result);
3119 if (key) free(ret); 3120 if (cipher_key) free(ret);
3120 3121
3121 return result ? 1 : 0; 3122 return result ? 1 : 0;
3122} 3123}
@@ -3132,19 +3133,20 @@ eet_data_text_dump(const void *data_in,
3132 3133
3133EAPI void * 3134EAPI void *
3134eet_data_text_undump_cipher(const char *text, 3135eet_data_text_undump_cipher(const char *text,
3135 const char *key, 3136 const char *cipher_key,
3136 int textlen, 3137 int textlen,
3137 int *size_ret) 3138 int *size_ret)
3138{ 3139{
3139 void *ret = NULL; 3140 void *ret = NULL;
3140 3141
3141 ret = _eet_data_dump_parse(NULL, size_ret, text, textlen); 3142 ret = _eet_data_dump_parse(NULL, size_ret, text, textlen);
3142 if (ret && key) 3143 if (ret && cipher_key)
3143 { 3144 {
3144 void *ciphered = NULL; 3145 void *ciphered = NULL;
3145 unsigned int ciphered_len; 3146 unsigned int ciphered_len;
3146 3147
3147 if (eet_cipher(ret, *size_ret, key, strlen(key), &ciphered, &ciphered_len)) 3148 if (eet_cipher(ret, *size_ret, cipher_key,
3149 strlen(cipher_key), &ciphered, &ciphered_len))
3148 { 3150 {
3149 if (ciphered) free(ciphered); 3151 if (ciphered) free(ciphered);
3150 size_ret = 0; 3152 size_ret = 0;
@@ -3169,7 +3171,7 @@ eet_data_text_undump(const char *text,
3169EAPI int 3171EAPI int
3170eet_data_undump_cipher(Eet_File *ef, 3172eet_data_undump_cipher(Eet_File *ef,
3171 const char *name, 3173 const char *name,
3172 const char *key, 3174 const char *cipher_key,
3173 const char *text, 3175 const char *text,
3174 int textlen, 3176 int textlen,
3175 int compress) 3177 int compress)
@@ -3183,7 +3185,7 @@ eet_data_undump_cipher(Eet_File *ef,
3183 3185
3184 data_enc = _eet_data_dump_parse(ed, &size, text, textlen); 3186 data_enc = _eet_data_dump_parse(ed, &size, text, textlen);
3185 if (!data_enc) return 0; 3187 if (!data_enc) return 0;
3186 val = eet_write_cipher(ef, name, data_enc, size, compress, key); 3188 val = eet_write_cipher(ef, name, data_enc, size, compress, cipher_key);
3187 free(data_enc); 3189 free(data_enc);
3188 return val; 3190 return val;
3189} 3191}
@@ -3201,7 +3203,7 @@ eet_data_undump(Eet_File *ef,
3201EAPI void * 3203EAPI void *
3202eet_data_descriptor_decode_cipher(Eet_Data_Descriptor *edd, 3204eet_data_descriptor_decode_cipher(Eet_Data_Descriptor *edd,
3203 const void *data_in, 3205 const void *data_in,
3204 const char *key, 3206 const char *cipher_key,
3205 int size_in) 3207 int size_in)
3206{ 3208{
3207 void *deciphered = (void*) data_in; 3209 void *deciphered = (void*) data_in;
@@ -3209,9 +3211,10 @@ eet_data_descriptor_decode_cipher(Eet_Data_Descriptor *edd,
3209 Eet_Free_Context context; 3211 Eet_Free_Context context;
3210 unsigned int deciphered_len = size_in; 3212 unsigned int deciphered_len = size_in;
3211 3213
3212 if (key && data_in) 3214 if (cipher_key && data_in)
3213 { 3215 {
3214 if (eet_decipher(data_in, size_in, key, strlen(key), &deciphered, &deciphered_len)) 3216 if (eet_decipher(data_in, size_in, cipher_key,
3217 strlen(cipher_key), &deciphered, &deciphered_len))
3215 { 3218 {
3216 if (deciphered) free(deciphered); 3219 if (deciphered) free(deciphered);
3217 return NULL; 3220 return NULL;
@@ -3235,16 +3238,17 @@ eet_data_descriptor_decode(Eet_Data_Descriptor *edd,
3235} 3238}
3236 3239
3237EAPI void * 3240EAPI void *
3238eet_data_node_decode_cipher(const void *data_in, const char *key, int size_in) 3241eet_data_node_decode_cipher(const void *data_in, const char *cipher_key, int size_in)
3239{ 3242{
3240 void *deciphered = (void*) data_in; 3243 void *deciphered = (void*) data_in;
3241 Eet_Node *ret; 3244 Eet_Node *ret;
3242 Eet_Free_Context context; 3245 Eet_Free_Context context;
3243 unsigned int deciphered_len = size_in; 3246 unsigned int deciphered_len = size_in;
3244 3247
3245 if (key && data_in) 3248 if (cipher_key && data_in)
3246 { 3249 {
3247 if (eet_decipher(data_in, size_in, key, strlen(key), &deciphered, &deciphered_len)) 3250 if (eet_decipher(data_in, size_in, cipher_key,
3251 strlen(cipher_key), &deciphered, &deciphered_len))
3248 { 3252 {
3249 if (deciphered) free(deciphered); 3253 if (deciphered) free(deciphered);
3250 return NULL; 3254 return NULL;
@@ -3310,7 +3314,7 @@ _eet_data_descriptor_encode(Eet_Dictionary *ed,
3310} 3314}
3311 3315
3312EAPI int 3316EAPI int
3313eet_data_node_write_cipher(Eet_File *ef, const char *name, const char *key, Eet_Node *node, int compress) 3317eet_data_node_write_cipher(Eet_File *ef, const char *name, const char *cipher_key, Eet_Node *node, int compress)
3314{ 3318{
3315 Eet_Dictionary *ed; 3319 Eet_Dictionary *ed;
3316 void *data_enc; 3320 void *data_enc;
@@ -3321,14 +3325,14 @@ eet_data_node_write_cipher(Eet_File *ef, const char *name, const char *key, Eet_
3321 3325
3322 data_enc = _eet_data_dump_encode(EET_G_UNKNOWN, ed, node, &size); 3326 data_enc = _eet_data_dump_encode(EET_G_UNKNOWN, ed, node, &size);
3323 if (!data_enc) return 0; 3327 if (!data_enc) return 0;
3324 val = eet_write_cipher(ef, name, data_enc, size, compress, key); 3328 val = eet_write_cipher(ef, name, data_enc, size, compress, cipher_key);
3325 free(data_enc); 3329 free(data_enc);
3326 return val; 3330 return val;
3327} 3331}
3328 3332
3329EAPI void * 3333EAPI void *
3330eet_data_node_encode_cipher(Eet_Node *node, 3334eet_data_node_encode_cipher(Eet_Node *node,
3331 const char *key, 3335 const char *cipher_key,
3332 int *size_ret) 3336 int *size_ret)
3333{ 3337{
3334 void *ret = NULL; 3338 void *ret = NULL;
@@ -3337,9 +3341,10 @@ eet_data_node_encode_cipher(Eet_Node *node,
3337 int size; 3341 int size;
3338 3342
3339 ret = _eet_data_dump_encode(EET_G_UNKNOWN, NULL, node, &size); 3343 ret = _eet_data_dump_encode(EET_G_UNKNOWN, NULL, node, &size);
3340 if (key && ret) 3344 if (cipher_key && ret)
3341 { 3345 {
3342 if (eet_cipher(ret, size, key, strlen(key), &ciphered, &ciphered_len)) 3346 if (eet_cipher(ret, size, cipher_key,
3347 strlen(cipher_key), &ciphered, &ciphered_len))
3343 { 3348 {
3344 if (ciphered) free(ciphered); 3349 if (ciphered) free(ciphered);
3345 if (size_ret) *size_ret = 0; 3350 if (size_ret) *size_ret = 0;
@@ -3358,7 +3363,7 @@ eet_data_node_encode_cipher(Eet_Node *node,
3358EAPI void * 3363EAPI void *
3359eet_data_descriptor_encode_cipher(Eet_Data_Descriptor *edd, 3364eet_data_descriptor_encode_cipher(Eet_Data_Descriptor *edd,
3360 const void *data_in, 3365 const void *data_in,
3361 const char *key, 3366 const char *cipher_key,
3362 int *size_ret) 3367 int *size_ret)
3363{ 3368{
3364 void *ret = NULL; 3369 void *ret = NULL;
@@ -3367,9 +3372,10 @@ eet_data_descriptor_encode_cipher(Eet_Data_Descriptor *edd,
3367 int size; 3372 int size;
3368 3373
3369 ret = _eet_data_descriptor_encode(NULL, edd, data_in, &size); 3374 ret = _eet_data_descriptor_encode(NULL, edd, data_in, &size);
3370 if (key && ret) 3375 if (cipher_key && ret)
3371 { 3376 {
3372 if (eet_cipher(ret, size, key, strlen(key), &ciphered, &ciphered_len)) 3377 if (eet_cipher(ret, size, cipher_key,
3378 strlen(cipher_key), &ciphered, &ciphered_len))
3373 { 3379 {
3374 if (ciphered) free(ciphered); 3380 if (ciphered) free(ciphered);
3375 if (size_ret) *size_ret = 0; 3381 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
909} 909}
910 910
911EAPI int 911EAPI int
912eet_data_image_write_cipher(Eet_File *ef, const char *name, const char *key, 912eet_data_image_write_cipher(Eet_File *ef, const char *name, const char *cipher_key,
913 const void *data, unsigned int w, unsigned int h, int alpha, 913 const void *data, unsigned int w, unsigned int h, int alpha,
914 int comp, int quality, int lossy) 914 int comp, int quality, int lossy)
915{ 915{
@@ -921,7 +921,7 @@ eet_data_image_write_cipher(Eet_File *ef, const char *name, const char *key,
921 { 921 {
922 int v; 922 int v;
923 923
924 v = eet_write_cipher(ef, name, d, size, 0, key); 924 v = eet_write_cipher(ef, name, d, size, 0, cipher_key);
925 free(d); 925 free(d);
926 return v; 926 return v;
927 } 927 }
@@ -938,7 +938,7 @@ eet_data_image_write(Eet_File *ef, const char *name,
938 938
939 939
940EAPI void * 940EAPI void *
941eet_data_image_read_cipher(Eet_File *ef, const char *name, const char *key, 941eet_data_image_read_cipher(Eet_File *ef, const char *name, const char *cipher_key,
942 unsigned int *w, unsigned int *h, int *alpha, 942 unsigned int *w, unsigned int *h, int *alpha,
943 int *comp, int *quality, int *lossy) 943 int *comp, int *quality, int *lossy)
944{ 944{
@@ -947,11 +947,11 @@ eet_data_image_read_cipher(Eet_File *ef, const char *name, const char *key,
947 int free_data = 0; 947 int free_data = 0;
948 int size; 948 int size;
949 949
950 if (!key) 950 if (!cipher_key)
951 data = (void *)eet_read_direct(ef, name, &size); 951 data = (void *)eet_read_direct(ef, name, &size);
952 if (!data) 952 if (!data)
953 { 953 {
954 data = eet_read_cipher(ef, name, &size, key); 954 data = eet_read_cipher(ef, name, &size, cipher_key);
955 free_data = 1; 955 free_data = 1;
956 if (!data) return NULL; 956 if (!data) return NULL;
957 } 957 }
@@ -973,7 +973,7 @@ eet_data_image_read(Eet_File *ef, const char *name,
973} 973}
974 974
975EAPI int 975EAPI int
976eet_data_image_read_to_surface_cipher(Eet_File *ef, const char *name, const char *key, unsigned int src_x, unsigned int src_y, 976eet_data_image_read_to_surface_cipher(Eet_File *ef, const char *name, const char *cipher_key, unsigned int src_x, unsigned int src_y,
977 unsigned int *d, unsigned int w, unsigned int h, unsigned int row_stride, 977 unsigned int *d, unsigned int w, unsigned int h, unsigned int row_stride,
978 int *alpha, int *comp, int *quality, int *lossy) 978 int *alpha, int *comp, int *quality, int *lossy)
979{ 979{
@@ -982,11 +982,11 @@ eet_data_image_read_to_surface_cipher(Eet_File *ef, const char *name, const char
982 int res = 1; 982 int res = 1;
983 int size; 983 int size;
984 984
985 if (!key) 985 if (!cipher_key)
986 data = (void *)eet_read_direct(ef, name, &size); 986 data = (void *)eet_read_direct(ef, name, &size);
987 if (!data) 987 if (!data)
988 { 988 {
989 data = eet_read_cipher(ef, name, &size, key); 989 data = eet_read_cipher(ef, name, &size, cipher_key);
990 free_data = 1; 990 free_data = 1;
991 if (!data) return 0; 991 if (!data) return 0;
992 } 992 }
@@ -1008,7 +1008,7 @@ eet_data_image_read_to_surface(Eet_File *ef, const char *name, unsigned int src_
1008} 1008}
1009 1009
1010EAPI int 1010EAPI int
1011eet_data_image_header_read_cipher(Eet_File *ef, const char *name, const char *key, 1011eet_data_image_header_read_cipher(Eet_File *ef, const char *name, const char *cipher_key,
1012 unsigned int *w, unsigned int *h, int *alpha, 1012 unsigned int *w, unsigned int *h, int *alpha,
1013 int *comp, int *quality, int *lossy) 1013 int *comp, int *quality, int *lossy)
1014{ 1014{
@@ -1017,11 +1017,11 @@ eet_data_image_header_read_cipher(Eet_File *ef, const char *name, const char *ke
1017 int free_data = 0; 1017 int free_data = 0;
1018 int d; 1018 int d;
1019 1019
1020 if (!key) 1020 if (!cipher_key)
1021 data = (void *)eet_read_direct(ef, name, &size); 1021 data = (void *)eet_read_direct(ef, name, &size);
1022 if (!data) 1022 if (!data)
1023 { 1023 {
1024 data = eet_read_cipher(ef, name, &size, key); 1024 data = eet_read_cipher(ef, name, &size, cipher_key);
1025 free_data = 1; 1025 free_data = 1;
1026 if (!data) return 0; 1026 if (!data) return 0;
1027 } 1027 }
@@ -1043,7 +1043,7 @@ eet_data_image_header_read(Eet_File *ef, const char *name,
1043 1043
1044 1044
1045EAPI void * 1045EAPI void *
1046eet_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) 1046eet_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)
1047{ 1047{
1048 void *d = NULL; 1048 void *d = NULL;
1049 void *ciphered_d = NULL; 1049 void *ciphered_d = NULL;
@@ -1067,9 +1067,9 @@ eet_data_image_encode_cipher(const void *data, const char *key, unsigned int w,
1067 else 1067 else
1068 d = eet_data_image_jpeg_alpha_convert(&size, data, w, h, alpha, quality); 1068 d = eet_data_image_jpeg_alpha_convert(&size, data, w, h, alpha, quality);
1069 } 1069 }
1070 if (key) 1070 if (cipher_key)
1071 { 1071 {
1072 if(!eet_cipher(d, size, key, strlen(key), &ciphered_d, &ciphered_sz)) 1072 if(!eet_cipher(d, size, cipher_key, strlen(cipher_key), &ciphered_d, &ciphered_sz))
1073 { 1073 {
1074 if (d) free(d); 1074 if (d) free(d);
1075 d = ciphered_d; 1075 d = ciphered_d;
@@ -1090,15 +1090,15 @@ eet_data_image_encode(const void *data, int *size_ret, unsigned int w, unsigned
1090} 1090}
1091 1091
1092EAPI int 1092EAPI int
1093eet_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) 1093eet_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)
1094{ 1094{
1095 int header[8]; 1095 int header[8];
1096 void *deciphered_d = NULL; 1096 void *deciphered_d = NULL;
1097 unsigned int deciphered_sz = 0; 1097 unsigned int deciphered_sz = 0;
1098 1098
1099 if (key) 1099 if (cipher_key)
1100 { 1100 {
1101 if (!eet_decipher(data, size, key, strlen(key), &deciphered_d, &deciphered_sz)) 1101 if (!eet_decipher(data, size, cipher_key, strlen(cipher_key), &deciphered_d, &deciphered_sz))
1102 { 1102 {
1103 data = deciphered_d; 1103 data = deciphered_d;
1104 size = deciphered_sz; 1104 size = deciphered_sz;
@@ -1306,7 +1306,7 @@ _eet_data_image_decode_inside(const void *data, int size, unsigned int src_x, un
1306} 1306}
1307 1307
1308EAPI void * 1308EAPI void *
1309eet_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) 1309eet_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)
1310{ 1310{
1311 unsigned int *d = NULL; 1311 unsigned int *d = NULL;
1312 unsigned int iw, ih; 1312 unsigned int iw, ih;
@@ -1314,9 +1314,9 @@ eet_data_image_decode_cipher(const void *data, const char *key, int size, unsign
1314 void *deciphered_d = NULL; 1314 void *deciphered_d = NULL;
1315 unsigned int deciphered_sz = 0; 1315 unsigned int deciphered_sz = 0;
1316 1316
1317 if (key) 1317 if (cipher_key)
1318 { 1318 {
1319 if (!eet_decipher(data, size, key, strlen(key), &deciphered_d, &deciphered_sz)) 1319 if (!eet_decipher(data, size, cipher_key, strlen(cipher_key), &deciphered_d, &deciphered_sz))
1320 { 1320 {
1321 data = deciphered_d; 1321 data = deciphered_d;
1322 size = deciphered_sz; 1322 size = deciphered_sz;
@@ -1355,7 +1355,7 @@ eet_data_image_decode(const void *data, int size, unsigned int *w, unsigned int
1355} 1355}
1356 1356
1357EAPI int 1357EAPI int
1358eet_data_image_decode_to_surface_cipher(const void *data, const char *key, int size, unsigned int src_x, unsigned int src_y, 1358eet_data_image_decode_to_surface_cipher(const void *data, const char *cipher_key, int size, unsigned int src_x, unsigned int src_y,
1359 unsigned int *d, unsigned int w, unsigned int h, unsigned int row_stride, 1359 unsigned int *d, unsigned int w, unsigned int h, unsigned int row_stride,
1360 int *alpha, int *comp, int *quality, int *lossy) 1360 int *alpha, int *comp, int *quality, int *lossy)
1361{ 1361{
@@ -1364,9 +1364,9 @@ eet_data_image_decode_to_surface_cipher(const void *data, const char *key, int s
1364 void *deciphered_d = NULL; 1364 void *deciphered_d = NULL;
1365 unsigned int deciphered_sz = 0; 1365 unsigned int deciphered_sz = 0;
1366 1366
1367 if (key) 1367 if (cipher_key)
1368 { 1368 {
1369 if (!eet_decipher(data, size, key, strlen(key), &deciphered_d, &deciphered_sz)) 1369 if (!eet_decipher(data, size, cipher_key, strlen(cipher_key), &deciphered_d, &deciphered_sz))
1370 { 1370 {
1371 data = deciphered_d; 1371 data = deciphered_d;
1372 size = deciphered_sz; 1372 size = deciphered_sz;