summaryrefslogtreecommitdiffstats
path: root/src/plugins/abrt-action-mailx.cpp
diff options
context:
space:
mode:
authorDenys Vlasenko <dvlasenk@redhat.com>2010-12-06 16:56:50 +0100
committerDenys Vlasenko <dvlasenk@redhat.com>2010-12-06 16:56:50 +0100
commit47728cc3c70c2b6d3a645e5760b39b20bd946e39 (patch)
tree6fd64dc8d124d5a10dd4efddd69a71f921f4a1d1 /src/plugins/abrt-action-mailx.cpp
parent300a498bdc7b2912f8aaebeb87a7b4cc0a9970a5 (diff)
downloadabrt-47728cc3c70c2b6d3a645e5760b39b20bd946e39.tar.gz
abrt-47728cc3c70c2b6d3a645e5760b39b20bd946e39.tar.xz
abrt-47728cc3c70c2b6d3a645e5760b39b20bd946e39.zip
This patch changes crash data to use C structures.
The smallest data element is: struct crash_item { char *content; unsigned flags; }; where content is, eh, content, and flags is a bit flag field. crash_data_t is a map of crash_item's, implemented as a pointer to heap-allocated GHashTable. vector_of_crash_data_t is a vector of crash_data_t's, implemented as a pointer to heap-allocated GPtrArray. Most operations have light wrappers around them to hide the nature of the containers. For example, to free vector_of_crash_data, you need to use free_vector_of_crash_data(ptr) instead of open-coding g_ptr_array_free. The wrapper is thin. The goal is not so much to hide the implementation, but more to make it easier to use the correct function. dbus (un)marshalling functions convert crash_item to three-element array of strings, in order to keep compatibility with abrt-gui (python). This can be changed later to use native representation. crash_data_t and vector_of_crash_data_t are represented in "natural" way, no funny stuff there. Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
Diffstat (limited to 'src/plugins/abrt-action-mailx.cpp')
-rw-r--r--src/plugins/abrt-action-mailx.cpp20
1 files changed, 12 insertions, 8 deletions
diff --git a/src/plugins/abrt-action-mailx.cpp b/src/plugins/abrt-action-mailx.cpp
index fa7fd8a0..824791fa 100644
--- a/src/plugins/abrt-action-mailx.cpp
+++ b/src/plugins/abrt-action-mailx.cpp
@@ -66,8 +66,7 @@ static void create_and_send_email(
if (!dd)
exit(1); /* error msg is already logged by dd_opendir */
- map_crash_data_t pCrashData;
- load_crash_data_from_crash_dump_dir(dd, pCrashData);
+ crash_data_t *crash_data = load_crash_data_from_crash_dump_dir(dd);
dd_close(dd);
char* env;
@@ -90,17 +89,20 @@ static void create_and_send_email(
unsigned arg_size = 0;
args = append_str_to_vector(args, arg_size, "/bin/mailx");
- char *dsc = make_description_mailx(pCrashData);
+ char *dsc = make_description_mailx(crash_data);
if (send_binary_data)
{
- map_crash_data_t::const_iterator it_cd;
- for (it_cd = pCrashData.begin(); it_cd != pCrashData.end(); it_cd++)
+ GHashTableIter iter;
+ char *name;
+ struct crash_item *value;
+ g_hash_table_iter_init(&iter, crash_data);
+ while (g_hash_table_iter_next(&iter, (void**)&name, (void**)&value))
{
- if (it_cd->second[CD_TYPE] == CD_BIN)
+ if (value->flags & CD_FLAG_BIN)
{
args = append_str_to_vector(args, arg_size, "-a");
- args = append_str_to_vector(args, arg_size, it_cd->second[CD_CONTENT].c_str());
+ args = append_str_to_vector(args, arg_size, value->content);
}
}
}
@@ -112,7 +114,7 @@ static void create_and_send_email(
args = append_str_to_vector(args, arg_size, email_to);
log(_("Sending an email..."));
- const char *uid_str = get_crash_data_item_content_or_NULL(pCrashData, FILENAME_UID);
+ const char *uid_str = get_crash_item_content_or_NULL(crash_data, FILENAME_UID);
exec_and_feed_input(xatoi_u(uid_str), dsc, args);
free(dsc);
@@ -122,6 +124,8 @@ static void create_and_send_email(
args -= arg_size;
free(args);
+ free_crash_data(crash_data);
+
log("Email was sent to: %s", email_to);
}