diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/wkb-ibus-config-eet-test.c | 1 | ||||
-rw-r--r-- | src/wkb-ibus-config-eet.c | 68 | ||||
-rw-r--r-- | src/wkb-ibus-config-eet.h | 1 |
3 files changed, 70 insertions, 0 deletions
diff --git a/src/wkb-ibus-config-eet-test.c b/src/wkb-ibus-config-eet-test.c index 1c993e5..21176c0 100644 --- a/src/wkb-ibus-config-eet-test.c +++ b/src/wkb-ibus-config-eet-test.c @@ -36,6 +36,7 @@ main (int argc, char *argv[]) } cfg = wkb_ibus_config_eet_new("ibus-cfg.eet", NULL); + wkb_ibus_config_eet_dump(cfg); wkb_ibus_config_eet_free(cfg); ret = 0; wkb_ibus_config_eet_shutdown(); diff --git a/src/wkb-ibus-config-eet.c b/src/wkb-ibus-config-eet.c index 4f455cf..0ca56ab 100644 --- a/src/wkb-ibus-config-eet.c +++ b/src/wkb-ibus-config-eet.c @@ -151,6 +151,61 @@ end: return ret; } +void +_config_section_dump(struct _config_section *base, const char *tab) +{ + Eina_List *node; + struct _config_section *sec; + struct wkb_config_key *key; + const char *sig, *new_tab; + + EINA_LIST_FOREACH(base->keys, node, key) + { + printf("%s'%s/%s': ", tab, wkb_config_key_section(key), wkb_config_key_id(key)); + sig = wkb_config_key_signature(key); + switch (*sig) + { + case 's': + { + printf("'%s'\n", wkb_config_key_get_string(key)); + break; + } + case 'i': + { + printf("%d\n", wkb_config_key_get_int(key)); + break; + } + case 'b': + { + printf("%s\n", wkb_config_key_get_bool(key) ? "True" : "False"); + break; + } + case 'a': + { + char **s, **slist = wkb_config_key_get_string_list(key); + printf("{"); + for (s = slist; *s != NULL; ++s) + { + printf("'%s',", *s); + } + printf("}\n"); + free(slist); + break; + } + default: + break; + } + } + + new_tab = eina_stringshare_printf("\t%s", tab); + EINA_LIST_FOREACH(base->subsections, node, sec) + { + printf("%s%s'%s'\n", base->keys ? "\n" : "", tab, sec->id); + _config_section_dump(sec, new_tab); + } + eina_stringshare_del(new_tab); +} + #define _config_section_init(_section, _id, _parent) \ do { \ if (!_section) \ @@ -1180,3 +1235,16 @@ wkb_ibus_config_eet_shutdown() eet_shutdown(); } + +void +wkb_ibus_config_eet_dump(struct wkb_ibus_config_eet *eet) +{ + Eina_List *node; + struct _config_section *sec; + + EINA_LIST_FOREACH(eet->sections, node, sec) + { + printf("'%s'\n", sec->id); + _config_section_dump(sec, "\t"); + } +} diff --git a/src/wkb-ibus-config-eet.h b/src/wkb-ibus-config-eet.h index eeb7205..8fc9a6d 100644 --- a/src/wkb-ibus-config-eet.h +++ b/src/wkb-ibus-config-eet.h @@ -46,6 +46,7 @@ int wkb_ibus_config_eet_get_value_int(struct wkb_ibus_config_eet *config_eet, co Eina_Bool wkb_ibus_config_eet_get_value_bool(struct wkb_ibus_config_eet *config_eet, const char *section, const char *name); const char *wkb_ibus_config_eet_get_value_string(struct wkb_ibus_config_eet *config_eet, const char *section, const char *name); char **wkb_ibus_config_eet_get_value_string_list(struct wkb_ibus_config_eet *config_eet, const char *section, const char *name); +void wkb_ibus_config_eet_dump(struct wkb_ibus_config_eet *config_eet); #ifdef __cplusplus } #endif |