3 #endif /* ifdef HAVE_CONFIG_H */
11 #ifdef HAVE_NETINET_IN_H
12 # include <netinet/in.h>
13 #endif /* ifdef HAVE_NETINET_IN_H */
16 # include <winsock2.h>
17 #endif /* ifdef _WIN32 */
22 #include "Eet_private.h"
25 * routines for doing data -> struct and struct -> data conversion
45 * multiple entries ordered as...
47 * fixed size array [ of basic types ]
48 * variable size array [ of basic types ]
49 * linked list [ of basic types ]
50 * hash table [ of basic types ]
52 * need to provide builder/accessor funcs for:
64 typedef struct _Eet_Data_Element Eet_Data_Element;
65 typedef struct _Eet_Data_Basic_Type_Codec Eet_Data_Basic_Type_Codec;
66 typedef struct _Eet_Data_Group_Type_Codec Eet_Data_Group_Type_Codec;
67 typedef struct _Eet_Data_Chunk Eet_Data_Chunk;
68 typedef struct _Eet_Data_Stream Eet_Data_Stream;
69 typedef struct _Eet_Data_Descriptor_Hash Eet_Data_Descriptor_Hash;
70 typedef struct _Eet_Data_Encode_Hash_Info Eet_Data_Encode_Hash_Info;
71 typedef struct _Eet_Free Eet_Free;
72 typedef struct _Eet_Free_Context Eet_Free_Context;
73 typedef struct _Eet_Variant_Unknow Eet_Variant_Unknow;
78 * Eet_Data_Basic_Type_Codec (Coder, Decoder)
79 * Eet_Data_Group_Type_Codec (Coder, Decoder)
81 struct _Eet_Data_Basic_Type_Codec
85 int (*get)(const Eet_Dictionary *ed, const void *src, const void *src_end, void *dest);
86 void * (*put)(Eet_Dictionary *ed, const void *src, int *size_ret);
89 struct _Eet_Data_Group_Type_Codec
91 int (*get)(Eet_Free_Context *context, const Eet_Dictionary *ed, Eet_Data_Descriptor *edd, Eet_Data_Element *ede, Eet_Data_Chunk *echnk, int type, int group_type, void *data_in, char **p, int *size);
92 void (*put)(Eet_Dictionary *ed, Eet_Data_Descriptor *edd, Eet_Data_Element *ede, Eet_Data_Stream *ds, void *data_in);
95 struct _Eet_Data_Chunk
103 unsigned char group_type;
106 struct _Eet_Data_Stream
113 struct _Eet_Data_Descriptor_Hash
115 Eet_Data_Element *element;
116 Eet_Data_Descriptor_Hash *next;
119 struct _Eet_Data_Descriptor
122 const Eet_Dictionary *ed;
126 void * (*mem_alloc)(size_t size);
127 void (*mem_free)(void *mem);
128 char * (*str_alloc)(const char *str);
129 char * (*str_direct_alloc)(const char *str);
130 void (*str_free)(const char *str);
131 void (*str_direct_free)(const char *str);
132 void * (*list_next)(void *l);
133 void * (*list_append)(void *l, void *d);
134 void * (*list_data)(void *l);
135 void * (*list_free)(void *l);
136 void (*hash_foreach)(void *h, int (*func)(void *h, const char *k, void *dt, void *fdt), void *fdt);
137 void * (*hash_add)(void *h, const char *k, void *d);
138 void (*hash_free)(void *h);
139 const char *(*type_get)(const void *data, Eina_Bool *unknow);
140 Eina_Bool (*type_set)(const char *type, void *data, Eina_Bool unknow);
141 void * (*array_alloc)(size_t size);
142 void (*array_free)(void *mem);
147 Eet_Data_Element *set;
151 Eet_Data_Descriptor_Hash *buckets;
155 Eina_Bool unified_type : 1;
160 struct _Eet_Data_Element
163 const char *counter_name;
164 const char *directory_name_ptr;
165 Eet_Data_Descriptor *subtype;
166 int offset; /* offset in bytes from the base element */
167 int count; /* number of elements for a fixed array */
168 int counter_offset; /* for a variable array we need the offset of the count variable */
169 unsigned char type; /* EET_T_XXX */
170 unsigned char group_type; /* EET_G_XXX */
173 struct _Eet_Data_Encode_Hash_Info
176 Eet_Data_Element *ede;
180 #define EET_FREE_COUNT 256
184 Eina_Array list[EET_FREE_COUNT];
187 struct _Eet_Free_Context
190 Eet_Free freelist_array;
191 Eet_Free freelist_list;
192 Eet_Free freelist_hash;
193 Eet_Free freelist_str;
194 Eet_Free freelist_direct_str;
197 struct _Eet_Variant_Unknow
207 static void eet_free_context_init(Eet_Free_Context *context);
208 static void eet_free_context_shutdown(Eet_Free_Context *context);
210 static int eet_data_get_char(const Eet_Dictionary *ed,
214 static void * eet_data_put_char(Eet_Dictionary *ed,
217 static int eet_data_get_short(const Eet_Dictionary *ed,
221 static void * eet_data_put_short(Eet_Dictionary *ed,
224 static inline int eet_data_get_int(const Eet_Dictionary *ed,
228 static void * eet_data_put_int(Eet_Dictionary *ed,
231 static int eet_data_get_long_long(const Eet_Dictionary *ed,
235 static void * eet_data_put_long_long(Eet_Dictionary *ed,
238 static int eet_data_get_float(const Eet_Dictionary *ed,
242 static void * eet_data_put_float(Eet_Dictionary *ed,
245 static int eet_data_get_double(const Eet_Dictionary *ed,
249 static void * eet_data_put_double(Eet_Dictionary *ed,
252 static int eet_data_get_f32p32(const Eet_Dictionary *ed,
256 static void * eet_data_put_f32p32(Eet_Dictionary *ed,
259 static int eet_data_get_f16p16(const Eet_Dictionary *ed,
263 static void * eet_data_put_f16p16(Eet_Dictionary *ed,
266 static int eet_data_get_f8p24(const Eet_Dictionary *ed,
270 static void * eet_data_put_f8p24(Eet_Dictionary *ed,
273 static inline int eet_data_get_string(const Eet_Dictionary *ed,
277 static void * eet_data_put_string(Eet_Dictionary *ed,
280 static int eet_data_get_istring(const Eet_Dictionary *ed,
284 static void * eet_data_put_istring(Eet_Dictionary *ed,
287 static int eet_data_get_null(const Eet_Dictionary *ed,
291 static void * eet_data_put_null(Eet_Dictionary *ed,
295 static int eet_data_get_type(const Eet_Dictionary *ed,
300 static void * eet_data_put_type(Eet_Dictionary *ed,
305 static Eet_Node * eet_data_node_simple_type(int type,
309 static int eet_data_get_unknown(Eet_Free_Context *context,
310 const Eet_Dictionary *ed,
311 Eet_Data_Descriptor *edd,
312 Eet_Data_Element *ede,
313 Eet_Data_Chunk *echnk,
319 static void eet_data_put_unknown(Eet_Dictionary *ed,
320 Eet_Data_Descriptor *edd,
321 Eet_Data_Element *ede,
324 static void eet_data_put_array(Eet_Dictionary *ed,
325 Eet_Data_Descriptor *edd,
326 Eet_Data_Element *ede,
329 static int eet_data_get_array(Eet_Free_Context *context,
330 const Eet_Dictionary *ed,
331 Eet_Data_Descriptor *edd,
332 Eet_Data_Element *ede,
333 Eet_Data_Chunk *echnk,
339 static int eet_data_get_list(Eet_Free_Context *context,
340 const Eet_Dictionary *ed,
341 Eet_Data_Descriptor *edd,
342 Eet_Data_Element *ede,
343 Eet_Data_Chunk *echnk,
349 static void eet_data_put_list(Eet_Dictionary *ed,
350 Eet_Data_Descriptor *edd,
351 Eet_Data_Element *ede,
354 static void eet_data_put_hash(Eet_Dictionary *ed,
355 Eet_Data_Descriptor *edd,
356 Eet_Data_Element *ede,
359 static int eet_data_get_hash(Eet_Free_Context *context,
360 const Eet_Dictionary *ed,
361 Eet_Data_Descriptor *edd,
362 Eet_Data_Element *ede,
363 Eet_Data_Chunk *echnk,
369 static void eet_data_put_union(Eet_Dictionary *ed,
370 Eet_Data_Descriptor *edd,
371 Eet_Data_Element *ede,
374 static int eet_data_get_union(Eet_Free_Context *context,
375 const Eet_Dictionary *ed,
376 Eet_Data_Descriptor *edd,
377 Eet_Data_Element *ede,
378 Eet_Data_Chunk *echnk,
384 static void eet_data_put_variant(Eet_Dictionary *ed,
385 Eet_Data_Descriptor *edd,
386 Eet_Data_Element *ede,
389 static int eet_data_get_variant(Eet_Free_Context *context,
390 const Eet_Dictionary *ed,
391 Eet_Data_Descriptor *edd,
392 Eet_Data_Element *ede,
393 Eet_Data_Chunk *echnk,
400 static void eet_data_chunk_get(const Eet_Dictionary *ed,
401 Eet_Data_Chunk *chnk,
404 static Eet_Data_Chunk * eet_data_chunk_new(void *data,
409 static void eet_data_chunk_free(Eet_Data_Chunk *chnk);
411 static Eet_Data_Stream * eet_data_stream_new(void);
412 static void eet_data_stream_write(Eet_Data_Stream *ds,
415 static void eet_data_stream_free(Eet_Data_Stream *ds);
417 static void eet_data_chunk_put(Eet_Dictionary *ed,
418 Eet_Data_Chunk *chnk,
419 Eet_Data_Stream *ds);
421 static int eet_data_descriptor_encode_hash_cb(void *hash,
425 static void * _eet_data_descriptor_encode(Eet_Dictionary *ed,
426 Eet_Data_Descriptor *edd,
429 static void * _eet_data_descriptor_decode(Eet_Free_Context *context,
430 const Eet_Dictionary *ed,
431 Eet_Data_Descriptor *edd,
439 static const Eet_Data_Basic_Type_Codec eet_basic_codec[] =
441 {sizeof(char), "char", eet_data_get_char, eet_data_put_char },
442 {sizeof(short), "short", eet_data_get_short, eet_data_put_short },
443 {sizeof(int), "int", eet_data_get_int, eet_data_put_int },
444 {sizeof(long long), "long_long", eet_data_get_long_long, eet_data_put_long_long},
445 {sizeof(float), "float", eet_data_get_float, eet_data_put_float },
446 {sizeof(double), "double", eet_data_get_double, eet_data_put_double },
447 {sizeof(char), "uchar", eet_data_get_char, eet_data_put_char },
448 {sizeof(short), "ushort", eet_data_get_short, eet_data_put_short },
449 {sizeof(int), "uint", eet_data_get_int, eet_data_put_int },
450 {sizeof(long long), "ulong_long", eet_data_get_long_long, eet_data_put_long_long},
451 {sizeof(char *), "string", eet_data_get_string, eet_data_put_string },
452 {sizeof(char *), "inlined", eet_data_get_istring, eet_data_put_istring },
453 {sizeof(void *), "NULL", eet_data_get_null, eet_data_put_null },
454 {sizeof(Eina_F32p32),"f32p32", eet_data_get_f32p32, eet_data_put_f32p32 },
455 {sizeof(Eina_F16p16),"f16p16", eet_data_get_f16p16, eet_data_put_f16p16 },
456 {sizeof(Eina_F8p24),"f8p24", eet_data_get_f8p24, eet_data_put_f8p24 }
459 static const Eet_Data_Group_Type_Codec eet_group_codec[] =
461 { eet_data_get_unknown, eet_data_put_unknown },
462 { eet_data_get_array, eet_data_put_array },
463 { eet_data_get_array, eet_data_put_array },
464 { eet_data_get_list, eet_data_put_list },
465 { eet_data_get_hash, eet_data_put_hash },
466 { eet_data_get_union, eet_data_put_union },
467 { eet_data_get_variant, eet_data_put_variant }
470 static int _eet_data_words_bigendian = -1;
474 #define SWAP64(x) (x) =\
475 ((((unsigned long long)(x) & 0x00000000000000ffULL) << 56) |\
476 (((unsigned long long)(x) & 0x000000000000ff00ULL) << 40) |\
477 (((unsigned long long)(x) & 0x0000000000ff0000ULL) << 24) |\
478 (((unsigned long long)(x) & 0x00000000ff000000ULL) << 8) |\
479 (((unsigned long long)(x) & 0x000000ff00000000ULL) >> 8) |\
480 (((unsigned long long)(x) & 0x0000ff0000000000ULL) >> 24) |\
481 (((unsigned long long)(x) & 0x00ff000000000000ULL) >> 40) |\
482 (((unsigned long long)(x) & 0xff00000000000000ULL) >> 56))
483 #define SWAP32(x) (x) =\
484 ((((int)(x) & 0x000000ff) << 24) |\
485 (((int)(x) & 0x0000ff00) << 8) |\
486 (((int)(x) & 0x00ff0000) >> 8) |\
487 (((int)(x) & 0xff000000) >> 24))
488 #define SWAP16(x) (x) =\
489 ((((short)(x) & 0x00ff) << 8) |\
490 (((short)(x) & 0xff00) >> 8))
494 #endif /* ifdef CONV8 */
497 #endif /* ifdef CONV16 */
500 #endif /* ifdef CONV32 */
503 #endif /* ifdef CONV64 */
506 #define CONV16(x) {if (_eet_data_words_bigendian) {SWAP16(x); }}
507 #define CONV32(x) {if (_eet_data_words_bigendian) {SWAP32(x); }}
508 #define CONV64(x) {if (_eet_data_words_bigendian) {SWAP64(x); }}
510 #define IS_SIMPLE_TYPE(Type) (Type > EET_T_UNKNOW && Type < EET_T_LAST)
511 #define IS_POINTER_TYPE(Type) (Type >= EET_T_STRING && Type <= EET_T_NULL)
513 #define POINTER_TYPE_DECODE(Context,\
525 ___r = eet_data_get_unknown(Context,\
529 Type, EET_G_UNKNOWN,\
531 if (!___r) { goto Label; }\
534 #define STRUCT_TYPE_DECODE(Data_Ret, Context, Ed, Ede, Data, Size, SubSize, Label) \
536 Data_Ret = _eet_data_descriptor_decode(Context,\
541 SubSize > 0 ? Data_Ret : NULL,\
543 if (!Data_Ret) { goto Label; }\
546 #define EET_I_STRING 1 << 4
547 #define EET_I_INLINED_STRING 2 << 4
548 #define EET_I_NULL 3 << 4
550 #define EET_MAGIC_VARIANT 0xF1234BC
555 eet_data_get_char(const Eet_Dictionary *ed __UNUSED__,
562 if (((char *)src + sizeof(char)) > (char *)src_end)
570 } /* eet_data_get_char */
573 eet_data_put_char(Eet_Dictionary *ed __UNUSED__,
579 d = (char *)malloc(sizeof(char));
586 *size_ret = sizeof(char);
588 } /* eet_data_put_char */
592 eet_data_get_short(const Eet_Dictionary *ed __UNUSED__,
599 if (((char *)src + sizeof(short)) > (char *)src_end)
602 memcpy(dst, src, sizeof(short));
605 return sizeof(short);
606 } /* eet_data_get_short */
609 eet_data_put_short(Eet_Dictionary *ed __UNUSED__,
615 d = (short *)malloc(sizeof(short));
622 *size_ret = sizeof(short);
624 } /* eet_data_put_short */
628 eet_data_get_int(const Eet_Dictionary *ed __UNUSED__,
635 if (((char *)src + sizeof(int)) > (char *)src_end)
638 memcpy(dst, src, sizeof(int));
642 } /* eet_data_get_int */
645 eet_data_put_int(Eet_Dictionary *ed __UNUSED__,
651 d = (int *)malloc(sizeof(int));
658 *size_ret = sizeof(int);
660 } /* eet_data_put_int */
664 eet_data_get_long_long(const Eet_Dictionary *ed __UNUSED__,
669 unsigned long long *d;
671 if (((char *)src + sizeof(unsigned long long)) > (char *)src_end)
674 memcpy(dst, src, sizeof(unsigned long long));
675 d = (unsigned long long *)dst;
677 return sizeof(unsigned long long);
678 } /* eet_data_get_long_long */
681 eet_data_put_long_long(Eet_Dictionary *ed __UNUSED__,
685 unsigned long long *s, *d;
687 d = (unsigned long long *)malloc(sizeof(unsigned long long));
691 s = (unsigned long long *)src;
694 *size_ret = sizeof(unsigned long long);
696 } /* eet_data_put_long_long */
700 eet_data_get_string_hash(const Eet_Dictionary *ed,
708 if (eet_data_get_int(ed, src, src_end, &idx) < 0)
711 return eet_dictionary_string_get_hash(ed, idx);
715 } /* eet_data_get_string_hash */
718 eet_data_get_string(const Eet_Dictionary *ed,
732 if (eet_data_get_int(ed, src, src_end, &idx) < 0)
735 str = eet_dictionary_string_get_char(ed, idx);
740 return eet_dictionary_string_get_size(ed, idx);
751 return strlen(s) + 1;
752 } /* eet_data_get_string */
755 eet_data_put_string(Eet_Dictionary *ed,
767 str = *((const char **)src);
771 idx = eet_dictionary_string_add(ed, str);
775 return eet_data_put_int(ed, &idx, size_ret);
778 s = (char *)(*((char **)src));
787 memcpy(d, s, len + 1);
790 } /* eet_data_put_string */
792 /* ALWAYS INLINED STRING TYPE */
794 eet_data_get_istring(const Eet_Dictionary *ed __UNUSED__,
799 return eet_data_get_string(NULL, src, src_end, dst);
800 } /* eet_data_get_istring */
803 eet_data_put_istring(Eet_Dictionary *ed __UNUSED__,
807 return eet_data_put_string(NULL, src, size_ret);
808 } /* eet_data_put_istring */
810 /* ALWAYS NULL TYPE */
812 eet_data_get_null(const Eet_Dictionary *ed __UNUSED__,
813 const void *src __UNUSED__,
814 const void *src_end __UNUSED__,
823 } /* eet_data_get_null */
826 eet_data_put_null(Eet_Dictionary *ed __UNUSED__,
827 const void *src __UNUSED__,
832 } /* eet_data_put_null */
835 * Fast lookups of simple doubles/floats.
837 * These aren't properly a cache because they don't store pre-calculated
838 * values, but have a so simple math that is almost as fast.
841 _eet_data_float_cache_get(const char *s,
845 /* fast handle of simple case 0xMp+E*/
846 if ((len == 6) && (s[0] == '0') && (s[1] == 'x') && (s[3] == 'p'))
848 int mantisse = (s[2] >= 'a') ? (s[2] - 'a' + 10) : (s[2] - '0');
849 int exponent = (s[5] - '0');
852 *d = (float)(mantisse << exponent);
854 *d = (float)mantisse / (float)(1 << exponent);
860 } /* _eet_data_float_cache_get */
863 _eet_data_double_cache_get(const char *s,
867 /* fast handle of simple case 0xMp+E*/
868 if ((len == 6) && (s[0] == '0') && (s[1] == 'x') && (s[3] == 'p'))
870 int mantisse = (s[2] >= 'a') ? (s[2] - 'a' + 10) : (s[2] - '0');
871 int exponent = (s[5] - '0');
874 *d = (double)(mantisse << exponent);
876 *d = (double)mantisse / (double)(1 << exponent);
882 } /* _eet_data_double_cache_get */
886 eet_data_get_float(const Eet_Dictionary *ed,
902 s = (const char *)src;
905 while ((p < (const char *)src_end) && (*p != 0)) {len++; p++; }
907 if (_eet_data_float_cache_get(s, len, d) != 0)
910 if (eina_convert_atod(s, len, &mantisse, &exponent) == EINA_FALSE)
913 *d = (float)ldexp((double)mantisse, exponent);
918 if (eet_data_get_int(ed, src, src_end, &idx) < 0)
921 if (!eet_dictionary_string_get_float(ed, idx, d))
925 } /* eet_data_get_float */
928 eet_data_put_float(Eet_Dictionary *ed,
935 eina_convert_dtoa((double)(*(float *)src), buf);
947 memcpy(d, buf, len + 1);
952 idx = eet_dictionary_string_add(ed, buf);
956 return eet_data_put_int(ed, &idx, size_ret);
957 } /* eet_data_put_float */
961 eet_data_get_double(const Eet_Dictionary *ed,
974 long long mantisse = 0;
978 s = (const char *)src;
981 while ((p < (const char *)src_end) && (*p != 0)) {len++; p++; }
983 if (_eet_data_double_cache_get(s, len, d) != 0)
986 if (eina_convert_atod(s, len, &mantisse, &exponent) == EINA_FALSE)
989 *d = ldexp((double)mantisse, exponent);
994 if (eet_data_get_int(ed, src, src_end, &idx) < 0)
997 if (!eet_dictionary_string_get_double(ed, idx, d))
1001 } /* eet_data_get_double */
1004 eet_data_put_double(Eet_Dictionary *ed,
1011 eina_convert_dtoa((double)(*(double *)src), buf);
1019 d = malloc(len + 1);
1023 memcpy(d, buf, len + 1);
1024 *size_ret = len + 1;
1029 idx = eet_dictionary_string_add(ed, buf);
1033 return eet_data_put_int(ed, &idx, size_ret);
1034 } /* eet_data_put_double */
1037 eet_data_get_f32p32(const Eet_Dictionary *ed,
1039 const void *src_end,
1045 fp = (Eina_F32p32 *)dst;
1052 s = (const char *)src;
1055 while ((p < (const char *)src_end) && (*p != 0)) { len++; p++; }
1057 if (!(eina_convert_atofp(s, len, fp)))
1063 if (eet_data_get_int(ed, src, src_end, &idx) < 0)
1066 if (!eet_dictionary_string_get_fp(ed, idx, fp))
1070 } /* eet_data_get_f32p32 */
1073 eet_data_put_f32p32(Eet_Dictionary *ed,
1080 eina_convert_fptoa((Eina_F32p32)(*(Eina_F32p32 *)src), buf);
1088 d = malloc(len + 1);
1092 memcpy(d, buf, len + 1);
1093 *size_ret = len + 1;
1098 idx = eet_dictionary_string_add(ed, buf);
1102 return eet_data_put_int(ed, &idx, size_ret);
1103 } /* eet_data_put_f32p32 */
1106 eet_data_get_f16p16(const Eet_Dictionary *ed,
1108 const void *src_end,
1114 fp = (Eina_F16p16 *)dst;
1116 if (eet_data_get_f32p32(ed, src, src_end, &tmp) < 0)
1119 *fp = eina_f32p32_to_f16p16(tmp);
1121 } /* eet_data_get_f16p16 */
1124 eet_data_put_f16p16(Eet_Dictionary *ed,
1130 tmp = eina_f16p16_to_f32p32((Eina_F16p16)(*(Eina_F16p16 *)src));
1131 return eet_data_put_f32p32(ed, &tmp, size_ret);
1132 } /* eet_data_put_f16p16 */
1135 eet_data_get_f8p24(const Eet_Dictionary *ed,
1137 const void *src_end,
1143 fp = (Eina_F8p24 *)dst;
1145 if (eet_data_get_f32p32(ed, src, src_end, &tmp) < 0)
1148 *fp = eina_f32p32_to_f8p24(tmp);
1150 } /* eet_data_get_f8p24 */
1153 eet_data_put_f8p24(Eet_Dictionary *ed,
1159 tmp = eina_f8p24_to_f32p32((Eina_F8p24)(*(Eina_F8p24 *)src));
1160 return eet_data_put_f32p32(ed, &tmp, size_ret);
1161 } /* eet_data_put_f8p24 */
1164 eet_data_get_type(const Eet_Dictionary *ed,
1167 const void *src_end,
1172 ret = eet_basic_codec[type - 1].get(ed, src, src_end, dest);
1174 } /* eet_data_get_type */
1176 static inline void *
1177 eet_data_put_type(Eet_Dictionary *ed,
1184 ret = eet_basic_codec[type - 1].put(ed, src, size_ret);
1186 } /* eet_data_put_type */
1188 static inline Eina_Bool
1189 eet_data_type_match(int type1,
1195 /* Note: All floating point type are equivalent and could be read
1196 without problem by any other floating point getter. */
1223 } /* eet_data_type_match */
1227 * char[4] = "CHnK"; // untyped data ... or
1228 * char[4] = "CHKx"; // typed data - x == type
1230 * int = chunk size (including magic string);
1231 * char[] = chunk magic/name string (0 byte terminated);
1232 * ... sub-chunks (a chunk can contain chuncks recusrively) ...
1234 * ... payload data ...
1239 eet_data_chunk_get(const Eet_Dictionary *ed,
1240 Eet_Data_Chunk *chnk,
1259 if ((s[0] != 'C') || (s[1] != 'H') || (s[2] != 'K'))
1262 chnk->type = (unsigned char)(s[3]);
1263 if (chnk->type >= EET_I_LIMIT)
1266 ((chnk->type - EET_I_LIMIT) & 0xF) + EET_G_UNKNOWN;
1267 switch ((chnk->type - EET_I_LIMIT) & 0xF0)
1269 #define EET_UNMATCH_TYPE(Type)\
1270 case EET_I_ ## Type: chnk->type = EET_T_ ## Type; break;
1272 EET_UNMATCH_TYPE(STRING);
1273 EET_UNMATCH_TYPE(INLINED_STRING);
1274 EET_UNMATCH_TYPE(NULL);
1280 else if (chnk->type > EET_T_LAST)
1282 chnk->group_type = chnk->type;
1283 chnk->type = EET_T_UNKNOW;
1286 chnk->group_type = EET_G_UNKNOWN;
1287 if ((chnk->type >= EET_T_LAST) ||
1288 (chnk->group_type >=
1292 chnk->group_type = 0;
1295 else if ((s[0] != 'C') || (s[1] != 'H') || (s[2] != 'n') || (s[3] != 'K'))
1298 ret1 = eet_data_get_type(ed, EET_T_INT, (s + 4), (s + size), &(chnk->size));
1303 if ((chnk->size < 0) || ((chnk->size + 8) > size))
1306 ret2 = eet_data_get_type(ed, EET_T_STRING, (s + 8), (s + size), &(chnk->name));
1314 chnk->hash = eet_data_get_string_hash(ed, (s + 8), (s + size));
1318 chnk->data = (char *)src + 4 + ret1 + sizeof(int);
1319 chnk->size -= sizeof(int);
1323 chnk->data = (char *)src + 4 + ret1 + chnk->len;
1324 chnk->size -= chnk->len;
1328 } /* eet_data_chunk_get */
1330 static inline Eet_Data_Chunk *
1331 eet_data_chunk_new(void *data,
1337 Eet_Data_Chunk *chnk;
1342 chnk = calloc(1, sizeof(Eet_Data_Chunk));
1346 /* Note: Another security, so older eet library could read file
1347 saved with fixed point value. */
1348 if (type == EET_T_F32P32
1349 || type == EET_T_F16P16
1350 || type == EET_T_F8P24)
1351 type = EET_T_DOUBLE;
1353 chnk->name = strdup(name);
1354 chnk->len = strlen(name) + 1;
1358 chnk->group_type = group_type;
1360 } /* eet_data_chunk_new */
1363 eet_data_chunk_free(Eet_Data_Chunk *chnk)
1369 } /* eet_data_chunk_free */
1371 static inline Eet_Data_Stream *
1372 eet_data_stream_new(void)
1374 Eet_Data_Stream *ds;
1376 ds = calloc(1, sizeof(Eet_Data_Stream));
1381 } /* eet_data_stream_new */
1384 eet_data_stream_free(Eet_Data_Stream *ds)
1390 } /* eet_data_stream_free */
1393 eet_data_stream_flush(Eet_Data_Stream *ds)
1396 } /* eet_data_stream_flush */
1399 eet_data_stream_write(Eet_Data_Stream *ds,
1405 if ((ds->pos + size) > ds->size)
1407 ds->data = realloc(ds->data, ds->size + size + 512);
1415 ds->size = ds->size + size + 512;
1419 memcpy(p + ds->pos, data, size);
1421 } /* eet_data_stream_write */
1424 eet_data_chunk_put(Eet_Dictionary *ed,
1425 Eet_Data_Chunk *chnk,
1426 Eet_Data_Stream *ds)
1433 unsigned char buf[4] = "CHK";
1435 /* disable this check - it will allow empty chunks to be written. this is
1436 * right for corner-cases when y have a struct with empty fields (empty
1437 * strings or empty list ptrs etc.) */
1438 /* if (!chnk->data && chnk->type != EET_T_NULL) return; */
1441 /* eet_data_stream_write(ds, "CHnK", 4);*/
1442 if (chnk->type != EET_T_UNKNOW)
1444 if (chnk->group_type != EET_G_UNKNOWN)
1446 int type = EET_I_LIMIT + chnk->group_type - EET_G_UNKNOWN;
1450 /* Only make sense with pointer type. */
1451 #define EET_MATCH_TYPE(Type)\
1452 case EET_T_ ## Type: type += EET_I_ ## Type; break;
1454 EET_MATCH_TYPE(STRING);
1455 EET_MATCH_TYPE(INLINED_STRING);
1456 EET_MATCH_TYPE(NULL);
1465 buf[3] = chnk->type;
1468 buf[3] = chnk->group_type;
1470 string = eet_data_put_string(ed, &chnk->name, &string_ret);
1474 /* size of chunk payload data + name */
1475 s = chnk->size + string_ret;
1476 size = eet_data_put_int(ed, &s, &size_ret);
1478 /* FIXME: If something goes wrong the resulting file will be corrupted. */
1482 eet_data_stream_write(ds, buf, 4);
1484 /* write chunk length */
1485 eet_data_stream_write(ds, size, size_ret);
1487 /* write chunk name */
1488 eet_data_stream_write(ds, string, string_ret);
1492 eet_data_stream_write(ds, chnk->data, chnk->size);
1497 } /* eet_data_chunk_put */
1502 _eet_descriptor_hash_new(Eet_Data_Descriptor *edd)
1506 edd->elements.hash.size = 1 << 6;
1507 edd->elements.hash.buckets = calloc(
1509 sizeof(Eet_Data_Descriptor_Hash) *
1510 edd->elements.hash.size);
1511 for (i = 0; i < edd->elements.num; i++)
1513 Eet_Data_Element *ede;
1516 ede = &(edd->elements.set[i]);
1517 hash = _eet_hash_gen((char *)ede->name, 6);
1518 if (!edd->elements.hash.buckets[hash].element)
1519 edd->elements.hash.buckets[hash].element = ede;
1522 Eet_Data_Descriptor_Hash *bucket;
1524 bucket = calloc(1, sizeof(Eet_Data_Descriptor_Hash));
1525 bucket->element = ede;
1526 bucket->next = edd->elements.hash.buckets[hash].next;
1527 edd->elements.hash.buckets[hash].next = bucket;
1530 } /* _eet_descriptor_hash_new */
1533 _eet_descriptor_hash_free(Eet_Data_Descriptor *edd)
1537 for (i = 0; i < edd->elements.hash.size; i++)
1539 Eet_Data_Descriptor_Hash *bucket, *pbucket;
1541 bucket = edd->elements.hash.buckets[i].next;
1545 bucket = bucket->next;
1549 if (edd->elements.hash.buckets)
1550 free(edd->elements.hash.buckets);
1551 } /* _eet_descriptor_hash_free */
1553 static Eet_Data_Element *
1554 _eet_descriptor_hash_find(Eet_Data_Descriptor *edd,
1558 Eet_Data_Descriptor_Hash *bucket;
1561 hash = _eet_hash_gen(name, 6);
1565 if (!edd->elements.hash.buckets[hash].element)
1567 When we use the dictionnary as a source for chunk name, we will always
1568 have the same pointer in name. It's a good idea to just compare pointer
1569 instead of running strcmp on both string.
1572 if (edd->elements.hash.buckets[hash].element->directory_name_ptr == name)
1573 return edd->elements.hash.buckets[hash].element;
1575 if (!strcmp(edd->elements.hash.buckets[hash].element->name, name))
1577 edd->elements.hash.buckets[hash].element->directory_name_ptr = name;
1578 return edd->elements.hash.buckets[hash].element;
1581 bucket = edd->elements.hash.buckets[hash].next;
1584 if (bucket->element->directory_name_ptr == name)
1585 return bucket->element;
1587 if (!strcmp(bucket->element->name, name))
1589 bucket->element->directory_name_ptr = name;
1590 return bucket->element;
1593 bucket = bucket->next;
1596 } /* _eet_descriptor_hash_find */
1599 _eet_mem_alloc(size_t size)
1601 return calloc(1, size);
1602 } /* _eet_mem_alloc */
1605 _eet_mem_free(void *mem)
1608 } /* _eet_mem_free */
1611 _eet_str_alloc(const char *str)
1614 } /* _eet_str_alloc */
1617 _eet_str_free(const char *str)
1620 } /* _eet_str_free */
1623 _eet_eina_hash_add_alloc(Eina_Hash *hash,
1628 hash = eina_hash_string_small_new(NULL);
1633 eina_hash_add(hash, key, data);
1635 } /* _eet_eina_hash_add_alloc */
1638 _eet_eina_hash_direct_add_alloc(Eina_Hash *hash,
1643 hash = eina_hash_string_small_new(NULL);
1648 eina_hash_direct_add(hash, key, data);
1650 } /* _eet_eina_hash_direct_add_alloc */
1653 _eet_str_direct_alloc(const char *str)
1656 } /* _eet_str_direct_alloc */
1659 _eet_str_direct_free(const char *str __UNUSED__)
1661 } /* _eet_str_direct_free */
1664 _eet_eina_hash_foreach(void *hash,
1665 Eina_Hash_Foreach cb,
1669 eina_hash_foreach(hash, cb, fdata);
1670 } /* _eet_eina_hash_foreach */
1673 _eet_eina_hash_free(void *hash)
1676 eina_hash_free(hash);
1677 } /* _eet_eina_hash_free */
1681 eet_eina_stream_data_descriptor_class_set(Eet_Data_Descriptor_Class *eddc,
1682 /* When we change the structure content in the future, we need to handle old structure type too */
1683 unsigned int eddc_size,
1687 if (!eddc || !name || eddc_size != sizeof (Eet_Data_Descriptor_Class))
1692 eddc->version = EET_DATA_DESCRIPTOR_CLASS_VERSION;
1694 eddc->func.mem_alloc = _eet_mem_alloc;
1695 eddc->func.mem_free = _eet_mem_free;
1696 eddc->func.str_alloc = (char *(*)(const char *))eina_stringshare_add;
1697 eddc->func.str_free = eina_stringshare_del;
1698 eddc->func.list_next = (void *(*)(void *))eina_list_next;
1699 eddc->func.list_append = (void *(*)(void *, void *))eina_list_append;
1700 eddc->func.list_data = (void *(*)(void *))eina_list_data_get;
1701 eddc->func.list_free = (void *(*)(void *))eina_list_free;
1702 eddc->func.hash_foreach = (void (*)(void *, int (*)(void *, const char *, void *, void *), void *))_eet_eina_hash_foreach;
1703 eddc->func.hash_add = (void * (*)(void *, const char *, void *))_eet_eina_hash_add_alloc;
1704 eddc->func.hash_free = (void (*)(void *))_eet_eina_hash_free;
1706 /* This will cause an ABI incompatibility */
1707 eddc->func.array_alloc = _eet_mem_alloc;
1708 eddc->func.array_free = _eet_mem_free;
1711 } /* eet_eina_stream_data_descriptor_class_set */
1714 eet_eina_file_data_descriptor_class_set(Eet_Data_Descriptor_Class *eddc,
1715 /* When we change the structure content in the future, we need to handle old structure type too */
1716 unsigned int eddc_size,
1720 if (!eet_eina_stream_data_descriptor_class_set(eddc, eddc_size, name, size))
1723 eddc->version = EET_DATA_DESCRIPTOR_CLASS_VERSION;
1725 eddc->func.hash_add = (void * (*)(void *, const char *, void *))_eet_eina_hash_direct_add_alloc;
1726 eddc->func.str_direct_alloc = _eet_str_direct_alloc;
1727 eddc->func.str_direct_free = _eet_str_direct_free;
1730 } /* eet_eina_file_data_descriptor_class_set */
1732 static Eet_Data_Descriptor *
1733 _eet_data_descriptor_new(const Eet_Data_Descriptor_Class *eddc,
1736 Eet_Data_Descriptor *edd;
1741 edd = calloc(1, sizeof (Eet_Data_Descriptor));
1745 edd->name = eddc->name;
1747 edd->size = eddc->size;
1748 edd->func.mem_alloc = _eet_mem_alloc;
1749 edd->func.mem_free = _eet_mem_free;
1750 edd->func.str_alloc = _eet_str_alloc;
1751 edd->func.str_free = _eet_str_free;
1752 if (eddc->func.mem_alloc)
1753 edd->func.mem_alloc = eddc->func.mem_alloc;
1755 if (eddc->func.mem_free)
1756 edd->func.mem_free = eddc->func.mem_free;
1758 if (eddc->func.str_alloc)
1759 edd->func.str_alloc = eddc->func.str_alloc;
1761 if (eddc->func.str_free)
1762 edd->func.str_free = eddc->func.str_free;
1764 edd->func.list_next = eddc->func.list_next;
1765 edd->func.list_append = eddc->func.list_append;
1766 edd->func.list_data = eddc->func.list_data;
1767 edd->func.list_free = eddc->func.list_free;
1768 edd->func.hash_foreach = eddc->func.hash_foreach;
1769 edd->func.hash_add = eddc->func.hash_add;
1770 edd->func.hash_free = eddc->func.hash_free;
1772 if (eddc->version > 1 && version > 1)
1774 edd->func.str_direct_alloc = eddc->func.str_direct_alloc;
1775 edd->func.str_direct_free = eddc->func.str_direct_free;
1778 if (eddc->version > 2)
1780 edd->func.type_get = eddc->func.type_get;
1781 edd->func.type_set = eddc->func.type_set;
1784 if (eddc->version > 3)
1786 edd->func.array_alloc = eddc->func.array_alloc;
1787 edd->func.array_free = eddc->func.array_free;
1791 } /* _eet_data_descriptor_new */
1793 EAPI Eet_Data_Descriptor *
1794 eet_data_descriptor_new(const char *name,
1796 Eet_Descriptor_List_Next_Callback func_list_next,
1797 Eet_Descriptor_List_Append_Callback func_list_append,
1798 Eet_Descriptor_List_Data_Callback func_list_data,
1799 Eet_Descriptor_List_Free_Callback func_list_free,
1800 Eet_Descriptor_Hash_Foreach_Callback func_hash_foreach,
1801 Eet_Descriptor_Hash_Add_Callback func_hash_add,
1802 Eet_Descriptor_Hash_Free_Callback func_hash_free)
1804 Eet_Data_Descriptor_Class eddc;
1809 memset(&eddc, 0, sizeof (Eet_Data_Descriptor_Class));
1815 eddc.func.list_next = func_list_next;
1816 eddc.func.list_append = func_list_append;
1817 eddc.func.list_data = func_list_data;
1818 eddc.func.list_free = func_list_free;
1819 eddc.func.hash_foreach = func_hash_foreach;
1820 eddc.func.hash_add = func_hash_add;
1821 eddc.func.hash_free = func_hash_free;
1823 return _eet_data_descriptor_new(&eddc, 0);
1824 } /* eet_data_descriptor_new */
1826 EAPI Eet_Data_Descriptor *
1827 eet_data_descriptor2_new(const Eet_Data_Descriptor_Class *eddc)
1829 return _eet_data_descriptor_new(eddc, 1);
1830 } /* eet_data_descriptor2_new */
1832 EAPI Eet_Data_Descriptor *
1833 eet_data_descriptor3_new(const Eet_Data_Descriptor_Class *eddc)
1835 return _eet_data_descriptor_new(eddc, 2);
1836 } /* eet_data_descriptor3_new */
1838 EAPI Eet_Data_Descriptor *
1839 eet_data_descriptor_stream_new(const Eet_Data_Descriptor_Class *eddc)
1841 return _eet_data_descriptor_new(eddc, 1);
1842 } /* eet_data_descriptor_stream_new */
1844 EAPI Eet_Data_Descriptor *
1845 eet_data_descriptor_file_new(const Eet_Data_Descriptor_Class *eddc)
1847 return _eet_data_descriptor_new(eddc, 2);
1848 } /* eet_data_descriptor_file_new */
1851 eet_data_descriptor_free(Eet_Data_Descriptor *edd)
1856 _eet_descriptor_hash_free(edd);
1857 if (edd->elements.set)
1858 free(edd->elements.set);
1861 } /* eet_data_descriptor_free */
1864 eet_data_descriptor_element_add(Eet_Data_Descriptor *edd,
1870 /* int counter_offset, */
1871 const char *counter_name /* FIXME: Useless should go on a major release */,
1872 Eet_Data_Descriptor *subtype)
1874 Eet_Data_Element *ede;
1875 Eet_Data_Element *tmp;
1877 /* UNION, VARIANT type would not work with simple type, we need a way to map the type. */
1878 if ((group_type == EET_G_UNION
1879 || group_type == EET_G_VARIANT)
1881 (type != EET_T_UNKNOW
1883 || !subtype->func.type_get
1884 || !subtype->func.type_set))
1887 /* VARIANT type will only work if the map only contains EET_G_*, but not UNION, VARIANT and ARRAY. */
1888 if (group_type == EET_G_VARIANT)
1892 for (i = 0; i < subtype->elements.num; ++i)
1893 if (subtype->elements.set[i].type != EET_T_UNKNOW
1894 && subtype->elements.set[i].group_type > EET_G_VAR_ARRAY
1895 && subtype->elements.set[i].group_type < EET_G_UNION)
1898 subtype->unified_type = EINA_TRUE;
1902 && subtype->unified_type
1903 && (type != EET_T_UNKNOW
1904 || group_type < EET_G_UNION))
1907 /* Sanity check done, let allocate ! */
1908 edd->elements.num++;
1909 tmp = realloc(edd->elements.set, edd->elements.num * sizeof(Eet_Data_Element));
1913 edd->elements.set = tmp;
1914 ede = &(edd->elements.set[edd->elements.num - 1]);
1916 ede->directory_name_ptr = NULL;
1919 * We do a special case when we do list,hash or whatever group of simple type.
1920 * Instead of handling it in encode/decode/dump/undump, we create an
1921 * implicit structure with only the simple type.
1923 if ((group_type > EET_G_UNKNOWN)
1924 && (group_type < EET_G_LAST)
1925 && (((type > EET_T_UNKNOW) && (type < EET_T_STRING))
1926 || ((type > EET_T_NULL) && (type < EET_T_LAST)))
1929 subtype = calloc(1, sizeof (Eet_Data_Descriptor));
1933 subtype->name = "implicit";
1934 subtype->size = eet_basic_codec[type - 1].size;
1935 memcpy(&subtype->func, &edd->func, sizeof(subtype->func));
1937 eet_data_descriptor_element_add(subtype,
1938 eet_basic_codec[type - 1].name,
1945 type = EET_T_UNKNOW;
1949 ede->group_type = group_type;
1950 ede->offset = offset;
1952 /* FIXME: For the time being, VAR_ARRAY, UNION and VARIANT will put the counter_offset in count. */
1953 ede->counter_offset = count;
1954 /* ede->counter_offset = counter_offset; */
1955 ede->counter_name = counter_name;
1957 ede->subtype = subtype;
1958 } /* eet_data_descriptor_element_add */
1961 eet_data_read_cipher(Eet_File *ef,
1962 Eet_Data_Descriptor *edd,
1964 const char *cipher_key)
1966 const Eet_Dictionary *ed = NULL;
1967 const void *data = NULL;
1969 Eet_Free_Context context;
1970 int required_free = 0;
1973 ed = eet_dictionary_get(ef);
1976 data = eet_read_direct(ef, name, &size);
1981 data = eet_read_cipher(ef, name, &size, cipher_key);
1986 eet_free_context_init(&context);
1987 data_dec = _eet_data_descriptor_decode(&context, ed, edd, data, size, NULL, 0);
1988 eet_free_context_shutdown(&context);
1994 } /* eet_data_read_cipher */
1997 eet_data_node_read_cipher(Eet_File *ef,
1999 const char *cipher_key)
2001 const Eet_Dictionary *ed = NULL;
2002 const void *data = NULL;
2004 Eet_Free_Context context;
2005 int required_free = 0;
2008 ed = eet_dictionary_get(ef);
2011 data = eet_read_direct(ef, name, &size);
2016 data = eet_read_cipher(ef, name, &size, cipher_key);
2021 eet_free_context_init(&context);
2022 result = _eet_data_descriptor_decode(&context, ed, NULL, data, size, NULL, 0);
2023 eet_free_context_shutdown(&context);
2029 } /* eet_data_node_read_cipher */
2032 eet_data_read(Eet_File *ef,
2033 Eet_Data_Descriptor *edd,
2036 return eet_data_read_cipher(ef, edd, name, NULL);
2037 } /* eet_data_read */
2040 eet_data_write_cipher(Eet_File *ef,
2041 Eet_Data_Descriptor *edd,
2043 const char *cipher_key,
2052 ed = eet_dictionary_get(ef);
2054 data_enc = _eet_data_descriptor_encode(ed, edd, data, &size);
2058 val = eet_write_cipher(ef, name, data_enc, size, compress, cipher_key);
2061 } /* eet_data_write_cipher */
2064 eet_data_write(Eet_File *ef,
2065 Eet_Data_Descriptor *edd,
2070 return eet_data_write_cipher(ef, edd, name, NULL, data, compress);
2071 } /* eet_data_write */
2074 eet_free_context_init(Eet_Free_Context *context)
2078 memset(context, 0, sizeof (Eet_Free_Context));
2079 for (i = 0; i < EET_FREE_COUNT; ++i)
2081 eina_array_step_set(&context->freelist.list[i],
2082 sizeof (context->freelist.list[i]),
2084 eina_array_step_set(&context->freelist_array.list[i],
2085 sizeof (context->freelist.list[i]),
2087 eina_array_step_set(&context->freelist_list.list[i],
2088 sizeof (context->freelist.list[i]),
2090 eina_array_step_set(&context->freelist_hash.list[i],
2091 sizeof (context->freelist.list[i]),
2093 eina_array_step_set(&context->freelist_str.list[i],
2094 sizeof (context->freelist.list[i]),
2096 eina_array_step_set(&context->freelist_direct_str.list[i],
2097 sizeof (context->freelist.list[i]),
2103 eet_free_context_shutdown(Eet_Free_Context *context)
2107 for (i = 0; i < EET_FREE_COUNT; ++i)
2109 eina_array_flush(&context->freelist.list[i]);
2110 eina_array_flush(&context->freelist_array.list[i]);
2111 eina_array_flush(&context->freelist_list.list[i]);
2112 eina_array_flush(&context->freelist_hash.list[i]);
2113 eina_array_flush(&context->freelist_str.list[i]);
2114 eina_array_flush(&context->freelist_direct_str.list[i]);
2119 _eet_free_hash(void *data)
2122 __int64 ptr = (UINT_PTR)data;
2123 #else /* ifdef _WIN64 */
2124 unsigned long ptr = (unsigned long)(data);
2125 #endif /* ifdef _WIN64 */
2133 #if defined (_WIN64) || ((!defined (_WIN32)) && (LONG_BIT != 32))
2138 #endif /* if defined (_WIN64) || ((!defined (_WIN32)) && (LONG_BIT != 32)) */
2141 } /* _eet_free_hash */
2144 _eet_free_add(Eet_Free *ef,
2148 Eina_Array_Iterator it;
2152 hash = _eet_free_hash(data);
2154 EINA_ARRAY_ITER_NEXT(&ef->list[hash], i, track, it)
2158 eina_array_push(&ef->list[hash], data);
2159 } /* _eet_free_add */
2163 _eet_free_del(Eet_Free *ef,
2167 Eina_Array_Iterator it;
2171 hash = _eet_free_hash(data);
2173 EINA_ARRAY_ITER_NEXT(&ef->list[hash], i, track, it)
2176 eina_array_data_set(&ef->list[hash], i, NULL);
2183 _eet_free_reset(Eet_Free *ef)
2190 for (i = 0; i < EET_FREE_COUNT; ++i)
2191 eina_array_clean(&ef->list[i]);
2192 } /* _eet_free_reset */
2195 _eet_free_ref(Eet_Free *ef)
2198 } /* _eet_free_ref */
2201 _eet_free_unref(Eet_Free *ef)
2204 } /* _eet_free_unref */
2206 #define _eet_freelist_add(Ctx, Data) _eet_free_add(&Ctx->freelist, Data);
2207 #define _eet_freelist_del(Ctx, Data) _eet_free_del(&Ctx->freelist, Data);
2208 #define _eet_freelist_reset(Ctx) _eet_free_reset(&Ctx->freelist);
2209 #define _eet_freelist_ref(Ctx) _eet_free_ref(&Ctx->freelist);
2210 #define _eet_freelist_unref(Ctx) _eet_free_unref(&Ctx->freelist);
2213 _eet_freelist_free(Eet_Free_Context *context,
2214 Eet_Data_Descriptor *edd)
2217 Eina_Array_Iterator it;
2221 if (context->freelist.ref > 0)
2224 for (j = 0; j < EET_FREE_COUNT; ++j)
2225 EINA_ARRAY_ITER_NEXT(&context->freelist.list[j], i, track, it)
2229 edd->func.mem_free(track);
2233 _eet_free_reset(&context->freelist);
2234 } /* _eet_freelist_free */
2236 #define _eet_freelist_array_add(Ctx, Data) _eet_free_add(&Ctx->freelist_array, Data);
2237 #define _eet_freelist_array_del(Ctx, Data) _eet_free_del(&Ctx->freelist_array, Data);
2238 #define _eet_freelist_array_reset(Ctx) _eet_free_reset(&Ctx->freelist_array);
2239 #define _eet_freelist_array_ref(Ctx) _eet_free_ref(&Ctx->freelist_array);
2240 #define _eet_freelist_array_unref(Ctx) _eet_free_unref(&Ctx->freelist_array);
2243 _eet_freelist_array_free(Eet_Free_Context *context,
2244 Eet_Data_Descriptor *edd)
2247 Eina_Array_Iterator it;
2251 if (context->freelist_array.ref > 0)
2254 for (j = 0; j < EET_FREE_COUNT; ++j)
2255 EINA_ARRAY_ITER_NEXT(&context->freelist_array.list[j], i, track, it)
2260 if (edd->func.array_free)
2261 edd->func.array_free(track);
2263 edd->func.mem_free(track);
2268 _eet_free_reset(&context->freelist_array);
2269 } /* _eet_freelist_array_free */
2271 #define _eet_freelist_list_add(Ctx, Data) _eet_free_add(&Ctx->freelist_list, Data);
2272 #define _eet_freelist_list_del(Ctx, Data) _eet_free_del(&Ctx->freelist_list, Data);
2273 #define _eet_freelist_list_reset(Ctx) _eet_free_reset(&Ctx->freelist_list);
2274 #define _eet_freelist_list_ref(Ctx) _eet_free_ref(&Ctx->freelist_list);
2275 #define _eet_freelist_list_unref(Ctx) _eet_free_unref(&Ctx->freelist_list);
2278 _eet_freelist_list_free(Eet_Free_Context *context,
2279 Eet_Data_Descriptor *edd)
2282 Eina_Array_Iterator it;
2286 if (context->freelist_list.ref > 0)
2289 for (j = 0; j < EET_FREE_COUNT; ++j)
2290 EINA_ARRAY_ITER_NEXT(&context->freelist_list.list[j], i, track, it)
2294 edd->func.list_free(*((void **)(track)));
2296 _eet_free_reset(&context->freelist_list);
2297 } /* _eet_freelist_list_free */
2299 #define _eet_freelist_str_add(Ctx, Data) _eet_free_add(&Ctx->freelist_str, Data);
2300 #define _eet_freelist_str_del(Ctx, Data) _eet_free_del(&Ctx->freelist_str, Data);
2301 #define _eet_freelist_str_reset(Ctx) _eet_free_reset(&Ctx->freelist_str);
2302 #define _eet_freelist_str_ref(Ctx) _eet_free_ref(&Ctx->freelist_str);
2303 #define _eet_freelist_str_unref(Ctx) _eet_free_unref(&Ctx->freelist_str);
2306 _eet_freelist_str_free(Eet_Free_Context *context, Eet_Data_Descriptor *edd)
2309 Eina_Array_Iterator it;
2313 if (context->freelist_str.ref > 0)
2316 for (j = 0; j < EET_FREE_COUNT; ++j)
2317 EINA_ARRAY_ITER_NEXT(&context->freelist_str.list[j], i, track, it)
2321 edd->func.str_free(track);
2325 _eet_free_reset(&context->freelist_str);
2326 } /* _eet_freelist_str_free */
2328 #define _eet_freelist_direct_str_add(Ctx, Data) _eet_free_add(&Ctx->freelist_direct_str, Data);
2329 #define _eet_freelist_direct_str_del(Ctx, Data) _eet_free_del(&Ctx->freelist_direct_str, Data);
2330 #define _eet_freelist_direct_str_reset(Ctx) _eet_free_reset(&Ctx->freelist_direct_str);
2331 #define _eet_freelist_direct_str_ref(Ctx) _eet_free_ref(&Ctx->freelist_direct_str);
2332 #define _eet_freelist_direct_str_unref(Ctx) _eet_free_unref(&Ctx->freelist_direct_str);
2335 _eet_freelist_direct_str_free(Eet_Free_Context *context,
2336 Eet_Data_Descriptor *edd)
2339 Eina_Array_Iterator it;
2343 if (context->freelist_direct_str.ref > 0)
2346 for (j = 0; j < EET_FREE_COUNT; ++j)
2347 EINA_ARRAY_ITER_NEXT(&context->freelist_str.list[j], i, track, it)
2351 edd->func.str_direct_free(track);
2355 _eet_free_reset(&context->freelist_direct_str);
2356 } /* _eet_freelist_direct_str_free */
2358 #define _eet_freelist_hash_add(Ctx, Data) _eet_free_add(&Ctx->freelist_hash, Data);
2359 #define _eet_freelist_hash_del(Ctx, Data) _eet_free_del(&Ctx->freelist_hash, Data);
2360 #define _eet_freelist_hash_reset(Ctx) _eet_free_reset(&Ctx->freelist_hash);
2361 #define _eet_freelist_hash_ref(Ctx) _eet_free_ref(&Ctx->freelist_hash);
2362 #define _eet_freelist_hash_unref(Ctx) _eet_free_unref(&Ctx->freelist_hash);
2365 _eet_freelist_hash_free(Eet_Free_Context *context,
2366 Eet_Data_Descriptor *edd)
2369 Eina_Array_Iterator it;
2373 if (context->freelist_hash.ref > 0)
2376 for (j = 0; j < EET_FREE_COUNT; ++j)
2377 EINA_ARRAY_ITER_NEXT(&context->freelist_hash.list[j], i, track, it)
2381 edd->func.hash_free(track);
2385 _eet_free_reset(&context->freelist_hash);
2386 } /* _eet_freelist_hash_free */
2389 _eet_freelist_all_ref(Eet_Free_Context *freelist_context)
2391 _eet_freelist_ref(freelist_context);
2392 _eet_freelist_str_ref(freelist_context);
2393 _eet_freelist_list_ref(freelist_context);
2394 _eet_freelist_hash_ref(freelist_context);
2395 _eet_freelist_direct_str_ref(freelist_context);
2396 } /* _eet_freelist_all_ref */
2399 _eet_freelist_all_unref(Eet_Free_Context *freelist_context)
2401 _eet_freelist_unref(freelist_context);
2402 _eet_freelist_str_unref(freelist_context);
2403 _eet_freelist_list_unref(freelist_context);
2404 _eet_freelist_hash_unref(freelist_context);
2405 _eet_freelist_direct_str_unref(freelist_context);
2406 } /* _eet_freelist_all_unref */
2409 eet_data_descriptor_encode_hash_cb(void *hash __UNUSED__,
2410 const char *cipher_key,
2415 Eet_Data_Encode_Hash_Info *edehi;
2416 Eet_Data_Stream *ds;
2417 Eet_Data_Element *ede;
2418 Eet_Data_Chunk *echnk;
2428 data = eet_data_put_type(ed,
2434 echnk = eet_data_chunk_new(data,
2439 eet_data_chunk_put(ed, echnk, ds);
2440 eet_data_chunk_free(echnk);
2445 EET_ASSERT(!((ede->type > EET_T_UNKNOW) && (ede->type < EET_T_STRING)), return );
2448 if (ede->type >= EET_T_STRING)
2449 eet_data_put_unknown(ed, NULL, ede, ds, &hdata);
2453 data = _eet_data_descriptor_encode(ed,
2460 echnk = eet_data_chunk_new(data,
2465 eet_data_chunk_put(ed, echnk, ds);
2466 eet_data_chunk_free(echnk);
2473 } /* eet_data_descriptor_encode_hash_cb */
2476 _eet_data_dump_token_get(const char *src,
2483 int tlen = 0, tsize = 0;
2491 tok = realloc(tok, tsize);\
2496 for (p = src; *len > 0; p++, (*len)--)
2502 if ((p[0] == '\"') && (p > src) && (p[-1] != '\\'))
2504 else if ((p[0] == '\\') && (*len > 1) &&
2509 else if ((p[0] == '\\') && (p > src) && (p[-1] == '\\'))
2513 else if ((p[0] == '\\') && (*len > 1) && (p[1] == 'n'))
2517 else if ((p[0] == 'n') && (p > src) && (p[-1] == '\\'))
2528 if ((isspace(p[0])) || (p[0] == ';')) /* token ends here */
2539 else if (!((isspace(p[0])) || (p[0] == ';')))
2556 } /* _eet_data_dump_token_get */
2559 eet_data_encode(Eet_Dictionary *ed,
2560 Eet_Data_Stream *ds,
2567 Eet_Data_Chunk *echnk;
2572 if (group_type != EET_G_UNKNOWN)
2573 if (type >= EET_T_LAST)
2574 type = EET_T_UNKNOW;
2576 echnk = eet_data_chunk_new(data, size, name, type, group_type);
2577 eet_data_chunk_put(ed, echnk, ds);
2578 eet_data_chunk_free(echnk);
2580 } /* eet_data_encode */
2583 _eet_data_dump_encode(int parent_type,
2588 Eet_Data_Chunk *chnk = NULL;
2589 Eet_Data_Stream *ds;
2596 if (_eet_data_words_bigendian == -1)
2598 unsigned long int v;
2600 v = htonl(0x12345678);
2601 if (v == 0x12345678)
2602 _eet_data_words_bigendian = 1;
2604 _eet_data_words_bigendian = 0;
2610 ds = eet_data_stream_new();
2617 for (n = node->values; n; n = n->next)
2619 data = _eet_data_dump_encode(node->type, ed, n, &size);
2622 eet_data_stream_write(ds, data, size);
2629 case EET_G_VAR_ARRAY:
2630 for (child_type = EET_T_NULL, n = node->values; n; n = n->next)
2632 if (n->type != EET_T_NULL)
2634 child_type = n->type;
2639 data = eet_data_put_type(ed,
2651 count = node->count;
2653 for (n = node->values; n; n = n->next)
2660 case EET_T_INLINED_STRING:
2661 data = eet_data_put_type(ed,
2663 &(n->data.value.str),
2680 data = _eet_data_dump_encode(n->type, ed, n, &size);
2694 for (; count; count--)
2705 /* Array is somekind of special case, so we should embed it inside another chunk. */
2706 *size_ret = ds->pos;
2711 eet_data_stream_free(ds);
2717 for (n = node->values; n; n = n->next)
2722 case EET_T_INLINED_STRING:
2723 data = eet_data_put_type(ed,
2725 &(n->data.value.str),
2742 data = _eet_data_dump_encode(node->type, ed, n, &size);
2753 /* List is another somekind of special case, every chunk is embed inside a list chunk. */
2754 *size_ret = ds->pos;
2759 eet_data_stream_free(ds);
2767 data = eet_data_put_type(ed,
2780 /* A Hash without key will not decode correctly. */
2783 for (n = node->values; n; n = n->next)
2788 case EET_T_INLINED_STRING:
2789 data = eet_data_put_type(ed,
2791 &(n->data.value.str),
2808 data = _eet_data_dump_encode(node->type, ed, n, &size);
2819 /* Hash is somekind of special case, so we should embed it inside another chunk. */
2820 *size_ret = ds->pos;
2823 eet_data_stream_flush(ds);
2830 #define EET_DATA_NODE_ENCODE(Eet_Type, Type)\
2832 data = eet_data_put_type(ed, node->type, &(node->data.value.Type), &size);\
2835 eet_data_encode(ed,\
2843 *size_ret = ds->pos;\
2844 eet_data_stream_flush(ds);\
2849 EET_DATA_NODE_ENCODE(EET_T_CHAR, c);
2850 EET_DATA_NODE_ENCODE(EET_T_SHORT, s);
2851 EET_DATA_NODE_ENCODE(EET_T_INT, i);
2852 EET_DATA_NODE_ENCODE(EET_T_LONG_LONG, l);
2853 EET_DATA_NODE_ENCODE(EET_T_FLOAT, f);
2854 EET_DATA_NODE_ENCODE(EET_T_DOUBLE, d);
2855 EET_DATA_NODE_ENCODE(EET_T_UCHAR, uc);
2856 EET_DATA_NODE_ENCODE(EET_T_USHORT, us);
2857 EET_DATA_NODE_ENCODE(EET_T_UINT, ui);
2858 EET_DATA_NODE_ENCODE(EET_T_ULONG_LONG, ul);
2859 EET_DATA_NODE_ENCODE(EET_T_INLINED_STRING, str);
2860 EET_DATA_NODE_ENCODE(EET_T_STRING, str);
2866 if ((node->type >= EET_G_UNKNOWN) && (node->type < EET_G_LAST))
2867 chnk = eet_data_chunk_new(ds->data,
2873 chnk = eet_data_chunk_new(ds->data,
2879 eet_data_stream_flush(ds);
2881 ds = eet_data_stream_new();
2882 eet_data_chunk_put(ed, chnk, ds);
2886 eet_data_stream_flush(ds);
2890 eet_data_chunk_free(chnk);
2893 } /* _eet_data_dump_encode */
2896 _eet_data_dump_parse(Eet_Dictionary *ed,
2902 const char *p = NULL;
2907 Eet_Node *node_base = NULL;
2908 Eet_Node *node = NULL;
2909 Eet_Node *n = NULL, *nn = NULL;
2911 /* FIXME; handle parse errors */
2913 jump = left; t = _eet_data_dump_token_get(p, &left); p += jump - left;
2915 for (p = src; p < (src + size); )
2917 char *tok1, *tok2, *tok3, *tok4;
2922 if (!strcmp(tok1, "group"))
2933 if (!strcmp(tok4, "{"))
2935 /* we have 'group NAM TYP {' */
2949 for (nn = node->values; nn;
2960 n->name = eina_stringshare_add(tok2);
2961 if (!strcmp(tok3, "struct"))
2962 n->type = EET_G_UNKNOWN;
2963 else if (!strcmp(tok3, "array"))
2964 n->type = EET_G_ARRAY;
2965 else if (!strcmp(tok3, "var_array"))
2966 n->type = EET_G_VAR_ARRAY;
2967 else if (!strcmp(tok3, "list"))
2968 n->type = EET_G_LIST;
2969 else if (!strcmp(tok3, "hash"))
2970 n->type = EET_G_HASH;
2973 "ERROR: group type '%s' invalid.",
2989 else if (!strcmp(tok1, "value"))
3000 /* we have 'value NAME TYP XXX' */
3011 for (nn = node->values; nn;
3021 n->name = eina_stringshare_add(tok2);
3022 if (!strcmp(tok3, "char:"))
3024 n->type = EET_T_CHAR;
3025 sscanf(tok4, "%hhi",
3026 &(n->data.value.c));
3028 else if (!strcmp(tok3, "short:"))
3030 n->type = EET_T_SHORT;
3032 &(n->data.value.s));
3034 else if (!strcmp(tok3, "int:"))
3036 n->type = EET_T_INT;
3038 &(n->data.value.i));
3040 else if (!strcmp(tok3, "long_long:"))
3042 n->type = EET_T_LONG_LONG;
3043 sscanf(tok4, "%lli",
3044 &(n->data.value.l));
3046 else if (!strcmp(tok3, "float:"))
3048 n->type = EET_T_FLOAT;
3050 &(n->data.value.f));
3052 else if (!strcmp(tok3, "double:"))
3054 n->type = EET_T_DOUBLE;
3056 &(n->data.value.d));
3058 else if (!strcmp(tok3, "uchar:"))
3060 n->type = EET_T_UCHAR;
3061 sscanf(tok4, "%hhu",
3062 &(n->data.value.uc));
3064 else if (!strcmp(tok3, "ushort:"))
3066 n->type = EET_T_USHORT;
3068 &(n->data.value.us));
3070 else if (!strcmp(tok3, "uint:"))
3072 n->type = EET_T_UINT;
3074 &(n->data.value.ui));
3076 else if (!strcmp(tok3, "ulong_long:"))
3078 n->type = EET_T_ULONG_LONG;
3079 sscanf(tok4, "%llu",
3080 &(n->data.value.ul));
3082 else if (!strcmp(tok3, "string:"))
3084 n->type = EET_T_STRING;
3086 eina_stringshare_add(tok4);
3088 else if (!strcmp(tok3, "inlined:"))
3090 n->type = EET_T_INLINED_STRING;
3092 eina_stringshare_add(tok4);
3094 else if (!strcmp(tok3, "null"))
3096 n->type = EET_T_NULL;
3097 n->data.value.str = NULL;
3101 "ERROR: value type '%s' invalid.",
3115 else if (!strcmp(tok1, "key"))
3120 /* we have 'key NAME' */
3122 node->key = eina_stringshare_add(tok2);
3127 else if (!strcmp(tok1, "count"))
3132 /* we have a 'count COUNT' */
3134 sscanf(tok2, "%i", &(node->count));
3139 else if (!strcmp(tok1, "}"))
3140 /* we have an end of the group */
3142 node = node->parent;
3150 cdata = _eet_data_dump_encode(EET_G_UNKNOWN, ed, node_base, size_ret);
3151 eet_node_del(node_base);
3155 } /* _eet_data_dump_parse */
3157 #define NEXT_CHUNK(P, Size, Echnk, Ed)\
3160 __tmp = Ed ? (int)(sizeof(int) * 2) : Echnk.len + 4;\
3161 P += (4 + Echnk.size + __tmp);\
3162 Size -= (4 + Echnk.size + __tmp);\
3166 _eet_data_descriptor_decode(Eet_Free_Context *context,
3167 const Eet_Dictionary *ed,
3168 Eet_Data_Descriptor *edd,
3169 const void *data_in,
3174 Eet_Node *result = NULL;
3178 Eet_Data_Chunk chnk;
3180 if (_eet_data_words_bigendian == -1)
3182 unsigned long int v;
3184 v = htonl(0x12345678);
3185 if (v == 0x12345678)
3186 _eet_data_words_bigendian = 1;
3188 _eet_data_words_bigendian = 0;
3195 if (size_out <= edd->size)
3200 data = edd->func.mem_alloc(edd->size);
3208 for (i = 0; i < edd->elements.num; i++)
3209 edd->elements.set[i].directory_name_ptr = NULL;
3214 _eet_freelist_all_ref(context);
3215 if (data && !data_out)
3216 _eet_freelist_add(context, data);
3218 memset(&chnk, 0, sizeof(Eet_Data_Chunk));
3219 eet_data_chunk_get(ed, &chnk, data_in, size_in);
3224 if (strcmp(chnk.name, edd->name))
3229 size = size_in - (4 + sizeof(int) * 2);
3231 size = size_in - (4 + 4 + chnk.len);
3235 if (!edd->elements.hash.buckets)
3236 _eet_descriptor_hash_new(edd);
3240 switch (chnk.group_type)
3246 return eet_node_string_new(chnk.name, chnk.data);
3248 case EET_T_INLINED_STRING:
3249 return eet_node_inlined_string_new(chnk.name, chnk.data);
3252 return eet_node_null_new(chnk.name);
3255 result = eet_node_struct_new(chnk.name, NULL);
3259 case EET_G_VAR_ARRAY:
3260 return eet_node_var_array_new(chnk.name, NULL);
3274 Eet_Data_Chunk echnk;
3275 Eet_Data_Element *ede = NULL;
3276 Eet_Node *child = NULL;
3277 int group_type = EET_G_UNKNOWN, type = EET_T_UNKNOW;
3280 /* get next data chunk */
3281 memset(&echnk, 0, sizeof(Eet_Data_Chunk));
3282 eet_data_chunk_get(ed, &echnk, p, size);
3284 goto error; /* FIXME: don't REPLY on edd - work without */
3288 ede = _eet_descriptor_hash_find(edd, echnk.name, echnk.hash);
3291 group_type = ede->group_type;
3293 if ((echnk.type == 0) && (echnk.group_type == 0))
3296 group_type = ede->group_type;
3300 if (IS_SIMPLE_TYPE(echnk.type) &&
3301 eet_data_type_match(echnk.type, ede->type))
3302 /* Needed when converting on the fly from FP to Float */
3304 else if ((echnk.group_type > EET_G_UNKNOWN) &&
3305 (echnk.group_type < EET_G_LAST) &&
3306 (echnk.group_type == ede->group_type))
3307 group_type = echnk.group_type;
3311 /*...... dump to node */
3315 group_type = echnk.group_type;
3318 if (!edd && group_type == EET_G_UNKNOWN && IS_SIMPLE_TYPE(type))
3320 unsigned char dd[128];
3322 ret = eet_data_get_type(ed,
3325 ((char *)echnk.data) + echnk.size,
3330 child = eet_data_node_simple_type(type, echnk.name, dd);
3332 eet_node_struct_append(result, echnk.name, child);
3336 ret = eet_group_codec[group_type - 100].get(
3344 ede ? (void *)(((char*) data) + ede->offset) : (void **)&result,
3352 /* advance to next chunk */
3353 NEXT_CHUNK(p, size, echnk, ed);
3356 _eet_freelist_all_unref(context);
3359 _eet_freelist_str_free(context, edd);
3360 _eet_freelist_direct_str_free(context, edd);
3361 _eet_freelist_list_free(context, edd);
3362 _eet_freelist_hash_free(context, edd);
3363 _eet_freelist_array_free(context, edd);
3364 _eet_freelist_free(context, edd);
3368 _eet_freelist_reset(context);
3369 _eet_freelist_str_reset(context);
3370 _eet_freelist_list_reset(context);
3371 _eet_freelist_hash_reset(context);
3372 _eet_freelist_direct_str_reset(context);
3373 _eet_freelist_array_reset(context);
3382 eet_node_del(result);
3384 _eet_freelist_all_unref(context);
3385 _eet_freelist_str_free(context, edd);
3386 _eet_freelist_direct_str_free(context, edd);
3387 _eet_freelist_list_free(context, edd);
3388 _eet_freelist_hash_free(context, edd);
3389 _eet_freelist_array_free(context, edd);
3390 _eet_freelist_free(context, edd);
3392 /* FIXME: Warn that something goes wrong here. */
3394 } /* _eet_data_descriptor_decode */
3397 eet_data_get_list(Eet_Free_Context *context,
3398 const Eet_Dictionary *ed,
3399 Eet_Data_Descriptor *edd,
3400 Eet_Data_Element *ede,
3401 Eet_Data_Chunk *echnk,
3403 int group_type __UNUSED__,
3408 Eet_Data_Descriptor *subtype = NULL;
3413 EET_ASSERT(!((type > EET_T_UNKNOW) && (type < EET_T_STRING)), return 0);
3417 subtype = ede->subtype;
3419 if (type != ede->type)
3423 ptr = (void **)data;
3427 if (IS_POINTER_TYPE(type))
3428 POINTER_TYPE_DECODE(context,
3439 STRUCT_TYPE_DECODE(data_ret,
3450 list = edd->func.list_append(list, data_ret);
3452 _eet_freelist_list_add(context, ptr);
3455 eet_node_list_append(*((Eet_Node **)data), echnk->name, data_ret);
3461 } /* eet_data_get_list */
3464 eet_data_get_hash(Eet_Free_Context *context,
3465 const Eet_Dictionary *ed,
3466 Eet_Data_Descriptor *edd,
3467 Eet_Data_Element *ede,
3468 Eet_Data_Chunk *echnk,
3470 int group_type __UNUSED__,
3478 void *data_ret = NULL;
3481 EET_ASSERT(!((type > EET_T_UNKNOW) && (type < EET_T_STRING)), return 0);
3483 ptr = (void **)data;
3487 ret = eet_data_get_type(ed,
3490 ((char *)echnk->data) + echnk->size,
3498 /* Advance to next chunk */
3499 NEXT_CHUNK((*p), (*size), (*echnk), ed);
3500 memset(echnk, 0, sizeof(Eet_Data_Chunk));
3503 eet_data_chunk_get(ed, echnk, *p, *size);
3508 if ((ede->group_type != echnk->group_type)
3509 || (ede->type != echnk->type))
3512 if (IS_POINTER_TYPE(echnk->type))
3513 POINTER_TYPE_DECODE(context,
3524 STRUCT_TYPE_DECODE(data_ret,
3527 ede ? ede->subtype : NULL,
3535 hash = edd->func.hash_add(hash, key, data_ret);
3537 _eet_freelist_hash_add(context, hash);
3540 eet_node_hash_add(*((Eet_Node **)data), echnk->name, key, data_ret);
3546 } /* eet_data_get_hash */
3548 /* var arrays and fixed arrays have to
3549 * get all chunks at once. for fixed arrays
3550 * we can get each chunk and increment a
3551 * counter stored on the element itself but
3552 * it wont be thread safe. for var arrays
3553 * we still need a way to get the number of
3554 * elements from the data, so storing the
3555 * number of elements and the element data on
3556 * each chunk is pointless.
3559 eet_data_get_array(Eet_Free_Context *context,
3560 const Eet_Dictionary *ed,
3561 Eet_Data_Descriptor *edd,
3562 Eet_Data_Element *ede,
3563 Eet_Data_Chunk *echnk,
3570 Eina_List *childs = NULL;
3579 EET_ASSERT(!((type > EET_T_UNKNOW) && (type < EET_T_STRING)), return 0);
3582 /* read the number of elements */
3583 ret = eet_data_get_type(ed,
3586 ((char *)echnk->data) + echnk->size,
3595 if (IS_POINTER_TYPE(type))
3596 subsize = eet_basic_codec[ede->type].size;
3598 subsize = ede->subtype->size;
3600 if (group_type == EET_G_VAR_ARRAY)
3602 /* store the number of elements
3603 * on the counter offset */
3604 *(int *)(((char *)data) + ede->count - ede->offset) = count;
3605 /* allocate space for the array of elements */
3606 if (edd->func.array_alloc)
3607 *(void **) ptr = edd->func.array_alloc(count * subsize);
3609 *(void **) ptr = edd->func.mem_alloc(count * subsize);
3614 memset(*(void **)ptr, 0, count * subsize);
3616 _eet_freelist_array_add(context, *(void **)ptr);
3620 /* get all array elements */
3621 for (i = 0; i < count; i++)
3625 /* Advance to next chunk */
3626 NEXT_CHUNK((*p), (*size), (*echnk), ed);
3627 memset(echnk, 0, sizeof(Eet_Data_Chunk));
3629 eet_data_chunk_get(ed, echnk, *p, *size);
3630 if (!echnk->name || strcmp(echnk->name, name) != 0)
3631 goto on_error; /* get the data */
3633 if ((echnk->group_type != group_type)
3634 || ((echnk->type != type) && (echnk->type != EET_T_NULL)))
3638 if ((ede->group_type != echnk->group_type)
3639 || ((echnk->type != ede->type) && (echnk->type != EET_T_NULL)))
3642 /* get the destination pointer */
3645 if (group_type == EET_G_ARRAY)
3646 dst = (char *)ptr + (subsize * i);
3648 dst = *(char **)ptr + (subsize * i);
3651 if (IS_POINTER_TYPE(echnk->type))
3653 void *data_ret = NULL;
3655 POINTER_TYPE_DECODE(context,
3666 memcpy(dst, &data_ret, subsize);
3669 childs = eina_list_append(childs, data_ret);
3673 STRUCT_TYPE_DECODE(dst,
3676 ede ? ede->subtype : NULL,
3683 childs = eina_list_append(childs, dst);
3689 Eet_Node *parent = *((Eet_Node **)data);
3692 if (group_type == EET_G_ARRAY)
3693 array = eet_node_array_new(name, count, childs);
3695 array = eet_node_var_array_new(name, childs);
3700 eet_node_struct_append(parent, name, array);
3706 EINA_LIST_FREE(childs, tmp)
3710 } /* eet_data_get_array */
3713 eet_data_put_union(Eet_Dictionary *ed,
3714 Eet_Data_Descriptor *edd __UNUSED__,
3715 Eet_Data_Element *ede,
3716 Eet_Data_Stream *ds,
3719 const char *union_type;
3722 EET_ASSERT(!((ede->type != EET_T_UNKNOW) || (!ede->subtype)), return );
3724 union_type = ede->subtype->func.type_get(
3725 ((char *)data_in) + ede->count - ede->offset,
3731 /* Search the structure of the union to encode. */
3732 for (i = 0; i < ede->subtype->elements.num; ++i)
3733 if (strcmp(ede->subtype->elements.set[i].name, union_type) == 0)
3735 Eet_Data_Element *sede;
3739 /* Yeah we found it ! */
3740 data = eet_data_put_type(ed, EET_T_STRING, &union_type, &size);
3750 sede = &(ede->subtype->elements.set[i]);
3751 data = _eet_data_descriptor_encode(ed,
3767 } /* eet_data_put_union */
3770 eet_data_get_union(Eet_Free_Context *context,
3771 const Eet_Dictionary *ed,
3772 Eet_Data_Descriptor *edd __UNUSED__,
3773 Eet_Data_Element *ede,
3774 Eet_Data_Chunk *echnk,
3781 const char *union_type;
3782 void *data_ret = NULL;
3787 ret = eet_data_get_type(ed,
3790 ((char *)echnk->data) + echnk->size,
3795 /* Advance to next chunk */
3796 NEXT_CHUNK((*p), (*size), (*echnk), ed);
3797 memset(echnk, 0, sizeof(Eet_Data_Chunk));
3800 eet_data_chunk_get(ed, echnk, *p, *size);
3806 EET_ASSERT(!(ede->group_type != group_type || ede->type != type),
3809 /* Search the structure of the union to decode */
3810 for (i = 0; i < ede->subtype->elements.num; ++i)
3811 if (strcmp(ede->subtype->elements.set[i].name, union_type) == 0)
3813 Eet_Data_Element *sede;
3816 /* Yeah we found it ! */
3817 sede = &(ede->subtype->elements.set[i]);
3818 EET_ASSERT(sede->subtype, goto on_error);
3820 data_ret = _eet_data_descriptor_decode(context,
3826 sede->subtype->size);
3830 /* Set union type. */
3831 if ((!ed) || (!ede->subtype->func.str_direct_alloc))
3833 ut = ede->subtype->func.str_alloc(union_type);
3834 _eet_freelist_str_add(context, ut);
3838 ut = ede->subtype->func.str_direct_alloc(union_type);
3839 _eet_freelist_direct_str_add(context, ut);
3842 ede->subtype->func.type_set(
3844 ((char *)data) + ede->count -
3854 /* FIXME: generate node structure. */
3855 data_ret = _eet_data_descriptor_decode(context,
3857 echnk->data, echnk->size,
3866 } /* eet_data_get_union */
3869 eet_data_put_variant(Eet_Dictionary *ed,
3870 Eet_Data_Descriptor *edd __UNUSED__,
3871 Eet_Data_Element *ede,
3872 Eet_Data_Stream *ds,
3875 const char *union_type;
3877 Eina_Bool unknow = EINA_FALSE;
3881 EET_ASSERT(!((ede->type != EET_T_UNKNOW) || (!ede->subtype)), return );
3883 union_type = ede->subtype->func.type_get(
3884 ((char *)data_in) + ede->count - ede->offset,
3887 if (!union_type && unknow == EINA_FALSE)
3892 /* Handle opaque internal representation */
3893 Eet_Variant_Unknow *evu;
3895 data = eet_data_put_type(ed, EET_T_STRING, &union_type, &size);
3905 evu = (Eet_Variant_Unknow *)data_in;
3906 if (evu && EINA_MAGIC_CHECK(evu, EET_MAGIC_VARIANT))
3916 /* Search the structure of the union to encode. */
3917 for (i = 0; i < ede->subtype->elements.num; ++i)
3918 if (strcmp(ede->subtype->elements.set[i].name, union_type) == 0)
3920 Eet_Data_Element *sede;
3922 /* Yeah we found it ! */
3923 data = eet_data_put_type(ed, EET_T_STRING, &union_type, &size);
3933 sede = &(ede->subtype->elements.set[i]);
3935 if (sede->group_type != EET_G_UNKNOWN)
3937 Eet_Data_Stream *lds;
3939 lds = eet_data_stream_new();
3940 eet_group_codec[sede->group_type - 100].put(ed,
3947 eet_data_encode(ed, ds, lds->data, ede->name, lds->pos,
3948 ede->type, ede->group_type);
3954 eet_data_encode(ed, ds, NULL, ede->name, 0,
3955 EET_T_NULL, ede->group_type);
3957 eet_data_stream_free(lds);
3961 data = _eet_data_descriptor_encode(ed,
3978 } /* eet_data_put_variant */
3981 eet_data_get_variant(Eet_Free_Context *context,
3982 const Eet_Dictionary *ed,
3983 Eet_Data_Descriptor *edd __UNUSED__,
3984 Eet_Data_Element *ede,
3985 Eet_Data_Chunk *echnk,
3986 int type __UNUSED__,
3987 int group_type __UNUSED__,
3992 const char *union_type;
3993 void *data_ret = NULL;
3998 ret = eet_data_get_type(ed,
4001 ((char *)echnk->data) + echnk->size,
4006 /* Advance to next chunk */
4007 NEXT_CHUNK((*p), (*size), (*echnk), ed);
4008 memset(echnk, 0, sizeof(Eet_Data_Chunk));
4011 eet_data_chunk_get(ed, echnk, *p, *size);
4019 EET_ASSERT(ede->subtype, goto on_error);
4021 if ((!ed) || (!ede->subtype->func.str_direct_alloc))
4023 ut = ede->subtype->func.str_alloc(union_type);
4024 _eet_freelist_str_add(context, ut);
4028 ut = ede->subtype->func.str_direct_alloc(union_type);
4029 _eet_freelist_direct_str_add(context, ut);
4032 /* Search the structure of the union to decode */
4033 for (i = 0; i < ede->subtype->elements.num; ++i)
4034 if (strcmp(ede->subtype->elements.set[i].name, union_type) == 0)
4036 Eet_Data_Element *sede;
4038 /* Yeah we found it ! */
4039 sede = &(ede->subtype->elements.set[i]);
4041 if (sede->group_type != EET_G_UNKNOWN)
4043 Eet_Data_Chunk chnk;
4048 size2 = echnk->size;
4050 /* Didn't find a proper way to provide this
4051 without duplicating code */
4054 memset(&chnk, 0, sizeof(Eet_Data_Chunk));
4055 eet_data_chunk_get(ed, &chnk, p2, size2);
4060 ret = eet_group_codec[sede->group_type - 100].get
4061 (context, ed, sede->subtype, sede, &chnk, sede->type,
4062 sede->group_type, data, &p2, &size2);
4067 /* advance to next chunk */
4068 NEXT_CHUNK(p2, size2, chnk, ed);
4071 /* Put garbage so that we will not put eet_variant_unknow in it */
4072 data_ret = (void *)data;
4074 /* Set variant type. */
4075 ede->subtype->func.type_set
4076 (ut, ((char *)data) + ede->count - ede->offset,
4081 data_ret = _eet_data_descriptor_decode(context,
4090 /* And point to the variant data. */
4091 *(void **)data = data_ret;
4093 /* Set variant type. */
4094 ede->subtype->func.type_set
4095 (ut, ((char *)data) + ede->count - ede->offset, EINA_FALSE);
4101 Eet_Variant_Unknow *evu;
4103 evu = calloc(1, sizeof (Eet_Variant_Unknow) + echnk->size - 1);
4107 evu->size = echnk->size;
4108 memcpy(evu->data, echnk->data, evu->size);
4109 EINA_MAGIC_SET(evu, EET_MAGIC_VARIANT);
4111 /* And point to the opaque internal data scructure */
4112 *(void **)data = evu;
4114 /* Set variant type. */
4115 ede->subtype->func.type_set
4116 (ut, ((char *)data) + ede->count - ede->offset, EINA_TRUE);
4121 /* FIXME: dump node structure. */
4122 data_ret = _eet_data_descriptor_decode(context,
4124 echnk->data, echnk->size,
4133 } /* eet_data_get_variant */
4136 eet_data_node_simple_type(int type, const char *name, void *dd)
4140 #endif /* ifdef EET_T_TYPE */
4142 #define EET_T_TYPE(Eet_Type, Eet_Node_Type, Type)\
4144 return eet_node_ ## Eet_Node_Type ## _new(name, *((Type *)dd));\
4148 EET_T_TYPE(EET_T_CHAR, char, char);
4149 EET_T_TYPE(EET_T_SHORT, short, short);
4150 EET_T_TYPE(EET_T_INT, int, int);
4151 EET_T_TYPE(EET_T_LONG_LONG, long_long, long long);
4152 EET_T_TYPE(EET_T_FLOAT, float, float);
4153 EET_T_TYPE(EET_T_DOUBLE, double, double);
4154 EET_T_TYPE(EET_T_UCHAR, unsigned_char, unsigned char);
4155 EET_T_TYPE(EET_T_USHORT, unsigned_short, unsigned short);
4156 EET_T_TYPE(EET_T_UINT, unsigned_int, unsigned int);
4157 EET_T_TYPE(EET_T_ULONG_LONG, unsigned_long_long, unsigned long long);
4158 EET_T_TYPE(EET_T_STRING, string, char *);
4159 EET_T_TYPE(EET_T_INLINED_STRING, inlined_string, char *);
4162 return eet_node_null_new(name);
4165 ERR("Unknow type passed to eet_data_node_simple_type");
4168 } /* eet_data_node_simple_type */
4171 eet_data_get_unknown(Eet_Free_Context *context,
4172 const Eet_Dictionary *ed,
4173 Eet_Data_Descriptor *edd,
4174 Eet_Data_Element *ede,
4175 Eet_Data_Chunk *echnk,
4177 int group_type __UNUSED__,
4179 char **p __UNUSED__,
4180 int *size __UNUSED__)
4185 if (IS_SIMPLE_TYPE(type))
4187 unsigned char dd[128];
4189 ret = eet_data_get_type(ed,
4192 ((char *)echnk->data) + echnk->size,
4193 edd ? (char *)data : (char *)dd);
4199 Eet_Node **parent = data;
4202 node = eet_data_node_simple_type(type, echnk->name, dd);
4205 eet_node_struct_append(*parent, echnk->name, node);
4211 if (type == EET_T_STRING)
4215 str = (char **)(((char *)data));
4218 if ((!ed) || (!edd->func.str_direct_alloc))
4220 *str = edd->func.str_alloc(*str);
4221 _eet_freelist_str_add(context, *str);
4225 *str = edd->func.str_direct_alloc(*str);
4226 _eet_freelist_direct_str_add(context, *str);
4230 else if (edd && type == EET_T_INLINED_STRING)
4234 str = (char **)(((char *)data));
4237 *str = edd->func.str_alloc(*str);
4238 _eet_freelist_str_add(context, *str);
4245 Eet_Data_Descriptor *subtype;
4247 subtype = ede ? ede->subtype : NULL;
4249 if (subtype || !edd)
4251 Eet_Node **parent = data;
4254 data_ret = _eet_data_descriptor_decode(context,
4265 ptr = (void **)(((char *)data));
4266 *ptr = (void *)data_ret;
4270 Eet_Node *node = data_ret;
4274 node = eet_node_struct_child_new(echnk->name, node);
4275 eet_node_struct_append(*parent, echnk->name, node);
4284 } /* eet_data_get_unknown */
4287 eet_data_put_array(Eet_Dictionary *ed,
4288 Eet_Data_Descriptor *edd __UNUSED__,
4289 Eet_Data_Element *ede,
4290 Eet_Data_Stream *ds,
4300 EET_ASSERT(!((ede->type > EET_T_UNKNOW) && (ede->type < EET_T_STRING)),
4303 if (ede->group_type == EET_G_ARRAY)
4304 count = ede->counter_offset;
4306 count = *(int *)(((char *)data_in) + ede->count - ede->offset);
4309 return; /* Store number of elements */
4311 data = eet_data_put_type(ed, EET_T_INT, &count, &size);
4313 eet_data_encode(ed, ds, data, ede->name, size, ede->type, ede->group_type);
4315 if (IS_POINTER_TYPE(ede->type))
4316 subsize = eet_basic_codec[ede->type].size;
4318 subsize = ede->subtype->size;
4320 for (j = 0; j < count; j++)
4325 if (ede->group_type == EET_G_ARRAY)
4326 d = (void *)(((char *)data_in) + offset);
4328 d = *(((char **)data_in)) + offset;
4330 if (IS_POINTER_TYPE(ede->type))
4333 eet_data_put_unknown(ed, NULL, ede, ds, d);
4337 data = _eet_data_descriptor_encode(ed, ede->subtype, d, &size);
4349 /* Add a NULL element just to have the correct array layout. */
4360 } /* eet_data_put_array */
4363 eet_data_put_unknown(Eet_Dictionary *ed,
4364 Eet_Data_Descriptor *edd __UNUSED__,
4365 Eet_Data_Element *ede,
4366 Eet_Data_Stream *ds,
4372 if (IS_SIMPLE_TYPE(ede->type))
4373 data = eet_data_put_type(ed, ede->type, data_in, &size);
4374 else if (ede->subtype)
4375 if (*((char **)data_in))
4376 data = _eet_data_descriptor_encode(ed,
4378 *((char **)((char *)(data_in))),
4389 } /* eet_data_put_unknown */
4392 eet_data_put_list(Eet_Dictionary *ed,
4393 Eet_Data_Descriptor *edd,
4394 Eet_Data_Element *ede,
4395 Eet_Data_Stream *ds,
4402 EET_ASSERT(!(((ede->type > EET_T_UNKNOW) && (ede->type < EET_T_STRING))
4403 || ((ede->type > EET_T_NULL) && (ede->type < EET_T_LAST))),
4406 l = *((void **)(((char *)data_in)));
4407 for (; l; l = edd->func.list_next(l))
4409 if (IS_POINTER_TYPE(ede->type))
4411 const void *str = edd->func.list_data(l);
4412 eet_data_put_unknown(ed, NULL, ede, ds, &str);
4416 data = _eet_data_descriptor_encode(ed,
4418 edd->func.list_data(l),
4430 } /* eet_data_put_list */
4433 eet_data_put_hash(Eet_Dictionary *ed,
4434 Eet_Data_Descriptor *edd,
4435 Eet_Data_Element *ede,
4436 Eet_Data_Stream *ds,
4439 Eet_Data_Encode_Hash_Info fdata;
4442 l = *((void **)(((char *)data_in)));
4446 edd->func.hash_foreach(l, eet_data_descriptor_encode_hash_cb, &fdata);
4447 } /* eet_data_put_hash */
4450 eet_data_dump_cipher(Eet_File *ef,
4452 const char *cipher_key,
4453 Eet_Dump_Callback dumpfunc,
4456 const Eet_Dictionary *ed = NULL;
4457 const void *data = NULL;
4459 Eet_Free_Context context;
4460 int required_free = 0;
4463 ed = eet_dictionary_get(ef);
4466 data = eet_read_direct(ef, name, &size);
4471 data = eet_read_cipher(ef, name, &size, cipher_key);
4476 eet_free_context_init(&context);
4477 result = _eet_data_descriptor_decode(&context, ed, NULL, data, size, NULL, 0);
4478 eet_free_context_shutdown(&context);
4480 eet_node_dump(result, 0, dumpfunc, dumpdata);
4482 eet_node_del(result);
4487 return result ? 1 : 0;
4488 } /* eet_data_dump_cipher */
4491 eet_data_dump(Eet_File *ef,
4493 Eet_Dump_Callback dumpfunc,
4496 return eet_data_dump_cipher(ef, name, NULL, dumpfunc, dumpdata);
4497 } /* eet_data_dump */
4500 eet_data_text_dump_cipher(const void *data_in,
4501 const char *cipher_key,
4503 Eet_Dump_Callback dumpfunc,
4508 Eet_Free_Context context;
4509 unsigned int ret_len = 0;
4516 if (eet_decipher(data_in, size_in, cipher_key,
4517 strlen(cipher_key), &ret, &ret_len))
4527 ret = (void *)data_in;
4531 eet_free_context_init(&context);
4532 result = _eet_data_descriptor_decode(&context, NULL, NULL, ret, ret_len, NULL, 0);
4533 eet_free_context_shutdown(&context);
4535 eet_node_dump(result, 0, dumpfunc, dumpdata);
4537 eet_node_del(result);
4541 return result ? 1 : 0;
4542 } /* eet_data_text_dump_cipher */
4545 eet_data_text_dump(const void *data_in,
4547 Eet_Dump_Callback dumpfunc,
4550 return eet_data_text_dump_cipher(data_in, NULL, size_in, dumpfunc, dumpdata);
4551 } /* eet_data_text_dump */
4554 eet_data_text_undump_cipher(const char *text,
4555 const char *cipher_key,
4561 ret = _eet_data_dump_parse(NULL, size_ret, text, textlen);
4562 if (ret && cipher_key)
4564 void *ciphered = NULL;
4565 unsigned int ciphered_len;
4567 if (eet_cipher(ret, *size_ret, cipher_key,
4568 strlen(cipher_key), &ciphered, &ciphered_len))
4579 *size_ret = ciphered_len;
4584 } /* eet_data_text_undump_cipher */
4587 eet_data_text_undump(const char *text,
4591 return eet_data_text_undump_cipher(text, NULL, textlen, size_ret);
4592 } /* eet_data_text_undump */
4595 eet_data_undump_cipher(Eet_File *ef,
4597 const char *cipher_key,
4607 ed = eet_dictionary_get(ef);
4609 data_enc = _eet_data_dump_parse(ed, &size, text, textlen);
4613 val = eet_write_cipher(ef, name, data_enc, size, compress, cipher_key);
4616 } /* eet_data_undump_cipher */
4619 eet_data_undump(Eet_File *ef,
4625 return eet_data_undump_cipher(ef, name, NULL, text, textlen, compress);
4626 } /* eet_data_undump */
4629 eet_data_descriptor_decode_cipher(Eet_Data_Descriptor *edd,
4630 const void *data_in,
4631 const char *cipher_key,
4634 void *deciphered = (void *)data_in;
4636 Eet_Free_Context context;
4637 unsigned int deciphered_len = size_in;
4639 if (cipher_key && data_in)
4640 if (eet_decipher(data_in, size_in, cipher_key,
4641 strlen(cipher_key), &deciphered, &deciphered_len))
4649 eet_free_context_init(&context);
4650 ret = _eet_data_descriptor_decode(&context,
4656 eet_free_context_shutdown(&context);
4658 if (data_in != deciphered)
4662 } /* eet_data_descriptor_decode_cipher */
4665 eet_data_descriptor_decode(Eet_Data_Descriptor *edd,
4666 const void *data_in,
4669 return eet_data_descriptor_decode_cipher(edd, data_in, NULL, size_in);
4670 } /* eet_data_descriptor_decode */
4673 eet_data_node_decode_cipher(const void *data_in,
4674 const char *cipher_key,
4677 void *deciphered = (void *)data_in;
4679 Eet_Free_Context context;
4680 unsigned int deciphered_len = size_in;
4682 if (cipher_key && data_in)
4683 if (eet_decipher(data_in, size_in, cipher_key,
4684 strlen(cipher_key), &deciphered, &deciphered_len))
4692 eet_free_context_init(&context);
4693 ret = _eet_data_descriptor_decode(&context,
4699 eet_free_context_shutdown(&context);
4701 if (data_in != deciphered)
4705 } /* eet_data_node_decode_cipher */
4708 _eet_data_descriptor_encode(Eet_Dictionary *ed,
4709 Eet_Data_Descriptor *edd,
4710 const void *data_in,
4713 Eet_Data_Stream *ds;
4714 Eet_Data_Chunk *chnk;
4719 if (_eet_data_words_bigendian == -1)
4721 unsigned long int v;
4723 v = htonl(0x12345678);
4724 if (v == 0x12345678)
4725 _eet_data_words_bigendian = 1;
4727 _eet_data_words_bigendian = 0;
4730 ds = eet_data_stream_new();
4731 for (i = 0; i < edd->elements.num; i++)
4733 Eet_Data_Element *ede;
4735 ede = &(edd->elements.set[i]);
4736 eet_group_codec[ede->group_type - 100].put(
4744 chnk = eet_data_chunk_new(ds->data,
4751 eet_data_stream_free(ds);
4753 ds = eet_data_stream_new();
4754 eet_data_chunk_put(ed, chnk, ds);
4760 eet_data_stream_free(ds);
4764 eet_data_chunk_free(chnk);
4767 } /* _eet_data_descriptor_encode */
4770 eet_data_node_write_cipher(Eet_File *ef,
4772 const char *cipher_key,
4781 ed = eet_dictionary_get(ef);
4783 data_enc = _eet_data_dump_encode(EET_G_UNKNOWN, ed, node, &size);
4787 val = eet_write_cipher(ef, name, data_enc, size, compress, cipher_key);
4790 } /* eet_data_node_write_cipher */
4793 eet_data_node_encode_cipher(Eet_Node *node,
4794 const char *cipher_key,
4798 void *ciphered = NULL;
4799 unsigned int ciphered_len = 0;
4802 ret = _eet_data_dump_encode(EET_G_UNKNOWN, NULL, node, &size);
4803 if (cipher_key && ret)
4805 if (eet_cipher(ret, size, cipher_key,
4806 strlen(cipher_key), &ciphered, &ciphered_len))
4819 size = (int)ciphered_len;
4827 } /* eet_data_node_encode_cipher */
4830 eet_data_descriptor_encode_cipher(Eet_Data_Descriptor *edd,
4831 const void *data_in,
4832 const char *cipher_key,
4836 void *ciphered = NULL;
4837 unsigned int ciphered_len = 0;
4840 ret = _eet_data_descriptor_encode(NULL, edd, data_in, &size);
4841 if (cipher_key && ret)
4843 if (eet_cipher(ret, size, cipher_key,
4844 strlen(cipher_key), &ciphered, &ciphered_len))
4857 size = ciphered_len;
4865 } /* eet_data_descriptor_encode_cipher */
4868 eet_data_descriptor_encode(Eet_Data_Descriptor *edd,
4869 const void *data_in,
4872 return eet_data_descriptor_encode_cipher(edd, data_in, NULL, size_ret);
4873 } /* eet_data_descriptor_encode */