Enlightenment CVS committal Author : raster Project : e17 Module : libs/ecore
Dir : e17/libs/ecore/src/lib/ecore_config Modified Files: Makefile.am ecore_config.c ecore_config_ipc_ecore.c ecore_config_private.h ecore_config_storage.c Added Files: ecore_config_db.c Log Message: ecore_config uses eet for storage now... check the disk space savings: -rw-r--r-- 1 raster raster 12288 Oct 19 15:29 config.db -rw-r--r-- 1 raster raster 687 Oct 19 15:29 config.eet also.. edb goes back to obscurity as a little/non use lib again :) =================================================================== RCS file: /cvsroot/enlightenment/e17/libs/ecore/src/lib/ecore_config/Makefile.am,v retrieving revision 1.23 retrieving revision 1.24 diff -u -3 -r1.23 -r1.24 --- Makefile.am 13 Oct 2004 19:43:16 -0000 1.23 +++ Makefile.am 19 Oct 2004 06:34:20 -0000 1.24 @@ -7,7 +7,7 @@ -I$(top_builddir)/src/lib/ecore \ -I$(top_builddir)/src/lib/ecore_ipc \ -I$(top_builddir)/ \ [EMAIL PROTECTED]@ @edb_cflags@ [EMAIL PROTECTED]@ @eet_cflags@ CLEANFILES = $(DB) @@ -19,19 +19,19 @@ if BUILD_ECORE_CONFIG -DB = system.db -$(DB): Makefile - edb_ed $(top_builddir)/src/lib/ecore_config/$(DB) add /e/theme/name str "winter" - edb_ed $(top_builddir)/src/lib/ecore_config/$(DB) add /e/font/path str "$(pkgdatadir)/data/fonts" - edb_ed $(top_builddir)/src/lib/ecore_config/$(DB) add /apps/web/browser str `which firefox 2>/dev/null || which phoenix 2>/dev/null || which mozilla 2>/dev/null || which opera 2>/dev/null || which konqueror 2>/dev/null || which epiphany 2>/dev/null` - edb_ed $(top_builddir)/src/lib/ecore_config/$(DB) add /apps/web/email str `which thunderbird 2>/dev/null || which mozilla 2>/dev/null || which kmail 2>/dev/null || which sylpheed 2>/dev/null || which evolution 2>/dev/null` +#DB = system.db +#$(DB): Makefile +# edb_ed $(top_builddir)/src/lib/ecore_config/$(DB) add /e/theme/name str "winter" +# edb_ed $(top_builddir)/src/lib/ecore_config/$(DB) add /e/font/path str "$(pkgdatadir)/data/fonts" +# edb_ed $(top_builddir)/src/lib/ecore_config/$(DB) add /apps/web/browser str `which firefox 2>/dev/null || which phoenix 2>/dev/null || which mozilla 2>/dev/null || which opera 2>/dev/null || which konqueror 2>/dev/null || which epiphany 2>/dev/null` +# edb_ed $(top_builddir)/src/lib/ecore_config/$(DB) add /apps/web/email str `which thunderbird 2>/dev/null || which mozilla 2>/dev/null || which kmail 2>/dev/null || which sylpheed 2>/dev/null || which evolution 2>/dev/null` lib_LTLIBRARIES = libecore_config.la ecore_config_ipc_ecore.la include_HEADERS = \ Ecore_Config.h -config_DATA = $(DB) -configdir = $(pkgdatadir) +#config_DATA = $(DB) +#configdir = $(pkgdatadir) libecore_config_la_SOURCES = \ ecore_config.c \ @@ -39,11 +39,12 @@ ecore_config_util.c \ ecore_config_storage.c \ ecore_config_extra.c \ +ecore_config_db.c \ ecore_config_private.h libecore_config_la_LIBADD = \ $(top_builddir)/src/lib/ecore/libecore.la \ [EMAIL PROTECTED]@ \ [EMAIL PROTECTED]@ \ @evas_libs@ libecore_config_la_DEPENDENCIES = \ @@ -60,7 +61,7 @@ $(top_builddir)/src/lib/ecore/libecore.la \ $(top_builddir)/src/lib/ecore_ipc/libecore_ipc.la \ libecore_config.la \ [EMAIL PROTECTED]@ \ [EMAIL PROTECTED]@ \ @evas_libs@ endif =================================================================== RCS file: /cvsroot/enlightenment/e17/libs/ecore/src/lib/ecore_config/ecore_config.c,v retrieving revision 1.51 retrieving revision 1.52 diff -u -3 -r1.51 -r1.52 --- ecore_config.c 13 Oct 2004 19:43:16 -0000 1.51 +++ ecore_config.c 19 Oct 2004 06:34:20 -0000 1.52 @@ -1561,9 +1561,9 @@ { /* debug-only ### FIXME */ if ((buf = malloc(PATH_MAX * sizeof(char)))) { - snprintf(buf, PATH_MAX, "%s/.e/config.db", p); + snprintf(buf, PATH_MAX, "%s/.e/config.eet", p); if (ecore_config_file_load(buf) != 0) - if (ecore_config_file_load(PACKAGE_DATA_DIR "/system.db") != 0) + if (ecore_config_file_load(PACKAGE_DATA_DIR "/system.eet") != 0) return ECORE_CONFIG_ERR_NOFILE; sys = __ecore_config_bundle_local->data; while (sys) =================================================================== RCS file: /cvsroot/enlightenment/e17/libs/ecore/src/lib/ecore_config/ecore_config_ipc_ecore.c,v retrieving revision 1.1 retrieving revision 1.2 diff -u -3 -r1.1 -r1.2 --- ecore_config_ipc_ecore.c 13 Oct 2004 19:43:16 -0000 1.1 +++ ecore_config_ipc_ecore.c 19 Oct 2004 06:34:20 -0000 1.2 @@ -1,8 +1,6 @@ /* by Azundris, with thanks to Corey Donohoe <[EMAIL PROTECTED]> */ - #include "ecore_config_ipc.h" #include "ecore_config_util.h" - #include "ecore_config_private.h" #include <stdio.h> @@ -18,8 +16,6 @@ #include <Ecore.h> #include <Ecore_Ipc.h> -#include <Edb.h> - #include "Ecore_Config.h" #include "config.h" @@ -51,68 +47,74 @@ char * _ecore_config_ipc_global_prop_list(Ecore_Config_Server * srv, const long serial) { - E_DB_File *db; - char **keys; - int key_count, x; - estring *s; - int f; - char *buf, *p, *type, *data; + Ecore_Config_DB_File *db; + char **keys; + int key_count, x; + estring *s; + int f; + char buf[PATH_MAX], *p, *type, *data; db = NULL; - buf = NULL; s = estring_new(8192); f = 0; if ((p = getenv("HOME"))) - { /* debug-only ### FIXME */ - if ((buf = malloc(PATH_MAX * sizeof(char)))) + { + snprintf(buf, sizeof(buf), "%s/.e/config.eet", p); + if (!(db = _ecore_config_db_open_read(buf))) { - snprintf(buf, PATH_MAX, "%s/.e/config.db", p); - db = e_db_open_read(buf); - if (!(db = e_db_open_read(buf))) - if (!(db = e_db_open_read(buf = PACKAGE_DATA_DIR "/system.db"))) - return NULL; + strcpy(buf, PACKAGE_DATA_DIR"/system.eet"); + if (!(db = _ecore_config_db_open_read(buf))) + return NULL; } } - - keys = e_db_dump_key_list(buf, &key_count); - free(buf); - - for (x = 0; x < key_count; x++) + if (!db) return NULL; + key_count = 0; + keys = _ecore_config_db_keys_get(db, &key_count); + if (keys) { - type = e_db_type_get(db, keys[x]); - if (!type) - type = "?"; - - if (!strcmp(type, "int")) - estring_appendf(s, "%s%s: integer", f ? "\n" : "", keys[x]); - else if (!strcmp(type, "float")) - estring_appendf(s, "%s%s: float", f ? "\n" : "", keys[x]); - else if (!strcmp(type, "str")) + for (x = 0; x < key_count; x++) { - data = e_db_str_get(db, keys[x]); - if (data) + type = _ecore_config_db_key_type_get(db, keys[x]); + if (!type) type = "?"; + if (!strcmp(type, "int")) + estring_appendf(s, "%s%s: integer", f ? "\n" : "", keys[x]); + else if (!strcmp(type, "float")) + estring_appendf(s, "%s%s: float", f ? "\n" : "", keys[x]); + else if (!strcmp(type, "str")) { - if (ecore_config_type_guess(keys[x], data) == PT_RGB) - estring_appendf(s, "%s%s: colour", f ? "\n" : "", keys[x]); + data = _ecore_config_db_key_str_get(db, keys[x]); + if (data) + { + if (ecore_config_type_guess(keys[x], data) == PT_RGB) + estring_appendf(s, "%s%s: colour", f ? "\n" : "", keys[x]); + else + estring_appendf(s, "%s%s: string", f ? "\n" : "", keys[x]); + free(data); + } else - estring_appendf(s, "%s%s: string", f ? "\n" : "", keys[x]); - free(data); + { + estring_appendf(s, "%s%s: string", f ? "\n" : "", keys[x]); + } } else { - estring_appendf(s, "%s%s: string", f ? "\n" : "", keys[x]); + estring_appendf(s, "%s%s: unknown", f ? "\n" : "", keys[x]); + continue; } + if (type) free(type); + f = 1; } - else - estring_appendf(s, "%s%s: unknown", f ? "\n" : "", keys[x]); - - if (type) - free(type); - f = 1; } - e_db_close(db); - free(keys); - + _ecore_config_db_close(db); + if (keys) + { + for (x = 0; x < key_count; x++) + { + free(keys[x]); + } + free(keys); + } + return estring_disown(s); } =================================================================== RCS file: /cvsroot/enlightenment/e17/libs/ecore/src/lib/ecore_config/ecore_config_private.h,v retrieving revision 1.2 retrieving revision 1.3 diff -u -3 -r1.2 -r1.3 --- ecore_config_private.h 26 May 2004 04:26:28 -0000 1.2 +++ ecore_config_private.h 19 Oct 2004 06:34:20 -0000 1.3 @@ -6,9 +6,20 @@ # define D(fmt,args...) do { if(DEBUG>=0) fprintf(stderr,fmt,## args); } while(0); # define E(lvl,args...) do { if(DEBUG>=(lvl)) fprintf(stderr,## args); } while(0) +typedef struct _Ecore_Config_DB_File Ecore_Config_DB_File; - - - +Ecore_Config_DB_File *_ecore_config_db_open_read(char *file); +Ecore_Config_DB_File *_ecore_config_db_open_write(char *file); +void _ecore_config_db_close(Ecore_Config_DB_File *db); +char **_ecore_config_db_keys_get(Ecore_Config_DB_File *db, int *num_ret); +char *_ecore_config_db_key_type_get(Ecore_Config_DB_File *db, char *key); +int _ecore_config_db_key_int_get(Ecore_Config_DB_File *db, char *key, int *dest); +int _ecore_config_db_key_float_get(Ecore_Config_DB_File *db, char *key, double *dest); +char *_ecore_config_db_key_str_get(Ecore_Config_DB_File *db, char *key); +void *_ecore_config_db_key_data_get(Ecore_Config_DB_File *db, char *key, int *size_ret); +void _ecore_config_db_key_int_set(Ecore_Config_DB_File *db, char *key, int val); +void _ecore_config_db_key_float_set(Ecore_Config_DB_File *db, char *key, double val); +void _ecore_config_db_key_str_set(Ecore_Config_DB_File *db, char *key, char *str); +void _ecore_config_db_key_data_set(Ecore_Config_DB_File *db, char *key, void *data, int data_size); #endif =================================================================== RCS file: /cvsroot/enlightenment/e17/libs/ecore/src/lib/ecore_config/ecore_config_storage.c,v retrieving revision 1.1 retrieving revision 1.2 diff -u -3 -r1.1 -r1.2 --- ecore_config_storage.c 13 Oct 2004 19:43:16 -0000 1.1 +++ ecore_config_storage.c 19 Oct 2004 06:34:20 -0000 1.2 @@ -1,6 +1,4 @@ -#include <Edb.h> #include "Ecore_Config.h" - #include "ecore_config_private.h" #include <stdlib.h> @@ -24,7 +22,7 @@ { char file[PATH_MAX]; - snprintf(file, PATH_MAX, "%s/.e/apps/%s/config.db", getenv("HOME"), + snprintf(file, PATH_MAX, "%s/.e/apps/%s/config.eet", getenv("HOME"), __ecore_config_app_name); return ecore_config_file_load(file); } @@ -41,7 +39,7 @@ { char file[PATH_MAX]; - snprintf(file, PATH_MAX, "%s/.e/apps/%s/config.db", getenv("HOME"), + snprintf(file, PATH_MAX, "%s/.e/apps/%s/config.eet", getenv("HOME"), __ecore_config_app_name); return ecore_config_file_save(file); } @@ -56,103 +54,110 @@ int ecore_config_file_load(char *file) { - E_DB_File *db; - char **keys; - int key_count; - int x, pt; - int itmp; - float ftmp; - char *type; - char *data; + Ecore_Config_DB_File *db; + char **keys; + int key_count; + int x, pt; + int itmp; + double ftmp; + char *type; + char *data; db = NULL; type = NULL; data = NULL; - db = e_db_open_read(file); + db = _ecore_config_db_open_read(file); if (!db) { E(0, "Cannot open database from file %s!\n", file); return ECORE_CONFIG_ERR_NODATA; } - - keys = e_db_dump_key_list(file, &key_count); - for (x = 0; x < key_count; x++) + key_count = 0; + keys = _ecore_config_db_keys_get(db, &key_count); + printf("keys = %p, %i\n", keys, key_count); + if (keys) { - - type = e_db_type_get(db, keys[x]); - if (!type) - type = "?"; - - if (!strcmp(type, "int")) + for (x = 0; x < key_count; x++) { - if (e_db_int_get(db, keys[x], &itmp)) + type = _ecore_config_db_key_type_get(db, keys[x]); + printf("%s == %s\n", keys[x], type); + if (!type) type = "?"; + if (!strcmp(type, "int")) { - Ecore_Config_Prop *p; - - pt = PT_INT; - if ((p = ecore_config_get(keys[x]))) pt = p->type; - switch (pt) + if (_ecore_config_db_key_int_get(db, keys[x], &itmp)) { - case PT_BLN: - ecore_config_boolean_set(keys[x], itmp); - break; - default: - ecore_config_int_set(keys[x], itmp); - break; + Ecore_Config_Prop *p; + + pt = PT_INT; + if ((p = ecore_config_get(keys[x]))) pt = p->type; + switch (pt) + { + case PT_BLN: + ecore_config_boolean_set(keys[x], itmp); + break; + default: + ecore_config_int_set(keys[x], itmp); + break; + } + } + else + { + E(0, "Could not read key %s!\n", keys[x]); } } - else - { - E(0, "Could not read key %s!\n", keys[x]); - } - } - else if (!strcmp(type, "float")) - { - if (e_db_float_get(db, keys[x], &ftmp)) - { - ecore_config_float_set(keys[x], ftmp); - } - else + else if (!strcmp(type, "float")) { - E(0, "Could not read key %s!\n", keys[x]); + if (_ecore_config_db_key_float_get(db, keys[x], &ftmp)) + { + ecore_config_float_set(keys[x], ftmp); + } + else + { + E(0, "Could not read key %s!\n", keys[x]); + } } - } - else if (!strcmp(type, "str")) - { - data = e_db_str_get(db, keys[x]); - if (data) + else if (!strcmp(type, "str")) { - pt = ecore_config_type_guess(keys[x], data); - switch (pt) + data = _ecore_config_db_key_str_get(db, keys[x]); + if (data) + { + pt = ecore_config_type_guess(keys[x], data); + switch (pt) + { + case PT_RGB: + ecore_config_argb_set(keys[x], data); + break; + case PT_THM: + ecore_config_theme_set(keys[x], data); + break; + default: + ecore_config_string_set(keys[x], data); + } + free(data); + } + else { - case PT_RGB: - ecore_config_argb_set(keys[x], data); - break; - case PT_THM: - ecore_config_theme_set(keys[x], data); - break; - default: - ecore_config_string_set(keys[x], data); + E(0, "Could not read key %s!\n", keys[x]); } - free(data); } else { - E(0, "Could not read key %s!\n", keys[x]); + E(1, "Unexpected type: %s\n", type); + continue; } + if (type) free(type); } - else + } + _ecore_config_db_close(db); + if (keys) + { + for (x = 0; x < key_count; x++) { - E(1, "Unexpected type: %s\n", type); - continue; + free(keys[x]); } - - if (type) - free(type); + free(keys); } - e_db_close(db); - free(keys); return ECORE_CONFIG_ERR_SUCC; } @@ -188,10 +193,10 @@ int ecore_config_file_save(char *file) { - Ecore_Config_Prop *next; - E_DB_File *db; - struct stat status; - char *tmp; + Ecore_Config_Prop *next; + Ecore_Config_DB_File *db; + struct stat status; + char *tmp; next = __ecore_config_bundle_local->data; db = NULL; @@ -200,7 +205,7 @@ if (stat(file, &status)) _ecore_config_recurse_mkdir(file); - db = e_db_open(file); + db = _ecore_config_db_open_write(file); if (!db) { E(0, "Cannot open database from file %s!\n", file); @@ -209,24 +214,25 @@ while (next) { + /* let the config_db deal with this if (!(next->flags & PF_MODIFIED)) { next = next->next; continue; } - + */ tmp = NULL; switch (next->type) { case PT_INT: - e_db_int_set(db, next->key, ecore_config_int_get(next->key)); + _ecore_config_db_key_int_set(db, next->key, ecore_config_int_get(next->key)); break; case PT_BLN: - e_db_int_set(db, next->key, ecore_config_boolean_get(next->key)); + _ecore_config_db_key_int_set(db, next->key, ecore_config_boolean_get(next->key)); break; case PT_FLT: - e_db_float_set(db, next->key, ecore_config_float_get(next->key)); + _ecore_config_db_key_float_set(db, next->key, ecore_config_float_get(next->key)); break; case PT_RGB: tmp = ecore_config_argbstr_get(next->key); @@ -243,14 +249,13 @@ } if (tmp) { - e_db_str_set(db, next->key, tmp); + _ecore_config_db_key_str_set(db, next->key, tmp); free(tmp); } next = next->next; } - e_db_close(db); - e_db_flush(); + _ecore_config_db_close(db); return ECORE_CONFIG_ERR_SUCC; } ------------------------------------------------------- This SF.net email is sponsored by: IT Product Guide on ITManagersJournal Use IT products in your business? Tell us what you think of them. Give us Your Opinions, Get Free ThinkGeek Gift Certificates! Click to find out more http://productguide.itmanagersjournal.com/guidepromo.tmpl _______________________________________________ enlightenment-cvs mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs