2007-03-26 12:16:57 +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-03-26 12:16:57 +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 --> */
|
|
|
|
#ifndef _D_OPTION_HANDLER_IMPL_H_
|
|
|
|
#define _D_OPTION_HANDLER_IMPL_H_
|
|
|
|
|
|
|
|
#include "OptionHandler.h"
|
2008-11-04 14:08:26 +00:00
|
|
|
|
2010-03-11 15:09:34 +00:00
|
|
|
#include <cassert>
|
2008-11-04 14:08:26 +00:00
|
|
|
#include <cstdio>
|
|
|
|
#include <utility>
|
|
|
|
#include <algorithm>
|
|
|
|
#include <numeric>
|
|
|
|
#include <sstream>
|
|
|
|
#include <iterator>
|
2010-02-28 12:30:11 +00:00
|
|
|
#include <vector>
|
2008-11-04 14:08:26 +00:00
|
|
|
|
2007-03-26 12:16:57 +00:00
|
|
|
#include "NameMatchOptionHandler.h"
|
2009-10-22 15:35:33 +00:00
|
|
|
#include "util.h"
|
2009-05-12 13:51:12 +00:00
|
|
|
#include "DlAbortEx.h"
|
2007-03-26 12:16:57 +00:00
|
|
|
#include "prefs.h"
|
2008-02-08 15:53:45 +00:00
|
|
|
#include "Option.h"
|
2008-04-27 02:22:14 +00:00
|
|
|
#include "StringFormat.h"
|
2008-09-22 09:26:57 +00:00
|
|
|
#include "A2STR.h"
|
2008-11-04 14:08:26 +00:00
|
|
|
#include "Request.h"
|
2009-06-06 12:33:07 +00:00
|
|
|
#include "a2functional.h"
|
2009-09-09 12:50:42 +00:00
|
|
|
#include "message.h"
|
|
|
|
#include "File.h"
|
2009-11-29 06:43:38 +00:00
|
|
|
#include "FileEntry.h"
|
2009-12-09 14:32:12 +00:00
|
|
|
#include "a2io.h"
|
2008-02-08 15:53:45 +00:00
|
|
|
|
|
|
|
namespace aria2 {
|
2007-03-26 12:16:57 +00:00
|
|
|
|
|
|
|
class NullOptionHandler : public OptionHandler {
|
2009-02-07 11:00:34 +00:00
|
|
|
private:
|
2010-06-21 13:51:56 +00:00
|
|
|
int id_;
|
2007-03-26 12:16:57 +00:00
|
|
|
public:
|
|
|
|
virtual ~NullOptionHandler() {}
|
|
|
|
|
2008-02-08 15:53:45 +00:00
|
|
|
virtual bool canHandle(const std::string& optName) { return true; }
|
2007-03-26 12:16:57 +00:00
|
|
|
|
2009-02-07 11:00:34 +00:00
|
|
|
virtual void parse(Option& option, const std::string& arg) {}
|
2008-09-22 09:26:57 +00:00
|
|
|
|
|
|
|
virtual bool hasTag(const std::string& tag) const { return false; }
|
|
|
|
|
|
|
|
virtual void addTag(const std::string& tag) {}
|
|
|
|
|
|
|
|
virtual std::string toTagString() const { return A2STR::NIL; }
|
|
|
|
|
|
|
|
virtual const std::string& getName() const { return A2STR::NIL; }
|
|
|
|
|
|
|
|
virtual const std::string& getDescription() const { return A2STR::NIL; }
|
|
|
|
|
|
|
|
virtual const std::string& getDefaultValue() const { return A2STR::NIL; }
|
|
|
|
|
|
|
|
virtual std::string createPossibleValuesString() const { return A2STR::NIL; }
|
|
|
|
|
|
|
|
virtual bool isHidden() const { return true; }
|
2009-02-07 11:00:34 +00:00
|
|
|
|
2009-03-08 08:19:50 +00:00
|
|
|
virtual void hide() {}
|
|
|
|
|
2009-02-07 11:00:34 +00:00
|
|
|
virtual OptionHandler::ARG_TYPE getArgType() const
|
|
|
|
{
|
|
|
|
return OptionHandler::NO_ARG;
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual int getOptionID() const
|
|
|
|
{
|
2010-06-21 13:51:56 +00:00
|
|
|
return id_;
|
2009-02-07 11:00:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
virtual void setOptionID(int id)
|
|
|
|
{
|
2010-06-21 13:51:56 +00:00
|
|
|
id_ = id;
|
2009-02-07 11:00:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
virtual char getShortName() const
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
2007-03-26 12:16:57 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class BooleanOptionHandler : public NameMatchOptionHandler {
|
|
|
|
public:
|
2008-09-22 09:26:57 +00:00
|
|
|
BooleanOptionHandler(const std::string& optName,
|
2010-01-05 16:01:46 +00:00
|
|
|
const std::string& description = NO_DESCRIPTION,
|
|
|
|
const std::string& defaultValue = NO_DEFAULT_VALUE,
|
|
|
|
OptionHandler::ARG_TYPE argType = OptionHandler::REQ_ARG,
|
|
|
|
char shortName = 0):
|
2009-02-07 11:00:34 +00:00
|
|
|
NameMatchOptionHandler(optName, description, defaultValue,
|
2010-01-05 16:01:46 +00:00
|
|
|
argType, shortName) {}
|
2008-09-22 09:26:57 +00:00
|
|
|
|
2007-03-26 12:16:57 +00:00
|
|
|
virtual ~BooleanOptionHandler() {}
|
|
|
|
|
2009-02-07 11:00:34 +00:00
|
|
|
virtual void parseArg(Option& option, const std::string& optarg)
|
2007-03-26 12:16:57 +00:00
|
|
|
{
|
2009-02-07 11:00:34 +00:00
|
|
|
if(optarg == "true" ||
|
2010-06-21 13:51:56 +00:00
|
|
|
((argType_ == OptionHandler::OPT_ARG ||
|
|
|
|
argType_ == OptionHandler::NO_ARG)
|
2010-01-05 16:01:46 +00:00
|
|
|
&& optarg.empty())) {
|
2010-09-11 12:48:03 +00:00
|
|
|
option.put(optName_, A2_V_TRUE);
|
2007-03-26 12:16:57 +00:00
|
|
|
} else if(optarg == "false") {
|
2010-09-11 12:48:03 +00:00
|
|
|
option.put(optName_, A2_V_FALSE);
|
2007-03-26 12:16:57 +00:00
|
|
|
} else {
|
2010-06-21 13:51:56 +00:00
|
|
|
std::string msg = optName_;
|
2009-06-06 12:33:07 +00:00
|
|
|
strappend(msg, " ", _("must be either 'true' or 'false'."));
|
2009-05-18 15:07:15 +00:00
|
|
|
throw DL_ABORT_EX(msg);
|
2007-03-26 12:16:57 +00:00
|
|
|
}
|
|
|
|
}
|
2008-09-22 09:26:57 +00:00
|
|
|
|
|
|
|
virtual std::string createPossibleValuesString() const
|
|
|
|
{
|
|
|
|
return "true,false";
|
|
|
|
}
|
2007-03-26 12:16:57 +00:00
|
|
|
};
|
|
|
|
|
2007-11-21 16:14:40 +00:00
|
|
|
class IntegerRangeOptionHandler : public NameMatchOptionHandler {
|
|
|
|
private:
|
2010-06-21 13:51:56 +00:00
|
|
|
int32_t min_;
|
|
|
|
int32_t max_;
|
2007-11-21 16:14:40 +00:00
|
|
|
public:
|
2008-09-22 09:26:57 +00:00
|
|
|
IntegerRangeOptionHandler(const std::string& optName,
|
2010-01-05 16:01:46 +00:00
|
|
|
const std::string& description,
|
|
|
|
const std::string& defaultValue,
|
|
|
|
int32_t min, int32_t max,
|
|
|
|
char shortName = 0):
|
2009-02-07 11:00:34 +00:00
|
|
|
NameMatchOptionHandler(optName, description, defaultValue,
|
2010-01-05 16:01:46 +00:00
|
|
|
OptionHandler::REQ_ARG, shortName),
|
2010-06-21 13:51:56 +00:00
|
|
|
min_(min), max_(max) {}
|
2007-11-21 16:14:40 +00:00
|
|
|
|
|
|
|
virtual ~IntegerRangeOptionHandler() {}
|
|
|
|
|
2009-02-07 11:00:34 +00:00
|
|
|
virtual void parseArg(Option& option, const std::string& optarg)
|
2007-11-21 16:14:40 +00:00
|
|
|
{
|
2009-10-22 15:09:00 +00:00
|
|
|
IntSequence seq = util::parseIntRange(optarg);
|
2007-11-21 16:14:40 +00:00
|
|
|
while(seq.hasNext()) {
|
|
|
|
int32_t v = seq.next();
|
2010-06-21 13:51:56 +00:00
|
|
|
if(v < min_ || max_ < v) {
|
|
|
|
std::string msg = optName_;
|
2010-01-05 16:01:46 +00:00
|
|
|
strappend(msg, " ", _("must be between %s and %s."));
|
|
|
|
throw DL_ABORT_EX
|
2010-06-21 13:51:56 +00:00
|
|
|
(StringFormat(msg.c_str(), util::itos(min_).c_str(),
|
|
|
|
util::itos(max_).c_str()).str());
|
2007-11-21 16:14:40 +00:00
|
|
|
}
|
2010-06-21 13:51:56 +00:00
|
|
|
option.put(optName_, optarg);
|
2007-11-21 16:14:40 +00:00
|
|
|
}
|
|
|
|
}
|
2008-09-22 09:26:57 +00:00
|
|
|
|
|
|
|
virtual std::string createPossibleValuesString() const
|
|
|
|
{
|
2010-06-21 13:51:56 +00:00
|
|
|
return util::itos(min_)+"-"+util::itos(max_);
|
2008-09-22 09:26:57 +00:00
|
|
|
}
|
2007-11-21 16:14:40 +00:00
|
|
|
};
|
|
|
|
|
2007-03-26 12:16:57 +00:00
|
|
|
class NumberOptionHandler : public NameMatchOptionHandler {
|
|
|
|
private:
|
2010-06-21 13:51:56 +00:00
|
|
|
int64_t min_;
|
|
|
|
int64_t max_;
|
2007-03-26 12:16:57 +00:00
|
|
|
public:
|
2008-09-22 09:26:57 +00:00
|
|
|
NumberOptionHandler(const std::string& optName,
|
2010-01-05 16:01:46 +00:00
|
|
|
const std::string& description = NO_DESCRIPTION,
|
|
|
|
const std::string& defaultValue = NO_DEFAULT_VALUE,
|
|
|
|
int64_t min = -1,
|
|
|
|
int64_t max = -1,
|
|
|
|
char shortName = 0):
|
2009-02-07 11:00:34 +00:00
|
|
|
NameMatchOptionHandler(optName, description, defaultValue,
|
2010-01-05 16:01:46 +00:00
|
|
|
OptionHandler::REQ_ARG, shortName),
|
2010-06-21 13:51:56 +00:00
|
|
|
min_(min), max_(max) {}
|
2007-03-26 12:16:57 +00:00
|
|
|
|
|
|
|
virtual ~NumberOptionHandler() {}
|
|
|
|
|
2009-02-07 11:00:34 +00:00
|
|
|
virtual void parseArg(Option& option, const std::string& optarg)
|
2007-03-26 12:16:57 +00:00
|
|
|
{
|
2009-10-22 15:09:00 +00:00
|
|
|
int64_t num = util::parseLLInt(optarg);
|
2007-03-26 12:16:57 +00:00
|
|
|
parseArg(option, num);
|
|
|
|
}
|
|
|
|
|
2009-02-07 11:00:34 +00:00
|
|
|
void parseArg(Option& option, int64_t number)
|
2007-03-26 12:16:57 +00:00
|
|
|
{
|
2010-06-21 13:51:56 +00:00
|
|
|
if((min_ == -1 || min_ <= number) && (max_ == -1 || number <= max_)) {
|
|
|
|
option.put(optName_, util::itos(number));
|
2007-03-26 12:16:57 +00:00
|
|
|
} else {
|
2010-06-21 13:51:56 +00:00
|
|
|
std::string msg = optName_;
|
2009-06-06 12:33:07 +00:00
|
|
|
msg += " ";
|
2010-06-21 13:51:56 +00:00
|
|
|
if(min_ == -1 && max_ != -1) {
|
2010-01-05 16:01:46 +00:00
|
|
|
msg += StringFormat(_("must be smaller than or equal to %s."),
|
2010-06-21 13:51:56 +00:00
|
|
|
util::itos(max_).c_str()).str();
|
|
|
|
} else if(min_ != -1 && max_ != -1) {
|
2010-01-05 16:01:46 +00:00
|
|
|
msg += StringFormat(_("must be between %s and %s."),
|
2010-06-21 13:51:56 +00:00
|
|
|
util::itos(min_).c_str(), util::itos(max_).c_str()).str();
|
|
|
|
} else if(min_ != -1 && max_ == -1) {
|
2010-01-05 16:01:46 +00:00
|
|
|
msg += StringFormat(_("must be greater than or equal to %s."),
|
2010-06-21 13:51:56 +00:00
|
|
|
util::itos(min_).c_str()).str();
|
2007-03-26 12:16:57 +00:00
|
|
|
} else {
|
2010-01-05 16:01:46 +00:00
|
|
|
msg += _("must be a number.");
|
2007-03-26 12:16:57 +00:00
|
|
|
}
|
2009-05-18 15:07:15 +00:00
|
|
|
throw DL_ABORT_EX(msg);
|
2007-03-26 12:16:57 +00:00
|
|
|
}
|
|
|
|
}
|
2008-09-22 09:26:57 +00:00
|
|
|
|
|
|
|
virtual std::string createPossibleValuesString() const
|
|
|
|
{
|
2009-06-06 12:33:07 +00:00
|
|
|
std::string values;
|
2010-06-21 13:51:56 +00:00
|
|
|
if(min_ == -1) {
|
2009-06-06 12:33:07 +00:00
|
|
|
values += "*";
|
|
|
|
} else {
|
2010-06-21 13:51:56 +00:00
|
|
|
values += util::itos(min_);
|
2009-06-06 12:33:07 +00:00
|
|
|
}
|
|
|
|
values += "-";
|
2010-06-21 13:51:56 +00:00
|
|
|
if(max_ == -1) {
|
2009-06-06 12:33:07 +00:00
|
|
|
values += "*";
|
|
|
|
} else {
|
2010-06-21 13:51:56 +00:00
|
|
|
values += util::itos(max_);
|
2009-06-06 12:33:07 +00:00
|
|
|
}
|
|
|
|
return values;
|
2008-09-22 09:26:57 +00:00
|
|
|
}
|
2007-03-26 12:16:57 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class UnitNumberOptionHandler : public NumberOptionHandler {
|
|
|
|
public:
|
2008-09-22 09:26:57 +00:00
|
|
|
UnitNumberOptionHandler(const std::string& optName,
|
2010-01-05 16:01:46 +00:00
|
|
|
const std::string& description = NO_DESCRIPTION,
|
|
|
|
const std::string& defaultValue = NO_DEFAULT_VALUE,
|
|
|
|
int64_t min = -1,
|
|
|
|
int64_t max = -1,
|
|
|
|
char shortName = 0):
|
2009-02-07 11:00:34 +00:00
|
|
|
NumberOptionHandler(optName, description, defaultValue, min, max,
|
2010-01-05 16:01:46 +00:00
|
|
|
shortName) {}
|
2007-03-26 12:16:57 +00:00
|
|
|
|
|
|
|
virtual ~UnitNumberOptionHandler() {}
|
|
|
|
|
2009-02-07 11:00:34 +00:00
|
|
|
virtual void parseArg(Option& option, const std::string& optarg)
|
2007-03-26 12:16:57 +00:00
|
|
|
{
|
2009-10-22 15:09:00 +00:00
|
|
|
int64_t num = util::getRealSize(optarg);
|
2007-03-26 12:16:57 +00:00
|
|
|
NumberOptionHandler::parseArg(option, num);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
class FloatNumberOptionHandler : public NameMatchOptionHandler {
|
|
|
|
private:
|
2010-06-21 13:51:56 +00:00
|
|
|
double min_;
|
|
|
|
double max_;
|
2007-03-26 12:16:57 +00:00
|
|
|
public:
|
2008-09-22 09:26:57 +00:00
|
|
|
FloatNumberOptionHandler(const std::string& optName,
|
2010-01-05 16:01:46 +00:00
|
|
|
const std::string& description = NO_DESCRIPTION,
|
|
|
|
const std::string& defaultValue = NO_DEFAULT_VALUE,
|
|
|
|
double min = -1, double max = -1,
|
|
|
|
char shortName = 0):
|
2009-02-07 11:00:34 +00:00
|
|
|
NameMatchOptionHandler(optName, description, defaultValue,
|
2010-01-05 16:01:46 +00:00
|
|
|
OptionHandler::REQ_ARG, shortName),
|
2010-06-21 13:51:56 +00:00
|
|
|
min_(min), max_(max) {}
|
2007-03-26 12:16:57 +00:00
|
|
|
|
|
|
|
virtual ~FloatNumberOptionHandler() {}
|
|
|
|
|
2009-02-07 11:00:34 +00:00
|
|
|
virtual void parseArg(Option& option, const std::string& optarg)
|
2007-03-26 12:16:57 +00:00
|
|
|
{
|
|
|
|
double number = strtod(optarg.c_str(), 0);
|
2010-06-21 13:51:56 +00:00
|
|
|
if((min_ < 0 || min_ <= number) && (max_ < 0 || number <= max_)) {
|
|
|
|
option.put(optName_, optarg);
|
2007-03-26 12:16:57 +00:00
|
|
|
} else {
|
2010-06-21 13:51:56 +00:00
|
|
|
std::string msg = optName_;
|
2009-06-06 12:33:07 +00:00
|
|
|
msg += " ";
|
2010-06-21 13:51:56 +00:00
|
|
|
if(min_ < 0 && max_ >= 0) {
|
2010-01-05 16:01:46 +00:00
|
|
|
msg += StringFormat(_("must be smaller than or equal to %.1f."),
|
2010-06-21 13:51:56 +00:00
|
|
|
max_).str();
|
|
|
|
} else if(min_ >= 0 && max_ >= 0) {
|
2010-01-05 16:01:46 +00:00
|
|
|
msg += StringFormat(_("must be between %.1f and %.1f."),
|
2010-06-21 13:51:56 +00:00
|
|
|
min_, max_).str();
|
|
|
|
} else if(min_ >= 0 && max_ < 0) {
|
2010-01-05 16:01:46 +00:00
|
|
|
msg += StringFormat(_("must be greater than or equal to %.1f."),
|
2010-06-21 13:51:56 +00:00
|
|
|
min_).str();
|
2007-03-26 12:16:57 +00:00
|
|
|
} else {
|
2010-01-05 16:01:46 +00:00
|
|
|
msg += _("must be a number.");
|
2007-03-26 12:16:57 +00:00
|
|
|
}
|
2009-05-18 15:07:15 +00:00
|
|
|
throw DL_ABORT_EX(msg);
|
2007-03-26 12:16:57 +00:00
|
|
|
}
|
|
|
|
}
|
2008-09-22 09:26:57 +00:00
|
|
|
|
|
|
|
virtual std::string createPossibleValuesString() const
|
|
|
|
{
|
|
|
|
std::string valuesString;
|
2010-06-21 13:51:56 +00:00
|
|
|
if(min_ < 0) {
|
2008-09-22 09:26:57 +00:00
|
|
|
valuesString += "*";
|
|
|
|
} else {
|
|
|
|
char buf[11];
|
2010-06-21 13:51:56 +00:00
|
|
|
snprintf(buf, sizeof(buf), "%.1f", min_);
|
2008-09-22 09:26:57 +00:00
|
|
|
valuesString += buf;
|
|
|
|
}
|
|
|
|
valuesString += "-";
|
2010-06-21 13:51:56 +00:00
|
|
|
if(max_ < 0) {
|
2008-09-22 09:26:57 +00:00
|
|
|
valuesString += "*";
|
|
|
|
} else {
|
|
|
|
char buf[11];
|
2010-06-21 13:51:56 +00:00
|
|
|
snprintf(buf, sizeof(buf), "%.1f", max_);
|
2008-09-22 09:26:57 +00:00
|
|
|
valuesString += buf;
|
|
|
|
}
|
|
|
|
return valuesString;
|
|
|
|
}
|
2007-03-26 12:16:57 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class DefaultOptionHandler : public NameMatchOptionHandler {
|
2008-09-22 09:26:57 +00:00
|
|
|
private:
|
2010-06-21 13:51:56 +00:00
|
|
|
std::string possibleValuesString_;
|
2007-03-26 12:16:57 +00:00
|
|
|
public:
|
2008-09-22 09:26:57 +00:00
|
|
|
DefaultOptionHandler(const std::string& optName,
|
2010-01-05 16:01:46 +00:00
|
|
|
const std::string& description = NO_DESCRIPTION,
|
|
|
|
const std::string& defaultValue = NO_DEFAULT_VALUE,
|
|
|
|
const std::string& possibleValuesString = A2STR::NIL,
|
|
|
|
OptionHandler::ARG_TYPE argType = OptionHandler::REQ_ARG,
|
|
|
|
char shortName = 0):
|
2009-02-07 11:00:34 +00:00
|
|
|
NameMatchOptionHandler(optName, description, defaultValue, argType,
|
2010-01-05 16:01:46 +00:00
|
|
|
shortName),
|
2010-06-21 13:51:56 +00:00
|
|
|
possibleValuesString_(possibleValuesString) {}
|
2007-03-26 12:16:57 +00:00
|
|
|
|
|
|
|
virtual ~DefaultOptionHandler() {}
|
|
|
|
|
2009-02-07 11:00:34 +00:00
|
|
|
virtual void parseArg(Option& option, const std::string& optarg)
|
2007-03-26 12:16:57 +00:00
|
|
|
{
|
2010-06-21 13:51:56 +00:00
|
|
|
option.put(optName_, optarg);
|
2007-03-26 12:16:57 +00:00
|
|
|
}
|
2008-09-22 09:26:57 +00:00
|
|
|
|
|
|
|
virtual std::string createPossibleValuesString() const
|
|
|
|
{
|
2010-06-21 13:51:56 +00:00
|
|
|
return possibleValuesString_;
|
2008-09-22 09:26:57 +00:00
|
|
|
}
|
2007-03-26 12:16:57 +00:00
|
|
|
};
|
|
|
|
|
2008-04-20 06:30:44 +00:00
|
|
|
class CumulativeOptionHandler : public NameMatchOptionHandler {
|
|
|
|
private:
|
2010-06-21 13:51:56 +00:00
|
|
|
std::string delim_;
|
2008-09-22 09:26:57 +00:00
|
|
|
|
2010-06-21 13:51:56 +00:00
|
|
|
std::string possibleValuesString_;
|
2008-04-20 06:30:44 +00:00
|
|
|
public:
|
|
|
|
CumulativeOptionHandler(const std::string& optName,
|
2010-01-05 16:01:46 +00:00
|
|
|
const std::string& description,
|
|
|
|
const std::string& defaultValue,
|
|
|
|
const std::string& delim,
|
|
|
|
const std::string& possibleValuesString = A2STR::NIL,
|
|
|
|
OptionHandler::ARG_TYPE argType =
|
|
|
|
OptionHandler::REQ_ARG,
|
|
|
|
char shortName = 0):
|
2009-02-07 11:00:34 +00:00
|
|
|
NameMatchOptionHandler(optName, description, defaultValue, argType,
|
2010-01-05 16:01:46 +00:00
|
|
|
shortName),
|
2010-06-21 13:51:56 +00:00
|
|
|
delim_(delim),
|
|
|
|
possibleValuesString_(possibleValuesString) {}
|
2008-04-20 06:30:44 +00:00
|
|
|
|
|
|
|
virtual ~CumulativeOptionHandler() {}
|
|
|
|
|
2009-02-07 11:00:34 +00:00
|
|
|
virtual void parseArg(Option& option, const std::string& optarg)
|
2008-04-20 06:30:44 +00:00
|
|
|
{
|
2010-06-21 13:51:56 +00:00
|
|
|
std::string value = option.get(optName_);
|
|
|
|
strappend(value, optarg, delim_);
|
|
|
|
option.put(optName_, value);
|
2008-04-20 06:30:44 +00:00
|
|
|
}
|
2008-09-22 09:26:57 +00:00
|
|
|
|
|
|
|
virtual std::string createPossibleValuesString() const
|
|
|
|
{
|
2010-06-21 13:51:56 +00:00
|
|
|
return possibleValuesString_;
|
2008-09-22 09:26:57 +00:00
|
|
|
}
|
2008-04-20 06:30:44 +00:00
|
|
|
};
|
|
|
|
|
2009-03-07 03:10:53 +00:00
|
|
|
class IndexOutOptionHandler : public NameMatchOptionHandler {
|
|
|
|
private:
|
|
|
|
public:
|
|
|
|
IndexOutOptionHandler(const std::string& optName,
|
2010-01-05 16:01:46 +00:00
|
|
|
const std::string& description,
|
|
|
|
char shortName = 0):
|
2009-03-07 03:10:53 +00:00
|
|
|
NameMatchOptionHandler(optName, description, NO_DEFAULT_VALUE,
|
2010-01-05 16:01:46 +00:00
|
|
|
OptionHandler::REQ_ARG, shortName) {}
|
2009-03-07 03:10:53 +00:00
|
|
|
|
|
|
|
virtual ~IndexOutOptionHandler() {}
|
|
|
|
|
|
|
|
virtual void parseArg(Option& option, const std::string& optarg)
|
|
|
|
{
|
|
|
|
// See optarg is in the fomrat of "INDEX=PATH"
|
2009-10-22 15:09:00 +00:00
|
|
|
util::parseIndexPath(optarg);
|
2010-06-21 13:51:56 +00:00
|
|
|
std::string value = option.get(optName_);
|
2009-06-06 12:33:07 +00:00
|
|
|
strappend(value, optarg, "\n");
|
2010-06-21 13:51:56 +00:00
|
|
|
option.put(optName_, value);
|
2009-03-07 03:10:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
virtual std::string createPossibleValuesString() const
|
|
|
|
{
|
|
|
|
return "INDEX=PATH";
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2007-03-26 12:16:57 +00:00
|
|
|
class ParameterOptionHandler : public NameMatchOptionHandler {
|
|
|
|
private:
|
2010-06-21 13:51:56 +00:00
|
|
|
std::vector<std::string> validParamValues_;
|
2007-03-26 12:16:57 +00:00
|
|
|
public:
|
2008-09-22 09:26:57 +00:00
|
|
|
ParameterOptionHandler(const std::string& optName,
|
2010-01-05 16:01:46 +00:00
|
|
|
const std::string& description,
|
|
|
|
const std::string& defaultValue,
|
2010-02-28 12:30:11 +00:00
|
|
|
const std::vector<std::string>& validParamValues,
|
2010-01-05 16:01:46 +00:00
|
|
|
char shortName = 0):
|
2009-02-07 11:00:34 +00:00
|
|
|
NameMatchOptionHandler(optName, description, defaultValue,
|
2010-01-05 16:01:46 +00:00
|
|
|
OptionHandler::REQ_ARG, shortName),
|
2010-06-21 13:51:56 +00:00
|
|
|
validParamValues_(validParamValues) {}
|
2007-03-26 12:16:57 +00:00
|
|
|
|
2008-09-22 09:26:57 +00:00
|
|
|
ParameterOptionHandler(const std::string& optName,
|
2010-01-05 16:01:46 +00:00
|
|
|
const std::string& description,
|
|
|
|
const std::string& defaultValue,
|
|
|
|
const std::string& validParamValue,
|
|
|
|
char shortName = 0):
|
2009-02-07 11:00:34 +00:00
|
|
|
NameMatchOptionHandler(optName, description, defaultValue,
|
2010-01-05 16:01:46 +00:00
|
|
|
OptionHandler::REQ_ARG, shortName)
|
2007-03-26 12:16:57 +00:00
|
|
|
{
|
2010-06-21 13:51:56 +00:00
|
|
|
validParamValues_.push_back(validParamValue);
|
2007-03-26 12:16:57 +00:00
|
|
|
}
|
|
|
|
|
2008-02-08 15:53:45 +00:00
|
|
|
ParameterOptionHandler(const std::string& optName,
|
2010-01-05 16:01:46 +00:00
|
|
|
const std::string& description,
|
|
|
|
const std::string& defaultValue,
|
|
|
|
const std::string& validParamValue1,
|
|
|
|
const std::string& validParamValue2,
|
|
|
|
char shortName = 0):
|
2009-02-07 11:00:34 +00:00
|
|
|
NameMatchOptionHandler(optName, description, defaultValue,
|
2010-01-05 16:01:46 +00:00
|
|
|
OptionHandler::REQ_ARG, shortName)
|
2007-03-26 12:16:57 +00:00
|
|
|
{
|
2010-06-21 13:51:56 +00:00
|
|
|
validParamValues_.push_back(validParamValue1);
|
|
|
|
validParamValues_.push_back(validParamValue2);
|
2007-03-26 12:16:57 +00:00
|
|
|
}
|
2007-11-27 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
Rewritten to add content-type support.
* src/DownloadHandler.{h, cc}
* src/BtPostDownloadHandler.{h, cc}
* test/BtPostDownloadHandlerTest.cc
* src/MetalinkPostDownloadHandler.{h, cc}
* test/MetalinkPostDownloadHandlerTest.cc
* src/PostDownloadHandler.{h, cc}
* src/DownloadHandlerConstants.{h, cc}
* src/RequestGroup.cc
* src/HttpResponseCommand.cc
* src/FtpNegotiationCommand.cc
* src/SingleFileDownloadContext.{h, cc}
* src/RequestGroup.h
* src/RequestGroupCriteria.h
* src/ContentTypeRequestGroupCriteria.h
Added 'mem' option value for --follow-metalink,
--follow-torrent.
If it is give, metalink/torrent file is not written to the disk,
but
just is kept in memory. Parsing is occurred on memory.
* src/MetalinkHelper.{h, cc}
* src/MetalinkProcessor.h
* src/Xml2MetalinkProcessor.{h, cc}
* test/Xml2MetalinkProcessorTest.cc
* src/DownloadHandlerFactory.{h, cc}
* test/DownloadHandlerFactoryTest.cc
* src/PreDownloadHandler.{h, cc}
* src/OptionHandlerFactory.cc
* src/DefaultBtContext.{h, cc}
* test/DefaultBtContextTest.cc
* src/version_usage.cc
* src/Metalink2RequestGroup.{h, cc}
* src/RequestGroup.{h, cc}
* src/a2functional.h
* test/a2functionalTest.cc
* src/MemoryBufferPreDownloadHandler.{h, cc}
* src/OptionHandlerImpl.h
* src/prefs.h
* src/Util.{h, cc}
* test/UtilTest.cc
Keep DownloadResult rather than RequestGroup after downloads to
reduce
memory usage.
* src/RequestGroupMan.{h, cc}
* src/DownloadEngine.cc
* src/BtDependency.{h, cc}: Changed the type of dependee from
WeakHandle to SharedHandle because WeakHandle could be null.
* src/RequestGroup.{h, cc}
* src/DownloadEngineFactory.cc
* src/DownloadResult.h
Set totalLength after download finished
* src/UnknownLengthPieceStorage.{h, cc}
Keep torrent file specified in metalink in memory.
* src/Metalink2RequestGroup.cc
* src/BtDependency.cc
* src/TrueRequestGroupCriteria.h
Fixed the bug: seekg is used where seekp should be used.
* src/ByteArrayDiskWriter.cc
* test/ByteArraydiskWriterTest.cc
2007-11-27 12:27:10 +00:00
|
|
|
|
2008-02-08 15:53:45 +00:00
|
|
|
ParameterOptionHandler(const std::string& optName,
|
2010-01-05 16:01:46 +00:00
|
|
|
const std::string& description,
|
|
|
|
const std::string& defaultValue,
|
|
|
|
const std::string& validParamValue1,
|
|
|
|
const std::string& validParamValue2,
|
|
|
|
const std::string& validParamValue3,
|
|
|
|
char shortName = 0):
|
2009-02-07 11:00:34 +00:00
|
|
|
NameMatchOptionHandler(optName, description, defaultValue,
|
2010-01-05 16:01:46 +00:00
|
|
|
OptionHandler::REQ_ARG, shortName)
|
2007-11-27 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
Rewritten to add content-type support.
* src/DownloadHandler.{h, cc}
* src/BtPostDownloadHandler.{h, cc}
* test/BtPostDownloadHandlerTest.cc
* src/MetalinkPostDownloadHandler.{h, cc}
* test/MetalinkPostDownloadHandlerTest.cc
* src/PostDownloadHandler.{h, cc}
* src/DownloadHandlerConstants.{h, cc}
* src/RequestGroup.cc
* src/HttpResponseCommand.cc
* src/FtpNegotiationCommand.cc
* src/SingleFileDownloadContext.{h, cc}
* src/RequestGroup.h
* src/RequestGroupCriteria.h
* src/ContentTypeRequestGroupCriteria.h
Added 'mem' option value for --follow-metalink,
--follow-torrent.
If it is give, metalink/torrent file is not written to the disk,
but
just is kept in memory. Parsing is occurred on memory.
* src/MetalinkHelper.{h, cc}
* src/MetalinkProcessor.h
* src/Xml2MetalinkProcessor.{h, cc}
* test/Xml2MetalinkProcessorTest.cc
* src/DownloadHandlerFactory.{h, cc}
* test/DownloadHandlerFactoryTest.cc
* src/PreDownloadHandler.{h, cc}
* src/OptionHandlerFactory.cc
* src/DefaultBtContext.{h, cc}
* test/DefaultBtContextTest.cc
* src/version_usage.cc
* src/Metalink2RequestGroup.{h, cc}
* src/RequestGroup.{h, cc}
* src/a2functional.h
* test/a2functionalTest.cc
* src/MemoryBufferPreDownloadHandler.{h, cc}
* src/OptionHandlerImpl.h
* src/prefs.h
* src/Util.{h, cc}
* test/UtilTest.cc
Keep DownloadResult rather than RequestGroup after downloads to
reduce
memory usage.
* src/RequestGroupMan.{h, cc}
* src/DownloadEngine.cc
* src/BtDependency.{h, cc}: Changed the type of dependee from
WeakHandle to SharedHandle because WeakHandle could be null.
* src/RequestGroup.{h, cc}
* src/DownloadEngineFactory.cc
* src/DownloadResult.h
Set totalLength after download finished
* src/UnknownLengthPieceStorage.{h, cc}
Keep torrent file specified in metalink in memory.
* src/Metalink2RequestGroup.cc
* src/BtDependency.cc
* src/TrueRequestGroupCriteria.h
Fixed the bug: seekg is used where seekp should be used.
* src/ByteArrayDiskWriter.cc
* test/ByteArraydiskWriterTest.cc
2007-11-27 12:27:10 +00:00
|
|
|
{
|
2010-06-21 13:51:56 +00:00
|
|
|
validParamValues_.push_back(validParamValue1);
|
|
|
|
validParamValues_.push_back(validParamValue2);
|
|
|
|
validParamValues_.push_back(validParamValue3);
|
2007-11-27 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
Rewritten to add content-type support.
* src/DownloadHandler.{h, cc}
* src/BtPostDownloadHandler.{h, cc}
* test/BtPostDownloadHandlerTest.cc
* src/MetalinkPostDownloadHandler.{h, cc}
* test/MetalinkPostDownloadHandlerTest.cc
* src/PostDownloadHandler.{h, cc}
* src/DownloadHandlerConstants.{h, cc}
* src/RequestGroup.cc
* src/HttpResponseCommand.cc
* src/FtpNegotiationCommand.cc
* src/SingleFileDownloadContext.{h, cc}
* src/RequestGroup.h
* src/RequestGroupCriteria.h
* src/ContentTypeRequestGroupCriteria.h
Added 'mem' option value for --follow-metalink,
--follow-torrent.
If it is give, metalink/torrent file is not written to the disk,
but
just is kept in memory. Parsing is occurred on memory.
* src/MetalinkHelper.{h, cc}
* src/MetalinkProcessor.h
* src/Xml2MetalinkProcessor.{h, cc}
* test/Xml2MetalinkProcessorTest.cc
* src/DownloadHandlerFactory.{h, cc}
* test/DownloadHandlerFactoryTest.cc
* src/PreDownloadHandler.{h, cc}
* src/OptionHandlerFactory.cc
* src/DefaultBtContext.{h, cc}
* test/DefaultBtContextTest.cc
* src/version_usage.cc
* src/Metalink2RequestGroup.{h, cc}
* src/RequestGroup.{h, cc}
* src/a2functional.h
* test/a2functionalTest.cc
* src/MemoryBufferPreDownloadHandler.{h, cc}
* src/OptionHandlerImpl.h
* src/prefs.h
* src/Util.{h, cc}
* test/UtilTest.cc
Keep DownloadResult rather than RequestGroup after downloads to
reduce
memory usage.
* src/RequestGroupMan.{h, cc}
* src/DownloadEngine.cc
* src/BtDependency.{h, cc}: Changed the type of dependee from
WeakHandle to SharedHandle because WeakHandle could be null.
* src/RequestGroup.{h, cc}
* src/DownloadEngineFactory.cc
* src/DownloadResult.h
Set totalLength after download finished
* src/UnknownLengthPieceStorage.{h, cc}
Keep torrent file specified in metalink in memory.
* src/Metalink2RequestGroup.cc
* src/BtDependency.cc
* src/TrueRequestGroupCriteria.h
Fixed the bug: seekg is used where seekp should be used.
* src/ByteArrayDiskWriter.cc
* test/ByteArraydiskWriterTest.cc
2007-11-27 12:27:10 +00:00
|
|
|
}
|
2007-03-26 12:16:57 +00:00
|
|
|
|
|
|
|
virtual ~ParameterOptionHandler() {}
|
|
|
|
|
2009-02-07 11:00:34 +00:00
|
|
|
virtual void parseArg(Option& option, const std::string& optarg)
|
2007-03-26 12:16:57 +00:00
|
|
|
{
|
2010-02-28 12:30:11 +00:00
|
|
|
std::vector<std::string>::const_iterator itr =
|
2010-06-21 13:51:56 +00:00
|
|
|
std::find(validParamValues_.begin(), validParamValues_.end(), optarg);
|
|
|
|
if(itr == validParamValues_.end()) {
|
|
|
|
std::string msg = optName_;
|
2009-06-06 12:33:07 +00:00
|
|
|
strappend(msg, " ", _("must be one of the following:"));
|
2010-06-21 13:51:56 +00:00
|
|
|
if(validParamValues_.size() == 0) {
|
2010-01-05 16:01:46 +00:00
|
|
|
msg += "''";
|
2007-03-26 12:16:57 +00:00
|
|
|
} else {
|
2010-02-28 12:30:11 +00:00
|
|
|
for(std::vector<std::string>::const_iterator itr =
|
2010-06-21 13:51:56 +00:00
|
|
|
validParamValues_.begin(), eoi = validParamValues_.end();
|
2010-02-28 16:04:52 +00:00
|
|
|
itr != eoi; ++itr) {
|
2010-01-05 16:01:46 +00:00
|
|
|
strappend(msg, "'", *itr, "' ");
|
|
|
|
}
|
2007-03-26 12:16:57 +00:00
|
|
|
}
|
2009-05-18 15:07:15 +00:00
|
|
|
throw DL_ABORT_EX(msg);
|
2007-03-26 12:16:57 +00:00
|
|
|
} else {
|
2010-06-21 13:51:56 +00:00
|
|
|
option.put(optName_, optarg);
|
2007-03-26 12:16:57 +00:00
|
|
|
}
|
|
|
|
}
|
2008-09-22 09:26:57 +00:00
|
|
|
|
|
|
|
virtual std::string createPossibleValuesString() const
|
|
|
|
{
|
|
|
|
std::stringstream s;
|
2010-06-21 13:51:56 +00:00
|
|
|
std::copy(validParamValues_.begin(), validParamValues_.end(),
|
2010-01-05 16:01:46 +00:00
|
|
|
std::ostream_iterator<std::string>(s, ","));
|
2010-10-09 16:49:02 +00:00
|
|
|
return util::strip(s.str(), ", ");
|
2008-09-22 09:26:57 +00:00
|
|
|
}
|
2007-03-26 12:16:57 +00:00
|
|
|
};
|
|
|
|
|
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
|
|
|
class HostPortOptionHandler : public NameMatchOptionHandler {
|
|
|
|
private:
|
2010-06-21 13:51:56 +00:00
|
|
|
std::string hostOptionName_;
|
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
|
|
|
|
2010-06-21 13:51:56 +00:00
|
|
|
std::string portOptionName_;
|
2007-03-26 12:16:57 +00:00
|
|
|
public:
|
2008-02-08 15:53:45 +00:00
|
|
|
HostPortOptionHandler(const std::string& optName,
|
2010-01-05 16:01:46 +00:00
|
|
|
const std::string& description,
|
|
|
|
const std::string& defaultValue,
|
|
|
|
const std::string& hostOptionName,
|
|
|
|
const std::string& portOptionName,
|
|
|
|
char shortName = 0):
|
2009-02-07 11:00:34 +00:00
|
|
|
NameMatchOptionHandler(optName, description, defaultValue,
|
2010-01-05 16:01:46 +00:00
|
|
|
OptionHandler::REQ_ARG, shortName),
|
2010-06-21 13:51:56 +00:00
|
|
|
hostOptionName_(hostOptionName),
|
|
|
|
portOptionName_(portOptionName) {}
|
2007-03-26 12:16:57 +00:00
|
|
|
|
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
|
|
|
virtual ~HostPortOptionHandler() {}
|
2007-03-26 12:16:57 +00:00
|
|
|
|
2009-02-07 11:00:34 +00:00
|
|
|
virtual void parseArg(Option& option, const std::string& optarg)
|
2007-03-26 12:16:57 +00:00
|
|
|
{
|
2010-08-07 14:15:21 +00:00
|
|
|
std::string uri = "http://";
|
|
|
|
uri += optarg;
|
|
|
|
Request req;
|
|
|
|
if(!req.setUri(uri)) {
|
|
|
|
throw DL_ABORT_EX(_("Unrecognized format"));
|
2007-03-26 12:16:57 +00:00
|
|
|
}
|
2010-06-21 13:51:56 +00:00
|
|
|
option.put(optName_, optarg);
|
2010-08-07 14:15:21 +00:00
|
|
|
setHostAndPort(option, req.getHost(), req.getPort());
|
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
|
|
|
}
|
|
|
|
|
2010-08-07 14:15:21 +00:00
|
|
|
void setHostAndPort
|
|
|
|
(Option& option, const std::string& hostname, uint16_t port)
|
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
|
|
|
{
|
2010-06-21 13:51:56 +00:00
|
|
|
option.put(hostOptionName_, hostname);
|
|
|
|
option.put(portOptionName_, util::uitos(port));
|
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
|
|
|
}
|
2008-09-22 09:26:57 +00:00
|
|
|
|
|
|
|
virtual std::string createPossibleValuesString() const
|
|
|
|
{
|
|
|
|
return "HOST:PORT";
|
|
|
|
}
|
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
|
|
|
};
|
|
|
|
|
2010-03-11 15:09:34 +00:00
|
|
|
class HttpProxyUserOptionHandler:public NameMatchOptionHandler {
|
|
|
|
public:
|
|
|
|
HttpProxyUserOptionHandler(const std::string& optName,
|
|
|
|
const std::string& description,
|
|
|
|
const std::string& defaultValue,
|
|
|
|
char shortName = 0):
|
|
|
|
NameMatchOptionHandler(optName, description, defaultValue,
|
|
|
|
OptionHandler::REQ_ARG, shortName)
|
|
|
|
{}
|
|
|
|
|
|
|
|
virtual void parseArg(Option& option, const std::string& optarg)
|
|
|
|
{
|
2010-06-21 13:51:56 +00:00
|
|
|
if(util::endsWith(optName_, "-user")) {
|
|
|
|
const std::string proxyPref = optName_.substr(0, optName_.size()-5);
|
2010-03-11 15:09:34 +00:00
|
|
|
const std::string& olduri = option.get(proxyPref);
|
|
|
|
if(!olduri.empty()) {
|
|
|
|
Request req;
|
|
|
|
bool b = req.setUri(olduri);
|
|
|
|
assert(b);
|
|
|
|
std::string uri = "http://";
|
|
|
|
if(!optarg.empty()) {
|
|
|
|
uri += util::percentEncode(optarg);
|
|
|
|
}
|
|
|
|
if(req.hasPassword()) {
|
|
|
|
uri += A2STR::COLON_C;
|
|
|
|
uri += util::percentEncode(req.getPassword());
|
|
|
|
}
|
|
|
|
if(uri.size() > 7) {
|
|
|
|
uri += "@";
|
|
|
|
}
|
|
|
|
strappend(uri, req.getHost(),A2STR::COLON_C,util::uitos(req.getPort()));
|
|
|
|
option.put(proxyPref, uri);
|
|
|
|
}
|
|
|
|
}
|
2010-06-21 13:51:56 +00:00
|
|
|
option.put(optName_, optarg);
|
2010-03-11 15:09:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
virtual std::string createPossibleValuesString() const
|
|
|
|
{
|
|
|
|
return "";
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
class HttpProxyPasswdOptionHandler:public NameMatchOptionHandler {
|
|
|
|
public:
|
|
|
|
HttpProxyPasswdOptionHandler(const std::string& optName,
|
|
|
|
const std::string& description,
|
|
|
|
const std::string& defaultValue,
|
|
|
|
char shortName = 0):
|
|
|
|
NameMatchOptionHandler(optName, description, defaultValue,
|
|
|
|
OptionHandler::REQ_ARG, shortName)
|
|
|
|
{}
|
|
|
|
|
|
|
|
virtual void parseArg(Option& option, const std::string& optarg)
|
|
|
|
{
|
2010-06-21 13:51:56 +00:00
|
|
|
if(util::endsWith(optName_, "-passwd")) {
|
|
|
|
const std::string proxyPref = optName_.substr(0, optName_.size()-7);
|
2010-03-11 15:09:34 +00:00
|
|
|
const std::string& olduri = option.get(proxyPref);
|
|
|
|
if(!olduri.empty()) {
|
|
|
|
Request req;
|
|
|
|
bool b = req.setUri(olduri);
|
|
|
|
assert(b);
|
|
|
|
std::string uri = "http://";
|
|
|
|
if(!req.getUsername().empty()) {
|
|
|
|
uri += util::percentEncode(req.getUsername());
|
|
|
|
}
|
|
|
|
uri += A2STR::COLON_C;
|
|
|
|
if(!optarg.empty()) {
|
|
|
|
uri += util::percentEncode(optarg);
|
|
|
|
}
|
|
|
|
if(uri.size() > 7) {
|
|
|
|
uri += "@";
|
|
|
|
}
|
|
|
|
strappend(uri, req.getHost(), A2STR::COLON_C,util::itos(req.getPort()));
|
|
|
|
option.put(proxyPref, uri);
|
|
|
|
}
|
|
|
|
}
|
2010-06-21 13:51:56 +00:00
|
|
|
option.put(optName_, optarg);
|
2010-03-11 15:09:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
virtual std::string createPossibleValuesString() const
|
|
|
|
{
|
|
|
|
return "";
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2008-11-04 14:08:26 +00:00
|
|
|
class HttpProxyOptionHandler : public NameMatchOptionHandler {
|
2010-03-11 15:09:34 +00:00
|
|
|
private:
|
2010-06-21 13:51:56 +00:00
|
|
|
std::string proxyUserPref_;
|
|
|
|
std::string proxyPasswdPref_;
|
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
|
|
|
public:
|
2008-02-08 15:53:45 +00:00
|
|
|
HttpProxyOptionHandler(const std::string& optName,
|
2010-01-05 16:01:46 +00:00
|
|
|
const std::string& description,
|
|
|
|
const std::string& defaultValue,
|
|
|
|
char shortName = 0)
|
2008-11-04 14:08:26 +00:00
|
|
|
:
|
2009-02-07 11:00:34 +00:00
|
|
|
NameMatchOptionHandler(optName, description, defaultValue,
|
2010-03-11 15:09:34 +00:00
|
|
|
OptionHandler::REQ_ARG, shortName),
|
2010-06-21 13:51:56 +00:00
|
|
|
proxyUserPref_(optName_+"-user"),
|
|
|
|
proxyPasswdPref_(optName_+"-passwd")
|
2008-09-22 09:26:57 +00:00
|
|
|
{}
|
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
|
|
|
|
|
|
|
virtual ~HttpProxyOptionHandler() {}
|
|
|
|
|
2009-02-07 11:00:34 +00:00
|
|
|
virtual void parseArg(Option& option, const std::string& optarg)
|
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
|
|
|
{
|
2010-01-15 09:04:47 +00:00
|
|
|
if(optarg.empty()) {
|
2010-06-21 13:51:56 +00:00
|
|
|
option.put(optName_, optarg);
|
2008-11-04 14:08:26 +00:00
|
|
|
} else {
|
2010-01-15 09:04:47 +00:00
|
|
|
Request req;
|
2010-03-07 10:36:42 +00:00
|
|
|
std::string uri;
|
2010-01-15 09:04:47 +00:00
|
|
|
if(util::startsWith(optarg, "http://")) {
|
2010-03-07 10:36:42 +00:00
|
|
|
uri = optarg;
|
2010-01-15 09:04:47 +00:00
|
|
|
} else {
|
2010-03-07 10:36:42 +00:00
|
|
|
uri = "http://"+optarg;
|
2010-01-15 09:04:47 +00:00
|
|
|
}
|
2010-03-11 15:09:34 +00:00
|
|
|
if(!req.setUri(uri)) {
|
2010-01-15 09:04:47 +00:00
|
|
|
throw DL_ABORT_EX(_("unrecognized proxy format"));
|
|
|
|
}
|
2010-03-11 15:09:34 +00:00
|
|
|
uri = "http://";
|
|
|
|
if(req.getUsername().empty()) {
|
2010-06-21 13:51:56 +00:00
|
|
|
if(option.defined(proxyUserPref_)) {
|
|
|
|
uri += util::percentEncode(option.get(proxyUserPref_));
|
2010-03-11 15:09:34 +00:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
uri += util::percentEncode(req.getUsername());
|
|
|
|
}
|
|
|
|
if(!req.hasPassword()) {
|
2010-06-21 13:51:56 +00:00
|
|
|
if(option.defined(proxyPasswdPref_)) {
|
2010-03-11 15:09:34 +00:00
|
|
|
uri += A2STR::COLON_C;
|
2010-06-21 13:51:56 +00:00
|
|
|
uri += util::percentEncode(option.get(proxyPasswdPref_));
|
2010-03-11 15:09:34 +00:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
uri += A2STR::COLON_C;
|
|
|
|
uri += util::percentEncode(req.getPassword());
|
|
|
|
}
|
|
|
|
if(uri.size() > 7) {
|
|
|
|
uri += "@";
|
|
|
|
}
|
|
|
|
strappend(uri, req.getHost(), A2STR::COLON_C, util::uitos(req.getPort()));
|
2010-06-21 13:51:56 +00:00
|
|
|
option.put(optName_, uri);
|
2008-11-04 14:08:26 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual std::string createPossibleValuesString() const
|
|
|
|
{
|
|
|
|
return "[http://][USER:PASSWORD@]HOST[:PORT]";
|
2007-03-26 12:16:57 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2009-09-09 12:50:42 +00:00
|
|
|
class LocalFilePathOptionHandler : public NameMatchOptionHandler {
|
2009-12-09 14:32:12 +00:00
|
|
|
private:
|
2010-06-21 13:51:56 +00:00
|
|
|
bool acceptStdin_;
|
2009-09-09 12:50:42 +00:00
|
|
|
public:
|
|
|
|
LocalFilePathOptionHandler
|
|
|
|
(const std::string& optName,
|
|
|
|
const std::string& description = NO_DESCRIPTION,
|
|
|
|
const std::string& defaultValue = NO_DEFAULT_VALUE,
|
2009-12-09 14:32:12 +00:00
|
|
|
bool acceptStdin = false,
|
2009-09-09 12:50:42 +00:00
|
|
|
char shortName = 0):
|
|
|
|
NameMatchOptionHandler(optName, description, defaultValue,
|
2010-01-05 16:01:46 +00:00
|
|
|
OptionHandler::REQ_ARG,
|
|
|
|
shortName),
|
2010-06-21 13:51:56 +00:00
|
|
|
acceptStdin_(acceptStdin) {}
|
2009-09-09 12:50:42 +00:00
|
|
|
|
|
|
|
virtual void parseArg(Option& option, const std::string& optarg)
|
|
|
|
{
|
2010-06-21 13:51:56 +00:00
|
|
|
if(acceptStdin_ && optarg == "-") {
|
|
|
|
option.put(optName_, DEV_STDIN);
|
2009-12-09 14:32:12 +00:00
|
|
|
} else {
|
|
|
|
File f(optarg);
|
|
|
|
if(!f.exists() || f.isDir()) {
|
2010-01-05 16:01:46 +00:00
|
|
|
throw DL_ABORT_EX
|
|
|
|
(StringFormat(MSG_NOT_FILE, optarg.c_str()).str());
|
2009-12-09 14:32:12 +00:00
|
|
|
}
|
2010-06-21 13:51:56 +00:00
|
|
|
option.put(optName_, optarg);
|
2009-09-09 12:50:42 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual std::string createPossibleValuesString() const
|
|
|
|
{
|
|
|
|
return "/path/to/file";
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2009-11-29 06:43:38 +00:00
|
|
|
class PrioritizePieceOptionHandler:public NameMatchOptionHandler {
|
|
|
|
public:
|
|
|
|
PrioritizePieceOptionHandler
|
|
|
|
(const std::string& optName,
|
|
|
|
const std::string& description = NO_DESCRIPTION,
|
|
|
|
const std::string& defaultValue = NO_DEFAULT_VALUE,
|
|
|
|
char shortName = 0):
|
|
|
|
NameMatchOptionHandler(optName, description, defaultValue,
|
2010-01-05 16:01:46 +00:00
|
|
|
OptionHandler::REQ_ARG, shortName) {}
|
2009-11-29 06:43:38 +00:00
|
|
|
|
|
|
|
virtual void parseArg(Option& option, const std::string& optarg)
|
|
|
|
{
|
|
|
|
// Parse optarg against empty FileEntry list to detect syntax
|
|
|
|
// error.
|
|
|
|
std::vector<size_t> result;
|
|
|
|
util::parsePrioritizePieceRange
|
|
|
|
(result, optarg, std::vector<SharedHandle<FileEntry> >(), 1024);
|
2010-06-21 13:51:56 +00:00
|
|
|
option.put(optName_, optarg);
|
2009-11-29 06:43:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
virtual std::string createPossibleValuesString() const
|
|
|
|
{
|
|
|
|
return "head[=SIZE],tail[=SIZE]";
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2008-02-08 15:53:45 +00:00
|
|
|
} // namespace aria2
|
|
|
|
|
2007-03-26 12:16:57 +00:00
|
|
|
#endif // _D_OPTION_HANDLER_IMPL_H_
|