mirror of https://github.com/aria2/aria2
2010-08-28 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
Changed signature of util::executeHook(). * src/RequestGroupMan.cc * src/util.cc * src/util.hpull/1/head
parent
d5bb40ce9e
commit
b49081340d
|
@ -1,3 +1,10 @@
|
|||
2010-08-28 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
|
||||
|
||||
Changed signature of util::executeHook().
|
||||
* src/RequestGroupMan.cc
|
||||
* src/util.cc
|
||||
* src/util.h
|
||||
|
||||
2010-08-28 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
|
||||
|
||||
Wait data arrives at clientSocket_ in
|
||||
|
|
|
@ -255,12 +255,15 @@ static void executeStopHook
|
|||
{
|
||||
if(result->result == downloadresultcode::FINISHED &&
|
||||
!option->blank(PREF_ON_DOWNLOAD_COMPLETE)) {
|
||||
util::executeHook(option->get(PREF_ON_DOWNLOAD_COMPLETE), result->gid);
|
||||
util::executeHook(option->get(PREF_ON_DOWNLOAD_COMPLETE),
|
||||
util::itos(result->gid));
|
||||
} else if(result->result != downloadresultcode::IN_PROGRESS &&
|
||||
!option->blank(PREF_ON_DOWNLOAD_ERROR)) {
|
||||
util::executeHook(option->get(PREF_ON_DOWNLOAD_ERROR), result->gid);
|
||||
util::executeHook(option->get(PREF_ON_DOWNLOAD_ERROR),
|
||||
util::itos(result->gid));
|
||||
} else if(!option->blank(PREF_ON_DOWNLOAD_STOP)) {
|
||||
util::executeHook(option->get(PREF_ON_DOWNLOAD_STOP), result->gid);
|
||||
util::executeHook(option->get(PREF_ON_DOWNLOAD_STOP),
|
||||
util::itos(result->gid));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
10
src/util.cc
10
src/util.cc
|
@ -1346,17 +1346,17 @@ void removeMetalinkContentTypes(const SharedHandle<RequestGroup>& group)
|
|||
}
|
||||
}
|
||||
|
||||
void executeHook(const std::string& command, gid_t gid)
|
||||
void executeHook(const std::string& command, const std::string& arg)
|
||||
{
|
||||
LogFactory::getInstance()->info("Executing user command: %s %s",
|
||||
command.c_str(), util::itos(gid).c_str());
|
||||
command.c_str(), arg.c_str());
|
||||
#ifndef __MINGW32__
|
||||
pid_t cpid = fork();
|
||||
if(cpid == -1) {
|
||||
LogFactory::getInstance()->error("fork() failed."
|
||||
" Cannot execute user command.");
|
||||
} else if(cpid == 0) {
|
||||
execl(command.c_str(), command.c_str(), util::itos(gid).c_str(),
|
||||
execl(command.c_str(), command.c_str(), arg.c_str(),
|
||||
reinterpret_cast<char*>(0));
|
||||
perror(("Could not execute user command: "+command).c_str());
|
||||
exit(EXIT_FAILURE);
|
||||
|
@ -1371,7 +1371,7 @@ void executeHook(const std::string& command, gid_t gid)
|
|||
memset(&pi, 0, sizeof (pi));
|
||||
|
||||
std::string cmdline = command;
|
||||
strappend(cmdline, " ", util::itos(gid));
|
||||
strappend(cmdline, " ", arg);
|
||||
|
||||
DWORD rc = CreateProcess(
|
||||
NULL,
|
||||
|
@ -1402,7 +1402,7 @@ void executeHookByOptName
|
|||
(const RequestGroup* group, const Option* option, const std::string& opt)
|
||||
{
|
||||
if(!option->blank(opt)) {
|
||||
executeHook(option->get(opt), group->getGID());
|
||||
executeHook(option->get(opt), util::itos(group->getGID()));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -396,7 +396,7 @@ bool inSameCidrBlock(const std::string& ip1, const std::string& ip2, int bits);
|
|||
|
||||
void removeMetalinkContentTypes(const SharedHandle<RequestGroup>& group);
|
||||
|
||||
void executeHook(const std::string& command, gid_t gid);
|
||||
void executeHook(const std::string& command, const std::string& arg);
|
||||
|
||||
void executeHookByOptName
|
||||
(const SharedHandle<RequestGroup>& group, const Option* option,
|
||||
|
|
Loading…
Reference in New Issue