10 #endif /* ifdef EAPI */
15 # define EAPI __declspec(dllexport)
16 # else /* ifdef DLL_EXPORT */
18 # endif /* ! DLL_EXPORT */
19 # else /* ifdef EFL_EET_BUILD */
20 # define EAPI __declspec(dllimport)
21 # endif /* ! EFL_EET_BUILD */
22 #else /* ifdef _WIN32 */
25 # define EAPI __attribute__ ((visibility("default")))
26 # else /* if __GNUC__ >= 4 */
28 # endif /* if __GNUC__ >= 4 */
29 # else /* ifdef __GNUC__ */
31 # endif /* ifdef __GNUC__ */
36 #endif /* ifdef __cplusplus */
40 * @brief The file that provides the eet functions.
42 * This header provides the Eet management functions.
46 #define EET_VERSION_MAJOR 1
47 #define EET_VERSION_MINOR 3
49 * @typedef Eet_Version
51 * This is the Eet version information structure that can be used at
52 * runtiime to detect which version of eet is being used and adapt
53 * appropriately as follows for example:
56 * #if defined(EET_VERSION_MAJOR) && (EET_VERSION_MAJOR >= 1) && defined(EET_VERSION_MINOR) && (EET_VERSION_MINOR > 2)
57 * printf("Eet version: %i.%i.%i\n",
60 * eet_version->micro);
61 * if (eet_version->revision > 0)
63 * printf(" Built from SVN revision # %i\n", eet_version->revision);
68 * Note the #if check can be dropped if your program refuses to compile or
69 * work with an Eet version less than 1.3.0.
71 typedef struct _Eet_Version
73 int major; /** < major (binary or source incompatible changes) */
74 int minor; /** < minor (new features, bugfixes, major improvements version) */
75 int micro; /** < micro (bugfix, internal improvements, no new features version) */
76 int revision; /** < svn revision (0 if a proper rlease or the svn revsion number Eet is built from) */
79 EAPI extern Eet_Version *eet_version;
82 * @defgroup Eet_Group Top level functions
83 * Functions that affect Eet as a whole.
90 * All the error identifiers known by Eet.
92 typedef enum _Eet_Error
94 EET_ERROR_NONE, /**< No error, it's all fine! */
95 EET_ERROR_BAD_OBJECT, /**< Given object or handle is NULL or invalid */
96 EET_ERROR_EMPTY, /**< There was nothing to do */
97 EET_ERROR_NOT_WRITABLE, /**< Could not write to file or fine is #EET_FILE_MODE_READ */
98 EET_ERROR_OUT_OF_MEMORY, /**< Could not allocate memory */
99 EET_ERROR_WRITE_ERROR, /**< Failed to write data to destination */
100 EET_ERROR_WRITE_ERROR_FILE_TOO_BIG, /**< Failed to write file since it is too big */
101 EET_ERROR_WRITE_ERROR_IO_ERROR, /**< Failed to write since generic Input/Output error */
102 EET_ERROR_WRITE_ERROR_OUT_OF_SPACE, /**< Failed to write due out of space */
103 EET_ERROR_WRITE_ERROR_FILE_CLOSED, /**< Failed to write because file was closed */
104 EET_ERROR_MMAP_FAILED, /**< Could not mmap file */
105 EET_ERROR_X509_ENCODING_FAILED, /**< Could not encode using X509 */
106 EET_ERROR_SIGNATURE_FAILED, /**< Could not validate signature */
107 EET_ERROR_INVALID_SIGNATURE, /**< Signature is invalid */
108 EET_ERROR_NOT_SIGNED, /**< File or contents are not signed */
109 EET_ERROR_NOT_IMPLEMENTED, /**< Function is not implemented */
110 EET_ERROR_PRNG_NOT_SEEDED, /**< Could not introduce random seed */
111 EET_ERROR_ENCRYPT_FAILED, /**< Could not encrypt contents */
112 EET_ERROR_DECRYPT_FAILED /**< Could not decrypt contents */
113 } Eet_Error; /**< Eet error identifiers */
120 * Initialize the EET library.
122 * @return The new init count.
127 EAPI int eet_init(void);
130 * Shut down the EET library.
132 * @return The new init count.
137 EAPI int eet_shutdown(void);
142 * Eet didn't free items by default. If you are under memory
143 * presure, just call this function to recall all memory that are
144 * not yet referenced anymore. The cache take care of modification
150 EAPI void eet_clearcache(void);
153 * @defgroup Eet_File_Group Eet File Main Functions
155 * Functions to create, destroy and do basic manipulation of
162 * @enum _Eet_File_Mode
163 * Modes that a file can be opened.
165 typedef enum _Eet_File_Mode
167 EET_FILE_MODE_INVALID = -1,
168 EET_FILE_MODE_READ, /**< File is read-only. */
169 EET_FILE_MODE_WRITE, /**< File is write-only. */
170 EET_FILE_MODE_READ_WRITE /**< File is for both read and write */
171 } Eet_File_Mode; /**< Modes that a file can be opened. */
175 * Opaque handle that defines an Eet file (or memory).
178 * @see eet_memopen_read()
181 typedef struct _Eet_File Eet_File;
184 * @typedef Eet_Dictionary
185 * Opaque handle that defines a file-backed (mmaped) dictionary of strings.
187 typedef struct _Eet_Dictionary Eet_Dictionary;
194 * Open an eet file on disk, and returns a handle to it.
195 * @param file The file path to the eet file. eg: @c "/tmp/file.eet".
196 * @param mode The mode for opening. Either #EET_FILE_MODE_READ,
197 * #EET_FILE_MODE_WRITE or #EET_FILE_MODE_READ_WRITE.
198 * @return An opened eet file handle.
199 * @ingroup Eet_File_Group
201 * This function will open an exiting eet file for reading, and build
202 * the directory table in memory and return a handle to the file, if it
203 * exists and can be read, and no memory errors occur on the way, otherwise
204 * NULL will be returned.
206 * It will also open an eet file for writing. This will, if successful,
207 * delete the original file and replace it with a new empty file, till
208 * the eet file handle is closed or flushed. If it cannot be opened for
209 * writing or a memory error occurs, NULL is returned.
211 * You can also open the file for read/write. If you then write a key that
212 * does not exist it will be created, if the key exists it will be replaced
219 * #include <string.h>
222 * main(int argc, char **argv)
225 * char buf[1024], *ret, **list;
230 * strcpy(buf, "Here is a string of data to save!");
232 * ef = eet_open("/tmp/my_file.eet", EET_FILE_MODE_WRITE);
233 * if (!ef) return -1;
234 * if (!eet_write(ef, "/key/to_store/at", buf, 1024, 1))
235 * fprintf(stderr, "Error writing data!\n");
238 * ef = eet_open("/tmp/my_file.eet", EET_FILE_MODE_READ);
239 * if (!ef) return -1;
240 * list = eet_list(ef, "*", &num);
243 * for (i = 0; i < num; i++)
244 * printf("Key stored: %s\n", list[i]);
247 * ret = eet_read(ef, "/key/to_store/at", &size);
250 * printf("Data read (%i bytes):\n%s\n", size, ret);
263 EAPI Eet_File * eet_open(const char *file,
267 * Open an eet file directly from a memory location. The data are not copied,
268 * so you must keep them around as long as the eet file is open. Their is
269 * currently no cache for this kind of Eet_File, so it's reopen every time
270 * you do use eet_memopen_read.
273 * @ingroup Eet_File_Group
275 EAPI Eet_File * eet_memopen_read(const void *data,
279 * Get the mode an Eet_File was opened with.
280 * @param ef A valid eet file handle.
281 * @return The mode ef was opened with.
284 * @ingroup Eet_File_Group
286 EAPI Eet_File_Mode eet_mode_get(Eet_File *ef);
289 * Close an eet file handle and flush and writes pending.
290 * @param ef A valid eet file handle.
292 * This function will flush any pending writes to disk if the eet file
293 * was opened for write, and free all data associated with the file handle
294 * and file, and close the file.
296 * If the eet file handle is not valid nothing will be done.
299 * @ingroup Eet_File_Group
301 EAPI Eet_Error eet_close(Eet_File *ef);
304 * Sync content of an eet file handle, flushing pending writes.
305 * @param ef A valid eet file handle.
307 * This function will flush any pending writes to disk. The eet file must
308 * be opened for write.
310 * If the eet file handle is not valid nothing will be done.
313 * @ingroup Eet_File_Group
315 EAPI Eet_Error eet_sync(Eet_File *ef);
318 * Return a handle to the shared string dictionary of the Eet file
319 * @param ef A valid eet file handle.
320 * @return A handle to the dictionary of the file
322 * This function returns a handle to the dictionary of an Eet file whose
323 * handle is @p ef, if a dictionary exists. NULL is returned otherwise or
324 * if the file handle is known to be invalid.
326 * @see eet_dictionary_string_check() to know if given string came
327 * from the dictionary or it was dynamically allocated using
328 * the #Eet_Data_Descriptor_Class instructrions.
331 * @ingroup Eet_File_Group
333 EAPI Eet_Dictionary * eet_dictionary_get(Eet_File *ef);
336 * Check if a given string comes from a given dictionary
337 * @param ed A valid dictionary handle
338 * @param string A valid 0 byte terminated C string
339 * @return 1 if it is in the dictionary, 0 otherwise
341 * This checks the given dictionary to see if the given string is actually
342 * inside that dictionary (i.e. comes from it) and returns 1 if it does.
343 * If the dictionary handle is invlide, the string is NULL or the string is
344 * not in the dictionary, 0 is returned.
347 * @ingroup Eet_File_Group
349 EAPI int eet_dictionary_string_check(Eet_Dictionary *ed,
353 * Read a specified entry from an eet file and return data
354 * @param ef A valid eet file handle opened for reading.
355 * @param name Name of the entry. eg: "/base/file_i_want".
356 * @param size_ret Number of bytes read from entry and returned.
357 * @return The data stored in that entry in the eet file.
359 * This function finds an entry in the eet file that is stored under the
360 * name specified, and returns that data, decompressed, if successful.
361 * NULL is returned if the lookup fails or if memory errors are
362 * encountered. It is the job of the calling program to call free() on
363 * the returned data. The number of bytes in the returned data chunk are
364 * placed in size_ret.
366 * If the eet file handle is not valid NULL is returned and size_ret is
369 * @see eet_read_cipher()
372 * @ingroup Eet_File_Group
374 EAPI void * eet_read(Eet_File *ef,
379 * Read a specified entry from an eet file and return data
380 * @param ef A valid eet file handle opened for reading.
381 * @param name Name of the entry. eg: "/base/file_i_want".
382 * @param size_ret Number of bytes read from entry and returned.
383 * @return The data stored in that entry in the eet file.
385 * This function finds an entry in the eet file that is stored under the
386 * name specified, and returns that data if not compressed and successful.
387 * NULL is returned if the lookup fails or if memory errors are
388 * encountered or if the data is comrpessed. The calling program must never
389 * call free() on the returned data. The number of bytes in the returned
390 * data chunk are placed in size_ret.
392 * If the eet file handle is not valid NULL is returned and size_ret is
396 * @ingroup Eet_File_Group
398 EAPI const void * eet_read_direct(Eet_File *ef,
403 * Write a specified entry to an eet file handle
404 * @param ef A valid eet file handle opened for writing.
405 * @param name Name of the entry. eg: "/base/file_i_want".
406 * @param data Pointer to the data to be stored.
407 * @param size Length in bytes in the data to be stored.
408 * @param compress Compression flags (1 == compress, 0 = don't compress).
409 * @return bytes written on successful write, 0 on failure.
411 * This function will write the specified chunk of data to the eet file
412 * and return greater than 0 on success. 0 will be returned on failure.
414 * The eet file handle must be a valid file handle for an eet file opened
415 * for writing. If it is not, 0 will be returned and no action will be
418 * Name, and data must not be NULL, and size must be > 0. If these
419 * conditions are not met, 0 will be returned.
421 * The data will be copied (and optionally compressed) in ram, pending
422 * a flush to disk (it will stay in ram till the eet file handle is
425 * @see eet_write_cipher()
428 * @ingroup Eet_File_Group
430 EAPI int eet_write(Eet_File *ef,
437 * Delete a specified entry from an Eet file being written or re-written
438 * @param ef A valid eet file handle opened for writing.
439 * @param name Name of the entry. eg: "/base/file_i_want".
440 * @return Success or failure of the delete.
442 * This function will delete the specified chunk of data from the eet file
443 * and return greater than 0 on success. 0 will be returned on failure.
445 * The eet file handle must be a valid file handle for an eet file opened
446 * for writing. If it is not, 0 will be returned and no action will be
449 * Name, must not be NULL, otherwise 0 will be returned.
452 * @ingroup Eet_File_Group
454 EAPI int eet_delete(Eet_File *ef,
458 * Alias a specific section to another one. Destination may exist or not,
460 * @param ef A valid eet file handle opened for writing.
461 * @param name Name of the entry. eg: "/base/file_i_want".
462 * @param destination Destionation of the alias. eg: "/base/the_real_stuff_i_want".
463 * @param compress Compression flags (1 == compress, 0 = don't compress).
464 * @return EINA_TRUE on success, EINA_FALSE on failure.
466 * Name and Destination must not be NULL, otherwhise EINA_FALSE will be returned.
469 * @ingroup Eet_File_Group
471 EAPI Eina_Bool eet_alias(Eet_File *ef,
473 const char *destination,
477 * List all entries in eet file matching shell glob.
478 * @param ef A valid eet file handle.
479 * @param glob A shell glob to match against.
480 * @param count_ret Number of entries found to match.
481 * @return Pointer to an array of strings.
483 * This function will list all entries in the eet file matching the
484 * supplied shell glob and return an allocated list of their names, if
485 * there are any, and if no memory errors occur.
487 * The eet file handle must be valid and glob must not be NULL, or NULL
488 * will be returned and count_ret will be filled with 0.
490 * The calling program must call free() on the array returned, but NOT
491 * on the string pointers in the array. They are taken as read-only
492 * internals from the eet file handle. They are only valid as long as
493 * the file handle is not closed. When it is closed those pointers in the
494 * array are now not valid and should not be used.
496 * On success the array returned will have a list of string pointers
497 * that are the names of the entries that matched, and count_ret will have
498 * the number of entries in this array placed in it.
500 * Hint: an easy way to list all entries in an eet file is to use a glob
504 * @ingroup Eet_File_Group
506 EAPI char ** eet_list(Eet_File *ef,
511 * Return the number of entries in the specified eet file.
512 * @param ef A valid eet file handle.
513 * @return Number of entries in ef or -1 if the number of entries
514 * cannot be read due to open mode restrictions.
517 * @ingroup Eet_File_Group
519 EAPI int eet_num_entries(Eet_File *ef);
522 * @defgroup Eet_File_Cipher_Group Eet File Ciphered Main Functions
524 * Most of the @ref Eet_File_Group have alternative versions that
525 * accounts for ciphers to protect their content.
527 * @see @ref Eet_Cipher_Group
529 * @ingroup Eet_File_Group
533 * Read a specified entry from an eet file and return data using a cipher.
534 * @param ef A valid eet file handle opened for reading.
535 * @param name Name of the entry. eg: "/base/file_i_want".
536 * @param size_ret Number of bytes read from entry and returned.
537 * @param cipher_key The key to use as cipher.
538 * @return The data stored in that entry in the eet file.
540 * This function finds an entry in the eet file that is stored under the
541 * name specified, and returns that data, decompressed, if successful.
542 * NULL is returned if the lookup fails or if memory errors are
543 * encountered. It is the job of the calling program to call free() on
544 * the returned data. The number of bytes in the returned data chunk are
545 * placed in size_ret.
547 * If the eet file handle is not valid NULL is returned and size_ret is
553 * @ingroup Eet_File_Cipher_Group
555 EAPI void * eet_read_cipher(Eet_File *ef,
558 const char *cipher_key);
561 * Write a specified entry to an eet file handle using a cipher.
562 * @param ef A valid eet file handle opened for writing.
563 * @param name Name of the entry. eg: "/base/file_i_want".
564 * @param data Pointer to the data to be stored.
565 * @param size Length in bytes in the data to be stored.
566 * @param compress Compression flags (1 == compress, 0 = don't compress).
567 * @param cipher_key The key to use as cipher.
568 * @return bytes written on successful write, 0 on failure.
570 * This function will write the specified chunk of data to the eet file
571 * and return greater than 0 on success. 0 will be returned on failure.
573 * The eet file handle must be a valid file handle for an eet file opened
574 * for writing. If it is not, 0 will be returned and no action will be
577 * Name, and data must not be NULL, and size must be > 0. If these
578 * conditions are not met, 0 will be returned.
580 * The data will be copied (and optionally compressed) in ram, pending
581 * a flush to disk (it will stay in ram till the eet file handle is
587 * @ingroup Eet_File_Cipher_Group
589 EAPI int eet_write_cipher(Eet_File *ef,
594 const char *cipher_key);
597 * @defgroup Eet_File_Image_Group Image Store and Load
599 * Eet efficiently stores and loads images, including alpha
600 * channels and lossy compressions.
604 * Read just the header data for an image and dont decode the pixels.
605 * @param ef A valid eet file handle opened for reading.
606 * @param name Name of the entry. eg: "/base/file_i_want".
607 * @param w A pointer to the unsigned int to hold the width in pixels.
608 * @param h A pointer to the unsigned int to hold the height in pixels.
609 * @param alpha A pointer to the int to hold the alpha flag.
610 * @param compress A pointer to the int to hold the compression amount.
611 * @param quality A pointer to the int to hold the quality amount.
612 * @param lossy A pointer to the int to hold the lossiness flag.
613 * @return 1 on successfull decode, 0 otherwise
615 * This function reads an image from an eet file stored under the named
616 * key in the eet file and return a pointer to the decompressed pixel data.
618 * The other parameters of the image (width, height etc.) are placed into
619 * the values pointed to (they must be supplied). The pixel data is a linear
620 * array of pixels starting from the top-left of the image scanning row by
621 * row from left to right. Each pile is a 32bit value, with the high byte
622 * being the alpha channel, the next being red, then green, and the low byte
623 * being blue. The width and height are measured in pixels and will be
624 * greater than 0 when returned. The alpha flag is either 0 or 1. 0 denotes
625 * that the alpha channel is not used. 1 denotes that it is significant.
626 * Compress is filled with the compression value/amount the image was
627 * stored with. The quality value is filled with the quality encoding of
628 * the image file (0 - 100). The lossy flags is either 0 or 1 as to if
629 * the image was encoded lossily or not.
631 * On success the function returns 1 indicating the header was read and
632 * decoded properly, or 0 on failure.
634 * @see eet_data_image_header_read_cipher()
637 * @ingroup Eet_File_Image_Group
639 EAPI int eet_data_image_header_read(Eet_File *ef,
649 * Read image data from the named key in the eet file.
650 * @param ef A valid eet file handle opened for reading.
651 * @param name Name of the entry. eg: "/base/file_i_want".
652 * @param w A pointer to the unsigned int to hold the width in pixels.
653 * @param h A pointer to the unsigned int to hold the height in pixels.
654 * @param alpha A pointer to the int to hold the alpha flag.
655 * @param compress A pointer to the int to hold the compression amount.
656 * @param quality A pointer to the int to hold the quality amount.
657 * @param lossy A pointer to the int to hold the lossiness flag.
658 * @return The image pixel data decoded
660 * This function reads an image from an eet file stored under the named
661 * key in the eet file and return a pointer to the decompressed pixel data.
663 * The other parameters of the image (width, height etc.) are placed into
664 * the values pointed to (they must be supplied). The pixel data is a linear
665 * array of pixels starting from the top-left of the image scanning row by
666 * row from left to right. Each pile is a 32bit value, with the high byte
667 * being the alpha channel, the next being red, then green, and the low byte
668 * being blue. The width and height are measured in pixels and will be
669 * greater than 0 when returned. The alpha flag is either 0 or 1. 0 denotes
670 * that the alpha channel is not used. 1 denotes that it is significant.
671 * Compress is filled with the compression value/amount the image was
672 * stored with. The quality value is filled with the quality encoding of
673 * the image file (0 - 100). The lossy flags is either 0 or 1 as to if
674 * the image was encoded lossily or not.
676 * On success the function returns a pointer to the image data decoded. The
677 * calling application is responsible for calling free() on the image data
678 * when it is done with it. On failure NULL is returned and the parameter
679 * values may not contain any sensible data.
681 * @see eet_data_image_read_cipher()
684 * @ingroup Eet_File_Image_Group
686 EAPI void * eet_data_image_read(Eet_File *ef,
696 * Read image data from the named key in the eet file.
697 * @param ef A valid eet file handle opened for reading.
698 * @param name Name of the entry. eg: "/base/file_i_want".
699 * @param src_x The starting x coordinate from where to dump the stream.
700 * @param src_y The starting y coordinate from where to dump the stream.
701 * @param d A pointer to the pixel surface.
702 * @param w The expected width in pixels of the pixel surface to decode.
703 * @param h The expected height in pixels of the pixel surface to decode.
704 * @param row_stride The length of a pixels line in the destination surface.
705 * @param alpha A pointer to the int to hold the alpha flag.
706 * @param compress A pointer to the int to hold the compression amount.
707 * @param quality A pointer to the int to hold the quality amount.
708 * @param lossy A pointer to the int to hold the lossiness flag.
709 * @return 1 on success, 0 otherwise.
711 * This function reads an image from an eet file stored under the named
712 * key in the eet file and return a pointer to the decompressed pixel data.
714 * The other parameters of the image (width, height etc.) are placed into
715 * the values pointed to (they must be supplied). The pixel data is a linear
716 * array of pixels starting from the top-left of the image scanning row by
717 * row from left to right. Each pile is a 32bit value, with the high byte
718 * being the alpha channel, the next being red, then green, and the low byte
719 * being blue. The width and height are measured in pixels and will be
720 * greater than 0 when returned. The alpha flag is either 0 or 1. 0 denotes
721 * that the alpha channel is not used. 1 denotes that it is significant.
722 * Compress is filled with the compression value/amount the image was
723 * stored with. The quality value is filled with the quality encoding of
724 * the image file (0 - 100). The lossy flags is either 0 or 1 as to if
725 * the image was encoded lossily or not.
727 * On success the function returns 1, and 0 on failure. On failure the
728 * parameter values may not contain any sensible data.
730 * @see eet_data_image_read_to_surface_cipher()
733 * @ingroup Eet_File_Image_Group
735 EAPI int eet_data_image_read_to_surface(Eet_File *ef,
742 unsigned int row_stride,
749 * Write image data to the named key in an eet file.
750 * @param ef A valid eet file handle opened for writing.
751 * @param name Name of the entry. eg: "/base/file_i_want".
752 * @param data A pointer to the image pixel data.
753 * @param w The width of the image in pixels.
754 * @param h The height of the image in pixels.
755 * @param alpha The alpha channel flag.
756 * @param compress The compression amount.
757 * @param quality The quality encoding amount.
758 * @param lossy The lossiness flag.
759 * @return Success if the data was encoded and written or not.
761 * This function takes image pixel data and encodes it in an eet file
762 * stored under the supplied name key, and returns how many bytes were
763 * actually written to encode the image data.
765 * The data expected is the same format as returned by eet_data_image_read.
766 * If this is not the case weird things may happen. Width and height must
767 * be between 1 and 8000 pixels. The alpha flags can be 0 or 1 (0 meaning
768 * the alpha values are not useful and 1 meaning they are). Compress can
769 * be from 0 to 9 (0 meaning no compression, 9 meaning full compression).
770 * This is only used if the image is not lossily encoded. Quality is used on
771 * lossy compression and should be a value from 0 to 100. The lossy flag
772 * can be 0 or 1. 0 means encode losslessly and 1 means to encode with
773 * image quality loss (but then have a much smaller encoding).
775 * On success this function returns the number of bytes that were required
776 * to encode the image data, or on failure it returns 0.
778 * @see eet_data_image_write_cipher()
781 * @ingroup Eet_File_Image_Group
783 EAPI int eet_data_image_write(Eet_File *ef,
794 * Decode Image data header only to get information.
795 * @param data The encoded pixel data.
796 * @param size The size, in bytes, of the encoded pixel data.
797 * @param w A pointer to the unsigned int to hold the width in pixels.
798 * @param h A pointer to the unsigned int to hold the height in pixels.
799 * @param alpha A pointer to the int to hold the alpha flag.
800 * @param compress A pointer to the int to hold the compression amount.
801 * @param quality A pointer to the int to hold the quality amount.
802 * @param lossy A pointer to the int to hold the lossiness flag.
803 * @return 1 on success, 0 on failure.
805 * This function takes encoded pixel data and decodes it into raw RGBA
808 * The other parameters of the image (width, height etc.) are placed into
809 * the values pointed to (they must be supplied). The pixel data is a linear
810 * array of pixels starting from the top-left of the image scanning row by
811 * row from left to right. Each pixel is a 32bit value, with the high byte
812 * being the alpha channel, the next being red, then green, and the low byte
813 * being blue. The width and height are measured in pixels and will be
814 * greater than 0 when returned. The alpha flag is either 0 or 1. 0 denotes
815 * that the alpha channel is not used. 1 denotes that it is significant.
816 * Compress is filled with the compression value/amount the image was
817 * stored with. The quality value is filled with the quality encoding of
818 * the image file (0 - 100). The lossy flags is either 0 or 1 as to if
819 * the image was encoded lossily or not.
821 * On success the function returns 1 indicating the header was read and
822 * decoded properly, or 0 on failure.
824 * @see eet_data_image_header_decode_cipher()
827 * @ingroup Eet_File_Image_Group
829 EAPI int eet_data_image_header_decode(const void *data,
839 * Decode Image data into pixel data.
840 * @param data The encoded pixel data.
841 * @param size The size, in bytes, of the encoded pixel data.
842 * @param w A pointer to the unsigned int to hold the width in pixels.
843 * @param h A pointer to the unsigned int to hold the height in pixels.
844 * @param alpha A pointer to the int to hold the alpha flag.
845 * @param compress A pointer to the int to hold the compression amount.
846 * @param quality A pointer to the int to hold the quality amount.
847 * @param lossy A pointer to the int to hold the lossiness flag.
848 * @return The image pixel data decoded
850 * This function takes encoded pixel data and decodes it into raw RGBA
853 * The other parameters of the image (width, height etc.) are placed into
854 * the values pointed to (they must be supplied). The pixel data is a linear
855 * array of pixels starting from the top-left of the image scanning row by
856 * row from left to right. Each pixel is a 32bit value, with the high byte
857 * being the alpha channel, the next being red, then green, and the low byte
858 * being blue. The width and height are measured in pixels and will be
859 * greater than 0 when returned. The alpha flag is either 0 or 1. 0 denotes
860 * that the alpha channel is not used. 1 denotes that it is significant.
861 * Compress is filled with the compression value/amount the image was
862 * stored with. The quality value is filled with the quality encoding of
863 * the image file (0 - 100). The lossy flags is either 0 or 1 as to if
864 * the image was encoded lossily or not.
866 * On success the function returns a pointer to the image data decoded. The
867 * calling application is responsible for calling free() on the image data
868 * when it is done with it. On failure NULL is returned and the parameter
869 * values may not contain any sensible data.
871 * @see eet_data_image_decode_cipher()
874 * @ingroup Eet_File_Image_Group
876 EAPI void * eet_data_image_decode(const void *data,
886 * Decode Image data into pixel data.
887 * @param data The encoded pixel data.
888 * @param size The size, in bytes, of the encoded pixel data.
889 * @param src_x The starting x coordinate from where to dump the stream.
890 * @param src_y The starting y coordinate from where to dump the stream.
891 * @param d A pointer to the pixel surface.
892 * @param w The expected width in pixels of the pixel surface to decode.
893 * @param h The expected height in pixels of the pixel surface to decode.
894 * @param row_stride The length of a pixels line in the destination surface.
895 * @param alpha A pointer to the int to hold the alpha flag.
896 * @param compress A pointer to the int to hold the compression amount.
897 * @param quality A pointer to the int to hold the quality amount.
898 * @param lossy A pointer to the int to hold the lossiness flag.
899 * @return 1 on success, 0 otherwise.
901 * This function takes encoded pixel data and decodes it into raw RGBA
904 * The other parameters of the image (alpha, compress etc.) are placed into
905 * the values pointed to (they must be supplied). The pixel data is a linear
906 * array of pixels starting from the top-left of the image scanning row by
907 * row from left to right. Each pixel is a 32bit value, with the high byte
908 * being the alpha channel, the next being red, then green, and the low byte
909 * being blue. The width and height are measured in pixels and will be
910 * greater than 0 when returned. The alpha flag is either 0 or 1. 0 denotes
911 * that the alpha channel is not used. 1 denotes that it is significant.
912 * Compress is filled with the compression value/amount the image was
913 * stored with. The quality value is filled with the quality encoding of
914 * the image file (0 - 100). The lossy flags is either 0 or 1 as to if
915 * the image was encoded lossily or not.
917 * On success the function returns 1, and 0 on failure. On failure the
918 * parameter values may not contain any sensible data.
920 * @see eet_data_image_decode_to_surface_cipher()
923 * @ingroup Eet_File_Image_Group
925 EAPI int eet_data_image_decode_to_surface(const void *data,
932 unsigned int row_stride,
939 * Encode image data for storage or transmission.
940 * @param data A pointer to the image pixel data.
941 * @param size_ret A pointer to an int to hold the size of the returned data.
942 * @param w The width of the image in pixels.
943 * @param h The height of the image in pixels.
944 * @param alpha The alpha channel flag.
945 * @param compress The compression amount.
946 * @param quality The quality encoding amount.
947 * @param lossy The lossiness flag.
948 * @return The encoded image data.
950 * This function stakes image pixel data and encodes it with compression and
951 * possible loss of quality (as a trade off for size) for storage or
952 * transmission to another system.
954 * The data expected is the same format as returned by eet_data_image_read.
955 * If this is not the case weird things may happen. Width and height must
956 * be between 1 and 8000 pixels. The alpha flags can be 0 or 1 (0 meaning
957 * the alpha values are not useful and 1 meaning they are). Compress can
958 * be from 0 to 9 (0 meaning no compression, 9 meaning full compression).
959 * This is only used if the image is not lossily encoded. Quality is used on
960 * lossy compression and should be a value from 0 to 100. The lossy flag
961 * can be 0 or 1. 0 means encode losslessly and 1 means to encode with
962 * image quality loss (but then have a much smaller encoding).
964 * On success this function returns a pointer to the encoded data that you
965 * can free with free() when no longer needed.
967 * @see eet_data_image_encode_cipher()
970 * @ingroup Eet_File_Image_Group
972 EAPI void * eet_data_image_encode(const void *data,
982 * @defgroup Eet_File_Image_Cipher_Group Image Store and Load using a Cipher
984 * Most of the @ref Eet_File_Image_Group have alternative versions
985 * that accounts for ciphers to protect their content.
987 * @see @ref Eet_Cipher_Group
989 * @ingroup Eet_File_Image_Group
993 * Read just the header data for an image and dont decode the pixels using a cipher.
994 * @param ef A valid eet file handle opened for reading.
995 * @param name Name of the entry. eg: "/base/file_i_want".
996 * @param cipher_key The key to use as cipher.
997 * @param w A pointer to the unsigned int to hold the width in pixels.
998 * @param h A pointer to the unsigned int to hold the height in pixels.
999 * @param alpha A pointer to the int to hold the alpha flag.
1000 * @param compress A pointer to the int to hold the compression amount.
1001 * @param quality A pointer to the int to hold the quality amount.
1002 * @param lossy A pointer to the int to hold the lossiness flag.
1003 * @return 1 on successfull decode, 0 otherwise
1005 * This function reads an image from an eet file stored under the named
1006 * key in the eet file and return a pointer to the decompressed pixel data.
1008 * The other parameters of the image (width, height etc.) are placed into
1009 * the values pointed to (they must be supplied). The pixel data is a linear
1010 * array of pixels starting from the top-left of the image scanning row by
1011 * row from left to right. Each pile is a 32bit value, with the high byte
1012 * being the alpha channel, the next being red, then green, and the low byte
1013 * being blue. The width and height are measured in pixels and will be
1014 * greater than 0 when returned. The alpha flag is either 0 or 1. 0 denotes
1015 * that the alpha channel is not used. 1 denotes that it is significant.
1016 * Compress is filled with the compression value/amount the image was
1017 * stored with. The quality value is filled with the quality encoding of
1018 * the image file (0 - 100). The lossy flags is either 0 or 1 as to if
1019 * the image was encoded lossily or not.
1021 * On success the function returns 1 indicating the header was read and
1022 * decoded properly, or 0 on failure.
1024 * @see eet_data_image_header_read()
1027 * @ingroup Eet_File_Image_Cipher_Group
1029 EAPI int eet_data_image_header_read_cipher(Eet_File *ef,
1031 const char *cipher_key,
1040 * Read image data from the named key in the eet file using a cipher.
1041 * @param ef A valid eet file handle opened for reading.
1042 * @param name Name of the entry. eg: "/base/file_i_want".
1043 * @param cipher_key The key to use as cipher.
1044 * @param w A pointer to the unsigned int to hold the width in pixels.
1045 * @param h A pointer to the unsigned int to hold the height in pixels.
1046 * @param alpha A pointer to the int to hold the alpha flag.
1047 * @param compress A pointer to the int to hold the compression amount.
1048 * @param quality A pointer to the int to hold the quality amount.
1049 * @param lossy A pointer to the int to hold the lossiness flag.
1050 * @return The image pixel data decoded
1052 * This function reads an image from an eet file stored under the named
1053 * key in the eet file and return a pointer to the decompressed pixel data.
1055 * The other parameters of the image (width, height etc.) are placed into
1056 * the values pointed to (they must be supplied). The pixel data is a linear
1057 * array of pixels starting from the top-left of the image scanning row by
1058 * row from left to right. Each pile is a 32bit value, with the high byte
1059 * being the alpha channel, the next being red, then green, and the low byte
1060 * being blue. The width and height are measured in pixels and will be
1061 * greater than 0 when returned. The alpha flag is either 0 or 1. 0 denotes
1062 * that the alpha channel is not used. 1 denotes that it is significant.
1063 * Compress is filled with the compression value/amount the image was
1064 * stored with. The quality value is filled with the quality encoding of
1065 * the image file (0 - 100). The lossy flags is either 0 or 1 as to if
1066 * the image was encoded lossily or not.
1068 * On success the function returns a pointer to the image data decoded. The
1069 * calling application is responsible for calling free() on the image data
1070 * when it is done with it. On failure NULL is returned and the parameter
1071 * values may not contain any sensible data.
1073 * @see eet_data_image_read()
1076 * @ingroup Eet_File_Image_Cipher_Group
1078 EAPI void * eet_data_image_read_cipher(Eet_File *ef,
1080 const char *cipher_key,
1089 * Read image data from the named key in the eet file using a cipher.
1090 * @param ef A valid eet file handle opened for reading.
1091 * @param name Name of the entry. eg: "/base/file_i_want".
1092 * @param cipher_key The key to use as cipher.
1093 * @param src_x The starting x coordinate from where to dump the stream.
1094 * @param src_y The starting y coordinate from where to dump the stream.
1095 * @param d A pointer to the pixel surface.
1096 * @param w The expected width in pixels of the pixel surface to decode.
1097 * @param h The expected height in pixels of the pixel surface to decode.
1098 * @param row_stride The length of a pixels line in the destination surface.
1099 * @param alpha A pointer to the int to hold the alpha flag.
1100 * @param compress A pointer to the int to hold the compression amount.
1101 * @param quality A pointer to the int to hold the quality amount.
1102 * @param lossy A pointer to the int to hold the lossiness flag.
1103 * @return 1 on success, 0 otherwise.
1105 * This function reads an image from an eet file stored under the named
1106 * key in the eet file and return a pointer to the decompressed pixel data.
1108 * The other parameters of the image (width, height etc.) are placed into
1109 * the values pointed to (they must be supplied). The pixel data is a linear
1110 * array of pixels starting from the top-left of the image scanning row by
1111 * row from left to right. Each pile is a 32bit value, with the high byte
1112 * being the alpha channel, the next being red, then green, and the low byte
1113 * being blue. The width and height are measured in pixels and will be
1114 * greater than 0 when returned. The alpha flag is either 0 or 1. 0 denotes
1115 * that the alpha channel is not used. 1 denotes that it is significant.
1116 * Compress is filled with the compression value/amount the image was
1117 * stored with. The quality value is filled with the quality encoding of
1118 * the image file (0 - 100). The lossy flags is either 0 or 1 as to if
1119 * the image was encoded lossily or not.
1121 * On success the function returns 1, and 0 on failure. On failure the
1122 * parameter values may not contain any sensible data.
1124 * @see eet_data_image_read_to_surface()
1127 * @ingroup Eet_File_Image_Cipher_Group
1129 EAPI int eet_data_image_read_to_surface_cipher(Eet_File *ef,
1131 const char *cipher_key,
1137 unsigned int row_stride,
1144 * Write image data to the named key in an eet file using a cipher.
1145 * @param ef A valid eet file handle opened for writing.
1146 * @param name Name of the entry. eg: "/base/file_i_want".
1147 * @param cipher_key The key to use as cipher.
1148 * @param data A pointer to the image pixel data.
1149 * @param w The width of the image in pixels.
1150 * @param h The height of the image in pixels.
1151 * @param alpha The alpha channel flag.
1152 * @param compress The compression amount.
1153 * @param quality The quality encoding amount.
1154 * @param lossy The lossiness flag.
1155 * @return Success if the data was encoded and written or not.
1157 * This function takes image pixel data and encodes it in an eet file
1158 * stored under the supplied name key, and returns how many bytes were
1159 * actually written to encode the image data.
1161 * The data expected is the same format as returned by eet_data_image_read.
1162 * If this is not the case weird things may happen. Width and height must
1163 * be between 1 and 8000 pixels. The alpha flags can be 0 or 1 (0 meaning
1164 * the alpha values are not useful and 1 meaning they are). Compress can
1165 * be from 0 to 9 (0 meaning no compression, 9 meaning full compression).
1166 * This is only used if the image is not lossily encoded. Quality is used on
1167 * lossy compression and should be a value from 0 to 100. The lossy flag
1168 * can be 0 or 1. 0 means encode losslessly and 1 means to encode with
1169 * image quality loss (but then have a much smaller encoding).
1171 * On success this function returns the number of bytes that were required
1172 * to encode the image data, or on failure it returns 0.
1174 * @see eet_data_image_write()
1177 * @ingroup Eet_File_Image_Cipher_Group
1179 EAPI int eet_data_image_write_cipher(Eet_File *ef,
1181 const char *cipher_key,
1191 * Decode Image data header only to get information using a cipher.
1192 * @param data The encoded pixel data.
1193 * @param cipher_key The key to use as cipher.
1194 * @param size The size, in bytes, of the encoded pixel data.
1195 * @param w A pointer to the unsigned int to hold the width in pixels.
1196 * @param h A pointer to the unsigned int to hold the height in pixels.
1197 * @param alpha A pointer to the int to hold the alpha flag.
1198 * @param compress A pointer to the int to hold the compression amount.
1199 * @param quality A pointer to the int to hold the quality amount.
1200 * @param lossy A pointer to the int to hold the lossiness flag.
1201 * @return 1 on success, 0 on failure.
1203 * This function takes encoded pixel data and decodes it into raw RGBA
1204 * pixels on success.
1206 * The other parameters of the image (width, height etc.) are placed into
1207 * the values pointed to (they must be supplied). The pixel data is a linear
1208 * array of pixels starting from the top-left of the image scanning row by
1209 * row from left to right. Each pixel is a 32bit value, with the high byte
1210 * being the alpha channel, the next being red, then green, and the low byte
1211 * being blue. The width and height are measured in pixels and will be
1212 * greater than 0 when returned. The alpha flag is either 0 or 1. 0 denotes
1213 * that the alpha channel is not used. 1 denotes that it is significant.
1214 * Compress is filled with the compression value/amount the image was
1215 * stored with. The quality value is filled with the quality encoding of
1216 * the image file (0 - 100). The lossy flags is either 0 or 1 as to if
1217 * the image was encoded lossily or not.
1219 * On success the function returns 1 indicating the header was read and
1220 * decoded properly, or 0 on failure.
1222 * @see eet_data_image_header_decode()
1225 * @ingroup Eet_File_Image_Cipher_Group
1227 EAPI int eet_data_image_header_decode_cipher(const void *data,
1228 const char *cipher_key,
1238 * Decode Image data into pixel data using a cipher.
1239 * @param data The encoded pixel data.
1240 * @param cipher_key The key to use as cipher.
1241 * @param size The size, in bytes, of the encoded pixel data.
1242 * @param w A pointer to the unsigned int to hold the width in pixels.
1243 * @param h A pointer to the unsigned int to hold the height in pixels.
1244 * @param alpha A pointer to the int to hold the alpha flag.
1245 * @param compress A pointer to the int to hold the compression amount.
1246 * @param quality A pointer to the int to hold the quality amount.
1247 * @param lossy A pointer to the int to hold the lossiness flag.
1248 * @return The image pixel data decoded
1250 * This function takes encoded pixel data and decodes it into raw RGBA
1251 * pixels on success.
1253 * The other parameters of the image (width, height etc.) are placed into
1254 * the values pointed to (they must be supplied). The pixel data is a linear
1255 * array of pixels starting from the top-left of the image scanning row by
1256 * row from left to right. Each pixel is a 32bit value, with the high byte
1257 * being the alpha channel, the next being red, then green, and the low byte
1258 * being blue. The width and height are measured in pixels and will be
1259 * greater than 0 when returned. The alpha flag is either 0 or 1. 0 denotes
1260 * that the alpha channel is not used. 1 denotes that it is significant.
1261 * Compress is filled with the compression value/amount the image was
1262 * stored with. The quality value is filled with the quality encoding of
1263 * the image file (0 - 100). The lossy flags is either 0 or 1 as to if
1264 * the image was encoded lossily or not.
1266 * On success the function returns a pointer to the image data decoded. The
1267 * calling application is responsible for calling free() on the image data
1268 * when it is done with it. On failure NULL is returned and the parameter
1269 * values may not contain any sensible data.
1271 * @see eet_data_image_decode()
1274 * @ingroup Eet_File_Image_Cipher_Group
1276 EAPI void * eet_data_image_decode_cipher(const void *data,
1277 const char *cipher_key,
1287 * Decode Image data into pixel data using a cipher.
1288 * @param data The encoded pixel data.
1289 * @param cipher_key The key to use as cipher.
1290 * @param size The size, in bytes, of the encoded pixel data.
1291 * @param src_x The starting x coordinate from where to dump the stream.
1292 * @param src_y The starting y coordinate from where to dump the stream.
1293 * @param d A pointer to the pixel surface.
1294 * @param w The expected width in pixels of the pixel surface to decode.
1295 * @param h The expected height in pixels of the pixel surface to decode.
1296 * @param row_stride The length of a pixels line in the destination surface.
1297 * @param alpha A pointer to the int to hold the alpha flag.
1298 * @param compress A pointer to the int to hold the compression amount.
1299 * @param quality A pointer to the int to hold the quality amount.
1300 * @param lossy A pointer to the int to hold the lossiness flag.
1301 * @return 1 on success, 0 otherwise.
1303 * This function takes encoded pixel data and decodes it into raw RGBA
1304 * pixels on success.
1306 * The other parameters of the image (alpha, compress etc.) are placed into
1307 * the values pointed to (they must be supplied). The pixel data is a linear
1308 * array of pixels starting from the top-left of the image scanning row by
1309 * row from left to right. Each pixel is a 32bit value, with the high byte
1310 * being the alpha channel, the next being red, then green, and the low byte
1311 * being blue. The width and height are measured in pixels and will be
1312 * greater than 0 when returned. The alpha flag is either 0 or 1. 0 denotes
1313 * that the alpha channel is not used. 1 denotes that it is significant.
1314 * Compress is filled with the compression value/amount the image was
1315 * stored with. The quality value is filled with the quality encoding of
1316 * the image file (0 - 100). The lossy flags is either 0 or 1 as to if
1317 * the image was encoded lossily or not.
1319 * On success the function returns 1, and 0 on failure. On failure the
1320 * parameter values may not contain any sensible data.
1322 * @see eet_data_image_decode_to_surface()
1325 * @ingroup Eet_File_Image_Cipher_Group
1327 EAPI int eet_data_image_decode_to_surface_cipher(const void *data,
1328 const char *cipher_key,
1335 unsigned int row_stride,
1342 * Encode image data for storage or transmission using a cipher.
1343 * @param data A pointer to the image pixel data.
1344 * @param cipher_key The key to use as cipher.
1345 * @param size_ret A pointer to an int to hold the size of the returned data.
1346 * @param w The width of the image in pixels.
1347 * @param h The height of the image in pixels.
1348 * @param alpha The alpha channel flag.
1349 * @param compress The compression amount.
1350 * @param quality The quality encoding amount.
1351 * @param lossy The lossiness flag.
1352 * @return The encoded image data.
1354 * This function stakes image pixel data and encodes it with compression and
1355 * possible loss of quality (as a trade off for size) for storage or
1356 * transmission to another system.
1358 * The data expected is the same format as returned by eet_data_image_read.
1359 * If this is not the case weird things may happen. Width and height must
1360 * be between 1 and 8000 pixels. The alpha flags can be 0 or 1 (0 meaning
1361 * the alpha values are not useful and 1 meaning they are). Compress can
1362 * be from 0 to 9 (0 meaning no compression, 9 meaning full compression).
1363 * This is only used if the image is not lossily encoded. Quality is used on
1364 * lossy compression and should be a value from 0 to 100. The lossy flag
1365 * can be 0 or 1. 0 means encode losslessly and 1 means to encode with
1366 * image quality loss (but then have a much smaller encoding).
1368 * On success this function returns a pointer to the encoded data that you
1369 * can free with free() when no longer needed.
1371 * @see eet_data_image_encode()
1374 * @ingroup Eet_File_Image_Cipher_Group
1376 EAPI void * eet_data_image_encode_cipher(const void *data,
1377 const char *cipher_key,
1387 * @defgroup Eet_Cipher_Group Cipher, Identity and Protection Mechanisms
1389 * Eet allows one to protect entries of an #Eet_File
1390 * individually. This may be used to ensure data was not tampered or
1391 * that third party does not read your data.
1393 * @see @ref Eet_File_Cipher_Group
1394 * @see @ref Eet_File_Image_Cipher_Group
1401 * Opaque handle that defines an identity (also known as key)
1402 * in Eet's cipher system.
1404 typedef struct _Eet_Key Eet_Key;
1411 * Callback used to request if needed the password of a private key.
1413 * @param buffer the buffer where to store the password.
1414 * @param size the maximum password size (size of buffer, including '@\0').
1415 * @param rwflag if the buffer is also readable or just writable.
1416 * @param data currently unused, may contain some context in future.
1417 * @return 1 on success and password was set to @p buffer, 0 on failure.
1420 * @ingroup Eet_Cipher_Group
1422 typedef int (* Eet_Key_Password_Callback)(char *buffer, int size, int rwflag, void *data);
1425 * Create an Eet_Key needed for signing an eet file.
1427 * The certificate should provide the public that match the private key.
1428 * No verification is done to ensure that.
1430 * @param certificate_file The file where to find the certificate.
1431 * @param private_key_file The file that contains the private key.
1432 * @param cb Function to callback if password is required to unlock
1434 * @return A key handle to use, or @c NULL on failure.
1436 * @see eet_identity_close()
1439 * @ingroup Eet_Cipher_Group
1441 EAPI Eet_Key * eet_identity_open(const char *certificate_file,
1442 const char *private_key_file,
1443 Eet_Key_Password_Callback cb);
1446 * Close and release all ressource used by an Eet_Key. An
1447 * reference counter prevent it from being freed until all file
1448 * using it are also closed.
1450 * @param key the key handle to close and free resources.
1453 * @ingroup Eet_Cipher_Group
1455 EAPI void eet_identity_close(Eet_Key *key);
1458 * Set a key to sign a file
1460 * @param ef the file to set the identity.
1461 * @param key the key handle to set as identity.
1462 * @return #EET_ERROR_BAD_OBJECT if @p ef is invalid or
1463 * #EET_ERROR_NONE on success.
1466 * @ingroup Eet_Cipher_Group
1468 EAPI Eet_Error eet_identity_set(Eet_File *ef,
1472 * Display both private and public key of an Eet_Key.
1474 * @param key the handle to print.
1475 * @param out where to print.
1478 * @ingroup Eet_Cipher_Group
1480 EAPI void eet_identity_print(Eet_Key *key,
1484 * Get the x509 der certificate associated with an Eet_File. Will return NULL
1485 * if the file is not signed.
1487 * @param ef The file handle to query.
1488 * @param der_length The length of returned data, may be @c NULL.
1489 * @return the x509 certificate or @c NULL on error.
1492 * @ingroup Eet_Cipher_Group
1494 EAPI const void * eet_identity_x509(Eet_File *ef,
1498 * Get the raw signature associated with an Eet_File. Will return NULL
1499 * if the file is not signed.
1501 * @param ef The file handle to query.
1502 * @param signature_length The length of returned data, may be @c NULL.
1503 * @return the raw signature or @c NULL on error.
1505 * @ingroup Eet_Cipher_Group
1507 EAPI const void * eet_identity_signature(Eet_File *ef,
1508 int *signature_length);
1511 * Get the SHA1 associated with a file. Could be the one used to
1512 * sign the data or if the data where not signed, it will be the
1515 * @param ef The file handle to query.
1516 * @param sha1_length The length of returned data, may be @c NULL.
1517 * @return the associated SHA1 or @c NULL on error.
1520 * @ingroup Eet_Cipher_Group
1522 EAPI const void * eet_identity_sha1(Eet_File *ef,
1526 * Display the x509 der certificate to out.
1528 * @param certificate the x509 certificate to print
1529 * @param der_length The length the certificate.
1530 * @param out where to print.
1533 * @ingroup Eet_Cipher_Group
1535 EAPI void eet_identity_certificate_print(const unsigned char *certificate,
1540 * @defgroup Eet_Data_Group Eet Data Serialization
1542 * Convenience functions to serialize and parse complex data
1543 * structures to binary blobs.
1545 * While Eet core just handles binary blobs, it is often required
1546 * to save some structured data of different types, such as
1547 * strings, integers, lists, hashes and so on.
1549 * Eet can serialize and then parse data types given some
1550 * construction instructions. These are defined in two levels:
1552 * - #Eet_Data_Descriptor_Class to tell generic memory handling,
1553 * such as the size of the type, how to allocate memory, strings,
1554 * lists, hashes and so on.
1556 * - #Eet_Data_Descriptor to tell inside such type, the members and
1557 * their offsets inside the memory blob, their types and
1558 * names. These members can be simple types or other
1559 * #Eet_Data_Descriptor, allowing hierarchical types to be
1562 * Given that C provides no introspection, this process can be
1563 * quite cumbersome, so we provide lots of macros and convenience
1564 * functions to aid creating the types.
1572 * typedef struct _blah2
1577 * typedef struct _blah3
1582 * typedef struct _blah
1589 * double floating_lots;
1596 * main(int argc, char **argv)
1601 * Eet_Data_Descriptor *edd, *edd2, *edd3;
1602 * Eet_Data_Descriptor_Class eddc, eddc2, eddc3;
1610 * EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eddc3, Blah3);
1611 * edd3 = eet_data_descriptor_stream_new(&eddc3);
1612 * EET_DATA_DESCRIPTOR_ADD_BASIC(edd3, Blah3, "string3", string, EET_T_STRING);
1614 * EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eddc2, Blah2);
1615 * edd2 = eet_data_descriptor_stream_new(&eddc2);
1616 * EET_DATA_DESCRIPTOR_ADD_BASIC(edd2, Blah2, "string2", string, EET_T_STRING);
1618 * EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eddc, Blah);
1619 * edd = eet_data_descriptor_stream_new(&eddc);
1620 * EET_DATA_DESCRIPTOR_ADD_BASIC(edd, Blah, "character", character, EET_T_CHAR);
1621 * EET_DATA_DESCRIPTOR_ADD_BASIC(edd, Blah, "sixteen", sixteen, EET_T_SHORT);
1622 * EET_DATA_DESCRIPTOR_ADD_BASIC(edd, Blah, "integer", integer, EET_T_INT);
1623 * EET_DATA_DESCRIPTOR_ADD_BASIC(edd, Blah, "lots", lots, EET_T_LONG_LONG);
1624 * EET_DATA_DESCRIPTOR_ADD_BASIC(edd, Blah, "floating", floating, EET_T_FLOAT);
1625 * EET_DATA_DESCRIPTOR_ADD_BASIC(edd, Blah, "floating_lots", floating_lots, EET_T_DOUBLE);
1626 * EET_DATA_DESCRIPTOR_ADD_BASIC(edd, Blah, "string", string, EET_T_STRING);
1627 * EET_DATA_DESCRIPTOR_ADD_SUB(edd, Blah, "blah2", blah2, edd2);
1628 * EET_DATA_DESCRIPTOR_ADD_LIST(edd, Blah, "blah3", blah3, edd3);
1630 * blah3.string = "PANTS";
1632 * blah2.string = "subtype string here!";
1634 * blah.character = '7';
1635 * blah.sixteen = 0x7777;
1636 * blah.integer = 0xc0def00d;
1637 * blah.lots = 0xdeadbeef31337777;
1638 * blah.floating = 3.141592654;
1639 * blah.floating_lots = 0.777777777777777;
1640 * blah.string = "bite me like a turnip";
1641 * blah.blah2 = &blah2;
1642 * blah.blah3 = eina_list_append(NULL, &blah3);
1643 * blah.blah3 = eina_list_append(blah.blah3, &blah3);
1644 * blah.blah3 = eina_list_append(blah.blah3, &blah3);
1645 * blah.blah3 = eina_list_append(blah.blah3, &blah3);
1646 * blah.blah3 = eina_list_append(blah.blah3, &blah3);
1647 * blah.blah3 = eina_list_append(blah.blah3, &blah3);
1648 * blah.blah3 = eina_list_append(blah.blah3, &blah3);
1650 * data = eet_data_descriptor_encode(edd, &blah, &size);
1651 * printf("-----DECODING\n");
1652 * blah_in = eet_data_descriptor_decode(edd, data, size);
1654 * printf("-----DECODED!\n");
1655 * printf("%c\n", blah_in->character);
1656 * printf("%x\n", (int)blah_in->sixteen);
1657 * printf("%x\n", blah_in->integer);
1658 * printf("%lx\n", blah_in->lots);
1659 * printf("%f\n", (double)blah_in->floating);
1660 * printf("%f\n", (double)blah_in->floating_lots);
1661 * printf("%s\n", blah_in->string);
1662 * printf("%p\n", blah_in->blah2);
1663 * printf(" %s\n", blah_in->blah2->string);
1668 * EINA_LIST_FOREACH(blah_in->blah3, l, blah3_in)
1670 * printf("%p\n", blah3_in);
1671 * printf(" %s\n", blah3_in->string);
1674 * eet_data_descriptor_free(edd);
1675 * eet_data_descriptor_free(edd2);
1676 * eet_data_descriptor_free(edd3);
1686 #define EET_T_UNKNOW 0 /**< Unknown data encoding type */
1687 #define EET_T_CHAR 1 /**< Data type: char */
1688 #define EET_T_SHORT 2 /**< Data type: short */
1689 #define EET_T_INT 3 /**< Data type: int */
1690 #define EET_T_LONG_LONG 4 /**< Data type: long long */
1691 #define EET_T_FLOAT 5 /**< Data type: float */
1692 #define EET_T_DOUBLE 6 /**< Data type: double */
1693 #define EET_T_UCHAR 7 /**< Data type: unsigned char */
1694 #define EET_T_USHORT 8 /**< Data type: unsigned short */
1695 #define EET_T_UINT 9 /**< Data type: unsigned int */
1696 #define EET_T_ULONG_LONG 10 /**< Data type: unsigned long long */
1697 #define EET_T_STRING 11 /**< Data type: char * */
1698 #define EET_T_INLINED_STRING 12 /**< Data type: char * (but compressed inside the resulting eet) */
1699 #define EET_T_NULL 13 /**< Data type: (void *) (only use it if you know why) */
1700 #define EET_T_F32P32 14 /**< Data type: fixed point 32.32 */
1701 #define EET_T_F16P16 15 /**< Data type: fixed point 16.16 */
1702 #define EET_T_F8P24 16 /**< Data type: fixed point 8.24 */
1703 #define EET_T_LAST 18 /**< Last data type */
1705 #define EET_G_UNKNOWN 100 /**< Unknown group data encoding type */
1706 #define EET_G_ARRAY 101 /**< Fixed size array group type */
1707 #define EET_G_VAR_ARRAY 102 /**< Variable size array group type */
1708 #define EET_G_LIST 103 /**< Linked list group type */
1709 #define EET_G_HASH 104 /**< Hash table group type */
1710 #define EET_G_UNION 105 /**< Union group type */
1711 #define EET_G_VARIANT 106 /**< Selectable subtype group */
1712 #define EET_G_LAST 107 /**< Last group type */
1714 #define EET_I_LIMIT 128 /**< Other type exist but are reserved for internal purpose. */
1717 * @typedef Eet_Data_Descriptor
1719 * Opaque handle that have information on a type members.
1721 * The members are added by means of
1722 * EET_DATA_DESCRIPTOR_ADD_BASIC(), EET_DATA_DESCRIPTOR_ADD_SUB(),
1723 * EET_DATA_DESCRIPTOR_ADD_LIST(), EET_DATA_DESCRIPTOR_ADD_HASH()
1724 * or eet_data_descriptor_element_add().
1726 * @see eet_data_descriptor_stream_new()
1727 * @see eet_data_descriptor_file_new()
1728 * @see eet_data_descriptor_free()
1730 typedef struct _Eet_Data_Descriptor Eet_Data_Descriptor;
1733 * @def EET_DATA_DESCRIPTOR_CLASS_VERSION
1734 * The version of #Eet_Data_Descriptor_Class at the time of the
1735 * distribution of the sources. One should define this to its
1736 * version member so it is compatible with abi changes, or at least
1737 * will not crash with them.
1739 #define EET_DATA_DESCRIPTOR_CLASS_VERSION 3
1742 * @typedef Eet_Data_Descriptor_Class
1744 * Instructs Eet about memory management for different needs under
1745 * serialization and parse process.
1747 typedef struct _Eet_Data_Descriptor_Class Eet_Data_Descriptor_Class;
1750 * @struct _Eet_Data_Descriptor_Class
1752 * Instructs Eet about memory management for different needs under
1753 * serialization and parse process.
1755 * If using Eina data types, it is advised to use the helpers
1756 * EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET() and
1757 * EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET().
1759 struct _Eet_Data_Descriptor_Class
1761 int version; /**< ABI version as #EET_DATA_DESCRIPTOR_CLASS_VERSION */
1762 const char *name; /**< Name of data type to be serialized */
1763 int size; /**< Size in bytes of data type to be serialized */
1766 void * (*mem_alloc)(size_t size); /**< how to allocate memory (usually malloc()) */
1767 void (*mem_free)(void *mem); /**< how to free memory (usually free()) */
1768 char * (*str_alloc)(const char *str); /**< how to allocate a string */
1769 void (*str_free)(const char *str); /**< how to free a string */
1770 void * (*list_next)(void *l); /**< how to iterate to the next element of a list. Receives and should return the list node. */
1771 void * (*list_append)(void *l, void *d); /**< how to append data @p d to list which head node is @p l */
1772 void * (*list_data)(void *l); /**< retrieves the data from node @p l */
1773 void * (*list_free)(void *l); /**< free all the nodes from the list which head node is @p l */
1774 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 */
1775 void * (*hash_add)(void *h, const char *k, void *d); /**< add a new data @p d as key @p k in hash @p h */
1776 void (*hash_free)(void *h); /**< free all entries from the hash @p h */
1777 char * (*str_direct_alloc)(const char *str); /**< how to allocate a string directly from file backed/mmaped region pointed by @p str */
1778 void (*str_direct_free)(const char *str); /**< how to free a string returned by str_direct_alloc */
1779 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. */
1780 Eina_Bool (*type_set)(const char *type, void *data, Eina_Bool unknow); /**< set the type at a particular adress */
1789 * Create a new empty data structure descriptor.
1790 * @param name The string name of this data structure (most be a
1791 * global constant and never change).
1792 * @param size The size of the struct (in bytes).
1793 * @param func_list_next The function to get the next list node.
1794 * @param func_list_append The function to append a member to a list.
1795 * @param func_list_data The function to get the data from a list node.
1796 * @param func_list_free The function to free an entire linked list.
1797 * @param func_hash_foreach The function to iterate through all
1798 * hash table entries.
1799 * @param func_hash_add The function to add a member to a hash table.
1800 * @param func_hash_free The function to free an entire hash table.
1801 * @return A new empty data descriptor.
1803 * This function creates a new data descriptore and returns a handle to the
1804 * new data descriptor. On creation it will be empty, containing no contents
1805 * describing anything other than the shell of the data structure.
1807 * You add structure members to the data descriptor using the macros
1808 * EET_DATA_DESCRIPTOR_ADD_BASIC(), EET_DATA_DESCRIPTOR_ADD_SUB() and
1809 * EET_DATA_DESCRIPTOR_ADD_LIST(), depending on what type of member you are
1810 * adding to the description.
1812 * Once you have described all the members of a struct you want loaded, or
1813 * saved eet can load and save those members for you, encode them into
1814 * endian-independant serialised data chunks for transmission across a
1815 * a network or more.
1817 * The function pointers to the list and hash table functions are only
1818 * needed if you use those data types, else you can pass NULL instead.
1821 * @ingroup Eet_Data_Group
1823 * @deprecated use eet_data_descriptor_stream_new() or
1824 * eet_data_descriptor_file_new()
1826 EINA_DEPRECATED EAPI Eet_Data_Descriptor * eet_data_descriptor_new(const char *name,
1828 void *(*func_list_next)(void *l),
1829 void *(*func_list_append)(void *l, void *d),
1830 void *(*func_list_data)(void *l),
1831 void *(*func_list_free)(void *l),
1832 void (*func_hash_foreach)(void *h, int (*func)(void *h,
1835 void *fdt), void *fdt),
1836 void *(*func_hash_add)(void *h, const char *k, void *d),
1837 void (*func_hash_free)(void *h));
1841 * moving to this api from the old above. this will break things when the
1842 * move happens - but be warned
1844 EINA_DEPRECATED EAPI Eet_Data_Descriptor * eet_data_descriptor2_new(const Eet_Data_Descriptor_Class *eddc);
1845 EINA_DEPRECATED EAPI Eet_Data_Descriptor * eet_data_descriptor3_new(const Eet_Data_Descriptor_Class *eddc);
1848 * This function creates a new data descriptore and returns a handle to the
1849 * new data descriptor. On creation it will be empty, containing no contents
1850 * describing anything other than the shell of the data structure.
1851 * @param eddc The data descriptor to free.
1853 * You add structure members to the data descriptor using the macros
1854 * EET_DATA_DESCRIPTOR_ADD_BASIC(), EET_DATA_DESCRIPTOR_ADD_SUB() and
1855 * EET_DATA_DESCRIPTOR_ADD_LIST(), depending on what type of member you are
1856 * adding to the description.
1858 * Once you have described all the members of a struct you want loaded, or
1859 * saved eet can load and save those members for you, encode them into
1860 * endian-independant serialised data chunks for transmission across a
1861 * a network or more.
1863 * This function specially ignore str_direct_alloc and str_direct_free. It
1864 * is usefull when the eet_data you are reading don't have a dictionnary
1865 * like network stream or ipc. It also mean that all string will be allocated
1866 * and duplicated in memory.
1869 * @ingroup Eet_Data_Group
1871 EAPI Eet_Data_Descriptor * eet_data_descriptor_stream_new(const Eet_Data_Descriptor_Class *eddc);
1874 * This function creates a new data descriptore and returns a handle to the
1875 * new data descriptor. On creation it will be empty, containing no contents
1876 * describing anything other than the shell of the data structure.
1877 * @param eddc The data descriptor to free.
1879 * You add structure members to the data descriptor using the macros
1880 * EET_DATA_DESCRIPTOR_ADD_BASIC(), EET_DATA_DESCRIPTOR_ADD_SUB() and
1881 * EET_DATA_DESCRIPTOR_ADD_LIST(), depending on what type of member you are
1882 * adding to the description.
1884 * Once you have described all the members of a struct you want loaded, or
1885 * saved eet can load and save those members for you, encode them into
1886 * endian-independant serialised data chunks for transmission across a
1887 * a network or more.
1889 * This function use str_direct_alloc and str_direct_free. It is
1890 * usefull when the eet_data you are reading come from a file and
1891 * have a dictionnary. This will reduce memory use, improve the
1892 * possibility for the OS to page this string out. But be carrefull
1893 * all EET_T_STRING are pointer to a mmapped area and it will point
1894 * to nowhere if you close the file. So as long as you use this
1895 * strings, you need to have the Eet_File open.
1898 * @ingroup Eet_Data_Group
1900 EAPI Eet_Data_Descriptor * eet_data_descriptor_file_new(const Eet_Data_Descriptor_Class *eddc);
1903 * This function is an helper that set all the parameter of an
1904 * Eet_Data_Descriptor_Class correctly when you use Eina data type
1906 * @param eddc The Eet_Data_Descriptor_Class you want to set.
1907 * @param name The name of the structure described by this class.
1908 * @param size The size of the structure described by this class.
1909 * @return EINA_TRUE if the structure was correctly set (The only
1910 * reason that could make it fail is if you did give wrong
1914 * @ingroup Eet_Data_Group
1916 EAPI Eina_Bool eet_eina_stream_data_descriptor_class_set(Eet_Data_Descriptor_Class *eddc,
1921 * This macro is an helper that set all the parameter of an
1922 * Eet_Data_Descriptor_Class correctly when you use Eina data type
1924 * @param Clas The Eet_Data_Descriptor_Class you want to set.
1925 * @param Type The type of the structure described by this class.
1926 * @return EINA_TRUE if the structure was correctly set (The only
1927 * reason that could make it fail is if you did give wrong
1931 * @ingroup Eet_Data_Group
1933 #define EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(clas, type)\
1934 (eet_eina_stream_data_descriptor_class_set(clas, # type, sizeof(type)))
1937 * This function is an helper that set all the parameter of an
1938 * Eet_Data_Descriptor_Class correctly when you use Eina data type
1940 * @param eddc The Eet_Data_Descriptor_Class you want to set.
1941 * @param name The name of the structure described by this class.
1942 * @param size The size of the structure described by this class.
1943 * @return EINA_TRUE if the structure was correctly set (The only
1944 * reason that could make it fail is if you did give wrong
1948 * @ingroup Eet_Data_Group
1950 EAPI Eina_Bool eet_eina_file_data_descriptor_class_set(Eet_Data_Descriptor_Class *eddc,
1955 * This macro is an helper that set all the parameter of an
1956 * Eet_Data_Descriptor_Class correctly when you use Eina data type
1958 * @param Clas The Eet_Data_Descriptor_Class you want to set.
1959 * @param Type The type of the structure described by this class.
1960 * @return EINA_TRUE if the structure was correctly set (The only
1961 * reason that could make it fail is if you did give wrong
1965 * @ingroup Eet_Data_Group
1967 #define EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(clas, type) (\
1968 eet_eina_file_data_descriptor_class_set(clas, # type, sizeof(type)))
1971 * This function frees a data descriptor when it is not needed anymore.
1972 * @param edd The data descriptor to free.
1974 * This function takes a data descriptor handle as a parameter and frees all
1975 * data allocated for the data descriptor and the handle itself. After this
1976 * call the descriptor is no longer valid.
1979 * @ingroup Eet_Data_Group
1981 EAPI void eet_data_descriptor_free(Eet_Data_Descriptor *edd);
1984 * This function is an internal used by macros.
1986 * This function is used by macros EET_DATA_DESCRIPTOR_ADD_BASIC(),
1987 * EET_DATA_DESCRIPTOR_ADD_SUB() and EET_DATA_DESCRIPTOR_ADD_LIST(). It is
1988 * complex to use by hand and should be left to be used by the macros, and
1989 * thus is not documented.
1991 * @param edd The data descriptor handle to add element (member).
1992 * @param name The name of element to be serialized.
1993 * @param type The type of element to be serialized, like
1994 * #EET_T_INT. If #EET_T_UNKNOW, then it is considered to be a
1995 * group, list or hash.
1996 * @param group_type If element type is #EET_T_UNKNOW, then the @p
1997 * group_type will speficy if it is a list (#EET_G_LIST),
1998 * array (#EET_G_ARRAY) and so on. If #EET_G_UNKNOWN, then
1999 * the member is a subtype (pointer to another type defined by
2000 * another #Eet_Data_Descriptor).
2001 * @param offset byte offset inside the source memory to be serialized.
2002 * @param count number of elements (if #EET_G_ARRAY or #EET_G_VAR_ARRAY).
2003 * @param counter_name variable that defines the name of number of elements.
2004 * @param subtype If contains a subtype, then its data descriptor.
2007 * @ingroup Eet_Data_Group
2009 EAPI void eet_data_descriptor_element_add(Eet_Data_Descriptor *edd,
2014 /* int count_offset, */
2016 const char *counter_name,
2017 Eet_Data_Descriptor *subtype);
2020 * Read a data structure from an eet file and decodes it.
2021 * @param ef The eet file handle to read from.
2022 * @param edd The data descriptor handle to use when decoding.
2023 * @param name The key the data is stored under in the eet file.
2024 * @return A pointer to the decoded data structure.
2026 * This function decodes a data structure stored in an eet file, returning
2027 * a pointer to it if it decoded successfully, or NULL on failure. This
2028 * can save a programmer dozens of hours of work in writing configuration
2029 * file parsing and writing code, as eet does all that work for the program
2030 * and presents a program-friendly data structure, just as the programmer
2031 * likes. Eet can handle members being added or deleted from the data in
2032 * storage and safely zero-fills unfilled members if they were not found
2033 * in the data. It checks sizes and headers whenever it reads data, allowing
2034 * the programmer to not worry about corrupt data.
2036 * Once a data structure has been described by the programmer with the
2037 * fields they wish to save or load, storing or retrieving a data structure
2038 * from an eet file, or from a chunk of memory is as simple as a single
2041 * @see eet_data_read_cipher()
2044 * @ingroup Eet_Data_Group
2046 EAPI void * eet_data_read(Eet_File *ef,
2047 Eet_Data_Descriptor *edd,
2051 * Write a data structure from memory and store in an eet file.
2052 * @param ef The eet file handle to write to.
2053 * @param edd The data descriptor to use when encoding.
2054 * @param name The key to store the data under in the eet file.
2055 * @param data A pointer to the data structure to ssave and encode.
2056 * @param compress Compression flags for storage.
2057 * @return bytes written on successful write, 0 on failure.
2059 * This function is the reverse of eet_data_read(), saving a data structure
2062 * @see eet_data_write_cipher()
2065 * @ingroup Eet_Data_Group
2067 EAPI int eet_data_write(Eet_File *ef,
2068 Eet_Data_Descriptor *edd,
2074 * Dump an eet encoded data structure into ascii text
2075 * @param data_in The pointer to the data to decode into a struct.
2076 * @param size_in The size of the data pointed to in bytes.
2077 * @param dumpfunc The function to call passed a string when new
2078 * data is converted to text
2079 * @param dumpdata The data to pass to the @p dumpfunc callback.
2080 * @return 1 on success, 0 on failure
2082 * This function will take a chunk of data encoded by
2083 * eet_data_descriptor_encode() and convert it into human readable
2084 * ascii text. It does this by calling the @p dumpfunc callback
2085 * for all new text that is generated. This callback should append
2086 * to any existing text buffer and will be passed the pointer @p
2087 * dumpdata as a parameter as well as a string with new text to be
2093 * void output(void *data, const char *string)
2095 * printf("%s", string);
2098 * void dump(const char *file)
2104 * f = fopen(file, "r");
2105 * fseek(f, 0, SEEK_END);
2108 * data = malloc(len);
2109 * fread(data, len, 1, f);
2111 * eet_data_text_dump(data, len, output, NULL);
2115 * @see eet_data_text_dump_cipher()
2118 * @ingroup Eet_Data_Group
2120 EAPI int eet_data_text_dump(const void *data_in,
2122 void (*dumpfunc)(void *data, const char *str),
2126 * Take an ascii encoding from eet_data_text_dump() and re-encode in binary.
2127 * @param text The pointer to the string data to parse and encode.
2128 * @param textlen The size of the string in bytes (not including 0
2130 * @param size_ret This gets filled in with the encoded data blob
2132 * @return The encoded data on success, NULL on failure.
2134 * This function will parse the string pointed to by @p text and return
2135 * an encoded data lump the same way eet_data_descriptor_encode() takes an
2136 * in-memory data struct and encodes into a binary blob. @p text is a normal
2139 * @see eet_data_text_undump_cipher()
2142 * @ingroup Eet_Data_Group
2144 EAPI void * eet_data_text_undump(const char *text,
2149 * Dump an eet encoded data structure from an eet file into ascii text
2150 * @param ef A valid eet file handle.
2151 * @param name Name of the entry. eg: "/base/file_i_want".
2152 * @param dumpfunc The function to call passed a string when new
2153 * data is converted to text
2154 * @param dumpdata The data to pass to the @p dumpfunc callback.
2155 * @return 1 on success, 0 on failure
2157 * This function will take an open and valid eet file from
2158 * eet_open() request the data encoded by
2159 * eet_data_descriptor_encode() corresponding to the key @p name
2160 * and convert it into human readable ascii text. It does this by
2161 * calling the @p dumpfunc callback for all new text that is
2162 * generated. This callback should append to any existing text
2163 * buffer and will be passed the pointer @p dumpdata as a parameter
2164 * as well as a string with new text to be appended.
2166 * @see eet_data_dump_cipher()
2169 * @ingroup Eet_Data_Group
2171 EAPI int eet_data_dump(Eet_File *ef,
2173 void (*dumpfunc)(void *data, const char *str),
2177 * Take an ascii encoding from eet_data_dump() and re-encode in binary.
2178 * @param ef A valid eet file handle.
2179 * @param name Name of the entry. eg: "/base/file_i_want".
2180 * @param text The pointer to the string data to parse and encode.
2181 * @param textlen The size of the string in bytes (not including 0
2183 * @param compress Compression flags (1 == compress, 0 = don't compress).
2184 * @return 1 on success, 0 on failure
2186 * This function will parse the string pointed to by @p text,
2187 * encode it the same way eet_data_descriptor_encode() takes an
2188 * in-memory data struct and encodes into a binary blob.
2190 * The data (optionally compressed) will be in ram, pending a flush to
2191 * disk (it will stay in ram till the eet file handle is closed though).
2193 * @see eet_data_undump_cipher()
2196 * @ingroup Eet_Data_Group
2198 EAPI int eet_data_undump(Eet_File *ef,
2205 * Decode a data structure from an arbitary location in memory.
2206 * @param edd The data descriptor to use when decoding.
2207 * @param data_in The pointer to the data to decode into a struct.
2208 * @param size_in The size of the data pointed to in bytes.
2209 * @return NULL on failure, or a valid decoded struct pointer on success.
2211 * This function will decode a data structure that has been encoded using
2212 * eet_data_descriptor_encode(), and return a data structure with all its
2213 * elements filled out, if successful, or NULL on failure.
2215 * The data to be decoded is stored at the memory pointed to by @p data_in,
2216 * and is described by the descriptor pointed to by @p edd. The data size is
2217 * passed in as the value to @p size_in, ande must be greater than 0 to
2220 * This function is useful for decoding data structures delivered to the
2221 * application by means other than an eet file, such as an IPC or socket
2222 * connection, raw files, shared memory etc.
2224 * Please see eet_data_read() for more information.
2226 * @see eet_data_descriptor_decode_cipher()
2229 * @ingroup Eet_Data_Group
2231 EAPI void * eet_data_descriptor_decode(Eet_Data_Descriptor *edd,
2232 const void *data_in,
2236 * Encode a dsata struct to memory and return that encoded data.
2237 * @param edd The data descriptor to use when encoding.
2238 * @param data_in The pointer to the struct to encode into data.
2239 * @param size_ret pointer to the an int to be filled with the decoded size.
2240 * @return NULL on failure, or a valid encoded data chunk on success.
2242 * This function takes a data structutre in memory and encodes it into a
2243 * serialised chunk of data that can be decoded again by
2244 * eet_data_descriptor_decode(). This is useful for being able to transmit
2245 * data structures across sockets, pipes, IPC or shared file mechanisms,
2246 * without having to worry about memory space, machine type, endianess etc.
2248 * The parameter @p edd must point to a valid data descriptor, and
2249 * @p data_in must point to the right data structure to encode. If not, the
2250 * encoding may fail.
2252 * On success a non NULL valid pointer is returned and what @p size_ret
2253 * points to is set to the size of this decoded data, in bytes. When the
2254 * encoded data is no longer needed, call free() on it. On failure NULL is
2255 * returned and what @p size_ret points to is set to 0.
2257 * Please see eet_data_write() for more information.
2259 * @see eet_data_descriptor_encode_cipher()
2262 * @ingroup Eet_Data_Group
2264 EAPI void * eet_data_descriptor_encode(Eet_Data_Descriptor *edd,
2265 const void *data_in,
2269 * Add a basic data element to a data descriptor.
2270 * @param edd The data descriptor to add the type to.
2271 * @param struct_type The type of the struct.
2272 * @param name The string name to use to encode/decode this member
2273 * (must be a constant global and never change).
2274 * @param member The struct member itself to be encoded.
2275 * @param type The type of the member to encode.
2277 * This macro is a convenience macro provided to add a member to
2278 * the data descriptor @p edd. The type of the structure is
2279 * provided as the @p struct_type parameter (for example: struct
2280 * my_struct). The @p name parameter defines a string that will be
2281 * used to uniquely name that member of the struct (it is suggested
2282 * to use the struct member itself). The @p member parameter is
2283 * the actual struct member itself (for eet_dictionary_string_check
2284 * example: values), and @p type is the basic data type of the
2285 * member which must be one of: EET_T_CHAR, EET_T_SHORT, EET_T_INT,
2286 * EET_T_LONG_LONG, EET_T_FLOAT, EET_T_DOUBLE, EET_T_UCHAR,
2287 * EET_T_USHORT, EET_T_UINT, EET_T_ULONG_LONG or EET_T_STRING.
2290 * @ingroup Eet_Data_Group
2292 #define EET_DATA_DESCRIPTOR_ADD_BASIC(edd, struct_type, name, member, type)\
2294 struct_type ___ett;\
2295 eet_data_descriptor_element_add(edd, name, type, EET_G_UNKNOWN,\
2296 (char *)(& (___ett.member)) -\
2297 (char *)(& (___ett)),\
2298 0, /* 0, */ NULL, NULL);\
2302 * Add a sub-element type to a data descriptor
2303 * @param edd The data descriptor to add the type to.
2304 * @param struct_type The type of the struct.
2305 * @param name The string name to use to encode/decode this member
2306 * (must be a constant global and never change).
2307 * @param member The struct member itself to be encoded.
2308 * @param subtype The type of sub-type struct to add.
2310 * This macro lets you easily add a sub-type (a struct that's pointed to
2311 * by this one). All the parameters are the same as for
2312 * EET_DATA_DESCRIPTOR_ADD_BASIC(), with the @p subtype being the exception.
2313 * This must be the data descriptor of the struct that is pointed to by
2317 * @ingroup Eet_Data_Group
2319 #define EET_DATA_DESCRIPTOR_ADD_SUB(edd, struct_type, name, member, subtype)\
2321 struct_type ___ett;\
2323 eet_data_descriptor_element_add(edd, name, EET_T_UNKNOW, EET_G_UNKNOWN,\
2324 (char *)(& (___ett.member)) -\
2325 (char *)(& (___ett)),\
2326 0, /* 0, */ NULL, subtype);\
2330 * Add a linked list type to a data descriptor
2331 * @param edd The data descriptor to add the type to.
2332 * @param struct_type The type of the struct.
2333 * @param name The string name to use to encode/decode this member
2334 * (must be a constant global and never change).
2335 * @param member The struct member itself to be encoded.
2336 * @param subtype The type of linked list member to add.
2338 * This macro lets you easily add a linked list of other data types. All the
2339 * parameters are the same as for EET_DATA_DESCRIPTOR_ADD_BASIC(), with the
2340 * @p subtype being the exception. This must be the data descriptor of the
2341 * element that is in each member of the linked list to be stored.
2344 * @ingroup Eet_Data_Group
2346 #define EET_DATA_DESCRIPTOR_ADD_LIST(edd, struct_type, name, member, subtype)\
2348 struct_type ___ett;\
2350 eet_data_descriptor_element_add(edd, name, EET_T_UNKNOW, EET_G_LIST,\
2351 (char *)(& (___ett.member)) -\
2352 (char *)(& (___ett)),\
2353 0, /* 0, */ NULL, subtype);\
2357 * Add a hash type to a data descriptor
2358 * @param edd The data descriptor to add the type to.
2359 * @param struct_type The type of the struct.
2360 * @param name The string name to use to encode/decode this member
2361 * (must be a constant global and never change).
2362 * @param member The struct member itself to be encoded.
2363 * @param subtype The type of hash member to add.
2365 * This macro lets you easily add a hash of other data types. All the
2366 * parameters are the same as for EET_DATA_DESCRIPTOR_ADD_BASIC(), with the
2367 * @p subtype being the exception. This must be the data descriptor of the
2368 * element that is in each member of the hash to be stored.
2371 * @ingroup Eet_Data_Group
2373 #define EET_DATA_DESCRIPTOR_ADD_HASH(edd, struct_type, name, member, subtype)\
2375 struct_type ___ett;\
2377 eet_data_descriptor_element_add(edd, name, EET_T_UNKNOW, EET_G_HASH,\
2378 (char *)(& (___ett.member)) -\
2379 (char *)(& (___ett)),\
2380 0, /* 0, */ NULL, subtype);\
2384 * Add a fixed size array type to a data descriptor
2385 * @param edd The data descriptor to add the type to.
2386 * @param struct_type The type of the struct.
2387 * @param name The string name to use to encode/decode this member
2388 * (must be a constant global and never change).
2389 * @param member The struct member itself to be encoded.
2390 * @param subtype The type of hash member to add.
2392 * This macro lets you easily add a fixed size array of other data
2393 * types. All the parameters are the same as for
2394 * EET_DATA_DESCRIPTOR_ADD_BASIC(), with the @p subtype being the
2395 * exception. This must be the data descriptor of the element that
2396 * is in each member of the hash to be stored.
2399 * @ingroup Eet_Data_Group
2401 #define EET_DATA_DESCRIPTOR_ADD_ARRAY(edd, struct_type, name, member, subtype)\
2403 struct_type ___ett;\
2405 eet_data_descriptor_element_add(edd, name, EET_T_UNKNOW, EET_G_ARRAY,\
2406 (char *)(& (___ett.member)) -\
2407 (char *)(& (___ett)),\
2408 /* 0, */ sizeof(___ett.member) /\
2409 sizeof(___ett.member[0]), NULL, subtype);\
2413 * Add a variable size array type to a data descriptor
2414 * @param edd The data descriptor to add the type to.
2415 * @param struct_type The type of the struct.
2416 * @param name The string name to use to encode/decode this member
2417 * (must be a constant global and never change).
2418 * @param member The struct member itself to be encoded.
2419 * @param subtype The type of hash member to add.
2421 * This macro lets you easily add a fixed size array of other data
2422 * types. All the parameters are the same as for
2423 * EET_DATA_DESCRIPTOR_ADD_BASIC(), with the @p subtype being the
2424 * exception. This must be the data descriptor of the element that
2425 * is in each member of the hash to be stored.
2428 * @ingroup Eet_Data_Group
2430 #define EET_DATA_DESCRIPTOR_ADD_VAR_ARRAY(edd,\
2436 struct_type ___ett;\
2438 eet_data_descriptor_element_add(edd,\
2442 (char *)(& (___ett.member)) -\
2443 (char *)(& (___ett)),\
2444 (char *)(& (___ett.member ## _count)) -\
2445 (char *)(& (___ett)),\
2451 * Add an union type to a data descriptor
2452 * @param edd The data descriptor to add the type to.
2453 * @param struct_type The type of the struct.
2454 * @param name The string name to use to encode/decode this member
2455 * (must be a constant global and never change).
2456 * @param member The struct member itself to be encoded.
2457 * @param type_member The member that give hints on what is in the union.
2458 * @param unified_type Describe all possible type the union could handle.
2460 * This macro lets you easily add an union with a member that specify what is inside.
2461 * The @p unified_type is an Eet_Data_Descriptor, but only the entry that match the name
2462 * returned by type_get will be used for each serialized data. The type_get and type_set
2463 * callback of unified_type should be defined.
2466 * @ingroup Eet_Data_Group
2467 * @see Eet_Data_Descriptor_Class
2469 #define EET_DATA_DESCRIPTOR_ADD_UNION(edd,\
2476 struct_type ___ett;\
2478 eet_data_descriptor_element_add(edd, name, EET_T_UNKNOW, EET_G_UNION,\
2479 (char *)(& (___ett.member)) -\
2480 (char *)(& (___ett)),\
2481 (char *)(& (___ett.type_member)) -\
2482 (char *)(& (___ett)),\
2483 NULL, unified_type);\
2487 * Add a automatically selectable type to a data descriptor
2488 * @param edd The data descriptor to add the type to.
2489 * @param struct_type The type of the struct.
2490 * @param name The string name to use to encode/decode this member
2491 * (must be a constant global and never change).
2492 * @param member The struct member itself to be encoded.
2493 * @param type_member The member that give hints on what is in the union.
2494 * @param unified_type Describe all possible type the union could handle.
2496 * This macro lets you easily define what the content of @p member points to depending of
2497 * the content of @p type_member. The type_get and type_set callback of unified_type should
2498 * be defined. If the the type is not know at the time of restoring it, eet will still call
2499 * type_set of @p unified_type but the pointer will be set to a serialized binary representation
2500 * of what eet know. This make it possible, to save this pointer again by just returning the string
2501 * given previously and telling it by setting unknow to EINA_TRUE.
2504 * @ingroup Eet_Data_Group
2505 * @see Eet_Data_Descriptor_Class
2507 #define EET_DATA_DESCRIPTOR_ADD_VARIANT(edd,\
2514 struct_type ___ett;\
2516 eet_data_descriptor_element_add(edd, name, EET_T_UNKNOW, EET_G_VARIANT,\
2517 (char *)(& (___ett.member)) -\
2518 (char *)(& (___ett)),\
2519 (char *)(& (___ett.type_member)) -\
2520 (char *)(& (___ett)),\
2521 NULL, unified_type);\
2525 * Add a mapping to a data descriptor that will be used by union, variant or inherited type
2526 * @param unified_type The data descriptor to add the mapping to.
2527 * @param name The string name to get/set type.
2528 * @param subtype The matching data descriptor.
2531 * @ingroup Eet_Data_Group
2532 * @see Eet_Data_Descriptor_Class
2534 #define EET_DATA_DESCRIPTOR_ADD_MAPPING(unified_type, name, subtype)\
2535 eet_data_descriptor_element_add(unified_type,\
2545 * @defgroup Eet_Data_Cipher_Group Eet Data Serialization using A Ciphers
2547 * Most of the @ref Eet_Data_Group have alternative versions that
2548 * accounts for ciphers to protect their content.
2550 * @see @ref Eet_Cipher_Group
2552 * @ingroup Eet_Data_Group
2556 * Read a data structure from an eet file and decodes it using a cipher.
2557 * @param ef The eet file handle to read from.
2558 * @param edd The data descriptor handle to use when decoding.
2559 * @param name The key the data is stored under in the eet file.
2560 * @param cipher_key The key to use as cipher.
2561 * @return A pointer to the decoded data structure.
2563 * This function decodes a data structure stored in an eet file, returning
2564 * a pointer to it if it decoded successfully, or NULL on failure. This
2565 * can save a programmer dozens of hours of work in writing configuration
2566 * file parsing and writing code, as eet does all that work for the program
2567 * and presents a program-friendly data structure, just as the programmer
2568 * likes. Eet can handle members being added or deleted from the data in
2569 * storage and safely zero-fills unfilled members if they were not found
2570 * in the data. It checks sizes and headers whenever it reads data, allowing
2571 * the programmer to not worry about corrupt data.
2573 * Once a data structure has been described by the programmer with the
2574 * fields they wish to save or load, storing or retrieving a data structure
2575 * from an eet file, or from a chunk of memory is as simple as a single
2578 * @see eet_data_read()
2581 * @ingroup Eet_Data_Cipher_Group
2583 EAPI void * eet_data_read_cipher(Eet_File *ef,
2584 Eet_Data_Descriptor *edd,
2586 const char *cipher_key);
2589 * Write a data structure from memory and store in an eet file
2591 * @param ef The eet file handle to write to.
2592 * @param edd The data descriptor to use when encoding.
2593 * @param name The key to store the data under in the eet file.
2594 * @param cipher_key The key to use as cipher.
2595 * @param data A pointer to the data structure to ssave and encode.
2596 * @param compress Compression flags for storage.
2597 * @return bytes written on successful write, 0 on failure.
2599 * This function is the reverse of eet_data_read(), saving a data structure
2602 * @see eet_data_write_cipher()
2605 * @ingroup Eet_Data_Cipher_Group
2607 EAPI int eet_data_write_cipher(Eet_File *ef,
2608 Eet_Data_Descriptor *edd,
2610 const char *cipher_key,
2615 * Dump an eet encoded data structure into ascii text using a cipher.
2616 * @param data_in The pointer to the data to decode into a struct.
2617 * @param cipher_key The key to use as cipher.
2618 * @param size_in The size of the data pointed to in bytes.
2619 * @param dumpfunc The function to call passed a string when new
2620 * data is converted to text
2621 * @param dumpdata The data to pass to the @p dumpfunc callback.
2622 * @return 1 on success, 0 on failure
2624 * This function will take a chunk of data encoded by
2625 * eet_data_descriptor_encode() and convert it into human readable
2626 * ascii text. It does this by calling the @p dumpfunc callback
2627 * for all new text that is generated. This callback should append
2628 * to any existing text buffer and will be passed the pointer @p
2629 * dumpdata as a parameter as well as a string with new text to be
2635 * void output(void *data, const char *string)
2637 * printf("%s", string);
2640 * void dump(const char *file)
2646 * f = fopen(file, "r");
2647 * fseek(f, 0, SEEK_END);
2650 * data = malloc(len);
2651 * fread(data, len, 1, f);
2653 * eet_data_text_dump_cipher(data, cipher_key, len, output, NULL);
2657 * @see eet_data_text_dump()
2660 * @ingroup Eet_Data_Cipher_Group
2662 EAPI int eet_data_text_dump_cipher(const void *data_in,
2663 const char *cipher_key,
2665 void (*dumpfunc)(void *data, const char *str),
2669 * Take an ascii encoding from eet_data_text_dump() and re-encode
2670 * in binary using a cipher.
2671 * @param text The pointer to the string data to parse and encode.
2672 * @param cipher_key The key to use as cipher.
2673 * @param textlen The size of the string in bytes (not including 0
2675 * @param size_ret This gets filled in with the encoded data blob
2677 * @return The encoded data on success, NULL on failure.
2679 * This function will parse the string pointed to by @p text and return
2680 * an encoded data lump the same way eet_data_descriptor_encode() takes an
2681 * in-memory data struct and encodes into a binary blob. @p text is a normal
2684 * @see eet_data_text_undump()
2687 * @ingroup Eet_Data_Cipher_Group
2689 EAPI void * eet_data_text_undump_cipher(const char *text,
2690 const char *cipher_key,
2695 * Dump an eet encoded data structure from an eet file into ascii
2696 * text using a cipher.
2697 * @param ef A valid eet file handle.
2698 * @param name Name of the entry. eg: "/base/file_i_want".
2699 * @param cipher_key The key to use as cipher.
2700 * @param dumpfunc The function to call passed a string when new
2701 * data is converted to text
2702 * @param dumpdata The data to pass to the @p dumpfunc callback.
2703 * @return 1 on success, 0 on failure
2705 * This function will take an open and valid eet file from
2706 * eet_open() request the data encoded by
2707 * eet_data_descriptor_encode() corresponding to the key @p name
2708 * and convert it into human readable ascii text. It does this by
2709 * calling the @p dumpfunc callback for all new text that is
2710 * generated. This callback should append to any existing text
2711 * buffer and will be passed the pointer @p dumpdata as a parameter
2712 * as well as a string with new text to be appended.
2714 * @see eet_data_dump()
2717 * @ingroup Eet_Data_Cipher_Group
2719 EAPI int eet_data_dump_cipher(Eet_File *ef,
2721 const char *cipher_key,
2722 void (*dumpfunc)(void *data, const char *str),
2726 * Take an ascii encoding from eet_data_dump() and re-encode in
2727 * binary using a cipher.
2728 * @param ef A valid eet file handle.
2729 * @param name Name of the entry. eg: "/base/file_i_want".
2730 * @param cipher_key The key to use as cipher.
2731 * @param text The pointer to the string data to parse and encode.
2732 * @param textlen The size of the string in bytes (not including 0
2734 * @param compress Compression flags (1 == compress, 0 = don't compress).
2735 * @return 1 on success, 0 on failure
2737 * This function will parse the string pointed to by @p text,
2738 * encode it the same way eet_data_descriptor_encode() takes an
2739 * in-memory data struct and encodes into a binary blob.
2741 * The data (optionally compressed) will be in ram, pending a flush to
2742 * disk (it will stay in ram till the eet file handle is closed though).
2744 * @see eet_data_undump()
2747 * @ingroup Eet_Data_Cipher_Group
2749 EAPI int eet_data_undump_cipher(Eet_File *ef,
2751 const char *cipher_key,
2757 * Decode a data structure from an arbitary location in memory
2759 * @param edd The data descriptor to use when decoding.
2760 * @param data_in The pointer to the data to decode into a struct.
2761 * @param cipher_key The key to use as cipher.
2762 * @param size_in The size of the data pointed to in bytes.
2763 * @return NULL on failure, or a valid decoded struct pointer on success.
2765 * This function will decode a data structure that has been encoded using
2766 * eet_data_descriptor_encode(), and return a data structure with all its
2767 * elements filled out, if successful, or NULL on failure.
2769 * The data to be decoded is stored at the memory pointed to by @p data_in,
2770 * and is described by the descriptor pointed to by @p edd. The data size is
2771 * passed in as the value to @p size_in, ande must be greater than 0 to
2774 * This function is useful for decoding data structures delivered to the
2775 * application by means other than an eet file, such as an IPC or socket
2776 * connection, raw files, shared memory etc.
2778 * Please see eet_data_read() for more information.
2780 * @see eet_data_descriptor_decode()
2783 * @ingroup Eet_Data_Cipher_Group
2785 EAPI void * eet_data_descriptor_decode_cipher(Eet_Data_Descriptor *edd,
2786 const void *data_in,
2787 const char *cipher_key,
2791 * Encode a data struct to memory and return that encoded data
2793 * @param edd The data descriptor to use when encoding.
2794 * @param data_in The pointer to the struct to encode into data.
2795 * @param cipher_key The key to use as cipher.
2796 * @param size_ret pointer to the an int to be filled with the decoded size.
2797 * @return NULL on failure, or a valid encoded data chunk on success.
2799 * This function takes a data structutre in memory and encodes it into a
2800 * serialised chunk of data that can be decoded again by
2801 * eet_data_descriptor_decode(). This is useful for being able to transmit
2802 * data structures across sockets, pipes, IPC or shared file mechanisms,
2803 * without having to worry about memory space, machine type, endianess etc.
2805 * The parameter @p edd must point to a valid data descriptor, and
2806 * @p data_in must point to the right data structure to encode. If not, the
2807 * encoding may fail.
2809 * On success a non NULL valid pointer is returned and what @p size_ret
2810 * points to is set to the size of this decoded data, in bytes. When the
2811 * encoded data is no longer needed, call free() on it. On failure NULL is
2812 * returned and what @p size_ret points to is set to 0.
2814 * Please see eet_data_write() for more information.
2816 * @see eet_data_descriptor_encode()
2819 * @ingroup Eet_Data_Cipher_Group
2821 EAPI void * eet_data_descriptor_encode_cipher(Eet_Data_Descriptor *edd,
2822 const void *data_in,
2823 const char *cipher_key,
2827 * @defgroup Eet_Node_Group Low-level Serialization Structures.
2829 * Functions that create, destroy and manipulate serialization nodes
2830 * used by @ref Eet_Data_Group.
2837 * Opaque handle to manage serialization node.
2839 typedef struct _Eet_Node Eet_Node;
2842 * @typedef Eet_Node_Data
2843 * Contains an union that can fit any kind of node.
2845 typedef struct _Eet_Node_Data Eet_Node_Data;
2848 * @struct _Eet_Node_Data
2849 * Contains an union that can fit any kind of node.
2851 struct _Eet_Node_Data
2863 unsigned long long ul;
2874 * @ingroup Eet_Node_Group
2876 EAPI Eet_Node * eet_node_char_new(const char *name,
2881 * @ingroup Eet_Node_Group
2883 EAPI Eet_Node * eet_node_short_new(const char *name,
2888 * @ingroup Eet_Node_Group
2890 EAPI Eet_Node * eet_node_int_new(const char *name,
2895 * @ingroup Eet_Node_Group
2897 EAPI Eet_Node * eet_node_long_long_new(const char *name,
2902 * @ingroup Eet_Node_Group
2904 EAPI Eet_Node * eet_node_float_new(const char *name,
2909 * @ingroup Eet_Node_Group
2911 EAPI Eet_Node * eet_node_double_new(const char *name,
2916 * @ingroup Eet_Node_Group
2918 EAPI Eet_Node * eet_node_unsigned_char_new(const char *name,
2923 * @ingroup Eet_Node_Group
2925 EAPI Eet_Node * eet_node_unsigned_short_new(const char *name,
2930 * @ingroup Eet_Node_Group
2932 EAPI Eet_Node * eet_node_unsigned_int_new(const char *name,
2937 * @ingroup Eet_Node_Group
2939 EAPI Eet_Node * eet_node_unsigned_long_long_new(const char *name,
2940 unsigned long long l);
2944 * @ingroup Eet_Node_Group
2946 EAPI Eet_Node * eet_node_string_new(const char *name,
2951 * @ingroup Eet_Node_Group
2953 EAPI Eet_Node * eet_node_inlined_string_new(const char *name,
2958 * @ingroup Eet_Node_Group
2960 EAPI Eet_Node * eet_node_null_new(const char *name);
2964 * @ingroup Eet_Node_Group
2966 EAPI Eet_Node * eet_node_list_new(const char *name,
2971 * @ingroup Eet_Node_Group
2973 EAPI Eet_Node * eet_node_array_new(const char *name,
2979 * @ingroup Eet_Node_Group
2981 EAPI Eet_Node * eet_node_var_array_new(const char *name,
2986 * @ingroup Eet_Node_Group
2988 EAPI Eet_Node * eet_node_hash_new(const char *name,
2994 * @ingroup Eet_Node_Group
2996 EAPI Eet_Node * eet_node_struct_new(const char *name,
3001 * @ingroup Eet_Node_Group
3003 EAPI Eet_Node * eet_node_struct_child_new(const char *parent,
3008 * @ingroup Eet_Node_Group
3010 EAPI void eet_node_list_append(Eet_Node *parent,
3016 * @ingroup Eet_Node_Group
3018 EAPI void eet_node_struct_append(Eet_Node *parent,
3024 * @ingroup Eet_Node_Group
3026 EAPI void eet_node_hash_add(Eet_Node *parent,
3033 * @ingroup Eet_Node_Group
3035 EAPI void eet_node_dump(Eet_Node *n,
3037 void (*dumpfunc)(void *data, const char *str),
3042 * @ingroup Eet_Node_Group
3044 EAPI void eet_node_del(Eet_Node *n);
3048 * @ingroup Eet_Node_Group
3050 EAPI void * eet_data_node_encode_cipher(Eet_Node *node,
3051 const char *cipher_key,
3056 * @ingroup Eet_Node_Group
3058 EAPI Eet_Node * eet_data_node_decode_cipher(const void *data_in,
3059 const char *cipher_key,
3064 * @ingroup Eet_Node_Group
3066 EAPI Eet_Node * eet_data_node_read_cipher(Eet_File *ef,
3068 const char *cipher_key);
3072 * @ingroup Eet_Node_Group
3074 EAPI int eet_data_node_write_cipher(Eet_File *ef,
3076 const char *cipher_key,
3080 /* EXPERIMENTAL: THIS API MAY CHANGE IN THE FUTURE, USE IT ONLY IF YOU KNOW WHAT YOU ARE DOING. */
3083 * @typedef Eet_Node_Walk
3084 * Describes how to walk trees of #Eet_Node.
3086 typedef struct _Eet_Node_Walk Eet_Node_Walk;
3089 * @struct _Eet_Node_Walk
3090 * Describes how to walk trees of #Eet_Node.
3092 struct _Eet_Node_Walk
3094 void *(*struct_alloc)(const char *type, void *user_data);
3095 void (*struct_add)(void *parent, const char *name, void *child, void *user_data);
3096 void *(*array)(Eina_Bool variable, const char *name, int count, void *user_data);
3097 void (*insert)(void *array, int index, void *child, void *user_data);
3098 void *(*list)(const char *name, void *user_data);
3099 void (*append)(void *list, void *child, void *user_data);
3100 void *(*hash)(void *parent, const char *name, const char *key, void *value, void *user_data);
3101 void *(*simple)(int type, Eet_Node_Data *data, void *user_data);
3104 EAPI void * eet_node_walk(void *parent,
3113 * @defgroup Eet_Connection_Group Helper function to use eet over a network link
3115 * Function that reconstruct and prepare packet of @ref Eet_Data_Group to be send.
3120 * @typedef Eet_Connection
3121 * Opaque handle to track paquet for a specific connection.
3123 * @ingroup Eet_Connection_Group
3125 typedef struct _Eet_Connection Eet_Connection;
3128 * @typedef Eet_Read_Cb
3129 * Called back when an @ref Eet_Data_Group has been received completly and could be used.
3131 * @ingroup Eet_Connection_Group
3133 typedef Eina_Bool Eet_Read_Cb (const void *eet_data, size_t size, void *user_data);
3136 * @typedef Eet_Write_Cb
3137 * Called back when a packet containing @ref Eet_Data_Group data is ready to be send.
3139 * @ingroup Eet_Connection_Group
3141 typedef Eina_Bool Eet_Write_Cb (const void *data, size_t size, void *user_data);
3144 * Instanciate a new connection to track.
3145 * @oaram eet_read_cb Function to call when one Eet_Data packet has been fully assemble.
3146 * @param eet_write_cb Function to call when one Eet_Data packet is ready to be send over the wire.
3147 * @param user_data Pointer provided to both functions to be used as a context handler.
3148 * @return NULL on failure, or a valid Eet_Connection handler.
3150 * For every connection to track you will need a separate Eet_Connection provider.
3153 * @ingroup Eet_Connection_Group
3155 EAPI Eet_Connection * eet_connection_new(Eet_Read_Cb *eet_read_cb,
3156 Eet_Write_Cb *eet_write_cb,
3157 const void *user_data);
3160 * Process a raw packet received over the link
3161 * @oaram conn Connection handler to track.
3162 * @param data Raw data packet.
3163 * @param size The size of that packet.
3164 * @return 0 on complete success, any other value indicate where in the stream it got wrong (It could be before that packet).
3166 * Every time you receive a packet related to your connection, you should pass
3167 * it to that function so that it could process and assemble packet has you
3168 * receive it. It will automatically call Eet_Read_Cb when one is fully received.
3171 * @ingroup Eet_Connection_Group
3173 EAPI int eet_connection_received(Eet_Connection *conn,
3178 * Convert a complex structure and prepare it to be send.
3179 * @oaram conn Connection handler to track.
3180 * @param edd The data descriptor to use when encoding.
3181 * @param data_in The pointer to the struct to encode into data.
3182 * @param cipher_key The key to use as cipher.
3183 * @return EINA_TRUE if the data where correctly send, EINA_FALSE if they don't.
3185 * This function serialize data_in with edd, assemble the packet and call
3186 * Eet_Write_Cb when ready. The data passed Eet_Write_Cb are temporary allocated
3187 * and will vanish just after the return of the callback.
3189 * @see eet_data_descriptor_encode_cipher
3192 * @ingroup Eet_Connection_Group
3194 EAPI Eina_Bool eet_connection_send(Eet_Connection *conn,
3195 Eet_Data_Descriptor *edd,
3196 const void *data_in,
3197 const char *cipher_key);
3200 * Convert a Eet_Node tree and prepare it to be send.
3201 * @oaram conn Connection handler to track.
3202 * @param node The data tree to use when encoding.
3203 * @param cipher_key The key to use as cipher.
3204 * @return EINA_TRUE if the data where correctly send, EINA_FALSE if they don't.
3206 * This function serialize node, assemble the packet and call
3207 * Eet_Write_Cb when ready. The data passed Eet_Write_Cb are temporary allocated
3208 * and will vanish just after the return of the callback.
3210 * @see eet_data_node_encode_cipher
3213 * @ingroup Eet_Connection_Group
3215 EAPI Eina_Bool eet_connection_node_send(Eet_Connection *conn,
3217 const char *cipher_key);
3220 * Close a connection and lost its track.
3221 * @oaram conn Connection handler to close.
3222 * @param on_going Signal if a partial packet wasn't completed.
3223 * @return the user_data passed to both callback.
3226 * @ingroup Eet_Connection_Group
3228 EAPI void * eet_connection_close(Eet_Connection *conn,
3229 Eina_Bool *on_going);
3231 /***************************************************************************/
3235 #endif /* ifdef __cplusplus */
3237 #endif /* ifndef _EET_H */