2017-07-17 05:14:28 -07:00
|
|
|
#include <Eina.h>
|
|
|
|
#include <Eet.h>
|
|
|
|
#include "e_macros.h"
|
|
|
|
#define E_TYPEDEFS
|
|
|
|
#include "e_config_data.h"
|
|
|
|
#undef E_TYPEDEFS
|
|
|
|
#include "e_config_data.h"
|
2007-09-25 07:26:36 -07:00
|
|
|
|
2013-02-01 03:31:59 -08:00
|
|
|
static Eina_Hash *config_hash = NULL;
|
|
|
|
|
2015-05-07 12:13:10 -07:00
|
|
|
E_API void
|
2013-02-01 03:31:59 -08:00
|
|
|
e_config_descriptor_free(E_Config_DD *edd)
|
|
|
|
{
|
|
|
|
eina_hash_del_by_key(config_hash, eet_data_descriptor_name_get((Eet_Data_Descriptor*)edd));
|
|
|
|
eet_data_descriptor_free((Eet_Data_Descriptor*)edd);
|
|
|
|
}
|
|
|
|
|
2015-05-07 12:13:10 -07:00
|
|
|
E_API E_Config_DD *
|
2007-09-25 07:26:36 -07:00
|
|
|
e_config_descriptor_new(const char *name, int size)
|
|
|
|
{
|
|
|
|
Eet_Data_Descriptor_Class eddc;
|
2013-02-01 03:31:59 -08:00
|
|
|
E_Config_DD *edd;
|
2009-09-03 05:05:49 -07:00
|
|
|
|
2010-08-13 09:50:55 -07:00
|
|
|
if (!eet_eina_stream_data_descriptor_class_set(&eddc, sizeof (eddc), name, size))
|
2009-09-03 05:05:49 -07:00
|
|
|
return NULL;
|
|
|
|
|
2010-04-07 06:54:33 -07:00
|
|
|
/* FIXME: We can directly map string inside an Eet_File and reuse it.
|
|
|
|
But this need a break in all user of config every where in E.
|
2013-01-11 02:34:29 -08:00
|
|
|
*/
|
2009-09-03 05:05:49 -07:00
|
|
|
|
2013-02-01 03:31:59 -08:00
|
|
|
edd = (E_Config_DD *)eet_data_descriptor_stream_new(&eddc);
|
|
|
|
|
|
|
|
if (!config_hash) config_hash = eina_hash_string_superfast_new(NULL);
|
|
|
|
eina_hash_set(config_hash, name, edd);
|
|
|
|
return edd;
|
2007-09-25 07:26:36 -07:00
|
|
|
}
|
2013-01-11 02:34:29 -08:00
|
|
|
|
2015-05-07 12:13:10 -07:00
|
|
|
E_API E_Config_DD *
|
2013-02-01 03:31:59 -08:00
|
|
|
e_config_descriptor_find(const char *name)
|
|
|
|
{
|
|
|
|
EINA_SAFETY_ON_NULL_RETURN_VAL(name, NULL);
|
|
|
|
return eina_hash_find(config_hash, name);
|
|
|
|
}
|