/** * Get the contents of a defined structure property and load it into the passed * C struct * @param key The name of the structure property to look up. * @param data The struct to write into. * @return @c ECORE_CONFIG_ERR_SUCC if the structure is written successfully. * @ingroup Ecore_Config_Struct_Group */ EAPI int ecore_config_struct_get(const char *key, void *data) { Ecore_Config_Prop *e, *f; Eina_List *l; unsigned char *ptr; long argb; e = ecore_config_get(key); if (!e) return ECORE_CONFIG_ERR_NODATA; l = e->data; ptr = data; while (l) { f = (Ecore_Config_Prop *) l->data; switch (f->type) { case ECORE_CONFIG_INT: *((int *) ptr) = _ecore_config_int_get(f); ptr += sizeof(int); break; case ECORE_CONFIG_BLN: *((int *) ptr) = _ecore_config_boolean_get(f); ptr += sizeof(int); break; case ECORE_CONFIG_FLT: *((float *) ptr) = _ecore_config_float_get(f); ptr += sizeof(float); break; case ECORE_CONFIG_STR: case ECORE_CONFIG_THM: *((char **) ptr) = _ecore_config_string_get(f); ptr += sizeof(char *); break; case ECORE_CONFIG_RGB: argb = _ecore_config_argbint_get(f); *((int *) ptr) = (argb >> 24) & 0xff; ptr += sizeof(int); *((int *) ptr) = (argb >> 16) & 0xff; ptr += sizeof(int); *((int *) ptr) = (argb >> 8) & 0xff; ptr += sizeof(int); *((int *) ptr) = argb & 0xff; ptr += sizeof(int); break; default: WRN("ARGH - STRUCT coding not implemented yet"); } l = eina_list_next(l); } return ECORE_CONFIG_ERR_SUCC; }
/** * Retrieves the key as a string. * @param key The property key. * @return Returns a character array in the form of 'key:type=value'. @c NULL * is returned if the property does not exist. * @ingroup Ecore_Config_Get_Group */ EAPI char * ecore_config_as_string_get(const char *key) { Ecore_Config_Prop *e; char *val; char *r; val = NULL; r = NULL; if (!(e = ecore_config_get(key))) ERR("no such property, \"%s\"...", key); else { switch (e->type) { case ECORE_CONFIG_NIL: val = strdup("<nil>"); break; case ECORE_CONFIG_INT: esprintf(&val, "%ld", _ecore_config_int_get(e)); break; case ECORE_CONFIG_BLN: esprintf(&val, "%ld", _ecore_config_boolean_get(e)); break; case ECORE_CONFIG_FLT: esprintf(&val, "%lf", _ecore_config_float_get(e)); break; case ECORE_CONFIG_STR: esprintf(&val, "\"%s\"", _ecore_config_string_get(e)); break; case ECORE_CONFIG_RGB: esprintf(&val, "#%08x", _ecore_config_int_get(e)); break; case ECORE_CONFIG_THM: esprintf(&val, "\"%s\"", _ecore_config_theme_get(e)); break; case ECORE_CONFIG_SCT: break; default: esprintf(&r, "%s:unknown_type", key); break; } if (val) { esprintf(&r, "%s:%s=%s", key, _ecore_config_type[e->type], val); free(val); } } return r; }
void _ecore_config_db_write(Ecore_Config_DB_File *db, Ecore_Config_Prop *e) { char *prev_locale= NULL; char *val = NULL; char *r = NULL; int num; prev_locale = setlocale(LC_NUMERIC, "C"); switch (e->type) { case ECORE_CONFIG_INT: esprintf(&val, "%i", _ecore_config_int_get(e)); break; case ECORE_CONFIG_BLN: esprintf(&val, "%i", _ecore_config_boolean_get(e)); break; case ECORE_CONFIG_FLT: esprintf(&val, "%16.16f", _ecore_config_float_get(e)); break; case ECORE_CONFIG_STR: val = _ecore_config_string_get(e); break; case ECORE_CONFIG_THM: val = _ecore_config_theme_get(e); break; case ECORE_CONFIG_RGB: val = _ecore_config_argbstr_get(e); break; default: WRN("Type %d not handled", e->type); } if (prev_locale) { setlocale(LC_NUMERIC, prev_locale); } if(val) { num = esprintf(&r, "%c%c%s%c", (char) e->type, 0, val, 0); if(num) eet_write(db->ef, e->key, r, num, 1); free(r); } free(val); }
/** * Returns the specified property as a float. * @param key The property key. * @return The float value of the property. The function returns 0.0 if the * property is not a float or is not set. * @ingroup Ecore_Config_Get_Group */ EAPI float ecore_config_float_get(const char *key) { return _ecore_config_float_get( ecore_config_get(key) ); }