2007-10-11 16:58:24 +00:00
|
|
|
|
/* <!-- copyright */
|
|
|
|
|
/*
|
|
|
|
|
* aria2 - The high speed download utility
|
|
|
|
|
*
|
|
|
|
|
* Copyright (C) 2006 Tatsuhiro Tsujikawa
|
|
|
|
|
*
|
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
|
* (at your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
|
* along with this program; if not, write to the Free Software
|
2010-01-05 16:01:46 +00:00
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
2007-10-11 16:58:24 +00:00
|
|
|
|
*
|
|
|
|
|
* In addition, as a special exception, the copyright holders give
|
|
|
|
|
* permission to link the code of portions of this program with the
|
|
|
|
|
* OpenSSL library under certain conditions as described in each
|
|
|
|
|
* individual source file, and distribute linked combinations
|
|
|
|
|
* including the two.
|
|
|
|
|
* You must obey the GNU General Public License in all respects
|
|
|
|
|
* for all of the code used other than OpenSSL. If you modify
|
|
|
|
|
* file(s) with this exception, you may extend this exception to your
|
|
|
|
|
* version of the file(s), but you are not obligated to do so. If you
|
|
|
|
|
* do not wish to do so, delete this exception statement from your
|
|
|
|
|
* version. If you delete this exception statement from all source
|
|
|
|
|
* files in the program, then also delete it here.
|
|
|
|
|
*/
|
|
|
|
|
/* copyright --> */
|
|
|
|
|
#include "common.h"
|
2008-12-02 15:53:27 +00:00
|
|
|
|
|
|
|
|
|
#include <cstdlib>
|
|
|
|
|
#include <cstring>
|
|
|
|
|
#include <sstream>
|
|
|
|
|
|
2007-10-11 16:58:24 +00:00
|
|
|
|
#include "Option.h"
|
|
|
|
|
#include "prefs.h"
|
|
|
|
|
#include "OptionParser.h"
|
|
|
|
|
#include "OptionHandlerFactory.h"
|
2008-02-08 15:53:45 +00:00
|
|
|
|
#include "OptionHandler.h"
|
2009-10-22 15:35:33 +00:00
|
|
|
|
#include "util.h"
|
2007-10-11 16:58:24 +00:00
|
|
|
|
#include "message.h"
|
2007-11-10 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
Don't connect server before checking file integrity at startup,
if
filesize and output file path are known.
* src/AbstractCommand.cc
* src/StreamFileAllocationEntry.cc
* src/Metalink2RequestGroup.cc
* src/RequestGroup.{h, cc}
* src/HttpResponseCommand.cc
* src/FtpNegotiationCommand.cc
Added DownloadFailureException. If it is thrown, RequestGroup
should
halt.
* src/AbstractCommand.cc
* src/DownloadFailureException.h
* src/RequestGroup.cc
Catch RecoverableException, instead of DlAbortEx.
* src/RequestGroupMan.cc
* src/FillRequestGroupCommand.cc
* src/MetaFileUtil.cc
* src/IteratableChunkChecksumValidator.cc
Now first parameter of MSG_DOWNLOAD_ABORTED is
gid(RequestGroup::
getGID())
* src/CheckIntegrityCommand.cc
* src/message.h
Print gid instead of idx.
* src/RequestGroupMan.cc
Removed exception throwers declaration.
* src/DirectDiskAdaptor.{h, cc}
* src/SocketCore.{h, cc}
* src/MultiDiskAdaptor.{h, cc}
* src/HttpConnection.{h, cc}
* src/HttpResponse.{h, cc}
* src/DiskAdaptor.{h, cc}
* src/CopyDiskAdaptor.{h, cc}
* src/MultiDiskAdaptor.{h, cc}
* src/HttpHeaderProcessor.{h, cc}
* src/AbstractSingleDiskAdaptor.{h, cc}
* src/Util.{h, cc}
* test/UtilTest.cc
* src/DefaultDiskWriter.{h, cc}
* src/FtpConnection.{h, cc}
* src/AbstractDiskWriter.{h, cc}
Removed duplicate code.
* src/StreamCheckIntegrityEntry.cc
Removed unnecessary include.
* src/DiskWriter.h
Included Exception.h
* src/option_processing.cc
Included 2 files and added doc
* src/TrackerWatcherCommand.cc
* src/SocketCore.cc (writeData): Fixed send error with GnuTLS.
2007-11-09 18:01:12 +00:00
|
|
|
|
#include "Exception.h"
|
2007-11-28 14:22:28 +00:00
|
|
|
|
#include "a2io.h"
|
2008-01-05 11:26:56 +00:00
|
|
|
|
#include "help_tags.h"
|
2008-02-08 15:53:45 +00:00
|
|
|
|
#include "File.h"
|
2010-11-20 09:36:14 +00:00
|
|
|
|
#include "fmt.h"
|
2008-09-26 16:05:45 +00:00
|
|
|
|
#include "OptionHandlerException.h"
|
2011-12-03 07:30:00 +00:00
|
|
|
|
#include "UnknownOptionException.h"
|
2010-11-28 07:52:02 +00:00
|
|
|
|
#include "error_code.h"
|
2009-06-28 10:37:15 +00:00
|
|
|
|
#include "SimpleRandomizer.h"
|
|
|
|
|
#include "bittorrent_helper.h"
|
2011-08-06 16:21:55 +00:00
|
|
|
|
#include "BufferedFile.h"
|
2011-08-09 15:38:48 +00:00
|
|
|
|
#include "console.h"
|
2011-11-04 14:43:32 +00:00
|
|
|
|
#include "array_fun.h"
|
2009-09-19 09:05:20 +00:00
|
|
|
|
#ifndef HAVE_DAEMON
|
|
|
|
|
#include "daemon.h"
|
|
|
|
|
#endif // !HAVE_DAEMON
|
2007-10-11 16:58:24 +00:00
|
|
|
|
|
2008-02-08 15:53:45 +00:00
|
|
|
|
namespace aria2 {
|
|
|
|
|
|
2007-10-11 16:58:24 +00:00
|
|
|
|
extern void showVersion();
|
2011-10-21 16:03:14 +00:00
|
|
|
|
extern void showUsage
|
2011-12-03 07:30:00 +00:00
|
|
|
|
(const std::string& keyword,
|
|
|
|
|
const SharedHandle<OptionParser>& oparser,
|
|
|
|
|
const Console& out);
|
2007-10-11 16:58:24 +00:00
|
|
|
|
|
2010-10-30 16:02:15 +00:00
|
|
|
|
namespace {
|
2011-10-21 16:03:14 +00:00
|
|
|
|
void overrideWithEnv
|
|
|
|
|
(Option& op,
|
|
|
|
|
const SharedHandle<OptionParser>& optionParser,
|
|
|
|
|
const Pref* pref,
|
|
|
|
|
const std::string& envName)
|
2008-11-04 14:57:05 +00:00
|
|
|
|
{
|
|
|
|
|
char* value = getenv(envName.c_str());
|
|
|
|
|
if(value) {
|
|
|
|
|
try {
|
2011-10-21 16:03:14 +00:00
|
|
|
|
optionParser->find(pref)->parse(op, value);
|
2008-11-04 14:57:05 +00:00
|
|
|
|
} catch(Exception& e) {
|
2011-08-09 16:28:20 +00:00
|
|
|
|
global::cerr()->printf
|
2011-12-03 07:30:00 +00:00
|
|
|
|
(_("Caught Error while parsing environment variable '%s'"),
|
|
|
|
|
envName.c_str());
|
|
|
|
|
global::cerr()->printf("\n%s\n", e.stackTrace().c_str());
|
2008-11-04 14:57:05 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2010-10-30 16:02:15 +00:00
|
|
|
|
} // namespace
|
2008-11-04 14:57:05 +00:00
|
|
|
|
|
2011-12-03 07:30:00 +00:00
|
|
|
|
namespace {
|
2011-12-03 12:41:07 +00:00
|
|
|
|
// Calculates Damerau–Levenshtein distance between c-string a and b
|
|
|
|
|
// with given costs. swapcost, subcost, addcost and delcost are cost
|
|
|
|
|
// to swap 2 adjacent characters, substitute characters, add character
|
|
|
|
|
// and delete character respectively.
|
|
|
|
|
int levenshtein
|
2011-12-03 07:30:00 +00:00
|
|
|
|
(const char* a,
|
|
|
|
|
const char* b,
|
|
|
|
|
int swapcost,
|
|
|
|
|
int subcost,
|
|
|
|
|
int addcost,
|
|
|
|
|
int delcost)
|
|
|
|
|
{
|
|
|
|
|
int alen = strlen(a);
|
|
|
|
|
int blen = strlen(b);
|
|
|
|
|
std::vector<std::vector<int> > dp(3, std::vector<int>(blen+1));
|
|
|
|
|
for(int i = 0; i <= blen; ++i) {
|
|
|
|
|
dp[1][i] = i;
|
|
|
|
|
}
|
|
|
|
|
for(int i = 1; i <= alen; ++i) {
|
|
|
|
|
dp[0][0] = i;
|
|
|
|
|
for(int j = 1; j <= blen; ++j) {
|
2011-12-03 12:41:07 +00:00
|
|
|
|
dp[0][j] = dp[1][j-1]+(a[i-1] == b[j-1] ? 0 : subcost);
|
2011-12-03 07:30:00 +00:00
|
|
|
|
if(i >= 2 && j >= 2 && a[i-1] != b[j-1] &&
|
|
|
|
|
a[i-2] == b[j-1] && a[i-1] == b[j-2]) {
|
|
|
|
|
dp[0][j] = std::min(dp[0][j], dp[2][j-2]+swapcost);
|
|
|
|
|
}
|
|
|
|
|
dp[0][j] = std::min(dp[0][j],
|
|
|
|
|
std::min(dp[1][j]+delcost, dp[0][j-1]+addcost));
|
|
|
|
|
}
|
|
|
|
|
std::rotate(dp.begin(), dp.begin()+2, dp.end());
|
|
|
|
|
}
|
|
|
|
|
return dp[1][blen];
|
|
|
|
|
}
|
|
|
|
|
} // namespace
|
|
|
|
|
|
|
|
|
|
namespace {
|
|
|
|
|
|
|
|
|
|
void showCandidates
|
|
|
|
|
(const std::string& unknownOption, const SharedHandle<OptionParser>& parser)
|
|
|
|
|
{
|
|
|
|
|
const char* optstr = unknownOption.c_str();
|
|
|
|
|
for(; *optstr == '-'; ++optstr);
|
|
|
|
|
if(*optstr == '\0') {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
int optstrlen = strlen(optstr);
|
|
|
|
|
std::vector<std::pair<int, const Pref*> > cands;
|
|
|
|
|
for(int i = 1, len = option::countOption(); i < len; ++i) {
|
|
|
|
|
const Pref* pref = option::i2p(i);
|
2012-09-27 13:45:31 +00:00
|
|
|
|
const OptionHandler* h = parser->find(pref);
|
2011-12-03 07:30:00 +00:00
|
|
|
|
if(!h || h->isHidden()) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
// Use cost 0 for prefix match
|
|
|
|
|
if(util::startsWith(pref->k, pref->k+strlen(pref->k),
|
|
|
|
|
optstr, optstr+optstrlen)) {
|
|
|
|
|
cands.push_back(std::make_pair(0, pref));
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
// cost values are borrowed from git, help.c.
|
2011-12-03 12:41:07 +00:00
|
|
|
|
int sim = levenshtein(optstr, pref->k, 0, 2, 1, 4);
|
2011-12-03 07:30:00 +00:00
|
|
|
|
cands.push_back(std::make_pair(sim, pref));
|
|
|
|
|
}
|
|
|
|
|
if(cands.empty()) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
std::sort(cands.begin(), cands.end());
|
|
|
|
|
int threshold = cands[0].first;
|
2012-09-23 06:06:39 +00:00
|
|
|
|
// threshold value 12 is a magic value.
|
|
|
|
|
if(threshold > 12) {
|
2011-12-03 07:30:00 +00:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
global::cerr()->printf("\n");
|
|
|
|
|
global::cerr()->printf(_("Did you mean:"));
|
|
|
|
|
global::cerr()->printf("\n");
|
|
|
|
|
for(std::vector<std::pair<int, const Pref*> >::iterator i = cands.begin(),
|
|
|
|
|
eoi = cands.end(); i != eoi && (*i).first <= threshold; ++i) {
|
|
|
|
|
global::cerr()->printf("\t--%s\n", (*i).second->k);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} // namespace
|
|
|
|
|
|
2010-02-28 12:30:11 +00:00
|
|
|
|
void option_processing(Option& op, std::vector<std::string>& uris,
|
2011-04-22 14:38:59 +00:00
|
|
|
|
int argc, char* argv[])
|
2008-04-22 11:26:50 +00:00
|
|
|
|
{
|
2011-10-21 16:03:14 +00:00
|
|
|
|
const SharedHandle<OptionParser>& oparser = OptionParser::getInstance();
|
2008-09-22 09:26:57 +00:00
|
|
|
|
try {
|
2009-02-07 11:00:34 +00:00
|
|
|
|
bool noConf = false;
|
|
|
|
|
std::string ucfname;
|
|
|
|
|
std::stringstream cmdstream;
|
2011-10-21 16:03:14 +00:00
|
|
|
|
oparser->parseArg(cmdstream, uris, argc, argv);
|
2009-02-07 11:00:34 +00:00
|
|
|
|
{
|
|
|
|
|
// first evaluate --no-conf and --conf-path options.
|
|
|
|
|
Option op;
|
2011-10-21 16:03:14 +00:00
|
|
|
|
oparser->parse(op, cmdstream);
|
2009-02-07 11:00:34 +00:00
|
|
|
|
noConf = op.getAsBool(PREF_NO_CONF);
|
|
|
|
|
ucfname = op.get(PREF_CONF_PATH);
|
2008-09-22 09:26:57 +00:00
|
|
|
|
|
2011-10-21 12:56:42 +00:00
|
|
|
|
if(op.defined(PREF_VERSION)) {
|
2010-01-05 16:01:46 +00:00
|
|
|
|
showVersion();
|
2010-11-28 07:52:02 +00:00
|
|
|
|
exit(error_code::FINISHED);
|
2007-10-11 16:58:24 +00:00
|
|
|
|
}
|
2011-10-21 12:56:42 +00:00
|
|
|
|
if(op.defined(PREF_HELP)) {
|
2010-01-05 16:01:46 +00:00
|
|
|
|
std::string keyword;
|
2011-10-21 12:56:42 +00:00
|
|
|
|
if(op.get(PREF_HELP).empty()) {
|
2012-09-23 05:59:05 +00:00
|
|
|
|
keyword = strHelpTag(TAG_BASIC);
|
2010-01-05 16:01:46 +00:00
|
|
|
|
} else {
|
2011-10-21 12:56:42 +00:00
|
|
|
|
keyword = op.get(PREF_HELP);
|
2012-01-10 16:03:38 +00:00
|
|
|
|
if(util::startsWith(keyword, "--")) {
|
2011-11-04 16:26:09 +00:00
|
|
|
|
keyword.erase(keyword.begin(), keyword.begin()+2);
|
2010-01-05 16:01:46 +00:00
|
|
|
|
}
|
|
|
|
|
std::string::size_type eqpos = keyword.find("=");
|
|
|
|
|
if(eqpos != std::string::npos) {
|
2011-11-04 16:26:09 +00:00
|
|
|
|
keyword.erase(keyword.begin()+eqpos, keyword.end());
|
2010-01-05 16:01:46 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2011-12-03 07:30:00 +00:00
|
|
|
|
showUsage(keyword, oparser, global::cout());
|
2010-11-28 07:52:02 +00:00
|
|
|
|
exit(error_code::FINISHED);
|
2008-01-05 11:26:56 +00:00
|
|
|
|
}
|
2007-10-11 16:58:24 +00:00
|
|
|
|
}
|
|
|
|
|
|
2011-10-21 16:03:14 +00:00
|
|
|
|
oparser->parseDefaultValues(op);
|
2009-02-07 11:00:34 +00:00
|
|
|
|
|
2008-01-11 14:50:34 +00:00
|
|
|
|
if(!noConf) {
|
2012-09-23 05:59:05 +00:00
|
|
|
|
std::string cfname =
|
2010-01-05 16:01:46 +00:00
|
|
|
|
ucfname.empty() ?
|
2011-10-21 16:03:14 +00:00
|
|
|
|
oparser->find(PREF_CONF_PATH)->getDefaultValue() : ucfname;
|
2008-09-22 09:26:57 +00:00
|
|
|
|
|
2008-01-11 14:50:34 +00:00
|
|
|
|
if(File(cfname).isFile()) {
|
2011-08-06 16:21:55 +00:00
|
|
|
|
std::stringstream ss;
|
|
|
|
|
{
|
2012-09-25 14:44:41 +00:00
|
|
|
|
BufferedFile fp(cfname.c_str(), BufferedFile::READ);
|
2011-08-06 16:21:55 +00:00
|
|
|
|
if(fp) {
|
|
|
|
|
fp.transfer(ss);
|
|
|
|
|
}
|
|
|
|
|
}
|
2010-01-05 16:01:46 +00:00
|
|
|
|
try {
|
2011-10-21 16:03:14 +00:00
|
|
|
|
oparser->parse(op, ss);
|
2010-01-05 16:01:46 +00:00
|
|
|
|
} catch(OptionHandlerException& e) {
|
2011-12-03 07:30:00 +00:00
|
|
|
|
global::cerr()->printf(_("Parse error in %s"), cfname.c_str());
|
|
|
|
|
global::cerr()->printf("\n%s", e.stackTrace().c_str());
|
2012-09-27 13:45:31 +00:00
|
|
|
|
const OptionHandler* h = oparser->find(e.getPref());
|
2010-11-12 12:48:48 +00:00
|
|
|
|
if(h) {
|
2011-12-03 07:30:00 +00:00
|
|
|
|
global::cerr()->printf(_("Usage:"));
|
|
|
|
|
global::cerr()->printf("\n%s\n", h->getDescription());
|
2010-01-09 09:35:18 +00:00
|
|
|
|
}
|
2010-12-01 12:26:58 +00:00
|
|
|
|
exit(e.getErrorCode());
|
2010-01-05 16:01:46 +00:00
|
|
|
|
} catch(Exception& e) {
|
2011-12-03 07:30:00 +00:00
|
|
|
|
global::cerr()->printf(_("Parse error in %s"), cfname.c_str());
|
|
|
|
|
global::cerr()->printf("\n%s", e.stackTrace().c_str());
|
2010-12-01 12:26:58 +00:00
|
|
|
|
exit(e.getErrorCode());
|
2010-01-05 16:01:46 +00:00
|
|
|
|
}
|
2008-09-22 09:26:57 +00:00
|
|
|
|
} else if(!ucfname.empty()) {
|
2011-12-03 07:30:00 +00:00
|
|
|
|
global::cerr()->printf(_("Configuration file %s is not found."),
|
2011-08-09 16:28:20 +00:00
|
|
|
|
cfname.c_str());
|
2011-12-03 07:30:00 +00:00
|
|
|
|
global::cerr()->printf("\n");
|
2012-09-23 05:59:05 +00:00
|
|
|
|
showUsage(strHelpTag(TAG_HELP), oparser, global::cerr());
|
2010-11-28 07:52:02 +00:00
|
|
|
|
exit(error_code::UNKNOWN_ERROR);
|
2008-01-11 14:50:34 +00:00
|
|
|
|
}
|
2007-10-11 16:58:24 +00:00
|
|
|
|
}
|
2008-11-04 14:57:05 +00:00
|
|
|
|
// Override configuration with environment variables.
|
|
|
|
|
overrideWithEnv(op, oparser, PREF_HTTP_PROXY, "http_proxy");
|
|
|
|
|
overrideWithEnv(op, oparser, PREF_HTTPS_PROXY, "https_proxy");
|
|
|
|
|
overrideWithEnv(op, oparser, PREF_FTP_PROXY, "ftp_proxy");
|
|
|
|
|
overrideWithEnv(op, oparser, PREF_ALL_PROXY, "all_proxy");
|
2008-11-09 08:23:11 +00:00
|
|
|
|
overrideWithEnv(op, oparser, PREF_NO_PROXY, "no_proxy");
|
2008-11-04 14:57:05 +00:00
|
|
|
|
|
2009-02-07 11:00:34 +00:00
|
|
|
|
// we must clear eof bit and seek to the beginning of the buffer.
|
|
|
|
|
cmdstream.clear();
|
|
|
|
|
cmdstream.seekg(0, std::ios::beg);
|
|
|
|
|
// finaly let's parse and store command-iine options.
|
2011-10-21 16:03:14 +00:00
|
|
|
|
oparser->parse(op, cmdstream);
|
2011-08-04 12:43:02 +00:00
|
|
|
|
#ifdef __MINGW32__
|
2011-12-01 14:21:56 +00:00
|
|
|
|
for(size_t i = 1, len = option::countOption(); i < len; ++i) {
|
|
|
|
|
const Pref* pref = option::i2p(i);
|
|
|
|
|
if(op.defined(pref) && !util::isUtf8(op.get(pref))) {
|
|
|
|
|
op.put(pref, nativeToUtf8(op.get(pref)));
|
2011-08-04 12:43:02 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endif // __MINGW32__
|
2009-02-07 11:00:34 +00:00
|
|
|
|
} catch(OptionHandlerException& e) {
|
2011-12-03 07:30:00 +00:00
|
|
|
|
global::cerr()->printf("%s", e.stackTrace().c_str());
|
2012-09-27 13:45:31 +00:00
|
|
|
|
const OptionHandler* h = oparser->find(e.getPref());
|
2010-12-01 12:26:58 +00:00
|
|
|
|
if(h) {
|
2011-12-03 07:30:00 +00:00
|
|
|
|
global::cerr()->printf(_("Usage:"));
|
|
|
|
|
global::cerr()->printf("\n");
|
|
|
|
|
write(global::cerr(), *h);
|
2010-12-01 12:26:58 +00:00
|
|
|
|
}
|
|
|
|
|
exit(e.getErrorCode());
|
2011-12-03 07:30:00 +00:00
|
|
|
|
} catch(UnknownOptionException& e) {
|
|
|
|
|
showUsage("", oparser, global::cerr());
|
|
|
|
|
showCandidates(e.getUnknownOption(), oparser);
|
|
|
|
|
exit(e.getErrorCode());
|
2009-02-07 11:00:34 +00:00
|
|
|
|
} catch(Exception& e) {
|
2011-12-03 07:30:00 +00:00
|
|
|
|
global::cerr()->printf("%s", e.stackTrace().c_str());
|
|
|
|
|
showUsage("", oparser, global::cerr());
|
2010-12-01 12:26:58 +00:00
|
|
|
|
exit(e.getErrorCode());
|
2007-10-11 16:58:24 +00:00
|
|
|
|
}
|
2011-03-14 12:02:25 +00:00
|
|
|
|
if(!op.getAsBool(PREF_ENABLE_RPC) &&
|
2007-10-11 16:58:24 +00:00
|
|
|
|
#ifdef ENABLE_BITTORRENT
|
2009-02-07 11:00:34 +00:00
|
|
|
|
op.blank(PREF_TORRENT_FILE) &&
|
2007-10-11 16:58:24 +00:00
|
|
|
|
#endif // ENABLE_BITTORRENT
|
|
|
|
|
#ifdef ENABLE_METALINK
|
2009-02-07 11:00:34 +00:00
|
|
|
|
op.blank(PREF_METALINK_FILE) &&
|
2007-10-11 16:58:24 +00:00
|
|
|
|
#endif // ENABLE_METALINK
|
2009-02-07 11:00:34 +00:00
|
|
|
|
op.blank(PREF_INPUT_FILE)) {
|
|
|
|
|
if(uris.empty()) {
|
2011-12-03 07:30:00 +00:00
|
|
|
|
global::cerr()->printf(MSG_URI_REQUIRED);
|
|
|
|
|
global::cerr()->printf("\n");
|
|
|
|
|
showUsage("", oparser, global::cerr());
|
2010-11-28 07:52:02 +00:00
|
|
|
|
exit(error_code::UNKNOWN_ERROR);
|
2007-10-11 16:58:24 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2009-02-07 11:00:34 +00:00
|
|
|
|
if(op.getAsBool(PREF_DAEMON)) {
|
2009-06-20 16:17:00 +00:00
|
|
|
|
if(daemon(0, 0) < 0) {
|
2007-10-11 16:58:24 +00:00
|
|
|
|
perror(MSG_DAEMON_FAILED);
|
2010-11-28 07:52:02 +00:00
|
|
|
|
exit(error_code::UNKNOWN_ERROR);
|
2007-10-11 16:58:24 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2008-02-08 15:53:45 +00:00
|
|
|
|
|
|
|
|
|
} // namespace aria2
|