summaryrefslogtreecommitdiffstats
path: root/lib/Utils
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2009-12-06 22:23:11 +0100
committerDenys Vlasenko <vda.linux@googlemail.com>2009-12-06 22:23:11 +0100
commit4ceb3715a3a6b752009627b0dc6a1974664c03a1 (patch)
tree8c96d097e7e63f905925419a8a65c814d407605f /lib/Utils
parentf66aa07338bbc8a8a80264ec5be3ae25b677d94a (diff)
downloadabrt-4ceb3715a3a6b752009627b0dc6a1974664c03a1.tar.gz
abrt-4ceb3715a3a6b752009627b0dc6a1974664c03a1.tar.xz
abrt-4ceb3715a3a6b752009627b0dc6a1974664c03a1.zip
remove std::string usage from class CABRTException.
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'lib/Utils')
-rw-r--r--lib/Utils/ABRTException.cpp15
-rw-r--r--lib/Utils/DebugDump.cpp26
-rw-r--r--lib/Utils/Makefile.am3
-rw-r--r--lib/Utils/abrt_xmlrpc.cpp2
4 files changed, 31 insertions, 15 deletions
diff --git a/lib/Utils/ABRTException.cpp b/lib/Utils/ABRTException.cpp
new file mode 100644
index 00000000..aa6c99d9
--- /dev/null
+++ b/lib/Utils/ABRTException.cpp
@@ -0,0 +1,15 @@
+#include "ABRTException.h"
+
+CABRTException::CABRTException(abrt_exception_t type, const char* fmt, ...)
+{
+ m_type = type;
+ va_list ap;
+ va_start(ap, fmt);
+ m_what = xvasprintf(fmt, ap);
+ va_end(ap);
+}
+
+CABRTException::CABRTException(const CABRTException& rhs):
+ m_type(rhs.m_type),
+ m_what(xstrdup(rhs.m_what))
+{}
diff --git a/lib/Utils/DebugDump.cpp b/lib/Utils/DebugDump.cpp
index 3e226f9a..b1db1698 100644
--- a/lib/Utils/DebugDump.cpp
+++ b/lib/Utils/DebugDump.cpp
@@ -77,7 +77,7 @@ void CDebugDump::Open(const char *pDir)
m_sDebugDumpDir = RemoveBackSlashes(pDir);
if (!ExistFileDir(m_sDebugDumpDir.c_str()))
{
- throw CABRTException(EXCEP_DD_OPEN, m_sDebugDumpDir + " does not exist");
+ throw CABRTException(EXCEP_DD_OPEN, "'%s' does not exist", m_sDebugDumpDir.c_str());
}
Lock();
m_bOpened = true;
@@ -222,7 +222,7 @@ void CDebugDump::Create(const char *pDir, int64_t uid)
m_sDebugDumpDir = RemoveBackSlashes(pDir);
if (ExistFileDir(m_sDebugDumpDir.c_str()))
{
- throw CABRTException(EXCEP_DD_OPEN, ssprintf("'%s' already exists", m_sDebugDumpDir.c_str()));
+ throw CABRTException(EXCEP_DD_OPEN, "'%s' already exists", m_sDebugDumpDir.c_str());
}
Lock();
@@ -232,13 +232,13 @@ void CDebugDump::Create(const char *pDir, int64_t uid)
{
UnLock();
m_bOpened = false;
- throw CABRTException(EXCEP_DD_OPEN, ssprintf("Can't create dir '%s'", pDir));
+ throw CABRTException(EXCEP_DD_OPEN, "Can't create dir '%s'", pDir);
}
if (chmod(m_sDebugDumpDir.c_str(), 0700) == -1)
{
UnLock();
m_bOpened = false;
- throw CABRTException(EXCEP_DD_OPEN, ssprintf("Can't change mode of '%s'", pDir));
+ throw CABRTException(EXCEP_DD_OPEN, "Can't change mode of '%s'", pDir);
}
struct passwd* pw = getpwuid(uid);
gid_t gid = pw ? pw->pw_gid : uid;
@@ -272,7 +272,7 @@ static void DeleteFileDir(const char *pDir)
if (errno != EISDIR)
{
closedir(dir);
- throw CABRTException(EXCEP_DD_DELETE, ssprintf("Can't remove dir %s", fullPath.c_str()));
+ throw CABRTException(EXCEP_DD_DELETE, "Can't remove dir %s", fullPath.c_str());
}
DeleteFileDir(fullPath.c_str());
}
@@ -280,7 +280,7 @@ static void DeleteFileDir(const char *pDir)
closedir(dir);
if (remove(pDir) == -1)
{
- throw CABRTException(EXCEP_DD_DELETE, ssprintf("Can't remove dir %s", pDir));
+ throw CABRTException(EXCEP_DD_DELETE, "Can't remove dir %s", pDir);
}
}
@@ -325,7 +325,7 @@ static void LoadTextFile(const char *pPath, std::string& pData)
FILE *fp = fopen(pPath, "r");
if (!fp)
{
- throw CABRTException(EXCEP_DD_LOAD, ssprintf("Can't open file '%s'", pPath));
+ throw CABRTException(EXCEP_DD_LOAD, "Can't open file '%s'", pPath);
}
pData = "";
int ch;
@@ -348,13 +348,13 @@ static void SaveBinaryFile(const char *pPath, const char* pData, unsigned pSize)
int fd = open(pPath, O_WRONLY | O_TRUNC | O_CREAT, 0666);
if (fd < 0)
{
- throw CABRTException(EXCEP_DD_SAVE, ssprintf("Can't open file '%s'", pPath));
+ throw CABRTException(EXCEP_DD_SAVE, "Can't open file '%s'", pPath);
}
unsigned r = full_write(fd, pData, pSize);
close(fd);
if (r != pSize)
{
- throw CABRTException(EXCEP_DD_SAVE, ssprintf("Can't save file '%s'", pPath));
+ throw CABRTException(EXCEP_DD_SAVE, "Can't save file '%s'", pPath);
}
}
@@ -362,7 +362,7 @@ void CDebugDump::LoadText(const char* pName, std::string& pData)
{
if (!m_bOpened)
{
- throw CABRTException(EXCEP_DD_OPEN, "CDebugDump::LoadText(): DebugDump is not opened.");
+ throw CABRTException(EXCEP_DD_OPEN, "DebugDump is not opened");
}
std::string fullPath = concat_path_file(m_sDebugDumpDir.c_str(), pName);
LoadTextFile(fullPath.c_str(), pData);
@@ -372,7 +372,7 @@ void CDebugDump::SaveText(const char* pName, const char* pData)
{
if (!m_bOpened)
{
- throw CABRTException(EXCEP_DD_OPEN, "CDebugDump::SaveText(): DebugDump is not opened.");
+ throw CABRTException(EXCEP_DD_OPEN, "DebugDump is not opened");
}
std::string fullPath = concat_path_file(m_sDebugDumpDir.c_str(), pName);
SaveBinaryFile(fullPath.c_str(), pData, strlen(pData));
@@ -381,7 +381,7 @@ void CDebugDump::SaveBinary(const char* pName, const char* pData, unsigned pSize
{
if (!m_bOpened)
{
- throw CABRTException(EXCEP_DD_OPEN, "CDebugDump::SaveBinary(): DebugDump is not opened.");
+ throw CABRTException(EXCEP_DD_OPEN, "DebugDump is not opened");
}
std::string fullPath = concat_path_file(m_sDebugDumpDir.c_str(), pName);
SaveBinaryFile(fullPath.c_str(), pData, pSize);
@@ -400,7 +400,7 @@ void CDebugDump::InitGetNextFile()
m_pGetNextFileDir = opendir(m_sDebugDumpDir.c_str());
if (m_pGetNextFileDir == NULL)
{
- throw CABRTException(EXCEP_DD_OPEN, "Can't open dir " + m_sDebugDumpDir);
+ throw CABRTException(EXCEP_DD_OPEN, "Can't open dir '%s'", m_sDebugDumpDir.c_str());
}
}
diff --git a/lib/Utils/Makefile.am b/lib/Utils/Makefile.am
index 297007a9..9618751a 100644
--- a/lib/Utils/Makefile.am
+++ b/lib/Utils/Makefile.am
@@ -17,7 +17,8 @@ libABRTUtils_la_SOURCES = \
popen_and_save_output.cpp \
stringops.cpp \
dirsize.cpp \
- DebugDump.h DebugDump.cpp
+ DebugDump.h DebugDump.cpp \
+ ABRTException.cpp
libABRTUtils_la_CPPFLAGS = \
-Wall -Werror \
-I$(srcdir)/../../inc \
diff --git a/lib/Utils/abrt_xmlrpc.cpp b/lib/Utils/abrt_xmlrpc.cpp
index 11c431b8..7205316c 100644
--- a/lib/Utils/abrt_xmlrpc.cpp
+++ b/lib/Utils/abrt_xmlrpc.cpp
@@ -13,7 +13,7 @@ void throw_if_xml_fault_occurred(xmlrpc_env *env)
xmlrpc_env_clean(env); // this is needed ONLY if fault_occurred
xmlrpc_env_init(env); // just in case user catches ex and _continues_ to use env
error_msg("%s", errmsg.c_str()); // show error in daemon log
- throw CABRTException(EXCEP_PLUGIN, errmsg);
+ throw CABRTException(EXCEP_PLUGIN, errmsg.c_str());
}
}