15 # define EAPI __declspec(dllexport)
18 # endif /* ! DLL_EXPORT */
20 # define EAPI __declspec(dllimport)
21 # endif /* ! EFL_EET_BUILD */
25 # define EAPI __attribute__ ((visibility("default")))
40 * @brief The file that provides the eet functions.
42 * This header provides the Eet management functions.
47 * @defgroup Eet_Group Top level functions
48 * Functions that affect Eet as a whole.
55 * All the error identifiers known by Eet.
57 typedef enum _Eet_Error
59 EET_ERROR_NONE, /**< No error, it's all fine! */
60 EET_ERROR_BAD_OBJECT, /**< Given object or handle is NULL or invalid */
61 EET_ERROR_EMPTY, /**< There was nothing to do */
62 EET_ERROR_NOT_WRITABLE, /**< Could not write to file or fine is #EET_FILE_MODE_READ */
63 EET_ERROR_OUT_OF_MEMORY, /**< Could not allocate memory */
64 EET_ERROR_WRITE_ERROR, /**< Failed to write data to destination */
65 EET_ERROR_WRITE_ERROR_FILE_TOO_BIG, /**< Failed to write file since it is too big */
66 EET_ERROR_WRITE_ERROR_IO_ERROR, /**< Failed to write since generic Input/Output error */
67 EET_ERROR_WRITE_ERROR_OUT_OF_SPACE, /**< Failed to write due out of space */
68 EET_ERROR_WRITE_ERROR_FILE_CLOSED, /**< Failed to write because file was closed */
69 EET_ERROR_MMAP_FAILED, /**< Could not mmap file */
70 EET_ERROR_X509_ENCODING_FAILED, /**< Could not encode using X509 */
71 EET_ERROR_SIGNATURE_FAILED, /**< Could not validate signature */
72 EET_ERROR_INVALID_SIGNATURE, /**< Signature is invalid */
73 EET_ERROR_NOT_SIGNED, /**< File or contents are not signed */
74 EET_ERROR_NOT_IMPLEMENTED, /**< Function is not implemented */
75 EET_ERROR_PRNG_NOT_SEEDED, /**< Could not introduce random seed */
76 EET_ERROR_ENCRYPT_FAILED, /**< Could not encrypt contents */
77 EET_ERROR_DECRYPT_FAILED /**< Could not decrypt contents */
78 } Eet_Error; /**< Eet error identifiers */
85 * Initialize the EET library.
87 * @return The new init count.
92 EAPI int eet_init(void);
95 * Shut down the EET library.
97 * @return The new init count.
102 EAPI int eet_shutdown(void);
107 * Eet didn't free items by default. If you are under memory
108 * presure, just call this function to recall all memory that are
109 * not yet referenced anymore. The cache take care of modification
115 EAPI void eet_clearcache(void);
119 * @defgroup Eet_File_Group Eet File Main Functions
121 * Functions to create, destroy and do basic manipulation of
128 * @enum _Eet_File_Mode
129 * Modes that a file can be opened.
131 typedef enum _Eet_File_Mode
133 EET_FILE_MODE_INVALID = -1,
134 EET_FILE_MODE_READ, /**< File is read-only. */
135 EET_FILE_MODE_WRITE, /**< File is write-only. */
136 EET_FILE_MODE_READ_WRITE /**< File is for both read and write */
137 } Eet_File_Mode; /**< Modes that a file can be opened. */
141 * Opaque handle that defines an Eet file (or memory).
144 * @see eet_memopen_read()
147 typedef struct _Eet_File Eet_File;
150 * @typedef Eet_Dictionary
151 * Opaque handle that defines a file-backed (mmaped) dictionary of strings.
153 typedef struct _Eet_Dictionary Eet_Dictionary;
161 * Open an eet file on disk, and returns a handle to it.
162 * @param file The file path to the eet file. eg: @c "/tmp/file.eet".
163 * @param mode The mode for opening. Either #EET_FILE_MODE_READ,
164 * #EET_FILE_MODE_WRITE or #EET_FILE_MODE_READ_WRITE.
165 * @return An opened eet file handle.
166 * @ingroup Eet_File_Group
168 * This function will open an exiting eet file for reading, and build
169 * the directory table in memory and return a handle to the file, if it
170 * exists and can be read, and no memory errors occur on the way, otherwise
171 * NULL will be returned.
173 * It will also open an eet file for writing. This will, if successful,
174 * delete the original file and replace it with a new empty file, till
175 * the eet file handle is closed or flushed. If it cannot be opened for
176 * writing or a memory error occurs, NULL is returned.
178 * You can also open the file for read/write. If you then write a key that
179 * does not exist it will be created, if the key exists it will be replaced
186 * #include <string.h>
189 * main(int argc, char **argv)
192 * char buf[1024], *ret, **list;
197 * strcpy(buf, "Here is a string of data to save!");
199 * ef = eet_open("/tmp/my_file.eet", EET_FILE_MODE_WRITE);
200 * if (!ef) return -1;
201 * if (!eet_write(ef, "/key/to_store/at", buf, 1024, 1))
202 * fprintf(stderr, "Error writing data!\n");
205 * ef = eet_open("/tmp/my_file.eet", EET_FILE_MODE_READ);
206 * if (!ef) return -1;
207 * list = eet_list(ef, "*", &num);
210 * for (i = 0; i < num; i++)
211 * printf("Key stored: %s\n", list[i]);
214 * ret = eet_read(ef, "/key/to_store/at", &size);
217 * printf("Data read (%i bytes):\n%s\n", size, ret);
230 EAPI Eet_File *eet_open(const char *file, Eet_File_Mode mode);
233 * Open an eet file directly from a memory location. The data are not copied,
234 * so you must keep them around as long as the eet file is open. Their is
235 * currently no cache for this kind of Eet_File, so it's reopen every time
236 * you do use eet_memopen_read.
239 * @ingroup Eet_File_Group
241 EAPI Eet_File *eet_memopen_read(const void *data, size_t size);
244 * Get the mode an Eet_File was opened with.
245 * @param ef A valid eet file handle.
246 * @return The mode ef was opened with.
249 * @ingroup Eet_File_Group
251 EAPI Eet_File_Mode eet_mode_get(Eet_File *ef);
254 * Close an eet file handle and flush and writes pending.
255 * @param ef A valid eet file handle.
257 * This function will flush any pending writes to disk if the eet file
258 * was opened for write, and free all data associated with the file handle
259 * and file, and close the file.
261 * If the eet file handle is not valid nothing will be done.
264 * @ingroup Eet_File_Group
266 EAPI Eet_Error eet_close(Eet_File *ef);
269 * Sync content of an eet file handle, flushing pending writes.
270 * @param ef A valid eet file handle.
272 * This function will flush any pending writes to disk. The eet file must
273 * be opened for write.
275 * If the eet file handle is not valid nothing will be done.
278 * @ingroup Eet_File_Group
280 EAPI Eet_Error eet_sync(Eet_File *ef);
283 * Return a handle to the shared string dictionary of the Eet file
284 * @param ef A valid eet file handle.
285 * @return A handle to the dictionary of the file
287 * This function returns a handle to the dictionary of an Eet file whose
288 * handle is @p ef, if a dictionary exists. NULL is returned otherwise or
289 * if the file handle is known to be invalid.
291 * @see eet_dictionary_string_check() to know if given string came
292 * from the dictionary or it was dynamically allocated using
293 * the #Eet_Data_Descriptor_Class instructrions.
296 * @ingroup Eet_File_Group
298 EAPI Eet_Dictionary *eet_dictionary_get(Eet_File *ef);
301 * Check if a given string comes from a given dictionary
302 * @param ed A valid dictionary handle
303 * @param string A valid 0 byte terminated C string
304 * @return 1 if it is in the dictionary, 0 otherwise
306 * This checks the given dictionary to see if the given string is actually
307 * inside that dictionary (i.e. comes from it) and returns 1 if it does.
308 * If the dictionary handle is invlide, the string is NULL or the string is
309 * not in the dictionary, 0 is returned.
312 * @ingroup Eet_File_Group
314 EAPI int eet_dictionary_string_check(Eet_Dictionary *ed, const char *string);
317 * Read a specified entry from an eet file and return data
318 * @param ef A valid eet file handle opened for reading.
319 * @param name Name of the entry. eg: "/base/file_i_want".
320 * @param size_ret Number of bytes read from entry and returned.
321 * @return The data stored in that entry in the eet file.
323 * This function finds an entry in the eet file that is stored under the
324 * name specified, and returns that data, decompressed, if successful.
325 * NULL is returned if the lookup fails or if memory errors are
326 * encountered. It is the job of the calling program to call free() on
327 * the returned data. The number of bytes in the returned data chunk are
328 * placed in size_ret.
330 * If the eet file handle is not valid NULL is returned and size_ret is
333 * @see eet_read_cipher()
336 * @ingroup Eet_File_Group
338 EAPI void *eet_read(Eet_File *ef, const char *name, int *size_ret);
341 * Read a specified entry from an eet file and return data
342 * @param ef A valid eet file handle opened for reading.
343 * @param name Name of the entry. eg: "/base/file_i_want".
344 * @param size_ret Number of bytes read from entry and returned.
345 * @return The data stored in that entry in the eet file.
347 * This function finds an entry in the eet file that is stored under the
348 * name specified, and returns that data if not compressed and successful.
349 * NULL is returned if the lookup fails or if memory errors are
350 * encountered or if the data is comrpessed. The calling program must never
351 * call free() on the returned data. The number of bytes in the returned
352 * data chunk are placed in size_ret.
354 * If the eet file handle is not valid NULL is returned and size_ret is
358 * @ingroup Eet_File_Group
360 EAPI const void *eet_read_direct(Eet_File *ef, const char *name, int *size_ret);
363 * Write a specified entry to an eet file handle
364 * @param ef A valid eet file handle opened for writing.
365 * @param name Name of the entry. eg: "/base/file_i_want".
366 * @param data Pointer to the data to be stored.
367 * @param size Length in bytes in the data to be stored.
368 * @param compress Compression flags (1 == compress, 0 = don't compress).
369 * @return bytes written on successful write, 0 on failure.
371 * This function will write the specified chunk of data to the eet file
372 * and return greater than 0 on success. 0 will be returned on failure.
374 * The eet file handle must be a valid file handle for an eet file opened
375 * for writing. If it is not, 0 will be returned and no action will be
378 * Name, and data must not be NULL, and size must be > 0. If these
379 * conditions are not met, 0 will be returned.
381 * The data will be copied (and optionally compressed) in ram, pending
382 * a flush to disk (it will stay in ram till the eet file handle is
385 * @see eet_write_cipher()
388 * @ingroup Eet_File_Group
390 EAPI int eet_write(Eet_File *ef, const char *name, const void *data, int size, int compress);
393 * Delete a specified entry from an Eet file being written or re-written
394 * @param ef A valid eet file handle opened for writing.
395 * @param name Name of the entry. eg: "/base/file_i_want".
396 * @return Success or failure of the delete.
398 * This function will delete the specified chunk of data from the eet file
399 * and return greater than 0 on success. 0 will be returned on failure.
401 * The eet file handle must be a valid file handle for an eet file opened
402 * for writing. If it is not, 0 will be returned and no action will be
405 * Name, must not be NULL, otherwise 0 will be returned.
408 * @ingroup Eet_File_Group
410 EAPI int eet_delete(Eet_File *ef, const char *name);
413 * List all entries in eet file matching shell glob.
414 * @param ef A valid eet file handle.
415 * @param glob A shell glob to match against.
416 * @param count_ret Number of entries found to match.
417 * @return Pointer to an array of strings.
419 * This function will list all entries in the eet file matching the
420 * supplied shell glob and return an allocated list of their names, if
421 * there are any, and if no memory errors occur.
423 * The eet file handle must be valid and glob must not be NULL, or NULL
424 * will be returned and count_ret will be filled with 0.
426 * The calling program must call free() on the array returned, but NOT
427 * on the string pointers in the array. They are taken as read-only
428 * internals from the eet file handle. They are only valid as long as
429 * the file handle is not closed. When it is closed those pointers in the
430 * array are now not valid and should not be used.
432 * On success the array returned will have a list of string pointers
433 * that are the names of the entries that matched, and count_ret will have
434 * the number of entries in this array placed in it.
436 * Hint: an easy way to list all entries in an eet file is to use a glob
440 * @ingroup Eet_File_Group
442 EAPI char **eet_list(Eet_File *ef, const char *glob, int *count_ret);
445 * Return the number of entries in the specified eet file.
446 * @param ef A valid eet file handle.
447 * @return Number of entries in ef or -1 if the number of entries
448 * cannot be read due to open mode restrictions.
451 * @ingroup Eet_File_Group
453 EAPI int eet_num_entries(Eet_File *ef);
456 * @defgroup Eet_File_Cipher_Group Eet File Ciphered Main Functions
458 * Most of the @ref Eet_File_Group have alternative versions that
459 * accounts for ciphers to protect their content.
461 * @see @ref Eet_Cipher_Group
463 * @ingroup Eet_File_Group
467 * Read a specified entry from an eet file and return data using a cipher.
468 * @param ef A valid eet file handle opened for reading.
469 * @param name Name of the entry. eg: "/base/file_i_want".
470 * @param size_ret Number of bytes read from entry and returned.
471 * @param cipher_key The key to use as cipher.
472 * @return The data stored in that entry in the eet file.
474 * This function finds an entry in the eet file that is stored under the
475 * name specified, and returns that data, decompressed, if successful.
476 * NULL is returned if the lookup fails or if memory errors are
477 * encountered. It is the job of the calling program to call free() on
478 * the returned data. The number of bytes in the returned data chunk are
479 * placed in size_ret.
481 * If the eet file handle is not valid NULL is returned and size_ret is
487 * @ingroup Eet_File_Cipher_Group
489 EAPI void *eet_read_cipher(Eet_File *ef, const char *name, int *size_ret, const char *cipher_key);
492 * Write a specified entry to an eet file handle using a cipher.
493 * @param ef A valid eet file handle opened for writing.
494 * @param name Name of the entry. eg: "/base/file_i_want".
495 * @param data Pointer to the data to be stored.
496 * @param size Length in bytes in the data to be stored.
497 * @param compress Compression flags (1 == compress, 0 = don't compress).
498 * @param cipher_key The key to use as cipher.
499 * @return bytes written on successful write, 0 on failure.
501 * This function will write the specified chunk of data to the eet file
502 * and return greater than 0 on success. 0 will be returned on failure.
504 * The eet file handle must be a valid file handle for an eet file opened
505 * for writing. If it is not, 0 will be returned and no action will be
508 * Name, and data must not be NULL, and size must be > 0. If these
509 * conditions are not met, 0 will be returned.
511 * The data will be copied (and optionally compressed) in ram, pending
512 * a flush to disk (it will stay in ram till the eet file handle is
518 * @ingroup Eet_File_Cipher_Group
520 EAPI int eet_write_cipher(Eet_File *ef, const char *name, const void *data, int size, int compress, const char *cipher_key);
524 * @defgroup Eet_File_Image_Group Image Store and Load
526 * Eet efficiently stores and loads images, including alpha
527 * channels and lossy compressions.
531 * Read just the header data for an image and dont decode the pixels.
532 * @param ef A valid eet file handle opened for reading.
533 * @param name Name of the entry. eg: "/base/file_i_want".
534 * @param w A pointer to the unsigned int to hold the width in pixels.
535 * @param h A pointer to the unsigned int to hold the height in pixels.
536 * @param alpha A pointer to the int to hold the alpha flag.
537 * @param compress A pointer to the int to hold the compression amount.
538 * @param quality A pointer to the int to hold the quality amount.
539 * @param lossy A pointer to the int to hold the lossiness flag.
540 * @return 1 on successfull decode, 0 otherwise
542 * This function reads an image from an eet file stored under the named
543 * key in the eet file and return a pointer to the decompressed pixel data.
545 * The other parameters of the image (width, height etc.) are placed into
546 * the values pointed to (they must be supplied). The pixel data is a linear
547 * array of pixels starting from the top-left of the image scanning row by
548 * row from left to right. Each pile is a 32bit value, with the high byte
549 * being the alpha channel, the next being red, then green, and the low byte
550 * being blue. The width and height are measured in pixels and will be
551 * greater than 0 when returned. The alpha flag is either 0 or 1. 0 denotes
552 * that the alpha channel is not used. 1 denotes that it is significant.
553 * Compress is filled with the compression value/amount the image was
554 * stored with. The quality value is filled with the quality encoding of
555 * the image file (0 - 100). The lossy flags is either 0 or 1 as to if
556 * the image was encoded lossily or not.
558 * On success the function returns 1 indicating the header was read and
559 * decoded properly, or 0 on failure.
561 * @see eet_data_image_header_read_cipher()
564 * @ingroup Eet_File_Image_Group
566 EAPI int eet_data_image_header_read(Eet_File *ef, const char *name, unsigned int *w, unsigned int *h, int *alpha, int *compress, int *quality, int *lossy);
569 * Read image data from the named key in the eet file.
570 * @param ef A valid eet file handle opened for reading.
571 * @param name Name of the entry. eg: "/base/file_i_want".
572 * @param w A pointer to the unsigned int to hold the width in pixels.
573 * @param h A pointer to the unsigned int to hold the height in pixels.
574 * @param alpha A pointer to the int to hold the alpha flag.
575 * @param compress A pointer to the int to hold the compression amount.
576 * @param quality A pointer to the int to hold the quality amount.
577 * @param lossy A pointer to the int to hold the lossiness flag.
578 * @return The image pixel data decoded
580 * This function reads an image from an eet file stored under the named
581 * key in the eet file and return a pointer to the decompressed pixel data.
583 * The other parameters of the image (width, height etc.) are placed into
584 * the values pointed to (they must be supplied). The pixel data is a linear
585 * array of pixels starting from the top-left of the image scanning row by
586 * row from left to right. Each pile is a 32bit value, with the high byte
587 * being the alpha channel, the next being red, then green, and the low byte
588 * being blue. The width and height are measured in pixels and will be
589 * greater than 0 when returned. The alpha flag is either 0 or 1. 0 denotes
590 * that the alpha channel is not used. 1 denotes that it is significant.
591 * Compress is filled with the compression value/amount the image was
592 * stored with. The quality value is filled with the quality encoding of
593 * the image file (0 - 100). The lossy flags is either 0 or 1 as to if
594 * the image was encoded lossily or not.
596 * On success the function returns a pointer to the image data decoded. The
597 * calling application is responsible for calling free() on the image data
598 * when it is done with it. On failure NULL is returned and the parameter
599 * values may not contain any sensible data.
601 * @see eet_data_image_read_cipher()
604 * @ingroup Eet_File_Image_Group
606 EAPI void *eet_data_image_read(Eet_File *ef, const char *name, unsigned int *w, unsigned int *h, int *alpha, int *compress, int *quality, int *lossy);
609 * Read image data from the named key in the eet file.
610 * @param ef A valid eet file handle opened for reading.
611 * @param name Name of the entry. eg: "/base/file_i_want".
612 * @param src_x The starting x coordinate from where to dump the stream.
613 * @param src_y The starting y coordinate from where to dump the stream.
614 * @param d A pointer to the pixel surface.
615 * @param w The expected width in pixels of the pixel surface to decode.
616 * @param h The expected height in pixels of the pixel surface to decode.
617 * @param row_stride The length of a pixels line in the destination surface.
618 * @param alpha A pointer to the int to hold the alpha flag.
619 * @param compress A pointer to the int to hold the compression amount.
620 * @param quality A pointer to the int to hold the quality amount.
621 * @param lossy A pointer to the int to hold the lossiness flag.
622 * @return 1 on success, 0 otherwise.
624 * This function reads an image from an eet file stored under the named
625 * key in the eet file and return a pointer to the decompressed pixel data.
627 * The other parameters of the image (width, height etc.) are placed into
628 * the values pointed to (they must be supplied). The pixel data is a linear
629 * array of pixels starting from the top-left of the image scanning row by
630 * row from left to right. Each pile is a 32bit value, with the high byte
631 * being the alpha channel, the next being red, then green, and the low byte
632 * being blue. The width and height are measured in pixels and will be
633 * greater than 0 when returned. The alpha flag is either 0 or 1. 0 denotes
634 * that the alpha channel is not used. 1 denotes that it is significant.
635 * Compress is filled with the compression value/amount the image was
636 * stored with. The quality value is filled with the quality encoding of
637 * the image file (0 - 100). The lossy flags is either 0 or 1 as to if
638 * the image was encoded lossily or not.
640 * On success the function returns 1, and 0 on failure. On failure the
641 * parameter values may not contain any sensible data.
643 * @see eet_data_image_read_to_surface_cipher()
646 * @ingroup Eet_File_Image_Group
648 EAPI int eet_data_image_read_to_surface(Eet_File *ef, const char *name, unsigned int src_x, unsigned int src_y, unsigned int *d, unsigned int w, unsigned int h, unsigned int row_stride, int *alpha, int *compress, int *quality, int *lossy);
651 * Write image data to the named key in an eet file.
652 * @param ef A valid eet file handle opened for writing.
653 * @param name Name of the entry. eg: "/base/file_i_want".
654 * @param data A pointer to the image pixel data.
655 * @param w The width of the image in pixels.
656 * @param h The height of the image in pixels.
657 * @param alpha The alpha channel flag.
658 * @param compress The compression amount.
659 * @param quality The quality encoding amount.
660 * @param lossy The lossiness flag.
661 * @return Success if the data was encoded and written or not.
663 * This function takes image pixel data and encodes it in an eet file
664 * stored under the supplied name key, and returns how many bytes were
665 * actually written to encode the image data.
667 * The data expected is the same format as returned by eet_data_image_read.
668 * If this is not the case weird things may happen. Width and height must
669 * be between 1 and 8000 pixels. The alpha flags can be 0 or 1 (0 meaning
670 * the alpha values are not useful and 1 meaning they are). Compress can
671 * be from 0 to 9 (0 meaning no compression, 9 meaning full compression).
672 * This is only used if the image is not lossily encoded. Quality is used on
673 * lossy compression and should be a value from 0 to 100. The lossy flag
674 * can be 0 or 1. 0 means encode losslessly and 1 means to encode with
675 * image quality loss (but then have a much smaller encoding).
677 * On success this function returns the number of bytes that were required
678 * to encode the image data, or on failure it returns 0.
680 * @see eet_data_image_write_cipher()
683 * @ingroup Eet_File_Image_Group
685 EAPI int eet_data_image_write(Eet_File *ef, const char *name, const void *data, unsigned int w, unsigned int h, int alpha, int compress, int quality, int lossy);
688 * Decode Image data header only to get information.
689 * @param data The encoded pixel data.
690 * @param size The size, in bytes, of the encoded pixel data.
691 * @param w A pointer to the unsigned int to hold the width in pixels.
692 * @param h A pointer to the unsigned int to hold the height in pixels.
693 * @param alpha A pointer to the int to hold the alpha flag.
694 * @param compress A pointer to the int to hold the compression amount.
695 * @param quality A pointer to the int to hold the quality amount.
696 * @param lossy A pointer to the int to hold the lossiness flag.
697 * @return 1 on success, 0 on failure.
699 * This function takes encoded pixel data and decodes it into raw RGBA
702 * The other parameters of the image (width, height etc.) are placed into
703 * the values pointed to (they must be supplied). The pixel data is a linear
704 * array of pixels starting from the top-left of the image scanning row by
705 * row from left to right. Each pixel is a 32bit value, with the high byte
706 * being the alpha channel, the next being red, then green, and the low byte
707 * being blue. The width and height are measured in pixels and will be
708 * greater than 0 when returned. The alpha flag is either 0 or 1. 0 denotes
709 * that the alpha channel is not used. 1 denotes that it is significant.
710 * Compress is filled with the compression value/amount the image was
711 * stored with. The quality value is filled with the quality encoding of
712 * the image file (0 - 100). The lossy flags is either 0 or 1 as to if
713 * the image was encoded lossily or not.
715 * On success the function returns 1 indicating the header was read and
716 * decoded properly, or 0 on failure.
718 * @see eet_data_image_header_decode_cipher()
721 * @ingroup Eet_File_Image_Group
723 EAPI int eet_data_image_header_decode(const void *data, int size, unsigned int *w, unsigned int *h, int *alpha, int *compress, int *quality, int *lossy);
726 * Decode Image data into pixel data.
727 * @param data The encoded pixel data.
728 * @param size The size, in bytes, of the encoded pixel data.
729 * @param w A pointer to the unsigned int to hold the width in pixels.
730 * @param h A pointer to the unsigned int to hold the height in pixels.
731 * @param alpha A pointer to the int to hold the alpha flag.
732 * @param compress A pointer to the int to hold the compression amount.
733 * @param quality A pointer to the int to hold the quality amount.
734 * @param lossy A pointer to the int to hold the lossiness flag.
735 * @return The image pixel data decoded
737 * This function takes encoded pixel data and decodes it into raw RGBA
740 * The other parameters of the image (width, height etc.) are placed into
741 * the values pointed to (they must be supplied). The pixel data is a linear
742 * array of pixels starting from the top-left of the image scanning row by
743 * row from left to right. Each pixel is a 32bit value, with the high byte
744 * being the alpha channel, the next being red, then green, and the low byte
745 * being blue. The width and height are measured in pixels and will be
746 * greater than 0 when returned. The alpha flag is either 0 or 1. 0 denotes
747 * that the alpha channel is not used. 1 denotes that it is significant.
748 * Compress is filled with the compression value/amount the image was
749 * stored with. The quality value is filled with the quality encoding of
750 * the image file (0 - 100). The lossy flags is either 0 or 1 as to if
751 * the image was encoded lossily or not.
753 * On success the function returns a pointer to the image data decoded. The
754 * calling application is responsible for calling free() on the image data
755 * when it is done with it. On failure NULL is returned and the parameter
756 * values may not contain any sensible data.
758 * @see eet_data_image_decode_cipher()
761 * @ingroup Eet_File_Image_Group
763 EAPI void *eet_data_image_decode(const void *data, int size, unsigned int *w, unsigned int *h, int *alpha, int *compress, int *quality, int *lossy);
766 * Decode Image data into pixel data.
767 * @param data The encoded pixel data.
768 * @param size The size, in bytes, of the encoded pixel data.
769 * @param src_x The starting x coordinate from where to dump the stream.
770 * @param src_y The starting y coordinate from where to dump the stream.
771 * @param d A pointer to the pixel surface.
772 * @param w The expected width in pixels of the pixel surface to decode.
773 * @param h The expected height in pixels of the pixel surface to decode.
774 * @param row_stride The length of a pixels line in the destination surface.
775 * @param alpha A pointer to the int to hold the alpha flag.
776 * @param compress A pointer to the int to hold the compression amount.
777 * @param quality A pointer to the int to hold the quality amount.
778 * @param lossy A pointer to the int to hold the lossiness flag.
779 * @return 1 on success, 0 otherwise.
781 * This function takes encoded pixel data and decodes it into raw RGBA
784 * The other parameters of the image (alpha, compress etc.) are placed into
785 * the values pointed to (they must be supplied). The pixel data is a linear
786 * array of pixels starting from the top-left of the image scanning row by
787 * row from left to right. Each pixel is a 32bit value, with the high byte
788 * being the alpha channel, the next being red, then green, and the low byte
789 * being blue. The width and height are measured in pixels and will be
790 * greater than 0 when returned. The alpha flag is either 0 or 1. 0 denotes
791 * that the alpha channel is not used. 1 denotes that it is significant.
792 * Compress is filled with the compression value/amount the image was
793 * stored with. The quality value is filled with the quality encoding of
794 * the image file (0 - 100). The lossy flags is either 0 or 1 as to if
795 * the image was encoded lossily or not.
797 * On success the function returns 1, and 0 on failure. On failure the
798 * parameter values may not contain any sensible data.
800 * @see eet_data_image_decode_to_surface_cipher()
803 * @ingroup Eet_File_Image_Group
805 EAPI int eet_data_image_decode_to_surface(const void *data, int size, unsigned int src_x, unsigned int src_y, unsigned int *d, unsigned int w, unsigned int h, unsigned int row_stride, int *alpha, int *compress, int *quality, int *lossy);
808 * Encode image data for storage or transmission.
809 * @param data A pointer to the image pixel data.
810 * @param size_ret A pointer to an int to hold the size of the returned data.
811 * @param w The width of the image in pixels.
812 * @param h The height of the image in pixels.
813 * @param alpha The alpha channel flag.
814 * @param compress The compression amount.
815 * @param quality The quality encoding amount.
816 * @param lossy The lossiness flag.
817 * @return The encoded image data.
819 * This function stakes image pixel data and encodes it with compression and
820 * possible loss of quality (as a trade off for size) for storage or
821 * transmission to another system.
823 * The data expected is the same format as returned by eet_data_image_read.
824 * If this is not the case weird things may happen. Width and height must
825 * be between 1 and 8000 pixels. The alpha flags can be 0 or 1 (0 meaning
826 * the alpha values are not useful and 1 meaning they are). Compress can
827 * be from 0 to 9 (0 meaning no compression, 9 meaning full compression).
828 * This is only used if the image is not lossily encoded. Quality is used on
829 * lossy compression and should be a value from 0 to 100. The lossy flag
830 * can be 0 or 1. 0 means encode losslessly and 1 means to encode with
831 * image quality loss (but then have a much smaller encoding).
833 * On success this function returns a pointer to the encoded data that you
834 * can free with free() when no longer needed.
836 * @see eet_data_image_encode_cipher()
839 * @ingroup Eet_File_Image_Group
841 EAPI void *eet_data_image_encode(const void *data, int *size_ret, unsigned int w, unsigned int h, int alpha, int compress, int quality, int lossy);
844 * @defgroup Eet_File_Image_Cipher_Group Image Store and Load using a Cipher
846 * Most of the @ref Eet_File_Image_Group have alternative versions
847 * that accounts for ciphers to protect their content.
849 * @see @ref Eet_Cipher_Group
851 * @ingroup Eet_File_Image_Group
855 * Read just the header data for an image and dont decode the pixels using a cipher.
856 * @param ef A valid eet file handle opened for reading.
857 * @param name Name of the entry. eg: "/base/file_i_want".
858 * @param cipher_key The key to use as cipher.
859 * @param w A pointer to the unsigned int to hold the width in pixels.
860 * @param h A pointer to the unsigned int to hold the height in pixels.
861 * @param alpha A pointer to the int to hold the alpha flag.
862 * @param compress A pointer to the int to hold the compression amount.
863 * @param quality A pointer to the int to hold the quality amount.
864 * @param lossy A pointer to the int to hold the lossiness flag.
865 * @return 1 on successfull decode, 0 otherwise
867 * This function reads an image from an eet file stored under the named
868 * key in the eet file and return a pointer to the decompressed pixel data.
870 * The other parameters of the image (width, height etc.) are placed into
871 * the values pointed to (they must be supplied). The pixel data is a linear
872 * array of pixels starting from the top-left of the image scanning row by
873 * row from left to right. Each pile is a 32bit value, with the high byte
874 * being the alpha channel, the next being red, then green, and the low byte
875 * being blue. The width and height are measured in pixels and will be
876 * greater than 0 when returned. The alpha flag is either 0 or 1. 0 denotes
877 * that the alpha channel is not used. 1 denotes that it is significant.
878 * Compress is filled with the compression value/amount the image was
879 * stored with. The quality value is filled with the quality encoding of
880 * the image file (0 - 100). The lossy flags is either 0 or 1 as to if
881 * the image was encoded lossily or not.
883 * On success the function returns 1 indicating the header was read and
884 * decoded properly, or 0 on failure.
886 * @see eet_data_image_header_read()
889 * @ingroup Eet_File_Image_Cipher_Group
891 EAPI int eet_data_image_header_read_cipher(Eet_File *ef, const char *name, const char *cipher_key, unsigned int *w, unsigned int *h, int *alpha, int *compress, int *quality, int *lossy);
894 * Read image data from the named key in the eet file using a cipher.
895 * @param ef A valid eet file handle opened for reading.
896 * @param name Name of the entry. eg: "/base/file_i_want".
897 * @param cipher_key The key to use as cipher.
898 * @param w A pointer to the unsigned int to hold the width in pixels.
899 * @param h A pointer to the unsigned int to hold the height in pixels.
900 * @param alpha A pointer to the int to hold the alpha flag.
901 * @param compress A pointer to the int to hold the compression amount.
902 * @param quality A pointer to the int to hold the quality amount.
903 * @param lossy A pointer to the int to hold the lossiness flag.
904 * @return The image pixel data decoded
906 * This function reads an image from an eet file stored under the named
907 * key in the eet file and return a pointer to the decompressed pixel data.
909 * The other parameters of the image (width, height etc.) are placed into
910 * the values pointed to (they must be supplied). The pixel data is a linear
911 * array of pixels starting from the top-left of the image scanning row by
912 * row from left to right. Each pile is a 32bit value, with the high byte
913 * being the alpha channel, the next being red, then green, and the low byte
914 * being blue. The width and height are measured in pixels and will be
915 * greater than 0 when returned. The alpha flag is either 0 or 1. 0 denotes
916 * that the alpha channel is not used. 1 denotes that it is significant.
917 * Compress is filled with the compression value/amount the image was
918 * stored with. The quality value is filled with the quality encoding of
919 * the image file (0 - 100). The lossy flags is either 0 or 1 as to if
920 * the image was encoded lossily or not.
922 * On success the function returns a pointer to the image data decoded. The
923 * calling application is responsible for calling free() on the image data
924 * when it is done with it. On failure NULL is returned and the parameter
925 * values may not contain any sensible data.
927 * @see eet_data_image_read()
930 * @ingroup Eet_File_Image_Cipher_Group
932 EAPI void *eet_data_image_read_cipher(Eet_File *ef, const char *name, const char *cipher_key, unsigned int *w, unsigned int *h, int *alpha, int *compress, int *quality, int *lossy);
935 * Read image data from the named key in the eet file using a cipher.
936 * @param ef A valid eet file handle opened for reading.
937 * @param name Name of the entry. eg: "/base/file_i_want".
938 * @param cipher_key The key to use as cipher.
939 * @param src_x The starting x coordinate from where to dump the stream.
940 * @param src_y The starting y coordinate from where to dump the stream.
941 * @param d A pointer to the pixel surface.
942 * @param w The expected width in pixels of the pixel surface to decode.
943 * @param h The expected height in pixels of the pixel surface to decode.
944 * @param row_stride The length of a pixels line in the destination surface.
945 * @param alpha A pointer to the int to hold the alpha flag.
946 * @param compress A pointer to the int to hold the compression amount.
947 * @param quality A pointer to the int to hold the quality amount.
948 * @param lossy A pointer to the int to hold the lossiness flag.
949 * @return 1 on success, 0 otherwise.
951 * This function reads an image from an eet file stored under the named
952 * key in the eet file and return a pointer to the decompressed pixel data.
954 * The other parameters of the image (width, height etc.) are placed into
955 * the values pointed to (they must be supplied). The pixel data is a linear
956 * array of pixels starting from the top-left of the image scanning row by
957 * row from left to right. Each pile is a 32bit value, with the high byte
958 * being the alpha channel, the next being red, then green, and the low byte
959 * being blue. The width and height are measured in pixels and will be
960 * greater than 0 when returned. The alpha flag is either 0 or 1. 0 denotes
961 * that the alpha channel is not used. 1 denotes that it is significant.
962 * Compress is filled with the compression value/amount the image was
963 * stored with. The quality value is filled with the quality encoding of
964 * the image file (0 - 100). The lossy flags is either 0 or 1 as to if
965 * the image was encoded lossily or not.
967 * On success the function returns 1, and 0 on failure. On failure the
968 * parameter values may not contain any sensible data.
970 * @see eet_data_image_read_to_surface()
973 * @ingroup Eet_File_Image_Cipher_Group
975 EAPI int eet_data_image_read_to_surface_cipher(Eet_File *ef, const char *name, const char *cipher_key, unsigned int src_x, unsigned int src_y, unsigned int *d, unsigned int w, unsigned int h, unsigned int row_stride, int *alpha, int *compress, int *quality, int *lossy);
978 * Write image data to the named key in an eet file using a cipher.
979 * @param ef A valid eet file handle opened for writing.
980 * @param name Name of the entry. eg: "/base/file_i_want".
981 * @param cipher_key The key to use as cipher.
982 * @param data A pointer to the image pixel data.
983 * @param w The width of the image in pixels.
984 * @param h The height of the image in pixels.
985 * @param alpha The alpha channel flag.
986 * @param compress The compression amount.
987 * @param quality The quality encoding amount.
988 * @param lossy The lossiness flag.
989 * @return Success if the data was encoded and written or not.
991 * This function takes image pixel data and encodes it in an eet file
992 * stored under the supplied name key, and returns how many bytes were
993 * actually written to encode the image data.
995 * The data expected is the same format as returned by eet_data_image_read.
996 * If this is not the case weird things may happen. Width and height must
997 * be between 1 and 8000 pixels. The alpha flags can be 0 or 1 (0 meaning
998 * the alpha values are not useful and 1 meaning they are). Compress can
999 * be from 0 to 9 (0 meaning no compression, 9 meaning full compression).
1000 * This is only used if the image is not lossily encoded. Quality is used on
1001 * lossy compression and should be a value from 0 to 100. The lossy flag
1002 * can be 0 or 1. 0 means encode losslessly and 1 means to encode with
1003 * image quality loss (but then have a much smaller encoding).
1005 * On success this function returns the number of bytes that were required
1006 * to encode the image data, or on failure it returns 0.
1008 * @see eet_data_image_write()
1011 * @ingroup Eet_File_Image_Cipher_Group
1013 EAPI int eet_data_image_write_cipher(Eet_File *ef, const char *name, const char *cipher_key, const void *data, unsigned int w, unsigned int h, int alpha, int compress, int quality, int lossy);
1017 * Decode Image data header only to get information using a cipher.
1018 * @param data The encoded pixel data.
1019 * @param cipher_key The key to use as cipher.
1020 * @param size The size, in bytes, of the encoded pixel data.
1021 * @param w A pointer to the unsigned int to hold the width in pixels.
1022 * @param h A pointer to the unsigned int to hold the height in pixels.
1023 * @param alpha A pointer to the int to hold the alpha flag.
1024 * @param compress A pointer to the int to hold the compression amount.
1025 * @param quality A pointer to the int to hold the quality amount.
1026 * @param lossy A pointer to the int to hold the lossiness flag.
1027 * @return 1 on success, 0 on failure.
1029 * This function takes encoded pixel data and decodes it into raw RGBA
1030 * pixels on success.
1032 * The other parameters of the image (width, height etc.) are placed into
1033 * the values pointed to (they must be supplied). The pixel data is a linear
1034 * array of pixels starting from the top-left of the image scanning row by
1035 * row from left to right. Each pixel is a 32bit value, with the high byte
1036 * being the alpha channel, the next being red, then green, and the low byte
1037 * being blue. The width and height are measured in pixels and will be
1038 * greater than 0 when returned. The alpha flag is either 0 or 1. 0 denotes
1039 * that the alpha channel is not used. 1 denotes that it is significant.
1040 * Compress is filled with the compression value/amount the image was
1041 * stored with. The quality value is filled with the quality encoding of
1042 * the image file (0 - 100). The lossy flags is either 0 or 1 as to if
1043 * the image was encoded lossily or not.
1045 * On success the function returns 1 indicating the header was read and
1046 * decoded properly, or 0 on failure.
1048 * @see eet_data_image_header_decode()
1051 * @ingroup Eet_File_Image_Cipher_Group
1053 EAPI int eet_data_image_header_decode_cipher(const void *data, const char *cipher_key, int size, unsigned int *w, unsigned int *h, int *alpha, int *compress, int *quality, int *lossy);
1056 * Decode Image data into pixel data using a cipher.
1057 * @param data The encoded pixel data.
1058 * @param cipher_key The key to use as cipher.
1059 * @param size The size, in bytes, of the encoded pixel data.
1060 * @param w A pointer to the unsigned int to hold the width in pixels.
1061 * @param h A pointer to the unsigned int to hold the height in pixels.
1062 * @param alpha A pointer to the int to hold the alpha flag.
1063 * @param compress A pointer to the int to hold the compression amount.
1064 * @param quality A pointer to the int to hold the quality amount.
1065 * @param lossy A pointer to the int to hold the lossiness flag.
1066 * @return The image pixel data decoded
1068 * This function takes encoded pixel data and decodes it into raw RGBA
1069 * pixels on success.
1071 * The other parameters of the image (width, height etc.) are placed into
1072 * the values pointed to (they must be supplied). The pixel data is a linear
1073 * array of pixels starting from the top-left of the image scanning row by
1074 * row from left to right. Each pixel is a 32bit value, with the high byte
1075 * being the alpha channel, the next being red, then green, and the low byte
1076 * being blue. The width and height are measured in pixels and will be
1077 * greater than 0 when returned. The alpha flag is either 0 or 1. 0 denotes
1078 * that the alpha channel is not used. 1 denotes that it is significant.
1079 * Compress is filled with the compression value/amount the image was
1080 * stored with. The quality value is filled with the quality encoding of
1081 * the image file (0 - 100). The lossy flags is either 0 or 1 as to if
1082 * the image was encoded lossily or not.
1084 * On success the function returns a pointer to the image data decoded. The
1085 * calling application is responsible for calling free() on the image data
1086 * when it is done with it. On failure NULL is returned and the parameter
1087 * values may not contain any sensible data.
1089 * @see eet_data_image_decode()
1092 * @ingroup Eet_File_Image_Cipher_Group
1094 EAPI void *eet_data_image_decode_cipher(const void *data, const char *cipher_key, int size, unsigned int *w, unsigned int *h, int *alpha, int *compress, int *quality, int *lossy);
1097 * Decode Image data into pixel data using a cipher.
1098 * @param data The encoded pixel data.
1099 * @param cipher_key The key to use as cipher.
1100 * @param size The size, in bytes, of the encoded pixel data.
1101 * @param src_x The starting x coordinate from where to dump the stream.
1102 * @param src_y The starting y coordinate from where to dump the stream.
1103 * @param d A pointer to the pixel surface.
1104 * @param w The expected width in pixels of the pixel surface to decode.
1105 * @param h The expected height in pixels of the pixel surface to decode.
1106 * @param row_stride The length of a pixels line in the destination surface.
1107 * @param alpha A pointer to the int to hold the alpha flag.
1108 * @param compress A pointer to the int to hold the compression amount.
1109 * @param quality A pointer to the int to hold the quality amount.
1110 * @param lossy A pointer to the int to hold the lossiness flag.
1111 * @return 1 on success, 0 otherwise.
1113 * This function takes encoded pixel data and decodes it into raw RGBA
1114 * pixels on success.
1116 * The other parameters of the image (alpha, compress etc.) are placed into
1117 * the values pointed to (they must be supplied). The pixel data is a linear
1118 * array of pixels starting from the top-left of the image scanning row by
1119 * row from left to right. Each pixel is a 32bit value, with the high byte
1120 * being the alpha channel, the next being red, then green, and the low byte
1121 * being blue. The width and height are measured in pixels and will be
1122 * greater than 0 when returned. The alpha flag is either 0 or 1. 0 denotes
1123 * that the alpha channel is not used. 1 denotes that it is significant.
1124 * Compress is filled with the compression value/amount the image was
1125 * stored with. The quality value is filled with the quality encoding of
1126 * the image file (0 - 100). The lossy flags is either 0 or 1 as to if
1127 * the image was encoded lossily or not.
1129 * On success the function returns 1, and 0 on failure. On failure the
1130 * parameter values may not contain any sensible data.
1132 * @see eet_data_image_decode_to_surface()
1135 * @ingroup Eet_File_Image_Cipher_Group
1137 EAPI int eet_data_image_decode_to_surface_cipher(const void *data, const char *cipher_key, int size, unsigned int src_x, unsigned int src_y, unsigned int *d, unsigned int w, unsigned int h, unsigned int row_stride, int *alpha, int *compress, int *quality, int *lossy);
1140 * Encode image data for storage or transmission using a cipher.
1141 * @param data A pointer to the image pixel data.
1142 * @param cipher_key The key to use as cipher.
1143 * @param size_ret A pointer to an int to hold the size of the returned data.
1144 * @param w The width of the image in pixels.
1145 * @param h The height of the image in pixels.
1146 * @param alpha The alpha channel flag.
1147 * @param compress The compression amount.
1148 * @param quality The quality encoding amount.
1149 * @param lossy The lossiness flag.
1150 * @return The encoded image data.
1152 * This function stakes image pixel data and encodes it with compression and
1153 * possible loss of quality (as a trade off for size) for storage or
1154 * transmission to another system.
1156 * The data expected is the same format as returned by eet_data_image_read.
1157 * If this is not the case weird things may happen. Width and height must
1158 * be between 1 and 8000 pixels. The alpha flags can be 0 or 1 (0 meaning
1159 * the alpha values are not useful and 1 meaning they are). Compress can
1160 * be from 0 to 9 (0 meaning no compression, 9 meaning full compression).
1161 * This is only used if the image is not lossily encoded. Quality is used on
1162 * lossy compression and should be a value from 0 to 100. The lossy flag
1163 * can be 0 or 1. 0 means encode losslessly and 1 means to encode with
1164 * image quality loss (but then have a much smaller encoding).
1166 * On success this function returns a pointer to the encoded data that you
1167 * can free with free() when no longer needed.
1169 * @see eet_data_image_encode()
1172 * @ingroup Eet_File_Image_Cipher_Group
1174 EAPI void *eet_data_image_encode_cipher(const void *data, const char *cipher_key, unsigned int w, unsigned int h, int alpha, int compress, int quality, int lossy, int *size_ret);
1178 * @defgroup Eet_Cipher_Group Cipher, Identity and Protection Mechanisms
1180 * Eet allows one to protect entries of an #Eet_File
1181 * individually. This may be used to ensure data was not tampered or
1182 * that third party does not read your data.
1184 * @see @ref Eet_File_Cipher_Group
1185 * @see @ref Eet_File_Image_Cipher_Group
1192 * Opaque handle that defines an identity (also known as key)
1193 * in Eet's cipher system.
1195 typedef struct _Eet_Key Eet_Key;
1203 * Callback used to request if needed the password of a private key.
1205 * @param buffer the buffer where to store the password.
1206 * @param size the maximum password size (size of buffer, including '@\0').
1207 * @param rwflag if the buffer is also readable or just writable.
1208 * @param data currently unused, may contain some context in future.
1209 * @return 1 on success and password was set to @p buffer, 0 on failure.
1212 * @ingroup Eet_Cipher_Group
1214 typedef int (*Eet_Key_Password_Callback)(char *buffer, int size, int rwflag, void *data);
1217 * Create an Eet_Key needed for signing an eet file.
1219 * The certificate should provide the public that match the private key.
1220 * No verification is done to ensure that.
1222 * @param certificate_file The file where to find the certificate.
1223 * @param private_key_file The file that contains the private key.
1224 * @param cb Function to callback if password is required to unlock
1226 * @return A key handle to use, or @c NULL on failure.
1228 * @see eet_identity_close()
1231 * @ingroup Eet_Cipher_Group
1233 EAPI Eet_Key* eet_identity_open(const char *certificate_file, const char *private_key_file, Eet_Key_Password_Callback cb);
1236 * Close and release all ressource used by an Eet_Key. An
1237 * reference counter prevent it from being freed until all file
1238 * using it are also closed.
1240 * @param key the key handle to close and free resources.
1243 * @ingroup Eet_Cipher_Group
1245 EAPI void eet_identity_close(Eet_Key *key);
1248 * Set a key to sign a file
1250 * @param ef the file to set the identity.
1251 * @param key the key handle to set as identity.
1252 * @return #EET_ERROR_BAD_OBJECT if @p ef is invalid or
1253 * #EET_ERROR_NONE on success.
1256 * @ingroup Eet_Cipher_Group
1258 EAPI Eet_Error eet_identity_set(Eet_File *ef, Eet_Key *key);
1261 * Display both private and public key of an Eet_Key.
1263 * @param key the handle to print.
1264 * @param out where to print.
1267 * @ingroup Eet_Cipher_Group
1269 EAPI void eet_identity_print(Eet_Key *key, FILE *out);
1272 * Get the x509 der certificate associated with an Eet_File. Will return NULL
1273 * if the file is not signed.
1275 * @param ef The file handle to query.
1276 * @param der_length The length of returned data, may be @c NULL.
1277 * @return the x509 certificate or @c NULL on error.
1280 * @ingroup Eet_Cipher_Group
1282 EAPI const void *eet_identity_x509(Eet_File *ef, int *der_length);
1285 * Get the raw signature associated with an Eet_File. Will return NULL
1286 * if the file is not signed.
1288 * @param ef The file handle to query.
1289 * @param signature_length The length of returned data, may be @c NULL.
1290 * @return the raw signature or @c NULL on error.
1292 * @ingroup Eet_Cipher_Group
1294 EAPI const void *eet_identity_signature(Eet_File *ef, int *signature_length);
1297 * Get the SHA1 associated with a file. Could be the one used to
1298 * sign the data or if the data where not signed, it will be the
1301 * @param ef The file handle to query.
1302 * @param sha1_length The length of returned data, may be @c NULL.
1303 * @return the associated SHA1 or @c NULL on error.
1306 * @ingroup Eet_Cipher_Group
1308 EAPI const void *eet_identity_sha1(Eet_File *ef, int *sha1_length);
1311 * Display the x509 der certificate to out.
1313 * @param certificate the x509 certificate to print
1314 * @param der_length The length the certificate.
1315 * @param out where to print.
1318 * @ingroup Eet_Cipher_Group
1320 EAPI void eet_identity_certificate_print(const unsigned char *certificate, int der_length, FILE *out);
1324 * @defgroup Eet_Data_Group Eet Data Serialization
1326 * Convenience functions to serialize and parse complex data
1327 * structures to binary blobs.
1329 * While Eet core just handles binary blobs, it is often required
1330 * to save some structured data of different types, such as
1331 * strings, integers, lists, hashes and so on.
1333 * Eet can serialize and then parse data types given some
1334 * construction instructions. These are defined in two levels:
1336 * - #Eet_Data_Descriptor_Class to tell generic memory handling,
1337 * such as the size of the type, how to allocate memory, strings,
1338 * lists, hashes and so on.
1340 * - #Eet_Data_Descriptor to tell inside such type, the members and
1341 * their offsets inside the memory blob, their types and
1342 * names. These members can be simple types or other
1343 * #Eet_Data_Descriptor, allowing hierarchical types to be
1346 * Given that C provides no introspection, this process can be
1347 * quite cumbersome, so we provide lots of macros and convenience
1348 * functions to aid creating the types.
1356 * typedef struct _blah2
1361 * typedef struct _blah3
1366 * typedef struct _blah
1373 * double floating_lots;
1380 * main(int argc, char **argv)
1385 * Eet_Data_Descriptor *edd, *edd2, *edd3;
1386 * Eet_Data_Descriptor_Class eddc, eddc2, eddc3;
1394 * EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eddc3, Blah3);
1395 * edd3 = eet_data_descriptor_stream_new(&eddc3);
1396 * EET_DATA_DESCRIPTOR_ADD_BASIC(edd3, Blah3, "string3", string, EET_T_STRING);
1398 * EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eddc2, Blah2);
1399 * edd2 = eet_data_descriptor_stream_new(&eddc2);
1400 * EET_DATA_DESCRIPTOR_ADD_BASIC(edd2, Blah2, "string2", string, EET_T_STRING);
1402 * EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eddc, Blah);
1403 * edd = eet_data_descriptor_stream_new(&eddc);
1404 * EET_DATA_DESCRIPTOR_ADD_BASIC(edd, Blah, "character", character, EET_T_CHAR);
1405 * EET_DATA_DESCRIPTOR_ADD_BASIC(edd, Blah, "sixteen", sixteen, EET_T_SHORT);
1406 * EET_DATA_DESCRIPTOR_ADD_BASIC(edd, Blah, "integer", integer, EET_T_INT);
1407 * EET_DATA_DESCRIPTOR_ADD_BASIC(edd, Blah, "lots", lots, EET_T_LONG_LONG);
1408 * EET_DATA_DESCRIPTOR_ADD_BASIC(edd, Blah, "floating", floating, EET_T_FLOAT);
1409 * EET_DATA_DESCRIPTOR_ADD_BASIC(edd, Blah, "floating_lots", floating_lots, EET_T_DOUBLE);
1410 * EET_DATA_DESCRIPTOR_ADD_BASIC(edd, Blah, "string", string, EET_T_STRING);
1411 * EET_DATA_DESCRIPTOR_ADD_SUB(edd, Blah, "blah2", blah2, edd2);
1412 * EET_DATA_DESCRIPTOR_ADD_LIST(edd, Blah, "blah3", blah3, edd3);
1414 * blah3.string = "PANTS";
1416 * blah2.string = "subtype string here!";
1418 * blah.character = '7';
1419 * blah.sixteen = 0x7777;
1420 * blah.integer = 0xc0def00d;
1421 * blah.lots = 0xdeadbeef31337777;
1422 * blah.floating = 3.141592654;
1423 * blah.floating_lots = 0.777777777777777;
1424 * blah.string = "bite me like a turnip";
1425 * blah.blah2 = &blah2;
1426 * blah.blah3 = eina_list_append(NULL, &blah3);
1427 * blah.blah3 = eina_list_append(blah.blah3, &blah3);
1428 * blah.blah3 = eina_list_append(blah.blah3, &blah3);
1429 * blah.blah3 = eina_list_append(blah.blah3, &blah3);
1430 * blah.blah3 = eina_list_append(blah.blah3, &blah3);
1431 * blah.blah3 = eina_list_append(blah.blah3, &blah3);
1432 * blah.blah3 = eina_list_append(blah.blah3, &blah3);
1434 * data = eet_data_descriptor_encode(edd, &blah, &size);
1435 * printf("-----DECODING\n");
1436 * blah_in = eet_data_descriptor_decode(edd, data, size);
1438 * printf("-----DECODED!\n");
1439 * printf("%c\n", blah_in->character);
1440 * printf("%x\n", (int)blah_in->sixteen);
1441 * printf("%x\n", blah_in->integer);
1442 * printf("%lx\n", blah_in->lots);
1443 * printf("%f\n", (double)blah_in->floating);
1444 * printf("%f\n", (double)blah_in->floating_lots);
1445 * printf("%s\n", blah_in->string);
1446 * printf("%p\n", blah_in->blah2);
1447 * printf(" %s\n", blah_in->blah2->string);
1452 * EINA_LIST_FOREACH(blah_in->blah3, l, blah3_in)
1454 * printf("%p\n", blah3_in);
1455 * printf(" %s\n", blah3_in->string);
1458 * eet_data_descriptor_free(edd);
1459 * eet_data_descriptor_free(edd2);
1460 * eet_data_descriptor_free(edd3);
1470 #define EET_T_UNKNOW 0 /**< Unknown data encoding type */
1471 #define EET_T_CHAR 1 /**< Data type: char */
1472 #define EET_T_SHORT 2 /**< Data type: short */
1473 #define EET_T_INT 3 /**< Data type: int */
1474 #define EET_T_LONG_LONG 4 /**< Data type: long long */
1475 #define EET_T_FLOAT 5 /**< Data type: float */
1476 #define EET_T_DOUBLE 6 /**< Data type: double */
1477 #define EET_T_UCHAR 7 /**< Data type: unsigned char */
1478 #define EET_T_USHORT 8 /**< Data type: unsigned short */
1479 #define EET_T_UINT 9 /**< Data type: unsigned int */
1480 #define EET_T_ULONG_LONG 10 /**< Data type: unsigned long long */
1481 #define EET_T_STRING 11 /**< Data type: char * */
1482 #define EET_T_INLINED_STRING 12 /**< Data type: char * (but compressed inside the resulting eet) */
1483 #define EET_T_NULL 13 /**< Data type: (void *) (only use it if you know why) */
1484 #define EET_T_F32P32 14 /**< Data type: fixed point 32.32 */
1485 #define EET_T_F16P16 15 /**< Data type: fixed point 16.16 */
1486 #define EET_T_F8P24 16 /**< Data type: fixed point 8.24 */
1487 #define EET_T_LAST 18 /**< Last data type */
1489 #define EET_G_UNKNOWN 100 /**< Unknown group data encoding type */
1490 #define EET_G_ARRAY 101 /**< Fixed size array group type */
1491 #define EET_G_VAR_ARRAY 102 /**< Variable size array group type */
1492 #define EET_G_LIST 103 /**< Linked list group type */
1493 #define EET_G_HASH 104 /**< Hash table group type */
1494 #define EET_G_UNION 105 /**< Union group type */
1495 #define EET_G_VARIANT 106 /**< Selectable subtype group */
1496 #define EET_G_LAST 107 /**< Last group type */
1498 #define EET_I_LIMIT 128 /**< Other type exist but are reserved for internal purpose. */
1501 * @typedef Eet_Data_Descriptor
1503 * Opaque handle that have information on a type members.
1505 * The members are added by means of
1506 * EET_DATA_DESCRIPTOR_ADD_BASIC(), EET_DATA_DESCRIPTOR_ADD_SUB(),
1507 * EET_DATA_DESCRIPTOR_ADD_LIST(), EET_DATA_DESCRIPTOR_ADD_HASH()
1508 * or eet_data_descriptor_element_add().
1510 * @see eet_data_descriptor_stream_new()
1511 * @see eet_data_descriptor_file_new()
1512 * @see eet_data_descriptor_free()
1514 typedef struct _Eet_Data_Descriptor Eet_Data_Descriptor;
1517 * @def EET_DATA_DESCRIPTOR_CLASS_VERSION
1518 * The version of #Eet_Data_Descriptor_Class at the time of the
1519 * distribution of the sources. One should define this to its
1520 * version member so it is compatible with abi changes, or at least
1521 * will not crash with them.
1523 #define EET_DATA_DESCRIPTOR_CLASS_VERSION 3
1526 * @typedef Eet_Data_Descriptor_Class
1528 * Instructs Eet about memory management for different needs under
1529 * serialization and parse process.
1531 typedef struct _Eet_Data_Descriptor_Class Eet_Data_Descriptor_Class;
1534 * @struct _Eet_Data_Descriptor_Class
1536 * Instructs Eet about memory management for different needs under
1537 * serialization and parse process.
1539 * If using Eina data types, it is advised to use the helpers
1540 * EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET() and
1541 * EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET().
1543 struct _Eet_Data_Descriptor_Class
1545 int version; /**< ABI version as #EET_DATA_DESCRIPTOR_CLASS_VERSION */
1546 const char *name; /**< Name of data type to be serialized */
1547 int size; /**< Size in bytes of data type to be serialized */
1549 void *(*mem_alloc) (size_t size); /**< how to allocate memory (usually malloc()) */
1550 void (*mem_free) (void *mem); /**< how to free memory (usually free()) */
1551 char *(*str_alloc) (const char *str); /**< how to allocate a string */
1552 void (*str_free) (const char *str); /**< how to free a string */
1553 void *(*list_next) (void *l); /**< how to iterate to the next element of a list. Receives and should return the list node. */
1554 void *(*list_append) (void *l, void *d); /**< how to append data @p d to list which head node is @p l */
1555 void *(*list_data) (void *l); /**< retrieves the data from node @p l */
1556 void *(*list_free) (void *l); /**< free all the nodes from the list which head node is @p l */
1557 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 */
1558 void *(*hash_add) (void *h, const char *k, void *d); /**< add a new data @p d as key @p k in hash @p h */
1559 void (*hash_free) (void *h); /**< free all entries from the hash @p h */
1560 char *(*str_direct_alloc) (const char *str); /**< how to allocate a string directly from file backed/mmaped region pointed by @p str */
1561 void (*str_direct_free) (const char *str); /**< how to free a string returned by str_direct_alloc */
1563 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. */
1564 Eina_Bool (*type_set) (const char *type, void *data, Eina_Bool unknow); /**< set the type at a particular adress */
1573 * Create a new empty data structure descriptor.
1574 * @param name The string name of this data structure (most be a
1575 * global constant and never change).
1576 * @param size The size of the struct (in bytes).
1577 * @param func_list_next The function to get the next list node.
1578 * @param func_list_append The function to append a member to a list.
1579 * @param func_list_data The function to get the data from a list node.
1580 * @param func_list_free The function to free an entire linked list.
1581 * @param func_hash_foreach The function to iterate through all
1582 * hash table entries.
1583 * @param func_hash_add The function to add a member to a hash table.
1584 * @param func_hash_free The function to free an entire hash table.
1585 * @return A new empty data descriptor.
1587 * This function creates a new data descriptore and returns a handle to the
1588 * new data descriptor. On creation it will be empty, containing no contents
1589 * describing anything other than the shell of the data structure.
1591 * You add structure members to the data descriptor using the macros
1592 * EET_DATA_DESCRIPTOR_ADD_BASIC(), EET_DATA_DESCRIPTOR_ADD_SUB() and
1593 * EET_DATA_DESCRIPTOR_ADD_LIST(), depending on what type of member you are
1594 * adding to the description.
1596 * Once you have described all the members of a struct you want loaded, or
1597 * saved eet can load and save those members for you, encode them into
1598 * endian-independant serialised data chunks for transmission across a
1599 * a network or more.
1601 * The function pointers to the list and hash table functions are only
1602 * needed if you use those data types, else you can pass NULL instead.
1605 * @ingroup Eet_Data_Group
1607 * @deprecated use eet_data_descriptor_stream_new() or
1608 * eet_data_descriptor_file_new()
1610 EINA_DEPRECATED EAPI Eet_Data_Descriptor *eet_data_descriptor_new(const char *name, int size, void *(*func_list_next) (void *l), void *(*func_list_append) (void *l, void *d), void *(*func_list_data) (void *l), void *(*func_list_free) (void *l), void (*func_hash_foreach) (void *h, int (*func) (void *h, const char *k, void *dt, void *fdt), void *fdt), void *(*func_hash_add) (void *h, const char *k, void *d), void (*func_hash_free) (void *h));
1614 * moving to this api from the old above. this will break things when the
1615 * move happens - but be warned
1617 EINA_DEPRECATED EAPI Eet_Data_Descriptor *eet_data_descriptor2_new(const Eet_Data_Descriptor_Class *eddc);
1618 EINA_DEPRECATED EAPI Eet_Data_Descriptor *eet_data_descriptor3_new(const Eet_Data_Descriptor_Class *eddc);
1621 * This function creates a new data descriptore and returns a handle to the
1622 * new data descriptor. On creation it will be empty, containing no contents
1623 * describing anything other than the shell of the data structure.
1624 * @param eddc The data descriptor to free.
1626 * You add structure members to the data descriptor using the macros
1627 * EET_DATA_DESCRIPTOR_ADD_BASIC(), EET_DATA_DESCRIPTOR_ADD_SUB() and
1628 * EET_DATA_DESCRIPTOR_ADD_LIST(), depending on what type of member you are
1629 * adding to the description.
1631 * Once you have described all the members of a struct you want loaded, or
1632 * saved eet can load and save those members for you, encode them into
1633 * endian-independant serialised data chunks for transmission across a
1634 * a network or more.
1636 * This function specially ignore str_direct_alloc and str_direct_free. It
1637 * is usefull when the eet_data you are reading don't have a dictionnary
1638 * like network stream or ipc. It also mean that all string will be allocated
1639 * and duplicated in memory.
1642 * @ingroup Eet_Data_Group
1644 EAPI Eet_Data_Descriptor *eet_data_descriptor_stream_new(const Eet_Data_Descriptor_Class *eddc);
1647 * This function creates a new data descriptore and returns a handle to the
1648 * new data descriptor. On creation it will be empty, containing no contents
1649 * describing anything other than the shell of the data structure.
1650 * @param eddc The data descriptor to free.
1652 * You add structure members to the data descriptor using the macros
1653 * EET_DATA_DESCRIPTOR_ADD_BASIC(), EET_DATA_DESCRIPTOR_ADD_SUB() and
1654 * EET_DATA_DESCRIPTOR_ADD_LIST(), depending on what type of member you are
1655 * adding to the description.
1657 * Once you have described all the members of a struct you want loaded, or
1658 * saved eet can load and save those members for you, encode them into
1659 * endian-independant serialised data chunks for transmission across a
1660 * a network or more.
1662 * This function use str_direct_alloc and str_direct_free. It is
1663 * usefull when the eet_data you are reading come from a file and
1664 * have a dictionnary. This will reduce memory use, improve the
1665 * possibility for the OS to page this string out. But be carrefull
1666 * all EET_T_STRING are pointer to a mmapped area and it will point
1667 * to nowhere if you close the file. So as long as you use this
1668 * strings, you need to have the Eet_File open.
1671 * @ingroup Eet_Data_Group
1673 EAPI Eet_Data_Descriptor *eet_data_descriptor_file_new(const Eet_Data_Descriptor_Class *eddc);
1676 * This function is an helper that set all the parameter of an
1677 * Eet_Data_Descriptor_Class correctly when you use Eina data type
1679 * @param eddc The Eet_Data_Descriptor_Class you want to set.
1680 * @param name The name of the structure described by this class.
1681 * @param size The size of the structure described by this class.
1682 * @return EINA_TRUE if the structure was correctly set (The only
1683 * reason that could make it fail is if you did give wrong
1687 * @ingroup Eet_Data_Group
1689 EAPI Eina_Bool eet_eina_stream_data_descriptor_class_set(Eet_Data_Descriptor_Class *eddc, const char *name, int size);
1692 * This macro is an helper that set all the parameter of an
1693 * Eet_Data_Descriptor_Class correctly when you use Eina data type
1695 * @param Clas The Eet_Data_Descriptor_Class you want to set.
1696 * @param Type The type of the structure described by this class.
1697 * @return EINA_TRUE if the structure was correctly set (The only
1698 * reason that could make it fail is if you did give wrong
1702 * @ingroup Eet_Data_Group
1704 #define EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(Clas, Type) (eet_eina_stream_data_descriptor_class_set(Clas, #Type , sizeof (Type)))
1707 * This function is an helper that set all the parameter of an
1708 * Eet_Data_Descriptor_Class correctly when you use Eina data type
1710 * @param eddc The Eet_Data_Descriptor_Class you want to set.
1711 * @param name The name of the structure described by this class.
1712 * @param size The size of the structure described by this class.
1713 * @return EINA_TRUE if the structure was correctly set (The only
1714 * reason that could make it fail is if you did give wrong
1718 * @ingroup Eet_Data_Group
1720 EAPI Eina_Bool eet_eina_file_data_descriptor_class_set(Eet_Data_Descriptor_Class *eddc, const char *name, int size);
1723 * This macro is an helper that set all the parameter of an
1724 * Eet_Data_Descriptor_Class correctly when you use Eina data type
1726 * @param Clas The Eet_Data_Descriptor_Class you want to set.
1727 * @param Type The type of the structure described by this class.
1728 * @return EINA_TRUE if the structure was correctly set (The only
1729 * reason that could make it fail is if you did give wrong
1733 * @ingroup Eet_Data_Group
1735 #define EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(Clas, Type) (eet_eina_file_data_descriptor_class_set(Clas, #Type , sizeof (Type)))
1738 * This function frees a data descriptor when it is not needed anymore.
1739 * @param edd The data descriptor to free.
1741 * This function takes a data descriptor handle as a parameter and frees all
1742 * data allocated for the data descriptor and the handle itself. After this
1743 * call the descriptor is no longer valid.
1746 * @ingroup Eet_Data_Group
1748 EAPI void eet_data_descriptor_free(Eet_Data_Descriptor *edd);
1751 * This function is an internal used by macros.
1753 * This function is used by macros EET_DATA_DESCRIPTOR_ADD_BASIC(),
1754 * EET_DATA_DESCRIPTOR_ADD_SUB() and EET_DATA_DESCRIPTOR_ADD_LIST(). It is
1755 * complex to use by hand and should be left to be used by the macros, and
1756 * thus is not documented.
1758 * @param edd The data descriptor handle to add element (member).
1759 * @param name The name of element to be serialized.
1760 * @param type The type of element to be serialized, like
1761 * #EET_T_INT. If #EET_T_UNKNOW, then it is considered to be a
1762 * group, list or hash.
1763 * @param group_type If element type is #EET_T_UNKNOW, then the @p
1764 * group_type will speficy if it is a list (#EET_G_LIST),
1765 * array (#EET_G_ARRAY) and so on. If #EET_G_UNKNOWN, then
1766 * the member is a subtype (pointer to another type defined by
1767 * another #Eet_Data_Descriptor).
1768 * @param offset byte offset inside the source memory to be serialized.
1769 * @param count number of elements (if #EET_G_ARRAY or #EET_G_VAR_ARRAY).
1770 * @param counter_name variable that defines the name of number of elements.
1771 * @param subtype If contains a subtype, then its data descriptor.
1774 * @ingroup Eet_Data_Group
1776 EAPI void eet_data_descriptor_element_add(Eet_Data_Descriptor *edd, const char *name, int type, int group_type, int offset, /* int count_offset, */int count, const char *counter_name, Eet_Data_Descriptor *subtype);
1779 * Read a data structure from an eet file and decodes it.
1780 * @param ef The eet file handle to read from.
1781 * @param edd The data descriptor handle to use when decoding.
1782 * @param name The key the data is stored under in the eet file.
1783 * @return A pointer to the decoded data structure.
1785 * This function decodes a data structure stored in an eet file, returning
1786 * a pointer to it if it decoded successfully, or NULL on failure. This
1787 * can save a programmer dozens of hours of work in writing configuration
1788 * file parsing and writing code, as eet does all that work for the program
1789 * and presents a program-friendly data structure, just as the programmer
1790 * likes. Eet can handle members being added or deleted from the data in
1791 * storage and safely zero-fills unfilled members if they were not found
1792 * in the data. It checks sizes and headers whenever it reads data, allowing
1793 * the programmer to not worry about corrupt data.
1795 * Once a data structure has been described by the programmer with the
1796 * fields they wish to save or load, storing or retrieving a data structure
1797 * from an eet file, or from a chunk of memory is as simple as a single
1800 * @see eet_data_read_cipher()
1803 * @ingroup Eet_Data_Group
1805 EAPI void *eet_data_read(Eet_File *ef, Eet_Data_Descriptor *edd, const char *name);
1808 * Write a data structure from memory and store in an eet file.
1809 * @param ef The eet file handle to write to.
1810 * @param edd The data descriptor to use when encoding.
1811 * @param name The key to store the data under in the eet file.
1812 * @param data A pointer to the data structure to ssave and encode.
1813 * @param compress Compression flags for storage.
1814 * @return bytes written on successful write, 0 on failure.
1816 * This function is the reverse of eet_data_read(), saving a data structure
1819 * @see eet_data_write_cipher()
1822 * @ingroup Eet_Data_Group
1824 EAPI int eet_data_write(Eet_File *ef, Eet_Data_Descriptor *edd, const char *name, const void *data, int compress);
1827 * Dump an eet encoded data structure into ascii text
1828 * @param data_in The pointer to the data to decode into a struct.
1829 * @param size_in The size of the data pointed to in bytes.
1830 * @param dumpfunc The function to call passed a string when new
1831 * data is converted to text
1832 * @param dumpdata The data to pass to the @p dumpfunc callback.
1833 * @return 1 on success, 0 on failure
1835 * This function will take a chunk of data encoded by
1836 * eet_data_descriptor_encode() and convert it into human readable
1837 * ascii text. It does this by calling the @p dumpfunc callback
1838 * for all new text that is generated. This callback should append
1839 * to any existing text buffer and will be passed the pointer @p
1840 * dumpdata as a parameter as well as a string with new text to be
1846 * void output(void *data, const char *string)
1848 * printf("%s", string);
1851 * void dump(const char *file)
1857 * f = fopen(file, "r");
1858 * fseek(f, 0, SEEK_END);
1861 * data = malloc(len);
1862 * fread(data, len, 1, f);
1864 * eet_data_text_dump(data, len, output, NULL);
1868 * @see eet_data_text_dump_cipher()
1871 * @ingroup Eet_Data_Group
1873 EAPI int eet_data_text_dump(const void *data_in, int size_in, void (*dumpfunc) (void *data, const char *str), void *dumpdata);
1876 * Take an ascii encoding from eet_data_text_dump() and re-encode in binary.
1877 * @param text The pointer to the string data to parse and encode.
1878 * @param textlen The size of the string in bytes (not including 0
1880 * @param size_ret This gets filled in with the encoded data blob
1882 * @return The encoded data on success, NULL on failure.
1884 * This function will parse the string pointed to by @p text and return
1885 * an encoded data lump the same way eet_data_descriptor_encode() takes an
1886 * in-memory data struct and encodes into a binary blob. @p text is a normal
1889 * @see eet_data_text_undump_cipher()
1892 * @ingroup Eet_Data_Group
1894 EAPI void *eet_data_text_undump(const char *text, int textlen, int *size_ret);
1897 * Dump an eet encoded data structure from an eet file into ascii text
1898 * @param ef A valid eet file handle.
1899 * @param name Name of the entry. eg: "/base/file_i_want".
1900 * @param dumpfunc The function to call passed a string when new
1901 * data is converted to text
1902 * @param dumpdata The data to pass to the @p dumpfunc callback.
1903 * @return 1 on success, 0 on failure
1905 * This function will take an open and valid eet file from
1906 * eet_open() request the data encoded by
1907 * eet_data_descriptor_encode() corresponding to the key @p name
1908 * and convert it into human readable ascii text. It does this by
1909 * calling the @p dumpfunc callback for all new text that is
1910 * generated. This callback should append to any existing text
1911 * buffer and will be passed the pointer @p dumpdata as a parameter
1912 * as well as a string with new text to be appended.
1914 * @see eet_data_dump_cipher()
1917 * @ingroup Eet_Data_Group
1919 EAPI int eet_data_dump(Eet_File *ef, const char *name, void (*dumpfunc) (void *data, const char *str), void *dumpdata);
1922 * Take an ascii encoding from eet_data_dump() and re-encode in binary.
1923 * @param ef A valid eet file handle.
1924 * @param name Name of the entry. eg: "/base/file_i_want".
1925 * @param text The pointer to the string data to parse and encode.
1926 * @param textlen The size of the string in bytes (not including 0
1928 * @param compress Compression flags (1 == compress, 0 = don't compress).
1929 * @return 1 on success, 0 on failure
1931 * This function will parse the string pointed to by @p text,
1932 * encode it the same way eet_data_descriptor_encode() takes an
1933 * in-memory data struct and encodes into a binary blob.
1935 * The data (optionally compressed) will be in ram, pending a flush to
1936 * disk (it will stay in ram till the eet file handle is closed though).
1938 * @see eet_data_undump_cipher()
1941 * @ingroup Eet_Data_Group
1943 EAPI int eet_data_undump(Eet_File *ef, const char *name, const char *text, int textlen, int compress);
1946 * Decode a data structure from an arbitary location in memory.
1947 * @param edd The data descriptor to use when decoding.
1948 * @param data_in The pointer to the data to decode into a struct.
1949 * @param size_in The size of the data pointed to in bytes.
1950 * @return NULL on failure, or a valid decoded struct pointer on success.
1952 * This function will decode a data structure that has been encoded using
1953 * eet_data_descriptor_encode(), and return a data structure with all its
1954 * elements filled out, if successful, or NULL on failure.
1956 * The data to be decoded is stored at the memory pointed to by @p data_in,
1957 * and is described by the descriptor pointed to by @p edd. The data size is
1958 * passed in as the value to @p size_in, ande must be greater than 0 to
1961 * This function is useful for decoding data structures delivered to the
1962 * application by means other than an eet file, such as an IPC or socket
1963 * connection, raw files, shared memory etc.
1965 * Please see eet_data_read() for more information.
1967 * @see eet_data_descriptor_decode_cipher()
1970 * @ingroup Eet_Data_Group
1972 EAPI void *eet_data_descriptor_decode(Eet_Data_Descriptor *edd, const void *data_in, int size_in);
1975 * Encode a dsata struct to memory and return that encoded data.
1976 * @param edd The data descriptor to use when encoding.
1977 * @param data_in The pointer to the struct to encode into data.
1978 * @param size_ret pointer to the an int to be filled with the decoded size.
1979 * @return NULL on failure, or a valid encoded data chunk on success.
1981 * This function takes a data structutre in memory and encodes it into a
1982 * serialised chunk of data that can be decoded again by
1983 * eet_data_descriptor_decode(). This is useful for being able to transmit
1984 * data structures across sockets, pipes, IPC or shared file mechanisms,
1985 * without having to worry about memory space, machine type, endianess etc.
1987 * The parameter @p edd must point to a valid data descriptor, and
1988 * @p data_in must point to the right data structure to encode. If not, the
1989 * encoding may fail.
1991 * On success a non NULL valid pointer is returned and what @p size_ret
1992 * points to is set to the size of this decoded data, in bytes. When the
1993 * encoded data is no longer needed, call free() on it. On failure NULL is
1994 * returned and what @p size_ret points to is set to 0.
1996 * Please see eet_data_write() for more information.
1998 * @see eet_data_descriptor_encode_cipher()
2001 * @ingroup Eet_Data_Group
2003 EAPI void *eet_data_descriptor_encode(Eet_Data_Descriptor *edd, const void *data_in, int *size_ret);
2006 * Add a basic data element to a data descriptor.
2007 * @param edd The data descriptor to add the type to.
2008 * @param struct_type The type of the struct.
2009 * @param name The string name to use to encode/decode this member
2010 * (must be a constant global and never change).
2011 * @param member The struct member itself to be encoded.
2012 * @param type The type of the member to encode.
2014 * This macro is a convenience macro provided to add a member to
2015 * the data descriptor @p edd. The type of the structure is
2016 * provided as the @p struct_type parameter (for example: struct
2017 * my_struct). The @p name parameter defines a string that will be
2018 * used to uniquely name that member of the struct (it is suggested
2019 * to use the struct member itself). The @p member parameter is
2020 * the actual struct member itself (for eet_dictionary_string_check
2021 * example: values), and @p type is the basic data type of the
2022 * member which must be one of: EET_T_CHAR, EET_T_SHORT, EET_T_INT,
2023 * EET_T_LONG_LONG, EET_T_FLOAT, EET_T_DOUBLE, EET_T_UCHAR,
2024 * EET_T_USHORT, EET_T_UINT, EET_T_ULONG_LONG or EET_T_STRING.
2027 * @ingroup Eet_Data_Group
2029 #define EET_DATA_DESCRIPTOR_ADD_BASIC(edd, struct_type, name, member, type) \
2031 struct_type ___ett; \
2033 eet_data_descriptor_element_add(edd, name, type, EET_G_UNKNOWN, \
2034 (char *)(&(___ett.member)) - (char *)(&(___ett)), \
2035 0, /* 0, */NULL, NULL); \
2039 * Add a sub-element type to a data descriptor
2040 * @param edd The data descriptor to add the type to.
2041 * @param struct_type The type of the struct.
2042 * @param name The string name to use to encode/decode this member
2043 * (must be a constant global and never change).
2044 * @param member The struct member itself to be encoded.
2045 * @param subtype The type of sub-type struct to add.
2047 * This macro lets you easily add a sub-type (a struct that's pointed to
2048 * by this one). All the parameters are the same as for
2049 * EET_DATA_DESCRIPTOR_ADD_BASIC(), with the @p subtype being the exception.
2050 * This must be the data descriptor of the struct that is pointed to by
2054 * @ingroup Eet_Data_Group
2056 #define EET_DATA_DESCRIPTOR_ADD_SUB(edd, struct_type, name, member, subtype) \
2058 struct_type ___ett; \
2060 eet_data_descriptor_element_add(edd, name, EET_T_UNKNOW, EET_G_UNKNOWN, \
2061 (char *)(&(___ett.member)) - (char *)(&(___ett)), \
2062 0, /* 0, */NULL, subtype); \
2066 * Add a linked list type to a data descriptor
2067 * @param edd The data descriptor to add the type to.
2068 * @param struct_type The type of the struct.
2069 * @param name The string name to use to encode/decode this member
2070 * (must be a constant global and never change).
2071 * @param member The struct member itself to be encoded.
2072 * @param subtype The type of linked list member to add.
2074 * This macro lets you easily add a linked list of other data types. All the
2075 * parameters are the same as for EET_DATA_DESCRIPTOR_ADD_BASIC(), with the
2076 * @p subtype being the exception. This must be the data descriptor of the
2077 * element that is in each member of the linked list to be stored.
2080 * @ingroup Eet_Data_Group
2082 #define EET_DATA_DESCRIPTOR_ADD_LIST(edd, struct_type, name, member, subtype) \
2084 struct_type ___ett; \
2086 eet_data_descriptor_element_add(edd, name, EET_T_UNKNOW, EET_G_LIST, \
2087 (char *)(&(___ett.member)) - (char *)(&(___ett)), \
2088 0, /* 0, */NULL, subtype); \
2092 * Add a hash type to a data descriptor
2093 * @param edd The data descriptor to add the type to.
2094 * @param struct_type The type of the struct.
2095 * @param name The string name to use to encode/decode this member
2096 * (must be a constant global and never change).
2097 * @param member The struct member itself to be encoded.
2098 * @param subtype The type of hash member to add.
2100 * This macro lets you easily add a hash of other data types. All the
2101 * parameters are the same as for EET_DATA_DESCRIPTOR_ADD_BASIC(), with the
2102 * @p subtype being the exception. This must be the data descriptor of the
2103 * element that is in each member of the hash to be stored.
2106 * @ingroup Eet_Data_Group
2108 #define EET_DATA_DESCRIPTOR_ADD_HASH(edd, struct_type, name, member, subtype) \
2110 struct_type ___ett; \
2112 eet_data_descriptor_element_add(edd, name, EET_T_UNKNOW, EET_G_HASH, \
2113 (char *)(&(___ett.member)) - (char *)(&(___ett)), \
2114 0, /* 0, */NULL, subtype); \
2118 * Add a fixed size array type to a data descriptor
2119 * @param edd The data descriptor to add the type to.
2120 * @param struct_type The type of the struct.
2121 * @param name The string name to use to encode/decode this member
2122 * (must be a constant global and never change).
2123 * @param member The struct member itself to be encoded.
2124 * @param subtype The type of hash member to add.
2126 * This macro lets you easily add a fixed size array of other data
2127 * types. All the parameters are the same as for
2128 * EET_DATA_DESCRIPTOR_ADD_BASIC(), with the @p subtype being the
2129 * exception. This must be the data descriptor of the element that
2130 * is in each member of the hash to be stored.
2133 * @ingroup Eet_Data_Group
2135 #define EET_DATA_DESCRIPTOR_ADD_ARRAY(edd, struct_type, name, member, subtype) \
2137 struct_type ___ett; \
2139 eet_data_descriptor_element_add(edd, name, EET_T_UNKNOW, EET_G_ARRAY, \
2140 (char *)(&(___ett.member)) - (char *)(&(___ett)), \
2141 /* 0, */sizeof(___ett.member)/sizeof(___ett.member[0]), NULL, subtype); \
2145 * Add a variable size array type to a data descriptor
2146 * @param edd The data descriptor to add the type to.
2147 * @param struct_type The type of the struct.
2148 * @param name The string name to use to encode/decode this member
2149 * (must be a constant global and never change).
2150 * @param member The struct member itself to be encoded.
2151 * @param subtype The type of hash member to add.
2153 * This macro lets you easily add a fixed size array of other data
2154 * types. All the parameters are the same as for
2155 * EET_DATA_DESCRIPTOR_ADD_BASIC(), with the @p subtype being the
2156 * exception. This must be the data descriptor of the element that
2157 * is in each member of the hash to be stored.
2160 * @ingroup Eet_Data_Group
2162 #define EET_DATA_DESCRIPTOR_ADD_VAR_ARRAY(edd, struct_type, name, member, subtype) \
2164 struct_type ___ett; \
2166 eet_data_descriptor_element_add(edd, name, EET_T_UNKNOW, EET_G_VAR_ARRAY, \
2167 (char *)(&(___ett.member)) - (char *)(&(___ett)), \
2168 (char *)(&(___ett.member ## _count)) - (char *)(&(___ett)), /* 0, */NULL, subtype); \
2172 * Add an union type to a data descriptor
2173 * @param edd The data descriptor to add the type to.
2174 * @param struct_type The type of the struct.
2175 * @param name The string name to use to encode/decode this member
2176 * (must be a constant global and never change).
2177 * @param member The struct member itself to be encoded.
2178 * @param type_member The member that give hints on what is in the union.
2179 * @param unified_type Describe all possible type the union could handle.
2181 * This macro lets you easily add an union with a member that specify what is inside.
2182 * The @p unified_type is an Eet_Data_Descriptor, but only the entry that match the name
2183 * returned by type_get will be used for each serialized data. The type_get and type_set
2184 * callback of unified_type should be defined.
2187 * @ingroup Eet_Data_Group
2188 * @see Eet_Data_Descriptor_Class
2190 #define EET_DATA_DESCRIPTOR_ADD_UNION(edd, struct_type, name, member, type_member, unified_type) \
2192 struct_type ___ett; \
2194 eet_data_descriptor_element_add(edd, name, EET_T_UNKNOW, EET_G_UNION, \
2195 (char *) (&(___ett.member)) - (char *)(&(___ett)), \
2196 (char *) (&(___ett.type_member)) - (char *)(&(___ett)), \
2197 NULL, unified_type); \
2201 * Add a automatically selectable type to a data descriptor
2202 * @param edd The data descriptor to add the type to.
2203 * @param struct_type The type of the struct.
2204 * @param name The string name to use to encode/decode this member
2205 * (must be a constant global and never change).
2206 * @param member The struct member itself to be encoded.
2207 * @param type_member The member that give hints on what is in the union.
2208 * @param unified_type Describe all possible type the union could handle.
2210 * This macro lets you easily define what the content of @p member points to depending of
2211 * the content of @p type_member. The type_get and type_set callback of unified_type should
2212 * be defined. If the the type is not know at the time of restoring it, eet will still call
2213 * type_set of @p unified_type but the pointer will be set to a serialized binary representation
2214 * of what eet know. This make it possible, to save this pointer again by just returning the string
2215 * given previously and telling it by setting unknow to EINA_TRUE.
2218 * @ingroup Eet_Data_Group
2219 * @see Eet_Data_Descriptor_Class
2221 #define EET_DATA_DESCRIPTOR_ADD_VARIANT(edd, struct_type, name, member, type_member, unified_type) \
2223 struct_type ___ett; \
2225 eet_data_descriptor_element_add(edd, name, EET_T_UNKNOW, EET_G_VARIANT, \
2226 (char *) (&(___ett.member)) - (char *)(&(___ett)), \
2227 (char *) (&(___ett.type_member)) - (char *)(&(___ett)), \
2228 NULL, unified_type); \
2232 * Add a mapping to a data descriptor that will be used by union, variant or inherited type
2233 * @param unified_type The data descriptor to add the mapping to.
2234 * @param name The string name to get/set type.
2235 * @param subtype The matching data descriptor.
2238 * @ingroup Eet_Data_Group
2239 * @see Eet_Data_Descriptor_Class
2241 #define EET_DATA_DESCRIPTOR_ADD_MAPPING(unified_type, name, subtype) \
2242 eet_data_descriptor_element_add(unified_type, name, EET_T_UNKNOW, EET_G_UNKNOWN, 0, 0, NULL, subtype);
2245 * @defgroup Eet_Data_Cipher_Group Eet Data Serialization using A Ciphers
2247 * Most of the @ref Eet_Data_Group have alternative versions that
2248 * accounts for ciphers to protect their content.
2250 * @see @ref Eet_Cipher_Group
2252 * @ingroup Eet_Data_Group
2256 * Read a data structure from an eet file and decodes it using a cipher.
2257 * @param ef The eet file handle to read from.
2258 * @param edd The data descriptor handle to use when decoding.
2259 * @param name The key the data is stored under in the eet file.
2260 * @param cipher_key The key to use as cipher.
2261 * @return A pointer to the decoded data structure.
2263 * This function decodes a data structure stored in an eet file, returning
2264 * a pointer to it if it decoded successfully, or NULL on failure. This
2265 * can save a programmer dozens of hours of work in writing configuration
2266 * file parsing and writing code, as eet does all that work for the program
2267 * and presents a program-friendly data structure, just as the programmer
2268 * likes. Eet can handle members being added or deleted from the data in
2269 * storage and safely zero-fills unfilled members if they were not found
2270 * in the data. It checks sizes and headers whenever it reads data, allowing
2271 * the programmer to not worry about corrupt data.
2273 * Once a data structure has been described by the programmer with the
2274 * fields they wish to save or load, storing or retrieving a data structure
2275 * from an eet file, or from a chunk of memory is as simple as a single
2278 * @see eet_data_read()
2281 * @ingroup Eet_Data_Cipher_Group
2283 EAPI void *eet_data_read_cipher(Eet_File *ef, Eet_Data_Descriptor *edd, const char *name, const char *cipher_key);
2286 * Write a data structure from memory and store in an eet file
2288 * @param ef The eet file handle to write to.
2289 * @param edd The data descriptor to use when encoding.
2290 * @param name The key to store the data under in the eet file.
2291 * @param cipher_key The key to use as cipher.
2292 * @param data A pointer to the data structure to ssave and encode.
2293 * @param compress Compression flags for storage.
2294 * @return bytes written on successful write, 0 on failure.
2296 * This function is the reverse of eet_data_read(), saving a data structure
2299 * @see eet_data_write_cipher()
2302 * @ingroup Eet_Data_Cipher_Group
2304 EAPI int eet_data_write_cipher(Eet_File *ef, Eet_Data_Descriptor *edd, const char *name, const char *cipher_key, const void *data, int compress);
2307 * Dump an eet encoded data structure into ascii text using a cipher.
2308 * @param data_in The pointer to the data to decode into a struct.
2309 * @param cipher_key The key to use as cipher.
2310 * @param size_in The size of the data pointed to in bytes.
2311 * @param dumpfunc The function to call passed a string when new
2312 * data is converted to text
2313 * @param dumpdata The data to pass to the @p dumpfunc callback.
2314 * @return 1 on success, 0 on failure
2316 * This function will take a chunk of data encoded by
2317 * eet_data_descriptor_encode() and convert it into human readable
2318 * ascii text. It does this by calling the @p dumpfunc callback
2319 * for all new text that is generated. This callback should append
2320 * to any existing text buffer and will be passed the pointer @p
2321 * dumpdata as a parameter as well as a string with new text to be
2327 * void output(void *data, const char *string)
2329 * printf("%s", string);
2332 * void dump(const char *file)
2338 * f = fopen(file, "r");
2339 * fseek(f, 0, SEEK_END);
2342 * data = malloc(len);
2343 * fread(data, len, 1, f);
2345 * eet_data_text_dump_cipher(data, cipher_key, len, output, NULL);
2349 * @see eet_data_text_dump()
2352 * @ingroup Eet_Data_Cipher_Group
2354 EAPI int eet_data_text_dump_cipher(const void *data_in, const char *cipher_key, int size_in, void (*dumpfunc) (void *data, const char *str), void *dumpdata);
2357 * Take an ascii encoding from eet_data_text_dump() and re-encode
2358 * in binary using a cipher.
2359 * @param text The pointer to the string data to parse and encode.
2360 * @param cipher_key The key to use as cipher.
2361 * @param textlen The size of the string in bytes (not including 0
2363 * @param size_ret This gets filled in with the encoded data blob
2365 * @return The encoded data on success, NULL on failure.
2367 * This function will parse the string pointed to by @p text and return
2368 * an encoded data lump the same way eet_data_descriptor_encode() takes an
2369 * in-memory data struct and encodes into a binary blob. @p text is a normal
2372 * @see eet_data_text_undump()
2375 * @ingroup Eet_Data_Cipher_Group
2377 EAPI void *eet_data_text_undump_cipher(const char *text, const char *cipher_key, int textlen, int *size_ret);
2380 * Dump an eet encoded data structure from an eet file into ascii
2381 * text using a cipher.
2382 * @param ef A valid eet file handle.
2383 * @param name Name of the entry. eg: "/base/file_i_want".
2384 * @param cipher_key The key to use as cipher.
2385 * @param dumpfunc The function to call passed a string when new
2386 * data is converted to text
2387 * @param dumpdata The data to pass to the @p dumpfunc callback.
2388 * @return 1 on success, 0 on failure
2390 * This function will take an open and valid eet file from
2391 * eet_open() request the data encoded by
2392 * eet_data_descriptor_encode() corresponding to the key @p name
2393 * and convert it into human readable ascii text. It does this by
2394 * calling the @p dumpfunc callback for all new text that is
2395 * generated. This callback should append to any existing text
2396 * buffer and will be passed the pointer @p dumpdata as a parameter
2397 * as well as a string with new text to be appended.
2399 * @see eet_data_dump()
2402 * @ingroup Eet_Data_Cipher_Group
2404 EAPI int eet_data_dump_cipher(Eet_File *ef, const char *name, const char *cipher_key, void (*dumpfunc) (void *data, const char *str), void *dumpdata);
2407 * Take an ascii encoding from eet_data_dump() and re-encode in
2408 * binary using a cipher.
2409 * @param ef A valid eet file handle.
2410 * @param name Name of the entry. eg: "/base/file_i_want".
2411 * @param cipher_key The key to use as cipher.
2412 * @param text The pointer to the string data to parse and encode.
2413 * @param textlen The size of the string in bytes (not including 0
2415 * @param compress Compression flags (1 == compress, 0 = don't compress).
2416 * @return 1 on success, 0 on failure
2418 * This function will parse the string pointed to by @p text,
2419 * encode it the same way eet_data_descriptor_encode() takes an
2420 * in-memory data struct and encodes into a binary blob.
2422 * The data (optionally compressed) will be in ram, pending a flush to
2423 * disk (it will stay in ram till the eet file handle is closed though).
2425 * @see eet_data_undump()
2428 * @ingroup Eet_Data_Cipher_Group
2430 EAPI int eet_data_undump_cipher(Eet_File *ef, const char *name, const char *cipher_key, const char *text, int textlen, int compress);
2433 * Decode a data structure from an arbitary location in memory
2435 * @param edd The data descriptor to use when decoding.
2436 * @param data_in The pointer to the data to decode into a struct.
2437 * @param cipher_key The key to use as cipher.
2438 * @param size_in The size of the data pointed to in bytes.
2439 * @return NULL on failure, or a valid decoded struct pointer on success.
2441 * This function will decode a data structure that has been encoded using
2442 * eet_data_descriptor_encode(), and return a data structure with all its
2443 * elements filled out, if successful, or NULL on failure.
2445 * The data to be decoded is stored at the memory pointed to by @p data_in,
2446 * and is described by the descriptor pointed to by @p edd. The data size is
2447 * passed in as the value to @p size_in, ande must be greater than 0 to
2450 * This function is useful for decoding data structures delivered to the
2451 * application by means other than an eet file, such as an IPC or socket
2452 * connection, raw files, shared memory etc.
2454 * Please see eet_data_read() for more information.
2456 * @see eet_data_descriptor_decode()
2459 * @ingroup Eet_Data_Cipher_Group
2461 EAPI void *eet_data_descriptor_decode_cipher(Eet_Data_Descriptor *edd, const void *data_in, const char *cipher_key, int size_in);
2464 * Encode a data struct to memory and return that encoded data
2466 * @param edd The data descriptor to use when encoding.
2467 * @param data_in The pointer to the struct to encode into data.
2468 * @param cipher_key The key to use as cipher.
2469 * @param size_ret pointer to the an int to be filled with the decoded size.
2470 * @return NULL on failure, or a valid encoded data chunk on success.
2472 * This function takes a data structutre in memory and encodes it into a
2473 * serialised chunk of data that can be decoded again by
2474 * eet_data_descriptor_decode(). This is useful for being able to transmit
2475 * data structures across sockets, pipes, IPC or shared file mechanisms,
2476 * without having to worry about memory space, machine type, endianess etc.
2478 * The parameter @p edd must point to a valid data descriptor, and
2479 * @p data_in must point to the right data structure to encode. If not, the
2480 * encoding may fail.
2482 * On success a non NULL valid pointer is returned and what @p size_ret
2483 * points to is set to the size of this decoded data, in bytes. When the
2484 * encoded data is no longer needed, call free() on it. On failure NULL is
2485 * returned and what @p size_ret points to is set to 0.
2487 * Please see eet_data_write() for more information.
2489 * @see eet_data_descriptor_encode()
2492 * @ingroup Eet_Data_Cipher_Group
2494 EAPI void *eet_data_descriptor_encode_cipher(Eet_Data_Descriptor *edd, const void *data_in, const char *cipher_key, int *size_ret);
2497 * @defgroup Eet_Node_Group Low-level Serialization Structures.
2499 * Functions that create, destroy and manipulate serialization nodes
2500 * used by @ref Eet_Data_Group.
2507 * Opaque handle to manage serialization node.
2509 typedef struct _Eet_Node Eet_Node;
2512 * @typedef Eet_Node_Data
2513 * Contains an union that can fit any kind of node.
2515 typedef struct _Eet_Node_Data Eet_Node_Data;
2518 * @struct _Eet_Node_Data
2519 * Contains an union that can fit any kind of node.
2521 struct _Eet_Node_Data
2533 unsigned long long ul;
2544 * @ingroup Eet_Node_Group
2546 EAPI Eet_Node *eet_node_char_new(const char *name, char c);
2550 * @ingroup Eet_Node_Group
2552 EAPI Eet_Node *eet_node_short_new(const char *name, short s);
2556 * @ingroup Eet_Node_Group
2558 EAPI Eet_Node *eet_node_int_new(const char *name, int i);
2562 * @ingroup Eet_Node_Group
2564 EAPI Eet_Node *eet_node_long_long_new(const char *name, long long l);
2568 * @ingroup Eet_Node_Group
2570 EAPI Eet_Node *eet_node_float_new(const char *name, float f);
2574 * @ingroup Eet_Node_Group
2576 EAPI Eet_Node *eet_node_double_new(const char *name, double d);
2580 * @ingroup Eet_Node_Group
2582 EAPI Eet_Node *eet_node_unsigned_char_new(const char *name, unsigned char uc);
2586 * @ingroup Eet_Node_Group
2588 EAPI Eet_Node *eet_node_unsigned_short_new(const char *name, unsigned short us);
2592 * @ingroup Eet_Node_Group
2594 EAPI Eet_Node *eet_node_unsigned_int_new(const char *name, unsigned int ui);
2598 * @ingroup Eet_Node_Group
2600 EAPI Eet_Node *eet_node_unsigned_long_long_new(const char *name, unsigned long long l);
2604 * @ingroup Eet_Node_Group
2606 EAPI Eet_Node *eet_node_string_new(const char *name, const char *str);
2610 * @ingroup Eet_Node_Group
2612 EAPI Eet_Node *eet_node_inlined_string_new(const char *name, const char *str);
2616 * @ingroup Eet_Node_Group
2618 EAPI Eet_Node *eet_node_null_new(const char *name);
2622 * @ingroup Eet_Node_Group
2624 EAPI Eet_Node *eet_node_list_new(const char *name, Eina_List *nodes);
2628 * @ingroup Eet_Node_Group
2630 EAPI Eet_Node *eet_node_array_new(const char *name, int count, Eina_List *nodes);
2634 * @ingroup Eet_Node_Group
2636 EAPI Eet_Node *eet_node_var_array_new(const char *name, Eina_List *nodes);
2640 * @ingroup Eet_Node_Group
2642 EAPI Eet_Node *eet_node_hash_new(const char *name, const char *key, Eet_Node *node);
2646 * @ingroup Eet_Node_Group
2648 EAPI Eet_Node *eet_node_struct_new(const char *name, Eina_List *nodes);
2652 * @ingroup Eet_Node_Group
2654 EAPI Eet_Node *eet_node_struct_child_new(const char *parent, Eet_Node *child);
2659 * @ingroup Eet_Node_Group
2661 EAPI void eet_node_list_append(Eet_Node *parent, const char *name, Eet_Node *child);
2665 * @ingroup Eet_Node_Group
2667 EAPI void eet_node_struct_append(Eet_Node *parent, const char *name, Eet_Node *child);
2671 * @ingroup Eet_Node_Group
2673 EAPI void eet_node_hash_add(Eet_Node *parent, const char *name, const char *key, Eet_Node *child);
2678 * @ingroup Eet_Node_Group
2680 EAPI void eet_node_dump(Eet_Node *n, int dumplevel, void (*dumpfunc) (void *data, const char *str), void *dumpdata);
2684 * @ingroup Eet_Node_Group
2686 EAPI void eet_node_del(Eet_Node *n);
2690 * @ingroup Eet_Node_Group
2692 EAPI void *eet_data_node_encode_cipher(Eet_Node *node, const char *cipher_key, int *size_ret);
2696 * @ingroup Eet_Node_Group
2698 EAPI Eet_Node *eet_data_node_decode_cipher(const void *data_in, const char *cipher_key, int size_in);
2702 * @ingroup Eet_Node_Group
2704 EAPI Eet_Node *eet_data_node_read_cipher(Eet_File *ef, const char *name, const char *cipher_key);
2708 * @ingroup Eet_Node_Group
2710 EAPI int eet_data_node_write_cipher(Eet_File *ef, const char *name, const char *cipher_key, Eet_Node *node, int compress);
2712 /* EXPERIMENTAL: THIS API MAY CHANGE IN THE FUTURE, USE IT ONLY IF YOU KNOW WHAT YOU ARE DOING. */
2715 * @typedef Eet_Node_Walk
2716 * Describes how to walk trees of #Eet_Node.
2718 typedef struct _Eet_Node_Walk Eet_Node_Walk;
2721 * @struct _Eet_Node_Walk
2722 * Describes how to walk trees of #Eet_Node.
2724 struct _Eet_Node_Walk
2726 void *(*struct_alloc)(const char *type, void *user_data);
2727 void (*struct_add)(void *parent, const char *name, void *child, void *user_data);
2728 void *(*array)(Eina_Bool variable, const char *name, int count, void *user_data);
2729 void (*insert)(void *array, int index, void *child, void *user_data);
2730 void *(*list)(const char *name, void *user_data);
2731 void (*append)(void *list, void *child, void *user_data);
2732 void *(*hash)(void *parent, const char *name, const char *key, void *value, void *user_data);
2733 void *(*simple)(int type, Eet_Node_Data *data, void *user_data);
2736 EAPI void *eet_node_walk(void *parent, const char *name, Eet_Node *root, Eet_Node_Walk *cb, void *user_data);
2741 * @defgroup Eet_Connection_Group Helper function to use eet over a network link
2743 * Function that reconstruct and prepare packet of @ref Eet_Data_Group to be send.
2748 * @typedef Eet_Connection
2749 * Opaque handle to track paquet for a specific connection.
2751 * @ingroup Eet_Connection_Group
2753 typedef struct _Eet_Connection Eet_Connection;
2756 * @typedef Eet_Read_Cb
2757 * Called back when an @ref Eet_Data_Group has been received completly and could be used.
2759 * @ingroup Eet_Connection_Group
2761 typedef Eina_Bool Eet_Read_Cb(const void *eet_data, size_t size, void *user_data);
2764 * @typedef Eet_Write_Cb
2765 * Called back when a packet containing @ref Eet_Data_Group data is ready to be send.
2767 * @ingroup Eet_Connection_Group
2769 typedef Eina_Bool Eet_Write_Cb(const void *data, size_t size, void *user_data);
2772 * Instanciate a new connection to track.
2773 * @oaram eet_read_cb Function to call when one Eet_Data packet has been fully assemble.
2774 * @param eet_write_cb Function to call when one Eet_Data packet is ready to be send over the wire.
2775 * @param user_data Pointer provided to both functions to be used as a context handler.
2776 * @return NULL on failure, or a valid Eet_Connection handler.
2778 * For every connection to track you will need a separate Eet_Connection provider.
2781 * @ingroup Eet_Connection_Group
2783 Eet_Connection *eet_connection_new(Eet_Read_Cb *eet_read_cb, Eet_Write_Cb *eet_write_cb, const void *user_data);
2786 * Process a raw packet received over the link
2787 * @oaram conn Connection handler to track.
2788 * @param data Raw data packet.
2789 * @param size The size of that packet.
2790 * @return 0 on complete success, any other value indicate where in the stream it got wrong (It could be before that packet).
2792 * Every time you receive a packet related to your connection, you should pass
2793 * it to that function so that it could process and assemble packet has you
2794 * receive it. It will automatically call Eet_Read_Cb when one is fully received.
2797 * @ingroup Eet_Connection_Group
2799 int eet_connection_received(Eet_Connection *conn, const void *data, size_t size);
2802 * Convert a complex structure and prepare it to be send.
2803 * @oaram conn Connection handler to track.
2804 * @param edd The data descriptor to use when encoding.
2805 * @param data_in The pointer to the struct to encode into data.
2806 * @param cipher_key The key to use as cipher.
2807 * @return EINA_TRUE if the data where correctly send, EINA_FALSE if they don't.
2809 * This function serialize data_in with edd, assemble the packet and call
2810 * Eet_Write_Cb when ready. The data passed Eet_Write_Cb are temporary allocated
2811 * and will vanish just after the return of the callback.
2813 * @see eet_data_descriptor_encode_cipher
2816 * @ingroup Eet_Connection_Group
2818 Eina_Bool eet_connection_send(Eet_Connection *conn, Eet_Data_Descriptor *edd, const void *data_in, const char *cipher_key);
2821 * Convert a Eet_Node tree and prepare it to be send.
2822 * @oaram conn Connection handler to track.
2823 * @param node The data tree to use when encoding.
2824 * @param cipher_key The key to use as cipher.
2825 * @return EINA_TRUE if the data where correctly send, EINA_FALSE if they don't.
2827 * This function serialize node, assemble the packet and call
2828 * Eet_Write_Cb when ready. The data passed Eet_Write_Cb are temporary allocated
2829 * and will vanish just after the return of the callback.
2831 * @see eet_data_node_encode_cipher
2834 * @ingroup Eet_Connection_Group
2836 Eina_Bool eet_connection_node_send(Eet_Connection *conn, Eet_Node *node, const char *cipher_key);
2839 * Close a connection and lost its track.
2840 * @oaram conn Connection handler to close.
2841 * @param on_going Signal if a partial packet wasn't completed.
2842 * @return the user_data passed to both callback.
2845 * @ingroup Eet_Connection_Group
2847 void *eet_connection_close(Eet_Connection *conn, Eina_Bool *on_going);
2849 /***************************************************************************/