use vector instead of list for execmd arg list

This commit is contained in:
Jean-Francois Dockes
2012-04-11 15:36:49 +02:00
parent c7c9c49437
commit 78bd8d63da
14 changed files with 28 additions and 32 deletions
+2 -2
View File
@@ -29,7 +29,7 @@ static bool eCrontabGetLines(vector<string>& lines)
{
string crontab;
ExecCmd croncmd;
list<string> args;
vector<string> args;
int status;
// Retrieve current crontab contents. An error here means that no
@@ -51,7 +51,7 @@ static bool eCrontabWriteFile(const vector<string>& lines, string& reason)
{
string crontab;
ExecCmd croncmd;
list<string> args;
vector<string> args;
int status;
for (vector<string>::const_iterator it = lines.begin();
+7 -8
View File
@@ -32,7 +32,6 @@
#include <string.h>
#endif
#include <list>
#include <vector>
#include <string>
#include <sstream>
@@ -173,12 +172,12 @@ ExecCmd::~ExecCmd()
ExecCmdRsrc(this);
}
int ExecCmd::startExec(const string &cmd, const list<string>& args,
int ExecCmd::startExec(const string &cmd, const vector<string>& args,
bool has_input, bool has_output)
{
{ // Debug and logging
string command = cmd + " ";
for (list<string>::const_iterator it = args.begin();it != args.end();
for (vector<string>::const_iterator it = args.begin();it != args.end();
it++) {
command += "{" + *it + "} ";
}
@@ -314,7 +313,7 @@ private:
};
int ExecCmd::doexec(const string &cmd, const list<string>& args,
int ExecCmd::doexec(const string &cmd, const vector<string>& args,
const string *input, string *output)
{
@@ -505,7 +504,7 @@ bool ExecCmd::maybereap(int *status)
// In child process. Set up pipes, environment, and exec command.
// This must not return. exit() on error.
void ExecCmd::dochild(const string &cmd, const list<string>& args,
void ExecCmd::dochild(const string &cmd, const vector<string>& args,
bool has_input, bool has_output)
{
// Start our own process group
@@ -581,7 +580,7 @@ void ExecCmd::dochild(const string &cmd, const list<string>& args,
// Fill up argv
argv[0] = cmd.c_str();
int i = 1;
list<string>::const_iterator it;
vector<string>::const_iterator it;
for (it = args.begin(); it != args.end(); it++) {
argv[i++] = it->c_str();
}
@@ -684,7 +683,7 @@ void ReExec::reexec()
#include <stdlib.h>
#include <string>
#include <iostream>
#include <list>
#include <vector>
#include "debuglog.h"
#include "cancelcheck.h"
@@ -781,7 +780,7 @@ int main(int argc, char *argv[])
Usage();
string cmd = *argv++; argc--;
list<string> l;
vector<string> l;
while (argc > 0) {
l.push_back(*argv++); argc--;
}
+4 -6
View File
@@ -18,11 +18,9 @@
#define _EXECMD_H_INCLUDED_
#include <signal.h>
#include <string>
#include <list>
#include <vector>
#include <stack>
#ifndef NO_NAMESPACES
using std::list;
using std::string;
using std::vector;
using std::stack;
@@ -119,12 +117,12 @@ class ExecCmd {
*
* @param cmd the program to execute. This must be an absolute file name
* or exist in the PATH.
* @param args the argument list (NOT including argv[0]).
* @param args the argument vector (NOT including argv[0]).
* @param input Input to send TO the command.
* @param output Output FROM the command.
* @return the exec ouput status (0 if ok), or -1
*/
int doexec(const string &cmd, const list<string>& args,
int doexec(const string &cmd, const vector<string>& args,
const string *input = 0,
string *output = 0);
@@ -132,7 +130,7 @@ class ExecCmd {
* The next four methods can be used when a Q/A dialog needs to be
* performed with the command
*/
int startExec(const string &cmd, const list<string>& args,
int startExec(const string &cmd, const vector<string>& args,
bool has_input, bool has_output);
int send(const string& data);
int receive(string& data, int cnt = -1);
@@ -202,7 +200,7 @@ class ExecCmd {
sigemptyset(&m_blkcld);
}
// Child process code
void dochild(const string &cmd, const list<string>& args,
void dochild(const string &cmd, const vector<string>& args,
bool has_input, bool has_output);
/* Copyconst and assignment private and forbidden */
ExecCmd(const ExecCmd &) {}
+1 -1
View File
@@ -29,7 +29,7 @@ bool rclionice(const string& clss, const string& cdata)
LOGDEB0(("rclionice: ionice not found\n"));
return false;
}
list<string> args;
vector<string> args;
args.push_back("-c");
args.push_back(clss);
-1
View File
@@ -19,7 +19,6 @@
#include <string>
#include <iostream>
#include <list>
#include <vector>