summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Pointner <equinox@anytun.org>2010-02-04 21:32:45 +0000
committerChristian Pointner <equinox@anytun.org>2010-02-04 21:32:45 +0000
commitd83412e9d4ff5a11eb128de5079c465a63709541 (patch)
tree7c1e83a2fe2c75556e9ec55d0f9917c987e4b62b
parentfixed build on posix (diff)
some cleanup
-rw-r--r--src/posix/sysExec.hpp14
-rw-r--r--src/sysExec.cpp12
-rw-r--r--src/sysExec.h2
-rw-r--r--src/win32/sysExec.hpp8
4 files changed, 18 insertions, 18 deletions
diff --git a/src/posix/sysExec.hpp b/src/posix/sysExec.hpp
index 359c1e4..48cd8f2 100644
--- a/src/posix/sysExec.hpp
+++ b/src/posix/sysExec.hpp
@@ -63,17 +63,17 @@ char** dupEnv(StringList const& env)
return evp;
}
-void SysExec::doExec(std::string const& script, StringVector const& args, StringList const& env)
+void SysExec::doExec(StringVector const& args, StringList const& env)
{
int pipefd[2];
if(pipe(pipefd) == -1) {
- cLog.msg(Log::PRIO_ERROR) << "executing script '" << script << "' pipe() error: " << AnytunErrno(errno);
+ cLog.msg(Log::PRIO_ERROR) << "executing script '" << script_ << "' pipe() error: " << AnytunErrno(errno);
return;
}
pid_ = fork();
if(pid_ == -1) {
- cLog.msg(Log::PRIO_ERROR) << "executing script '" << script << "' fork() error: " << AnytunErrno(errno);
+ cLog.msg(Log::PRIO_ERROR) << "executing script '" << script_ << "' fork() error: " << AnytunErrno(errno);
return;
}
@@ -99,8 +99,8 @@ void SysExec::doExec(std::string const& script, StringVector const& args, String
}
char** argv = new char*[args.size() + 2];
- argv[0] = new char[script.size() + 1];
- std::strcpy(argv[0], script.c_str());
+ argv[0] = new char[script_.size() + 1];
+ std::strcpy(argv[0], script_.c_str());
for(unsigned int i=0; i<args.size(); ++i) {
argv[i+1] = new char[args[i].size() + 1];
std::strcpy(argv[i+1], args[i].c_str());
@@ -109,7 +109,7 @@ void SysExec::doExec(std::string const& script, StringVector const& args, String
char** evp = dupEnv(env);
- execve(script.c_str(), argv, evp);
+ execve(script_.c_str(), argv, evp);
// if execve returns, an error occurred, but logging doesn't work
// because we closed all file descriptors, so just write errno to
// pipe and call exit
@@ -132,7 +132,7 @@ int SysExec::waitForScript()
if(select(pipefd_+1, &rfds, NULL, NULL, &tv) == 1) {
int err = 0;
if(read(pipefd_, (void*)(&err), sizeof(err)) >= static_cast<int>(sizeof(err))) {
- cLog.msg(Log::PRIO_NOTICE) << "script '" << script_ << "' exec() error: " << AnytunErrno(err);
+ cLog.msg(Log::PRIO_ERROR) << "script '" << script_ << "' exec() error: " << AnytunErrno(err);
close(pipefd_);
return_code_ = -1;
return return_code_;
diff --git a/src/sysExec.cpp b/src/sysExec.cpp
index 6e291d9..9fc6e10 100644
--- a/src/sysExec.cpp
+++ b/src/sysExec.cpp
@@ -38,32 +38,32 @@
#include "log.h"
#include "anytunError.h"
-//use system specific signal handler
+//use system specific sys exec
#ifndef _MSC_VER
#include "sysExec.hpp"
#else
- #include "win32/sysExec.hpp"
+#include "win32/sysExec.hpp"
#endif
SysExec::SysExec(std::string const& script) : script_(script),closed_(false),return_code_(0)
{
- doExec(script, StringVector(), StringList());
+ doExec(StringVector(), StringList());
}
SysExec::SysExec(std::string const& script, StringVector const& args) : script_(script),closed_(false),return_code_(0)
{
- doExec(script, args, StringList());
+ doExec(args, StringList());
}
SysExec::SysExec(std::string const& script, StringList const& env) : script_(script),closed_(false),return_code_(0)
{
- doExec( script, StringVector(), env);
+ doExec(StringVector(), env);
}
SysExec::SysExec(std::string const& script, StringVector const& args, StringList const& env) : script_(script),closed_(false),return_code_(0)
{
- doExec( script, args, env);
+ doExec(args, env);
}
int SysExec::getReturnCode() const
diff --git a/src/sysExec.h b/src/sysExec.h
index 02ac00e..6d0724e 100644
--- a/src/sysExec.h
+++ b/src/sysExec.h
@@ -57,7 +57,7 @@ class SysExec
static void waitAndDestroy(SysExec*& s);
private:
- void doExec(std::string const& script, StringVector const& args, StringList const& env);
+ void doExec(StringVector const& args, StringList const& env);
std::string script_;
bool closed_;
diff --git a/src/win32/sysExec.hpp b/src/win32/sysExec.hpp
index d04ed40..eba26f4 100644
--- a/src/win32/sysExec.hpp
+++ b/src/win32/sysExec.hpp
@@ -67,13 +67,13 @@ bool endsWith(std::string const& string, std::string const& suffix) {
return string.find(suffix, string.size() - suffix.size()) != std::string::npos;
}
-void SysExec::doExec(std::string const& script, StringVector const& args, StringList const& env)
+void SysExec::doExec(StringVector const& args, StringList const& env)
{
std::vector<char> arguments;
bool isBatchFile = false;
for(int i = 0; i < BATCH_FILE_EXTS_COUNT; ++i) {
- if(endsWith(script, BATCH_FILE_EXTS[i])) {
+ if(endsWith(script_, BATCH_FILE_EXTS[i])) {
isBatchFile = true;
break;
}
@@ -84,7 +84,7 @@ void SysExec::doExec(std::string const& script, StringVector const& args, String
arguments.insert(arguments.end(), BATCH_INTERPRETER.begin(), BATCH_INTERPRETER.end());
}
arguments.push_back('\"');
- arguments.insert(arguments.end(), script.begin(), script.end());
+ arguments.insert(arguments.end(), script_.begin(), script_.end());
arguments.push_back('\"');
arguments.push_back(' ');
@@ -126,7 +126,7 @@ void SysExec::doExec(std::string const& script, StringVector const& args, String
&process_info_
))
{
- cLog.msg(Log::PRIO_ERROR) << "executing script '" << script << "' CreateProcess() error: " << GetLastError();
+ cLog.msg(Log::PRIO_ERROR) << "executing script '" << script_ << "' CreateProcess() error: " << GetLastError();
return;
}
}