diff options
author | Denys Vlasenko <dvlasenk@redhat.com> | 2010-12-08 14:51:47 +0100 |
---|---|---|
committer | Denys Vlasenko <dvlasenk@redhat.com> | 2010-12-08 14:51:47 +0100 |
commit | 816f3e001271ed8ab7fdadb6d90aeb2c61362dac (patch) | |
tree | a7e453859a80fb47c7c74cb37791e35ad50f1d97 /src/lib/abrt_dbus.c | |
parent | 3a9554929de070297a0e816eb2839291335a9403 (diff) | |
download | abrt-816f3e001271ed8ab7fdadb6d90aeb2c61362dac.tar.gz abrt-816f3e001271ed8ab7fdadb6d90aeb2c61362dac.tar.xz abrt-816f3e001271ed8ab7fdadb6d90aeb2c61362dac.zip |
removal of C++isms from libabrt, part 1
This patch converts libabrt usage of C++ map<string, string>
to a glib-based container, GHashTable.
It is typedef-ed to map_string_h.
We can't typedef it to map_string_t, since other parts of ABRT
(daemon, cli) still use that name for C++ container.
Also, exceptions are removed everywhere.
Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
Diffstat (limited to 'src/lib/abrt_dbus.c')
-rw-r--r-- | src/lib/abrt_dbus.c | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/src/lib/abrt_dbus.c b/src/lib/abrt_dbus.c index 2ba5fa12..69ac1241 100644 --- a/src/lib/abrt_dbus.c +++ b/src/lib/abrt_dbus.c @@ -156,6 +156,34 @@ void store_string(DBusMessageIter* iter, const char* val) free((char*)sanitized); } +/* Helper for storing map_string */ +void store_map_string(DBusMessageIter* dbus_iter, map_string_h *val) +{ + DBusMessageIter sub_iter; + /* map_string is a map. map in dbus is an array of two element structs "({...})": + * "s" (string) for key and "s" for value (in this case, also string) */ + if (!dbus_message_iter_open_container(dbus_iter, DBUS_TYPE_ARRAY, "{ss}", &sub_iter)) + die_out_of_memory(); + + GHashTableIter iter; + char *name; + char *value; + g_hash_table_iter_init(&iter, val); + while (g_hash_table_iter_next(&iter, (void**)&name, (void**)&value)) + { + DBusMessageIter sub_sub_iter; + if (!dbus_message_iter_open_container(&sub_iter, DBUS_TYPE_DICT_ENTRY, NULL, &sub_sub_iter)) + die_out_of_memory(); + store_string(&sub_sub_iter, name); + store_string(&sub_sub_iter, value); + if (!dbus_message_iter_close_container(&sub_iter, &sub_sub_iter)) + die_out_of_memory(); + } + + if (!dbus_message_iter_close_container(dbus_iter, &sub_iter)) + die_out_of_memory(); +} + /* Helpers for storing crash_data */ static void store_crash_item(DBusMessageIter* iter, struct crash_item *val) |