Commit 08fd28bf authored by Cedric BAIL's avatar Cedric BAIL

* eet: Add eet_data_node_decode_cipher and eet_data_node_read_cipher.


SVN revision: 45062
parent 793f9f24
......@@ -300,3 +300,4 @@
* Rewrite Eet_Data. Now you can do list/hash/array of strings and all
the test suite is passing.
* Add eet_data_node_decode_cipher and eet_data_node_read_cipher.
......@@ -1502,6 +1502,9 @@ eet_dictionary_string_check * example: values), and @p type is the basic data
EAPI void eet_node_del(Eet_Node *n);
EAPI void *eet_data_node_encode_cipher(Eet_Node *node, const char *key, int *size_ret);
EAPI void *eet_data_node_decode_cipher(const void *data_in, const char *key, int size_in);
EAPI Eet_Node *eet_data_node_read_cipher(Eet_File *ef, const char *name, const char *key);
EAPI int eet_data_node_write_cipher(Eet_File *ef, const char *name, const char *key, Eet_Node *node, int compress);
/***************************************************************************/
......
......@@ -1462,6 +1462,35 @@ eet_data_read_cipher(Eet_File *ef, Eet_Data_Descriptor *edd, const char *name, c
return data_dec;
}
EAPI Eet_Node *
eet_data_node_read_cipher(Eet_File *ef, const char *name, const char *key)
{
const Eet_Dictionary *ed = NULL;
const void *data = NULL;
Eet_Node *result;
Eet_Free_Context context;
int required_free = 0;
int size;
ed = eet_dictionary_get(ef);
if (!key)
data = eet_read_direct(ef, name, &size);
if (!data)
{
required_free = 1;
data = eet_read_cipher(ef, name, &size, key);
if (!data) return NULL;
}
memset(&context, 0, sizeof (context));
result = _eet_data_descriptor_decode(&context, ed, NULL, data, size);
if (required_free)
free((void*)data);
return result;
}
EAPI void *
eet_data_read(Eet_File *ef, Eet_Data_Descriptor *edd, const char *name)
{
......@@ -3177,10 +3206,10 @@ eet_data_descriptor_decode_cipher(Eet_Data_Descriptor *edd,
const char *key,
int size_in)
{
void *deciphered = NULL;
void *deciphered = (void*) data_in;
void *ret;
Eet_Free_Context context;
unsigned int deciphered_len = 0;
unsigned int deciphered_len = size_in;
if (key && data_in)
{
......@@ -3189,13 +3218,14 @@ eet_data_descriptor_decode_cipher(Eet_Data_Descriptor *edd,
if (deciphered) free(deciphered);
return NULL;
}
memset(&context, 0, sizeof (context));
ret = _eet_data_descriptor_decode(&context, NULL, edd, deciphered, deciphered_len);
free(deciphered);
return ret;
}
memset(&context, 0, sizeof (context));
return _eet_data_descriptor_decode(&context, NULL, edd, data_in, size_in);
ret = _eet_data_descriptor_decode(&context, NULL, edd, deciphered, deciphered_len);
if (data_in != deciphered) free(deciphered);
return ret;
}
EAPI void *
......@@ -3206,6 +3236,31 @@ eet_data_descriptor_decode(Eet_Data_Descriptor *edd,
return eet_data_descriptor_decode_cipher(edd, data_in, NULL, size_in);
}
EAPI void *
eet_data_node_decode_cipher(const void *data_in, const char *key, int size_in)
{
void *deciphered = (void*) data_in;
Eet_Node *ret;
Eet_Free_Context context;
unsigned int deciphered_len = size_in;
if (key && data_in)
{
if (eet_decipher(data_in, size_in, key, strlen(key), &deciphered, &deciphered_len))
{
if (deciphered) free(deciphered);
return NULL;
}
}
memset(&context, 0, sizeof (context));
ret = _eet_data_descriptor_decode(&context, NULL, NULL, deciphered, deciphered_len);
if (data_in != deciphered) free(deciphered);
return ret;
}
static void *
_eet_data_descriptor_encode(Eet_Dictionary *ed,
Eet_Data_Descriptor *edd,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment