* eet: Add EET_G_VARIANT and EET_G_UNION.
[framework/uifw/eet.git] / src / lib / Eet.h
1 #ifndef _EET_H
2 #define _EET_H
3
4 #include <stdlib.h>
5 #include <stdio.h>
6 #include <Eina.h>
7
8 #ifdef EAPI
9 # undef EAPI
10 #endif
11
12 #ifdef _WIN32
13 # ifdef EFL_EET_BUILD
14 #  ifdef DLL_EXPORT
15 #   define EAPI __declspec(dllexport)
16 #  else
17 #   define EAPI
18 #  endif /* ! DLL_EXPORT */
19 # else
20 #  define EAPI __declspec(dllimport)
21 # endif /* ! EFL_EET_BUILD */
22 #else
23 # ifdef __GNUC__
24 #  if __GNUC__ >= 4
25 #   define EAPI __attribute__ ((visibility("default")))
26 #  else
27 #   define EAPI
28 #  endif
29 # else
30 #  define EAPI
31 # endif
32 #endif /* ! _WIN32 */
33
34 #ifdef __cplusplus
35 extern "C" {
36 #endif
37
38   /**
39    * @file Eet.h
40    * @brief The file that provides the eet functions.
41    *
42    * This header provides the Eet management functions.
43    *
44    */
45
46   /**
47    * @defgroup Eet_Group Top level functions
48    * Functions that affect Eet as a whole.
49    *
50    * @{
51    */
52
53   /**
54    * @enum _Eet_Error
55    * All the error identifiers known by Eet.
56    */
57    typedef enum _Eet_Error
58      {
59        EET_ERROR_NONE, /**< No error, it's all fine! */
60        EET_ERROR_BAD_OBJECT, /**< Given object or handle is NULL or invalid */
61        EET_ERROR_EMPTY, /**< There was nothing to do */
62        EET_ERROR_NOT_WRITABLE, /**< Could not write to file or fine is #EET_FILE_MODE_READ */
63        EET_ERROR_OUT_OF_MEMORY, /**< Could not allocate memory */
64        EET_ERROR_WRITE_ERROR, /**< Failed to write data to destination */
65        EET_ERROR_WRITE_ERROR_FILE_TOO_BIG, /**< Failed to write file since it is too big */
66        EET_ERROR_WRITE_ERROR_IO_ERROR, /**< Failed to write since generic Input/Output error */
67        EET_ERROR_WRITE_ERROR_OUT_OF_SPACE, /**< Failed to write due out of space */
68        EET_ERROR_WRITE_ERROR_FILE_CLOSED, /**< Failed to write because file was closed */
69        EET_ERROR_MMAP_FAILED, /**< Could not mmap file */
70        EET_ERROR_X509_ENCODING_FAILED, /**< Could not encode using X509 */
71        EET_ERROR_SIGNATURE_FAILED, /**< Could not validate signature */
72        EET_ERROR_INVALID_SIGNATURE, /**< Signature is invalid */
73        EET_ERROR_NOT_SIGNED, /**< File or contents are not signed */
74        EET_ERROR_NOT_IMPLEMENTED, /**< Function is not implemented */
75        EET_ERROR_PRNG_NOT_SEEDED, /**< Could not introduce random seed */
76        EET_ERROR_ENCRYPT_FAILED, /**< Could not encrypt contents */
77        EET_ERROR_DECRYPT_FAILED /**< Could not decrypt contents */
78      } Eet_Error; /**< Eet error identifiers */
79
80   /**
81    * @}
82    */
83
84    /**
85     * Initialize the EET library.
86     *
87     * @return The new init count.
88     *
89     * @since 1.0.0
90     * @ingroup Eet_Group
91     */
92    EAPI int eet_init(void);
93
94    /**
95     * Shut down the EET library.
96     *
97     * @return The new init count.
98     *
99     * @since 1.0.0
100     * @ingroup Eet_Group
101     */
102    EAPI int eet_shutdown(void);
103
104    /**
105     * Clear eet cache
106     *
107     * Eet didn't free items by default. If you are under memory
108     * presure, just call this function to recall all memory that are
109     * not yet referenced anymore.  The cache take care of modification
110     * on disk.
111     *
112     * @since 1.0.0
113     * @ingroup Eet_Group
114     */
115    EAPI void eet_clearcache(void);
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
160    /**
161     * Open an eet file on disk, and returns a handle to it.
162     * @param file The file path to the eet file. eg: @c "/tmp/file.eet".
163     * @param mode The mode for opening. Either #EET_FILE_MODE_READ,
164     *        #EET_FILE_MODE_WRITE or #EET_FILE_MODE_READ_WRITE.
165     * @return An opened eet file handle.
166     * @ingroup Eet_File_Group
167     *
168     * This function will open an exiting eet file for reading, and build
169     * the directory table in memory and return a handle to the file, if it
170     * exists and can be read, and no memory errors occur on the way, otherwise
171     * NULL will be returned.
172     *
173     * It will also open an eet file for writing. This will, if successful,
174     * delete the original file and replace it with a new empty file, till
175     * the eet file handle is closed or flushed. If it cannot be opened for
176     * writing or a memory error occurs, NULL is returned.
177     *
178     * You can also open the file for read/write. If you then write a key that
179     * does not exist it will be created, if the key exists it will be replaced
180     * by the new data.
181     *
182     * Example:
183     * @code
184     * #include <Eet.h>
185     * #include <stdio.h>
186     * #include <string.h>
187     *
188     * int
189     * main(int argc, char **argv)
190     * {
191     *   Eet_File *ef;
192     *   char buf[1024], *ret, **list;
193     *   int size, num, i;
194     *
195     *   eet_init();
196     *
197     *   strcpy(buf, "Here is a string of data to save!");
198     *
199     *   ef = eet_open("/tmp/my_file.eet", EET_FILE_MODE_WRITE);
200     *   if (!ef) return -1;
201     *   if (!eet_write(ef, "/key/to_store/at", buf, 1024, 1))
202     *     fprintf(stderr, "Error writing data!\n");
203     *   eet_close(ef);
204     *
205     *   ef = eet_open("/tmp/my_file.eet", EET_FILE_MODE_READ);
206     *   if (!ef) return -1;
207     *   list = eet_list(ef, "*", &num);
208     *   if (list)
209     *     {
210     *       for (i = 0; i < num; i++)
211     *         printf("Key stored: %s\n", list[i]);
212     *       free(list);
213     *     }
214     *   ret = eet_read(ef, "/key/to_store/at", &size);
215     *   if (ret)
216     *     {
217     *       printf("Data read (%i bytes):\n%s\n", size, ret);
218     *       free(ret);
219     *     }
220     *   eet_close(ef);
221     *
222     *   eet_shutdown();
223     *
224     *   return 0;
225     * }
226     * @endcode
227     *
228     * @since 1.0.0
229     */
230    EAPI Eet_File *eet_open(const char *file, Eet_File_Mode mode);
231
232    /**
233     * Open an eet file directly from a memory location. The data are not copied,
234     * so you must keep them around as long as the eet file is open. Their is
235     * currently no cache for this kind of Eet_File, so it's reopen every time
236     * you do use eet_memopen_read.
237     *
238     * @since 1.1.0
239     * @ingroup Eet_File_Group
240     */
241    EAPI Eet_File *eet_memopen_read(const void *data, size_t size);
242
243    /**
244     * Get the mode an Eet_File was opened with.
245     * @param ef A valid eet file handle.
246     * @return The mode ef was opened with.
247     *
248     * @since 1.0.0
249     * @ingroup Eet_File_Group
250     */
251    EAPI Eet_File_Mode eet_mode_get(Eet_File *ef);
252
253    /**
254     * Close an eet file handle and flush and writes pending.
255     * @param ef A valid eet file handle.
256     *
257     * This function will flush any pending writes to disk if the eet file
258     * was opened for write, and free all data associated with the file handle
259     * and file, and close the file.
260     *
261     * If the eet file handle is not valid nothing will be done.
262     *
263     * @since 1.0.0
264     * @ingroup Eet_File_Group
265     */
266    EAPI Eet_Error eet_close(Eet_File *ef);
267
268    /**
269     * Sync content of an eet file handle, flushing pending writes.
270     * @param ef A valid eet file handle.
271     *
272     * This function will flush any pending writes to disk. The eet file must
273     * be opened for write.
274     *
275     * If the eet file handle is not valid nothing will be done.
276     *
277     * @since 1.2.4
278     * @ingroup Eet_File_Group
279     */
280    EAPI Eet_Error eet_sync(Eet_File *ef);
281
282    /**
283     * Return a handle to the shared string dictionary of the Eet file
284     * @param ef A valid eet file handle.
285     * @return A handle to the dictionary of the file
286     *
287     * This function returns a handle to the dictionary of an Eet file whose
288     * handle is @p ef, if a dictionary exists. NULL is returned otherwise or
289     * if the file handle is known to be invalid.
290     *
291     * @see eet_dictionary_string_check() to know if given string came
292     *      from the dictionary or it was dynamically allocated using
293     *      the #Eet_Data_Descriptor_Class instructrions.
294     *
295     * @since 1.0.0
296     * @ingroup Eet_File_Group
297     */
298    EAPI Eet_Dictionary *eet_dictionary_get(Eet_File *ef);
299
300    /**
301     * Check if a given string comes from a given dictionary
302     * @param ed A valid dictionary handle
303     * @param string A valid 0 byte terminated C string
304     * @return 1 if it is in the dictionary, 0 otherwise
305     *
306     * This checks the given dictionary to see if the given string is actually
307     * inside that dictionary (i.e. comes from it) and returns 1 if it does.
308     * If the dictionary handle is invlide, the string is NULL or the string is
309     * not in the dictionary, 0 is returned.
310     *
311     * @since 1.0.0
312     * @ingroup Eet_File_Group
313     */
314    EAPI int eet_dictionary_string_check(Eet_Dictionary *ed, const char *string);
315
316    /**
317     * Read a specified entry from an eet file and return data
318     * @param ef A valid eet file handle opened for reading.
319     * @param name Name of the entry. eg: "/base/file_i_want".
320     * @param size_ret Number of bytes read from entry and returned.
321     * @return The data stored in that entry in the eet file.
322     *
323     * This function finds an entry in the eet file that is stored under the
324     * name specified, and returns that data, decompressed, if successful.
325     * NULL is returned if the lookup fails or if memory errors are
326     * encountered. It is the job of the calling program to call free() on
327     * the returned data. The number of bytes in the returned data chunk are
328     * placed in size_ret.
329     *
330     * If the eet file handle is not valid NULL is returned and size_ret is
331     * filled with 0.
332     *
333     * @see eet_read_cipher()
334     *
335     * @since 1.0.0
336     * @ingroup Eet_File_Group
337     */
338    EAPI void *eet_read(Eet_File *ef, const char *name, int *size_ret);
339
340    /**
341     * Read a specified entry from an eet file and return data
342     * @param ef A valid eet file handle opened for reading.
343     * @param name Name of the entry. eg: "/base/file_i_want".
344     * @param size_ret Number of bytes read from entry and returned.
345     * @return The data stored in that entry in the eet file.
346     *
347     * This function finds an entry in the eet file that is stored under the
348     * name specified, and returns that data if not compressed and successful.
349     * NULL is returned if the lookup fails or if memory errors are
350     * encountered or if the data is comrpessed. The calling program must never
351     * call free() on the returned data. The number of bytes in the returned
352     * data chunk are placed in size_ret.
353     *
354     * If the eet file handle is not valid NULL is returned and size_ret is
355     * filled with 0.
356     *
357     * @since 1.0.0
358     * @ingroup Eet_File_Group
359     */
360    EAPI const void *eet_read_direct(Eet_File *ef, const char *name, int *size_ret);
361
362    /**
363     * Write a specified entry to an eet file handle
364     * @param ef A valid eet file handle opened for writing.
365     * @param name Name of the entry. eg: "/base/file_i_want".
366     * @param data Pointer to the data to be stored.
367     * @param size Length in bytes in the data to be stored.
368     * @param compress Compression flags (1 == compress, 0 = don't compress).
369     * @return bytes written on successful write, 0 on failure.
370     *
371     * This function will write the specified chunk of data to the eet file
372     * and return greater than 0 on success. 0 will be returned on failure.
373     *
374     * The eet file handle must be a valid file handle for an eet file opened
375     * for writing. If it is not, 0 will be returned and no action will be
376     * performed.
377     *
378     * Name, and data must not be NULL, and size must be > 0. If these
379     * conditions are not met, 0 will be returned.
380     *
381     * The data will be copied (and optionally compressed) in ram, pending
382     * a flush to disk (it will stay in ram till the eet file handle is
383     * closed though).
384     *
385     * @see eet_write_cipher()
386     *
387     * @since 1.0.0
388     * @ingroup Eet_File_Group
389     */
390    EAPI int eet_write(Eet_File *ef, const char *name, const void *data, int size, int compress);
391
392    /**
393     * Delete a specified entry from an Eet file being written or re-written
394     * @param ef A valid eet file handle opened for writing.
395     * @param name Name of the entry. eg: "/base/file_i_want".
396     * @return Success or failure of the delete.
397     *
398     * This function will delete the specified chunk of data from the eet file
399     * and return greater than 0 on success. 0 will be returned on failure.
400     *
401     * The eet file handle must be a valid file handle for an eet file opened
402     * for writing. If it is not, 0 will be returned and no action will be
403     * performed.
404     *
405     * Name, must not be NULL, otherwise 0 will be returned.
406     *
407     * @since 1.0.0
408     * @ingroup Eet_File_Group
409     */
410    EAPI int eet_delete(Eet_File *ef, const char *name);
411
412    /**
413     * List all entries in eet file matching shell glob.
414     * @param ef A valid eet file handle.
415     * @param glob A shell glob to match against.
416     * @param count_ret Number of entries found to match.
417     * @return Pointer to an array of strings.
418     *
419     * This function will list all entries in the eet file matching the
420     * supplied shell glob and return an allocated list of their names, if
421     * there are any, and if no memory errors occur.
422     *
423     * The eet file handle must be valid and glob must not be NULL, or NULL
424     * will be returned and count_ret will be filled with 0.
425     *
426     * The calling program must call free() on the array returned, but NOT
427     * on the string pointers in the array. They are taken as read-only
428     * internals from the eet file handle. They are only valid as long as
429     * the file handle is not closed. When it is closed those pointers in the
430     * array are now not valid and should not be used.
431     *
432     * On success the array returned will have a list of string pointers
433     * that are the names of the entries that matched, and count_ret will have
434     * the number of entries in this array placed in it.
435     *
436     * Hint: an easy way to list all entries in an eet file is to use a glob
437     * value of "*".
438     *
439     * @since 1.0.0
440     * @ingroup Eet_File_Group
441     */
442    EAPI char **eet_list(Eet_File *ef, const char *glob, int *count_ret);
443
444    /**
445     * Return the number of entries in the specified eet file.
446     * @param ef A valid eet file handle.
447     * @return Number of entries in ef or -1 if the number of entries
448     *         cannot be read due to open mode restrictions.
449     *
450     * @since 1.0.0
451     * @ingroup Eet_File_Group
452     */
453    EAPI int eet_num_entries(Eet_File *ef);
454
455    /**
456     * @defgroup Eet_File_Cipher_Group Eet File Ciphered Main Functions
457     *
458     * Most of the @ref Eet_File_Group have alternative versions that
459     * accounts for ciphers to protect their content.
460     *
461     * @see @ref Eet_Cipher_Group
462     *
463     * @ingroup Eet_File_Group
464     */
465
466    /**
467     * Read a specified entry from an eet file and return data using a cipher.
468     * @param ef A valid eet file handle opened for reading.
469     * @param name Name of the entry. eg: "/base/file_i_want".
470     * @param size_ret Number of bytes read from entry and returned.
471     * @param cipher_key The key to use as cipher.
472     * @return The data stored in that entry in the eet file.
473     *
474     * This function finds an entry in the eet file that is stored under the
475     * name specified, and returns that data, decompressed, if successful.
476     * NULL is returned if the lookup fails or if memory errors are
477     * encountered. It is the job of the calling program to call free() on
478     * the returned data. The number of bytes in the returned data chunk are
479     * placed in size_ret.
480     *
481     * If the eet file handle is not valid NULL is returned and size_ret is
482     * filled with 0.
483     *
484     * @see eet_read()
485     *
486     * @since 1.0.0
487     * @ingroup Eet_File_Cipher_Group
488     */
489    EAPI void *eet_read_cipher(Eet_File *ef, const char *name, int *size_ret, const char *cipher_key);
490
491    /**
492     * Write a specified entry to an eet file handle using a cipher.
493     * @param ef A valid eet file handle opened for writing.
494     * @param name Name of the entry. eg: "/base/file_i_want".
495     * @param data Pointer to the data to be stored.
496     * @param size Length in bytes in the data to be stored.
497     * @param compress Compression flags (1 == compress, 0 = don't compress).
498     * @param cipher_key The key to use as cipher.
499     * @return bytes written on successful write, 0 on failure.
500     *
501     * This function will write the specified chunk of data to the eet file
502     * and return greater than 0 on success. 0 will be returned on failure.
503     *
504     * The eet file handle must be a valid file handle for an eet file opened
505     * for writing. If it is not, 0 will be returned and no action will be
506     * performed.
507     *
508     * Name, and data must not be NULL, and size must be > 0. If these
509     * conditions are not met, 0 will be returned.
510     *
511     * The data will be copied (and optionally compressed) in ram, pending
512     * a flush to disk (it will stay in ram till the eet file handle is
513     * closed though).
514     *
515     * @see eet_write()
516     *
517     * @since 1.0.0
518     * @ingroup Eet_File_Cipher_Group
519     */
520    EAPI int eet_write_cipher(Eet_File *ef, const char *name, const void *data, int size, int compress, const char *cipher_key);
521
522
523    /**
524     * @defgroup Eet_File_Image_Group Image Store and Load
525     *
526     * Eet efficiently stores and loads images, including alpha
527     * channels and lossy compressions.
528     */
529
530    /**
531     * Read just the header data for an image and dont decode the pixels.
532     * @param ef A valid eet file handle opened for reading.
533     * @param name Name of the entry. eg: "/base/file_i_want".
534     * @param w A pointer to the unsigned int to hold the width in pixels.
535     * @param h A pointer to the unsigned int to hold the height in pixels.
536     * @param alpha A pointer to the int to hold the alpha flag.
537     * @param compress A pointer to the int to hold the compression amount.
538     * @param quality A pointer to the int to hold the quality amount.
539     * @param lossy A pointer to the int to hold the lossiness flag.
540     * @return 1 on successfull decode, 0 otherwise
541     *
542     * This function reads an image from an eet file stored under the named
543     * key in the eet file and return a pointer to the decompressed pixel data.
544     *
545     * The other parameters of the image (width, height etc.) are placed into
546     * the values pointed to (they must be supplied). The pixel data is a linear
547     * array of pixels starting from the top-left of the image scanning row by
548     * row from left to right. Each pile is a 32bit value, with the high byte
549     * being the alpha channel, the next being red, then green, and the low byte
550     * being blue. The width and height are measured in pixels and will be
551     * greater than 0 when returned. The alpha flag is either 0 or 1. 0 denotes
552     * that the alpha channel is not used. 1 denotes that it is significant.
553     * Compress is filled with the compression value/amount the image was
554     * stored with. The quality value is filled with the quality encoding of
555     * the image file (0 - 100). The lossy flags is either 0 or 1 as to if
556     * the image was encoded lossily or not.
557     *
558     * On success the function returns 1 indicating the header was read and
559     * decoded properly, or 0 on failure.
560     *
561     * @see eet_data_image_header_read_cipher()
562     *
563     * @since 1.0.0
564     * @ingroup Eet_File_Image_Group
565     */
566    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);
567
568    /**
569     * Read image data from the named key in the eet file.
570     * @param ef A valid eet file handle opened for reading.
571     * @param name Name of the entry. eg: "/base/file_i_want".
572     * @param w A pointer to the unsigned int to hold the width in pixels.
573     * @param h A pointer to the unsigned int to hold the height in pixels.
574     * @param alpha A pointer to the int to hold the alpha flag.
575     * @param compress A pointer to the int to hold the compression amount.
576     * @param quality A pointer to the int to hold the quality amount.
577     * @param lossy A pointer to the int to hold the lossiness flag.
578     * @return The image pixel data decoded
579     *
580     * This function reads an image from an eet file stored under the named
581     * key in the eet file and return a pointer to the decompressed pixel data.
582     *
583     * The other parameters of the image (width, height etc.) are placed into
584     * the values pointed to (they must be supplied). The pixel data is a linear
585     * array of pixels starting from the top-left of the image scanning row by
586     * row from left to right. Each pile is a 32bit value, with the high byte
587     * being the alpha channel, the next being red, then green, and the low byte
588     * being blue. The width and height are measured in pixels and will be
589     * greater than 0 when returned. The alpha flag is either 0 or 1. 0 denotes
590     * that the alpha channel is not used. 1 denotes that it is significant.
591     * Compress is filled with the compression value/amount the image was
592     * stored with. The quality value is filled with the quality encoding of
593     * the image file (0 - 100). The lossy flags is either 0 or 1 as to if
594     * the image was encoded lossily or not.
595     *
596     * On success the function returns a pointer to the image data decoded. The
597     * calling application is responsible for calling free() on the image data
598     * when it is done with it. On failure NULL is returned and the parameter
599     * values may not contain any sensible data.
600     *
601     * @see eet_data_image_read_cipher()
602     *
603     * @since 1.0.0
604     * @ingroup Eet_File_Image_Group
605     */
606    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);
607
608    /**
609     * Read image data from the named key in the eet file.
610     * @param ef A valid eet file handle opened for reading.
611     * @param name Name of the entry. eg: "/base/file_i_want".
612     * @param src_x The starting x coordinate from where to dump the stream.
613     * @param src_y The starting y coordinate from where to dump the stream.
614     * @param d A pointer to the pixel surface.
615     * @param w The expected width in pixels of the pixel surface to decode.
616     * @param h The expected height in pixels of the pixel surface to decode.
617     * @param row_stride The length of a pixels line in the destination surface.
618     * @param alpha A pointer to the int to hold the alpha flag.
619     * @param compress A pointer to the int to hold the compression amount.
620     * @param quality A pointer to the int to hold the quality amount.
621     * @param lossy A pointer to the int to hold the lossiness flag.
622     * @return 1 on success, 0 otherwise.
623     *
624     * This function reads an image from an eet file stored under the named
625     * key in the eet file and return a pointer to the decompressed pixel data.
626     *
627     * The other parameters of the image (width, height etc.) are placed into
628     * the values pointed to (they must be supplied). The pixel data is a linear
629     * array of pixels starting from the top-left of the image scanning row by
630     * row from left to right. Each pile is a 32bit value, with the high byte
631     * being the alpha channel, the next being red, then green, and the low byte
632     * being blue. The width and height are measured in pixels and will be
633     * greater than 0 when returned. The alpha flag is either 0 or 1. 0 denotes
634     * that the alpha channel is not used. 1 denotes that it is significant.
635     * Compress is filled with the compression value/amount the image was
636     * stored with. The quality value is filled with the quality encoding of
637     * the image file (0 - 100). The lossy flags is either 0 or 1 as to if
638     * the image was encoded lossily or not.
639     *
640     * On success the function returns 1, and 0 on failure. On failure the
641     * parameter values may not contain any sensible data.
642     *
643     * @see eet_data_image_read_to_surface_cipher()
644     *
645     * @since 1.0.2
646     * @ingroup Eet_File_Image_Group
647     */
648    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);
649
650    /**
651     * Write image data to the named key in an eet file.
652     * @param ef A valid eet file handle opened for writing.
653     * @param name Name of the entry. eg: "/base/file_i_want".
654     * @param data A pointer to the image pixel data.
655     * @param w The width of the image in pixels.
656     * @param h The height of the image in pixels.
657     * @param alpha The alpha channel flag.
658     * @param compress The compression amount.
659     * @param quality The quality encoding amount.
660     * @param lossy The lossiness flag.
661     * @return Success if the data was encoded and written or not.
662     *
663     * This function takes image pixel data and encodes it in an eet file
664     * stored under the supplied name key, and returns how many bytes were
665     * actually written to encode the image data.
666     *
667     * The data expected is the same format as returned by eet_data_image_read.
668     * If this is not the case weird things may happen. Width and height must
669     * be between 1 and 8000 pixels. The alpha flags can be 0 or 1 (0 meaning
670     * the alpha values are not useful and 1 meaning they are). Compress can
671     * be from 0 to 9 (0 meaning no compression, 9 meaning full compression).
672     * This is only used if the image is not lossily encoded. Quality is used on
673     * lossy compression and should be a value from 0 to 100. The lossy flag
674     * can be 0 or 1. 0 means encode losslessly and 1 means to encode with
675     * image quality loss (but then have a much smaller encoding).
676     *
677     * On success this function returns the number of bytes that were required
678     * to encode the image data, or on failure it returns 0.
679     *
680     * @see eet_data_image_write_cipher()
681     *
682     * @since 1.0.0
683     * @ingroup Eet_File_Image_Group
684     */
685    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);
686
687    /**
688     * Decode Image data header only to get information.
689     * @param data The encoded pixel data.
690     * @param size The size, in bytes, of the encoded pixel data.
691     * @param w A pointer to the unsigned int to hold the width in pixels.
692     * @param h A pointer to the unsigned int to hold the height in pixels.
693     * @param alpha A pointer to the int to hold the alpha flag.
694     * @param compress A pointer to the int to hold the compression amount.
695     * @param quality A pointer to the int to hold the quality amount.
696     * @param lossy A pointer to the int to hold the lossiness flag.
697     * @return 1 on success, 0 on failure.
698     *
699     * This function takes encoded pixel data and decodes it into raw RGBA
700     * pixels on success.
701     *
702     * The other parameters of the image (width, height etc.) are placed into
703     * the values pointed to (they must be supplied). The pixel data is a linear
704     * array of pixels starting from the top-left of the image scanning row by
705     * row from left to right. Each pixel is a 32bit value, with the high byte
706     * being the alpha channel, the next being red, then green, and the low byte
707     * being blue. The width and height are measured in pixels and will be
708     * greater than 0 when returned. The alpha flag is either 0 or 1. 0 denotes
709     * that the alpha channel is not used. 1 denotes that it is significant.
710     * Compress is filled with the compression value/amount the image was
711     * stored with. The quality value is filled with the quality encoding of
712     * the image file (0 - 100). The lossy flags is either 0 or 1 as to if
713     * the image was encoded lossily or not.
714     *
715     * On success the function returns 1 indicating the header was read and
716     * decoded properly, or 0 on failure.
717     *
718     * @see eet_data_image_header_decode_cipher()
719     *
720     * @since 1.0.0
721     * @ingroup Eet_File_Image_Group
722     */
723    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);
724
725    /**
726     * Decode Image data into pixel data.
727     * @param data The encoded pixel data.
728     * @param size The size, in bytes, of the encoded pixel data.
729     * @param w A pointer to the unsigned int to hold the width in pixels.
730     * @param h A pointer to the unsigned int to hold the height in pixels.
731     * @param alpha A pointer to the int to hold the alpha flag.
732     * @param compress A pointer to the int to hold the compression amount.
733     * @param quality A pointer to the int to hold the quality amount.
734     * @param lossy A pointer to the int to hold the lossiness flag.
735     * @return The image pixel data decoded
736     *
737     * This function takes encoded pixel data and decodes it into raw RGBA
738     * pixels on success.
739     *
740     * The other parameters of the image (width, height etc.) are placed into
741     * the values pointed to (they must be supplied). The pixel data is a linear
742     * array of pixels starting from the top-left of the image scanning row by
743     * row from left to right. Each pixel is a 32bit value, with the high byte
744     * being the alpha channel, the next being red, then green, and the low byte
745     * being blue. The width and height are measured in pixels and will be
746     * greater than 0 when returned. The alpha flag is either 0 or 1. 0 denotes
747     * that the alpha channel is not used. 1 denotes that it is significant.
748     * Compress is filled with the compression value/amount the image was
749     * stored with. The quality value is filled with the quality encoding of
750     * the image file (0 - 100). The lossy flags is either 0 or 1 as to if
751     * the image was encoded lossily or not.
752     *
753     * On success the function returns a pointer to the image data decoded. The
754     * calling application is responsible for calling free() on the image data
755     * when it is done with it. On failure NULL is returned and the parameter
756     * values may not contain any sensible data.
757     *
758     * @see eet_data_image_decode_cipher()
759     *
760     * @since 1.0.0
761     * @ingroup Eet_File_Image_Group
762     */
763    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);
764
765    /**
766     * Decode Image data into pixel data.
767     * @param data The encoded pixel data.
768     * @param size The size, in bytes, of the encoded pixel data.
769     * @param src_x The starting x coordinate from where to dump the stream.
770     * @param src_y The starting y coordinate from where to dump the stream.
771     * @param d A pointer to the pixel surface.
772     * @param w The expected width in pixels of the pixel surface to decode.
773     * @param h The expected height in pixels of the pixel surface to decode.
774     * @param row_stride The length of a pixels line in the destination surface.
775     * @param alpha A pointer to the int to hold the alpha flag.
776     * @param compress A pointer to the int to hold the compression amount.
777     * @param quality A pointer to the int to hold the quality amount.
778     * @param lossy A pointer to the int to hold the lossiness flag.
779     * @return 1 on success, 0 otherwise.
780     *
781     * This function takes encoded pixel data and decodes it into raw RGBA
782     * pixels on success.
783     *
784     * The other parameters of the image (alpha, compress etc.) are placed into
785     * the values pointed to (they must be supplied). The pixel data is a linear
786     * array of pixels starting from the top-left of the image scanning row by
787     * row from left to right. Each pixel is a 32bit value, with the high byte
788     * being the alpha channel, the next being red, then green, and the low byte
789     * being blue. The width and height are measured in pixels and will be
790     * greater than 0 when returned. The alpha flag is either 0 or 1. 0 denotes
791     * that the alpha channel is not used. 1 denotes that it is significant.
792     * Compress is filled with the compression value/amount the image was
793     * stored with. The quality value is filled with the quality encoding of
794     * the image file (0 - 100). The lossy flags is either 0 or 1 as to if
795     * the image was encoded lossily or not.
796     *
797     * On success the function returns 1, and 0 on failure. On failure the
798     * parameter values may not contain any sensible data.
799     *
800     * @see eet_data_image_decode_to_surface_cipher()
801     *
802     * @since 1.0.2
803     * @ingroup Eet_File_Image_Group
804     */
805    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);
806
807    /**
808     * Encode image data for storage or transmission.
809     * @param data A pointer to the image pixel data.
810     * @param size_ret A pointer to an int to hold the size of the returned data.
811     * @param w The width of the image in pixels.
812     * @param h The height of the image in pixels.
813     * @param alpha The alpha channel flag.
814     * @param compress The compression amount.
815     * @param quality The quality encoding amount.
816     * @param lossy The lossiness flag.
817     * @return The encoded image data.
818     *
819     * This function stakes image pixel data and encodes it with compression and
820     * possible loss of quality (as a trade off for size) for storage or
821     * transmission to another system.
822     *
823     * The data expected is the same format as returned by eet_data_image_read.
824     * If this is not the case weird things may happen. Width and height must
825     * be between 1 and 8000 pixels. The alpha flags can be 0 or 1 (0 meaning
826     * the alpha values are not useful and 1 meaning they are). Compress can
827     * be from 0 to 9 (0 meaning no compression, 9 meaning full compression).
828     * This is only used if the image is not lossily encoded. Quality is used on
829     * lossy compression and should be a value from 0 to 100. The lossy flag
830     * can be 0 or 1. 0 means encode losslessly and 1 means to encode with
831     * image quality loss (but then have a much smaller encoding).
832     *
833     * On success this function returns a pointer to the encoded data that you
834     * can free with free() when no longer needed.
835     *
836     * @see eet_data_image_encode_cipher()
837     *
838     * @since 1.0.0
839     * @ingroup Eet_File_Image_Group
840     */
841    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);
842
843    /**
844     * @defgroup Eet_File_Image_Cipher_Group Image Store and Load using a Cipher
845     *
846     * Most of the @ref Eet_File_Image_Group have alternative versions
847     * that accounts for ciphers to protect their content.
848     *
849     * @see @ref Eet_Cipher_Group
850     *
851     * @ingroup Eet_File_Image_Group
852     */
853
854    /**
855     * Read just the header data for an image and dont decode the pixels using a cipher.
856     * @param ef A valid eet file handle opened for reading.
857     * @param name Name of the entry. eg: "/base/file_i_want".
858     * @param cipher_key The key to use as cipher.
859     * @param w A pointer to the unsigned int to hold the width in pixels.
860     * @param h A pointer to the unsigned int to hold the height in pixels.
861     * @param alpha A pointer to the int to hold the alpha flag.
862     * @param compress A pointer to the int to hold the compression amount.
863     * @param quality A pointer to the int to hold the quality amount.
864     * @param lossy A pointer to the int to hold the lossiness flag.
865     * @return 1 on successfull decode, 0 otherwise
866     *
867     * This function reads an image from an eet file stored under the named
868     * key in the eet file and return a pointer to the decompressed pixel data.
869     *
870     * The other parameters of the image (width, height etc.) are placed into
871     * the values pointed to (they must be supplied). The pixel data is a linear
872     * array of pixels starting from the top-left of the image scanning row by
873     * row from left to right. Each pile is a 32bit value, with the high byte
874     * being the alpha channel, the next being red, then green, and the low byte
875     * being blue. The width and height are measured in pixels and will be
876     * greater than 0 when returned. The alpha flag is either 0 or 1. 0 denotes
877     * that the alpha channel is not used. 1 denotes that it is significant.
878     * Compress is filled with the compression value/amount the image was
879     * stored with. The quality value is filled with the quality encoding of
880     * the image file (0 - 100). The lossy flags is either 0 or 1 as to if
881     * the image was encoded lossily or not.
882     *
883     * On success the function returns 1 indicating the header was read and
884     * decoded properly, or 0 on failure.
885     *
886     * @see eet_data_image_header_read()
887     *
888     * @since 1.0.0
889     * @ingroup Eet_File_Image_Cipher_Group
890     */
891    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);
892
893    /**
894     * Read image data from the named key in the eet file using a cipher.
895     * @param ef A valid eet file handle opened for reading.
896     * @param name Name of the entry. eg: "/base/file_i_want".
897     * @param cipher_key The key to use as cipher.
898     * @param w A pointer to the unsigned int to hold the width in pixels.
899     * @param h A pointer to the unsigned int to hold the height in pixels.
900     * @param alpha A pointer to the int to hold the alpha flag.
901     * @param compress A pointer to the int to hold the compression amount.
902     * @param quality A pointer to the int to hold the quality amount.
903     * @param lossy A pointer to the int to hold the lossiness flag.
904     * @return The image pixel data decoded
905     *
906     * This function reads an image from an eet file stored under the named
907     * key in the eet file and return a pointer to the decompressed pixel data.
908     *
909     * The other parameters of the image (width, height etc.) are placed into
910     * the values pointed to (they must be supplied). The pixel data is a linear
911     * array of pixels starting from the top-left of the image scanning row by
912     * row from left to right. Each pile is a 32bit value, with the high byte
913     * being the alpha channel, the next being red, then green, and the low byte
914     * being blue. The width and height are measured in pixels and will be
915     * greater than 0 when returned. The alpha flag is either 0 or 1. 0 denotes
916     * that the alpha channel is not used. 1 denotes that it is significant.
917     * Compress is filled with the compression value/amount the image was
918     * stored with. The quality value is filled with the quality encoding of
919     * the image file (0 - 100). The lossy flags is either 0 or 1 as to if
920     * the image was encoded lossily or not.
921     *
922     * On success the function returns a pointer to the image data decoded. The
923     * calling application is responsible for calling free() on the image data
924     * when it is done with it. On failure NULL is returned and the parameter
925     * values may not contain any sensible data.
926     *
927     * @see eet_data_image_read()
928     *
929     * @since 1.0.0
930     * @ingroup Eet_File_Image_Cipher_Group
931     */
932    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);
933
934    /**
935     * Read image data from the named key in the eet file using a cipher.
936     * @param ef A valid eet file handle opened for reading.
937     * @param name Name of the entry. eg: "/base/file_i_want".
938     * @param cipher_key The key to use as cipher.
939     * @param src_x The starting x coordinate from where to dump the stream.
940     * @param src_y The starting y coordinate from where to dump the stream.
941     * @param d A pointer to the pixel surface.
942     * @param w The expected width in pixels of the pixel surface to decode.
943     * @param h The expected height in pixels of the pixel surface to decode.
944     * @param row_stride The length of a pixels line in the destination surface.
945     * @param alpha A pointer to the int to hold the alpha flag.
946     * @param compress A pointer to the int to hold the compression amount.
947     * @param quality A pointer to the int to hold the quality amount.
948     * @param lossy A pointer to the int to hold the lossiness flag.
949     * @return 1 on success, 0 otherwise.
950     *
951     * This function reads an image from an eet file stored under the named
952     * key in the eet file and return a pointer to the decompressed pixel data.
953     *
954     * The other parameters of the image (width, height etc.) are placed into
955     * the values pointed to (they must be supplied). The pixel data is a linear
956     * array of pixels starting from the top-left of the image scanning row by
957     * row from left to right. Each pile is a 32bit value, with the high byte
958     * being the alpha channel, the next being red, then green, and the low byte
959     * being blue. The width and height are measured in pixels and will be
960     * greater than 0 when returned. The alpha flag is either 0 or 1. 0 denotes
961     * that the alpha channel is not used. 1 denotes that it is significant.
962     * Compress is filled with the compression value/amount the image was
963     * stored with. The quality value is filled with the quality encoding of
964     * the image file (0 - 100). The lossy flags is either 0 or 1 as to if
965     * the image was encoded lossily or not.
966     *
967     * On success the function returns 1, and 0 on failure. On failure the
968     * parameter values may not contain any sensible data.
969     *
970     * @see eet_data_image_read_to_surface()
971     *
972     * @since 1.0.2
973     * @ingroup Eet_File_Image_Cipher_Group
974     */
975    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);
976
977    /**
978     * Write image data to the named key in an eet file using a cipher.
979     * @param ef A valid eet file handle opened for writing.
980     * @param name Name of the entry. eg: "/base/file_i_want".
981     * @param cipher_key The key to use as cipher.
982     * @param data A pointer to the image pixel data.
983     * @param w The width of the image in pixels.
984     * @param h The height of the image in pixels.
985     * @param alpha The alpha channel flag.
986     * @param compress The compression amount.
987     * @param quality The quality encoding amount.
988     * @param lossy The lossiness flag.
989     * @return Success if the data was encoded and written or not.
990     *
991     * This function takes image pixel data and encodes it in an eet file
992     * stored under the supplied name key, and returns how many bytes were
993     * actually written to encode the image data.
994     *
995     * The data expected is the same format as returned by eet_data_image_read.
996     * If this is not the case weird things may happen. Width and height must
997     * be between 1 and 8000 pixels. The alpha flags can be 0 or 1 (0 meaning
998     * the alpha values are not useful and 1 meaning they are). Compress can
999     * be from 0 to 9 (0 meaning no compression, 9 meaning full compression).
1000     * This is only used if the image is not lossily encoded. Quality is used on
1001     * lossy compression and should be a value from 0 to 100. The lossy flag
1002     * can be 0 or 1. 0 means encode losslessly and 1 means to encode with
1003     * image quality loss (but then have a much smaller encoding).
1004     *
1005     * On success this function returns the number of bytes that were required
1006     * to encode the image data, or on failure it returns 0.
1007     *
1008     * @see eet_data_image_write()
1009     *
1010     * @since 1.0.0
1011     * @ingroup Eet_File_Image_Cipher_Group
1012     */
1013    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);
1014
1015
1016    /**
1017     * Decode Image data header only to get information using a cipher.
1018     * @param data The encoded pixel data.
1019     * @param cipher_key The key to use as cipher.
1020     * @param size The size, in bytes, of the encoded pixel data.
1021     * @param w A pointer to the unsigned int to hold the width in pixels.
1022     * @param h A pointer to the unsigned int to hold the height in pixels.
1023     * @param alpha A pointer to the int to hold the alpha flag.
1024     * @param compress A pointer to the int to hold the compression amount.
1025     * @param quality A pointer to the int to hold the quality amount.
1026     * @param lossy A pointer to the int to hold the lossiness flag.
1027     * @return 1 on success, 0 on failure.
1028     *
1029     * This function takes encoded pixel data and decodes it into raw RGBA
1030     * pixels on success.
1031     *
1032     * The other parameters of the image (width, height etc.) are placed into
1033     * the values pointed to (they must be supplied). The pixel data is a linear
1034     * array of pixels starting from the top-left of the image scanning row by
1035     * row from left to right. Each pixel is a 32bit value, with the high byte
1036     * being the alpha channel, the next being red, then green, and the low byte
1037     * being blue. The width and height are measured in pixels and will be
1038     * greater than 0 when returned. The alpha flag is either 0 or 1. 0 denotes
1039     * that the alpha channel is not used. 1 denotes that it is significant.
1040     * Compress is filled with the compression value/amount the image was
1041     * stored with. The quality value is filled with the quality encoding of
1042     * the image file (0 - 100). The lossy flags is either 0 or 1 as to if
1043     * the image was encoded lossily or not.
1044     *
1045     * On success the function returns 1 indicating the header was read and
1046     * decoded properly, or 0 on failure.
1047     *
1048     * @see eet_data_image_header_decode()
1049     *
1050     * @since 1.0.0
1051     * @ingroup Eet_File_Image_Cipher_Group
1052     */
1053    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);
1054
1055    /**
1056     * Decode Image data into pixel data using a cipher.
1057     * @param data The encoded pixel data.
1058     * @param cipher_key The key to use as cipher.
1059     * @param size The size, in bytes, of the encoded pixel data.
1060     * @param w A pointer to the unsigned int to hold the width in pixels.
1061     * @param h A pointer to the unsigned int to hold the height in pixels.
1062     * @param alpha A pointer to the int to hold the alpha flag.
1063     * @param compress A pointer to the int to hold the compression amount.
1064     * @param quality A pointer to the int to hold the quality amount.
1065     * @param lossy A pointer to the int to hold the lossiness flag.
1066     * @return The image pixel data decoded
1067     *
1068     * This function takes encoded pixel data and decodes it into raw RGBA
1069     * pixels on success.
1070     *
1071     * The other parameters of the image (width, height etc.) are placed into
1072     * the values pointed to (they must be supplied). The pixel data is a linear
1073     * array of pixels starting from the top-left of the image scanning row by
1074     * row from left to right. Each pixel is a 32bit value, with the high byte
1075     * being the alpha channel, the next being red, then green, and the low byte
1076     * being blue. The width and height are measured in pixels and will be
1077     * greater than 0 when returned. The alpha flag is either 0 or 1. 0 denotes
1078     * that the alpha channel is not used. 1 denotes that it is significant.
1079     * Compress is filled with the compression value/amount the image was
1080     * stored with. The quality value is filled with the quality encoding of
1081     * the image file (0 - 100). The lossy flags is either 0 or 1 as to if
1082     * the image was encoded lossily or not.
1083     *
1084     * On success the function returns a pointer to the image data decoded. The
1085     * calling application is responsible for calling free() on the image data
1086     * when it is done with it. On failure NULL is returned and the parameter
1087     * values may not contain any sensible data.
1088     *
1089     * @see eet_data_image_decode()
1090     *
1091     * @since 1.0.0
1092     * @ingroup Eet_File_Image_Cipher_Group
1093     */
1094    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);
1095
1096    /**
1097     * Decode Image data into pixel data using a cipher.
1098     * @param data The encoded pixel data.
1099     * @param cipher_key The key to use as cipher.
1100     * @param size The size, in bytes, of the encoded pixel data.
1101     * @param src_x The starting x coordinate from where to dump the stream.
1102     * @param src_y The starting y coordinate from where to dump the stream.
1103     * @param d A pointer to the pixel surface.
1104     * @param w The expected width in pixels of the pixel surface to decode.
1105     * @param h The expected height in pixels of the pixel surface to decode.
1106     * @param row_stride The length of a pixels line in the destination surface.
1107     * @param alpha A pointer to the int to hold the alpha flag.
1108     * @param compress A pointer to the int to hold the compression amount.
1109     * @param quality A pointer to the int to hold the quality amount.
1110     * @param lossy A pointer to the int to hold the lossiness flag.
1111     * @return 1 on success, 0 otherwise.
1112     *
1113     * This function takes encoded pixel data and decodes it into raw RGBA
1114     * pixels on success.
1115     *
1116     * The other parameters of the image (alpha, compress etc.) are placed into
1117     * the values pointed to (they must be supplied). The pixel data is a linear
1118     * array of pixels starting from the top-left of the image scanning row by
1119     * row from left to right. Each pixel is a 32bit value, with the high byte
1120     * being the alpha channel, the next being red, then green, and the low byte
1121     * being blue. The width and height are measured in pixels and will be
1122     * greater than 0 when returned. The alpha flag is either 0 or 1. 0 denotes
1123     * that the alpha channel is not used. 1 denotes that it is significant.
1124     * Compress is filled with the compression value/amount the image was
1125     * stored with. The quality value is filled with the quality encoding of
1126     * the image file (0 - 100). The lossy flags is either 0 or 1 as to if
1127     * the image was encoded lossily or not.
1128     *
1129     * On success the function returns 1, and 0 on failure. On failure the
1130     * parameter values may not contain any sensible data.
1131     *
1132     * @see eet_data_image_decode_to_surface()
1133     *
1134     * @since 1.0.2
1135     * @ingroup Eet_File_Image_Cipher_Group
1136     */
1137    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);
1138
1139    /**
1140     * Encode image data for storage or transmission using a cipher.
1141     * @param data A pointer to the image pixel data.
1142     * @param cipher_key The key to use as cipher.
1143     * @param size_ret A pointer to an int to hold the size of the returned data.
1144     * @param w The width of the image in pixels.
1145     * @param h The height of the image in pixels.
1146     * @param alpha The alpha channel flag.
1147     * @param compress The compression amount.
1148     * @param quality The quality encoding amount.
1149     * @param lossy The lossiness flag.
1150     * @return The encoded image data.
1151     *
1152     * This function stakes image pixel data and encodes it with compression and
1153     * possible loss of quality (as a trade off for size) for storage or
1154     * transmission to another system.
1155     *
1156     * The data expected is the same format as returned by eet_data_image_read.
1157     * If this is not the case weird things may happen. Width and height must
1158     * be between 1 and 8000 pixels. The alpha flags can be 0 or 1 (0 meaning
1159     * the alpha values are not useful and 1 meaning they are). Compress can
1160     * be from 0 to 9 (0 meaning no compression, 9 meaning full compression).
1161     * This is only used if the image is not lossily encoded. Quality is used on
1162     * lossy compression and should be a value from 0 to 100. The lossy flag
1163     * can be 0 or 1. 0 means encode losslessly and 1 means to encode with
1164     * image quality loss (but then have a much smaller encoding).
1165     *
1166     * On success this function returns a pointer to the encoded data that you
1167     * can free with free() when no longer needed.
1168     *
1169     * @see eet_data_image_encode()
1170     *
1171     * @since 1.0.0
1172     * @ingroup Eet_File_Image_Cipher_Group
1173     */
1174    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);
1175
1176
1177    /**
1178     * @defgroup Eet_Cipher_Group Cipher, Identity and Protection Mechanisms
1179     *
1180     * Eet allows one to protect entries of an #Eet_File
1181     * individually. This may be used to ensure data was not tampered or
1182     * that third party does not read your data.
1183     *
1184     * @see @ref Eet_File_Cipher_Group
1185     * @see @ref Eet_File_Image_Cipher_Group
1186     *
1187     * @{
1188     */
1189
1190    /**
1191     * @typedef Eet_Key
1192     * Opaque handle that defines an identity (also known as key)
1193     * in Eet's cipher system.
1194     */
1195    typedef struct _Eet_Key Eet_Key;
1196
1197    /**
1198     * @}
1199     */
1200
1201
1202    /**
1203     * Callback used to request if needed the password of a private key.
1204     *
1205     * @param buffer the buffer where to store the password.
1206     * @param size the maximum password size (size of buffer, including '@\0').
1207     * @param rwflag if the buffer is also readable or just writable.
1208     * @param data currently unused, may contain some context in future.
1209     * @return 1 on success and password was set to @p buffer, 0 on failure.
1210     *
1211     * @since 1.2.0
1212     * @ingroup Eet_Cipher_Group
1213     */
1214    typedef int (*Eet_Key_Password_Callback)(char *buffer, int size, int rwflag, void *data);
1215
1216    /**
1217     * Create an Eet_Key needed for signing an eet file.
1218     *
1219     * The certificate should provide the public that match the private key.
1220     * No verification is done to ensure that.
1221     *
1222     * @param certificate_file The file where to find the certificate.
1223     * @param private_key_file The file that contains the private key.
1224     * @param cb Function to callback if password is required to unlock
1225     *        private key.
1226     * @return A key handle to use, or @c NULL on failure.
1227     *
1228     * @see eet_identity_close()
1229     *
1230     * @since 1.2.0
1231     * @ingroup Eet_Cipher_Group
1232     */
1233    EAPI Eet_Key* eet_identity_open(const char *certificate_file, const char *private_key_file, Eet_Key_Password_Callback cb);
1234
1235    /**
1236     * Close and release all ressource used by an Eet_Key.  An
1237     * reference counter prevent it from being freed until all file
1238     * using it are also closed.
1239     *
1240     * @param key the key handle to close and free resources.
1241     *
1242     * @since 1.2.0
1243     * @ingroup Eet_Cipher_Group
1244     */
1245    EAPI void eet_identity_close(Eet_Key *key);
1246
1247    /**
1248     * Set a key to sign a file
1249     *
1250     * @param ef the file to set the identity.
1251     * @param key the key handle to set as identity.
1252     * @return #EET_ERROR_BAD_OBJECT if @p ef is invalid or
1253     *         #EET_ERROR_NONE on success.
1254     *
1255     * @since 1.2.0
1256     * @ingroup Eet_Cipher_Group
1257     */
1258    EAPI Eet_Error eet_identity_set(Eet_File *ef, Eet_Key *key);
1259
1260    /**
1261     * Display both private and public key of an Eet_Key.
1262     *
1263     * @param key the handle to print.
1264     * @param out where to print.
1265     *
1266     * @since 1.2.0
1267     * @ingroup Eet_Cipher_Group
1268     */
1269    EAPI void eet_identity_print(Eet_Key *key, FILE *out);
1270
1271    /**
1272     * Get the x509 der certificate associated with an Eet_File. Will return NULL
1273     * if the file is not signed.
1274     *
1275     * @param ef The file handle to query.
1276     * @param der_length The length of returned data, may be @c NULL.
1277     * @return the x509 certificate or @c NULL on error.
1278     *
1279     * @since 1.2.0
1280     * @ingroup Eet_Cipher_Group
1281     */
1282    EAPI const void *eet_identity_x509(Eet_File *ef, int *der_length);
1283
1284    /**
1285     * Get the raw signature associated with an Eet_File. Will return NULL
1286     * if the file is not signed.
1287     *
1288     * @param ef The file handle to query.
1289     * @param signature_length The length of returned data, may be @c NULL.
1290     * @return the raw signature or @c NULL on error.
1291     *
1292     * @ingroup Eet_Cipher_Group
1293     */
1294    EAPI const void *eet_identity_signature(Eet_File *ef, int *signature_length);
1295
1296    /**
1297     * Get the SHA1 associated with a file. Could be the one used to
1298     * sign the data or if the data where not signed, it will be the
1299     * SHA1 of the file.
1300     *
1301     * @param ef The file handle to query.
1302     * @param sha1_length The length of returned data, may be @c NULL.
1303     * @return the associated SHA1 or @c NULL on error.
1304     *
1305     * @since 1.2.0
1306     * @ingroup Eet_Cipher_Group
1307     */
1308    EAPI const void *eet_identity_sha1(Eet_File *ef, int *sha1_length);
1309
1310    /**
1311     * Display the x509 der certificate to out.
1312     *
1313     * @param certificate the x509 certificate to print
1314     * @param der_length The length the certificate.
1315     * @param out where to print.
1316     *
1317     * @since 1.2.0
1318     * @ingroup Eet_Cipher_Group
1319     */
1320    EAPI void eet_identity_certificate_print(const unsigned char *certificate, int der_length, FILE *out);
1321
1322
1323    /**
1324     * @defgroup Eet_Data_Group Eet Data Serialization
1325     *
1326     * Convenience functions to serialize and parse complex data
1327     * structures to binary blobs.
1328     *
1329     * While Eet core just handles binary blobs, it is often required
1330     * to save some structured data of different types, such as
1331     * strings, integers, lists, hashes and so on.
1332     *
1333     * Eet can serialize and then parse data types given some
1334     * construction instructions. These are defined in two levels:
1335     *
1336     * - #Eet_Data_Descriptor_Class to tell generic memory handling,
1337     *   such as the size of the type, how to allocate memory, strings,
1338     *   lists, hashes and so on.
1339     *
1340     * - #Eet_Data_Descriptor to tell inside such type, the members and
1341     *   their offsets inside the memory blob, their types and
1342     *   names. These members can be simple types or other
1343     *   #Eet_Data_Descriptor, allowing hierarchical types to be
1344     *   defined.
1345     *
1346     * Given that C provides no introspection, this process can be
1347     * quite cumbersome, so we provide lots of macros and convenience
1348     * functions to aid creating the types.
1349     *
1350     * Example:
1351     *
1352     * @code
1353     * #include <Eet.h>
1354     * #include <Evas.h>
1355     *
1356     * typedef struct _blah2
1357     * {
1358     *    char *string;
1359     * } Blah2;
1360     *
1361     * typedef struct _blah3
1362     * {
1363     *    char *string;
1364     * } Blah3;
1365     *
1366     * typedef struct _blah
1367     * {
1368     *    char character;
1369     *    short sixteen;
1370     *    int integer;
1371     *    long long lots;
1372     *    float floating;
1373     *    double floating_lots;
1374     *    char *string;
1375     *    Blah2 *blah2;
1376     *    Eina_List *blah3;
1377     * } Blah;
1378     *
1379     * int
1380     * main(int argc, char **argv)
1381     * {
1382     *    Blah blah;
1383     *    Blah2 blah2;
1384     *    Blah3 blah3;
1385     *    Eet_Data_Descriptor *edd, *edd2, *edd3;
1386     *    Eet_Data_Descriptor_Class eddc, eddc2, eddc3;
1387     *    void *data;
1388     *    int size;
1389     *    FILE *f;
1390     *    Blah *blah_in;
1391     *
1392     *    eet_init();
1393     *
1394     *    EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eddc3, Blah3);
1395     *    edd3 = eet_data_descriptor_stream_new(&eddc3);
1396     *    EET_DATA_DESCRIPTOR_ADD_BASIC(edd3, Blah3, "string3", string, EET_T_STRING);
1397     *
1398     *    EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eddc2, Blah2);
1399     *    edd2 = eet_data_descriptor_stream_new(&eddc2);
1400     *    EET_DATA_DESCRIPTOR_ADD_BASIC(edd2, Blah2, "string2", string, EET_T_STRING);
1401     *
1402     *    EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eddc, Blah);
1403     *    edd = eet_data_descriptor_stream_new(&eddc);
1404     *    EET_DATA_DESCRIPTOR_ADD_BASIC(edd, Blah, "character", character, EET_T_CHAR);
1405     *    EET_DATA_DESCRIPTOR_ADD_BASIC(edd, Blah, "sixteen", sixteen, EET_T_SHORT);
1406     *    EET_DATA_DESCRIPTOR_ADD_BASIC(edd, Blah, "integer", integer, EET_T_INT);
1407     *    EET_DATA_DESCRIPTOR_ADD_BASIC(edd, Blah, "lots", lots, EET_T_LONG_LONG);
1408     *    EET_DATA_DESCRIPTOR_ADD_BASIC(edd, Blah, "floating", floating, EET_T_FLOAT);
1409     *    EET_DATA_DESCRIPTOR_ADD_BASIC(edd, Blah, "floating_lots", floating_lots, EET_T_DOUBLE);
1410     *    EET_DATA_DESCRIPTOR_ADD_BASIC(edd, Blah, "string", string, EET_T_STRING);
1411     *    EET_DATA_DESCRIPTOR_ADD_SUB(edd, Blah, "blah2", blah2, edd2);
1412     *    EET_DATA_DESCRIPTOR_ADD_LIST(edd, Blah, "blah3", blah3, edd3);
1413     *
1414     *    blah3.string = "PANTS";
1415     *
1416     *    blah2.string = "subtype string here!";
1417     *
1418     *    blah.character = '7';
1419     *    blah.sixteen = 0x7777;
1420     *    blah.integer = 0xc0def00d;
1421     *    blah.lots = 0xdeadbeef31337777;
1422     *    blah.floating = 3.141592654;
1423     *    blah.floating_lots = 0.777777777777777;
1424     *    blah.string = "bite me like a turnip";
1425     *    blah.blah2 = &blah2;
1426     *    blah.blah3 = eina_list_append(NULL, &blah3);
1427     *    blah.blah3 = eina_list_append(blah.blah3, &blah3);
1428     *    blah.blah3 = eina_list_append(blah.blah3, &blah3);
1429     *    blah.blah3 = eina_list_append(blah.blah3, &blah3);
1430     *    blah.blah3 = eina_list_append(blah.blah3, &blah3);
1431     *    blah.blah3 = eina_list_append(blah.blah3, &blah3);
1432     *    blah.blah3 = eina_list_append(blah.blah3, &blah3);
1433     *
1434     *    data = eet_data_descriptor_encode(edd, &blah, &size);
1435     *    printf("-----DECODING\n");
1436     *    blah_in = eet_data_descriptor_decode(edd, data, size);
1437     *
1438     *    printf("-----DECODED!\n");
1439     *    printf("%c\n", blah_in->character);
1440     *    printf("%x\n", (int)blah_in->sixteen);
1441     *    printf("%x\n", blah_in->integer);
1442     *    printf("%lx\n", blah_in->lots);
1443     *    printf("%f\n", (double)blah_in->floating);
1444     *    printf("%f\n", (double)blah_in->floating_lots);
1445     *    printf("%s\n", blah_in->string);
1446     *    printf("%p\n", blah_in->blah2);
1447     *    printf("  %s\n", blah_in->blah2->string);
1448     *      {
1449     *         Eina_List *l;
1450     *         Blah3 *blah3_in;
1451     *
1452     *         EINA_LIST_FOREACH(blah_in->blah3, l, blah3_in)
1453     *           {
1454     *              printf("%p\n", blah3_in);
1455     *              printf("  %s\n", blah3_in->string);
1456     *           }
1457     *      }
1458     *    eet_data_descriptor_free(edd);
1459     *    eet_data_descriptor_free(edd2);
1460     *    eet_data_descriptor_free(edd3);
1461     *
1462     *    eet_shutdown();
1463     *
1464     *   return 0;
1465     * }
1466     * @endcode
1467     *
1468     * @{
1469     */
1470 #define EET_T_UNKNOW            0 /**< Unknown data encoding type */
1471 #define EET_T_CHAR              1 /**< Data type: char */
1472 #define EET_T_SHORT             2 /**< Data type: short */
1473 #define EET_T_INT               3 /**< Data type: int */
1474 #define EET_T_LONG_LONG         4 /**< Data type: long long */
1475 #define EET_T_FLOAT             5 /**< Data type: float */
1476 #define EET_T_DOUBLE            6 /**< Data type: double */
1477 #define EET_T_UCHAR             7 /**< Data type: unsigned char */
1478 #define EET_T_USHORT            8 /**< Data type: unsigned short */
1479 #define EET_T_UINT              9 /**< Data type: unsigned int */
1480 #define EET_T_ULONG_LONG        10 /**< Data type: unsigned long long */
1481 #define EET_T_STRING            11 /**< Data type: char * */
1482 #define EET_T_INLINED_STRING    12 /**< Data type: char * (but compressed inside the resulting eet) */
1483 #define EET_T_NULL              13 /**< Data type: (void *) (only use it if you know why) */
1484 #define EET_T_F32P32            14 /**< Data type:  */
1485 #define EET_T_F16P16            15 /**< Data type:  */
1486 #define EET_T_F8P24             16 /**< Data type:  */
1487 #define EET_T_LAST              17 /**< Last data type */
1488
1489 #define EET_G_UNKNOWN    100 /**< Unknown group data encoding type */
1490 #define EET_G_ARRAY      101 /**< Fixed size array group type */
1491 #define EET_G_VAR_ARRAY  102 /**< Variable size array group type */
1492 #define EET_G_LIST       103 /**< Linked list group type */
1493 #define EET_G_HASH       104 /**< Hash table group type */
1494 #define EET_G_UNION      105 /**< Union group type */
1495 #define EET_G_INHERIT    106 /**< Inherit object group type */
1496 #define EET_G_VARIANT    107 /**< Selectable subtype group */
1497 #define EET_G_LAST       108 /**< Last group type */
1498
1499 #define EET_I_LIMIT      128 /**< Other type exist but are reserved for internal purpose. */
1500
1501    /**
1502     * @typedef Eet_Data_Descriptor
1503     *
1504     * Opaque handle that have information on a type members.
1505     *
1506     * The members are added by means of
1507     * EET_DATA_DESCRIPTOR_ADD_BASIC(), EET_DATA_DESCRIPTOR_ADD_SUB(),
1508     * EET_DATA_DESCRIPTOR_ADD_LIST(), EET_DATA_DESCRIPTOR_ADD_HASH()
1509     * or eet_data_descriptor_element_add().
1510     *
1511     * @see eet_data_descriptor_stream_new()
1512     * @see eet_data_descriptor_file_new()
1513     * @see eet_data_descriptor_free()
1514     */
1515    typedef struct _Eet_Data_Descriptor       Eet_Data_Descriptor;
1516
1517    /**
1518     * @def EET_DATA_DESCRIPTOR_CLASS_VERSION
1519     * The version of #Eet_Data_Descriptor_Class at the time of the
1520     * distribution of the sources. One should define this to its
1521     * version member so it is compatible with abi changes, or at least
1522     * will not crash with them.
1523     */
1524 #define EET_DATA_DESCRIPTOR_CLASS_VERSION 3
1525
1526   /**
1527    * @typedef Eet_Data_Descriptor_Class
1528    *
1529    * Instructs Eet about memory management for different needs under
1530    * serialization and parse process.
1531    */
1532    typedef struct _Eet_Data_Descriptor_Class Eet_Data_Descriptor_Class;
1533
1534    /**
1535     * @struct _Eet_Data_Descriptor_Class
1536     *
1537     * Instructs Eet about memory management for different needs under
1538     * serialization and parse process.
1539     *
1540     * If using Eina data types, it is advised to use the helpers
1541     * EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET() and
1542     * EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET().
1543     */
1544    struct _Eet_Data_Descriptor_Class
1545      {
1546         int         version; /**< ABI version as #EET_DATA_DESCRIPTOR_CLASS_VERSION */
1547         const char *name; /**< Name of data type to be serialized */
1548         int         size; /**< Size in bytes of data type to be serialized */
1549         struct {
1550            void   *(*mem_alloc) (size_t size); /**< how to allocate memory (usually malloc()) */
1551            void    (*mem_free) (void *mem); /**< how to free memory (usually free()) */
1552            char   *(*str_alloc) (const char *str); /**< how to allocate a string */
1553            void    (*str_free) (const char *str); /**< how to free a string */
1554            void   *(*list_next) (void *l); /**< how to iterate to the next element of a list. Receives and should return the list node. */
1555            void   *(*list_append) (void *l, void *d); /**< how to append data @p d to list which head node is @p l */
1556            void   *(*list_data) (void *l); /**< retrieves the data from node @p l */
1557            void   *(*list_free) (void *l); /**< free all the nodes from the list which head node is @p l */
1558            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 */
1559            void   *(*hash_add) (void *h, const char *k, void *d); /**< add a new data @p d as key @p k in hash @p h */
1560            void    (*hash_free) (void *h); /**< free all entries from the hash @p h */
1561            char   *(*str_direct_alloc) (const char *str); /**< how to allocate a string directly from file backed/mmaped region pointed by @p str */
1562            void    (*str_direct_free) (const char *str); /**< how to free a string returned by str_direct_alloc */
1563
1564            const char *(*type_get) (const void *data, Eina_Bool *unknow); /**< convert any kind of data type to a name that define an Eet_Data_Element. */
1565            Eina_Bool  (*type_set) (const char *type, void *data, Eina_Bool unknow); /**< set the type at a particular adress */
1566         } func;
1567      };
1568
1569    /**
1570     * @}
1571     */
1572
1573    /**
1574     * Create a new empty data structure descriptor.
1575     * @param name The string name of this data structure (most be a
1576     *        global constant and never change).
1577     * @param size The size of the struct (in bytes).
1578     * @param func_list_next The function to get the next list node.
1579     * @param func_list_append The function to append a member to a list.
1580     * @param func_list_data The function to get the data from a list node.
1581     * @param func_list_free The function to free an entire linked list.
1582     * @param func_hash_foreach The function to iterate through all
1583     *        hash table entries.
1584     * @param func_hash_add The function to add a member to a hash table.
1585     * @param func_hash_free The function to free an entire hash table.
1586     * @return A new empty data descriptor.
1587     *
1588     * This function creates a new data descriptore and returns a handle to the
1589     * new data descriptor. On creation it will be empty, containing no contents
1590     * describing anything other than the shell of the data structure.
1591     *
1592     * You add structure members to the data descriptor using the macros
1593     * EET_DATA_DESCRIPTOR_ADD_BASIC(), EET_DATA_DESCRIPTOR_ADD_SUB() and
1594     * EET_DATA_DESCRIPTOR_ADD_LIST(), depending on what type of member you are
1595     * adding to the description.
1596     *
1597     * Once you have described all the members of a struct you want loaded, or
1598     * saved eet can load and save those members for you, encode them into
1599     * endian-independant serialised data chunks for transmission across a
1600     * a network or more.
1601     *
1602     * The function pointers to the list and hash table functions are only
1603     * needed if you use those data types, else you can pass NULL instead.
1604     *
1605     * @since 1.0.0
1606     * @ingroup Eet_Data_Group
1607     *
1608     * @deprecated use eet_data_descriptor_stream_new() or
1609     *             eet_data_descriptor_file_new()
1610     */
1611    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));
1612    /*
1613     * FIXME:
1614     *
1615     * moving to this api from the old above. this will break things when the
1616     * move happens - but be warned
1617     */
1618    EINA_DEPRECATED EAPI Eet_Data_Descriptor *eet_data_descriptor2_new(const Eet_Data_Descriptor_Class *eddc);
1619    EINA_DEPRECATED EAPI Eet_Data_Descriptor *eet_data_descriptor3_new(const Eet_Data_Descriptor_Class *eddc);
1620
1621    /**
1622     * This function creates a new data descriptore and returns a handle to the
1623     * new data descriptor. On creation it will be empty, containing no contents
1624     * describing anything other than the shell of the data structure.
1625     * @param eddc The data descriptor to free.
1626     *
1627     * You add structure members to the data descriptor using the macros
1628     * EET_DATA_DESCRIPTOR_ADD_BASIC(), EET_DATA_DESCRIPTOR_ADD_SUB() and
1629     * EET_DATA_DESCRIPTOR_ADD_LIST(), depending on what type of member you are
1630     * adding to the description.
1631     *
1632     * Once you have described all the members of a struct you want loaded, or
1633     * saved eet can load and save those members for you, encode them into
1634     * endian-independant serialised data chunks for transmission across a
1635     * a network or more.
1636     *
1637     * This function specially ignore str_direct_alloc and str_direct_free. It
1638     * is usefull when the eet_data you are reading don't have a dictionnary
1639     * like network stream or ipc. It also mean that all string will be allocated
1640     * and duplicated in memory.
1641     *
1642     * @since 1.2.3
1643     * @ingroup Eet_Data_Group
1644     */
1645    EAPI Eet_Data_Descriptor *eet_data_descriptor_stream_new(const Eet_Data_Descriptor_Class *eddc);
1646
1647    /**
1648     * This function creates a new data descriptore and returns a handle to the
1649     * new data descriptor. On creation it will be empty, containing no contents
1650     * describing anything other than the shell of the data structure.
1651     * @param eddc The data descriptor to free.
1652     *
1653     * You add structure members to the data descriptor using the macros
1654     * EET_DATA_DESCRIPTOR_ADD_BASIC(), EET_DATA_DESCRIPTOR_ADD_SUB() and
1655     * EET_DATA_DESCRIPTOR_ADD_LIST(), depending on what type of member you are
1656     * adding to the description.
1657     *
1658     * Once you have described all the members of a struct you want loaded, or
1659     * saved eet can load and save those members for you, encode them into
1660     * endian-independant serialised data chunks for transmission across a
1661     * a network or more.
1662     *
1663     * This function use str_direct_alloc and str_direct_free. It is
1664     * usefull when the eet_data you are reading come from a file and
1665     * have a dictionnary. This will reduce memory use, improve the
1666     * possibility for the OS to page this string out. But be carrefull
1667     * all EET_T_STRING are pointer to a mmapped area and it will point
1668     * to nowhere if you close the file. So as long as you use this
1669     * strings, you need to have the Eet_File open.
1670     *
1671     * @since 1.2.3
1672     * @ingroup Eet_Data_Group
1673     */
1674    EAPI Eet_Data_Descriptor *eet_data_descriptor_file_new(const Eet_Data_Descriptor_Class *eddc);
1675
1676    /**
1677     * This function is an helper that set all the parameter of an
1678     * Eet_Data_Descriptor_Class correctly when you use Eina data type
1679     * with a stream.
1680     * @param eddc The Eet_Data_Descriptor_Class you want to set.
1681     * @param name The name of the structure described by this class.
1682     * @param size The size of the structure described by this class.
1683     * @return EINA_TRUE if the structure was correctly set (The only
1684     *         reason that could make it fail is if you did give wrong
1685     *         parameter).
1686     *
1687     * @since 1.2.3
1688     * @ingroup Eet_Data_Group
1689     */
1690    EAPI Eina_Bool eet_eina_stream_data_descriptor_class_set(Eet_Data_Descriptor_Class *eddc, const char *name, int size);
1691
1692    /**
1693     * This macro is an helper that set all the parameter of an
1694     * Eet_Data_Descriptor_Class correctly when you use Eina data type
1695     * with stream.
1696     * @param Clas The Eet_Data_Descriptor_Class you want to set.
1697     * @param Type The type of the structure described by this class.
1698     * @return EINA_TRUE if the structure was correctly set (The only
1699     *         reason that could make it fail is if you did give wrong
1700     *         parameter).
1701     *
1702     * @since 1.2.3
1703     * @ingroup Eet_Data_Group
1704     */
1705 #define EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(Clas, Type) (eet_eina_stream_data_descriptor_class_set(Clas, #Type , sizeof (Type)))
1706
1707    /**
1708     * This function is an helper that set all the parameter of an
1709     * Eet_Data_Descriptor_Class correctly when you use Eina data type
1710     * with a file.
1711     * @param eddc The Eet_Data_Descriptor_Class you want to set.
1712     * @param name The name of the structure described by this class.
1713     * @param size The size of the structure described by this class.
1714     * @return EINA_TRUE if the structure was correctly set (The only
1715     *         reason that could make it fail is if you did give wrong
1716     *         parameter).
1717     *
1718     * @since 1.2.3
1719     * @ingroup Eet_Data_Group
1720     */
1721    EAPI Eina_Bool eet_eina_file_data_descriptor_class_set(Eet_Data_Descriptor_Class *eddc, const char *name, int size);
1722
1723    /**
1724     * This macro is an helper that set all the parameter of an
1725     * Eet_Data_Descriptor_Class correctly when you use Eina data type
1726     * with file.
1727     * @param Clas The Eet_Data_Descriptor_Class you want to set.
1728     * @param Type The type of the structure described by this class.
1729     * @return EINA_TRUE if the structure was correctly set (The only
1730     *         reason that could make it fail is if you did give wrong
1731     *         parameter).
1732     *
1733     * @since 1.2.3
1734     * @ingroup Eet_Data_Group
1735     */
1736 #define EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(Clas, Type) (eet_eina_file_data_descriptor_class_set(Clas, #Type , sizeof (Type)))
1737
1738    /**
1739     * This function frees a data descriptor when it is not needed anymore.
1740     * @param edd The data descriptor to free.
1741     *
1742     * This function takes a data descriptor handle as a parameter and frees all
1743     * data allocated for the data descriptor and the handle itself. After this
1744     * call the descriptor is no longer valid.
1745     *
1746     * @since 1.0.0
1747     * @ingroup Eet_Data_Group
1748     */
1749    EAPI void eet_data_descriptor_free(Eet_Data_Descriptor *edd);
1750
1751    /**
1752     * This function is an internal used by macros.
1753     *
1754     * This function is used by macros EET_DATA_DESCRIPTOR_ADD_BASIC(),
1755     * EET_DATA_DESCRIPTOR_ADD_SUB() and EET_DATA_DESCRIPTOR_ADD_LIST(). It is
1756     * complex to use by hand and should be left to be used by the macros, and
1757     * thus is not documented.
1758     *
1759     * @param edd The data descriptor handle to add element (member).
1760     * @param name The name of element to be serialized.
1761     * @param type The type of element to be serialized, like
1762     *        #EET_T_INT. If #EET_T_UNKNOW, then it is considered to be a
1763     *        group, list or hash.
1764     * @param group_type If element type is #EET_T_UNKNOW, then the @p
1765     *        group_type will speficy if it is a list (#EET_G_LIST),
1766     *        array (#EET_G_ARRAY) and so on. If #EET_G_UNKNOWN, then
1767     *        the member is a subtype (pointer to another type defined by
1768     *        another #Eet_Data_Descriptor).
1769     * @param offset byte offset inside the source memory to be serialized.
1770     * @param count number of elements (if #EET_G_ARRAY or #EET_G_VAR_ARRAY).
1771     * @param counter_name variable that defines the name of number of elements.
1772     * @param subtype If contains a subtype, then its data descriptor.
1773     *
1774     * @since 1.0.0
1775     * @ingroup Eet_Data_Group
1776     */
1777    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);
1778
1779    /**
1780     * Read a data structure from an eet file and decodes it.
1781     * @param ef The eet file handle to read from.
1782     * @param edd The data descriptor handle to use when decoding.
1783     * @param name The key the data is stored under in the eet file.
1784     * @return A pointer to the decoded data structure.
1785     *
1786     * This function decodes a data structure stored in an eet file, returning
1787     * a pointer to it if it decoded successfully, or NULL on failure. This
1788     * can save a programmer dozens of hours of work in writing configuration
1789     * file parsing and writing code, as eet does all that work for the program
1790     * and presents a program-friendly data structure, just as the programmer
1791     * likes. Eet can handle members being added or deleted from the data in
1792     * storage and safely zero-fills unfilled members if they were not found
1793     * in the data. It checks sizes and headers whenever it reads data, allowing
1794     * the programmer to not worry about corrupt data.
1795     *
1796     * Once a data structure has been described by the programmer with the
1797     * fields they wish to save or load, storing or retrieving a data structure
1798     * from an eet file, or from a chunk of memory is as simple as a single
1799     * function call.
1800     *
1801     * @see eet_data_read_cipher()
1802     *
1803     * @since 1.0.0
1804     * @ingroup Eet_Data_Group
1805     */
1806    EAPI void *eet_data_read(Eet_File *ef, Eet_Data_Descriptor *edd, const char *name);
1807
1808    /**
1809     * Write a data structure from memory and store in an eet file.
1810     * @param ef The eet file handle to write to.
1811     * @param edd The data descriptor to use when encoding.
1812     * @param name The key to store the data under in the eet file.
1813     * @param data A pointer to the data structure to ssave and encode.
1814     * @param compress Compression flags for storage.
1815     * @return bytes written on successful write, 0 on failure.
1816     *
1817     * This function is the reverse of eet_data_read(), saving a data structure
1818     * to an eet file.
1819     *
1820     * @see eet_data_write_cipher()
1821     *
1822     * @since 1.0.0
1823     * @ingroup Eet_Data_Group
1824     */
1825    EAPI int eet_data_write(Eet_File *ef, Eet_Data_Descriptor *edd, const char *name, const void *data, int compress);
1826
1827    /**
1828     * Dump an eet encoded data structure into ascii text
1829     * @param data_in The pointer to the data to decode into a struct.
1830     * @param size_in The size of the data pointed to in bytes.
1831     * @param dumpfunc The function to call passed a string when new
1832     *        data is converted to text
1833     * @param dumpdata The data to pass to the @p dumpfunc callback.
1834     * @return 1 on success, 0 on failure
1835     *
1836     * This function will take a chunk of data encoded by
1837     * eet_data_descriptor_encode() and convert it into human readable
1838     * ascii text.  It does this by calling the @p dumpfunc callback
1839     * for all new text that is generated. This callback should append
1840     * to any existing text buffer and will be passed the pointer @p
1841     * dumpdata as a parameter as well as a string with new text to be
1842     * appended.
1843     *
1844     * Example:
1845     *
1846     * @code
1847     * void output(void *data, const char *string)
1848     * {
1849     *   printf("%s", string);
1850     * }
1851     *
1852     * void dump(const char *file)
1853     * {
1854     *   FILE *f;
1855     *   int len;
1856     *   void *data;
1857     *
1858     *   f = fopen(file, "r");
1859     *   fseek(f, 0, SEEK_END);
1860     *   len = ftell(f);
1861     *   rewind(f);
1862     *   data = malloc(len);
1863     *   fread(data, len, 1, f);
1864     *   fclose(f);
1865     *   eet_data_text_dump(data, len, output, NULL);
1866     * }
1867     * @endcode
1868     *
1869     * @see eet_data_text_dump_cipher()
1870     *
1871     * @since 1.0.0
1872     * @ingroup Eet_Data_Group
1873     */
1874    EAPI int eet_data_text_dump(const void *data_in, int size_in, void (*dumpfunc) (void *data, const char *str), void *dumpdata);
1875
1876    /**
1877     * Take an ascii encoding from eet_data_text_dump() and re-encode in binary.
1878     * @param text The pointer to the string data to parse and encode.
1879     * @param textlen The size of the string in bytes (not including 0
1880     *        byte terminator).
1881     * @param size_ret This gets filled in with the encoded data blob
1882     *        size in bytes.
1883     * @return The encoded data on success, NULL on failure.
1884     *
1885     * This function will parse the string pointed to by @p text and return
1886     * an encoded data lump the same way eet_data_descriptor_encode() takes an
1887     * in-memory data struct and encodes into a binary blob. @p text is a normal
1888     * C string.
1889     *
1890     * @see eet_data_text_undump_cipher()
1891     *
1892     * @since 1.0.0
1893     * @ingroup Eet_Data_Group
1894     */
1895    EAPI void *eet_data_text_undump(const char *text, int textlen, int *size_ret);
1896
1897    /**
1898     * Dump an eet encoded data structure from an eet file into ascii text
1899     * @param ef A valid eet file handle.
1900     * @param name Name of the entry. eg: "/base/file_i_want".
1901     * @param dumpfunc The function to call passed a string when new
1902     *        data is converted to text
1903     * @param dumpdata The data to pass to the @p dumpfunc callback.
1904     * @return 1 on success, 0 on failure
1905     *
1906     * This function will take an open and valid eet file from
1907     * eet_open() request the data encoded by
1908     * eet_data_descriptor_encode() corresponding to the key @p name
1909     * and convert it into human readable ascii text. It does this by
1910     * calling the @p dumpfunc callback for all new text that is
1911     * generated. This callback should append to any existing text
1912     * buffer and will be passed the pointer @p dumpdata as a parameter
1913     * as well as a string with new text to be appended.
1914     *
1915     * @see eet_data_dump_cipher()
1916     *
1917     * @since 1.0.0
1918     * @ingroup Eet_Data_Group
1919     */
1920    EAPI int eet_data_dump(Eet_File *ef, const char *name, void (*dumpfunc) (void *data, const char *str), void *dumpdata);
1921
1922    /**
1923     * Take an ascii encoding from eet_data_dump() and re-encode in binary.
1924     * @param ef A valid eet file handle.
1925     * @param name Name of the entry. eg: "/base/file_i_want".
1926     * @param text The pointer to the string data to parse and encode.
1927     * @param textlen The size of the string in bytes (not including 0
1928     *        byte terminator).
1929     * @param compress Compression flags (1 == compress, 0 = don't compress).
1930     * @return 1 on success, 0 on failure
1931     *
1932     * This function will parse the string pointed to by @p text,
1933     * encode it the same way eet_data_descriptor_encode() takes an
1934     * in-memory data struct and encodes into a binary blob.
1935     *
1936     * The data (optionally compressed) will be in ram, pending a flush to
1937     * disk (it will stay in ram till the eet file handle is closed though).
1938     *
1939     * @see eet_data_undump_cipher()
1940     *
1941     * @since 1.0.0
1942     * @ingroup Eet_Data_Group
1943     */
1944    EAPI int eet_data_undump(Eet_File *ef, const char *name, const char *text, int textlen, int compress);
1945
1946    /**
1947     * Decode a data structure from an arbitary location in memory.
1948     * @param edd The data  descriptor to use when decoding.
1949     * @param data_in The pointer to the data to decode into a struct.
1950     * @param size_in The size of the data pointed to in bytes.
1951     * @return NULL on failure, or a valid decoded struct pointer on success.
1952     *
1953     * This function will decode a data structure that has been encoded using
1954     * eet_data_descriptor_encode(), and return a data structure with all its
1955     * elements filled out, if successful, or NULL on failure.
1956     *
1957     * The data to be decoded is stored at the memory pointed to by @p data_in,
1958     * and is described by the descriptor pointed to by @p edd. The data size is
1959     * passed in as the value to @p size_in, ande must be greater than 0 to
1960     * succeed.
1961     *
1962     * This function is useful for decoding data structures delivered to the
1963     * application by means other than an eet file, such as an IPC or socket
1964     * connection, raw files, shared memory etc.
1965     *
1966     * Please see eet_data_read() for more information.
1967     *
1968     * @see eet_data_descriptor_decode_cipher()
1969     *
1970     * @since 1.0.0
1971     * @ingroup Eet_Data_Group
1972     */
1973    EAPI void *eet_data_descriptor_decode(Eet_Data_Descriptor *edd, const void *data_in, int size_in);
1974
1975    /**
1976     * Encode a dsata struct to memory and return that encoded data.
1977     * @param edd The data  descriptor to use when encoding.
1978     * @param data_in The pointer to the struct to encode into data.
1979     * @param size_ret pointer to the an int to be filled with the decoded size.
1980     * @return NULL on failure, or a valid encoded data chunk on success.
1981     *
1982     * This function takes a data structutre in memory and encodes it into a
1983     * serialised chunk of data that can be decoded again by
1984     * eet_data_descriptor_decode(). This is useful for being able to transmit
1985     * data structures across sockets, pipes, IPC or shared file mechanisms,
1986     * without having to worry about memory space, machine type, endianess etc.
1987     *
1988     * The parameter @p edd must point to a valid data descriptor, and
1989     * @p data_in must point to the right data structure to encode. If not, the
1990     * encoding may fail.
1991     *
1992     * On success a non NULL valid pointer is returned and what @p size_ret
1993     * points to is set to the size of this decoded data, in bytes. When the
1994     * encoded data is no longer needed, call free() on it. On failure NULL is
1995     * returned and what @p size_ret points to is set to 0.
1996     *
1997     * Please see eet_data_write() for more information.
1998     *
1999     * @see eet_data_descriptor_encode_cipher()
2000     *
2001     * @since 1.0.0
2002     * @ingroup Eet_Data_Group
2003     */
2004    EAPI void *eet_data_descriptor_encode(Eet_Data_Descriptor *edd, const void *data_in, int *size_ret);
2005
2006    /**
2007     * Add a basic data element to a data descriptor.
2008     * @param edd The data descriptor to add the type to.
2009     * @param struct_type The type of the struct.
2010     * @param name The string name to use to encode/decode this member
2011     *        (must be a constant global and never change).
2012     * @param member The struct member itself to be encoded.
2013     * @param type The type of the member to encode.
2014     *
2015     * This macro is a convenience macro provided to add a member to
2016     * the data descriptor @p edd. The type of the structure is
2017     * provided as the @p struct_type parameter (for example: struct
2018     * my_struct). The @p name parameter defines a string that will be
2019     * used to uniquely name that member of the struct (it is suggested
2020     * to use the struct member itself).  The @p member parameter is
2021     * the actual struct member itself (for eet_dictionary_string_check
2022     * example: values), and @p type is the basic data type of the
2023     * member which must be one of: EET_T_CHAR, EET_T_SHORT, EET_T_INT,
2024     * EET_T_LONG_LONG, EET_T_FLOAT, EET_T_DOUBLE, EET_T_UCHAR,
2025     * EET_T_USHORT, EET_T_UINT, EET_T_ULONG_LONG or EET_T_STRING.
2026     *
2027     * @since 1.0.0
2028     * @ingroup Eet_Data_Group
2029     */
2030 #define EET_DATA_DESCRIPTOR_ADD_BASIC(edd, struct_type, name, member, type) \
2031      { \
2032         struct_type ___ett; \
2033         \
2034         eet_data_descriptor_element_add(edd, name, type, EET_G_UNKNOWN, \
2035                                         (char *)(&(___ett.member)) - (char *)(&(___ett)), \
2036                                         0, /* 0,  */NULL, NULL); \
2037      }
2038
2039    /**
2040     * Add a sub-element type to a data descriptor
2041     * @param edd The data descriptor to add the type to.
2042     * @param struct_type The type of the struct.
2043     * @param name The string name to use to encode/decode this member
2044     *        (must be a constant global and never change).
2045     * @param member The struct member itself to be encoded.
2046     * @param subtype The type of sub-type struct to add.
2047     *
2048     * This macro lets you easily add a sub-type (a struct that's pointed to
2049     * by this one). All the parameters are the same as for
2050     * EET_DATA_DESCRIPTOR_ADD_BASIC(), with the @p subtype being the exception.
2051     * This must be the data descriptor of the struct that is pointed to by
2052     * this element.
2053     *
2054     * @since 1.0.0
2055     * @ingroup Eet_Data_Group
2056     */
2057 #define EET_DATA_DESCRIPTOR_ADD_SUB(edd, struct_type, name, member, subtype) \
2058      { \
2059         struct_type ___ett; \
2060         \
2061         eet_data_descriptor_element_add(edd, name, EET_T_UNKNOW, EET_G_UNKNOWN, \
2062                                         (char *)(&(___ett.member)) - (char *)(&(___ett)), \
2063                                         0, /* 0,  */NULL, subtype); \
2064      }
2065
2066    /**
2067     * Add a linked list type to a data descriptor
2068     * @param edd The data descriptor to add the type to.
2069     * @param struct_type The type of the struct.
2070     * @param name The string name to use to encode/decode this member
2071     *        (must be a constant global and never change).
2072     * @param member The struct member itself to be encoded.
2073     * @param subtype The type of linked list member to add.
2074     *
2075     * This macro lets you easily add a linked list of other data types. All the
2076     * parameters are the same as for EET_DATA_DESCRIPTOR_ADD_BASIC(), with the
2077     * @p subtype being the exception. This must be the data descriptor of the
2078     * element that is in each member of the linked list to be stored.
2079     *
2080     * @since 1.0.0
2081     * @ingroup Eet_Data_Group
2082     */
2083 #define EET_DATA_DESCRIPTOR_ADD_LIST(edd, struct_type, name, member, subtype) \
2084      { \
2085         struct_type ___ett; \
2086         \
2087         eet_data_descriptor_element_add(edd, name, EET_T_UNKNOW, EET_G_LIST, \
2088                                         (char *)(&(___ett.member)) - (char *)(&(___ett)), \
2089                                         0, /* 0,  */NULL, subtype); \
2090      }
2091
2092    /**
2093     * Add a hash type to a data descriptor
2094     * @param edd The data descriptor to add the type to.
2095     * @param struct_type The type of the struct.
2096     * @param name The string name to use to encode/decode this member
2097     *        (must be a constant global and never change).
2098     * @param member The struct member itself to be encoded.
2099     * @param subtype The type of hash member to add.
2100     *
2101     * This macro lets you easily add a hash of other data types. All the
2102     * parameters are the same as for EET_DATA_DESCRIPTOR_ADD_BASIC(), with the
2103     * @p subtype being the exception. This must be the data descriptor of the
2104     * element that is in each member of the hash to be stored.
2105     *
2106     * @since 1.0.0
2107     * @ingroup Eet_Data_Group
2108     */
2109 #define EET_DATA_DESCRIPTOR_ADD_HASH(edd, struct_type, name, member, subtype) \
2110      { \
2111         struct_type ___ett; \
2112         \
2113         eet_data_descriptor_element_add(edd, name, EET_T_UNKNOW, EET_G_HASH, \
2114                                         (char *)(&(___ett.member)) - (char *)(&(___ett)), \
2115                                         0, /* 0,  */NULL, subtype); \
2116      }
2117
2118    /**
2119     * Add a fixed size array type to a data descriptor
2120     * @param edd The data descriptor to add the type to.
2121     * @param struct_type The type of the struct.
2122     * @param name The string name to use to encode/decode this member
2123     *        (must be a constant global and never change).
2124     * @param member The struct member itself to be encoded.
2125     * @param subtype The type of hash member to add.
2126     *
2127     * This macro lets you easily add a fixed size array of other data
2128     * types. All the parameters are the same as for
2129     * EET_DATA_DESCRIPTOR_ADD_BASIC(), with the @p subtype being the
2130     * exception. This must be the data descriptor of the element that
2131     * is in each member of the hash to be stored.
2132     *
2133     * @since 1.0.2
2134     * @ingroup Eet_Data_Group
2135     */
2136 #define EET_DATA_DESCRIPTOR_ADD_ARRAY(edd, struct_type, name, member, subtype) \
2137      { \
2138         struct_type ___ett; \
2139         \
2140         eet_data_descriptor_element_add(edd, name, EET_T_UNKNOW, EET_G_ARRAY, \
2141                                         (char *)(&(___ett.member)) - (char *)(&(___ett)), \
2142                                         /* 0,  */sizeof(___ett.member)/sizeof(___ett.member[0]), NULL, subtype); \
2143      }
2144
2145    /**
2146     * Add a variable size array type to a data descriptor
2147     * @param edd The data descriptor to add the type to.
2148     * @param struct_type The type of the struct.
2149     * @param name The string name to use to encode/decode this member
2150     *        (must be a constant global and never change).
2151     * @param member The struct member itself to be encoded.
2152     * @param subtype The type of hash member to add.
2153     *
2154     * This macro lets you easily add a fixed size array of other data
2155     * types. All the parameters are the same as for
2156     * EET_DATA_DESCRIPTOR_ADD_BASIC(), with the @p subtype being the
2157     * exception. This must be the data descriptor of the element that
2158     * is in each member of the hash to be stored.
2159     *
2160     * @since 1.0.2
2161     * @ingroup Eet_Data_Group
2162     */
2163 #define EET_DATA_DESCRIPTOR_ADD_VAR_ARRAY(edd, struct_type, name, member, subtype) \
2164      { \
2165         struct_type ___ett; \
2166         \
2167         eet_data_descriptor_element_add(edd, name, EET_T_UNKNOW, EET_G_VAR_ARRAY, \
2168                                         (char *)(&(___ett.member)) - (char *)(&(___ett)), \
2169                                         (char *)(&(___ett.member ## _count)) - (char *)(&(___ett)), /* 0,  */NULL, subtype); \
2170      }
2171
2172    /**
2173     * Add an union type to a data descriptor
2174     * @param edd The data descriptor to add the type to.
2175     * @param struct_type The type of the struct.
2176     * @param name The string name to use to encode/decode this member
2177     *        (must be a constant global and never change).
2178     * @param member The struct member itself to be encoded.
2179     * @param type_member The member that give hints on what is in the union.
2180     * @param unified_type Describe all possible type the union could handle.
2181     *
2182     * This macro lets you easily add an union with a member that specify what is inside.
2183     * The @p unified_type is an Eet_Data_Descriptor, but only the entry that match the name
2184     * returned by type_get will be used for each serialized data. The type_get and type_set
2185     * callback of unified_type should be defined.
2186     *
2187     * @since 1.2.4
2188     * @ingroup Eet_Data_Group
2189     * @see Eet_Data_Descriptor_Class
2190     */
2191 #define EET_DATA_DESCRIPTOR_ADD_UNION(edd, struct_type, name, member, type_member, unified_type) \
2192      { \
2193         struct_type ___ett;                     \
2194         \
2195         eet_data_descriptor_element_add(edd, name, EET_T_UNKNOW, EET_G_UNION, \
2196                                         (char *) (&(___ett.member)) - (char *)(&(___ett)), \
2197                                         (char *) (&(___ett.type_member)) - (char *)(&(___ett)), \
2198                                         NULL, unified_type); \
2199      }
2200
2201    /**
2202     * Make a structure variable in size/content depend on it's type
2203     * @param edd The data descriptor to add the type to.
2204     * @param struct_type The type of the struct.
2205     * @param name The string name to use to encode/decode this member
2206     *        (must be a constant global and never change).
2207     * @param member The struct member itself to be encoded.
2208     * @param type_member The member that give hints on what is in the union.
2209     * @param unified_type Describe all possible type the union could handle.
2210     *
2211     * This macro lets you easily add a switch for an object oriented representation. The position
2212     * of the member that define the type must be fixed for all possible type. Eet will then choose
2213     * in the unified_type the structure that need to be allocated to match the detected type.
2214     * The type_get and type_set callback of unified_type should be defined. This should be the only
2215     * type in edd.
2216     *
2217     * @since 1.2.4
2218     * @ingroup Eet_Data_Group
2219     * @see Eet_Data_Descriptor_Class
2220     */
2221 #define EET_DATA_DESCRIPTOR_ADD_INHERIT(edd, struct_type, name, member, type_member, unified_type) \
2222      { \
2223         struct_type ___ett;                     \
2224         \
2225         eet_data_descriptor_element_add(edd, name, EET_T_UNKNOW, EET_G_INHERIT, \
2226                                         (char *) (&(___ett.member)) - (char *)(&(___ett)), \
2227                                         (char *) (&(___ett.type_member)) - (char *)(&(___ett)), \
2228                                         NULL, unified_type); \
2229      }
2230
2231    /**
2232     * Add a automatically selectable type to a data descriptor
2233     * @param edd The data descriptor to add the type to.
2234     * @param struct_type The type of the struct.
2235     * @param name The string name to use to encode/decode this member
2236     *        (must be a constant global and never change).
2237     * @param member The struct member itself to be encoded.
2238     * @param type_member The member that give hints on what is in the union.
2239     * @param unified_type Describe all possible type the union could handle.
2240     *
2241     * This macro lets you easily define what the content of @p member points to depending of
2242     * the content of @p type_member. The type_get and type_set callback of unified_type should
2243     * be defined. If the the type is not know at the time of restoring it, eet will still call
2244     * type_set of @p unified_type but the pointer will be set to a serialized binary representation
2245     * of what eet know. This make it possible, to save this pointer again by just returning the string
2246     * given previously and telling it by setting unknow to EINA_TRUE.
2247     *
2248     * @since 1.2.4
2249     * @ingroup Eet_Data_Group
2250     * @see Eet_Data_Descriptor_Class
2251     */
2252 #define EET_DATA_DESCRIPTOR_ADD_VARIANT(edd, struct_type, name, member, type_member, unified_type) \
2253      { \
2254         struct_type ___ett;                     \
2255         \
2256         eet_data_descriptor_element_add(edd, name, EET_T_UNKNOW, EET_G_VARIANT, \
2257                                         (char *) (&(___ett.member)) - (char *)(&(___ett)), \
2258                                         (char *) (&(___ett.type_member)) - (char *)(&(___ett)), \
2259                                         NULL, unified_type); \
2260      }
2261
2262    /**
2263     * Add a mapping to a data descriptor that will be used by union, variant or inherited type
2264     * @param unified_type The data descriptor to add the mapping to.
2265     * @param name The string name to get/set type.
2266     * @param subtype The matching data descriptor.
2267     *
2268     * @since 1.2.4
2269     * @ingroup Eet_Data_Group
2270     * @see Eet_Data_Descriptor_Class
2271     */
2272 #define EET_DATA_DESCRIPTOR_ADD_MAPPING(unified_type, name, subtype) \
2273   eet_data_descriptor_element_add(unified_type, name, EET_T_UNKNOW, EET_G_UNKNOWN, 0, 0, NULL, subtype);
2274
2275    /**
2276     * @defgroup Eet_Data_Cipher_Group Eet Data Serialization using A Ciphers
2277     *
2278     * Most of the @ref Eet_Data_Group have alternative versions that
2279     * accounts for ciphers to protect their content.
2280     *
2281     * @see @ref Eet_Cipher_Group
2282     *
2283     * @ingroup Eet_Data_Group
2284     */
2285
2286    /**
2287     * Read a data structure from an eet file and decodes it using a cipher.
2288     * @param ef The eet file handle to read from.
2289     * @param edd The data descriptor handle to use when decoding.
2290     * @param name The key the data is stored under in the eet file.
2291     * @param cipher_key The key to use as cipher.
2292     * @return A pointer to the decoded data structure.
2293     *
2294     * This function decodes a data structure stored in an eet file, returning
2295     * a pointer to it if it decoded successfully, or NULL on failure. This
2296     * can save a programmer dozens of hours of work in writing configuration
2297     * file parsing and writing code, as eet does all that work for the program
2298     * and presents a program-friendly data structure, just as the programmer
2299     * likes. Eet can handle members being added or deleted from the data in
2300     * storage and safely zero-fills unfilled members if they were not found
2301     * in the data. It checks sizes and headers whenever it reads data, allowing
2302     * the programmer to not worry about corrupt data.
2303     *
2304     * Once a data structure has been described by the programmer with the
2305     * fields they wish to save or load, storing or retrieving a data structure
2306     * from an eet file, or from a chunk of memory is as simple as a single
2307     * function call.
2308     *
2309     * @see eet_data_read()
2310     *
2311     * @since 1.0.0
2312     * @ingroup Eet_Data_Cipher_Group
2313     */
2314    EAPI void *eet_data_read_cipher(Eet_File *ef, Eet_Data_Descriptor *edd, const char *name, const char *cipher_key);
2315
2316    /**
2317     * Write a data structure from memory and store in an eet file
2318     * using a cipher.
2319     * @param ef The eet file handle to write to.
2320     * @param edd The data descriptor to use when encoding.
2321     * @param name The key to store the data under in the eet file.
2322     * @param cipher_key The key to use as cipher.
2323     * @param data A pointer to the data structure to ssave and encode.
2324     * @param compress Compression flags for storage.
2325     * @return bytes written on successful write, 0 on failure.
2326     *
2327     * This function is the reverse of eet_data_read(), saving a data structure
2328     * to an eet file.
2329     *
2330     * @see eet_data_write_cipher()
2331     *
2332     * @since 1.0.0
2333     * @ingroup Eet_Data_Cipher_Group
2334     */
2335    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);
2336
2337    /**
2338     * Dump an eet encoded data structure into ascii text using a cipher.
2339     * @param data_in The pointer to the data to decode into a struct.
2340     * @param cipher_key The key to use as cipher.
2341     * @param size_in The size of the data pointed to in bytes.
2342     * @param dumpfunc The function to call passed a string when new
2343     *        data is converted to text
2344     * @param dumpdata The data to pass to the @p dumpfunc callback.
2345     * @return 1 on success, 0 on failure
2346     *
2347     * This function will take a chunk of data encoded by
2348     * eet_data_descriptor_encode() and convert it into human readable
2349     * ascii text.  It does this by calling the @p dumpfunc callback
2350     * for all new text that is generated. This callback should append
2351     * to any existing text buffer and will be passed the pointer @p
2352     * dumpdata as a parameter as well as a string with new text to be
2353     * appended.
2354     *
2355     * Example:
2356     *
2357     * @code
2358     * void output(void *data, const char *string)
2359     * {
2360     *   printf("%s", string);
2361     * }
2362     *
2363     * void dump(const char *file)
2364     * {
2365     *   FILE *f;
2366     *   int len;
2367     *   void *data;
2368     *
2369     *   f = fopen(file, "r");
2370     *   fseek(f, 0, SEEK_END);
2371     *   len = ftell(f);
2372     *   rewind(f);
2373     *   data = malloc(len);
2374     *   fread(data, len, 1, f);
2375     *   fclose(f);
2376     *   eet_data_text_dump_cipher(data, cipher_key, len, output, NULL);
2377     * }
2378     * @endcode
2379     *
2380     * @see eet_data_text_dump()
2381     *
2382     * @since 1.0.0
2383     * @ingroup Eet_Data_Cipher_Group
2384     */
2385    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);
2386
2387    /**
2388     * Take an ascii encoding from eet_data_text_dump() and re-encode
2389     * in binary using a cipher.
2390     * @param text The pointer to the string data to parse and encode.
2391     * @param cipher_key The key to use as cipher.
2392     * @param textlen The size of the string in bytes (not including 0
2393     *        byte terminator).
2394     * @param size_ret This gets filled in with the encoded data blob
2395     *        size in bytes.
2396     * @return The encoded data on success, NULL on failure.
2397     *
2398     * This function will parse the string pointed to by @p text and return
2399     * an encoded data lump the same way eet_data_descriptor_encode() takes an
2400     * in-memory data struct and encodes into a binary blob. @p text is a normal
2401     * C string.
2402     *
2403     * @see eet_data_text_undump()
2404     *
2405     * @since 1.0.0
2406     * @ingroup Eet_Data_Cipher_Group
2407     */
2408    EAPI void *eet_data_text_undump_cipher(const char *text, const char *cipher_key, int textlen, int *size_ret);
2409
2410    /**
2411     * Dump an eet encoded data structure from an eet file into ascii
2412     * text using a cipher.
2413     * @param ef A valid eet file handle.
2414     * @param name Name of the entry. eg: "/base/file_i_want".
2415     * @param cipher_key The key to use as cipher.
2416     * @param dumpfunc The function to call passed a string when new
2417     *        data is converted to text
2418     * @param dumpdata The data to pass to the @p dumpfunc callback.
2419     * @return 1 on success, 0 on failure
2420     *
2421     * This function will take an open and valid eet file from
2422     * eet_open() request the data encoded by
2423     * eet_data_descriptor_encode() corresponding to the key @p name
2424     * and convert it into human readable ascii text. It does this by
2425     * calling the @p dumpfunc callback for all new text that is
2426     * generated. This callback should append to any existing text
2427     * buffer and will be passed the pointer @p dumpdata as a parameter
2428     * as well as a string with new text to be appended.
2429     *
2430     * @see eet_data_dump()
2431     *
2432     * @since 1.0.0
2433     * @ingroup Eet_Data_Cipher_Group
2434     */
2435    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);
2436
2437    /**
2438     * Take an ascii encoding from eet_data_dump() and re-encode in
2439     * binary using a cipher.
2440     * @param ef A valid eet file handle.
2441     * @param name Name of the entry. eg: "/base/file_i_want".
2442     * @param cipher_key The key to use as cipher.
2443     * @param text The pointer to the string data to parse and encode.
2444     * @param textlen The size of the string in bytes (not including 0
2445     *        byte terminator).
2446     * @param compress Compression flags (1 == compress, 0 = don't compress).
2447     * @return 1 on success, 0 on failure
2448     *
2449     * This function will parse the string pointed to by @p text,
2450     * encode it the same way eet_data_descriptor_encode() takes an
2451     * in-memory data struct and encodes into a binary blob.
2452     *
2453     * The data (optionally compressed) will be in ram, pending a flush to
2454     * disk (it will stay in ram till the eet file handle is closed though).
2455     *
2456     * @see eet_data_undump()
2457     *
2458     * @since 1.0.0
2459     * @ingroup Eet_Data_Cipher_Group
2460     */
2461    EAPI int eet_data_undump_cipher(Eet_File *ef, const char *name, const char *cipher_key, const char *text, int textlen, int compress);
2462
2463    /**
2464     * Decode a data structure from an arbitary location in memory
2465     * using a cipher.
2466     * @param edd The data  descriptor to use when decoding.
2467     * @param data_in The pointer to the data to decode into a struct.
2468     * @param cipher_key The key to use as cipher.
2469     * @param size_in The size of the data pointed to in bytes.
2470     * @return NULL on failure, or a valid decoded struct pointer on success.
2471     *
2472     * This function will decode a data structure that has been encoded using
2473     * eet_data_descriptor_encode(), and return a data structure with all its
2474     * elements filled out, if successful, or NULL on failure.
2475     *
2476     * The data to be decoded is stored at the memory pointed to by @p data_in,
2477     * and is described by the descriptor pointed to by @p edd. The data size is
2478     * passed in as the value to @p size_in, ande must be greater than 0 to
2479     * succeed.
2480     *
2481     * This function is useful for decoding data structures delivered to the
2482     * application by means other than an eet file, such as an IPC or socket
2483     * connection, raw files, shared memory etc.
2484     *
2485     * Please see eet_data_read() for more information.
2486     *
2487     * @see eet_data_descriptor_decode()
2488     *
2489     * @since 1.0.0
2490     * @ingroup Eet_Data_Cipher_Group
2491     */
2492    EAPI void *eet_data_descriptor_decode_cipher(Eet_Data_Descriptor *edd, const void *data_in, const char *cipher_key, int size_in);
2493
2494    /**
2495     * Encode a data struct to memory and return that encoded data
2496     * using a cipher.
2497     * @param edd The data  descriptor to use when encoding.
2498     * @param data_in The pointer to the struct to encode into data.
2499     * @param cipher_key The key to use as cipher.
2500     * @param size_ret pointer to the an int to be filled with the decoded size.
2501     * @return NULL on failure, or a valid encoded data chunk on success.
2502     *
2503     * This function takes a data structutre in memory and encodes it into a
2504     * serialised chunk of data that can be decoded again by
2505     * eet_data_descriptor_decode(). This is useful for being able to transmit
2506     * data structures across sockets, pipes, IPC or shared file mechanisms,
2507     * without having to worry about memory space, machine type, endianess etc.
2508     *
2509     * The parameter @p edd must point to a valid data descriptor, and
2510     * @p data_in must point to the right data structure to encode. If not, the
2511     * encoding may fail.
2512     *
2513     * On success a non NULL valid pointer is returned and what @p size_ret
2514     * points to is set to the size of this decoded data, in bytes. When the
2515     * encoded data is no longer needed, call free() on it. On failure NULL is
2516     * returned and what @p size_ret points to is set to 0.
2517     *
2518     * Please see eet_data_write() for more information.
2519     *
2520     * @see eet_data_descriptor_encode()
2521     *
2522     * @since 1.0.0
2523     * @ingroup Eet_Data_Cipher_Group
2524     */
2525    EAPI void *eet_data_descriptor_encode_cipher(Eet_Data_Descriptor *edd, const void *data_in, const char *cipher_key, int *size_ret);
2526
2527   /**
2528    * @defgroup Eet_Node_Group Low-level Serialization Structures.
2529    *
2530    * Functions that create, destroy and manipulate serialization nodes
2531    * used by @ref Eet_Data_Group.
2532    *
2533    * @{
2534    */
2535
2536   /**
2537    * @typedef Eet_Node
2538    * Opaque handle to manage serialization node.
2539    */
2540    typedef struct _Eet_Node                  Eet_Node;
2541
2542   /**
2543    * @typedef Eet_Node_Data
2544    * Contains an union that can fit any kind of node.
2545    */
2546    typedef struct _Eet_Node_Data             Eet_Node_Data;
2547
2548   /**
2549    * @struct _Eet_Node_Data
2550    * Contains an union that can fit any kind of node.
2551    */
2552    struct _Eet_Node_Data
2553    {
2554       union {
2555          char c;
2556          short s;
2557          int i;
2558          long long l;
2559          float f;
2560          double d;
2561          unsigned char uc;
2562          unsigned short us;
2563          unsigned int ui;
2564          unsigned long long ul;
2565          const char *str;
2566       } value;
2567    };
2568
2569   /**
2570    * @}
2571    */
2572
2573   /**
2574    * TODO FIX ME
2575    * @ingroup Eet_Node_Group
2576    */
2577    EAPI Eet_Node *eet_node_char_new(const char *name, char c);
2578
2579   /**
2580    * TODO FIX ME
2581    * @ingroup Eet_Node_Group
2582    */
2583    EAPI Eet_Node *eet_node_short_new(const char *name, short s);
2584
2585   /**
2586    * TODO FIX ME
2587    * @ingroup Eet_Node_Group
2588    */
2589    EAPI Eet_Node *eet_node_int_new(const char *name, int i);
2590
2591   /**
2592    * TODO FIX ME
2593    * @ingroup Eet_Node_Group
2594    */
2595    EAPI Eet_Node *eet_node_long_long_new(const char *name, long long l);
2596
2597   /**
2598    * TODO FIX ME
2599    * @ingroup Eet_Node_Group
2600    */
2601    EAPI Eet_Node *eet_node_float_new(const char *name, float f);
2602
2603   /**
2604    * TODO FIX ME
2605    * @ingroup Eet_Node_Group
2606    */
2607    EAPI Eet_Node *eet_node_double_new(const char *name, double d);
2608
2609   /**
2610    * TODO FIX ME
2611    * @ingroup Eet_Node_Group
2612    */
2613    EAPI Eet_Node *eet_node_unsigned_char_new(const char *name, unsigned char uc);
2614
2615   /**
2616    * TODO FIX ME
2617    * @ingroup Eet_Node_Group
2618    */
2619    EAPI Eet_Node *eet_node_unsigned_short_new(const char *name, unsigned short us);
2620
2621   /**
2622    * TODO FIX ME
2623    * @ingroup Eet_Node_Group
2624    */
2625    EAPI Eet_Node *eet_node_unsigned_int_new(const char *name, unsigned int ui);
2626
2627   /**
2628    * TODO FIX ME
2629    * @ingroup Eet_Node_Group
2630    */
2631    EAPI Eet_Node *eet_node_unsigned_long_long_new(const char *name, unsigned long long l);
2632
2633   /**
2634    * TODO FIX ME
2635    * @ingroup Eet_Node_Group
2636    */
2637    EAPI Eet_Node *eet_node_string_new(const char *name, const char *str);
2638
2639   /**
2640    * TODO FIX ME
2641    * @ingroup Eet_Node_Group
2642    */
2643    EAPI Eet_Node *eet_node_inlined_string_new(const char *name, const char *str);
2644
2645   /**
2646    * TODO FIX ME
2647    * @ingroup Eet_Node_Group
2648    */
2649    EAPI Eet_Node *eet_node_null_new(const char *name);
2650
2651   /**
2652    * TODO FIX ME
2653    * @ingroup Eet_Node_Group
2654    */
2655    EAPI Eet_Node *eet_node_list_new(const char *name, Eina_List *nodes);
2656
2657   /**
2658    * TODO FIX ME
2659    * @ingroup Eet_Node_Group
2660    */
2661    EAPI Eet_Node *eet_node_array_new(const char *name, int count, Eina_List *nodes);
2662
2663   /**
2664    * TODO FIX ME
2665    * @ingroup Eet_Node_Group
2666    */
2667    EAPI Eet_Node *eet_node_var_array_new(const char *name, Eina_List *nodes);
2668
2669   /**
2670    * TODO FIX ME
2671    * @ingroup Eet_Node_Group
2672    */
2673    EAPI Eet_Node *eet_node_hash_new(const char *name, const char *key, Eet_Node *node);
2674
2675   /**
2676    * TODO FIX ME
2677    * @ingroup Eet_Node_Group
2678    */
2679    EAPI Eet_Node *eet_node_struct_new(const char *name, Eina_List *nodes);
2680
2681   /**
2682    * TODO FIX ME
2683    * @ingroup Eet_Node_Group
2684    */
2685    EAPI Eet_Node *eet_node_struct_child_new(const char *parent, Eet_Node *child);
2686
2687
2688   /**
2689    * TODO FIX ME
2690    * @ingroup Eet_Node_Group
2691    */
2692    EAPI void eet_node_list_append(Eet_Node *parent, const char *name, Eet_Node *child);
2693
2694   /**
2695    * TODO FIX ME
2696    * @ingroup Eet_Node_Group
2697    */
2698    EAPI void eet_node_struct_append(Eet_Node *parent, const char *name, Eet_Node *child);
2699
2700   /**
2701    * TODO FIX ME
2702    * @ingroup Eet_Node_Group
2703    */
2704    EAPI void eet_node_hash_add(Eet_Node *parent, const char *name, const char *key, Eet_Node *child);
2705
2706
2707   /**
2708    * TODO FIX ME
2709    * @ingroup Eet_Node_Group
2710    */
2711    EAPI void eet_node_dump(Eet_Node *n, int dumplevel, void (*dumpfunc) (void *data, const char *str), void *dumpdata);
2712
2713   /**
2714    * TODO FIX ME
2715    * @ingroup Eet_Node_Group
2716    */
2717    EAPI void eet_node_del(Eet_Node *n);
2718
2719   /**
2720    * TODO FIX ME
2721    * @ingroup Eet_Node_Group
2722    */
2723    EAPI void *eet_data_node_encode_cipher(Eet_Node *node, const char *cipher_key, int *size_ret);
2724
2725   /**
2726    * TODO FIX ME
2727    * @ingroup Eet_Node_Group
2728    */
2729    EAPI Eet_Node *eet_data_node_decode_cipher(const void *data_in, const char *cipher_key, int size_in);
2730
2731   /**
2732    * TODO FIX ME
2733    * @ingroup Eet_Node_Group
2734    */
2735    EAPI Eet_Node *eet_data_node_read_cipher(Eet_File *ef, const char *name, const char *cipher_key);
2736
2737   /**
2738    * TODO FIX ME
2739    * @ingroup Eet_Node_Group
2740    */
2741    EAPI int eet_data_node_write_cipher(Eet_File *ef, const char *name, const char *cipher_key, Eet_Node *node, int compress);
2742
2743   /* EXPERIMENTAL: THIS API MAY CHANGE IN THE FUTURE, USE IT ONLY IF YOU KNOW WHAT YOU ARE DOING. */
2744
2745   /**
2746    * @typedef Eet_Node_Walk
2747    * Describes how to walk trees of #Eet_Node.
2748    */
2749    typedef struct _Eet_Node_Walk             Eet_Node_Walk;
2750
2751   /**
2752    * @struct _Eet_Node_Walk
2753    * Describes how to walk trees of #Eet_Node.
2754    */
2755    struct _Eet_Node_Walk
2756    {
2757       void *(*struct_alloc)(const char *type, void *user_data);
2758       void (*struct_add)(void *parent, const char *name, void *child, void *user_data);
2759       void *(*array)(Eina_Bool variable, const char *name, int count, void *user_data);
2760       void (*insert)(void *array, int index, void *child, void *user_data);
2761       void *(*list)(const char *name, void *user_data);
2762       void (*append)(void *list, void *child, void *user_data);
2763       void *(*hash)(void *parent, const char *name, const char *key, void *value, void *user_data);
2764       void *(*simple)(int type, Eet_Node_Data *data, void *user_data);
2765    };
2766
2767    EAPI void *eet_node_walk(void *parent, const char *name, Eet_Node *root, Eet_Node_Walk *cb, void *user_data);
2768
2769   /*******/
2770
2771   /**
2772    * @defgroup Eet_Connection_Group Helper function to use eet over a network link
2773    *
2774    * Function that reconstruct and prepare packet of @ref Eet_Data_Group to be send.
2775    *
2776    */
2777
2778   /**
2779    * @typedef Eet_Connection
2780    * Opaque handle to track paquet for a specific connection.
2781    *
2782    * @ingroup Eet_Connection_Group
2783    */
2784    typedef struct _Eet_Connection Eet_Connection;
2785
2786   /**
2787    * @typedef Eet_Read_Cb
2788    * Called back when an @ref Eet_Data_Group has been received completly and could be used.
2789    *
2790    * @ingroup Eet_Connection_Group
2791    */
2792    typedef Eina_Bool Eet_Read_Cb(const void *eet_data, size_t size, void *user_data);
2793
2794   /**
2795    * @typedef Eet_Write_Cb
2796    * Called back when a packet containing @ref Eet_Data_Group data is ready to be send.
2797    *
2798    * @ingroup Eet_Connection_Group
2799    */
2800    typedef Eina_Bool Eet_Write_Cb(const void *data, size_t size, void *user_data);
2801
2802   /**
2803    * Instanciate a new connection to track.
2804    * @oaram eet_read_cb Function to call when one Eet_Data packet has been fully assemble.
2805    * @param eet_write_cb Function to call when one Eet_Data packet is ready to be send over the wire.
2806    * @param user_data Pointer provided to both functions to be used as a context handler.
2807    * @return NULL on failure, or a valid Eet_Connection handler.
2808    *
2809    * For every connection to track you will need a separate Eet_Connection provider.
2810    *
2811    * @since 1.2.4
2812    * @ingroup Eet_Connection_Group
2813    */
2814    Eet_Connection *eet_connection_new(Eet_Read_Cb *eet_read_cb, Eet_Write_Cb *eet_write_cb, const void *user_data);
2815
2816   /**
2817    * Process a raw packet received over the link
2818    * @oaram conn Connection handler to track.
2819    * @param data Raw data packet.
2820    * @param size The size of that packet.
2821    * @return 0 on complete success, any other value indicate where in the stream it got wrong (It could be before that packet).
2822    *
2823    * Every time you receive a packet related to your connection, you should pass
2824    * it to that function so that it could process and assemble packet has you
2825    * receive it. It will automatically call Eet_Read_Cb when one is fully received.
2826    *
2827    * @since 1.2.4
2828    * @ingroup Eet_Connection_Group
2829    */
2830    int eet_connection_received(Eet_Connection *conn, const void *data, size_t size);
2831
2832   /**
2833    * Convert a complex structure and prepare it to be send.
2834    * @oaram conn Connection handler to track.
2835    * @param edd The data descriptor to use when encoding.
2836    * @param data_in The pointer to the struct to encode into data.
2837    * @param cipher_key The key to use as cipher.
2838    * @return EINA_TRUE if the data where correctly send, EINA_FALSE if they don't.
2839    *
2840    * This function serialize data_in with edd, assemble the packet and call
2841    * Eet_Write_Cb when ready. The data passed Eet_Write_Cb are temporary allocated
2842    * and will vanish just after the return of the callback.
2843    *
2844    * @see eet_data_descriptor_encode_cipher
2845    *
2846    * @since 1.2.4
2847    * @ingroup Eet_Connection_Group
2848    */
2849    Eina_Bool eet_connection_send(Eet_Connection *conn, Eet_Data_Descriptor *edd, const void *data_in, const char *cipher_key);
2850
2851   /**
2852    * Convert a Eet_Node tree and prepare it to be send.
2853    * @oaram conn Connection handler to track.
2854    * @param node The data tree to use when encoding.
2855    * @param cipher_key The key to use as cipher.
2856    * @return EINA_TRUE if the data where correctly send, EINA_FALSE if they don't.
2857    *
2858    * This function serialize node, assemble the packet and call
2859    * Eet_Write_Cb when ready. The data passed Eet_Write_Cb are temporary allocated
2860    * and will vanish just after the return of the callback.
2861    *
2862    * @see eet_data_node_encode_cipher
2863    *
2864    * @since 1.2.4
2865    * @ingroup Eet_Connection_Group
2866    */
2867    Eina_Bool eet_connection_node_send(Eet_Connection *conn, Eet_Node *node, const char *cipher_key);
2868
2869   /**
2870    * Close a connection and lost its track.
2871    * @oaram conn Connection handler to close.
2872    * @param on_going Signal if a partial packet wasn't completed.
2873    * @return the user_data passed to both callback.
2874    *
2875    * @since 1.2.4
2876    * @ingroup Eet_Connection_Group
2877    */
2878    void *eet_connection_close(Eet_Connection *conn, Eina_Bool *on_going);
2879
2880 /***************************************************************************/
2881
2882 #ifdef __cplusplus
2883 }
2884 #endif
2885
2886 #endif