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 4
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.
131 * Shut down the EET library.
133 * @return The new init count.
144 * Eet didn't free items by default. If you are under memory
145 * presure, just call this function to recall all memory that are
146 * not yet referenced anymore. The cache take care of modification
153 eet_clearcache(void);
156 * @defgroup Eet_File_Group Eet File Main Functions
158 * Functions to create, destroy and do basic manipulation of
165 * @enum _Eet_File_Mode
166 * Modes that a file can be opened.
168 typedef enum _Eet_File_Mode
170 EET_FILE_MODE_INVALID = -1,
171 EET_FILE_MODE_READ, /**< File is read-only. */
172 EET_FILE_MODE_WRITE, /**< File is write-only. */
173 EET_FILE_MODE_READ_WRITE /**< File is for both read and write */
174 } Eet_File_Mode; /**< Modes that a file can be opened. */
178 * Opaque handle that defines an Eet file (or memory).
181 * @see eet_memopen_read()
184 typedef struct _Eet_File Eet_File;
187 * @typedef Eet_Dictionary
188 * Opaque handle that defines a file-backed (mmaped) dictionary of strings.
190 typedef struct _Eet_Dictionary Eet_Dictionary;
197 * Open an eet file on disk, and returns a handle to it.
198 * @param file The file path to the eet file. eg: @c "/tmp/file.eet".
199 * @param mode The mode for opening. Either #EET_FILE_MODE_READ,
200 * #EET_FILE_MODE_WRITE or #EET_FILE_MODE_READ_WRITE.
201 * @return An opened eet file handle.
202 * @ingroup Eet_File_Group
204 * This function will open an exiting eet file for reading, and build
205 * the directory table in memory and return a handle to the file, if it
206 * exists and can be read, and no memory errors occur on the way, otherwise
207 * NULL will be returned.
209 * It will also open an eet file for writing. This will, if successful,
210 * delete the original file and replace it with a new empty file, till
211 * the eet file handle is closed or flushed. If it cannot be opened for
212 * writing or a memory error occurs, NULL is returned.
214 * You can also open the file for read/write. If you then write a key that
215 * does not exist it will be created, if the key exists it will be replaced
222 * #include <string.h>
225 * main(int argc, char **argv)
228 * char buf[1024], *ret, **list;
233 * strcpy(buf, "Here is a string of data to save!");
235 * ef = eet_open("/tmp/my_file.eet", EET_FILE_MODE_WRITE);
236 * if (!ef) return -1;
237 * if (!eet_write(ef, "/key/to_store/at", buf, 1024, 1))
238 * fprintf(stderr, "Error writing data!\n");
241 * ef = eet_open("/tmp/my_file.eet", EET_FILE_MODE_READ);
242 * if (!ef) return -1;
243 * list = eet_list(ef, "*", &num);
246 * for (i = 0; i < num; i++)
247 * printf("Key stored: %s\n", list[i]);
250 * ret = eet_read(ef, "/key/to_store/at", &size);
253 * printf("Data read (%i bytes):\n%s\n", size, ret);
267 eet_open(const char *file,
271 * Open an eet file directly from a memory location. The data are not copied,
272 * so you must keep them around as long as the eet file is open. Their is
273 * currently no cache for this kind of Eet_File, so it's reopen every time
274 * you do use eet_memopen_read.
277 * @ingroup Eet_File_Group
280 eet_memopen_read(const void *data,
284 * Get the mode an Eet_File was opened with.
285 * @param ef A valid eet file handle.
286 * @return The mode ef was opened with.
289 * @ingroup Eet_File_Group
292 eet_mode_get(Eet_File *ef);
295 * Close an eet file handle and flush and writes pending.
296 * @param ef A valid eet file handle.
298 * This function will flush any pending writes to disk if the eet file
299 * was opened for write, and free all data associated with the file handle
300 * and file, and close the file.
302 * If the eet file handle is not valid nothing will be done.
305 * @ingroup Eet_File_Group
308 eet_close(Eet_File *ef);
311 * Sync content of an eet file handle, flushing pending writes.
312 * @param ef A valid eet file handle.
314 * This function will flush any pending writes to disk. The eet file must
315 * be opened for write.
317 * If the eet file handle is not valid nothing will be done.
320 * @ingroup Eet_File_Group
323 eet_sync(Eet_File *ef);
326 * Return a handle to the shared string dictionary of the Eet file
327 * @param ef A valid eet file handle.
328 * @return A handle to the dictionary of the file
330 * This function returns a handle to the dictionary of an Eet file whose
331 * handle is @p ef, if a dictionary exists. NULL is returned otherwise or
332 * if the file handle is known to be invalid.
334 * @see eet_dictionary_string_check() to know if given string came
335 * from the dictionary or it was dynamically allocated using
336 * the #Eet_Data_Descriptor_Class instructrions.
339 * @ingroup Eet_File_Group
341 EAPI Eet_Dictionary *
342 eet_dictionary_get(Eet_File *ef);
345 * Check if a given string comes from a given dictionary
346 * @param ed A valid dictionary handle
347 * @param string A valid 0 byte terminated C string
348 * @return 1 if it is in the dictionary, 0 otherwise
350 * This checks the given dictionary to see if the given string is actually
351 * inside that dictionary (i.e. comes from it) and returns 1 if it does.
352 * If the dictionary handle is invlide, the string is NULL or the string is
353 * not in the dictionary, 0 is returned.
356 * @ingroup Eet_File_Group
359 eet_dictionary_string_check(Eet_Dictionary *ed,
363 * Read a specified entry from an eet file and return data
364 * @param ef A valid eet file handle opened for reading.
365 * @param name Name of the entry. eg: "/base/file_i_want".
366 * @param size_ret Number of bytes read from entry and returned.
367 * @return The data stored in that entry in the eet file.
369 * This function finds an entry in the eet file that is stored under the
370 * name specified, and returns that data, decompressed, if successful.
371 * NULL is returned if the lookup fails or if memory errors are
372 * encountered. It is the job of the calling program to call free() on
373 * the returned data. The number of bytes in the returned data chunk are
374 * placed in size_ret.
376 * If the eet file handle is not valid NULL is returned and size_ret is
379 * @see eet_read_cipher()
382 * @ingroup Eet_File_Group
385 eet_read(Eet_File *ef,
390 * Read a specified entry from an eet file and return data
391 * @param ef A valid eet file handle opened for reading.
392 * @param name Name of the entry. eg: "/base/file_i_want".
393 * @param size_ret Number of bytes read from entry and returned.
394 * @return The data stored in that entry in the eet file.
396 * This function finds an entry in the eet file that is stored under the
397 * name specified, and returns that data if not compressed and successful.
398 * NULL is returned if the lookup fails or if memory errors are
399 * encountered or if the data is comrpessed. The calling program must never
400 * call free() on the returned data. The number of bytes in the returned
401 * data chunk are placed in size_ret.
403 * If the eet file handle is not valid NULL is returned and size_ret is
407 * @ingroup Eet_File_Group
410 eet_read_direct(Eet_File *ef,
415 * Write a specified entry to an eet file handle
416 * @param ef A valid eet file handle opened for writing.
417 * @param name Name of the entry. eg: "/base/file_i_want".
418 * @param data Pointer to the data to be stored.
419 * @param size Length in bytes in the data to be stored.
420 * @param compress Compression flags (1 == compress, 0 = don't compress).
421 * @return bytes written on successful write, 0 on failure.
423 * This function will write the specified chunk of data to the eet file
424 * and return greater than 0 on success. 0 will be returned on failure.
426 * The eet file handle must be a valid file handle for an eet file opened
427 * for writing. If it is not, 0 will be returned and no action will be
430 * Name, and data must not be NULL, and size must be > 0. If these
431 * conditions are not met, 0 will be returned.
433 * The data will be copied (and optionally compressed) in ram, pending
434 * a flush to disk (it will stay in ram till the eet file handle is
437 * @see eet_write_cipher()
440 * @ingroup Eet_File_Group
443 eet_write(Eet_File *ef,
450 * Delete a specified entry from an Eet file being written or re-written
451 * @param ef A valid eet file handle opened for writing.
452 * @param name Name of the entry. eg: "/base/file_i_want".
453 * @return Success or failure of the delete.
455 * This function will delete the specified chunk of data from the eet file
456 * and return greater than 0 on success. 0 will be returned on failure.
458 * The eet file handle must be a valid file handle for an eet file opened
459 * for writing. If it is not, 0 will be returned and no action will be
462 * Name, must not be NULL, otherwise 0 will be returned.
465 * @ingroup Eet_File_Group
468 eet_delete(Eet_File *ef,
472 * Alias a specific section to another one. Destination may exist or not,
474 * @param ef A valid eet file handle opened for writing.
475 * @param name Name of the entry. eg: "/base/file_i_want".
476 * @param destination Destionation of the alias. eg: "/base/the_real_stuff_i_want".
477 * @param compress Compression flags (1 == compress, 0 = don't compress).
478 * @return EINA_TRUE on success, EINA_FALSE on failure.
480 * Name and Destination must not be NULL, otherwhise EINA_FALSE will be returned.
483 * @ingroup Eet_File_Group
486 eet_alias(Eet_File *ef,
488 const char *destination,
492 * List all entries in eet file matching shell glob.
493 * @param ef A valid eet file handle.
494 * @param glob A shell glob to match against.
495 * @param count_ret Number of entries found to match.
496 * @return Pointer to an array of strings.
498 * This function will list all entries in the eet file matching the
499 * supplied shell glob and return an allocated list of their names, if
500 * there are any, and if no memory errors occur.
502 * The eet file handle must be valid and glob must not be NULL, or NULL
503 * will be returned and count_ret will be filled with 0.
505 * The calling program must call free() on the array returned, but NOT
506 * on the string pointers in the array. They are taken as read-only
507 * internals from the eet file handle. They are only valid as long as
508 * the file handle is not closed. When it is closed those pointers in the
509 * array are now not valid and should not be used.
511 * On success the array returned will have a list of string pointers
512 * that are the names of the entries that matched, and count_ret will have
513 * the number of entries in this array placed in it.
515 * Hint: an easy way to list all entries in an eet file is to use a glob
519 * @ingroup Eet_File_Group
522 eet_list(Eet_File *ef,
527 * Return the number of entries in the specified eet file.
528 * @param ef A valid eet file handle.
529 * @return Number of entries in ef or -1 if the number of entries
530 * cannot be read due to open mode restrictions.
533 * @ingroup Eet_File_Group
536 eet_num_entries(Eet_File *ef);
539 * @defgroup Eet_File_Cipher_Group Eet File Ciphered Main Functions
541 * Most of the @ref Eet_File_Group have alternative versions that
542 * accounts for ciphers to protect their content.
544 * @see @ref Eet_Cipher_Group
546 * @ingroup Eet_File_Group
550 * Read a specified entry from an eet file and return data using a cipher.
551 * @param ef A valid eet file handle opened for reading.
552 * @param name Name of the entry. eg: "/base/file_i_want".
553 * @param size_ret Number of bytes read from entry and returned.
554 * @param cipher_key The key to use as cipher.
555 * @return The data stored in that entry in the eet file.
557 * This function finds an entry in the eet file that is stored under the
558 * name specified, and returns that data, decompressed, if successful.
559 * NULL is returned if the lookup fails or if memory errors are
560 * encountered. It is the job of the calling program to call free() on
561 * the returned data. The number of bytes in the returned data chunk are
562 * placed in size_ret.
564 * If the eet file handle is not valid NULL is returned and size_ret is
570 * @ingroup Eet_File_Cipher_Group
573 eet_read_cipher(Eet_File *ef,
576 const char *cipher_key);
579 * Write a specified entry to an eet file handle using a cipher.
580 * @param ef A valid eet file handle opened for writing.
581 * @param name Name of the entry. eg: "/base/file_i_want".
582 * @param data Pointer to the data to be stored.
583 * @param size Length in bytes in the data to be stored.
584 * @param compress Compression flags (1 == compress, 0 = don't compress).
585 * @param cipher_key The key to use as cipher.
586 * @return bytes written on successful write, 0 on failure.
588 * This function will write the specified chunk of data to the eet file
589 * and return greater than 0 on success. 0 will be returned on failure.
591 * The eet file handle must be a valid file handle for an eet file opened
592 * for writing. If it is not, 0 will be returned and no action will be
595 * Name, and data must not be NULL, and size must be > 0. If these
596 * conditions are not met, 0 will be returned.
598 * The data will be copied (and optionally compressed) in ram, pending
599 * a flush to disk (it will stay in ram till the eet file handle is
605 * @ingroup Eet_File_Cipher_Group
608 eet_write_cipher(Eet_File *ef,
613 const char *cipher_key);
616 * @defgroup Eet_File_Image_Group Image Store and Load
618 * Eet efficiently stores and loads images, including alpha
619 * channels and lossy compressions.
623 * Read just the header data for an image and dont decode the pixels.
624 * @param ef A valid eet file handle opened for reading.
625 * @param name Name of the entry. eg: "/base/file_i_want".
626 * @param w A pointer to the unsigned int to hold the width in pixels.
627 * @param h A pointer to the unsigned int to hold the height in pixels.
628 * @param alpha A pointer to the int to hold the alpha flag.
629 * @param compress A pointer to the int to hold the compression amount.
630 * @param quality A pointer to the int to hold the quality amount.
631 * @param lossy A pointer to the int to hold the lossiness flag.
632 * @return 1 on successfull decode, 0 otherwise
634 * This function reads an image from an eet file stored under the named
635 * key in the eet file and return a pointer to the decompressed pixel data.
637 * The other parameters of the image (width, height etc.) are placed into
638 * the values pointed to (they must be supplied). The pixel data is a linear
639 * array of pixels starting from the top-left of the image scanning row by
640 * row from left to right. Each pile is a 32bit value, with the high byte
641 * being the alpha channel, the next being red, then green, and the low byte
642 * being blue. The width and height are measured in pixels and will be
643 * greater than 0 when returned. The alpha flag is either 0 or 1. 0 denotes
644 * that the alpha channel is not used. 1 denotes that it is significant.
645 * Compress is filled with the compression value/amount the image was
646 * stored with. The quality value is filled with the quality encoding of
647 * the image file (0 - 100). The lossy flags is either 0 or 1 as to if
648 * the image was encoded lossily or not.
650 * On success the function returns 1 indicating the header was read and
651 * decoded properly, or 0 on failure.
653 * @see eet_data_image_header_read_cipher()
656 * @ingroup Eet_File_Image_Group
659 eet_data_image_header_read(Eet_File *ef,
669 * Read image data from the named key in the eet file.
670 * @param ef A valid eet file handle opened for reading.
671 * @param name Name of the entry. eg: "/base/file_i_want".
672 * @param w A pointer to the unsigned int to hold the width in pixels.
673 * @param h A pointer to the unsigned int to hold the height in pixels.
674 * @param alpha A pointer to the int to hold the alpha flag.
675 * @param compress A pointer to the int to hold the compression amount.
676 * @param quality A pointer to the int to hold the quality amount.
677 * @param lossy A pointer to the int to hold the lossiness flag.
678 * @return The image pixel data decoded
680 * This function reads an image from an eet file stored under the named
681 * key in the eet file and return a pointer to the decompressed pixel data.
683 * The other parameters of the image (width, height etc.) are placed into
684 * the values pointed to (they must be supplied). The pixel data is a linear
685 * array of pixels starting from the top-left of the image scanning row by
686 * row from left to right. Each pile is a 32bit value, with the high byte
687 * being the alpha channel, the next being red, then green, and the low byte
688 * being blue. The width and height are measured in pixels and will be
689 * greater than 0 when returned. The alpha flag is either 0 or 1. 0 denotes
690 * that the alpha channel is not used. 1 denotes that it is significant.
691 * Compress is filled with the compression value/amount the image was
692 * stored with. The quality value is filled with the quality encoding of
693 * the image file (0 - 100). The lossy flags is either 0 or 1 as to if
694 * the image was encoded lossily or not.
696 * On success the function returns a pointer to the image data decoded. The
697 * calling application is responsible for calling free() on the image data
698 * when it is done with it. On failure NULL is returned and the parameter
699 * values may not contain any sensible data.
701 * @see eet_data_image_read_cipher()
704 * @ingroup Eet_File_Image_Group
707 eet_data_image_read(Eet_File *ef,
717 * Read image data from the named key in the eet file.
718 * @param ef A valid eet file handle opened for reading.
719 * @param name Name of the entry. eg: "/base/file_i_want".
720 * @param src_x The starting x coordinate from where to dump the stream.
721 * @param src_y The starting y coordinate from where to dump the stream.
722 * @param d A pointer to the pixel surface.
723 * @param w The expected width in pixels of the pixel surface to decode.
724 * @param h The expected height in pixels of the pixel surface to decode.
725 * @param row_stride The length of a pixels line in the destination surface.
726 * @param alpha A pointer to the int to hold the alpha flag.
727 * @param compress A pointer to the int to hold the compression amount.
728 * @param quality A pointer to the int to hold the quality amount.
729 * @param lossy A pointer to the int to hold the lossiness flag.
730 * @return 1 on success, 0 otherwise.
732 * This function reads an image from an eet file stored under the named
733 * key in the eet file and return a pointer to the decompressed pixel data.
735 * The other parameters of the image (width, height etc.) are placed into
736 * the values pointed to (they must be supplied). The pixel data is a linear
737 * array of pixels starting from the top-left of the image scanning row by
738 * row from left to right. Each pile is a 32bit value, with the high byte
739 * being the alpha channel, the next being red, then green, and the low byte
740 * being blue. The width and height are measured in pixels and will be
741 * greater than 0 when returned. The alpha flag is either 0 or 1. 0 denotes
742 * that the alpha channel is not used. 1 denotes that it is significant.
743 * Compress is filled with the compression value/amount the image was
744 * stored with. The quality value is filled with the quality encoding of
745 * the image file (0 - 100). The lossy flags is either 0 or 1 as to if
746 * the image was encoded lossily or not.
748 * On success the function returns 1, and 0 on failure. On failure the
749 * parameter values may not contain any sensible data.
751 * @see eet_data_image_read_to_surface_cipher()
754 * @ingroup Eet_File_Image_Group
757 eet_data_image_read_to_surface(Eet_File *ef,
764 unsigned int row_stride,
771 * Write image data to the named key in an eet file.
772 * @param ef A valid eet file handle opened for writing.
773 * @param name Name of the entry. eg: "/base/file_i_want".
774 * @param data A pointer to the image pixel data.
775 * @param w The width of the image in pixels.
776 * @param h The height of the image in pixels.
777 * @param alpha The alpha channel flag.
778 * @param compress The compression amount.
779 * @param quality The quality encoding amount.
780 * @param lossy The lossiness flag.
781 * @return Success if the data was encoded and written or not.
783 * This function takes image pixel data and encodes it in an eet file
784 * stored under the supplied name key, and returns how many bytes were
785 * actually written to encode the image data.
787 * The data expected is the same format as returned by eet_data_image_read.
788 * If this is not the case weird things may happen. Width and height must
789 * be between 1 and 8000 pixels. The alpha flags can be 0 or 1 (0 meaning
790 * the alpha values are not useful and 1 meaning they are). Compress can
791 * be from 0 to 9 (0 meaning no compression, 9 meaning full compression).
792 * This is only used if the image is not lossily encoded. Quality is used on
793 * lossy compression and should be a value from 0 to 100. The lossy flag
794 * can be 0 or 1. 0 means encode losslessly and 1 means to encode with
795 * image quality loss (but then have a much smaller encoding).
797 * On success this function returns the number of bytes that were required
798 * to encode the image data, or on failure it returns 0.
800 * @see eet_data_image_write_cipher()
803 * @ingroup Eet_File_Image_Group
806 eet_data_image_write(Eet_File *ef,
817 * Decode Image data header only to get information.
818 * @param data The encoded pixel data.
819 * @param size The size, in bytes, of the encoded pixel data.
820 * @param w A pointer to the unsigned int to hold the width in pixels.
821 * @param h A pointer to the unsigned int to hold the height in pixels.
822 * @param alpha A pointer to the int to hold the alpha flag.
823 * @param compress A pointer to the int to hold the compression amount.
824 * @param quality A pointer to the int to hold the quality amount.
825 * @param lossy A pointer to the int to hold the lossiness flag.
826 * @return 1 on success, 0 on failure.
828 * This function takes encoded pixel data and decodes it into raw RGBA
831 * The other parameters of the image (width, height etc.) are placed into
832 * the values pointed to (they must be supplied). The pixel data is a linear
833 * array of pixels starting from the top-left of the image scanning row by
834 * row from left to right. Each pixel is a 32bit value, with the high byte
835 * being the alpha channel, the next being red, then green, and the low byte
836 * being blue. The width and height are measured in pixels and will be
837 * greater than 0 when returned. The alpha flag is either 0 or 1. 0 denotes
838 * that the alpha channel is not used. 1 denotes that it is significant.
839 * Compress is filled with the compression value/amount the image was
840 * stored with. The quality value is filled with the quality encoding of
841 * the image file (0 - 100). The lossy flags is either 0 or 1 as to if
842 * the image was encoded lossily or not.
844 * On success the function returns 1 indicating the header was read and
845 * decoded properly, or 0 on failure.
847 * @see eet_data_image_header_decode_cipher()
850 * @ingroup Eet_File_Image_Group
853 eet_data_image_header_decode(const void *data,
863 * Decode Image data into pixel data.
864 * @param data The encoded pixel data.
865 * @param size The size, in bytes, of the encoded pixel data.
866 * @param w A pointer to the unsigned int to hold the width in pixels.
867 * @param h A pointer to the unsigned int to hold the height in pixels.
868 * @param alpha A pointer to the int to hold the alpha flag.
869 * @param compress A pointer to the int to hold the compression amount.
870 * @param quality A pointer to the int to hold the quality amount.
871 * @param lossy A pointer to the int to hold the lossiness flag.
872 * @return The image pixel data decoded
874 * This function takes encoded pixel data and decodes it into raw RGBA
877 * The other parameters of the image (width, height etc.) are placed into
878 * the values pointed to (they must be supplied). The pixel data is a linear
879 * array of pixels starting from the top-left of the image scanning row by
880 * row from left to right. Each pixel is a 32bit value, with the high byte
881 * being the alpha channel, the next being red, then green, and the low byte
882 * being blue. The width and height are measured in pixels and will be
883 * greater than 0 when returned. The alpha flag is either 0 or 1. 0 denotes
884 * that the alpha channel is not used. 1 denotes that it is significant.
885 * Compress is filled with the compression value/amount the image was
886 * stored with. The quality value is filled with the quality encoding of
887 * the image file (0 - 100). The lossy flags is either 0 or 1 as to if
888 * the image was encoded lossily or not.
890 * On success the function returns a pointer to the image data decoded. The
891 * calling application is responsible for calling free() on the image data
892 * when it is done with it. On failure NULL is returned and the parameter
893 * values may not contain any sensible data.
895 * @see eet_data_image_decode_cipher()
898 * @ingroup Eet_File_Image_Group
901 eet_data_image_decode(const void *data,
911 * Decode Image data into pixel data.
912 * @param data The encoded pixel data.
913 * @param size The size, in bytes, of the encoded pixel data.
914 * @param src_x The starting x coordinate from where to dump the stream.
915 * @param src_y The starting y coordinate from where to dump the stream.
916 * @param d A pointer to the pixel surface.
917 * @param w The expected width in pixels of the pixel surface to decode.
918 * @param h The expected height in pixels of the pixel surface to decode.
919 * @param row_stride The length of a pixels line in the destination surface.
920 * @param alpha A pointer to the int to hold the alpha flag.
921 * @param compress A pointer to the int to hold the compression amount.
922 * @param quality A pointer to the int to hold the quality amount.
923 * @param lossy A pointer to the int to hold the lossiness flag.
924 * @return 1 on success, 0 otherwise.
926 * This function takes encoded pixel data and decodes it into raw RGBA
929 * The other parameters of the image (alpha, compress etc.) are placed into
930 * the values pointed to (they must be supplied). The pixel data is a linear
931 * array of pixels starting from the top-left of the image scanning row by
932 * row from left to right. Each pixel is a 32bit value, with the high byte
933 * being the alpha channel, the next being red, then green, and the low byte
934 * being blue. The width and height are measured in pixels and will be
935 * greater than 0 when returned. The alpha flag is either 0 or 1. 0 denotes
936 * that the alpha channel is not used. 1 denotes that it is significant.
937 * Compress is filled with the compression value/amount the image was
938 * stored with. The quality value is filled with the quality encoding of
939 * the image file (0 - 100). The lossy flags is either 0 or 1 as to if
940 * the image was encoded lossily or not.
942 * On success the function returns 1, and 0 on failure. On failure the
943 * parameter values may not contain any sensible data.
945 * @see eet_data_image_decode_to_surface_cipher()
948 * @ingroup Eet_File_Image_Group
951 eet_data_image_decode_to_surface(const void *data,
958 unsigned int row_stride,
965 * Encode image data for storage or transmission.
966 * @param data A pointer to the image pixel data.
967 * @param size_ret A pointer to an int to hold the size of the returned data.
968 * @param w The width of the image in pixels.
969 * @param h The height of the image in pixels.
970 * @param alpha The alpha channel flag.
971 * @param compress The compression amount.
972 * @param quality The quality encoding amount.
973 * @param lossy The lossiness flag.
974 * @return The encoded image data.
976 * This function stakes image pixel data and encodes it with compression and
977 * possible loss of quality (as a trade off for size) for storage or
978 * transmission to another system.
980 * The data expected is the same format as returned by eet_data_image_read.
981 * If this is not the case weird things may happen. Width and height must
982 * be between 1 and 8000 pixels. The alpha flags can be 0 or 1 (0 meaning
983 * the alpha values are not useful and 1 meaning they are). Compress can
984 * be from 0 to 9 (0 meaning no compression, 9 meaning full compression).
985 * This is only used if the image is not lossily encoded. Quality is used on
986 * lossy compression and should be a value from 0 to 100. The lossy flag
987 * can be 0 or 1. 0 means encode losslessly and 1 means to encode with
988 * image quality loss (but then have a much smaller encoding).
990 * On success this function returns a pointer to the encoded data that you
991 * can free with free() when no longer needed.
993 * @see eet_data_image_encode_cipher()
996 * @ingroup Eet_File_Image_Group
999 eet_data_image_encode(const void *data,
1009 * @defgroup Eet_File_Image_Cipher_Group Image Store and Load using a Cipher
1011 * Most of the @ref Eet_File_Image_Group have alternative versions
1012 * that accounts for ciphers to protect their content.
1014 * @see @ref Eet_Cipher_Group
1016 * @ingroup Eet_File_Image_Group
1020 * Read just the header data for an image and dont decode the pixels using a cipher.
1021 * @param ef A valid eet file handle opened for reading.
1022 * @param name Name of the entry. eg: "/base/file_i_want".
1023 * @param cipher_key The key to use as cipher.
1024 * @param w A pointer to the unsigned int to hold the width in pixels.
1025 * @param h A pointer to the unsigned int to hold the height in pixels.
1026 * @param alpha A pointer to the int to hold the alpha flag.
1027 * @param compress A pointer to the int to hold the compression amount.
1028 * @param quality A pointer to the int to hold the quality amount.
1029 * @param lossy A pointer to the int to hold the lossiness flag.
1030 * @return 1 on successfull decode, 0 otherwise
1032 * This function reads an image from an eet file stored under the named
1033 * key in the eet file and return a pointer to the decompressed pixel data.
1035 * The other parameters of the image (width, height etc.) are placed into
1036 * the values pointed to (they must be supplied). The pixel data is a linear
1037 * array of pixels starting from the top-left of the image scanning row by
1038 * row from left to right. Each pile is a 32bit value, with the high byte
1039 * being the alpha channel, the next being red, then green, and the low byte
1040 * being blue. The width and height are measured in pixels and will be
1041 * greater than 0 when returned. The alpha flag is either 0 or 1. 0 denotes
1042 * that the alpha channel is not used. 1 denotes that it is significant.
1043 * Compress is filled with the compression value/amount the image was
1044 * stored with. The quality value is filled with the quality encoding of
1045 * the image file (0 - 100). The lossy flags is either 0 or 1 as to if
1046 * the image was encoded lossily or not.
1048 * On success the function returns 1 indicating the header was read and
1049 * decoded properly, or 0 on failure.
1051 * @see eet_data_image_header_read()
1054 * @ingroup Eet_File_Image_Cipher_Group
1057 eet_data_image_header_read_cipher(Eet_File *ef,
1059 const char *cipher_key,
1068 * Read image data from the named key in the eet file using a cipher.
1069 * @param ef A valid eet file handle opened for reading.
1070 * @param name Name of the entry. eg: "/base/file_i_want".
1071 * @param cipher_key The key to use as cipher.
1072 * @param w A pointer to the unsigned int to hold the width in pixels.
1073 * @param h A pointer to the unsigned int to hold the height in pixels.
1074 * @param alpha A pointer to the int to hold the alpha flag.
1075 * @param compress A pointer to the int to hold the compression amount.
1076 * @param quality A pointer to the int to hold the quality amount.
1077 * @param lossy A pointer to the int to hold the lossiness flag.
1078 * @return The image pixel data decoded
1080 * This function reads an image from an eet file stored under the named
1081 * key in the eet file and return a pointer to the decompressed pixel data.
1083 * The other parameters of the image (width, height etc.) are placed into
1084 * the values pointed to (they must be supplied). The pixel data is a linear
1085 * array of pixels starting from the top-left of the image scanning row by
1086 * row from left to right. Each pile is a 32bit value, with the high byte
1087 * being the alpha channel, the next being red, then green, and the low byte
1088 * being blue. The width and height are measured in pixels and will be
1089 * greater than 0 when returned. The alpha flag is either 0 or 1. 0 denotes
1090 * that the alpha channel is not used. 1 denotes that it is significant.
1091 * Compress is filled with the compression value/amount the image was
1092 * stored with. The quality value is filled with the quality encoding of
1093 * the image file (0 - 100). The lossy flags is either 0 or 1 as to if
1094 * the image was encoded lossily or not.
1096 * On success the function returns a pointer to the image data decoded. The
1097 * calling application is responsible for calling free() on the image data
1098 * when it is done with it. On failure NULL is returned and the parameter
1099 * values may not contain any sensible data.
1101 * @see eet_data_image_read()
1104 * @ingroup Eet_File_Image_Cipher_Group
1107 eet_data_image_read_cipher(Eet_File *ef,
1109 const char *cipher_key,
1118 * Read image data from the named key in the eet file using a cipher.
1119 * @param ef A valid eet file handle opened for reading.
1120 * @param name Name of the entry. eg: "/base/file_i_want".
1121 * @param cipher_key The key to use as cipher.
1122 * @param src_x The starting x coordinate from where to dump the stream.
1123 * @param src_y The starting y coordinate from where to dump the stream.
1124 * @param d A pointer to the pixel surface.
1125 * @param w The expected width in pixels of the pixel surface to decode.
1126 * @param h The expected height in pixels of the pixel surface to decode.
1127 * @param row_stride The length of a pixels line in the destination surface.
1128 * @param alpha A pointer to the int to hold the alpha flag.
1129 * @param compress A pointer to the int to hold the compression amount.
1130 * @param quality A pointer to the int to hold the quality amount.
1131 * @param lossy A pointer to the int to hold the lossiness flag.
1132 * @return 1 on success, 0 otherwise.
1134 * This function reads an image from an eet file stored under the named
1135 * key in the eet file and return a pointer to the decompressed pixel data.
1137 * The other parameters of the image (width, height etc.) are placed into
1138 * the values pointed to (they must be supplied). The pixel data is a linear
1139 * array of pixels starting from the top-left of the image scanning row by
1140 * row from left to right. Each pile is a 32bit value, with the high byte
1141 * being the alpha channel, the next being red, then green, and the low byte
1142 * being blue. The width and height are measured in pixels and will be
1143 * greater than 0 when returned. The alpha flag is either 0 or 1. 0 denotes
1144 * that the alpha channel is not used. 1 denotes that it is significant.
1145 * Compress is filled with the compression value/amount the image was
1146 * stored with. The quality value is filled with the quality encoding of
1147 * the image file (0 - 100). The lossy flags is either 0 or 1 as to if
1148 * the image was encoded lossily or not.
1150 * On success the function returns 1, and 0 on failure. On failure the
1151 * parameter values may not contain any sensible data.
1153 * @see eet_data_image_read_to_surface()
1156 * @ingroup Eet_File_Image_Cipher_Group
1159 eet_data_image_read_to_surface_cipher(Eet_File *ef,
1161 const char *cipher_key,
1167 unsigned int row_stride,
1174 * Write image data to the named key in an eet file using a cipher.
1175 * @param ef A valid eet file handle opened for writing.
1176 * @param name Name of the entry. eg: "/base/file_i_want".
1177 * @param cipher_key The key to use as cipher.
1178 * @param data A pointer to the image pixel data.
1179 * @param w The width of the image in pixels.
1180 * @param h The height of the image in pixels.
1181 * @param alpha The alpha channel flag.
1182 * @param compress The compression amount.
1183 * @param quality The quality encoding amount.
1184 * @param lossy The lossiness flag.
1185 * @return Success if the data was encoded and written or not.
1187 * This function takes image pixel data and encodes it in an eet file
1188 * stored under the supplied name key, and returns how many bytes were
1189 * actually written to encode the image data.
1191 * The data expected is the same format as returned by eet_data_image_read.
1192 * If this is not the case weird things may happen. Width and height must
1193 * be between 1 and 8000 pixels. The alpha flags can be 0 or 1 (0 meaning
1194 * the alpha values are not useful and 1 meaning they are). Compress can
1195 * be from 0 to 9 (0 meaning no compression, 9 meaning full compression).
1196 * This is only used if the image is not lossily encoded. Quality is used on
1197 * lossy compression and should be a value from 0 to 100. The lossy flag
1198 * can be 0 or 1. 0 means encode losslessly and 1 means to encode with
1199 * image quality loss (but then have a much smaller encoding).
1201 * On success this function returns the number of bytes that were required
1202 * to encode the image data, or on failure it returns 0.
1204 * @see eet_data_image_write()
1207 * @ingroup Eet_File_Image_Cipher_Group
1210 eet_data_image_write_cipher(Eet_File *ef,
1212 const char *cipher_key,
1222 * Decode Image data header only to get information using a cipher.
1223 * @param data The encoded pixel data.
1224 * @param cipher_key The key to use as cipher.
1225 * @param size The size, in bytes, of the encoded pixel data.
1226 * @param w A pointer to the unsigned int to hold the width in pixels.
1227 * @param h A pointer to the unsigned int to hold the height in pixels.
1228 * @param alpha A pointer to the int to hold the alpha flag.
1229 * @param compress A pointer to the int to hold the compression amount.
1230 * @param quality A pointer to the int to hold the quality amount.
1231 * @param lossy A pointer to the int to hold the lossiness flag.
1232 * @return 1 on success, 0 on failure.
1234 * This function takes encoded pixel data and decodes it into raw RGBA
1235 * pixels on success.
1237 * The other parameters of the image (width, height etc.) are placed into
1238 * the values pointed to (they must be supplied). The pixel data is a linear
1239 * array of pixels starting from the top-left of the image scanning row by
1240 * row from left to right. Each pixel is a 32bit value, with the high byte
1241 * being the alpha channel, the next being red, then green, and the low byte
1242 * being blue. The width and height are measured in pixels and will be
1243 * greater than 0 when returned. The alpha flag is either 0 or 1. 0 denotes
1244 * that the alpha channel is not used. 1 denotes that it is significant.
1245 * Compress is filled with the compression value/amount the image was
1246 * stored with. The quality value is filled with the quality encoding of
1247 * the image file (0 - 100). The lossy flags is either 0 or 1 as to if
1248 * the image was encoded lossily or not.
1250 * On success the function returns 1 indicating the header was read and
1251 * decoded properly, or 0 on failure.
1253 * @see eet_data_image_header_decode()
1256 * @ingroup Eet_File_Image_Cipher_Group
1259 eet_data_image_header_decode_cipher(const void *data,
1260 const char *cipher_key,
1270 * Decode Image data into pixel data using a cipher.
1271 * @param data The encoded pixel data.
1272 * @param cipher_key The key to use as cipher.
1273 * @param size The size, in bytes, of the encoded pixel data.
1274 * @param w A pointer to the unsigned int to hold the width in pixels.
1275 * @param h A pointer to the unsigned int to hold the height in pixels.
1276 * @param alpha A pointer to the int to hold the alpha flag.
1277 * @param compress A pointer to the int to hold the compression amount.
1278 * @param quality A pointer to the int to hold the quality amount.
1279 * @param lossy A pointer to the int to hold the lossiness flag.
1280 * @return The image pixel data decoded
1282 * This function takes encoded pixel data and decodes it into raw RGBA
1283 * pixels on success.
1285 * The other parameters of the image (width, height etc.) are placed into
1286 * the values pointed to (they must be supplied). The pixel data is a linear
1287 * array of pixels starting from the top-left of the image scanning row by
1288 * row from left to right. Each pixel is a 32bit value, with the high byte
1289 * being the alpha channel, the next being red, then green, and the low byte
1290 * being blue. The width and height are measured in pixels and will be
1291 * greater than 0 when returned. The alpha flag is either 0 or 1. 0 denotes
1292 * that the alpha channel is not used. 1 denotes that it is significant.
1293 * Compress is filled with the compression value/amount the image was
1294 * stored with. The quality value is filled with the quality encoding of
1295 * the image file (0 - 100). The lossy flags is either 0 or 1 as to if
1296 * the image was encoded lossily or not.
1298 * On success the function returns a pointer to the image data decoded. The
1299 * calling application is responsible for calling free() on the image data
1300 * when it is done with it. On failure NULL is returned and the parameter
1301 * values may not contain any sensible data.
1303 * @see eet_data_image_decode()
1306 * @ingroup Eet_File_Image_Cipher_Group
1309 eet_data_image_decode_cipher(const void *data,
1310 const char *cipher_key,
1320 * Decode Image data into pixel data using a cipher.
1321 * @param data The encoded pixel data.
1322 * @param cipher_key The key to use as cipher.
1323 * @param size The size, in bytes, of the encoded pixel data.
1324 * @param src_x The starting x coordinate from where to dump the stream.
1325 * @param src_y The starting y coordinate from where to dump the stream.
1326 * @param d A pointer to the pixel surface.
1327 * @param w The expected width in pixels of the pixel surface to decode.
1328 * @param h The expected height in pixels of the pixel surface to decode.
1329 * @param row_stride The length of a pixels line in the destination surface.
1330 * @param alpha A pointer to the int to hold the alpha flag.
1331 * @param compress A pointer to the int to hold the compression amount.
1332 * @param quality A pointer to the int to hold the quality amount.
1333 * @param lossy A pointer to the int to hold the lossiness flag.
1334 * @return 1 on success, 0 otherwise.
1336 * This function takes encoded pixel data and decodes it into raw RGBA
1337 * pixels on success.
1339 * The other parameters of the image (alpha, compress etc.) are placed into
1340 * the values pointed to (they must be supplied). The pixel data is a linear
1341 * array of pixels starting from the top-left of the image scanning row by
1342 * row from left to right. Each pixel is a 32bit value, with the high byte
1343 * being the alpha channel, the next being red, then green, and the low byte
1344 * being blue. The width and height are measured in pixels and will be
1345 * greater than 0 when returned. The alpha flag is either 0 or 1. 0 denotes
1346 * that the alpha channel is not used. 1 denotes that it is significant.
1347 * Compress is filled with the compression value/amount the image was
1348 * stored with. The quality value is filled with the quality encoding of
1349 * the image file (0 - 100). The lossy flags is either 0 or 1 as to if
1350 * the image was encoded lossily or not.
1352 * On success the function returns 1, and 0 on failure. On failure the
1353 * parameter values may not contain any sensible data.
1355 * @see eet_data_image_decode_to_surface()
1358 * @ingroup Eet_File_Image_Cipher_Group
1361 eet_data_image_decode_to_surface_cipher(const void *data,
1362 const char *cipher_key,
1369 unsigned int row_stride,
1376 * Encode image data for storage or transmission using a cipher.
1377 * @param data A pointer to the image pixel data.
1378 * @param cipher_key The key to use as cipher.
1379 * @param size_ret A pointer to an int to hold the size of the returned data.
1380 * @param w The width of the image in pixels.
1381 * @param h The height of the image in pixels.
1382 * @param alpha The alpha channel flag.
1383 * @param compress The compression amount.
1384 * @param quality The quality encoding amount.
1385 * @param lossy The lossiness flag.
1386 * @return The encoded image data.
1388 * This function stakes image pixel data and encodes it with compression and
1389 * possible loss of quality (as a trade off for size) for storage or
1390 * transmission to another system.
1392 * The data expected is the same format as returned by eet_data_image_read.
1393 * If this is not the case weird things may happen. Width and height must
1394 * be between 1 and 8000 pixels. The alpha flags can be 0 or 1 (0 meaning
1395 * the alpha values are not useful and 1 meaning they are). Compress can
1396 * be from 0 to 9 (0 meaning no compression, 9 meaning full compression).
1397 * This is only used if the image is not lossily encoded. Quality is used on
1398 * lossy compression and should be a value from 0 to 100. The lossy flag
1399 * can be 0 or 1. 0 means encode losslessly and 1 means to encode with
1400 * image quality loss (but then have a much smaller encoding).
1402 * On success this function returns a pointer to the encoded data that you
1403 * can free with free() when no longer needed.
1405 * @see eet_data_image_encode()
1408 * @ingroup Eet_File_Image_Cipher_Group
1411 eet_data_image_encode_cipher(const void *data,
1412 const char *cipher_key,
1422 * @defgroup Eet_Cipher_Group Cipher, Identity and Protection Mechanisms
1424 * Eet allows one to protect entries of an #Eet_File
1425 * individually. This may be used to ensure data was not tampered or
1426 * that third party does not read your data.
1428 * @see @ref Eet_File_Cipher_Group
1429 * @see @ref Eet_File_Image_Cipher_Group
1436 * Opaque handle that defines an identity (also known as key)
1437 * in Eet's cipher system.
1439 typedef struct _Eet_Key Eet_Key;
1446 * Callback used to request if needed the password of a private key.
1448 * @param buffer the buffer where to store the password.
1449 * @param size the maximum password size (size of buffer, including '@\0').
1450 * @param rwflag if the buffer is also readable or just writable.
1451 * @param data currently unused, may contain some context in future.
1452 * @return 1 on success and password was set to @p buffer, 0 on failure.
1455 * @ingroup Eet_Cipher_Group
1457 typedef int (*Eet_Key_Password_Callback) (char *buffer, int size, int rwflag, void *data);
1460 * Create an Eet_Key needed for signing an eet file.
1462 * The certificate should provide the public that match the private key.
1463 * No verification is done to ensure that.
1465 * @param certificate_file The file where to find the certificate.
1466 * @param private_key_file The file that contains the private key.
1467 * @param cb Function to callback if password is required to unlock
1469 * @return A key handle to use, or @c NULL on failure.
1471 * @see eet_identity_close()
1474 * @ingroup Eet_Cipher_Group
1477 eet_identity_open(const char *certificate_file,
1478 const char *private_key_file,
1479 Eet_Key_Password_Callback cb);
1482 * Close and release all ressource used by an Eet_Key. An
1483 * reference counter prevent it from being freed until all file
1484 * using it are also closed.
1486 * @param key the key handle to close and free resources.
1489 * @ingroup Eet_Cipher_Group
1492 eet_identity_close(Eet_Key *key);
1495 * Set a key to sign a file
1497 * @param ef the file to set the identity.
1498 * @param key the key handle to set as identity.
1499 * @return #EET_ERROR_BAD_OBJECT if @p ef is invalid or
1500 * #EET_ERROR_NONE on success.
1503 * @ingroup Eet_Cipher_Group
1506 eet_identity_set(Eet_File *ef,
1510 * Display both private and public key of an Eet_Key.
1512 * @param key the handle to print.
1513 * @param out where to print.
1516 * @ingroup Eet_Cipher_Group
1519 eet_identity_print(Eet_Key *key,
1523 * Get the x509 der certificate associated with an Eet_File. Will return NULL
1524 * if the file is not signed.
1526 * @param ef The file handle to query.
1527 * @param der_length The length of returned data, may be @c NULL.
1528 * @return the x509 certificate or @c NULL on error.
1531 * @ingroup Eet_Cipher_Group
1534 eet_identity_x509(Eet_File *ef,
1538 * Get the raw signature associated with an Eet_File. Will return NULL
1539 * if the file is not signed.
1541 * @param ef The file handle to query.
1542 * @param signature_length The length of returned data, may be @c NULL.
1543 * @return the raw signature or @c NULL on error.
1545 * @ingroup Eet_Cipher_Group
1548 eet_identity_signature(Eet_File *ef,
1549 int *signature_length);
1552 * Get the SHA1 associated with a file. Could be the one used to
1553 * sign the data or if the data where not signed, it will be the
1556 * @param ef The file handle to query.
1557 * @param sha1_length The length of returned data, may be @c NULL.
1558 * @return the associated SHA1 or @c NULL on error.
1561 * @ingroup Eet_Cipher_Group
1564 eet_identity_sha1(Eet_File *ef,
1568 * Display the x509 der certificate to out.
1570 * @param certificate the x509 certificate to print
1571 * @param der_length The length the certificate.
1572 * @param out where to print.
1575 * @ingroup Eet_Cipher_Group
1578 eet_identity_certificate_print(const unsigned char *certificate,
1583 * @defgroup Eet_Data_Group Eet Data Serialization
1585 * Convenience functions to serialize and parse complex data
1586 * structures to binary blobs.
1588 * While Eet core just handles binary blobs, it is often required
1589 * to save some structured data of different types, such as
1590 * strings, integers, lists, hashes and so on.
1592 * Eet can serialize and then parse data types given some
1593 * construction instructions. These are defined in two levels:
1595 * - #Eet_Data_Descriptor_Class to tell generic memory handling,
1596 * such as the size of the type, how to allocate memory, strings,
1597 * lists, hashes and so on.
1599 * - #Eet_Data_Descriptor to tell inside such type, the members and
1600 * their offsets inside the memory blob, their types and
1601 * names. These members can be simple types or other
1602 * #Eet_Data_Descriptor, allowing hierarchical types to be
1605 * Given that C provides no introspection, this process can be
1606 * quite cumbersome, so we provide lots of macros and convenience
1607 * functions to aid creating the types.
1615 * typedef struct _blah2
1620 * typedef struct _blah3
1625 * typedef struct _blah
1632 * double floating_lots;
1639 * main(int argc, char **argv)
1644 * Eet_Data_Descriptor *edd, *edd2, *edd3;
1645 * Eet_Data_Descriptor_Class eddc, eddc2, eddc3;
1653 * EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eddc3, Blah3);
1654 * edd3 = eet_data_descriptor_stream_new(&eddc3);
1655 * EET_DATA_DESCRIPTOR_ADD_BASIC(edd3, Blah3, "string3", string, EET_T_STRING);
1657 * EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eddc2, Blah2);
1658 * edd2 = eet_data_descriptor_stream_new(&eddc2);
1659 * EET_DATA_DESCRIPTOR_ADD_BASIC(edd2, Blah2, "string2", string, EET_T_STRING);
1661 * EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eddc, Blah);
1662 * edd = eet_data_descriptor_stream_new(&eddc);
1663 * EET_DATA_DESCRIPTOR_ADD_BASIC(edd, Blah, "character", character, EET_T_CHAR);
1664 * EET_DATA_DESCRIPTOR_ADD_BASIC(edd, Blah, "sixteen", sixteen, EET_T_SHORT);
1665 * EET_DATA_DESCRIPTOR_ADD_BASIC(edd, Blah, "integer", integer, EET_T_INT);
1666 * EET_DATA_DESCRIPTOR_ADD_BASIC(edd, Blah, "lots", lots, EET_T_LONG_LONG);
1667 * EET_DATA_DESCRIPTOR_ADD_BASIC(edd, Blah, "floating", floating, EET_T_FLOAT);
1668 * EET_DATA_DESCRIPTOR_ADD_BASIC(edd, Blah, "floating_lots", floating_lots, EET_T_DOUBLE);
1669 * EET_DATA_DESCRIPTOR_ADD_BASIC(edd, Blah, "string", string, EET_T_STRING);
1670 * EET_DATA_DESCRIPTOR_ADD_SUB(edd, Blah, "blah2", blah2, edd2);
1671 * EET_DATA_DESCRIPTOR_ADD_LIST(edd, Blah, "blah3", blah3, edd3);
1673 * blah3.string = "PANTS";
1675 * blah2.string = "subtype string here!";
1677 * blah.character = '7';
1678 * blah.sixteen = 0x7777;
1679 * blah.integer = 0xc0def00d;
1680 * blah.lots = 0xdeadbeef31337777;
1681 * blah.floating = 3.141592654;
1682 * blah.floating_lots = 0.777777777777777;
1683 * blah.string = "bite me like a turnip";
1684 * blah.blah2 = &blah2;
1685 * blah.blah3 = eina_list_append(NULL, &blah3);
1686 * blah.blah3 = eina_list_append(blah.blah3, &blah3);
1687 * blah.blah3 = eina_list_append(blah.blah3, &blah3);
1688 * blah.blah3 = eina_list_append(blah.blah3, &blah3);
1689 * blah.blah3 = eina_list_append(blah.blah3, &blah3);
1690 * blah.blah3 = eina_list_append(blah.blah3, &blah3);
1691 * blah.blah3 = eina_list_append(blah.blah3, &blah3);
1693 * data = eet_data_descriptor_encode(edd, &blah, &size);
1694 * printf("-----DECODING\n");
1695 * blah_in = eet_data_descriptor_decode(edd, data, size);
1697 * printf("-----DECODED!\n");
1698 * printf("%c\n", blah_in->character);
1699 * printf("%x\n", (int)blah_in->sixteen);
1700 * printf("%x\n", blah_in->integer);
1701 * printf("%lx\n", blah_in->lots);
1702 * printf("%f\n", (double)blah_in->floating);
1703 * printf("%f\n", (double)blah_in->floating_lots);
1704 * printf("%s\n", blah_in->string);
1705 * printf("%p\n", blah_in->blah2);
1706 * printf(" %s\n", blah_in->blah2->string);
1711 * EINA_LIST_FOREACH(blah_in->blah3, l, blah3_in)
1713 * printf("%p\n", blah3_in);
1714 * printf(" %s\n", blah3_in->string);
1717 * eet_data_descriptor_free(edd);
1718 * eet_data_descriptor_free(edd2);
1719 * eet_data_descriptor_free(edd3);
1729 #define EET_T_UNKNOW 0 /**< Unknown data encoding type */
1730 #define EET_T_CHAR 1 /**< Data type: char */
1731 #define EET_T_SHORT 2 /**< Data type: short */
1732 #define EET_T_INT 3 /**< Data type: int */
1733 #define EET_T_LONG_LONG 4 /**< Data type: long long */
1734 #define EET_T_FLOAT 5 /**< Data type: float */
1735 #define EET_T_DOUBLE 6 /**< Data type: double */
1736 #define EET_T_UCHAR 7 /**< Data type: unsigned char */
1737 #define EET_T_USHORT 8 /**< Data type: unsigned short */
1738 #define EET_T_UINT 9 /**< Data type: unsigned int */
1739 #define EET_T_ULONG_LONG 10 /**< Data type: unsigned long long */
1740 #define EET_T_STRING 11 /**< Data type: char * */
1741 #define EET_T_INLINED_STRING 12 /**< Data type: char * (but compressed inside the resulting eet) */
1742 #define EET_T_NULL 13 /**< Data type: (void *) (only use it if you know why) */
1743 #define EET_T_F32P32 14 /**< Data type: fixed point 32.32 */
1744 #define EET_T_F16P16 15 /**< Data type: fixed point 16.16 */
1745 #define EET_T_F8P24 16 /**< Data type: fixed point 8.24 */
1746 #define EET_T_LAST 18 /**< Last data type */
1748 #define EET_G_UNKNOWN 100 /**< Unknown group data encoding type */
1749 #define EET_G_ARRAY 101 /**< Fixed size array group type */
1750 #define EET_G_VAR_ARRAY 102 /**< Variable size array group type */
1751 #define EET_G_LIST 103 /**< Linked list group type */
1752 #define EET_G_HASH 104 /**< Hash table group type */
1753 #define EET_G_UNION 105 /**< Union group type */
1754 #define EET_G_VARIANT 106 /**< Selectable subtype group */
1755 #define EET_G_LAST 107 /**< Last group type */
1757 #define EET_I_LIMIT 128 /**< Other type exist but are reserved for internal purpose. */
1760 * @typedef Eet_Data_Descriptor
1762 * Opaque handle that have information on a type members.
1764 * The members are added by means of
1765 * EET_DATA_DESCRIPTOR_ADD_BASIC(), EET_DATA_DESCRIPTOR_ADD_SUB(),
1766 * EET_DATA_DESCRIPTOR_ADD_LIST(), EET_DATA_DESCRIPTOR_ADD_HASH()
1767 * or eet_data_descriptor_element_add().
1769 * @see eet_data_descriptor_stream_new()
1770 * @see eet_data_descriptor_file_new()
1771 * @see eet_data_descriptor_free()
1773 typedef struct _Eet_Data_Descriptor Eet_Data_Descriptor;
1776 * @def EET_DATA_DESCRIPTOR_CLASS_VERSION
1777 * The version of #Eet_Data_Descriptor_Class at the time of the
1778 * distribution of the sources. One should define this to its
1779 * version member so it is compatible with abi changes, or at least
1780 * will not crash with them.
1782 #define EET_DATA_DESCRIPTOR_CLASS_VERSION 4
1785 * @typedef Eet_Data_Descriptor_Class
1787 * Instructs Eet about memory management for different needs under
1788 * serialization and parse process.
1790 typedef struct _Eet_Data_Descriptor_Class Eet_Data_Descriptor_Class;
1793 * @struct _Eet_Data_Descriptor_Class
1795 * Instructs Eet about memory management for different needs under
1796 * serialization and parse process.
1798 * If using Eina data types, it is advised to use the helpers
1799 * EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET() and
1800 * EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET().
1802 struct _Eet_Data_Descriptor_Class
1804 int version; /**< ABI version as #EET_DATA_DESCRIPTOR_CLASS_VERSION */
1805 const char *name; /**< Name of data type to be serialized */
1806 int size; /**< Size in bytes of data type to be serialized */
1809 void *(*mem_alloc)(size_t size); /**< how to allocate memory (usually malloc()) */
1810 void (*mem_free)(void *mem); /**< how to free memory (usually free()) */
1811 char *(*str_alloc)(const char *str); /**< how to allocate a string */
1812 void (*str_free)(const char *str); /**< how to free a string */
1813 void *(*list_next)(void *l); /**< how to iterate to the next element of a list. Receives and should return the list node. */
1814 void *(*list_append)(void *l, void *d); /**< how to append data @p d to list which head node is @p l */
1815 void *(*list_data)(void *l); /**< retrieves the data from node @p l */
1816 void *(*list_free)(void *l); /**< free all the nodes from the list which head node is @p l */
1817 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 */
1818 void *(*hash_add)(void *h, const char *k, void *d); /**< add a new data @p d as key @p k in hash @p h */
1819 void (*hash_free)(void *h); /**< free all entries from the hash @p h */
1820 char *(*str_direct_alloc)(const char *str); /**< how to allocate a string directly from file backed/mmaped region pointed by @p str */
1821 void (*str_direct_free)(const char *str); /**< how to free a string returned by str_direct_alloc */
1822 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. */
1823 Eina_Bool (*type_set)(const char *type, void *data, Eina_Bool unknow); /**< set the type at a particular adress */
1824 void *(*array_alloc)(size_t size); /**< how to allocate memory for array (usually malloc()) */
1825 void (*array_free)(void *mem); /**< how to free memory for array (usually free()) */
1834 * Create a new empty data structure descriptor.
1835 * @param name The string name of this data structure (most be a
1836 * global constant and never change).
1837 * @param size The size of the struct (in bytes).
1838 * @param func_list_next The function to get the next list node.
1839 * @param func_list_append The function to append a member to a list.
1840 * @param func_list_data The function to get the data from a list node.
1841 * @param func_list_free The function to free an entire linked list.
1842 * @param func_hash_foreach The function to iterate through all
1843 * hash table entries.
1844 * @param func_hash_add The function to add a member to a hash table.
1845 * @param func_hash_free The function to free an entire hash table.
1846 * @return A new empty data descriptor.
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.
1852 * You add structure members to the data descriptor using the macros
1853 * EET_DATA_DESCRIPTOR_ADD_BASIC(), EET_DATA_DESCRIPTOR_ADD_SUB() and
1854 * EET_DATA_DESCRIPTOR_ADD_LIST(), depending on what type of member you are
1855 * adding to the description.
1857 * Once you have described all the members of a struct you want loaded, or
1858 * saved eet can load and save those members for you, encode them into
1859 * endian-independant serialised data chunks for transmission across a
1860 * a network or more.
1862 * The function pointers to the list and hash table functions are only
1863 * needed if you use those data types, else you can pass NULL instead.
1866 * @ingroup Eet_Data_Group
1868 * @deprecated use eet_data_descriptor_stream_new() or
1869 * eet_data_descriptor_file_new()
1871 EINA_DEPRECATED EAPI Eet_Data_Descriptor *
1872 eet_data_descriptor_new(const char *name,
1874 void *(*func_list_next)(void *l),
1875 void *(*func_list_append)(void *l, void *d),
1876 void *(*func_list_data)(void *l),
1877 void *(*func_list_free)(void *l),
1878 void (*func_hash_foreach)(void *h, int (*func)(void *h,
1881 void *fdt), void *fdt),
1882 void *(*func_hash_add)(void *h, const char *k, void *d),
1883 void (*func_hash_free)(void *h));
1887 * moving to this api from the old above. this will break things when the
1888 * move happens - but be warned
1890 EINA_DEPRECATED EAPI Eet_Data_Descriptor *
1891 eet_data_descriptor2_new(const Eet_Data_Descriptor_Class *eddc);
1892 EINA_DEPRECATED EAPI Eet_Data_Descriptor *
1893 eet_data_descriptor3_new(const Eet_Data_Descriptor_Class *eddc);
1896 * This function creates a new data descriptore and returns a handle to the
1897 * new data descriptor. On creation it will be empty, containing no contents
1898 * describing anything other than the shell of the data structure.
1899 * @param eddc The data descriptor to free.
1901 * You add structure members to the data descriptor using the macros
1902 * EET_DATA_DESCRIPTOR_ADD_BASIC(), EET_DATA_DESCRIPTOR_ADD_SUB() and
1903 * EET_DATA_DESCRIPTOR_ADD_LIST(), depending on what type of member you are
1904 * adding to the description.
1906 * Once you have described all the members of a struct you want loaded, or
1907 * saved eet can load and save those members for you, encode them into
1908 * endian-independant serialised data chunks for transmission across a
1909 * a network or more.
1911 * This function specially ignore str_direct_alloc and str_direct_free. It
1912 * is usefull when the eet_data you are reading don't have a dictionnary
1913 * like network stream or ipc. It also mean that all string will be allocated
1914 * and duplicated in memory.
1917 * @ingroup Eet_Data_Group
1919 EAPI Eet_Data_Descriptor *
1920 eet_data_descriptor_stream_new(const Eet_Data_Descriptor_Class *eddc);
1923 * This function creates a new data descriptore and returns a handle to the
1924 * new data descriptor. On creation it will be empty, containing no contents
1925 * describing anything other than the shell of the data structure.
1926 * @param eddc The data descriptor to free.
1928 * You add structure members to the data descriptor using the macros
1929 * EET_DATA_DESCRIPTOR_ADD_BASIC(), EET_DATA_DESCRIPTOR_ADD_SUB() and
1930 * EET_DATA_DESCRIPTOR_ADD_LIST(), depending on what type of member you are
1931 * adding to the description.
1933 * Once you have described all the members of a struct you want loaded, or
1934 * saved eet can load and save those members for you, encode them into
1935 * endian-independant serialised data chunks for transmission across a
1936 * a network or more.
1938 * This function use str_direct_alloc and str_direct_free. It is
1939 * usefull when the eet_data you are reading come from a file and
1940 * have a dictionnary. This will reduce memory use, improve the
1941 * possibility for the OS to page this string out. But be carrefull
1942 * all EET_T_STRING are pointer to a mmapped area and it will point
1943 * to nowhere if you close the file. So as long as you use this
1944 * strings, you need to have the Eet_File open.
1947 * @ingroup Eet_Data_Group
1949 EAPI Eet_Data_Descriptor *
1950 eet_data_descriptor_file_new(const Eet_Data_Descriptor_Class *eddc);
1953 * This function is an helper that set all the parameter of an
1954 * Eet_Data_Descriptor_Class correctly when you use Eina data type
1956 * @param eddc The Eet_Data_Descriptor_Class you want to set.
1957 * @param name The name of the structure described by this class.
1958 * @param size The size of the structure described by this class.
1959 * @return EINA_TRUE if the structure was correctly set (The only
1960 * reason that could make it fail is if you did give wrong
1964 * @ingroup Eet_Data_Group
1967 eet_eina_stream_data_descriptor_class_set(Eet_Data_Descriptor_Class *eddc,
1968 unsigned int eddc_size,
1973 * This macro is an helper that set all the parameter of an
1974 * Eet_Data_Descriptor_Class correctly when you use Eina data type
1976 * @param Clas The Eet_Data_Descriptor_Class you want to set.
1977 * @param Type The type of the structure described by this class.
1978 * @return EINA_TRUE if the structure was correctly set (The only
1979 * reason that could make it fail is if you did give wrong
1983 * @ingroup Eet_Data_Group
1985 #define EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(clas, type)\
1986 (eet_eina_stream_data_descriptor_class_set(clas, sizeof (*(clas)), # type, sizeof(type)))
1989 * This function is an helper that set all the parameter of an
1990 * Eet_Data_Descriptor_Class correctly when you use Eina data type
1992 * @param eddc The Eet_Data_Descriptor_Class you want to set.
1993 * @param name The name of the structure described by this class.
1994 * @param size The size of the structure described by this class.
1995 * @return EINA_TRUE if the structure was correctly set (The only
1996 * reason that could make it fail is if you did give wrong
2000 * @ingroup Eet_Data_Group
2003 eet_eina_file_data_descriptor_class_set(Eet_Data_Descriptor_Class *eddc,
2004 unsigned int eddc_size,
2009 * This macro is an helper that set all the parameter of an
2010 * Eet_Data_Descriptor_Class correctly when you use Eina data type
2012 * @param Clas The Eet_Data_Descriptor_Class you want to set.
2013 * @param Type The type of the structure described by this class.
2014 * @return EINA_TRUE if the structure was correctly set (The only
2015 * reason that could make it fail is if you did give wrong
2019 * @ingroup Eet_Data_Group
2021 #define EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(clas, type)\
2022 (eet_eina_file_data_descriptor_class_set(clas, sizeof (*(clas)), # type, sizeof(type)))
2025 * This function frees a data descriptor when it is not needed anymore.
2026 * @param edd The data descriptor to free.
2028 * This function takes a data descriptor handle as a parameter and frees all
2029 * data allocated for the data descriptor and the handle itself. After this
2030 * call the descriptor is no longer valid.
2033 * @ingroup Eet_Data_Group
2036 eet_data_descriptor_free(Eet_Data_Descriptor *edd);
2039 * This function is an internal used by macros.
2041 * This function is used by macros EET_DATA_DESCRIPTOR_ADD_BASIC(),
2042 * EET_DATA_DESCRIPTOR_ADD_SUB() and EET_DATA_DESCRIPTOR_ADD_LIST(). It is
2043 * complex to use by hand and should be left to be used by the macros, and
2044 * thus is not documented.
2046 * @param edd The data descriptor handle to add element (member).
2047 * @param name The name of element to be serialized.
2048 * @param type The type of element to be serialized, like
2049 * #EET_T_INT. If #EET_T_UNKNOW, then it is considered to be a
2050 * group, list or hash.
2051 * @param group_type If element type is #EET_T_UNKNOW, then the @p
2052 * group_type will speficy if it is a list (#EET_G_LIST),
2053 * array (#EET_G_ARRAY) and so on. If #EET_G_UNKNOWN, then
2054 * the member is a subtype (pointer to another type defined by
2055 * another #Eet_Data_Descriptor).
2056 * @param offset byte offset inside the source memory to be serialized.
2057 * @param count number of elements (if #EET_G_ARRAY or #EET_G_VAR_ARRAY).
2058 * @param counter_name variable that defines the name of number of elements.
2059 * @param subtype If contains a subtype, then its data descriptor.
2062 * @ingroup Eet_Data_Group
2065 eet_data_descriptor_element_add(Eet_Data_Descriptor *edd,
2070 /* int count_offset, */
2072 const char *counter_name,
2073 Eet_Data_Descriptor *subtype);
2076 * Read a data structure from an eet file and decodes it.
2077 * @param ef The eet file handle to read from.
2078 * @param edd The data descriptor handle to use when decoding.
2079 * @param name The key the data is stored under in the eet file.
2080 * @return A pointer to the decoded data structure.
2082 * This function decodes a data structure stored in an eet file, returning
2083 * a pointer to it if it decoded successfully, or NULL on failure. This
2084 * can save a programmer dozens of hours of work in writing configuration
2085 * file parsing and writing code, as eet does all that work for the program
2086 * and presents a program-friendly data structure, just as the programmer
2087 * likes. Eet can handle members being added or deleted from the data in
2088 * storage and safely zero-fills unfilled members if they were not found
2089 * in the data. It checks sizes and headers whenever it reads data, allowing
2090 * the programmer to not worry about corrupt data.
2092 * Once a data structure has been described by the programmer with the
2093 * fields they wish to save or load, storing or retrieving a data structure
2094 * from an eet file, or from a chunk of memory is as simple as a single
2097 * @see eet_data_read_cipher()
2100 * @ingroup Eet_Data_Group
2103 eet_data_read(Eet_File *ef,
2104 Eet_Data_Descriptor *edd,
2108 * Write a data structure from memory and store in an eet file.
2109 * @param ef The eet file handle to write to.
2110 * @param edd The data descriptor to use when encoding.
2111 * @param name The key to store the data under in the eet file.
2112 * @param data A pointer to the data structure to ssave and encode.
2113 * @param compress Compression flags for storage.
2114 * @return bytes written on successful write, 0 on failure.
2116 * This function is the reverse of eet_data_read(), saving a data structure
2119 * @see eet_data_write_cipher()
2122 * @ingroup Eet_Data_Group
2125 eet_data_write(Eet_File *ef,
2126 Eet_Data_Descriptor *edd,
2132 * Dump an eet encoded data structure into ascii text
2133 * @param data_in The pointer to the data to decode into a struct.
2134 * @param size_in The size of the data pointed to in bytes.
2135 * @param dumpfunc The function to call passed a string when new
2136 * data is converted to text
2137 * @param dumpdata The data to pass to the @p dumpfunc callback.
2138 * @return 1 on success, 0 on failure
2140 * This function will take a chunk of data encoded by
2141 * eet_data_descriptor_encode() and convert it into human readable
2142 * ascii text. It does this by calling the @p dumpfunc callback
2143 * for all new text that is generated. This callback should append
2144 * to any existing text buffer and will be passed the pointer @p
2145 * dumpdata as a parameter as well as a string with new text to be
2151 * void output(void *data, const char *string)
2153 * printf("%s", string);
2156 * void dump(const char *file)
2162 * f = fopen(file, "r");
2163 * fseek(f, 0, SEEK_END);
2166 * data = malloc(len);
2167 * fread(data, len, 1, f);
2169 * eet_data_text_dump(data, len, output, NULL);
2173 * @see eet_data_text_dump_cipher()
2176 * @ingroup Eet_Data_Group
2179 eet_data_text_dump(const void *data_in,
2181 void (*dumpfunc)(void *data, const char *str),
2185 * Take an ascii encoding from eet_data_text_dump() and re-encode in binary.
2186 * @param text The pointer to the string data to parse and encode.
2187 * @param textlen The size of the string in bytes (not including 0
2189 * @param size_ret This gets filled in with the encoded data blob
2191 * @return The encoded data on success, NULL on failure.
2193 * This function will parse the string pointed to by @p text and return
2194 * an encoded data lump the same way eet_data_descriptor_encode() takes an
2195 * in-memory data struct and encodes into a binary blob. @p text is a normal
2198 * @see eet_data_text_undump_cipher()
2201 * @ingroup Eet_Data_Group
2204 eet_data_text_undump(const char *text,
2209 * Dump an eet encoded data structure from an eet file into ascii text
2210 * @param ef A valid eet file handle.
2211 * @param name Name of the entry. eg: "/base/file_i_want".
2212 * @param dumpfunc The function to call passed a string when new
2213 * data is converted to text
2214 * @param dumpdata The data to pass to the @p dumpfunc callback.
2215 * @return 1 on success, 0 on failure
2217 * This function will take an open and valid eet file from
2218 * eet_open() request the data encoded by
2219 * eet_data_descriptor_encode() corresponding to the key @p name
2220 * and convert it into human readable ascii text. It does this by
2221 * calling the @p dumpfunc callback for all new text that is
2222 * generated. This callback should append to any existing text
2223 * buffer and will be passed the pointer @p dumpdata as a parameter
2224 * as well as a string with new text to be appended.
2226 * @see eet_data_dump_cipher()
2229 * @ingroup Eet_Data_Group
2232 eet_data_dump(Eet_File *ef,
2234 void (*dumpfunc)(void *data, const char *str),
2238 * Take an ascii encoding from eet_data_dump() and re-encode in binary.
2239 * @param ef A valid eet file handle.
2240 * @param name Name of the entry. eg: "/base/file_i_want".
2241 * @param text The pointer to the string data to parse and encode.
2242 * @param textlen The size of the string in bytes (not including 0
2244 * @param compress Compression flags (1 == compress, 0 = don't compress).
2245 * @return 1 on success, 0 on failure
2247 * This function will parse the string pointed to by @p text,
2248 * encode it the same way eet_data_descriptor_encode() takes an
2249 * in-memory data struct and encodes into a binary blob.
2251 * The data (optionally compressed) will be in ram, pending a flush to
2252 * disk (it will stay in ram till the eet file handle is closed though).
2254 * @see eet_data_undump_cipher()
2257 * @ingroup Eet_Data_Group
2260 eet_data_undump(Eet_File *ef,
2267 * Decode a data structure from an arbitary location in memory.
2268 * @param edd The data descriptor to use when decoding.
2269 * @param data_in The pointer to the data to decode into a struct.
2270 * @param size_in The size of the data pointed to in bytes.
2271 * @return NULL on failure, or a valid decoded struct pointer on success.
2273 * This function will decode a data structure that has been encoded using
2274 * eet_data_descriptor_encode(), and return a data structure with all its
2275 * elements filled out, if successful, or NULL on failure.
2277 * The data to be decoded is stored at the memory pointed to by @p data_in,
2278 * and is described by the descriptor pointed to by @p edd. The data size is
2279 * passed in as the value to @p size_in, ande must be greater than 0 to
2282 * This function is useful for decoding data structures delivered to the
2283 * application by means other than an eet file, such as an IPC or socket
2284 * connection, raw files, shared memory etc.
2286 * Please see eet_data_read() for more information.
2288 * @see eet_data_descriptor_decode_cipher()
2291 * @ingroup Eet_Data_Group
2294 eet_data_descriptor_decode(Eet_Data_Descriptor *edd,
2295 const void *data_in,
2299 * Encode a dsata struct to memory and return that encoded data.
2300 * @param edd The data descriptor to use when encoding.
2301 * @param data_in The pointer to the struct to encode into data.
2302 * @param size_ret pointer to the an int to be filled with the decoded size.
2303 * @return NULL on failure, or a valid encoded data chunk on success.
2305 * This function takes a data structutre in memory and encodes it into a
2306 * serialised chunk of data that can be decoded again by
2307 * eet_data_descriptor_decode(). This is useful for being able to transmit
2308 * data structures across sockets, pipes, IPC or shared file mechanisms,
2309 * without having to worry about memory space, machine type, endianess etc.
2311 * The parameter @p edd must point to a valid data descriptor, and
2312 * @p data_in must point to the right data structure to encode. If not, the
2313 * encoding may fail.
2315 * On success a non NULL valid pointer is returned and what @p size_ret
2316 * points to is set to the size of this decoded data, in bytes. When the
2317 * encoded data is no longer needed, call free() on it. On failure NULL is
2318 * returned and what @p size_ret points to is set to 0.
2320 * Please see eet_data_write() for more information.
2322 * @see eet_data_descriptor_encode_cipher()
2325 * @ingroup Eet_Data_Group
2328 eet_data_descriptor_encode(Eet_Data_Descriptor *edd,
2329 const void *data_in,
2333 * Add a basic data element to a data descriptor.
2334 * @param edd The data descriptor to add the type to.
2335 * @param struct_type The type of the struct.
2336 * @param name The string name to use to encode/decode this member
2337 * (must be a constant global and never change).
2338 * @param member The struct member itself to be encoded.
2339 * @param type The type of the member to encode.
2341 * This macro is a convenience macro provided to add a member to
2342 * the data descriptor @p edd. The type of the structure is
2343 * provided as the @p struct_type parameter (for example: struct
2344 * my_struct). The @p name parameter defines a string that will be
2345 * used to uniquely name that member of the struct (it is suggested
2346 * to use the struct member itself). The @p member parameter is
2347 * the actual struct member itself (for eet_dictionary_string_check
2348 * example: values), and @p type is the basic data type of the
2349 * member which must be one of: EET_T_CHAR, EET_T_SHORT, EET_T_INT,
2350 * EET_T_LONG_LONG, EET_T_FLOAT, EET_T_DOUBLE, EET_T_UCHAR,
2351 * EET_T_USHORT, EET_T_UINT, EET_T_ULONG_LONG or EET_T_STRING.
2354 * @ingroup Eet_Data_Group
2356 #define EET_DATA_DESCRIPTOR_ADD_BASIC(edd, struct_type, name, member, type) \
2358 struct_type ___ett; \
2359 eet_data_descriptor_element_add(edd, name, type, EET_G_UNKNOWN, \
2360 (char *)(& (___ett.member)) - \
2361 (char *)(& (___ett)), \
2362 0, /* 0, */ NULL, NULL); \
2366 * Add a sub-element type to a data descriptor
2367 * @param edd The data descriptor to add the type to.
2368 * @param struct_type The type of the struct.
2369 * @param name The string name to use to encode/decode this member
2370 * (must be a constant global and never change).
2371 * @param member The struct member itself to be encoded.
2372 * @param subtype The type of sub-type struct to add.
2374 * This macro lets you easily add a sub-type (a struct that's pointed to
2375 * by this one). All the parameters are the same as for
2376 * EET_DATA_DESCRIPTOR_ADD_BASIC(), with the @p subtype being the exception.
2377 * This must be the data descriptor of the struct that is pointed to by
2381 * @ingroup Eet_Data_Group
2383 #define EET_DATA_DESCRIPTOR_ADD_SUB(edd, struct_type, name, member, subtype) \
2385 struct_type ___ett; \
2386 eet_data_descriptor_element_add(edd, name, EET_T_UNKNOW, EET_G_UNKNOWN, \
2387 (char *)(& (___ett.member)) - \
2388 (char *)(& (___ett)), \
2389 0, /* 0, */ NULL, subtype); \
2393 * Add a linked list type to a data descriptor
2394 * @param edd The data descriptor to add the type to.
2395 * @param struct_type The type of the struct.
2396 * @param name The string name to use to encode/decode this member
2397 * (must be a constant global and never change).
2398 * @param member The struct member itself to be encoded.
2399 * @param subtype The type of linked list member to add.
2401 * This macro lets you easily add a linked list of other data types. All the
2402 * parameters are the same as for EET_DATA_DESCRIPTOR_ADD_BASIC(), with the
2403 * @p subtype being the exception. This must be the data descriptor of the
2404 * element that is in each member of the linked list to be stored.
2407 * @ingroup Eet_Data_Group
2409 #define EET_DATA_DESCRIPTOR_ADD_LIST(edd, struct_type, name, member, subtype) \
2411 struct_type ___ett; \
2412 eet_data_descriptor_element_add(edd, name, EET_T_UNKNOW, EET_G_LIST, \
2413 (char *)(& (___ett.member)) - \
2414 (char *)(& (___ett)), \
2415 0, /* 0, */ NULL, subtype); \
2419 * Add a hash type to a data descriptor
2420 * @param edd The data descriptor to add the type to.
2421 * @param struct_type The type of the struct.
2422 * @param name The string name to use to encode/decode this member
2423 * (must be a constant global and never change).
2424 * @param member The struct member itself to be encoded.
2425 * @param subtype The type of hash member to add.
2427 * This macro lets you easily add a hash of other data types. All the
2428 * parameters are the same as for EET_DATA_DESCRIPTOR_ADD_BASIC(), with the
2429 * @p subtype being the exception. This must be the data descriptor of the
2430 * element that is in each member of the hash to be stored.
2433 * @ingroup Eet_Data_Group
2435 #define EET_DATA_DESCRIPTOR_ADD_HASH(edd, struct_type, name, member, subtype) \
2437 struct_type ___ett; \
2438 eet_data_descriptor_element_add(edd, name, EET_T_UNKNOW, EET_G_HASH, \
2439 (char *)(& (___ett.member)) - \
2440 (char *)(& (___ett)), \
2441 0, /* 0, */ NULL, subtype); \
2445 * Add a hash of string to a data descriptor
2446 * @param edd The data descriptor to add the type to.
2447 * @param struct_type The type of the struct.
2448 * @param name The string name to use to encode/decode this member
2449 * (must be a constant global and never change).
2450 * @param member The struct member itself to be encoded.
2452 * This macro lets you easily add a hash of string. All the
2453 * parameters are the same as for EET_DATA_DESCRIPTOR_ADD_BASIC().
2456 * @ingroup Eet_Data_Group
2458 #define EET_DATA_DESCRIPTOR_ADD_HASH_STRING(edd, struct_type, name, member) \
2460 struct_type ___ett; \
2461 eet_data_descriptor_element_add(edd, name, EET_T_STRING, EET_G_HASH, \
2462 (char *)(& (___ett.member)) - \
2463 (char *)(& (___ett)), \
2464 0, /* 0, */ NULL, NULL); \
2468 * Add a fixed size array type to a data descriptor
2469 * @param edd The data descriptor to add the type to.
2470 * @param struct_type The type of the struct.
2471 * @param name The string name to use to encode/decode this member
2472 * (must be a constant global and never change).
2473 * @param member The struct member itself to be encoded.
2474 * @param subtype The type of hash member to add.
2476 * This macro lets you easily add a fixed size array of other data
2477 * types. All the parameters are the same as for
2478 * EET_DATA_DESCRIPTOR_ADD_BASIC(), with the @p subtype being the
2479 * exception. This must be the data descriptor of the element that
2480 * is in each member of the hash to be stored.
2483 * @ingroup Eet_Data_Group
2485 #define EET_DATA_DESCRIPTOR_ADD_ARRAY(edd, struct_type, name, member, subtype) \
2487 struct_type ___ett; \
2488 eet_data_descriptor_element_add(edd, name, EET_T_UNKNOW, EET_G_ARRAY, \
2489 (char *)(& (___ett.member)) - \
2490 (char *)(& (___ett)), \
2491 /* 0, */ sizeof(___ett.member) / \
2492 sizeof(___ett.member[0]), NULL, subtype); \
2496 * Add a variable size array type to a data descriptor
2497 * @param edd The data descriptor to add the type to.
2498 * @param struct_type The type of the struct.
2499 * @param name The string name to use to encode/decode this member
2500 * (must be a constant global and never change).
2501 * @param member The struct member itself to be encoded.
2502 * @param subtype The type of hash member to add.
2504 * This macro lets you easily add a fixed size array of other data
2505 * types. All the parameters are the same as for
2506 * EET_DATA_DESCRIPTOR_ADD_BASIC(), with the @p subtype being the
2507 * exception. This must be the data descriptor of the element that
2508 * is in each member of the hash to be stored.
2511 * @ingroup Eet_Data_Group
2513 #define EET_DATA_DESCRIPTOR_ADD_VAR_ARRAY(edd, struct_type, name, member, subtype) \
2515 struct_type ___ett; \
2516 eet_data_descriptor_element_add(edd, \
2520 (char *)(& (___ett.member)) - \
2521 (char *)(& (___ett)), \
2522 (char *)(& (___ett.member ## _count)) - \
2523 (char *)(& (___ett)), \
2529 * Add an union type to a data descriptor
2530 * @param edd The data descriptor to add the type to.
2531 * @param struct_type The type of the struct.
2532 * @param name The string name to use to encode/decode this member
2533 * (must be a constant global and never change).
2534 * @param member The struct member itself to be encoded.
2535 * @param type_member The member that give hints on what is in the union.
2536 * @param unified_type Describe all possible type the union could handle.
2538 * This macro lets you easily add an union with a member that specify what is inside.
2539 * The @p unified_type is an Eet_Data_Descriptor, but only the entry that match the name
2540 * returned by type_get will be used for each serialized data. The type_get and type_set
2541 * callback of unified_type should be defined.
2544 * @ingroup Eet_Data_Group
2545 * @see Eet_Data_Descriptor_Class
2547 #define EET_DATA_DESCRIPTOR_ADD_UNION(edd, struct_type, name, member, type_member, unified_type) \
2549 struct_type ___ett; \
2550 eet_data_descriptor_element_add(edd, name, EET_T_UNKNOW, EET_G_UNION, \
2551 (char *)(& (___ett.member)) - \
2552 (char *)(& (___ett)), \
2553 (char *)(& (___ett.type_member)) - \
2554 (char *)(& (___ett)), \
2555 NULL, unified_type); \
2559 * Add a automatically selectable type to a data descriptor
2560 * @param edd The data descriptor to add the type to.
2561 * @param struct_type The type of the struct.
2562 * @param name The string name to use to encode/decode this member
2563 * (must be a constant global and never change).
2564 * @param member The struct member itself to be encoded.
2565 * @param type_member The member that give hints on what is in the union.
2566 * @param unified_type Describe all possible type the union could handle.
2568 * This macro lets you easily define what the content of @p member points to depending of
2569 * the content of @p type_member. The type_get and type_set callback of unified_type should
2570 * be defined. If the the type is not know at the time of restoring it, eet will still call
2571 * type_set of @p unified_type but the pointer will be set to a serialized binary representation
2572 * of what eet know. This make it possible, to save this pointer again by just returning the string
2573 * given previously and telling it by setting unknow to EINA_TRUE.
2576 * @ingroup Eet_Data_Group
2577 * @see Eet_Data_Descriptor_Class
2579 #define EET_DATA_DESCRIPTOR_ADD_VARIANT(edd, struct_type, name, member, type_member, unified_type) \
2581 struct_type ___ett; \
2582 eet_data_descriptor_element_add(edd, name, EET_T_UNKNOW, EET_G_VARIANT, \
2583 (char *)(& (___ett.member)) - \
2584 (char *)(& (___ett)), \
2585 (char *)(& (___ett.type_member)) - \
2586 (char *)(& (___ett)), \
2587 NULL, unified_type); \
2591 * Add a mapping to a data descriptor that will be used by union, variant or inherited type
2592 * @param unified_type The data descriptor to add the mapping to.
2593 * @param name The string name to get/set type.
2594 * @param subtype The matching data descriptor.
2597 * @ingroup Eet_Data_Group
2598 * @see Eet_Data_Descriptor_Class
2600 #define EET_DATA_DESCRIPTOR_ADD_MAPPING(unified_type, name, subtype) \
2601 eet_data_descriptor_element_add(unified_type, \
2611 * @defgroup Eet_Data_Cipher_Group Eet Data Serialization using A Ciphers
2613 * Most of the @ref Eet_Data_Group have alternative versions that
2614 * accounts for ciphers to protect their content.
2616 * @see @ref Eet_Cipher_Group
2618 * @ingroup Eet_Data_Group
2622 * Read a data structure from an eet file and decodes it using a cipher.
2623 * @param ef The eet file handle to read from.
2624 * @param edd The data descriptor handle to use when decoding.
2625 * @param name The key the data is stored under in the eet file.
2626 * @param cipher_key The key to use as cipher.
2627 * @return A pointer to the decoded data structure.
2629 * This function decodes a data structure stored in an eet file, returning
2630 * a pointer to it if it decoded successfully, or NULL on failure. This
2631 * can save a programmer dozens of hours of work in writing configuration
2632 * file parsing and writing code, as eet does all that work for the program
2633 * and presents a program-friendly data structure, just as the programmer
2634 * likes. Eet can handle members being added or deleted from the data in
2635 * storage and safely zero-fills unfilled members if they were not found
2636 * in the data. It checks sizes and headers whenever it reads data, allowing
2637 * the programmer to not worry about corrupt data.
2639 * Once a data structure has been described by the programmer with the
2640 * fields they wish to save or load, storing or retrieving a data structure
2641 * from an eet file, or from a chunk of memory is as simple as a single
2644 * @see eet_data_read()
2647 * @ingroup Eet_Data_Cipher_Group
2650 eet_data_read_cipher(Eet_File *ef,
2651 Eet_Data_Descriptor *edd,
2653 const char *cipher_key);
2656 * Write a data structure from memory and store in an eet file
2658 * @param ef The eet file handle to write to.
2659 * @param edd The data descriptor to use when encoding.
2660 * @param name The key to store the data under in the eet file.
2661 * @param cipher_key The key to use as cipher.
2662 * @param data A pointer to the data structure to ssave and encode.
2663 * @param compress Compression flags for storage.
2664 * @return bytes written on successful write, 0 on failure.
2666 * This function is the reverse of eet_data_read(), saving a data structure
2669 * @see eet_data_write_cipher()
2672 * @ingroup Eet_Data_Cipher_Group
2675 eet_data_write_cipher(Eet_File *ef,
2676 Eet_Data_Descriptor *edd,
2678 const char *cipher_key,
2683 * Dump an eet encoded data structure into ascii text using a cipher.
2684 * @param data_in The pointer to the data to decode into a struct.
2685 * @param cipher_key The key to use as cipher.
2686 * @param size_in The size of the data pointed to in bytes.
2687 * @param dumpfunc The function to call passed a string when new
2688 * data is converted to text
2689 * @param dumpdata The data to pass to the @p dumpfunc callback.
2690 * @return 1 on success, 0 on failure
2692 * This function will take a chunk of data encoded by
2693 * eet_data_descriptor_encode() and convert it into human readable
2694 * ascii text. It does this by calling the @p dumpfunc callback
2695 * for all new text that is generated. This callback should append
2696 * to any existing text buffer and will be passed the pointer @p
2697 * dumpdata as a parameter as well as a string with new text to be
2703 * void output(void *data, const char *string)
2705 * printf("%s", string);
2708 * void dump(const char *file)
2714 * f = fopen(file, "r");
2715 * fseek(f, 0, SEEK_END);
2718 * data = malloc(len);
2719 * fread(data, len, 1, f);
2721 * eet_data_text_dump_cipher(data, cipher_key, len, output, NULL);
2725 * @see eet_data_text_dump()
2728 * @ingroup Eet_Data_Cipher_Group
2731 eet_data_text_dump_cipher(const void *data_in,
2732 const char *cipher_key,
2734 void (*dumpfunc)(void *data, const char *str),
2738 * Take an ascii encoding from eet_data_text_dump() and re-encode
2739 * in binary using a cipher.
2740 * @param text The pointer to the string data to parse and encode.
2741 * @param cipher_key The key to use as cipher.
2742 * @param textlen The size of the string in bytes (not including 0
2744 * @param size_ret This gets filled in with the encoded data blob
2746 * @return The encoded data on success, NULL on failure.
2748 * This function will parse the string pointed to by @p text and return
2749 * an encoded data lump the same way eet_data_descriptor_encode() takes an
2750 * in-memory data struct and encodes into a binary blob. @p text is a normal
2753 * @see eet_data_text_undump()
2756 * @ingroup Eet_Data_Cipher_Group
2759 eet_data_text_undump_cipher(const char *text,
2760 const char *cipher_key,
2765 * Dump an eet encoded data structure from an eet file into ascii
2766 * text using a cipher.
2767 * @param ef A valid eet file handle.
2768 * @param name Name of the entry. eg: "/base/file_i_want".
2769 * @param cipher_key The key to use as cipher.
2770 * @param dumpfunc The function to call passed a string when new
2771 * data is converted to text
2772 * @param dumpdata The data to pass to the @p dumpfunc callback.
2773 * @return 1 on success, 0 on failure
2775 * This function will take an open and valid eet file from
2776 * eet_open() request the data encoded by
2777 * eet_data_descriptor_encode() corresponding to the key @p name
2778 * and convert it into human readable ascii text. It does this by
2779 * calling the @p dumpfunc callback for all new text that is
2780 * generated. This callback should append to any existing text
2781 * buffer and will be passed the pointer @p dumpdata as a parameter
2782 * as well as a string with new text to be appended.
2784 * @see eet_data_dump()
2787 * @ingroup Eet_Data_Cipher_Group
2790 eet_data_dump_cipher(Eet_File *ef,
2792 const char *cipher_key,
2793 void (*dumpfunc)(void *data, const char *str),
2797 * Take an ascii encoding from eet_data_dump() and re-encode in
2798 * binary using a cipher.
2799 * @param ef A valid eet file handle.
2800 * @param name Name of the entry. eg: "/base/file_i_want".
2801 * @param cipher_key The key to use as cipher.
2802 * @param text The pointer to the string data to parse and encode.
2803 * @param textlen The size of the string in bytes (not including 0
2805 * @param compress Compression flags (1 == compress, 0 = don't compress).
2806 * @return 1 on success, 0 on failure
2808 * This function will parse the string pointed to by @p text,
2809 * encode it the same way eet_data_descriptor_encode() takes an
2810 * in-memory data struct and encodes into a binary blob.
2812 * The data (optionally compressed) will be in ram, pending a flush to
2813 * disk (it will stay in ram till the eet file handle is closed though).
2815 * @see eet_data_undump()
2818 * @ingroup Eet_Data_Cipher_Group
2821 eet_data_undump_cipher(Eet_File *ef,
2823 const char *cipher_key,
2829 * Decode a data structure from an arbitary location in memory
2831 * @param edd The data descriptor to use when decoding.
2832 * @param data_in The pointer to the data to decode into a struct.
2833 * @param cipher_key The key to use as cipher.
2834 * @param size_in The size of the data pointed to in bytes.
2835 * @return NULL on failure, or a valid decoded struct pointer on success.
2837 * This function will decode a data structure that has been encoded using
2838 * eet_data_descriptor_encode(), and return a data structure with all its
2839 * elements filled out, if successful, or NULL on failure.
2841 * The data to be decoded is stored at the memory pointed to by @p data_in,
2842 * and is described by the descriptor pointed to by @p edd. The data size is
2843 * passed in as the value to @p size_in, ande must be greater than 0 to
2846 * This function is useful for decoding data structures delivered to the
2847 * application by means other than an eet file, such as an IPC or socket
2848 * connection, raw files, shared memory etc.
2850 * Please see eet_data_read() for more information.
2852 * @see eet_data_descriptor_decode()
2855 * @ingroup Eet_Data_Cipher_Group
2858 eet_data_descriptor_decode_cipher(Eet_Data_Descriptor *edd,
2859 const void *data_in,
2860 const char *cipher_key,
2864 * Encode a data struct to memory and return that encoded data
2866 * @param edd The data descriptor to use when encoding.
2867 * @param data_in The pointer to the struct to encode into data.
2868 * @param cipher_key The key to use as cipher.
2869 * @param size_ret pointer to the an int to be filled with the decoded size.
2870 * @return NULL on failure, or a valid encoded data chunk on success.
2872 * This function takes a data structutre in memory and encodes it into a
2873 * serialised chunk of data that can be decoded again by
2874 * eet_data_descriptor_decode(). This is useful for being able to transmit
2875 * data structures across sockets, pipes, IPC or shared file mechanisms,
2876 * without having to worry about memory space, machine type, endianess etc.
2878 * The parameter @p edd must point to a valid data descriptor, and
2879 * @p data_in must point to the right data structure to encode. If not, the
2880 * encoding may fail.
2882 * On success a non NULL valid pointer is returned and what @p size_ret
2883 * points to is set to the size of this decoded data, in bytes. When the
2884 * encoded data is no longer needed, call free() on it. On failure NULL is
2885 * returned and what @p size_ret points to is set to 0.
2887 * Please see eet_data_write() for more information.
2889 * @see eet_data_descriptor_encode()
2892 * @ingroup Eet_Data_Cipher_Group
2895 eet_data_descriptor_encode_cipher(Eet_Data_Descriptor *edd,
2896 const void *data_in,
2897 const char *cipher_key,
2901 * @defgroup Eet_Node_Group Low-level Serialization Structures.
2903 * Functions that create, destroy and manipulate serialization nodes
2904 * used by @ref Eet_Data_Group.
2911 * Opaque handle to manage serialization node.
2913 typedef struct _Eet_Node Eet_Node;
2916 * @typedef Eet_Node_Data
2917 * Contains an union that can fit any kind of node.
2919 typedef struct _Eet_Node_Data Eet_Node_Data;
2922 * @struct _Eet_Node_Data
2923 * Contains an union that can fit any kind of node.
2925 struct _Eet_Node_Data
2937 unsigned long long ul;
2948 * @ingroup Eet_Node_Group
2951 eet_node_char_new(const char *name,
2956 * @ingroup Eet_Node_Group
2959 eet_node_short_new(const char *name,
2964 * @ingroup Eet_Node_Group
2967 eet_node_int_new(const char *name,
2972 * @ingroup Eet_Node_Group
2975 eet_node_long_long_new(const char *name,
2980 * @ingroup Eet_Node_Group
2983 eet_node_float_new(const char *name,
2988 * @ingroup Eet_Node_Group
2991 eet_node_double_new(const char *name,
2996 * @ingroup Eet_Node_Group
2999 eet_node_unsigned_char_new(const char *name,
3004 * @ingroup Eet_Node_Group
3007 eet_node_unsigned_short_new(const char *name,
3012 * @ingroup Eet_Node_Group
3015 eet_node_unsigned_int_new(const char *name,
3020 * @ingroup Eet_Node_Group
3023 eet_node_unsigned_long_long_new(const char *name,
3024 unsigned long long l);
3028 * @ingroup Eet_Node_Group
3031 eet_node_string_new(const char *name,
3036 * @ingroup Eet_Node_Group
3039 eet_node_inlined_string_new(const char *name,
3044 * @ingroup Eet_Node_Group
3047 eet_node_null_new(const char *name);
3051 * @ingroup Eet_Node_Group
3054 eet_node_list_new(const char *name,
3059 * @ingroup Eet_Node_Group
3062 eet_node_array_new(const char *name,
3068 * @ingroup Eet_Node_Group
3071 eet_node_var_array_new(const char *name,
3076 * @ingroup Eet_Node_Group
3079 eet_node_hash_new(const char *name,
3085 * @ingroup Eet_Node_Group
3088 eet_node_struct_new(const char *name,
3093 * @ingroup Eet_Node_Group
3096 eet_node_struct_child_new(const char *parent,
3101 * @ingroup Eet_Node_Group
3104 eet_node_list_append(Eet_Node *parent,
3110 * @ingroup Eet_Node_Group
3113 eet_node_struct_append(Eet_Node *parent,
3119 * @ingroup Eet_Node_Group
3122 eet_node_hash_add(Eet_Node *parent,
3129 * @ingroup Eet_Node_Group
3132 eet_node_dump(Eet_Node *n,
3134 void (*dumpfunc)(void *data, const char *str),
3139 * @ingroup Eet_Node_Group
3142 eet_node_del(Eet_Node *n);
3146 * @ingroup Eet_Node_Group
3149 eet_data_node_encode_cipher(Eet_Node *node,
3150 const char *cipher_key,
3155 * @ingroup Eet_Node_Group
3158 eet_data_node_decode_cipher(const void *data_in,
3159 const char *cipher_key,
3164 * @ingroup Eet_Node_Group
3167 eet_data_node_read_cipher(Eet_File *ef,
3169 const char *cipher_key);
3173 * @ingroup Eet_Node_Group
3176 eet_data_node_write_cipher(Eet_File *ef,
3178 const char *cipher_key,
3182 /* EXPERIMENTAL: THIS API MAY CHANGE IN THE FUTURE, USE IT ONLY IF YOU KNOW WHAT YOU ARE DOING. */
3185 * @typedef Eet_Node_Walk
3186 * Describes how to walk trees of #Eet_Node.
3188 typedef struct _Eet_Node_Walk Eet_Node_Walk;
3191 * @struct _Eet_Node_Walk
3192 * Describes how to walk trees of #Eet_Node.
3194 struct _Eet_Node_Walk
3196 void *(*struct_alloc) (const char *type, void *user_data);
3197 void (*struct_add) (void *parent, const char *name, void *child, void *user_data);
3198 void *(*array) (Eina_Bool variable, const char *name, int count, void *user_data);
3199 void (*insert) (void *array, int index, void *child, void *user_data);
3200 void *(*list) (const char *name, void *user_data);
3201 void (*append) (void *list, void *child, void *user_data);
3202 void *(*hash) (void *parent, const char *name, const char *key, void *value, void *user_data);
3203 void *(*simple) (int type, Eet_Node_Data *data, void *user_data);
3207 eet_node_walk(void *parent,
3216 * @defgroup Eet_Connection_Group Helper function to use eet over a network link
3218 * Function that reconstruct and prepare packet of @ref Eet_Data_Group to be send.
3223 * @typedef Eet_Connection
3224 * Opaque handle to track paquet for a specific connection.
3226 * @ingroup Eet_Connection_Group
3228 typedef struct _Eet_Connection Eet_Connection;
3231 * @typedef Eet_Read_Cb
3232 * Called back when an @ref Eet_Data_Group has been received completly and could be used.
3234 * @ingroup Eet_Connection_Group
3236 typedef Eina_Bool Eet_Read_Cb (const void *eet_data, size_t size, void *user_data);
3239 * @typedef Eet_Write_Cb
3240 * Called back when a packet containing @ref Eet_Data_Group data is ready to be send.
3242 * @ingroup Eet_Connection_Group
3244 typedef Eina_Bool Eet_Write_Cb (const void *data, size_t size, void *user_data);
3247 * Instanciate a new connection to track.
3248 * @oaram eet_read_cb Function to call when one Eet_Data packet has been fully assemble.
3249 * @param eet_write_cb Function to call when one Eet_Data packet is ready to be send over the wire.
3250 * @param user_data Pointer provided to both functions to be used as a context handler.
3251 * @return NULL on failure, or a valid Eet_Connection handler.
3253 * For every connection to track you will need a separate Eet_Connection provider.
3256 * @ingroup Eet_Connection_Group
3258 EAPI Eet_Connection *
3259 eet_connection_new(Eet_Read_Cb *eet_read_cb,
3260 Eet_Write_Cb *eet_write_cb,
3261 const void *user_data);
3264 * Process a raw packet received over the link
3265 * @oaram conn Connection handler to track.
3266 * @param data Raw data packet.
3267 * @param size The size of that packet.
3268 * @return 0 on complete success, any other value indicate where in the stream it got wrong (It could be before that packet).
3270 * Every time you receive a packet related to your connection, you should pass
3271 * it to that function so that it could process and assemble packet has you
3272 * receive it. It will automatically call Eet_Read_Cb when one is fully received.
3275 * @ingroup Eet_Connection_Group
3278 eet_connection_received(Eet_Connection *conn,
3283 * Convert a complex structure and prepare it to be send.
3284 * @oaram conn Connection handler to track.
3285 * @param edd The data descriptor to use when encoding.
3286 * @param data_in The pointer to the struct to encode into data.
3287 * @param cipher_key The key to use as cipher.
3288 * @return EINA_TRUE if the data where correctly send, EINA_FALSE if they don't.
3290 * This function serialize data_in with edd, assemble the packet and call
3291 * Eet_Write_Cb when ready. The data passed Eet_Write_Cb are temporary allocated
3292 * and will vanish just after the return of the callback.
3294 * @see eet_data_descriptor_encode_cipher
3297 * @ingroup Eet_Connection_Group
3300 eet_connection_send(Eet_Connection *conn,
3301 Eet_Data_Descriptor *edd,
3302 const void *data_in,
3303 const char *cipher_key);
3306 * Convert a Eet_Node tree and prepare it to be send.
3307 * @oaram conn Connection handler to track.
3308 * @param node The data tree to use when encoding.
3309 * @param cipher_key The key to use as cipher.
3310 * @return EINA_TRUE if the data where correctly send, EINA_FALSE if they don't.
3312 * This function serialize node, assemble the packet and call
3313 * Eet_Write_Cb when ready. The data passed Eet_Write_Cb are temporary allocated
3314 * and will vanish just after the return of the callback.
3316 * @see eet_data_node_encode_cipher
3319 * @ingroup Eet_Connection_Group
3322 eet_connection_node_send(Eet_Connection *conn,
3324 const char *cipher_key);
3327 * Close a connection and lost its track.
3328 * @oaram conn Connection handler to close.
3329 * @param on_going Signal if a partial packet wasn't completed.
3330 * @return the user_data passed to both callback.
3333 * @ingroup Eet_Connection_Group
3336 eet_connection_close(Eet_Connection *conn,
3337 Eina_Bool *on_going);
3339 /***************************************************************************/
3343 #endif /* ifdef __cplusplus */
3345 #endif /* ifndef _EET_H */