summaryrefslogtreecommitdiffstats
path: root/lib/Utils
diff options
context:
space:
mode:
authorKarel Klic <kklic@redhat.com>2009-11-13 11:28:17 +0100
committerKarel Klic <kklic@redhat.com>2009-11-13 11:28:17 +0100
commit61cf6a4bca76c5efaf9994ccf1b1640bc5d7de74 (patch)
tree9ca5046ab2ddd2f6fa16c8397c9afc58e3faf555 /lib/Utils
parenteb97977cc4d049887144d67d00e32d84bebecb99 (diff)
parent5d308d79beef7e6590855577b0b3e01d672f7580 (diff)
downloadabrt-61cf6a4bca76c5efaf9994ccf1b1640bc5d7de74.tar.gz
abrt-61cf6a4bca76c5efaf9994ccf1b1640bc5d7de74.tar.xz
abrt-61cf6a4bca76c5efaf9994ccf1b1640bc5d7de74.zip
Merge branch 'master' of ssh://git.fedorahosted.org/git/abrt
Diffstat (limited to 'lib/Utils')
-rw-r--r--lib/Utils/Makefile.am5
-rw-r--r--lib/Utils/popen_and_save_output.cpp30
-rw-r--r--lib/Utils/stringops.cpp2
3 files changed, 34 insertions, 3 deletions
diff --git a/lib/Utils/Makefile.am b/lib/Utils/Makefile.am
index 0ca7a2b..eae4148 100644
--- a/lib/Utils/Makefile.am
+++ b/lib/Utils/Makefile.am
@@ -4,16 +4,17 @@ lib_LTLIBRARIES = libABRTUtils.la
# time.cpp
# xconnect.cpp
+# removed: CrashTypesSocket.cpp
libABRTUtils_la_SOURCES = \
- stringops.cpp \
+ stringops.cpp \
xfuncs.cpp \
encbase64.cpp \
read_write.cpp \
logging.cpp \
copyfd.cpp \
skip_whitespace.cpp \
+ popen_and_save_output.cpp \
parse_release.cpp \
- CrashTypesSocket.cpp \
DebugDump.h DebugDump.cpp \
CommLayerInner.h CommLayerInner.cpp \
abrt_dbus.h abrt_dbus.cpp \
diff --git a/lib/Utils/popen_and_save_output.cpp b/lib/Utils/popen_and_save_output.cpp
new file mode 100644
index 0000000..4bcbcac
--- /dev/null
+++ b/lib/Utils/popen_and_save_output.cpp
@@ -0,0 +1,30 @@
+/*
+ * Utility routines.
+ *
+ * Licensed under GPLv2 or later, see file COPYING in this tarball for details.
+ */
+#include "abrtlib.h"
+
+using namespace std;
+
+string popen_and_save_output(const char *cmd)
+{
+ string result;
+
+ FILE *fp = popen(cmd, "r");
+ if (fp == NULL) /* fork or pipe failed; or out-of-mem */
+ {
+ return result;
+ }
+
+ size_t sz;
+ char buf[BUFSIZ + 1];
+ while ((sz = fread(buf, 1, sizeof(buf)-1, fp)) > 0)
+ {
+ buf[sz] = '\0';
+ result += buf;
+ }
+ pclose(fp);
+
+ return result;
+}
diff --git a/lib/Utils/stringops.cpp b/lib/Utils/stringops.cpp
index 73084fc..1b3793f 100644
--- a/lib/Utils/stringops.cpp
+++ b/lib/Utils/stringops.cpp
@@ -1,6 +1,6 @@
#include "abrtlib.h"
-void parse_args(const char *psArgs, vector_string_t& pArgs, const char quote)
+void parse_args(const char *psArgs, vector_string_t& pArgs, int quote)
{
unsigned ii;
bool is_quote = false;