diff options
| author | Jiri Moskovcak <jmoskovc@redhat.com> | 2009-11-06 15:11:55 +0100 |
|---|---|---|
| committer | Jiri Moskovcak <jmoskovc@redhat.com> | 2009-11-06 15:11:55 +0100 |
| commit | 3a62ede25114452938acb8e1a67006633b139efc (patch) | |
| tree | d3a291e5dac5d7ddf14bae4a097ff5b298b71aa5 /lib/Plugins/RunApp.cpp | |
| parent | fc571a9ac7aaa8802d3e8aacf9aefac12ca3c81c (diff) | |
| parent | 80975b02ec1a2e8dfc6f7ce21e47cf71b16b5a6e (diff) | |
| download | abrt-3a62ede25114452938acb8e1a67006633b139efc.tar.gz abrt-3a62ede25114452938acb8e1a67006633b139efc.tar.xz abrt-3a62ede25114452938acb8e1a67006633b139efc.zip | |
Merge branch 'master' of ssh://git.fedorahosted.org/git/abrt
Diffstat (limited to 'lib/Plugins/RunApp.cpp')
| -rw-r--r-- | lib/Plugins/RunApp.cpp | 31 |
1 files changed, 16 insertions, 15 deletions
diff --git a/lib/Plugins/RunApp.cpp b/lib/Plugins/RunApp.cpp index 5a5c1d4..f816dc2 100644 --- a/lib/Plugins/RunApp.cpp +++ b/lib/Plugins/RunApp.cpp @@ -29,41 +29,41 @@ #define COMMAND 0 #define FILENAME 1 -void CActionRunApp::ParseArgs(const std::string& psArgs, vector_string_t& pArgs) +/* TODO: do not duplicate: SOSreport.cpp has same function too */ +static void ParseArgs(const char *psArgs, vector_string_t& pArgs) { - unsigned int ii; + unsigned ii; bool is_quote = false; - std::string item = ""; - for (ii = 0; ii < psArgs.length(); ii++) + std::string item; + + for (ii = 0; psArgs[ii]; ii++) { - if (psArgs[ii] == '\"') + if (psArgs[ii] == '"') { - is_quote = is_quote == true ? false : true; + is_quote = !is_quote; } else if (psArgs[ii] == ',' && !is_quote) { pArgs.push_back(item); - item = ""; + item.clear(); } else { item += psArgs[ii]; } } - if (item != "") + + if (item.size() != 0) { pArgs.push_back(item); } } -void CActionRunApp::Run(const std::string& pActionDir, - const std::string& pArgs) +void CActionRunApp::Run(const char *pActionDir, const char *pArgs) { update_client(_("Executing RunApp plugin...")); - char line[1024]; - std::string output = ""; - + std::string output; vector_string_t args; ParseArgs(pArgs, args); @@ -71,8 +71,9 @@ void CActionRunApp::Run(const std::string& pActionDir, FILE *fp = popen(args[COMMAND].c_str(), "r"); if (fp == NULL) { - throw CABRTException(EXCEP_PLUGIN, "CActionRunApp::Run(): cannot execute " + args[COMMAND]); + throw CABRTException(EXCEP_PLUGIN, "Can't execute " + args[COMMAND]); } + char line[1024]; while (fgets(line, 1024, fp) != NULL) { output += line; @@ -83,7 +84,7 @@ void CActionRunApp::Run(const std::string& pActionDir, { CDebugDump dd; dd.Open(pActionDir); - dd.SaveText(args[FILENAME].c_str(), output); + dd.SaveText(args[FILENAME].c_str(), output.c_str()); } } |
