diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2010-01-19 16:48:54 +0100 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2010-01-19 16:48:54 +0100 |
commit | 764c3a1e4f21c635c565cf5c20c480dbf48d1599 (patch) | |
tree | 35befea8632742fcf9a05354c8a1ca9bc0a3e2d4 /lib/Utils | |
parent | b7e20eb84250ce9feeefde8dad2eab448125dc5d (diff) | |
download | abrt-764c3a1e4f21c635c565cf5c20c480dbf48d1599.tar.gz abrt-764c3a1e4f21c635c565cf5c20c480dbf48d1599.tar.xz abrt-764c3a1e4f21c635c565cf5c20c480dbf48d1599.zip |
unify "crash data, "crash info" and "crash report" data types. they are the same
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'lib/Utils')
-rw-r--r-- | lib/Utils/CrashTypes.cpp | 61 | ||||
-rw-r--r-- | lib/Utils/CrashTypesSocket.cpp | 12 | ||||
-rw-r--r-- | lib/Utils/Makefile.am | 1 | ||||
-rw-r--r-- | lib/Utils/Plugin.h | 6 | ||||
-rw-r--r-- | lib/Utils/Reporter.h | 4 | ||||
-rw-r--r-- | lib/Utils/make_descr.cpp | 30 | ||||
-rw-r--r-- | lib/Utils/test.cpp | 4 |
7 files changed, 90 insertions, 28 deletions
diff --git a/lib/Utils/CrashTypes.cpp b/lib/Utils/CrashTypes.cpp new file mode 100644 index 00000000..4824e507 --- /dev/null +++ b/lib/Utils/CrashTypes.cpp @@ -0,0 +1,61 @@ +/* + Copyright (C) 2010 Denys Vlasenko (dvlasenk@redhat.com) + Copyright (C) 2010 RedHat inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +*/ +#include "abrt_types.h" +#include "abrtlib.h" +#include "CrashTypes.h" + +void add_to_crash_data_ext(map_crash_data_t& pCrashData, + const char *pItem, + const char *pType, + const char *pEditable, + const char *pContent) +{ + map_crash_data_t::iterator it = pCrashData.find(pItem); + if (it == pCrashData.end()) { + pCrashData[pItem].push_back(pType); + pCrashData[pItem].push_back(pEditable); + pCrashData[pItem].push_back(pContent); + return; + } + vector_string_t& v = it->second; + while (v.size() < 3) + v.push_back(""); + v[CD_TYPE] = pType; + v[CD_EDITABLE] = pEditable; + v[CD_CONTENT] = pContent; +} + +void add_to_crash_data(map_crash_data_t& pCrashData, + const char *pItem, + const char *pContent) +{ + add_to_crash_data_ext(pCrashData, pItem, CD_TXT, CD_ISNOTEDITABLE, pContent); +} + +const std::string& get_crash_data_item_content(const map_crash_data_t& crash_data, const char *key) +{ + map_crash_data_t::const_iterator it = crash_data.find(key); + if (it == crash_data.end()) { + error_msg_and_die("Error accessing crash data: no ['%s']", key); + } + if (it->second.size() <= CD_CONTENT) { + error_msg_and_die("Error accessing crash data: no ['%s'][%d]", key, CD_CONTENT); + } + return it->second[CD_CONTENT]; +} diff --git a/lib/Utils/CrashTypesSocket.cpp b/lib/Utils/CrashTypesSocket.cpp index 3525c6a5..d555571b 100644 --- a/lib/Utils/CrashTypesSocket.cpp +++ b/lib/Utils/CrashTypesSocket.cpp @@ -87,13 +87,13 @@ std::string crash_data_to_string(const map_crash_data_t& pCrashData) return sCD.str(); } -std::string crash_infos_to_string(const vector_crash_infos_t& pCrashInfos) +std::string crash_infos_to_string(const vector_map_crash_data_t& pCrashDatas) { std::stringstream sCI; unsigned int ii; - for (ii = 0; ii < pCrashInfos.size(); ii++) + for (ii = 0; ii < pCrashDatas.size(); ii++) { - sCI << crash_data_to_string(pCrashInfos[ii]); + sCI << crash_data_to_string(pCrashDatas[ii]); } return sCI.str(); } @@ -164,15 +164,15 @@ map_crash_data_t string_to_crash_data(const std::string& pMessage, int& len) return ci; } -vector_crash_infos_t string_to_crash_infos(const std::string& pMessage) +vector_map_crash_data_t string_to_crash_infos(const std::string& pMessage) { - vector_crash_infos_t vci; + vector_map_crash_data_t vci; std::string message = pMessage; int len; while (message != "") { - map_crash_info_t crash_info = string_to_crash_data(message, len); + map_crash_data_t crash_info = string_to_crash_data(message, len); if (crash_info.size() == 0) { return vci; diff --git a/lib/Utils/Makefile.am b/lib/Utils/Makefile.am index a944d977..59607104 100644 --- a/lib/Utils/Makefile.am +++ b/lib/Utils/Makefile.am @@ -20,6 +20,7 @@ libABRTUtils_la_SOURCES = \ stringops.cpp \ dirsize.cpp \ DebugDump.h DebugDump.cpp \ + CrashTypes.cpp \ ABRTException.cpp libABRTUtils_la_CPPFLAGS = \ -Wall -Werror \ diff --git a/lib/Utils/Plugin.h b/lib/Utils/Plugin.h index d7108ce9..e8464032 100644 --- a/lib/Utils/Plugin.h +++ b/lib/Utils/Plugin.h @@ -120,8 +120,8 @@ typedef struct SPluginInfo }; /* helper finctions */ -std::string make_description_bz(const map_crash_report_t& pCrashReport); -std::string make_description_logger(const map_crash_report_t& pCrashReport); -std::string make_description_catcut(const map_crash_report_t& pCrashReport); +std::string make_description_bz(const map_crash_data_t& pCrashData); +std::string make_description_logger(const map_crash_data_t& pCrashData); +std::string make_description_catcut(const map_crash_data_t& pCrashData); #endif diff --git a/lib/Utils/Reporter.h b/lib/Utils/Reporter.h index 0a06a7c9..e9445f93 100644 --- a/lib/Utils/Reporter.h +++ b/lib/Utils/Reporter.h @@ -36,11 +36,11 @@ class CReporter : public CPlugin * A method, which reports a crash report to particular receiver. * The plugin can takes arguments, but the plugin has to parse them * by itself. - * @param pCrashReport A crash report. + * @param pCrashData A crash report. * @param pArgs Plugin's arguments. * @retun A message which can be displayed after a report is created. */ - virtual std::string Report(const map_crash_report_t& pCrashReport, + virtual std::string Report(const map_crash_data_t& pCrashData, const map_plugin_settings_t& pSettings, const char *pArgs) = 0; }; diff --git a/lib/Utils/make_descr.cpp b/lib/Utils/make_descr.cpp index 2a0d4a99..e74e9b1d 100644 --- a/lib/Utils/make_descr.cpp +++ b/lib/Utils/make_descr.cpp @@ -50,27 +50,27 @@ static void add_content(bool &was_multiline, string& description, const char *he } } -string make_description_bz(const map_crash_report_t& pCrashReport) +string make_description_bz(const map_crash_data_t& pCrashData) { string description; - map_crash_report_t::const_iterator it; - map_crash_report_t::const_iterator end = pCrashReport.end(); + map_crash_data_t::const_iterator it; + map_crash_data_t::const_iterator end = pCrashData.end(); bool was_multiline = 0; - it = pCrashReport.find(CD_REPRODUCE); + it = pCrashData.find(CD_REPRODUCE); if (it != end && it->second[CD_CONTENT] != "1.\n2.\n3.\n") { add_content(was_multiline, description, "How to reproduce", it->second[CD_CONTENT].c_str()); } - it = pCrashReport.find(CD_COMMENT); + it = pCrashData.find(CD_COMMENT); if (it != end) { add_content(was_multiline, description, "Comment", it->second[CD_CONTENT].c_str()); } - it = pCrashReport.begin(); + it = pCrashData.begin(); for (; it != end; it++) { const string &filename = it->first; @@ -97,13 +97,13 @@ string make_description_bz(const map_crash_report_t& pCrashReport) return description; } -string make_description_logger(const map_crash_report_t& pCrashReport) +string make_description_logger(const map_crash_data_t& pCrashData) { string description; string long_description; - map_crash_report_t::const_iterator it = pCrashReport.begin(); - for (; it != pCrashReport.end(); it++) + map_crash_data_t::const_iterator it = pCrashData.begin(); + for (; it != pCrashData.end(); it++) { const string &filename = it->first; const string &type = it->second[CD_TYPE]; @@ -141,13 +141,13 @@ string make_description_logger(const map_crash_report_t& pCrashReport) } /* This needs more work to make the result less ugly */ -string make_description_catcut(const map_crash_report_t& pCrashReport) +string make_description_catcut(const map_crash_data_t& pCrashData) { - map_crash_report_t::const_iterator end = pCrashReport.end(); - map_crash_report_t::const_iterator it; + map_crash_data_t::const_iterator end = pCrashData.end(); + map_crash_data_t::const_iterator it; string howToReproduce; - it = pCrashReport.find(CD_REPRODUCE); + it = pCrashData.find(CD_REPRODUCE); if (it != end) { howToReproduce = "\n\nHow to reproduce\n" @@ -155,7 +155,7 @@ string make_description_catcut(const map_crash_report_t& pCrashReport) howToReproduce += it->second[CD_CONTENT]; } string comment; - it = pCrashReport.find(CD_COMMENT); + it = pCrashData.find(CD_COMMENT); if (it != end) { comment = "\n\nComment\n" @@ -169,7 +169,7 @@ string make_description_catcut(const map_crash_report_t& pCrashReport) pDescription += "\n\nAdditional information\n" "======\n"; - for (it = pCrashReport.begin(); it != end; it++) + for (it = pCrashData.begin(); it != end; it++) { const string &filename = it->first; const string &type = it->second[CD_TYPE]; diff --git a/lib/Utils/test.cpp b/lib/Utils/test.cpp index fbad1db9..160c107b 100644 --- a/lib/Utils/test.cpp +++ b/lib/Utils/test.cpp @@ -80,7 +80,7 @@ int main(int argc, char** argv) std::cout << "-------------------------------------------" << std::endl; } /* Try to save it into DB */ - map_crash_info_t crashInfo; + map_crash_data_t crashInfo; if (middleWare.SaveDebugDump(argv[1], crashInfo)) { std::cout << "Application Crashed! " << @@ -91,7 +91,7 @@ int main(int argc, char** argv) /* Get Report, so user can change data (remove private stuff) * If we do not want user interaction, just send data immediately */ - map_crash_report_t crashReport; + map_crash_data_t crashReport; middleWare.CreateCrashReport(crashInfo[CD_UUID][CD_CONTENT], crashInfo[CD_UID][CD_CONTENT], crashReport); |