diff options
| author | Denys Vlasenko <vda.linux@googlemail.com> | 2009-11-12 16:17:39 +0100 |
|---|---|---|
| committer | Denys Vlasenko <vda.linux@googlemail.com> | 2009-11-12 16:17:39 +0100 |
| commit | 3938e6e075867ae3a349ba307ee672aa458d2662 (patch) | |
| tree | 4db5d4c58632519227e535610822f4c8a262c1e4 /lib | |
| parent | f93fc8bc4c4db4547ca7fcdd6ad67f73e1755873 (diff) | |
| download | abrt-3938e6e075867ae3a349ba307ee672aa458d2662.tar.gz abrt-3938e6e075867ae3a349ba307ee672aa458d2662.tar.xz abrt-3938e6e075867ae3a349ba307ee672aa458d2662.zip | |
SOSreport.cpp: __gnu_cxx::stdio_filebuf<char> is +8k in code, thanks but no
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/Plugins/SOSreport.cpp | 22 | ||||
| -rw-r--r-- | lib/Utils/Makefile.am | 3 | ||||
| -rw-r--r-- | lib/Utils/popen_and_save_output.cpp | 30 | ||||
| -rw-r--r-- | lib/Utils/stringops.cpp | 2 |
4 files changed, 37 insertions, 20 deletions
diff --git a/lib/Plugins/SOSreport.cpp b/lib/Plugins/SOSreport.cpp index b949339..287c01e 100644 --- a/lib/Plugins/SOSreport.cpp +++ b/lib/Plugins/SOSreport.cpp @@ -18,7 +18,6 @@ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ -#include <ext/stdio_filebuf.h> #include <fstream> #include <sstream> #include "abrtlib.h" @@ -56,7 +55,7 @@ static std::string ParseFilename(const std::string& pOutput) int filename_start = pOutput.find_first_not_of(" \n\t", p); ErrorCheck(p); - int line_end = pOutput.find_first_of('\n',filename_start); + int line_end = pOutput.find_first_of('\n', filename_start); ErrorCheck(p); int filename_end = pOutput.find_last_not_of(" \n\t", line_end); @@ -90,24 +89,11 @@ void CActionSOSreport::Run(const char *pActionDir, const char *pArgs) } update_client(_("running sosreport: %s"), command.c_str()); - FILE *fp = popen(command.c_str(), "r"); - if (fp == NULL) - { - throw CABRTException(EXCEP_PLUGIN, ssprintf("Can't execute '%s'", command.c_str())); - } - -//vda TODO: fix this mess - std::ostringstream output_stream; - __gnu_cxx::stdio_filebuf<char> command_output_buffer(fp, std::ios_base::in); - - output_stream << command << std::endl; - output_stream << &command_output_buffer; - - pclose(fp); + std::string output = command; + output += '\n'; + output += popen_and_save_output(command.c_str()); update_client(_("done running sosreport")); - std::string output = output_stream.str(); - std::string sosreport_filename = ParseFilename(output); std::string sosreport_dd_filename = concat_path_file(pActionDir, "sosreport.tar.bz2"); diff --git a/lib/Utils/Makefile.am b/lib/Utils/Makefile.am index 0ca7a2b..f752992 100644 --- a/lib/Utils/Makefile.am +++ b/lib/Utils/Makefile.am @@ -5,13 +5,14 @@ lib_LTLIBRARIES = libABRTUtils.la # xconnect.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 \ 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; |
