summaryrefslogtreecommitdiffstats
path: root/lib/Utils
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Utils')
-rw-r--r--lib/Utils/CrashTypes.cpp61
-rw-r--r--lib/Utils/CrashTypesSocket.cpp12
-rw-r--r--lib/Utils/DebugDump.h19
-rw-r--r--lib/Utils/Makefile.am1
-rw-r--r--lib/Utils/Plugin.h6
-rw-r--r--lib/Utils/Reporter.h4
-rw-r--r--lib/Utils/daemon.cpp2
-rw-r--r--lib/Utils/make_descr.cpp30
-rw-r--r--lib/Utils/test.cpp4
9 files changed, 91 insertions, 48 deletions
diff --git a/lib/Utils/CrashTypes.cpp b/lib/Utils/CrashTypes.cpp
new file mode 100644
index 0000000..4824e50
--- /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 3525c6a..d555571 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/DebugDump.h b/lib/Utils/DebugDump.h
index d3eebb4..60d3bd3 100644
--- a/lib/Utils/DebugDump.h
+++ b/lib/Utils/DebugDump.h
@@ -24,25 +24,6 @@
#define DEBUGDUMP_H_
#include <string>
-#include <dirent.h>
-#include <stdint.h>
-
-#define FILENAME_ARCHITECTURE "architecture"
-#define FILENAME_KERNEL "kernel"
-#define FILENAME_TIME "time"
-#define FILENAME_UID "uid"
-#define FILENAME_PACKAGE "package"
-#define FILENAME_COMPONENT "component"
-#define FILENAME_DESCRIPTION "description"
-#define FILENAME_ANALYZER "analyzer"
-#define FILENAME_RELEASE "release"
-#define FILENAME_EXECUTABLE "executable"
-#define FILENAME_REASON "reason"
-#define FILENAME_COMMENT "comment"
-#define FILENAME_REPRODUCE "reproduce"
-#define FILENAME_RATING "rating"
-#define FILENAME_CMDLINE "cmdline"
-
class CDebugDump
{
diff --git a/lib/Utils/Makefile.am b/lib/Utils/Makefile.am
index a944d97..5960710 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 d7108ce..e846403 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 0a06a7c..e9445f9 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/daemon.cpp b/lib/Utils/daemon.cpp
index 0527062..7d60ce3 100644
--- a/lib/Utils/daemon.cpp
+++ b/lib/Utils/daemon.cpp
@@ -16,7 +16,7 @@
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#include "abrtlib.h"
-#define FILENAME_CMDLINE "cmdline"
+
#define VAR_RUN_PID_FILE VAR_RUN"/abrt.pid"
static char *append_escaped(char *start, const char *s)
diff --git a/lib/Utils/make_descr.cpp b/lib/Utils/make_descr.cpp
index 2a0d4a9..e74e9b1 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 fbad1db..160c107 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);