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
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
|
|
*
|
|
|
|
* 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"
|
|
|
|
#include "Option.h"
|
|
|
|
#include "prefs.h"
|
|
|
|
#include "OptionParser.h"
|
|
|
|
#include "OptionHandlerFactory.h"
|
2008-02-08 15:53:45 +00:00
|
|
|
#include "OptionHandler.h"
|
2007-10-11 16:58:24 +00:00
|
|
|
#include "Util.h"
|
|
|
|
#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"
|
2008-04-26 05:58:49 +00:00
|
|
|
#include "StringFormat.h"
|
2008-03-15 04:19:46 +00:00
|
|
|
#include <cstdlib>
|
2008-05-13 14:15:23 +00:00
|
|
|
#include <cstring>
|
2007-10-11 16:58:24 +00:00
|
|
|
#include <fstream>
|
|
|
|
#include <sstream>
|
2008-02-08 15:53:45 +00:00
|
|
|
#include <iostream>
|
2007-10-11 16:58:24 +00:00
|
|
|
|
|
|
|
extern char* optarg;
|
|
|
|
extern int optind, opterr, optopt;
|
|
|
|
#include <getopt.h>
|
|
|
|
|
2008-02-08 15:53:45 +00:00
|
|
|
namespace aria2 {
|
|
|
|
|
2007-10-11 16:58:24 +00:00
|
|
|
extern void showVersion();
|
2008-04-22 11:26:50 +00:00
|
|
|
extern void showUsage(const std::string& category, const Option* option);
|
2007-10-11 16:58:24 +00:00
|
|
|
|
2008-02-08 15:53:45 +00:00
|
|
|
static std::string toBoolArg(const char* optarg)
|
2007-10-11 16:58:24 +00:00
|
|
|
{
|
2008-02-08 15:53:45 +00:00
|
|
|
std::string arg;
|
2008-05-13 14:15:23 +00:00
|
|
|
if(!optarg || strlen(optarg) == 0) {
|
2007-10-11 16:58:24 +00:00
|
|
|
arg = V_TRUE;
|
|
|
|
} else {
|
|
|
|
arg = optarg;
|
|
|
|
}
|
|
|
|
return arg;
|
|
|
|
}
|
|
|
|
|
2008-04-22 11:26:50 +00:00
|
|
|
Option* createDefaultOption()
|
2007-10-11 16:58:24 +00:00
|
|
|
{
|
|
|
|
Option* op = new Option();
|
|
|
|
op->put(PREF_STDOUT_LOG, V_FALSE);
|
|
|
|
op->put(PREF_DIR, ".");
|
2008-06-09 13:10:24 +00:00
|
|
|
op->put(PREF_SPLIT, "5");
|
2007-10-11 16:58:24 +00:00
|
|
|
op->put(PREF_DAEMON, V_FALSE);
|
|
|
|
op->put(PREF_SEGMENT_SIZE, Util::itos((int32_t)(1024*1024)));
|
2007-11-21 16:14:40 +00:00
|
|
|
op->put(PREF_LISTEN_PORT, "6881-6999");
|
2008-05-19 12:36:20 +00:00
|
|
|
op->put(PREF_METALINK_SERVERS, "5");
|
2007-10-11 16:58:24 +00:00
|
|
|
op->put(PREF_FOLLOW_TORRENT,
|
|
|
|
#ifdef ENABLE_BITTORRENT
|
|
|
|
V_TRUE
|
|
|
|
#else
|
|
|
|
V_FALSE
|
|
|
|
#endif // ENABLE_BITTORRENT
|
|
|
|
);
|
|
|
|
op->put(PREF_FOLLOW_METALINK,
|
|
|
|
#ifdef ENABLE_METALINK
|
|
|
|
V_TRUE
|
|
|
|
#else
|
|
|
|
V_FALSE
|
|
|
|
#endif // ENABLE_METALINK
|
|
|
|
);
|
|
|
|
op->put(PREF_RETRY_WAIT, "5");
|
|
|
|
op->put(PREF_TIMEOUT, "60");
|
2008-03-05 10:35:39 +00:00
|
|
|
op->put(PREF_DNS_TIMEOUT, "30");
|
2008-09-09 12:13:08 +00:00
|
|
|
op->put(PREF_CONNECT_TIMEOUT, "60");
|
2007-12-25 12:40:45 +00:00
|
|
|
op->put(PREF_PEER_CONNECTION_TIMEOUT, "20");
|
2007-10-11 16:58:24 +00:00
|
|
|
op->put(PREF_BT_TIMEOUT, "180");
|
|
|
|
op->put(PREF_BT_REQUEST_TIMEOUT, "60");
|
|
|
|
op->put(PREF_BT_KEEP_ALIVE_INTERVAL, "120");
|
|
|
|
op->put(PREF_MIN_SEGMENT_SIZE, "1048576");// 1M
|
|
|
|
op->put(PREF_MAX_TRIES, "5");
|
|
|
|
op->put(PREF_HTTP_AUTH_SCHEME, V_BASIC);
|
|
|
|
op->put(PREF_HTTP_PROXY_METHOD, V_TUNNEL);
|
|
|
|
op->put(PREF_FTP_TYPE, V_BINARY);
|
|
|
|
op->put(PREF_FTP_VIA_HTTP_PROXY, V_TUNNEL);
|
|
|
|
op->put(PREF_AUTO_SAVE_INTERVAL, "60");
|
|
|
|
op->put(PREF_DIRECT_FILE_MAPPING, V_TRUE);
|
|
|
|
op->put(PREF_LOWEST_SPEED_LIMIT, "0");
|
|
|
|
op->put(PREF_MAX_DOWNLOAD_LIMIT, "0");
|
|
|
|
op->put(PREF_MAX_UPLOAD_LIMIT, "0");
|
|
|
|
op->put(PREF_STARTUP_IDLE_TIME, "10");
|
|
|
|
op->put(PREF_TRACKER_MAX_TRIES, "10");
|
2007-10-29 12:43:45 +00:00
|
|
|
op->put(PREF_FILE_ALLOCATION, V_PREALLOC);
|
|
|
|
op->put(PREF_NO_FILE_ALLOCATION_LIMIT, "5242880"); // 5MiB
|
2007-10-11 16:58:24 +00:00
|
|
|
op->put(PREF_ALLOW_OVERWRITE, V_FALSE);
|
|
|
|
op->put(PREF_REALTIME_CHUNK_CHECKSUM, V_TRUE);
|
|
|
|
op->put(PREF_CHECK_INTEGRITY, V_FALSE);
|
|
|
|
op->put(PREF_NETRC_PATH, Util::getHomeDir()+"/.netrc");
|
|
|
|
op->put(PREF_CONTINUE, V_FALSE);
|
|
|
|
op->put(PREF_USER_AGENT, "aria2");
|
|
|
|
op->put(PREF_NO_NETRC, V_FALSE);
|
2008-05-19 12:36:20 +00:00
|
|
|
op->put(PREF_MAX_CONCURRENT_DOWNLOADS, "5");
|
2007-12-01 04:56:10 +00:00
|
|
|
op->put(PREF_DIRECT_DOWNLOAD_TIMEOUT, "300");
|
2007-10-11 16:58:24 +00:00
|
|
|
op->put(PREF_FORCE_SEQUENTIAL, V_FALSE);
|
|
|
|
op->put(PREF_AUTO_FILE_RENAMING, V_TRUE);
|
|
|
|
op->put(PREF_PARAMETERIZED_URI, V_FALSE);
|
2008-05-06 15:26:43 +00:00
|
|
|
op->put(PREF_ENABLE_HTTP_KEEP_ALIVE, V_TRUE);
|
2007-10-17 16:26:51 +00:00
|
|
|
op->put(PREF_ENABLE_HTTP_PIPELINING, V_FALSE);
|
|
|
|
op->put(PREF_MAX_HTTP_PIPELINING, "2");
|
2007-11-21 16:14:40 +00:00
|
|
|
op->put(PREF_SEED_RATIO, "1.0");
|
2007-11-28 14:22:28 +00:00
|
|
|
op->put(PREF_ENABLE_DIRECT_IO, V_FALSE);
|
2007-12-04 14:52:46 +00:00
|
|
|
op->put(PREF_ALLOW_PIECE_LENGTH_CHANGE, V_FALSE);
|
2007-12-12 13:53:33 +00:00
|
|
|
op->put(PREF_METALINK_PREFERRED_PROTOCOL, V_NONE);
|
2007-12-22 06:40:58 +00:00
|
|
|
op->put(PREF_METALINK_ENABLE_UNIQUE_PROTOCOL, V_TRUE);
|
2008-02-01 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
Added DHT functionality, compatible with mainline.
DHT is disabled by default. To enable it, give --enable-dht to
aria2c.
You may need to specify entry point to DHT network using
--dht-entry-point. DHT uses UDP port to listen incoming message.
Use --dht-listen-port to specify port number. Make sure that
your
firewall configuration can pass through UDP traffic to the port.
The routing table is saved in $HOME/.aria2/dht.dat.
* src/DHT*
* src/BNode.{h, cc}
* src/PeerInteractionCommand.cc: enable DHT functionality for a
particular torrent.
* src/Data.cc: Rewritten ctor.
* src/OptionHandlerFactory.cc: Added --enable-dht,
--dht-listen-port,
--dht-entry-point.
* src/DefaultBtInteractive.cc: Send port message if dht is
enabled.
* src/RequestGroup.cc: Initialize DHT functionality. When
download
ends, remove BtContext from DHTPeerAnnounceStorage.
* src/BtPortMessage.{h, cc}: Rewritten.
* src/message.h
* src/OptionHandlerImpl.cc
* src/option_processing.cc: Added --enable-dht,
--dht-listen-port,
--dht-entry-point.
* src/Dictionary.{h, cc} (remove): New function.
* src/prefs.h
* src/DefaultBtMessageFactory.h
* src/BtHandshakeMessage.cc
* src/ActivePeerConnectionCommand.cc
* src/SocketCore.{h, cc}: Added datagram socket support.
* src/DefaultBtMessageFactory.cc
* src/BtSetup.cc: Add BtContext to DHTPeerAnnounceStorage here.
Create DHT commands.
* src/BtMessageFactory.h
* src/PeerMessageUtil.{h, cc}
2008-02-01 17:36:33 +00:00
|
|
|
op->put(PREF_ENABLE_PEER_EXCHANGE, V_TRUE);
|
|
|
|
op->put(PREF_ENABLE_DHT, V_FALSE);
|
|
|
|
op->put(PREF_DHT_LISTEN_PORT, "6881-6999");
|
|
|
|
op->put(PREF_DHT_FILE_PATH, Util::getHomeDir()+"/.aria2/dht.dat");
|
2008-02-18 13:41:58 +00:00
|
|
|
op->put(PREF_BT_MIN_CRYPTO_LEVEL, V_PLAIN);
|
|
|
|
op->put(PREF_BT_REQUIRE_CRYPTO, V_FALSE);
|
2008-06-04 10:14:48 +00:00
|
|
|
op->put(PREF_BT_REQUEST_PEER_SPEED_LIMIT, "51200");
|
2008-06-08 12:34:36 +00:00
|
|
|
op->put(PREF_BT_MAX_OPEN_FILES, "100");
|
2008-07-12 13:54:36 +00:00
|
|
|
op->put(PREF_BT_SEED_UNVERIFIED, V_FALSE);
|
2008-04-22 10:29:48 +00:00
|
|
|
op->put(PREF_QUIET, V_FALSE);
|
2008-04-22 11:26:50 +00:00
|
|
|
op->put(PREF_STOP, "0");
|
2008-05-08 11:18:36 +00:00
|
|
|
#ifdef ENABLE_ASYNC_DNS
|
|
|
|
op->put(PREF_ASYNC_DNS, V_TRUE);
|
|
|
|
#else
|
|
|
|
op->put(PREF_ASYNC_DNS, V_FALSE);
|
|
|
|
#endif // ENABLE_ASYNC_DNS
|
2008-05-09 14:44:28 +00:00
|
|
|
op->put(PREF_FTP_REUSE_CONNECTION, V_TRUE);
|
2008-05-15 14:37:02 +00:00
|
|
|
op->put(PREF_SUMMARY_INTERVAL, "60");
|
2008-05-15 15:48:41 +00:00
|
|
|
op->put(PREF_LOG_LEVEL, V_DEBUG);
|
2008-08-04 17:06:47 +00:00
|
|
|
op->put(PREF_URI_SELECTOR, V_INORDER);
|
2008-08-10 15:22:55 +00:00
|
|
|
op->put(PREF_SERVER_STAT_TIMEOUT, "86400");// 1day
|
2008-09-07 14:38:26 +00:00
|
|
|
op->put(PREF_REMOTE_TIME, V_FALSE);
|
2008-09-10 14:56:44 +00:00
|
|
|
op->put(PREF_MAX_FILE_NOT_FOUND, "0");
|
2008-04-22 11:26:50 +00:00
|
|
|
return op;
|
|
|
|
}
|
|
|
|
|
|
|
|
Option* option_processing(int argc, char* const argv[])
|
|
|
|
{
|
|
|
|
std::stringstream cmdstream;
|
|
|
|
int32_t c;
|
|
|
|
Option* op = createDefaultOption();
|
2008-01-11 14:50:34 +00:00
|
|
|
|
|
|
|
// following options are not parsed by OptionHandler and not stored in Option.
|
|
|
|
bool noConf = false;
|
2008-02-08 15:53:45 +00:00
|
|
|
std::string defaultCfname = Util::getHomeDir()+"/.aria2/aria2.conf";
|
|
|
|
std::string ucfname;
|
2008-01-11 14:50:34 +00:00
|
|
|
|
2007-10-11 16:58:24 +00:00
|
|
|
while(1) {
|
|
|
|
int optIndex = 0;
|
|
|
|
int lopt;
|
|
|
|
static struct option longOpts[] = {
|
|
|
|
#ifdef HAVE_DAEMON
|
2008-05-19 10:25:38 +00:00
|
|
|
{ PREF_DAEMON.c_str(), no_argument, NULL, 'D' },
|
2007-10-11 16:58:24 +00:00
|
|
|
#endif // HAVE_DAEMON
|
2008-05-19 10:25:38 +00:00
|
|
|
{ PREF_DIR.c_str(), required_argument, NULL, 'd' },
|
|
|
|
{ PREF_OUT.c_str(), required_argument, NULL, 'o' },
|
|
|
|
{ PREF_LOG.c_str(), required_argument, NULL, 'l' },
|
|
|
|
{ PREF_SPLIT.c_str(), required_argument, NULL, 's' },
|
|
|
|
{ PREF_TIMEOUT.c_str(), required_argument, NULL, 't' },
|
|
|
|
{ PREF_MAX_TRIES.c_str(), required_argument, NULL, 'm' },
|
|
|
|
{ PREF_HTTP_PROXY.c_str(), required_argument, &lopt, 1 },
|
|
|
|
{ PREF_HTTP_USER.c_str(), required_argument, &lopt, 2 },
|
|
|
|
{ PREF_HTTP_PASSWD.c_str(), required_argument, &lopt, 3 },
|
|
|
|
{ PREF_HTTP_PROXY_USER.c_str(), required_argument, &lopt, 4 },
|
|
|
|
{ PREF_HTTP_PROXY_PASSWD.c_str(), required_argument, &lopt, 5 },
|
|
|
|
{ PREF_HTTP_AUTH_SCHEME.c_str(), required_argument, &lopt, 6 },
|
|
|
|
{ PREF_REFERER.c_str(), required_argument, &lopt, 7 },
|
|
|
|
{ PREF_RETRY_WAIT.c_str(), required_argument, &lopt, 8 },
|
|
|
|
{ PREF_FTP_USER.c_str(), required_argument, &lopt, 9 },
|
|
|
|
{ PREF_FTP_PASSWD.c_str(), required_argument, &lopt, 10 },
|
|
|
|
{ PREF_FTP_TYPE.c_str(), required_argument, &lopt, 11 },
|
|
|
|
{ PREF_FTP_PASV.c_str(), no_argument, NULL, 'p' },
|
|
|
|
{ PREF_FTP_VIA_HTTP_PROXY.c_str(), required_argument, &lopt, 12 },
|
|
|
|
//{ PREF_MIN_SEGMENT_SIZE.c_str(), required_argument, &lopt, 13 },
|
|
|
|
{ PREF_HTTP_PROXY_METHOD.c_str(), required_argument, &lopt, 14 },
|
|
|
|
{ PREF_LOWEST_SPEED_LIMIT.c_str(), required_argument, &lopt, 200 },
|
|
|
|
{ PREF_MAX_DOWNLOAD_LIMIT.c_str(), required_argument, &lopt, 201 },
|
|
|
|
{ PREF_FILE_ALLOCATION.c_str(), required_argument, 0, 'a' },
|
|
|
|
{ PREF_ALLOW_OVERWRITE.c_str(), required_argument, &lopt, 202 },
|
2007-10-11 16:58:24 +00:00
|
|
|
#ifdef ENABLE_MESSAGE_DIGEST
|
2008-05-19 10:25:38 +00:00
|
|
|
{ PREF_CHECK_INTEGRITY.c_str(), required_argument, &lopt, 203 },
|
|
|
|
{ PREF_REALTIME_CHUNK_CHECKSUM.c_str(), required_argument, &lopt, 204 },
|
2007-10-11 16:58:24 +00:00
|
|
|
#endif // ENABLE_MESSAGE_DIGEST
|
2008-05-19 10:25:38 +00:00
|
|
|
{ PREF_CONTINUE.c_str(), no_argument, 0, 'c' },
|
|
|
|
{ PREF_USER_AGENT.c_str(), required_argument, 0, 'U' },
|
|
|
|
{ PREF_NO_NETRC.c_str(), no_argument, 0, 'n' },
|
|
|
|
{ PREF_INPUT_FILE.c_str(), required_argument, 0, 'i' },
|
|
|
|
{ PREF_MAX_CONCURRENT_DOWNLOADS.c_str(), required_argument, 0, 'j' },
|
|
|
|
{ PREF_LOAD_COOKIES.c_str(), required_argument, &lopt, 205 },
|
|
|
|
{ PREF_FORCE_SEQUENTIAL.c_str(), optional_argument, 0, 'Z' },
|
|
|
|
{ PREF_AUTO_FILE_RENAMING.c_str(), optional_argument, &lopt, 206 },
|
|
|
|
{ PREF_PARAMETERIZED_URI.c_str(), optional_argument, 0, 'P' },
|
|
|
|
{ PREF_ENABLE_HTTP_KEEP_ALIVE.c_str(), optional_argument, &lopt, 207 },
|
|
|
|
{ PREF_ENABLE_HTTP_PIPELINING.c_str(), optional_argument, &lopt, 208 },
|
|
|
|
{ PREF_NO_FILE_ALLOCATION_LIMIT.c_str(), required_argument, &lopt, 209 },
|
2007-11-28 14:22:28 +00:00
|
|
|
#ifdef ENABLE_DIRECT_IO
|
2008-05-19 10:25:38 +00:00
|
|
|
{ PREF_ENABLE_DIRECT_IO.c_str(), optional_argument, &lopt, 210 },
|
2007-11-28 14:22:28 +00:00
|
|
|
#endif // ENABLE_DIRECT_IO
|
2008-05-19 10:25:38 +00:00
|
|
|
{ PREF_ALLOW_PIECE_LENGTH_CHANGE.c_str(), required_argument, &lopt, 211 },
|
|
|
|
{ PREF_NO_CONF.c_str(), no_argument, &lopt, 212 },
|
|
|
|
{ PREF_CONF_PATH.c_str(), required_argument, &lopt, 213 },
|
|
|
|
{ PREF_STOP.c_str(), required_argument, &lopt, 214 },
|
|
|
|
{ PREF_HEADER.c_str(), required_argument, &lopt, 215 },
|
|
|
|
{ PREF_QUIET.c_str(), optional_argument, 0, 'q' },
|
2008-05-08 11:18:36 +00:00
|
|
|
#ifdef ENABLE_ASYNC_DNS
|
2008-05-19 10:25:38 +00:00
|
|
|
{ PREF_ASYNC_DNS.c_str(), optional_argument, &lopt, 216 },
|
2008-05-08 11:18:36 +00:00
|
|
|
#endif // ENABLE_ASYNC_DNS
|
2008-05-19 10:25:38 +00:00
|
|
|
{ PREF_FTP_REUSE_CONNECTION.c_str(), optional_argument, &lopt, 217 },
|
|
|
|
{ PREF_SUMMARY_INTERVAL.c_str(), required_argument, &lopt, 218 },
|
|
|
|
{ PREF_LOG_LEVEL.c_str(), required_argument, &lopt, 219 },
|
2008-08-04 17:06:47 +00:00
|
|
|
{ PREF_URI_SELECTOR.c_str(), required_argument, &lopt, 220 },
|
2008-08-10 15:22:55 +00:00
|
|
|
{ PREF_SERVER_STAT_IF.c_str(), required_argument, &lopt, 221 },
|
|
|
|
{ PREF_SERVER_STAT_OF.c_str(), required_argument, &lopt, 222 },
|
|
|
|
{ PREF_SERVER_STAT_TIMEOUT.c_str(), required_argument, &lopt, 223 },
|
2008-09-07 14:38:26 +00:00
|
|
|
{ PREF_REMOTE_TIME.c_str(), optional_argument, 0, 'R' },
|
2008-09-09 12:13:08 +00:00
|
|
|
{ PREF_CONNECT_TIMEOUT.c_str(), required_argument, &lopt, 224 },
|
2008-09-10 14:56:44 +00:00
|
|
|
{ PREF_MAX_FILE_NOT_FOUND.c_str(), required_argument, &lopt, 225 },
|
2008-05-31 05:32:09 +00:00
|
|
|
#if defined ENABLE_BITTORRENT || defined ENABLE_METALINK
|
2008-05-19 10:25:38 +00:00
|
|
|
{ PREF_SHOW_FILES.c_str(), no_argument, NULL, 'S' },
|
|
|
|
{ PREF_SELECT_FILE.c_str(), required_argument, &lopt, 21 },
|
2007-10-11 16:58:24 +00:00
|
|
|
#endif // ENABLE_BITTORRENT || ENABLE_METALINK
|
|
|
|
#ifdef ENABLE_BITTORRENT
|
2008-05-19 10:25:38 +00:00
|
|
|
{ PREF_TORRENT_FILE.c_str(), required_argument, NULL, 'T' },
|
|
|
|
{ PREF_LISTEN_PORT.c_str(), required_argument, &lopt, 15 },
|
|
|
|
{ PREF_FOLLOW_TORRENT.c_str(), required_argument, &lopt, 16 },
|
|
|
|
{ PREF_NO_PREALLOCATION.c_str(), no_argument, &lopt, 18 },
|
|
|
|
{ PREF_DIRECT_FILE_MAPPING.c_str(), required_argument, &lopt, 19 },
|
2007-10-11 16:58:24 +00:00
|
|
|
// TODO remove upload-limit.
|
2008-05-19 10:25:38 +00:00
|
|
|
//{ "upload-limit".c_str(), required_argument, &lopt, 20 },
|
|
|
|
{ PREF_SEED_TIME.c_str(), required_argument, &lopt, 22 },
|
|
|
|
{ PREF_SEED_RATIO.c_str(), required_argument, &lopt, 23 },
|
|
|
|
{ PREF_MAX_UPLOAD_LIMIT.c_str(), required_argument, &lopt, 24 },
|
|
|
|
{ PREF_PEER_ID_PREFIX.c_str(), required_argument, &lopt, 25 },
|
|
|
|
{ PREF_ENABLE_PEER_EXCHANGE.c_str(), optional_argument, &lopt, 26 },
|
|
|
|
{ PREF_ENABLE_DHT.c_str(), optional_argument, &lopt, 27 },
|
|
|
|
{ PREF_DHT_LISTEN_PORT.c_str(), required_argument, &lopt, 28 },
|
|
|
|
{ PREF_DHT_ENTRY_POINT.c_str(), required_argument, &lopt, 29 },
|
|
|
|
{ PREF_BT_MIN_CRYPTO_LEVEL.c_str(), required_argument, &lopt, 30 },
|
|
|
|
{ PREF_BT_REQUIRE_CRYPTO.c_str(), required_argument, &lopt, 31 },
|
2008-06-04 10:14:48 +00:00
|
|
|
{ PREF_BT_REQUEST_PEER_SPEED_LIMIT.c_str(), required_argument, &lopt, 32 },
|
2008-07-08 14:18:51 +00:00
|
|
|
{ PREF_BT_MAX_OPEN_FILES.c_str(), required_argument, &lopt, 33 },
|
2008-07-12 13:54:36 +00:00
|
|
|
{ PREF_BT_SEED_UNVERIFIED.c_str(), optional_argument, &lopt, 34 },
|
2007-10-11 16:58:24 +00:00
|
|
|
#endif // ENABLE_BITTORRENT
|
|
|
|
#ifdef ENABLE_METALINK
|
2008-05-19 10:25:38 +00:00
|
|
|
{ PREF_METALINK_FILE.c_str(), required_argument, NULL, 'M' },
|
|
|
|
{ PREF_METALINK_SERVERS.c_str(), required_argument, NULL, 'C' },
|
|
|
|
{ PREF_METALINK_VERSION.c_str(), required_argument, &lopt, 100 },
|
|
|
|
{ PREF_METALINK_LANGUAGE.c_str(), required_argument, &lopt, 101 },
|
|
|
|
{ PREF_METALINK_OS.c_str(), required_argument, &lopt, 102 },
|
|
|
|
{ PREF_FOLLOW_METALINK.c_str(), required_argument, &lopt, 103 },
|
|
|
|
{ PREF_METALINK_LOCATION.c_str(), required_argument, &lopt, 104 },
|
|
|
|
{ PREF_METALINK_PREFERRED_PROTOCOL.c_str(), required_argument, &lopt, 105 },
|
|
|
|
{ PREF_METALINK_ENABLE_UNIQUE_PROTOCOL.c_str(), optional_argument, &lopt, 106 },
|
2007-10-11 16:58:24 +00:00
|
|
|
#endif // ENABLE_METALINK
|
|
|
|
{ "version", no_argument, NULL, 'v' },
|
2008-01-05 11:26:56 +00:00
|
|
|
{ "help", optional_argument, NULL, 'h' },
|
2007-10-11 16:58:24 +00:00
|
|
|
{ 0, 0, 0, 0 }
|
|
|
|
};
|
2008-09-07 14:38:26 +00:00
|
|
|
c = getopt_long(argc, argv,
|
|
|
|
"Dd:o:l:s:pt:m:vh::ST:M:C:a:cU:ni:j:Z::P::q::R::",
|
|
|
|
longOpts, &optIndex);
|
2007-10-11 16:58:24 +00:00
|
|
|
if(c == -1) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
switch(c) {
|
|
|
|
case 0:{
|
|
|
|
switch(lopt) {
|
|
|
|
case 1:
|
|
|
|
cmdstream << PREF_HTTP_PROXY << "=" << optarg << "\n";
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
cmdstream << PREF_HTTP_USER << "=" << optarg << "\n";
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
cmdstream << PREF_HTTP_PASSWD << "=" << optarg << "\n";
|
|
|
|
break;
|
|
|
|
case 4:
|
|
|
|
cmdstream << PREF_HTTP_PROXY_USER << "=" << optarg << "\n";
|
|
|
|
break;
|
|
|
|
case 5:
|
|
|
|
cmdstream << PREF_HTTP_PROXY_PASSWD << "=" << optarg << "\n";
|
|
|
|
break;
|
|
|
|
case 6:
|
|
|
|
cmdstream << PREF_HTTP_AUTH_SCHEME << "=" << optarg << "\n";
|
|
|
|
break;
|
|
|
|
case 7:
|
|
|
|
cmdstream << PREF_REFERER << "=" << optarg << "\n";
|
|
|
|
break;
|
|
|
|
case 8:
|
|
|
|
cmdstream << PREF_RETRY_WAIT << "=" << optarg << "\n";
|
|
|
|
break;
|
|
|
|
case 9:
|
|
|
|
cmdstream << PREF_FTP_USER << "=" << optarg << "\n";
|
|
|
|
break;
|
|
|
|
case 10:
|
|
|
|
cmdstream << PREF_FTP_PASSWD << "=" << optarg << "\n";
|
|
|
|
break;
|
|
|
|
case 11:
|
|
|
|
cmdstream << PREF_FTP_TYPE << "=" << optarg << "\n";
|
|
|
|
break;
|
|
|
|
case 12:
|
|
|
|
cmdstream << PREF_FTP_VIA_HTTP_PROXY << "=" << optarg << "\n";
|
|
|
|
break;
|
|
|
|
case 13:
|
|
|
|
cmdstream << PREF_MIN_SEGMENT_SIZE << "=" << optarg << "\n";
|
|
|
|
break;
|
|
|
|
case 14:
|
|
|
|
cmdstream << PREF_HTTP_PROXY_METHOD << "=" << optarg << "\n";
|
|
|
|
break;
|
|
|
|
case 15:
|
|
|
|
cmdstream << PREF_LISTEN_PORT << "=" << optarg << "\n";
|
|
|
|
break;
|
|
|
|
case 16:
|
|
|
|
cmdstream << PREF_FOLLOW_TORRENT << "=" << optarg << "\n";
|
|
|
|
break;
|
|
|
|
case 18:
|
|
|
|
cmdstream << PREF_NO_PREALLOCATION << "=" << V_TRUE << "\n";
|
|
|
|
break;
|
|
|
|
case 19:
|
|
|
|
cmdstream << PREF_DIRECT_FILE_MAPPING << "=" << optarg << "\n";
|
|
|
|
break;
|
|
|
|
case 21:
|
|
|
|
cmdstream << PREF_SELECT_FILE << "=" << optarg << "\n";
|
|
|
|
break;
|
|
|
|
case 22:
|
|
|
|
cmdstream << PREF_SEED_TIME << "=" << optarg << "\n";
|
|
|
|
break;
|
|
|
|
case 23:
|
|
|
|
cmdstream << PREF_SEED_RATIO << "=" << optarg << "\n";
|
|
|
|
break;
|
|
|
|
case 24:
|
|
|
|
cmdstream << PREF_MAX_UPLOAD_LIMIT << "=" << optarg << "\n";
|
|
|
|
break;
|
|
|
|
case 25:
|
|
|
|
cmdstream << PREF_PEER_ID_PREFIX << "=" << optarg << "\n";
|
2008-01-05 16:02:25 +00:00
|
|
|
break;
|
|
|
|
case 26:
|
|
|
|
cmdstream << PREF_ENABLE_PEER_EXCHANGE << "=" << toBoolArg(optarg) << "\n";
|
|
|
|
break;
|
2008-02-01 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
Added DHT functionality, compatible with mainline.
DHT is disabled by default. To enable it, give --enable-dht to
aria2c.
You may need to specify entry point to DHT network using
--dht-entry-point. DHT uses UDP port to listen incoming message.
Use --dht-listen-port to specify port number. Make sure that
your
firewall configuration can pass through UDP traffic to the port.
The routing table is saved in $HOME/.aria2/dht.dat.
* src/DHT*
* src/BNode.{h, cc}
* src/PeerInteractionCommand.cc: enable DHT functionality for a
particular torrent.
* src/Data.cc: Rewritten ctor.
* src/OptionHandlerFactory.cc: Added --enable-dht,
--dht-listen-port,
--dht-entry-point.
* src/DefaultBtInteractive.cc: Send port message if dht is
enabled.
* src/RequestGroup.cc: Initialize DHT functionality. When
download
ends, remove BtContext from DHTPeerAnnounceStorage.
* src/BtPortMessage.{h, cc}: Rewritten.
* src/message.h
* src/OptionHandlerImpl.cc
* src/option_processing.cc: Added --enable-dht,
--dht-listen-port,
--dht-entry-point.
* src/Dictionary.{h, cc} (remove): New function.
* src/prefs.h
* src/DefaultBtMessageFactory.h
* src/BtHandshakeMessage.cc
* src/ActivePeerConnectionCommand.cc
* src/SocketCore.{h, cc}: Added datagram socket support.
* src/DefaultBtMessageFactory.cc
* src/BtSetup.cc: Add BtContext to DHTPeerAnnounceStorage here.
Create DHT commands.
* src/BtMessageFactory.h
* src/PeerMessageUtil.{h, cc}
2008-02-01 17:36:33 +00:00
|
|
|
case 27:
|
|
|
|
cmdstream << PREF_ENABLE_DHT << "=" << toBoolArg(optarg) << "\n";
|
|
|
|
break;
|
|
|
|
case 28:
|
|
|
|
cmdstream << PREF_DHT_LISTEN_PORT << "=" << optarg << "\n";
|
|
|
|
break;
|
|
|
|
case 29:
|
|
|
|
cmdstream << PREF_DHT_ENTRY_POINT << "=" << optarg << "\n";
|
|
|
|
break;
|
2008-02-18 13:41:58 +00:00
|
|
|
case 30:
|
|
|
|
cmdstream << PREF_BT_MIN_CRYPTO_LEVEL << "=" << optarg << "\n";
|
|
|
|
break;
|
|
|
|
case 31:
|
|
|
|
cmdstream << PREF_BT_REQUIRE_CRYPTO << "=" << optarg << "\n";
|
|
|
|
break;
|
2008-06-04 10:14:48 +00:00
|
|
|
case 32:
|
|
|
|
cmdstream << PREF_BT_REQUEST_PEER_SPEED_LIMIT << "=" << optarg << "\n";
|
|
|
|
break;
|
2008-06-08 12:34:36 +00:00
|
|
|
case 33:
|
|
|
|
cmdstream << PREF_BT_MAX_OPEN_FILES << "=" << optarg << "\n";
|
|
|
|
break;
|
2008-07-08 14:18:51 +00:00
|
|
|
case 34:
|
2008-07-12 13:54:36 +00:00
|
|
|
cmdstream << PREF_BT_SEED_UNVERIFIED << "=" << toBoolArg(optarg)
|
|
|
|
<< "\n";
|
2008-07-08 14:18:51 +00:00
|
|
|
break;
|
2007-10-11 16:58:24 +00:00
|
|
|
case 100:
|
|
|
|
cmdstream << PREF_METALINK_VERSION << "=" << optarg << "\n";
|
|
|
|
break;
|
|
|
|
case 101:
|
|
|
|
cmdstream << PREF_METALINK_LANGUAGE << "=" << optarg << "\n";
|
|
|
|
break;
|
|
|
|
case 102:
|
|
|
|
cmdstream << PREF_METALINK_OS << "=" << optarg << "\n";
|
|
|
|
break;
|
|
|
|
case 103:
|
|
|
|
cmdstream << PREF_FOLLOW_METALINK << "=" << optarg << "\n";
|
|
|
|
break;
|
|
|
|
case 104:
|
|
|
|
cmdstream << PREF_METALINK_LOCATION << "=" << optarg << "\n";
|
|
|
|
break;
|
2007-12-12 13:53:33 +00:00
|
|
|
case 105:
|
|
|
|
cmdstream << PREF_METALINK_PREFERRED_PROTOCOL << "=" << optarg << "\n";
|
|
|
|
break;
|
2007-12-22 06:40:58 +00:00
|
|
|
case 106:
|
|
|
|
cmdstream << PREF_METALINK_ENABLE_UNIQUE_PROTOCOL << "=" << toBoolArg(optarg) << "\n";
|
|
|
|
break;
|
2007-10-11 16:58:24 +00:00
|
|
|
case 200:
|
|
|
|
cmdstream << PREF_LOWEST_SPEED_LIMIT << "=" << optarg << "\n";
|
|
|
|
break;
|
|
|
|
case 201:
|
|
|
|
cmdstream << PREF_MAX_DOWNLOAD_LIMIT << "=" << optarg << "\n";
|
|
|
|
break;
|
|
|
|
case 202:
|
|
|
|
cmdstream << PREF_ALLOW_OVERWRITE << "=" << optarg << "\n";
|
|
|
|
break;
|
|
|
|
case 203:
|
|
|
|
cmdstream << PREF_CHECK_INTEGRITY << "=" << optarg << "\n";
|
|
|
|
break;
|
|
|
|
case 204:
|
|
|
|
cmdstream << PREF_REALTIME_CHUNK_CHECKSUM << "=" << optarg << "\n";
|
|
|
|
break;
|
|
|
|
case 205:
|
|
|
|
cmdstream << PREF_LOAD_COOKIES << "=" << optarg << "\n";
|
|
|
|
break;
|
|
|
|
case 206:
|
|
|
|
cmdstream << PREF_AUTO_FILE_RENAMING << "=" << toBoolArg(optarg) << "\n";
|
|
|
|
break;
|
2007-10-17 16:26:51 +00:00
|
|
|
case 207:
|
|
|
|
cmdstream << PREF_ENABLE_HTTP_KEEP_ALIVE << "=" << toBoolArg(optarg) << "\n";
|
|
|
|
break;
|
|
|
|
case 208:
|
|
|
|
cmdstream << PREF_ENABLE_HTTP_PIPELINING << "=" << toBoolArg(optarg) << "\n";
|
|
|
|
break;
|
2007-10-29 12:43:45 +00:00
|
|
|
case 209:
|
|
|
|
cmdstream << PREF_NO_FILE_ALLOCATION_LIMIT << "=" << optarg << "\n";
|
|
|
|
break;
|
2007-11-28 14:22:28 +00:00
|
|
|
case 210:
|
|
|
|
cmdstream << PREF_ENABLE_DIRECT_IO << "=" << toBoolArg(optarg) << "\n";
|
|
|
|
break;
|
2007-12-04 14:52:46 +00:00
|
|
|
case 211:
|
|
|
|
cmdstream << PREF_ALLOW_PIECE_LENGTH_CHANGE << "=" << optarg << "\n";
|
|
|
|
break;
|
2008-01-11 14:50:34 +00:00
|
|
|
case 212:
|
|
|
|
noConf = true;
|
|
|
|
break;
|
|
|
|
case 213:
|
2008-01-20 15:20:16 +00:00
|
|
|
ucfname = optarg;
|
2008-01-11 14:50:34 +00:00
|
|
|
break;
|
2008-02-11 05:07:08 +00:00
|
|
|
case 214:
|
|
|
|
cmdstream << PREF_STOP << "=" << optarg << "\n";
|
|
|
|
break;
|
2008-04-20 06:30:44 +00:00
|
|
|
case 215:
|
|
|
|
cmdstream << PREF_HEADER << "=" << optarg << "\n";
|
|
|
|
break;
|
2008-05-08 11:18:36 +00:00
|
|
|
#ifdef ENABLE_ASYNC_DNS
|
|
|
|
case 216:
|
|
|
|
cmdstream << PREF_ASYNC_DNS << "=" << toBoolArg(optarg) << "\n";
|
|
|
|
break;
|
|
|
|
#endif // ENABLE_ASYNC_DNS
|
2008-05-09 14:44:28 +00:00
|
|
|
case 217:
|
|
|
|
cmdstream << PREF_FTP_REUSE_CONNECTION << "=" << toBoolArg(optarg) << "\n";
|
|
|
|
break;
|
2008-05-15 14:37:02 +00:00
|
|
|
case 218:
|
|
|
|
cmdstream << PREF_SUMMARY_INTERVAL << "=" << optarg << "\n";
|
|
|
|
break;
|
2008-05-15 15:48:41 +00:00
|
|
|
case 219:
|
|
|
|
cmdstream << PREF_LOG_LEVEL << "=" << optarg << "\n";
|
|
|
|
break;
|
2008-08-04 17:06:47 +00:00
|
|
|
case 220:
|
|
|
|
cmdstream << PREF_URI_SELECTOR << "=" << optarg << "\n";
|
|
|
|
break;
|
2008-08-10 15:22:55 +00:00
|
|
|
case 221:
|
|
|
|
cmdstream << PREF_SERVER_STAT_IF << "=" << optarg << "\n";
|
|
|
|
break;
|
|
|
|
case 222:
|
|
|
|
cmdstream << PREF_SERVER_STAT_OF << "=" << optarg << "\n";
|
|
|
|
break;
|
|
|
|
case 223:
|
|
|
|
cmdstream << PREF_SERVER_STAT_TIMEOUT << "=" << optarg << "\n";
|
|
|
|
break;
|
2008-09-09 12:13:08 +00:00
|
|
|
case 224:
|
|
|
|
cmdstream << PREF_CONNECT_TIMEOUT << "=" << optarg << "\n";
|
|
|
|
break;
|
2008-09-10 14:56:44 +00:00
|
|
|
case 225:
|
|
|
|
cmdstream << PREF_MAX_FILE_NOT_FOUND << "=" << optarg << "\n";
|
|
|
|
break;
|
2007-10-11 16:58:24 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
#ifdef HAVE_DAEMON
|
|
|
|
case 'D':
|
|
|
|
cmdstream << PREF_DAEMON << "=" << V_TRUE << "\n";
|
|
|
|
break;
|
|
|
|
#endif // HAVE_DAEMON
|
|
|
|
case 'd':
|
|
|
|
cmdstream << PREF_DIR << "=" << optarg << "\n";
|
|
|
|
break;
|
|
|
|
case 'o':
|
|
|
|
cmdstream << PREF_OUT << "=" << optarg << "\n";
|
|
|
|
break;
|
|
|
|
case 'l':
|
|
|
|
cmdstream << PREF_LOG << "=" << optarg << "\n";
|
|
|
|
break;
|
|
|
|
case 's':
|
|
|
|
cmdstream << PREF_SPLIT << "=" << optarg << "\n";
|
|
|
|
break;
|
|
|
|
case 't':
|
|
|
|
cmdstream << PREF_TIMEOUT << "=" << optarg << "\n";
|
|
|
|
break;
|
|
|
|
case 'm':
|
|
|
|
cmdstream << PREF_MAX_TRIES << "=" << optarg << "\n";
|
|
|
|
break;
|
|
|
|
case 'p':
|
|
|
|
cmdstream << PREF_FTP_PASV << "=" << V_TRUE << "\n";
|
|
|
|
break;
|
|
|
|
case 'S':
|
|
|
|
cmdstream << PREF_SHOW_FILES << "=" << V_TRUE << "\n";
|
|
|
|
break;
|
|
|
|
case 'T':
|
|
|
|
cmdstream << PREF_TORRENT_FILE << "=" << optarg << "\n";
|
|
|
|
break;
|
|
|
|
case 'M':
|
|
|
|
cmdstream << PREF_METALINK_FILE << "=" << optarg << "\n";
|
|
|
|
break;
|
|
|
|
case 'C':
|
|
|
|
cmdstream << PREF_METALINK_SERVERS << "=" << optarg << "\n";
|
|
|
|
break;
|
|
|
|
case 'a':
|
|
|
|
cmdstream << PREF_FILE_ALLOCATION << "=" << optarg << "\n";
|
|
|
|
break;
|
|
|
|
case 'c':
|
|
|
|
cmdstream << PREF_CONTINUE << "=" << V_TRUE << "\n";
|
|
|
|
break;
|
|
|
|
case 'U':
|
|
|
|
cmdstream << PREF_USER_AGENT << "=" << optarg << "\n";
|
|
|
|
break;
|
|
|
|
case 'n':
|
|
|
|
cmdstream << PREF_NO_NETRC << "=" << V_TRUE << "\n";
|
|
|
|
break;
|
|
|
|
case 'i':
|
|
|
|
cmdstream << PREF_INPUT_FILE << "=" << optarg << "\n";
|
|
|
|
break;
|
|
|
|
case 'j':
|
|
|
|
cmdstream << PREF_MAX_CONCURRENT_DOWNLOADS << "=" << optarg << "\n";
|
|
|
|
break;
|
|
|
|
case 'Z':
|
|
|
|
cmdstream << PREF_FORCE_SEQUENTIAL << "=" << toBoolArg(optarg) << "\n";
|
|
|
|
break;
|
|
|
|
case 'P':
|
|
|
|
cmdstream << PREF_PARAMETERIZED_URI << "=" << toBoolArg(optarg) << "\n";
|
|
|
|
break;
|
2008-04-22 10:29:48 +00:00
|
|
|
case 'q':
|
|
|
|
cmdstream << PREF_QUIET << "=" << toBoolArg(optarg) << "\n";
|
|
|
|
break;
|
2008-09-07 14:38:26 +00:00
|
|
|
case 'R':
|
|
|
|
cmdstream << PREF_REMOTE_TIME << "=" << toBoolArg(optarg) << "\n";
|
|
|
|
break;
|
2007-10-11 16:58:24 +00:00
|
|
|
case 'v':
|
|
|
|
showVersion();
|
|
|
|
exit(EXIT_SUCCESS);
|
|
|
|
case 'h':
|
2008-01-05 11:26:56 +00:00
|
|
|
{
|
2008-02-08 15:53:45 +00:00
|
|
|
std::string category;
|
2008-05-13 14:15:23 +00:00
|
|
|
if(optarg == 0 || strlen(optarg) == 0) {
|
2008-01-05 11:26:56 +00:00
|
|
|
category = TAG_BASIC;
|
|
|
|
} else {
|
|
|
|
category = optarg;
|
|
|
|
}
|
2008-04-22 11:26:50 +00:00
|
|
|
showUsage(category, createDefaultOption());
|
2008-01-05 11:26:56 +00:00
|
|
|
exit(EXIT_SUCCESS);
|
|
|
|
}
|
2007-10-11 16:58:24 +00:00
|
|
|
default:
|
2008-05-10 02:35:42 +00:00
|
|
|
showUsage(TAG_HELP, op);
|
2007-10-11 16:58:24 +00:00
|
|
|
exit(EXIT_FAILURE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
{
|
|
|
|
OptionParser oparser;
|
|
|
|
oparser.setOptionHandlers(OptionHandlerFactory::createOptionHandlers());
|
2008-01-11 14:50:34 +00:00
|
|
|
if(!noConf) {
|
2008-02-08 15:53:45 +00:00
|
|
|
std::string cfname;
|
2008-01-20 15:20:16 +00:00
|
|
|
if(ucfname.size()) {
|
|
|
|
cfname = ucfname;
|
|
|
|
} else {
|
|
|
|
cfname = defaultCfname;
|
|
|
|
}
|
2008-01-11 14:50:34 +00:00
|
|
|
if(File(cfname).isFile()) {
|
2008-02-08 15:53:45 +00:00
|
|
|
std::ifstream cfstream(cfname.c_str());
|
2008-01-11 14:50:34 +00:00
|
|
|
try {
|
|
|
|
oparser.parse(op, cfstream);
|
2008-04-27 02:22:14 +00:00
|
|
|
} catch(Exception& e) {
|
2008-02-08 15:53:45 +00:00
|
|
|
std::cerr << "Parse error in " << cfname << "\n"
|
2008-04-27 02:22:14 +00:00
|
|
|
<< e.stackTrace() << std::endl;
|
2008-01-11 14:50:34 +00:00
|
|
|
exit(EXIT_FAILURE);
|
|
|
|
}
|
2008-01-20 15:20:16 +00:00
|
|
|
} else if(ucfname.size()) {
|
2008-04-26 05:58:49 +00:00
|
|
|
std::cout << StringFormat("Configuration file %s is not found.", cfname.c_str())
|
|
|
|
<< "\n";
|
2008-01-11 14:50:34 +00:00
|
|
|
}
|
2007-10-11 16:58:24 +00:00
|
|
|
}
|
|
|
|
try {
|
|
|
|
oparser.parse(op, cmdstream);
|
2008-04-27 02:22:14 +00:00
|
|
|
} catch(Exception& e) {
|
|
|
|
std::cerr << e.stackTrace() << std::endl;
|
2008-05-10 02:35:42 +00:00
|
|
|
showUsage(TAG_HELP, op);
|
2007-10-11 16:58:24 +00:00
|
|
|
exit(EXIT_FAILURE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(op->defined(PREF_HTTP_USER)) {
|
|
|
|
op->put(PREF_HTTP_AUTH_ENABLED, V_TRUE);
|
|
|
|
}
|
|
|
|
if(op->defined(PREF_HTTP_PROXY_USER)) {
|
|
|
|
op->put(PREF_HTTP_PROXY_AUTH_ENABLED, V_TRUE);
|
|
|
|
}
|
|
|
|
if(
|
|
|
|
#ifdef ENABLE_BITTORRENT
|
|
|
|
!op->defined(PREF_TORRENT_FILE) &&
|
|
|
|
#endif // ENABLE_BITTORRENT
|
|
|
|
#ifdef ENABLE_METALINK
|
|
|
|
!op->defined(PREF_METALINK_FILE) &&
|
|
|
|
#endif // ENABLE_METALINK
|
|
|
|
!op->defined(PREF_INPUT_FILE)) {
|
|
|
|
if(optind == argc) {
|
2008-02-08 15:53:45 +00:00
|
|
|
std::cerr << MSG_URI_REQUIRED << std::endl;
|
2008-05-10 02:35:42 +00:00
|
|
|
showUsage(TAG_HELP, op);
|
2007-10-11 16:58:24 +00:00
|
|
|
exit(EXIT_FAILURE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#ifdef HAVE_DAEMON
|
|
|
|
if(op->getAsBool(PREF_DAEMON)) {
|
|
|
|
if(daemon(1, 1) < 0) {
|
|
|
|
perror(MSG_DAEMON_FAILED);
|
|
|
|
exit(EXIT_FAILURE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif // HAVE_DAEMON
|
|
|
|
return op;
|
|
|
|
}
|
2008-02-08 15:53:45 +00:00
|
|
|
|
|
|
|
} // namespace aria2
|