forked from enlightenment/efl
parent
819e078f4d
commit
9506bc06df
|
@ -56,11 +56,6 @@ efreet_ini_new(const char *file)
|
||||||
if (!ini) return NULL;
|
if (!ini) return NULL;
|
||||||
|
|
||||||
ini->data = efreet_ini_parse(file);
|
ini->data = efreet_ini_parse(file);
|
||||||
if (!ini->data)
|
|
||||||
{
|
|
||||||
FREE(ini);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
return ini;
|
return ini;
|
||||||
}
|
}
|
||||||
|
@ -98,15 +93,13 @@ efreet_ini_parse(const char *file)
|
||||||
buf = read_buf = static_buf;
|
buf = read_buf = static_buf;
|
||||||
read_len = static_buf_len;
|
read_len = static_buf_len;
|
||||||
|
|
||||||
data = ecore_hash_new(ecore_str_hash, ecore_str_compare);
|
f = fopen(file, "rb");
|
||||||
if (!data) return NULL;
|
if (!f) return NULL;
|
||||||
|
|
||||||
|
data = ecore_hash_new(ecore_str_hash, ecore_str_compare);
|
||||||
ecore_hash_free_key_cb_set(data, ECORE_FREE_CB(ecore_string_release));
|
ecore_hash_free_key_cb_set(data, ECORE_FREE_CB(ecore_string_release));
|
||||||
ecore_hash_free_value_cb_set(data, ECORE_FREE_CB(ecore_hash_destroy));
|
ecore_hash_free_value_cb_set(data, ECORE_FREE_CB(ecore_hash_destroy));
|
||||||
|
|
||||||
f = fopen(file, "rb");
|
|
||||||
if (!f) return data;
|
|
||||||
|
|
||||||
/* if a line is longer than the buffer size, this \n will get overwritten. */
|
/* if a line is longer than the buffer size, this \n will get overwritten. */
|
||||||
read_buf[read_len - 2] = '\n';
|
read_buf[read_len - 2] = '\n';
|
||||||
while (fgets(read_buf, read_len, f) != NULL)
|
while (fgets(read_buf, read_len, f) != NULL)
|
||||||
|
@ -273,7 +266,7 @@ int
|
||||||
efreet_ini_save(Efreet_Ini *ini, const char *file)
|
efreet_ini_save(Efreet_Ini *ini, const char *file)
|
||||||
{
|
{
|
||||||
FILE *f;
|
FILE *f;
|
||||||
if (!ini) return 0;
|
if (!ini || !ini->data) return 0;
|
||||||
|
|
||||||
f = fopen(file, "wb");
|
f = fopen(file, "wb");
|
||||||
if (!f) return 0;
|
if (!f) return 0;
|
||||||
|
@ -293,7 +286,7 @@ efreet_ini_save(Efreet_Ini *ini, const char *file)
|
||||||
int
|
int
|
||||||
efreet_ini_section_set(Efreet_Ini *ini, const char *section)
|
efreet_ini_section_set(Efreet_Ini *ini, const char *section)
|
||||||
{
|
{
|
||||||
if (!ini || !section) return 0;
|
if (!ini || !ini->data || !section) return 0;
|
||||||
|
|
||||||
ini->section = ecore_hash_get(ini->data, section);
|
ini->section = ecore_hash_get(ini->data, section);
|
||||||
return (ini->section ? 1 : 0);
|
return (ini->section ? 1 : 0);
|
||||||
|
|
Loading…
Reference in New Issue