1 #include <Eina.h>
2 #include <Eet.h>
3 #include "e_macros.h"
4 #define E_TYPEDEFS
5 #include "e_config_data.h"
6 #undef E_TYPEDEFS
7 #include "e_config_data.h"
8 
9 static Eina_Hash *config_hash = NULL;
10 
11 E_API void
e_config_descriptor_free(E_Config_DD * edd)12 e_config_descriptor_free(E_Config_DD *edd)
13 {
14    eina_hash_del_by_key(config_hash, eet_data_descriptor_name_get((Eet_Data_Descriptor*)edd));
15    eet_data_descriptor_free((Eet_Data_Descriptor*)edd);
16 }
17 
18 E_API E_Config_DD *
e_config_descriptor_new(const char * name,int size)19 e_config_descriptor_new(const char *name, int size)
20 {
21    Eet_Data_Descriptor_Class eddc;
22    E_Config_DD *edd;
23 
24    if (!eet_eina_stream_data_descriptor_class_set(&eddc, sizeof (eddc), name, size))
25      return NULL;
26 
27    /* FIXME: We can directly map string inside an Eet_File and reuse it.
28       But this need a break in all user of config every where in E.
29     */
30 
31    edd = (E_Config_DD *)eet_data_descriptor_stream_new(&eddc);
32 
33    if (!config_hash) config_hash = eina_hash_string_superfast_new(NULL);
34    eina_hash_set(config_hash, name, edd);
35    return edd;
36 }
37 
38 E_API E_Config_DD *
e_config_descriptor_find(const char * name)39 e_config_descriptor_find(const char *name)
40 {
41    EINA_SAFETY_ON_NULL_RETURN_VAL(name, NULL);
42    return eina_hash_find(config_hash, name);
43 }
44