diff options
| author | Karel Klic <kklic@redhat.com> | 2009-11-12 16:58:07 +0100 |
|---|---|---|
| committer | Karel Klic <kklic@redhat.com> | 2009-11-12 16:58:07 +0100 |
| commit | 32cee84a34c005fe0d2863f439007ec633687fa8 (patch) | |
| tree | 149ca7014e4295de3788f28ae88e9d9d7003da46 /lib/Plugins/SOSreport.cpp | |
| parent | 5a8a8a6c99c9067e0dfcce839c32826a2badff0b (diff) | |
| parent | 3938e6e075867ae3a349ba307ee672aa458d2662 (diff) | |
| download | abrt-32cee84a34c005fe0d2863f439007ec633687fa8.tar.gz abrt-32cee84a34c005fe0d2863f439007ec633687fa8.tar.xz abrt-32cee84a34c005fe0d2863f439007ec633687fa8.zip | |
Merge branch 'master' of ssh://git.fedorahosted.org/git/abrt
Diffstat (limited to 'lib/Plugins/SOSreport.cpp')
| -rw-r--r-- | lib/Plugins/SOSreport.cpp | 54 |
1 files changed, 5 insertions, 49 deletions
diff --git a/lib/Plugins/SOSreport.cpp b/lib/Plugins/SOSreport.cpp index fedc51a..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); @@ -65,36 +64,6 @@ static std::string ParseFilename(const std::string& pOutput) return pOutput.substr(filename_start, filename_end - filename_start + 1); } -/* TODO: do not duplicate: RunApp.cpp has same function too */ -static void ParseArgs(const char *psArgs, vector_string_t& pArgs) -{ - unsigned ii; - bool is_quote = false; - std::string item; - - for (ii = 0; psArgs[ii]; ii++) - { - if (psArgs[ii] == '"') - { - is_quote = !is_quote; - } - else if (psArgs[ii] == ',' && !is_quote) - { - pArgs.push_back(item); - item.clear(); - } - else - { - item += psArgs[ii]; - } - } - - if (item.size() != 0) - { - pArgs.push_back(item); - } -} - void CActionSOSreport::Run(const char *pActionDir, const char *pArgs) { update_client(_("Executing SOSreport plugin...")); @@ -108,7 +77,7 @@ void CActionSOSreport::Run(const char *pActionDir, const char *pArgs) std::string command; vector_string_t args; - ParseArgs(pArgs, args); + parse_args(pArgs, args, '"'); if (args.size() == 0 || args[0] == "") { @@ -120,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"); |
