diff --git a/legacy/eet/src/bin/Makefile.am b/legacy/eet/src/bin/Makefile.am index b66a83111d..c0991c6dca 100644 --- a/legacy/eet/src/bin/Makefile.am +++ b/legacy/eet/src/bin/Makefile.am @@ -9,6 +9,7 @@ AM_CPPFLAGS = \ -DPACKAGE_LIB_DIR=\"$(libdir)\" \ -DPACKAGE_DATA_DIR=\"$(datadir)/$(PACKAGE)\" \ @EET_CPPFLAGS@ \ +@EINA_CFLAGS@ \ @EVIL_CFLAGS@ bin_PROGRAMS = eet diff --git a/legacy/eet/src/lib/Eet.h b/legacy/eet/src/lib/Eet.h index c09dcf6722..b2f3f2fb65 100644 --- a/legacy/eet/src/lib/Eet.h +++ b/legacy/eet/src/lib/Eet.h @@ -3,6 +3,7 @@ #include #include +#include #ifdef EAPI # undef EAPI @@ -104,6 +105,7 @@ extern "C" { typedef struct _Eet_Dictionary Eet_Dictionary; typedef struct _Eet_Data_Descriptor Eet_Data_Descriptor; typedef struct _Eet_Key Eet_Key; + typedef struct _Eet_Node Eet_Node; typedef struct _Eet_Data_Descriptor_Class Eet_Data_Descriptor_Class; @@ -1355,6 +1357,30 @@ eet_dictionary_string_check * example: values), and @p type is the basic data } /***************************************************************************/ + + EAPI Eet_Node *eet_node_char_new(const char *name, char c); + EAPI Eet_Node *eet_node_short_new(const char *name, short s); + EAPI Eet_Node *eet_node_int_new(const char *name, int i); + EAPI Eet_Node *eet_node_long_long_new(const char *name, long long l); + EAPI Eet_Node *eet_node_float_new(const char *name, float f); + EAPI Eet_Node *eet_node_double_new(const char *name, double d); + EAPI Eet_Node *eet_node_unsigned_char_new(const char *name, unsigned char uc); + EAPI Eet_Node *eet_node_unsigned_short_new(const char *name, unsigned short us); + EAPI Eet_Node *eet_node_unsigned_int_new(const char *name, unsigned int ui); + EAPI Eet_Node *eet_node_string_new(const char *name, const char *str); + EAPI Eet_Node *eet_node_inlined_string_new(const char *name, const char *str); + EAPI Eet_Node *eet_node_null_new(const char *name); + EAPI Eet_Node *eet_node_list_new(const char *name, Eina_List *nodes); + EAPI Eet_Node *eet_node_array_new(const char *name, int count, Eina_List *nodes); + EAPI Eet_Node *eet_node_var_array_new(const char *name, int count, Eina_List *nodes); + EAPI Eet_Node *eet_node_hash_new(const char *name, const char *key, Eina_List *nodes); + EAPI Eet_Node *eet_node_struct_new(const char *name, Eina_List *nodes); + EAPI void eet_node_del(Eet_Node *n); + + EAPI void *eet_data_node_encode_cipher(Eet_Node *node, const char *key, int *size_ret); + +/***************************************************************************/ + #ifdef __cplusplus } #endif diff --git a/legacy/eet/src/lib/Eet_private.h b/legacy/eet/src/lib/Eet_private.h index 46d34367ce..1eadd6257f 100644 --- a/legacy/eet/src/lib/Eet_private.h +++ b/legacy/eet/src/lib/Eet_private.h @@ -5,13 +5,6 @@ #ifndef _EET_PRIVATE_H #define _EET_PRIVATE_H -#ifdef __GNUC__ -# if __GNUC__ >= 4 -// BROKEN in gcc 4 on amd64 -//# pragma GCC visibility push(hidden) -# endif -#endif - #ifdef HAVE_CONFIG_H # include #endif @@ -57,6 +50,30 @@ struct _Eet_Dictionary const char *end; }; +struct _Eet_Node +{ + int type; + int count; + const char *name; + const char *key; + Eet_Node *values; + Eet_Node *next; + Eet_Node *parent; + union { + char c; + short s; + int i; + long long l; + float f; + double d; + unsigned char uc; + unsigned short us; + unsigned int ui; + unsigned long long ul; + const char *str; + } data; +}; + Eet_Dictionary *eet_dictionary_add(void); void eet_dictionary_free(Eet_Dictionary *ed); int eet_dictionary_string_add(Eet_Dictionary *ed, const char *string); diff --git a/legacy/eet/src/lib/Makefile.am b/legacy/eet/src/lib/Makefile.am index e24d080f73..6739dcc350 100644 --- a/legacy/eet/src/lib/Makefile.am +++ b/legacy/eet/src/lib/Makefile.am @@ -26,6 +26,7 @@ eet_data.c \ eet_image.c \ eet_cipher.c \ eet_dictionary.c \ +eet_node.c \ eet_utils.c libeet_la_CFLAGS = @EET_CFLAGS@ @DEBUG_CFLAGS@ diff --git a/legacy/eet/src/lib/eet_data.c b/legacy/eet/src/lib/eet_data.c index 9157c26ef7..52ea5ab39a 100644 --- a/legacy/eet/src/lib/eet_data.c +++ b/legacy/eet/src/lib/eet_data.c @@ -1673,84 +1673,16 @@ _eet_data_dump_token_get(const char *src, int *len) return NULL; } -typedef struct _Node Node; - -struct _Node -{ - int type; - int count; - char *name; - char *key; - Node *values; - Node *next; - Node *parent; - union { - char c; - short s; - int i; - long long l; - float f; - double d; - unsigned char uc; - unsigned short us; - unsigned int ui; - unsigned long long ul; - char *str; - } data; -}; - -static void -_eet_data_dump_free(Node *node) -{ - Node *n, *n2; - - switch (node->type) - { - case EET_G_UNKNOWN: - case EET_G_ARRAY: - case EET_G_VAR_ARRAY: - case EET_G_LIST: - case EET_G_HASH: - if (node->key) free(node->key); - for (n = node->values; n;) - { - n2 = n; - n = n->next; - _eet_data_dump_free(n2); - } - break; - case EET_T_CHAR: - case EET_T_SHORT: - case EET_T_INT: - case EET_T_LONG_LONG: - case EET_T_FLOAT: - case EET_T_DOUBLE: - case EET_T_UCHAR: - case EET_T_USHORT: - case EET_T_UINT: - case EET_T_ULONG_LONG: - case EET_T_NULL: - break; - case EET_T_INLINED_STRING: - case EET_T_STRING: - if (node->data.str) free(node->data.str); - break; - default: - break; - } - free(node); -} - static void * _eet_data_dump_encode(Eet_Dictionary *ed, - Node *node, + Eet_Node *node, int *size_ret) { Eet_Data_Chunk *chnk = NULL, *echnk = NULL; Eet_Data_Stream *ds; void *cdata, *data; int csize, size; - Node *n; + Eet_Node *n; if (words_bigendian == -1) { @@ -1996,9 +1928,9 @@ _eet_data_dump_parse(Eet_Dictionary *ed, #define M_STRUCT 1 #define M_ 2 int left, jump; - Node *node_base = NULL; - Node *node = NULL; - Node *n, *nn; + Eet_Node *node_base = NULL; + Eet_Node *node = NULL; + Eet_Node *n, *nn; /* FIXME; handle parse errors */ #define TOK_GET(t) \ @@ -2025,7 +1957,7 @@ _eet_data_dump_parse(Eet_Dictionary *ed, if (!strcmp(tok4, "{")) { /* we have 'group NAM TYP {' */ - n = calloc(1, sizeof(Node)); + n = calloc(1, sizeof(Eet_Node)); if (n) { n->parent = node; @@ -2050,7 +1982,7 @@ _eet_data_dump_parse(Eet_Dictionary *ed, } } } - n->name = strdup(tok2); + n->name = eina_stringshare_add(tok2); if (!strcmp(tok3, "struct")) n->type = EET_G_UNKNOWN; else if (!strcmp(tok3, "array")) n->type = EET_G_ARRAY; else if (!strcmp(tok3, "var_array")) n->type = EET_G_VAR_ARRAY; @@ -2084,7 +2016,7 @@ _eet_data_dump_parse(Eet_Dictionary *ed, /* we have 'value NAME TYP XXX' */ if (node_base) { - n = calloc(1, sizeof(Node)); + n = calloc(1, sizeof(Eet_Node)); if (n) { n->parent = node; @@ -2102,7 +2034,7 @@ _eet_data_dump_parse(Eet_Dictionary *ed, } } } - n->name = strdup(tok2); + n->name = eina_stringshare_add(tok2); if (!strcmp(tok3, "char:")) { n->type = EET_T_CHAR; @@ -2156,12 +2088,12 @@ _eet_data_dump_parse(Eet_Dictionary *ed, else if (!strcmp(tok3, "string:")) { n->type = EET_T_STRING; - n->data.str = strdup(tok4); + n->data.str = eina_stringshare_add(tok4); } else if (!strcmp(tok3, "inlined:")) { n->type = EET_T_INLINED_STRING; - n->data.str = strdup(tok4); + n->data.str = eina_stringshare_add(tok4); } else if (!strcmp(tok3, "null")) { @@ -2189,7 +2121,7 @@ _eet_data_dump_parse(Eet_Dictionary *ed, /* we have 'key NAME' */ if (node) { - node->key = strdup(tok2); + node->key = eina_stringshare_add(tok2); } free(tok2); } @@ -2219,7 +2151,7 @@ _eet_data_dump_parse(Eet_Dictionary *ed, if (node_base) { cdata = _eet_data_dump_encode(ed, node_base, size_ret); - _eet_data_dump_free(node_base); + eet_node_del(node_base); } return cdata; } @@ -3328,6 +3260,35 @@ _eet_data_descriptor_encode(Eet_Dictionary *ed, return cdata; } +EAPI void * +eet_data_node_encode_cipher(Eet_Node *node, + const char *key, + int *size_ret) +{ + void *ret = NULL; + void *ciphered = NULL; + unsigned int ciphered_len = 0; + int size; + + ret = _eet_data_dump_encode(NULL, node, &size); + if (key && ret) + { + if (eet_cipher(ret, size, key, strlen(key), &ciphered, &ciphered_len)) + { + if (ciphered) free(ciphered); + if (size_ret) *size_ret = 0; + free(ret); + return NULL; + } + free(ret); + size = (int) ciphered_len; + ret = ciphered; + } + + if (size_ret) *size_ret = size; + return ret; +} + EAPI void * eet_data_descriptor_encode_cipher(Eet_Data_Descriptor *edd, const void *data_in, @@ -3337,21 +3298,24 @@ eet_data_descriptor_encode_cipher(Eet_Data_Descriptor *edd, void *ret = NULL; void *ciphered = NULL; unsigned int ciphered_len = 0; + int size; - ret = _eet_data_descriptor_encode(NULL, edd, data_in, size_ret); + ret = _eet_data_descriptor_encode(NULL, edd, data_in, &size); if (key && ret) { - if (eet_cipher(ret, *size_ret, key, strlen(key), &ciphered, &ciphered_len)) + if (eet_cipher(ret, size, key, strlen(key), &ciphered, &ciphered_len)) { if (ciphered) free(ciphered); - size_ret = 0; + if (size_ret) *size_ret = 0; free(ret); return NULL; } free(ret); - *size_ret = ciphered_len; + size = ciphered_len; ret = ciphered; } + + if (size_ret) *size_ret = size; return ret; }