mirror of https://github.com/aria2/aria2
2010-10-30 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
Use unnamed namespace instead of static keyword. * src/AbstractCommand.cc * src/AdaptiveURISelector.cc * src/Base64.cc * src/BitfieldMan.cc * src/BtDependency.cc * src/ConsoleStatCalc.cc * src/ContentTypeRequestGroupCriteria.cc * src/CookieStorage.cc * src/DHTMessageFactoryImpl.cc * src/DHTRoutingTableDeserializer.cc * src/DefaultBtAnnounce.cc * src/DefaultBtProgressInfoFile.cc * src/DefaultPeerStorage.cc * src/DefaultPieceStorage.cc * src/DownloadCommand.cc * src/DownloadEngine.cc * src/EpollEventPoll.cc * src/ExpatMetalinkProcessor.cc * src/ExpatXmlRpcRequestProcessor.cc * src/FileEntry.cc * src/HttpRequest.cc * src/HttpRequestCommand.cc * src/HttpResponseCommand.cc * src/KqueueEventPoll.cc * src/LongestSequencePieceSelector.cc * src/MetalinkParserStateV3Impl.cc * src/MetalinkParserStateV4Impl.cc * src/MultiDiskAdaptor.cc * src/MultiUrlRequestInfo.cc * src/OptionParser.cc * src/PeerSessionResource.cc * src/PortEventPoll.cc * src/Request.cc * src/RequestGroupMan.cc * src/SelectEventPoll.cc * src/SessionSerializer.cc * src/SimpleLogFormatter.cc * src/Sqlite3CookieParser.cc * src/TrackerWatcherCommand.cc * src/XML2SAXMetalinkProcessor.cc * src/Xml2XmlRpcRequestProcessor.cc * src/XmlRpcMethod.cc * src/XmlRpcMethodImpl.cc * src/XmlRpcResponse.cc * src/base32.cc * src/bencode2.cc * src/bittorrent_helper.cc * src/download_helper.cc * src/main.cc * src/messageDigest.cc * src/option_processing.cc * src/util.cc * test/AnnounceListTest.cc * test/BtRegistryTest.cc * test/DHTBucketTest.cc * test/DHTRoutingTableTest.cc * test/DefaultBtAnnounceTest.cc * test/FileEntryTest.cc * test/FtpConnectionTest.cc * test/MSEHandshakeTest.cc * test/MagnetTest.cc * test/XmlRpcMethodTest.cc * test/array_funTest.ccpull/1/head
parent
6ecfa4aad1
commit
236e64cb25
67
ChangeLog
67
ChangeLog
|
@ -1,3 +1,70 @@
|
|||
2010-10-30 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
|
||||
|
||||
Use unnamed namespace instead of static keyword.
|
||||
* src/AbstractCommand.cc
|
||||
* src/AdaptiveURISelector.cc
|
||||
* src/Base64.cc
|
||||
* src/BitfieldMan.cc
|
||||
* src/BtDependency.cc
|
||||
* src/ConsoleStatCalc.cc
|
||||
* src/ContentTypeRequestGroupCriteria.cc
|
||||
* src/CookieStorage.cc
|
||||
* src/DHTMessageFactoryImpl.cc
|
||||
* src/DHTRoutingTableDeserializer.cc
|
||||
* src/DefaultBtAnnounce.cc
|
||||
* src/DefaultBtProgressInfoFile.cc
|
||||
* src/DefaultPeerStorage.cc
|
||||
* src/DefaultPieceStorage.cc
|
||||
* src/DownloadCommand.cc
|
||||
* src/DownloadEngine.cc
|
||||
* src/EpollEventPoll.cc
|
||||
* src/ExpatMetalinkProcessor.cc
|
||||
* src/ExpatXmlRpcRequestProcessor.cc
|
||||
* src/FileEntry.cc
|
||||
* src/HttpRequest.cc
|
||||
* src/HttpRequestCommand.cc
|
||||
* src/HttpResponseCommand.cc
|
||||
* src/KqueueEventPoll.cc
|
||||
* src/LongestSequencePieceSelector.cc
|
||||
* src/MetalinkParserStateV3Impl.cc
|
||||
* src/MetalinkParserStateV4Impl.cc
|
||||
* src/MultiDiskAdaptor.cc
|
||||
* src/MultiUrlRequestInfo.cc
|
||||
* src/OptionParser.cc
|
||||
* src/PeerSessionResource.cc
|
||||
* src/PortEventPoll.cc
|
||||
* src/Request.cc
|
||||
* src/RequestGroupMan.cc
|
||||
* src/SelectEventPoll.cc
|
||||
* src/SessionSerializer.cc
|
||||
* src/SimpleLogFormatter.cc
|
||||
* src/Sqlite3CookieParser.cc
|
||||
* src/TrackerWatcherCommand.cc
|
||||
* src/XML2SAXMetalinkProcessor.cc
|
||||
* src/Xml2XmlRpcRequestProcessor.cc
|
||||
* src/XmlRpcMethod.cc
|
||||
* src/XmlRpcMethodImpl.cc
|
||||
* src/XmlRpcResponse.cc
|
||||
* src/base32.cc
|
||||
* src/bencode2.cc
|
||||
* src/bittorrent_helper.cc
|
||||
* src/download_helper.cc
|
||||
* src/main.cc
|
||||
* src/messageDigest.cc
|
||||
* src/option_processing.cc
|
||||
* src/util.cc
|
||||
* test/AnnounceListTest.cc
|
||||
* test/BtRegistryTest.cc
|
||||
* test/DHTBucketTest.cc
|
||||
* test/DHTRoutingTableTest.cc
|
||||
* test/DefaultBtAnnounceTest.cc
|
||||
* test/FileEntryTest.cc
|
||||
* test/FtpConnectionTest.cc
|
||||
* test/MSEHandshakeTest.cc
|
||||
* test/MagnetTest.cc
|
||||
* test/XmlRpcMethodTest.cc
|
||||
* test/array_funTest.cc
|
||||
|
||||
2010-10-30 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
|
||||
|
||||
Added '// namespace' after end of unnamed namespace.
|
||||
|
|
|
@ -521,8 +521,9 @@ void AbstractCommand::setWriteCheckSocketIf
|
|||
}
|
||||
}
|
||||
|
||||
namespace {
|
||||
// Returns proxy option value for the given protocol.
|
||||
static const std::string& getProxyOptionFor
|
||||
const std::string& getProxyOptionFor
|
||||
(const std::string& proxyPref, const SharedHandle<Option>& option)
|
||||
{
|
||||
if(option->defined(proxyPref)) {
|
||||
|
@ -531,10 +532,12 @@ static const std::string& getProxyOptionFor
|
|||
return option->get(PREF_ALL_PROXY);
|
||||
}
|
||||
}
|
||||
} // namespace
|
||||
|
||||
namespace {
|
||||
// Returns proxy URI for given protocol. If no proxy URI is defined,
|
||||
// then returns an empty string.
|
||||
static const std::string& getProxyUri
|
||||
const std::string& getProxyUri
|
||||
(const std::string& protocol, const SharedHandle<Option>& option)
|
||||
{
|
||||
if(protocol == Request::PROTO_HTTP) {
|
||||
|
@ -547,16 +550,19 @@ static const std::string& getProxyUri
|
|||
return A2STR::NIL;
|
||||
}
|
||||
}
|
||||
} // namespace
|
||||
|
||||
namespace {
|
||||
// Returns true if proxy is defined for the given protocol. Otherwise
|
||||
// returns false.
|
||||
static bool isProxyRequest
|
||||
bool isProxyRequest
|
||||
(const std::string& protocol, const SharedHandle<Option>& option)
|
||||
{
|
||||
const std::string& proxyUri = getProxyUri(protocol, option);
|
||||
uri::UriStruct us;
|
||||
return !proxyUri.empty() && uri::parse(us, proxyUri);
|
||||
}
|
||||
} // namespace
|
||||
|
||||
namespace {
|
||||
class DomainMatch {
|
||||
|
@ -576,8 +582,9 @@ public:
|
|||
};
|
||||
} // namespace
|
||||
|
||||
static bool inNoProxy(const SharedHandle<Request>& req,
|
||||
const std::string& noProxy)
|
||||
namespace {
|
||||
bool inNoProxy(const SharedHandle<Request>& req,
|
||||
const std::string& noProxy)
|
||||
{
|
||||
std::vector<std::string> entries;
|
||||
util::split(noProxy, std::back_inserter(entries), ",", true);
|
||||
|
@ -616,6 +623,7 @@ static bool inNoProxy(const SharedHandle<Request>& req,
|
|||
}
|
||||
return false;
|
||||
}
|
||||
} // namespace
|
||||
|
||||
bool AbstractCommand::isProxyDefined() const
|
||||
{
|
||||
|
|
|
@ -241,11 +241,13 @@ void AdaptiveURISelector::adjustLowestSpeedLimit
|
|||
}
|
||||
}
|
||||
|
||||
static unsigned int getUriMaxSpeed(SharedHandle<ServerStat> ss)
|
||||
namespace {
|
||||
unsigned int getUriMaxSpeed(SharedHandle<ServerStat> ss)
|
||||
{
|
||||
return std::max(ss->getSingleConnectionAvgSpeed(),
|
||||
ss->getMultiConnectionAvgSpeed());
|
||||
}
|
||||
} // namespace
|
||||
|
||||
unsigned int AdaptiveURISelector::getMaxDownloadSpeed
|
||||
(const std::deque<std::string>& uris) const
|
||||
|
|
|
@ -36,7 +36,8 @@
|
|||
|
||||
namespace aria2 {
|
||||
|
||||
static const char CHAR_TABLE[] = {
|
||||
namespace {
|
||||
const char CHAR_TABLE[] = {
|
||||
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H',
|
||||
'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P',
|
||||
'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X',
|
||||
|
@ -46,8 +47,10 @@ static const char CHAR_TABLE[] = {
|
|||
'w', 'x', 'y', 'z', '0', '1', '2', '3',
|
||||
'4', '5', '6', '7', '8', '9', '+', '/',
|
||||
};
|
||||
} // namespace
|
||||
|
||||
static const int INDEX_TABLE[] = {
|
||||
namespace {
|
||||
const int INDEX_TABLE[] = {
|
||||
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
||||
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
||||
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 62, -1, -1, -1, 63,
|
||||
|
@ -65,6 +68,7 @@ static const int INDEX_TABLE[] = {
|
|||
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
||||
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1
|
||||
};
|
||||
} // namespace
|
||||
|
||||
void Base64::encode(unsigned char*& result, size_t& rlength,
|
||||
const unsigned char* src, size_t slength)
|
||||
|
|
|
@ -198,8 +198,9 @@ bool BitfieldMan::getFirstMissingIndex(size_t& index) const
|
|||
}
|
||||
}
|
||||
|
||||
namespace {
|
||||
template<typename Array>
|
||||
static size_t getStartIndex(size_t index, const Array& bitfield, size_t blocks) {
|
||||
size_t getStartIndex(size_t index, const Array& bitfield, size_t blocks) {
|
||||
while(index < blocks && bitfield::test(bitfield, blocks, index)) {
|
||||
++index;
|
||||
}
|
||||
|
@ -209,17 +210,21 @@ static size_t getStartIndex(size_t index, const Array& bitfield, size_t blocks)
|
|||
return index;
|
||||
}
|
||||
}
|
||||
} // namespace
|
||||
|
||||
namespace {
|
||||
template<typename Array>
|
||||
static size_t getEndIndex(size_t index, const Array& bitfield, size_t blocks) {
|
||||
size_t getEndIndex(size_t index, const Array& bitfield, size_t blocks) {
|
||||
while(index < blocks && !bitfield::test(bitfield, blocks, index)) {
|
||||
++index;
|
||||
}
|
||||
return index;
|
||||
}
|
||||
} // namespace
|
||||
|
||||
namespace {
|
||||
template<typename Array>
|
||||
static bool getSparseMissingUnusedIndex
|
||||
bool getSparseMissingUnusedIndex
|
||||
(size_t& index,
|
||||
size_t minSplitSize,
|
||||
const Array& bitfield,
|
||||
|
@ -278,6 +283,7 @@ static bool getSparseMissingUnusedIndex
|
|||
return false;
|
||||
}
|
||||
}
|
||||
} // namespace
|
||||
|
||||
bool BitfieldMan::getSparseMissingUnusedIndex
|
||||
(size_t& index,
|
||||
|
@ -299,8 +305,9 @@ bool BitfieldMan::getSparseMissingUnusedIndex
|
|||
}
|
||||
}
|
||||
|
||||
namespace {
|
||||
template<typename Array>
|
||||
static bool copyBitfield(unsigned char* dst, const Array& src, size_t blocks)
|
||||
bool copyBitfield(unsigned char* dst, const Array& src, size_t blocks)
|
||||
{
|
||||
unsigned char bits = 0;
|
||||
size_t len = (blocks+7)/8;
|
||||
|
@ -312,6 +319,7 @@ static bool copyBitfield(unsigned char* dst, const Array& src, size_t blocks)
|
|||
bits |= dst[len-1];
|
||||
return bits != 0;
|
||||
}
|
||||
} // namespace
|
||||
|
||||
bool BitfieldMan::getAllMissingIndexes(unsigned char* misbitfield, size_t len)
|
||||
const
|
||||
|
@ -438,7 +446,8 @@ bool BitfieldMan::isFilteredAllBitSet() const {
|
|||
}
|
||||
}
|
||||
|
||||
static bool testAllBitSet
|
||||
namespace {
|
||||
bool testAllBitSet
|
||||
(const unsigned char* bitfield, size_t length, size_t blocks)
|
||||
{
|
||||
if(length == 0) {
|
||||
|
@ -451,6 +460,7 @@ static bool testAllBitSet
|
|||
}
|
||||
return bitfield[length-1] == bitfield::lastByteMask(blocks);
|
||||
}
|
||||
} // namespace
|
||||
|
||||
bool BitfieldMan::isAllBitSet() const
|
||||
{
|
||||
|
|
|
@ -59,8 +59,9 @@ BtDependency::BtDependency(const WeakHandle<RequestGroup>& dependant,
|
|||
|
||||
BtDependency::~BtDependency() {}
|
||||
|
||||
static void copyValues(const SharedHandle<FileEntry>& d,
|
||||
const SharedHandle<FileEntry>& s)
|
||||
namespace {
|
||||
void copyValues(const SharedHandle<FileEntry>& d,
|
||||
const SharedHandle<FileEntry>& s)
|
||||
{
|
||||
d->setRequested(true);
|
||||
d->setPath(s->getPath());
|
||||
|
@ -69,6 +70,7 @@ static void copyValues(const SharedHandle<FileEntry>& d,
|
|||
d->setMaxConnectionPerServer(s->getMaxConnectionPerServer());
|
||||
d->setUniqueProtocol(s->isUniqueProtocol());
|
||||
}
|
||||
} // namespace
|
||||
|
||||
bool BtDependency::resolve()
|
||||
{
|
||||
|
|
|
@ -74,7 +74,8 @@
|
|||
|
||||
namespace aria2 {
|
||||
|
||||
static void printProgress
|
||||
namespace {
|
||||
void printProgress
|
||||
(std::ostream& o, const SharedHandle<RequestGroup>& rg, const DownloadEngine* e,
|
||||
const SizeFormatter& sizeFormatter)
|
||||
{
|
||||
|
@ -146,6 +147,7 @@ static void printProgress
|
|||
}
|
||||
o << "]";
|
||||
}
|
||||
} // namespace
|
||||
|
||||
namespace {
|
||||
class PrintSummary
|
||||
|
@ -176,7 +178,8 @@ public:
|
|||
};
|
||||
} // namespace
|
||||
|
||||
static void printProgressSummary
|
||||
namespace {
|
||||
void printProgressSummary
|
||||
(const std::deque<SharedHandle<RequestGroup> >& groups, size_t cols,
|
||||
const DownloadEngine* e,
|
||||
const SizeFormatter& sizeFormatter)
|
||||
|
@ -203,6 +206,7 @@ static void printProgressSummary
|
|||
std::for_each(groups.begin(), groups.end(),
|
||||
PrintSummary(cols, e, sizeFormatter));
|
||||
}
|
||||
} // namespace
|
||||
|
||||
ConsoleStatCalc::ConsoleStatCalc(time_t summaryInterval, bool humanReadable):
|
||||
summaryInterval_(summaryInterval)
|
||||
|
|
|
@ -43,8 +43,9 @@
|
|||
|
||||
namespace aria2 {
|
||||
|
||||
namespace {
|
||||
template<typename InputIterator>
|
||||
static bool tailMatch
|
||||
bool tailMatch
|
||||
(InputIterator first, InputIterator last, const std::string& target)
|
||||
{
|
||||
for(; first != last; ++first) {
|
||||
|
@ -54,6 +55,7 @@ static bool tailMatch
|
|||
}
|
||||
return false;
|
||||
}
|
||||
} // namespace
|
||||
|
||||
bool ContentTypeRequestGroupCriteria::match
|
||||
(const RequestGroup* requestGroup) const
|
||||
|
|
|
@ -113,10 +113,12 @@ CookieStorage::CookieStorage():logger_(LogFactory::getInstance()) {}
|
|||
|
||||
CookieStorage::~CookieStorage() {}
|
||||
|
||||
namespace {
|
||||
// See CookieStorageTest::testDomainIsFull() in CookieStorageTest.cc
|
||||
static const size_t DOMAIN_EVICTION_TRIGGER = 2000;
|
||||
const size_t DOMAIN_EVICTION_TRIGGER = 2000;
|
||||
|
||||
static const double DOMAIN_EVICTION_RATE = 0.1;
|
||||
const double DOMAIN_EVICTION_RATE = 0.1;
|
||||
} // namespace
|
||||
|
||||
bool CookieStorage::store(const Cookie& cookie, time_t now)
|
||||
{
|
||||
|
|
|
@ -83,7 +83,8 @@ DHTMessageFactoryImpl::getRemoteNode
|
|||
return node;
|
||||
}
|
||||
|
||||
static const Dict* getDictionary(const Dict* dict, const std::string& key)
|
||||
namespace {
|
||||
const Dict* getDictionary(const Dict* dict, const std::string& key)
|
||||
{
|
||||
const Dict* d = asDict(dict->get(key));
|
||||
if(d) {
|
||||
|
@ -93,8 +94,10 @@ static const Dict* getDictionary(const Dict* dict, const std::string& key)
|
|||
(StringFormat("Malformed DHT message. Missing %s", key.c_str()).str());
|
||||
}
|
||||
}
|
||||
} // namespace
|
||||
|
||||
static const String* getString(const Dict* dict, const std::string& key)
|
||||
namespace {
|
||||
const String* getString(const Dict* dict, const std::string& key)
|
||||
{
|
||||
const String* c = asString(dict->get(key));
|
||||
if(c) {
|
||||
|
@ -104,8 +107,10 @@ static const String* getString(const Dict* dict, const std::string& key)
|
|||
(StringFormat("Malformed DHT message. Missing %s", key.c_str()).str());
|
||||
}
|
||||
}
|
||||
} // namespace
|
||||
|
||||
static const Integer* getInteger(const Dict* dict, const std::string& key)
|
||||
namespace {
|
||||
const Integer* getInteger(const Dict* dict, const std::string& key)
|
||||
{
|
||||
const Integer* c = asInteger(dict->get(key));
|
||||
if(c) {
|
||||
|
@ -115,8 +120,10 @@ static const Integer* getInteger(const Dict* dict, const std::string& key)
|
|||
(StringFormat("Malformed DHT message. Missing %s", key.c_str()).str());
|
||||
}
|
||||
}
|
||||
} // namespace
|
||||
|
||||
static const String* getString(const List* list, size_t index)
|
||||
namespace {
|
||||
const String* getString(const List* list, size_t index)
|
||||
{
|
||||
const String* c = asString(list->get(index));
|
||||
if(c) {
|
||||
|
@ -127,8 +134,10 @@ static const String* getString(const List* list, size_t index)
|
|||
static_cast<unsigned long>(index)).str());
|
||||
}
|
||||
}
|
||||
} // namespace
|
||||
|
||||
static const Integer* getInteger(const List* list, size_t index)
|
||||
namespace {
|
||||
const Integer* getInteger(const List* list, size_t index)
|
||||
{
|
||||
const Integer* c = asInteger(list->get(index));
|
||||
if(c) {
|
||||
|
@ -139,8 +148,10 @@ static const Integer* getInteger(const List* list, size_t index)
|
|||
static_cast<unsigned long>(index)).str());
|
||||
}
|
||||
}
|
||||
} // namespace
|
||||
|
||||
static const List* getList(const Dict* dict, const std::string& key)
|
||||
namespace {
|
||||
const List* getList(const Dict* dict, const std::string& key)
|
||||
{
|
||||
const List* l = asList(dict->get(key));
|
||||
if(l) {
|
||||
|
@ -150,6 +161,7 @@ static const List* getList(const Dict* dict, const std::string& key)
|
|||
(StringFormat("Malformed DHT message. Missing %s", key.c_str()).str());
|
||||
}
|
||||
}
|
||||
} // namespace
|
||||
|
||||
void DHTMessageFactoryImpl::validateID(const String* id) const
|
||||
{
|
||||
|
@ -171,7 +183,8 @@ void DHTMessageFactoryImpl::validatePort(const Integer* port) const
|
|||
}
|
||||
}
|
||||
|
||||
static void setVersion(const SharedHandle<DHTMessage>& msg, const Dict* dict)
|
||||
namespace {
|
||||
void setVersion(const SharedHandle<DHTMessage>& msg, const Dict* dict)
|
||||
{
|
||||
const String* v = asString(dict->get(DHTMessage::V));
|
||||
if(v) {
|
||||
|
@ -180,6 +193,7 @@ static void setVersion(const SharedHandle<DHTMessage>& msg, const Dict* dict)
|
|||
msg->setVersion(A2STR::NIL);
|
||||
}
|
||||
}
|
||||
} // namespace
|
||||
|
||||
SharedHandle<DHTQueryMessage> DHTMessageFactoryImpl::createQueryMessage
|
||||
(const Dict* dict, const std::string& ipaddr, uint16_t port)
|
||||
|
@ -274,7 +288,8 @@ DHTMessageFactoryImpl::createResponseMessage
|
|||
return msg;
|
||||
}
|
||||
|
||||
static const std::string& getDefaultVersion()
|
||||
namespace {
|
||||
const std::string& getDefaultVersion()
|
||||
{
|
||||
static std::string version;
|
||||
if(version.empty()) {
|
||||
|
@ -286,6 +301,7 @@ static const std::string& getDefaultVersion()
|
|||
}
|
||||
return version;
|
||||
}
|
||||
} // namespace
|
||||
|
||||
void DHTMessageFactoryImpl::setCommonProperty
|
||||
(const SharedHandle<DHTAbstractMessage>& m)
|
||||
|
|
|
@ -57,12 +57,14 @@ DHTRoutingTableDeserializer::DHTRoutingTableDeserializer(int family):
|
|||
|
||||
DHTRoutingTableDeserializer::~DHTRoutingTableDeserializer() {}
|
||||
|
||||
static void readBytes(unsigned char* buf, size_t buflen,
|
||||
std::istream& in, size_t readlen)
|
||||
namespace {
|
||||
void readBytes(unsigned char* buf, size_t buflen,
|
||||
std::istream& in, size_t readlen)
|
||||
{
|
||||
assert(readlen <= buflen);
|
||||
in.read(reinterpret_cast<char*>(buf), readlen);
|
||||
}
|
||||
} // namespace
|
||||
|
||||
#define CHECK_STREAM(in, length) \
|
||||
if(in.gcount() != length) { \
|
||||
|
|
|
@ -103,7 +103,8 @@ bool DefaultBtAnnounce::isAnnounceReady() {
|
|||
isDefaultAnnounceReady();
|
||||
}
|
||||
|
||||
static bool uriHasQuery(const std::string& uri)
|
||||
namespace {
|
||||
bool uriHasQuery(const std::string& uri)
|
||||
{
|
||||
uri::UriStruct us;
|
||||
if(uri::parse(us, uri)) {
|
||||
|
@ -112,6 +113,7 @@ static bool uriHasQuery(const std::string& uri)
|
|||
return false;
|
||||
}
|
||||
}
|
||||
} // namespace
|
||||
|
||||
std::string DefaultBtAnnounce::getAnnounceUrl() {
|
||||
if(isStoppedAnnounceReady()) {
|
||||
|
|
|
@ -66,13 +66,15 @@ namespace aria2 {
|
|||
const std::string DefaultBtProgressInfoFile::V0000("0000");
|
||||
const std::string DefaultBtProgressInfoFile::V0001("0001");
|
||||
|
||||
static std::string createFilename
|
||||
namespace {
|
||||
std::string createFilename
|
||||
(const SharedHandle<DownloadContext>& dctx, const std::string& suffix)
|
||||
{
|
||||
std::string t = dctx->getBasePath();
|
||||
t += suffix;
|
||||
return t;
|
||||
}
|
||||
} // namespace
|
||||
|
||||
DefaultBtProgressInfoFile::DefaultBtProgressInfoFile
|
||||
(const SharedHandle<DownloadContext>& dctx,
|
||||
|
|
|
@ -48,7 +48,9 @@
|
|||
|
||||
namespace aria2 {
|
||||
|
||||
static const int MAX_PEER_LIST_SIZE = 1024;
|
||||
namespace {
|
||||
const int MAX_PEER_LIST_SIZE = 1024;
|
||||
} // namespace
|
||||
|
||||
DefaultPeerStorage::DefaultPeerStorage():
|
||||
logger_(LogFactory::getInstance()),
|
||||
|
@ -86,7 +88,8 @@ bool DefaultPeerStorage::isPeerAlreadyAdded(const SharedHandle<Peer>& peer)
|
|||
FindIdenticalPeer(peer)) != peers_.end();
|
||||
}
|
||||
|
||||
static size_t calculateMaxPeerListSize(const SharedHandle<BtRuntime>& btRuntime)
|
||||
namespace {
|
||||
size_t calculateMaxPeerListSize(const SharedHandle<BtRuntime>& btRuntime)
|
||||
{
|
||||
if(btRuntime.isNull()) {
|
||||
return MAX_PEER_LIST_SIZE;
|
||||
|
@ -95,6 +98,7 @@ static size_t calculateMaxPeerListSize(const SharedHandle<BtRuntime>& btRuntime)
|
|||
MAX_PEER_LIST_SIZE :
|
||||
btRuntime->getMaxPeers()+(btRuntime->getMaxPeers() >> 2);
|
||||
}
|
||||
} // namespace
|
||||
|
||||
bool DefaultPeerStorage::addPeer(const SharedHandle<Peer>& peer) {
|
||||
if(isPeerAlreadyAdded(peer)) {
|
||||
|
@ -220,7 +224,8 @@ void DefaultPeerStorage::getActivePeers
|
|||
std::for_each(peers_.begin(), peers_.end(), CollectActivePeer(activePeers));
|
||||
}
|
||||
|
||||
static TransferStat calculateStatFor(const SharedHandle<Peer>& peer)
|
||||
namespace {
|
||||
TransferStat calculateStatFor(const SharedHandle<Peer>& peer)
|
||||
{
|
||||
TransferStat s;
|
||||
s.downloadSpeed = peer->calculateDownloadSpeed();
|
||||
|
@ -229,6 +234,7 @@ static TransferStat calculateStatFor(const SharedHandle<Peer>& peer)
|
|||
s.sessionUploadLength = peer->getSessionUploadLength();
|
||||
return s;
|
||||
}
|
||||
} // namespace
|
||||
|
||||
TransferStat DefaultPeerStorage::calculateStat()
|
||||
{
|
||||
|
|
|
@ -205,12 +205,14 @@ void DefaultPieceStorage::getMissingPiece
|
|||
}
|
||||
}
|
||||
|
||||
static void unsetExcludedIndexes(BitfieldMan& bitfield,
|
||||
const std::vector<size_t>& excludedIndexes)
|
||||
namespace {
|
||||
void unsetExcludedIndexes(BitfieldMan& bitfield,
|
||||
const std::vector<size_t>& excludedIndexes)
|
||||
{
|
||||
std::for_each(excludedIndexes.begin(), excludedIndexes.end(),
|
||||
std::bind1st(std::mem_fun(&BitfieldMan::unsetBit), &bitfield));
|
||||
}
|
||||
} // namespace
|
||||
|
||||
void DefaultPieceStorage::createFastIndexBitfield
|
||||
(BitfieldMan& bitfield, const SharedHandle<Peer>& peer)
|
||||
|
|
|
@ -70,7 +70,9 @@
|
|||
|
||||
namespace aria2 {
|
||||
|
||||
static const size_t BUFSIZE = 16*1024;
|
||||
namespace {
|
||||
const size_t BUFSIZE = 16*1024;
|
||||
} // namespace
|
||||
|
||||
DownloadCommand::DownloadCommand(cuid_t cuid,
|
||||
const SharedHandle<Request>& req,
|
||||
|
|
|
@ -115,8 +115,9 @@ void DownloadEngine::cleanQueue() {
|
|||
commands_.clear();
|
||||
}
|
||||
|
||||
static void executeCommand(std::deque<Command*>& commands,
|
||||
Command::STATUS statusFilter)
|
||||
namespace {
|
||||
void executeCommand(std::deque<Command*>& commands,
|
||||
Command::STATUS statusFilter)
|
||||
{
|
||||
size_t max = commands.size();
|
||||
for(size_t i = 0; i < max; ++i) {
|
||||
|
@ -136,6 +137,7 @@ static void executeCommand(std::deque<Command*>& commands,
|
|||
}
|
||||
}
|
||||
}
|
||||
} // namespace
|
||||
|
||||
void DownloadEngine::run()
|
||||
{
|
||||
|
@ -303,7 +305,8 @@ void DownloadEngine::poolSocket(const std::string& key,
|
|||
}
|
||||
}
|
||||
|
||||
static std::string createSockPoolKey
|
||||
namespace {
|
||||
std::string createSockPoolKey
|
||||
(const std::string& host, uint16_t port,
|
||||
const std::string& username,
|
||||
const std::string& proxyhost, uint16_t proxyport)
|
||||
|
@ -324,6 +327,7 @@ static std::string createSockPoolKey
|
|||
}
|
||||
return key;
|
||||
}
|
||||
} // namespace
|
||||
|
||||
void DownloadEngine::poolSocket
|
||||
(const std::string& ipaddr,
|
||||
|
|
|
@ -138,7 +138,8 @@ void EpollEventPoll::poll(const struct timeval& tv)
|
|||
// DHTEntryPoint...Command)
|
||||
}
|
||||
|
||||
static int translateEvents(EventPoll::EventType events)
|
||||
namespace {
|
||||
int translateEvents(EventPoll::EventType events)
|
||||
{
|
||||
int newEvents = 0;
|
||||
if(EventPoll::EVENT_READ&events) {
|
||||
|
@ -155,6 +156,7 @@ static int translateEvents(EventPoll::EventType events)
|
|||
}
|
||||
return newEvents;
|
||||
}
|
||||
} // namespace
|
||||
|
||||
bool EpollEventPoll::addEvents(sock_t socket,
|
||||
const EpollEventPoll::KEvent& event)
|
||||
|
|
|
@ -60,7 +60,8 @@ public:
|
|||
};
|
||||
} // namespace
|
||||
|
||||
static void splitNsName
|
||||
namespace {
|
||||
void splitNsName
|
||||
(std::string& localname, std::string& prefix, std::string& nsUri,
|
||||
const std::string& nsName)
|
||||
{
|
||||
|
@ -73,8 +74,10 @@ static void splitNsName
|
|||
localname = nsNamePair.second;
|
||||
}
|
||||
}
|
||||
} // namespace
|
||||
|
||||
static void mlStartElement(void* userData, const char* nsName, const char** attrs)
|
||||
namespace {
|
||||
void mlStartElement(void* userData, const char* nsName, const char** attrs)
|
||||
{
|
||||
SessionData* sd = reinterpret_cast<SessionData*>(userData);
|
||||
|
||||
|
@ -110,8 +113,10 @@ static void mlStartElement(void* userData, const char* nsName, const char** attr
|
|||
sd->charactersStack_.push_front(A2STR::NIL);
|
||||
}
|
||||
}
|
||||
} // namespace
|
||||
|
||||
static void mlEndElement(void* userData, const char* nsName)
|
||||
namespace {
|
||||
void mlEndElement(void* userData, const char* nsName)
|
||||
{
|
||||
std::string localname;
|
||||
std::string prefix;
|
||||
|
@ -126,16 +131,20 @@ static void mlEndElement(void* userData, const char* nsName)
|
|||
}
|
||||
sd->stm_->endElement(localname, prefix, nsUri, characters);
|
||||
}
|
||||
} // namespace
|
||||
|
||||
static void mlCharacters(void* userData, const char* ch, int len)
|
||||
namespace {
|
||||
void mlCharacters(void* userData, const char* ch, int len)
|
||||
{
|
||||
SessionData* sd = reinterpret_cast<SessionData*>(userData);
|
||||
if(sd->stm_->needsCharactersBuffering()) {
|
||||
sd->charactersStack_.front() += std::string(&ch[0], &ch[len]);
|
||||
}
|
||||
}
|
||||
} // namespace
|
||||
|
||||
static XML_Parser createParser(const SharedHandle<SessionData>& sessionData)
|
||||
namespace {
|
||||
XML_Parser createParser(const SharedHandle<SessionData>& sessionData)
|
||||
{
|
||||
XML_Parser parser = XML_ParserCreateNS(0, static_cast<const XML_Char>('\t'));
|
||||
XML_SetUserData(parser, sessionData.get());
|
||||
|
@ -143,8 +152,10 @@ static XML_Parser createParser(const SharedHandle<SessionData>& sessionData)
|
|||
XML_SetCharacterDataHandler(parser, &mlCharacters);
|
||||
return parser;
|
||||
}
|
||||
} // namespace
|
||||
|
||||
static void checkError(XML_Parser parser)
|
||||
namespace {
|
||||
void checkError(XML_Parser parser)
|
||||
{
|
||||
if(XML_Parse(parser, 0, 0, 1) == XML_STATUS_ERROR) {
|
||||
throw DL_ABORT_EX(MSG_CANNOT_PARSE_METALINK);
|
||||
|
@ -159,6 +170,7 @@ static void checkError(XML_Parser parser)
|
|||
throw DL_ABORT_EX(stm->getErrorString());
|
||||
}
|
||||
}
|
||||
} // namespace
|
||||
|
||||
SharedHandle<Metalinker>
|
||||
MetalinkProcessor::parseFile(const std::string& filename)
|
||||
|
|
|
@ -57,7 +57,8 @@ struct SessionData {
|
|||
};
|
||||
} // namespace
|
||||
|
||||
static void mlStartElement(void* userData, const char* name, const char** attrs)
|
||||
namespace {
|
||||
void mlStartElement(void* userData, const char* name, const char** attrs)
|
||||
{
|
||||
SessionData* sd = reinterpret_cast<SessionData*>(userData);
|
||||
|
||||
|
@ -78,8 +79,10 @@ static void mlStartElement(void* userData, const char* name, const char** attrs)
|
|||
sd->charactersStack_.push(std::string());
|
||||
}
|
||||
}
|
||||
} // namespace
|
||||
|
||||
static void mlEndElement(void* userData, const char* name)
|
||||
namespace {
|
||||
void mlEndElement(void* userData, const char* name)
|
||||
{
|
||||
SessionData* sd = reinterpret_cast<SessionData*>(userData);
|
||||
std::string characters;
|
||||
|
@ -89,14 +92,17 @@ static void mlEndElement(void* userData, const char* name)
|
|||
}
|
||||
sd->stm_->endElement(name, characters);
|
||||
}
|
||||
} // namespace
|
||||
|
||||
static void mlCharacters(void* userData, const char* ch, int len)
|
||||
namespace {
|
||||
void mlCharacters(void* userData, const char* ch, int len)
|
||||
{
|
||||
SessionData* sd = reinterpret_cast<SessionData*>(userData);
|
||||
if(sd->stm_->needsCharactersBuffering()) {
|
||||
sd->charactersStack_.top() += std::string(&ch[0], &ch[len]);
|
||||
}
|
||||
}
|
||||
} // namespace
|
||||
|
||||
XmlRpcRequest
|
||||
XmlRpcRequestProcessor::parseMemory(const std::string& xml)
|
||||
|
|
|
@ -104,9 +104,9 @@ void FileEntry::getUris(std::vector<std::string>& uris) const
|
|||
uris.insert(uris.end(), uris_.begin(), uris_.end());
|
||||
}
|
||||
|
||||
namespace {
|
||||
template<typename InputIterator, typename OutputIterator>
|
||||
static OutputIterator
|
||||
enumerateInFlightHosts
|
||||
OutputIterator enumerateInFlightHosts
|
||||
(InputIterator first, InputIterator last, OutputIterator out)
|
||||
{
|
||||
for(; first != last; ++first) {
|
||||
|
@ -117,6 +117,7 @@ enumerateInFlightHosts
|
|||
}
|
||||
return out;
|
||||
}
|
||||
} // namespace
|
||||
|
||||
SharedHandle<Request>
|
||||
FileEntry::getRequest
|
||||
|
@ -371,8 +372,9 @@ void FileEntry::releaseRuntimeResource()
|
|||
inFlightRequests_.clear();
|
||||
}
|
||||
|
||||
namespace {
|
||||
template<typename InputIterator, typename T>
|
||||
static InputIterator findRequestByUri
|
||||
InputIterator findRequestByUri
|
||||
(InputIterator first, InputIterator last, const T& uri)
|
||||
{
|
||||
for(; first != last; ++first) {
|
||||
|
@ -382,6 +384,7 @@ static InputIterator findRequestByUri
|
|||
}
|
||||
return last;
|
||||
}
|
||||
} // namespace
|
||||
|
||||
bool FileEntry::removeUri(const std::string& uri)
|
||||
{
|
||||
|
|
|
@ -123,7 +123,8 @@ bool HttpRequest::isRangeSatisfied(const RangeHandle& range) const
|
|||
}
|
||||
}
|
||||
|
||||
static std::string getHostText(const std::string& host, uint16_t port)
|
||||
namespace {
|
||||
std::string getHostText(const std::string& host, uint16_t port)
|
||||
{
|
||||
std::string hosttext = host;
|
||||
if(!(port == 80 || port == 443)) {
|
||||
|
@ -131,6 +132,7 @@ static std::string getHostText(const std::string& host, uint16_t port)
|
|||
}
|
||||
return hosttext;
|
||||
}
|
||||
} // namespace
|
||||
|
||||
std::string HttpRequest::createRequest()
|
||||
{
|
||||
|
|
|
@ -81,7 +81,8 @@ HttpRequestCommand::HttpRequestCommand
|
|||
|
||||
HttpRequestCommand::~HttpRequestCommand() {}
|
||||
|
||||
static SharedHandle<HttpRequest>
|
||||
namespace {
|
||||
SharedHandle<HttpRequest>
|
||||
createHttpRequest(const SharedHandle<Request>& req,
|
||||
const SharedHandle<FileEntry>& fileEntry,
|
||||
const SharedHandle<Segment>& segment,
|
||||
|
@ -117,6 +118,7 @@ createHttpRequest(const SharedHandle<Request>& req,
|
|||
httpRequest->setEndOffsetOverride(endOffset);
|
||||
return httpRequest;
|
||||
}
|
||||
} // namespace
|
||||
|
||||
bool HttpRequestCommand::executeInternal() {
|
||||
//socket->setBlockingMode();
|
||||
|
|
|
@ -79,13 +79,54 @@
|
|||
|
||||
namespace aria2 {
|
||||
|
||||
static SharedHandle<StreamFilter> getTransferEncodingStreamFilter
|
||||
namespace {
|
||||
SharedHandle<StreamFilter> getTransferEncodingStreamFilter
|
||||
(const SharedHandle<HttpResponse>& httpResponse,
|
||||
const SharedHandle<StreamFilter>& delegate = SharedHandle<StreamFilter>());
|
||||
const SharedHandle<StreamFilter>& delegate = SharedHandle<StreamFilter>())
|
||||
{
|
||||
SharedHandle<StreamFilter> filter;
|
||||
if(httpResponse->isTransferEncodingSpecified()) {
|
||||
filter = httpResponse->getTransferEncodingStreamFilter();
|
||||
if(filter.isNull()) {
|
||||
throw DL_ABORT_EX
|
||||
(StringFormat(EX_TRANSFER_ENCODING_NOT_SUPPORTED,
|
||||
httpResponse->getTransferEncoding().c_str()).str());
|
||||
}
|
||||
filter->init();
|
||||
filter->installDelegate(delegate);
|
||||
}
|
||||
if(filter.isNull()) {
|
||||
filter = delegate;
|
||||
}
|
||||
return filter;
|
||||
}
|
||||
} // namespace
|
||||
|
||||
static SharedHandle<StreamFilter> getContentEncodingStreamFilter
|
||||
namespace {
|
||||
SharedHandle<StreamFilter> getContentEncodingStreamFilter
|
||||
(const SharedHandle<HttpResponse>& httpResponse,
|
||||
const SharedHandle<StreamFilter>& delegate = SharedHandle<StreamFilter>());
|
||||
const SharedHandle<StreamFilter>& delegate = SharedHandle<StreamFilter>())
|
||||
{
|
||||
SharedHandle<StreamFilter> filter;
|
||||
if(httpResponse->isContentEncodingSpecified()) {
|
||||
filter = httpResponse->getContentEncodingStreamFilter();
|
||||
if(filter.isNull()) {
|
||||
LogFactory::getInstance()->info
|
||||
("Content-Encoding %s is specified, but the current implementation"
|
||||
"doesn't support it. The decoding process is skipped and the"
|
||||
"downloaded content will be still encoded.",
|
||||
httpResponse->getContentEncoding().c_str());
|
||||
} else {
|
||||
filter->init();
|
||||
filter->installDelegate(delegate);
|
||||
}
|
||||
}
|
||||
if(filter.isNull()) {
|
||||
filter = delegate;
|
||||
}
|
||||
return filter;
|
||||
}
|
||||
} // namespace
|
||||
|
||||
HttpResponseCommand::HttpResponseCommand
|
||||
(cuid_t cuid,
|
||||
|
@ -305,51 +346,6 @@ bool HttpResponseCommand::handleDefaultEncoding
|
|||
return true;
|
||||
}
|
||||
|
||||
static SharedHandle<StreamFilter> getTransferEncodingStreamFilter
|
||||
(const SharedHandle<HttpResponse>& httpResponse,
|
||||
const SharedHandle<StreamFilter>& delegate)
|
||||
{
|
||||
SharedHandle<StreamFilter> filter;
|
||||
if(httpResponse->isTransferEncodingSpecified()) {
|
||||
filter = httpResponse->getTransferEncodingStreamFilter();
|
||||
if(filter.isNull()) {
|
||||
throw DL_ABORT_EX
|
||||
(StringFormat(EX_TRANSFER_ENCODING_NOT_SUPPORTED,
|
||||
httpResponse->getTransferEncoding().c_str()).str());
|
||||
}
|
||||
filter->init();
|
||||
filter->installDelegate(delegate);
|
||||
}
|
||||
if(filter.isNull()) {
|
||||
filter = delegate;
|
||||
}
|
||||
return filter;
|
||||
}
|
||||
|
||||
static SharedHandle<StreamFilter> getContentEncodingStreamFilter
|
||||
(const SharedHandle<HttpResponse>& httpResponse,
|
||||
const SharedHandle<StreamFilter>& delegate)
|
||||
{
|
||||
SharedHandle<StreamFilter> filter;
|
||||
if(httpResponse->isContentEncodingSpecified()) {
|
||||
filter = httpResponse->getContentEncodingStreamFilter();
|
||||
if(filter.isNull()) {
|
||||
LogFactory::getInstance()->info
|
||||
("Content-Encoding %s is specified, but the current implementation"
|
||||
"doesn't support it. The decoding process is skipped and the"
|
||||
"downloaded content will be still encoded.",
|
||||
httpResponse->getContentEncoding().c_str());
|
||||
} else {
|
||||
filter->init();
|
||||
filter->installDelegate(delegate);
|
||||
}
|
||||
}
|
||||
if(filter.isNull()) {
|
||||
filter = delegate;
|
||||
}
|
||||
return filter;
|
||||
}
|
||||
|
||||
bool HttpResponseCommand::handleOtherEncoding
|
||||
(const SharedHandle<HttpResponse>& httpResponse) {
|
||||
// We assume that RequestGroup::getTotalLength() == 0 here
|
||||
|
@ -448,7 +444,8 @@ bool HttpResponseCommand::skipResponseBody
|
|||
return true;
|
||||
}
|
||||
|
||||
static bool decideFileAllocation
|
||||
namespace {
|
||||
bool decideFileAllocation
|
||||
(const SharedHandle<StreamFilter>& filter)
|
||||
{
|
||||
#ifdef HAVE_LIBZ
|
||||
|
@ -463,6 +460,7 @@ static bool decideFileAllocation
|
|||
#endif // HAVE_LIBZ
|
||||
return true;
|
||||
}
|
||||
} // namespace
|
||||
|
||||
HttpDownloadCommand* HttpResponseCommand::createHttpDownloadCommand
|
||||
(const SharedHandle<HttpResponse>& httpResponse,
|
||||
|
|
|
@ -148,7 +148,8 @@ void KqueueEventPoll::poll(const struct timeval& tv)
|
|||
// DHTEntryPoint...Command)
|
||||
}
|
||||
|
||||
static int translateEvents(EventPoll::EventType events)
|
||||
namespace {
|
||||
int translateEvents(EventPoll::EventType events)
|
||||
{
|
||||
int newEvents = 0;
|
||||
if(EventPoll::EVENT_READ&events) {
|
||||
|
@ -159,6 +160,7 @@ static int translateEvents(EventPoll::EventType events)
|
|||
}
|
||||
return newEvents;
|
||||
}
|
||||
} // namespace
|
||||
|
||||
bool KqueueEventPoll::addEvents
|
||||
(sock_t socket, const KqueueEventPoll::KEvent& event)
|
||||
|
|
|
@ -37,7 +37,8 @@
|
|||
|
||||
namespace aria2 {
|
||||
|
||||
static size_t getStartIndex
|
||||
namespace {
|
||||
size_t getStartIndex
|
||||
(size_t from, const unsigned char* bitfield, size_t nbits)
|
||||
{
|
||||
while(from < nbits && !bitfield::test(bitfield, nbits, from)) {
|
||||
|
@ -49,8 +50,10 @@ static size_t getStartIndex
|
|||
return from;
|
||||
}
|
||||
}
|
||||
} // namespace
|
||||
|
||||
static size_t getEndIndex
|
||||
namespace {
|
||||
size_t getEndIndex
|
||||
(size_t from, const unsigned char* bitfield, size_t nbits)
|
||||
{
|
||||
while(from < nbits && bitfield::test(bitfield, nbits, from)) {
|
||||
|
@ -58,6 +61,7 @@ static size_t getEndIndex
|
|||
}
|
||||
return from;
|
||||
}
|
||||
} // namespace
|
||||
|
||||
bool LongestSequencePieceSelector::select
|
||||
(size_t& index, const unsigned char* bitfield, size_t nbits) const
|
||||
|
|
|
@ -81,12 +81,14 @@ public:
|
|||
};
|
||||
} // namespace
|
||||
|
||||
namespace {
|
||||
template<typename Container>
|
||||
static typename Container::const_iterator findAttr
|
||||
typename Container::const_iterator findAttr
|
||||
(const Container& attrs, const std::string& localname)
|
||||
{
|
||||
return std::find_if(attrs.begin(), attrs.end(), FindAttr(localname));
|
||||
}
|
||||
} // namespace
|
||||
|
||||
void MetalinkMetalinkParserState::beginElement
|
||||
(MetalinkParserStateMachine* stm,
|
||||
|
|
|
@ -80,12 +80,14 @@ public:
|
|||
};
|
||||
} // namespace
|
||||
|
||||
namespace {
|
||||
template<typename Container>
|
||||
static typename Container::const_iterator findAttr
|
||||
typename Container::const_iterator findAttr
|
||||
(const Container& attrs, const std::string& localname)
|
||||
{
|
||||
return std::find_if(attrs.begin(), attrs.end(), FindAttr(localname));
|
||||
}
|
||||
} // namespace
|
||||
|
||||
void MetalinkMetalinkParserStateV4::beginElement
|
||||
(MetalinkParserStateMachine* stm,
|
||||
|
|
|
@ -144,7 +144,8 @@ MultiDiskAdaptor::MultiDiskAdaptor():
|
|||
directIOAllowed_(false),
|
||||
readOnly_(false) {}
|
||||
|
||||
static SharedHandle<DiskWriterEntry> createDiskWriterEntry
|
||||
namespace {
|
||||
SharedHandle<DiskWriterEntry> createDiskWriterEntry
|
||||
(const SharedHandle<FileEntry>& fileEntry,
|
||||
bool needsFileAllocation)
|
||||
{
|
||||
|
@ -152,6 +153,7 @@ static SharedHandle<DiskWriterEntry> createDiskWriterEntry
|
|||
entry->needsFileAllocation(needsFileAllocation);
|
||||
return entry;
|
||||
}
|
||||
} // namespace
|
||||
|
||||
void MultiDiskAdaptor::resetDiskWriterEntries()
|
||||
{
|
||||
|
@ -334,15 +336,18 @@ void MultiDiskAdaptor::closeFile()
|
|||
mem_fun_sh(&DiskWriterEntry::closeFile));
|
||||
}
|
||||
|
||||
static bool isInRange(const DiskWriterEntryHandle entry, off_t offset)
|
||||
namespace {
|
||||
bool isInRange(const DiskWriterEntryHandle entry, off_t offset)
|
||||
{
|
||||
return entry->getFileEntry()->getOffset() <= offset &&
|
||||
(uint64_t)offset <
|
||||
entry->getFileEntry()->getOffset()+entry->getFileEntry()->getLength();
|
||||
}
|
||||
} // namespace
|
||||
|
||||
static size_t calculateLength(const DiskWriterEntryHandle entry,
|
||||
off_t fileOffset, size_t rem)
|
||||
namespace {
|
||||
size_t calculateLength(const DiskWriterEntryHandle entry,
|
||||
off_t fileOffset, size_t rem)
|
||||
{
|
||||
size_t length;
|
||||
if(entry->getFileEntry()->getLength() < (uint64_t)fileOffset+rem) {
|
||||
|
@ -352,6 +357,7 @@ static size_t calculateLength(const DiskWriterEntryHandle entry,
|
|||
}
|
||||
return length;
|
||||
}
|
||||
} // namespace
|
||||
|
||||
namespace {
|
||||
class OffsetCompare {
|
||||
|
@ -363,8 +369,8 @@ public:
|
|||
};
|
||||
} // namespace
|
||||
|
||||
static DiskWriterEntries::const_iterator
|
||||
findFirstDiskWriterEntry
|
||||
namespace {
|
||||
DiskWriterEntries::const_iterator findFirstDiskWriterEntry
|
||||
(const DiskWriterEntries& diskWriterEntries, off_t offset)
|
||||
{
|
||||
DiskWriterEntries::const_iterator first =
|
||||
|
@ -381,15 +387,18 @@ findFirstDiskWriterEntry
|
|||
}
|
||||
return first;
|
||||
}
|
||||
} // namespace
|
||||
|
||||
static void throwOnDiskWriterNotOpened(const SharedHandle<DiskWriterEntry>& e,
|
||||
off_t offset)
|
||||
namespace {
|
||||
void throwOnDiskWriterNotOpened(const SharedHandle<DiskWriterEntry>& e,
|
||||
off_t offset)
|
||||
{
|
||||
throw DL_ABORT_EX
|
||||
(StringFormat("DiskWriter for offset=%s, filename=%s is not opened.",
|
||||
util::itos(offset).c_str(),
|
||||
e->getFilePath().c_str()).str());
|
||||
}
|
||||
} // namespace
|
||||
|
||||
void MultiDiskAdaptor::writeData(const unsigned char* data, size_t len,
|
||||
off_t offset)
|
||||
|
|
|
@ -73,7 +73,8 @@ extern volatile sig_atomic_t globalHaltRequested;
|
|||
|
||||
} // namespace global
|
||||
|
||||
static void handler(int signal) {
|
||||
namespace {
|
||||
void handler(int signal) {
|
||||
if(
|
||||
#ifdef SIGHUP
|
||||
signal == SIGHUP ||
|
||||
|
@ -90,6 +91,7 @@ static void handler(int signal) {
|
|||
}
|
||||
}
|
||||
}
|
||||
} // namespace
|
||||
|
||||
MultiUrlRequestInfo::MultiUrlRequestInfo
|
||||
(const std::vector<SharedHandle<RequestGroup> >& requestGroups,
|
||||
|
|
|
@ -55,8 +55,9 @@ OptionParser::OptionParser():
|
|||
idCounter_(0)
|
||||
{}
|
||||
|
||||
namespace {
|
||||
template<typename InputIterator>
|
||||
static size_t countPublicOption(InputIterator first, InputIterator last)
|
||||
size_t countPublicOption(InputIterator first, InputIterator last)
|
||||
{
|
||||
size_t count = 0;
|
||||
for(; first != last; ++first) {
|
||||
|
@ -66,10 +67,12 @@ static size_t countPublicOption(InputIterator first, InputIterator last)
|
|||
}
|
||||
return count;
|
||||
}
|
||||
} // namespace
|
||||
|
||||
namespace {
|
||||
template<typename InputIterator>
|
||||
static void putOptions(struct option* longOpts, int* plopt,
|
||||
InputIterator first, InputIterator last)
|
||||
void putOptions(struct option* longOpts, int* plopt,
|
||||
InputIterator first, InputIterator last)
|
||||
{
|
||||
for(; first != last; ++first) {
|
||||
if(!(*first)->isHidden()) {
|
||||
|
@ -106,9 +109,11 @@ static void putOptions(struct option* longOpts, int* plopt,
|
|||
(*longOpts).flag = 0;
|
||||
(*longOpts).val = 0;
|
||||
}
|
||||
} // namespace
|
||||
|
||||
namespace {
|
||||
template<typename InputIterator>
|
||||
static std::string createOptstring(InputIterator first, InputIterator last)
|
||||
std::string createOptstring(InputIterator first, InputIterator last)
|
||||
{
|
||||
std::string str = "";
|
||||
for(; first != last; ++first) {
|
||||
|
@ -125,6 +130,7 @@ static std::string createOptstring(InputIterator first, InputIterator last)
|
|||
}
|
||||
return str;
|
||||
}
|
||||
} // namespace
|
||||
|
||||
void OptionParser::parseArg
|
||||
(std::ostream& out, std::vector<std::string>& nonopts,
|
||||
|
@ -306,8 +312,9 @@ std::vector<SharedHandle<OptionHandler> > OptionParser::findAll() const
|
|||
return result;
|
||||
}
|
||||
|
||||
namespace {
|
||||
template<typename InputIterator, typename Predicate>
|
||||
static SharedHandle<OptionHandler> findOptionHandler
|
||||
SharedHandle<OptionHandler> findOptionHandler
|
||||
(InputIterator first, InputIterator last, Predicate pred)
|
||||
{
|
||||
SharedHandle<OptionHandler> handler;
|
||||
|
@ -317,6 +324,7 @@ static SharedHandle<OptionHandler> findOptionHandler
|
|||
}
|
||||
return handler;
|
||||
}
|
||||
} // namespace
|
||||
|
||||
SharedHandle<OptionHandler>
|
||||
OptionParser::findByName(const std::string& name) const
|
||||
|
|
|
@ -164,13 +164,15 @@ const std::vector<size_t>& PeerSessionResource::peerAllowedIndexSet() const
|
|||
return peerAllowedIndexSet_;
|
||||
}
|
||||
|
||||
static void updateIndexSet(std::vector<size_t>& c, size_t index)
|
||||
namespace {
|
||||
void updateIndexSet(std::vector<size_t>& c, size_t index)
|
||||
{
|
||||
std::vector<size_t>::iterator i = std::lower_bound(c.begin(), c.end(), index);
|
||||
if(i == c.end() || (*i) != index) {
|
||||
c.insert(i, index);
|
||||
}
|
||||
}
|
||||
} // namespace
|
||||
|
||||
void PeerSessionResource::addPeerAllowedIndex(size_t index)
|
||||
{
|
||||
|
|
|
@ -144,7 +144,8 @@ void PortEventPoll::poll(const struct timeval& tv)
|
|||
// DHTEntryPoint...Command)
|
||||
}
|
||||
|
||||
static int translateEvents(EventPoll::EventType events)
|
||||
namespace {
|
||||
int translateEvents(EventPoll::EventType events)
|
||||
{
|
||||
int newEvents = 0;
|
||||
if(EventPoll::EVENT_READ&events) {
|
||||
|
@ -161,6 +162,7 @@ static int translateEvents(EventPoll::EventType events)
|
|||
}
|
||||
return newEvents;
|
||||
}
|
||||
} // namespace
|
||||
|
||||
bool PortEventPoll::addEvents(sock_t socket,
|
||||
const PortEventPoll::KEvent& event)
|
||||
|
|
|
@ -70,7 +70,8 @@ Request::Request():
|
|||
connectedPort_(0)
|
||||
{}
|
||||
|
||||
static std::string removeFragment(const std::string& uri)
|
||||
namespace {
|
||||
std::string removeFragment(const std::string& uri)
|
||||
{
|
||||
std::string::size_type sharpIndex = uri.find("#");
|
||||
if(sharpIndex == std::string::npos) {
|
||||
|
@ -79,14 +80,10 @@ static std::string removeFragment(const std::string& uri)
|
|||
return uri.substr(0, sharpIndex);
|
||||
}
|
||||
}
|
||||
} // namespace
|
||||
|
||||
static bool isHexNumber(const char c)
|
||||
{
|
||||
return ('0' <= c && c <= '9') || ('A' <= c && c <= 'F') ||
|
||||
('a' <= c && c <= 'f');
|
||||
}
|
||||
|
||||
static std::string percentEncode(const std::string& src)
|
||||
namespace {
|
||||
std::string percentEncode(const std::string& src)
|
||||
{
|
||||
std::string result = src;
|
||||
if(src.empty()) {
|
||||
|
@ -98,7 +95,8 @@ static std::string percentEncode(const std::string& src)
|
|||
// '/' is not percent encoded because src is expected to be a path.
|
||||
if(!util::inRFC3986ReservedChars(c) && !util::inRFC3986UnreservedChars(c)) {
|
||||
if(c == '%') {
|
||||
if(!isHexNumber(result[index+1]) || !isHexNumber(result[index+2])) {
|
||||
if(!util::isHexDigit(result[index+1]) ||
|
||||
!util::isHexDigit(result[index+2])) {
|
||||
result.replace(index, 1, "%25");
|
||||
}
|
||||
} else {
|
||||
|
@ -109,6 +107,7 @@ static std::string percentEncode(const std::string& src)
|
|||
result.erase(result.size()-2);
|
||||
return result;
|
||||
}
|
||||
} // namespace
|
||||
|
||||
bool Request::setUri(const std::string& uri) {
|
||||
supportsPersistentConnection_ = true;
|
||||
|
|
|
@ -164,8 +164,9 @@ SharedHandle<RequestGroup> RequestGroupMan::getRequestGroup(size_t index) const
|
|||
}
|
||||
}
|
||||
|
||||
namespace {
|
||||
template<typename Iterator>
|
||||
static Iterator findByGID(Iterator first, Iterator last, gid_t gid)
|
||||
Iterator findByGID(Iterator first, Iterator last, gid_t gid)
|
||||
{
|
||||
for(; first != last; ++first) {
|
||||
if((*first)->getGID() == gid) {
|
||||
|
@ -174,6 +175,7 @@ static Iterator findByGID(Iterator first, Iterator last, gid_t gid)
|
|||
}
|
||||
return first;
|
||||
}
|
||||
} // namespace
|
||||
|
||||
SharedHandle<RequestGroup>
|
||||
RequestGroupMan::findRequestGroup(gid_t gid) const
|
||||
|
@ -255,7 +257,8 @@ bool RequestGroupMan::removeReservedGroup(gid_t gid)
|
|||
}
|
||||
}
|
||||
|
||||
static void executeStopHook
|
||||
namespace {
|
||||
void executeStopHook
|
||||
(const SharedHandle<DownloadResult>& result, const Option* option)
|
||||
{
|
||||
if(result->result == downloadresultcode::FINISHED &&
|
||||
|
@ -271,6 +274,7 @@ static void executeStopHook
|
|||
util::itos(result->gid));
|
||||
}
|
||||
}
|
||||
} // namespace
|
||||
|
||||
namespace {
|
||||
class ProcessStoppedRequestGroup {
|
||||
|
@ -471,12 +475,14 @@ void RequestGroupMan::configureRequestGroup
|
|||
}
|
||||
}
|
||||
|
||||
static void createInitialCommand(const SharedHandle<RequestGroup>& requestGroup,
|
||||
std::vector<Command*>& commands,
|
||||
namespace {
|
||||
void createInitialCommand(const SharedHandle<RequestGroup>& requestGroup,
|
||||
std::vector<Command*>& commands,
|
||||
DownloadEngine* e)
|
||||
{
|
||||
requestGroup->createInitialCommand(commands, e);
|
||||
}
|
||||
} // namespace
|
||||
|
||||
void RequestGroupMan::fillRequestGroupFromReserver(DownloadEngine* e)
|
||||
{
|
||||
|
@ -696,11 +702,12 @@ std::string RequestGroupMan::formatDownloadResult(const std::string& status, con
|
|||
return o.str();
|
||||
}
|
||||
|
||||
namespace {
|
||||
template<typename StringInputIterator, typename FileEntryInputIterator>
|
||||
static bool sameFilePathExists(StringInputIterator sfirst,
|
||||
StringInputIterator slast,
|
||||
FileEntryInputIterator ffirst,
|
||||
FileEntryInputIterator flast)
|
||||
bool sameFilePathExists(StringInputIterator sfirst,
|
||||
StringInputIterator slast,
|
||||
FileEntryInputIterator ffirst,
|
||||
FileEntryInputIterator flast)
|
||||
{
|
||||
for(; ffirst != flast; ++ffirst) {
|
||||
if(std::binary_search(sfirst, slast, (*ffirst)->getPath())) {
|
||||
|
@ -709,6 +716,7 @@ static bool sameFilePathExists(StringInputIterator sfirst,
|
|||
}
|
||||
return false;
|
||||
}
|
||||
} // namespace
|
||||
|
||||
bool RequestGroupMan::isSameFileBeingDownloaded(RequestGroup* requestGroup) const
|
||||
{
|
||||
|
|
|
@ -225,13 +225,15 @@ void SelectEventPoll::poll(const struct timeval& tv)
|
|||
}
|
||||
|
||||
#ifdef __MINGW32__
|
||||
static void checkFdCountMingw(const fd_set& fdset, Logger* logger)
|
||||
namespace {
|
||||
void checkFdCountMingw(const fd_set& fdset, Logger* logger)
|
||||
{
|
||||
if(fdset.fd_count >= FD_SETSIZE) {
|
||||
logger->warn("The number of file descriptor exceeded FD_SETSIZE. "
|
||||
"Download may slow down or fail.");
|
||||
}
|
||||
}
|
||||
} // namespace
|
||||
#endif // __MINGW32__
|
||||
|
||||
void SelectEventPoll::updateFdSet()
|
||||
|
|
|
@ -77,15 +77,18 @@ bool SessionSerializer::save(const std::string& filename) const
|
|||
}
|
||||
|
||||
|
||||
static const std::vector<std::string>& getCumulativeOpts()
|
||||
namespace {
|
||||
const std::vector<std::string>& getCumulativeOpts()
|
||||
{
|
||||
static std::string cumulativeOpts[] = { PREF_INDEX_OUT, PREF_HEADER };
|
||||
static std::vector<std::string> opts
|
||||
(vbegin(cumulativeOpts), vend(cumulativeOpts));
|
||||
return opts;
|
||||
}
|
||||
} // namespace
|
||||
|
||||
static bool inCumulativeOpts(const std::string& opt)
|
||||
namespace {
|
||||
bool inCumulativeOpts(const std::string& opt)
|
||||
{
|
||||
const std::vector<std::string>& cumopts = getCumulativeOpts();
|
||||
for(std::vector<std::string>::const_iterator itr = cumopts.begin(),
|
||||
|
@ -96,8 +99,10 @@ static bool inCumulativeOpts(const std::string& opt)
|
|||
}
|
||||
return false;
|
||||
}
|
||||
} // namespace
|
||||
|
||||
static void writeOption(std::ostream& out, const SharedHandle<Option>& op)
|
||||
namespace {
|
||||
void writeOption(std::ostream& out, const SharedHandle<Option>& op)
|
||||
{
|
||||
const std::set<std::string>& requestOptions = listRequestOptions();
|
||||
for(std::set<std::string>::const_iterator itr = requestOptions.begin(),
|
||||
|
@ -123,8 +128,10 @@ static void writeOption(std::ostream& out, const SharedHandle<Option>& op)
|
|||
}
|
||||
}
|
||||
}
|
||||
} // namespace
|
||||
|
||||
static void writeDownloadResult
|
||||
namespace {
|
||||
void writeDownloadResult
|
||||
(std::ostream& out, std::set<int64_t>& metainfoCache,
|
||||
const SharedHandle<DownloadResult>& dr)
|
||||
{
|
||||
|
@ -156,6 +163,7 @@ static void writeDownloadResult
|
|||
}
|
||||
writeOption(out, dr->option);
|
||||
}
|
||||
} // namespace
|
||||
|
||||
void SessionSerializer::save(std::ostream& out) const
|
||||
{
|
||||
|
|
|
@ -49,11 +49,13 @@ SimpleLogFormatter::SimpleLogFormatter() {}
|
|||
|
||||
SimpleLogFormatter::~SimpleLogFormatter() {}
|
||||
|
||||
static void writeHeader
|
||||
namespace {
|
||||
void writeHeader
|
||||
(std::ostream& o, const std::string& date, const std::string& logLevelLabel)
|
||||
{
|
||||
o << StringFormat("%s %s - ", date.c_str(), logLevelLabel.c_str());
|
||||
}
|
||||
} // namespace
|
||||
|
||||
void SimpleLogFormatter::writeLog
|
||||
(std::ostream& o, Logger::LEVEL level, const std::string& logLevelLabel,
|
||||
|
|
|
@ -70,7 +70,8 @@ Sqlite3CookieParser::~Sqlite3CookieParser()
|
|||
sqlite3_close(db_);
|
||||
}
|
||||
|
||||
static std::string toString(const char* str)
|
||||
namespace {
|
||||
std::string toString(const char* str)
|
||||
{
|
||||
if(str) {
|
||||
return str;
|
||||
|
@ -78,8 +79,10 @@ static std::string toString(const char* str)
|
|||
return A2STR::NIL;
|
||||
}
|
||||
}
|
||||
} // namespace
|
||||
|
||||
static bool parseTime(int64_t& time, const std::string& s)
|
||||
namespace {
|
||||
bool parseTime(int64_t& time, const std::string& s)
|
||||
{
|
||||
if(!util::parseLLIntNoThrow(time, s)) {
|
||||
return false;
|
||||
|
@ -91,9 +94,10 @@ static bool parseTime(int64_t& time, const std::string& s)
|
|||
}
|
||||
return true;
|
||||
}
|
||||
} // namespace
|
||||
|
||||
static int cookieRowMapper(void* data, int columns,
|
||||
char** values, char** names)
|
||||
namespace {
|
||||
int cookieRowMapper(void* data, int columns, char** values, char** names)
|
||||
{
|
||||
if(columns != 7) {
|
||||
return 0;
|
||||
|
@ -129,6 +133,7 @@ static int cookieRowMapper(void* data, int columns,
|
|||
cookies.push_back(c);
|
||||
return 0;
|
||||
}
|
||||
} // namespace
|
||||
|
||||
void Sqlite3CookieParser::parse(std::vector<Cookie>& cookies)
|
||||
{
|
||||
|
|
|
@ -197,7 +197,8 @@ SharedHandle<RequestGroup> TrackerWatcherCommand::createAnnounce() {
|
|||
return rg;
|
||||
}
|
||||
|
||||
static bool backupTrackerIsAvailable
|
||||
namespace {
|
||||
bool backupTrackerIsAvailable
|
||||
(const SharedHandle<DownloadContext>& context)
|
||||
{
|
||||
SharedHandle<TorrentAttribute> torrentAttrs =
|
||||
|
@ -214,6 +215,7 @@ static bool backupTrackerIsAvailable
|
|||
return false;
|
||||
}
|
||||
}
|
||||
} // namespace
|
||||
|
||||
SharedHandle<RequestGroup>
|
||||
TrackerWatcherCommand::createRequestGroup(const std::string& uri)
|
||||
|
|
|
@ -58,7 +58,8 @@ public:
|
|||
};
|
||||
} // namespace
|
||||
|
||||
static void mlStartElement
|
||||
namespace {
|
||||
void mlStartElement
|
||||
(void* userData,
|
||||
const xmlChar* srcLocalname,
|
||||
const xmlChar* srcPrefix,
|
||||
|
@ -102,8 +103,10 @@ static void mlStartElement
|
|||
sd->charactersStack_.push_front(A2STR::NIL);
|
||||
}
|
||||
}
|
||||
} // namespace
|
||||
|
||||
static void mlEndElement
|
||||
namespace {
|
||||
void mlEndElement
|
||||
(void* userData,
|
||||
const xmlChar* srcLocalname,
|
||||
const xmlChar* srcPrefix,
|
||||
|
@ -126,16 +129,20 @@ static void mlEndElement
|
|||
}
|
||||
sd->stm_->endElement(localname, prefix, nsUri, characters);
|
||||
}
|
||||
} // namespace
|
||||
|
||||
static void mlCharacters(void* userData, const xmlChar* ch, int len)
|
||||
namespace {
|
||||
void mlCharacters(void* userData, const xmlChar* ch, int len)
|
||||
{
|
||||
SessionData* sd = reinterpret_cast<SessionData*>(userData);
|
||||
if(sd->stm_->needsCharactersBuffering()) {
|
||||
sd->charactersStack_.front() += std::string(&ch[0], &ch[len]);
|
||||
}
|
||||
}
|
||||
} // namespace
|
||||
|
||||
static xmlSAXHandler mySAXHandler =
|
||||
namespace {
|
||||
xmlSAXHandler mySAXHandler =
|
||||
{
|
||||
0, // internalSubsetSAXFunc
|
||||
0, // isStandaloneSAXFunc
|
||||
|
@ -170,6 +177,7 @@ static xmlSAXHandler mySAXHandler =
|
|||
&mlEndElement, // endElementNsSAX2Func
|
||||
0, // xmlStructuredErrorFunc
|
||||
};
|
||||
} // namespace
|
||||
|
||||
SharedHandle<Metalinker>
|
||||
MetalinkProcessor::parseFile(const std::string& filename)
|
||||
|
|
|
@ -57,8 +57,9 @@ struct SessionData {
|
|||
};
|
||||
} // namespace
|
||||
|
||||
static void mlStartElement(void* userData, const xmlChar* name,
|
||||
const xmlChar** attrs)
|
||||
namespace {
|
||||
void mlStartElement(void* userData, const xmlChar* name,
|
||||
const xmlChar** attrs)
|
||||
{
|
||||
SessionData* sd = reinterpret_cast<SessionData*>(userData);
|
||||
std::map<std::string, std::string> attrmap;
|
||||
|
@ -80,8 +81,10 @@ static void mlStartElement(void* userData, const xmlChar* name,
|
|||
sd->charactersStack_.push(std::string());
|
||||
}
|
||||
}
|
||||
} // namespace
|
||||
|
||||
static void mlEndElement(void* userData, const xmlChar* name)
|
||||
namespace {
|
||||
void mlEndElement(void* userData, const xmlChar* name)
|
||||
{
|
||||
SessionData* sd = reinterpret_cast<SessionData*>(userData);
|
||||
std::string characters;
|
||||
|
@ -91,16 +94,20 @@ static void mlEndElement(void* userData, const xmlChar* name)
|
|||
}
|
||||
sd->stm_->endElement(reinterpret_cast<const char*>(name), characters);
|
||||
}
|
||||
} // namespace
|
||||
|
||||
static void mlCharacters(void* userData, const xmlChar* ch, int len)
|
||||
namespace {
|
||||
void mlCharacters(void* userData, const xmlChar* ch, int len)
|
||||
{
|
||||
SessionData* sd = reinterpret_cast<SessionData*>(userData);
|
||||
if(sd->stm_->needsCharactersBuffering()) {
|
||||
sd->charactersStack_.top() += std::string(&ch[0], &ch[len]);
|
||||
}
|
||||
}
|
||||
} // namespace
|
||||
|
||||
static xmlSAXHandler mySAXHandler =
|
||||
namespace {
|
||||
xmlSAXHandler mySAXHandler =
|
||||
{
|
||||
0, // internalSubsetSAXFunc
|
||||
0, // isStandaloneSAXFunc
|
||||
|
@ -135,6 +142,7 @@ static xmlSAXHandler mySAXHandler =
|
|||
0, // endElementNsSAX2Func
|
||||
0, // xmlStructuredErrorFunc
|
||||
};
|
||||
} // namespace
|
||||
|
||||
XmlRpcRequest
|
||||
XmlRpcRequestProcessor::parseMemory(const std::string& xml)
|
||||
|
|
|
@ -83,8 +83,9 @@ XmlRpcResponse XmlRpcMethod::execute
|
|||
}
|
||||
}
|
||||
|
||||
namespace {
|
||||
template<typename InputIterator>
|
||||
static void gatherOption
|
||||
void gatherOption
|
||||
(InputIterator first, InputIterator last,
|
||||
const std::set<std::string>& allowedOptions,
|
||||
const SharedHandle<Option>& option,
|
||||
|
@ -126,6 +127,7 @@ static void gatherOption
|
|||
}
|
||||
}
|
||||
}
|
||||
} // namespace
|
||||
|
||||
void XmlRpcMethod::gatherRequestOption
|
||||
(const SharedHandle<Option>& option, const Dict* optionsDict)
|
||||
|
@ -137,13 +139,14 @@ void XmlRpcMethod::gatherRequestOption
|
|||
}
|
||||
}
|
||||
|
||||
namespace {
|
||||
// Copy option in the range [optNameFirst, optNameLast) from src to
|
||||
// dest.
|
||||
template<typename InputIterator>
|
||||
static void applyOption(InputIterator optNameFirst,
|
||||
InputIterator optNameLast,
|
||||
Option* dest,
|
||||
Option* src)
|
||||
void applyOption(InputIterator optNameFirst,
|
||||
InputIterator optNameLast,
|
||||
Option* dest,
|
||||
Option* src)
|
||||
{
|
||||
for(; optNameFirst != optNameLast; ++optNameFirst) {
|
||||
if(src->defined(*optNameFirst)) {
|
||||
|
@ -151,6 +154,7 @@ static void applyOption(InputIterator optNameFirst,
|
|||
}
|
||||
}
|
||||
}
|
||||
} // namespace
|
||||
|
||||
const std::set<std::string>& listChangeableOptions()
|
||||
{
|
||||
|
|
|
@ -139,12 +139,15 @@ const std::string KEY_MODE = "mode";
|
|||
const std::string KEY_SERVERS = "servers";
|
||||
} // namespace
|
||||
|
||||
static SharedHandle<ValueBase> createGIDResponse(gid_t gid)
|
||||
namespace {
|
||||
SharedHandle<ValueBase> createGIDResponse(gid_t gid)
|
||||
{
|
||||
return String::g(util::itos(gid));
|
||||
}
|
||||
} // namespace
|
||||
|
||||
static SharedHandle<ValueBase>
|
||||
namespace {
|
||||
SharedHandle<ValueBase>
|
||||
addRequestGroup(const SharedHandle<RequestGroup>& group,
|
||||
DownloadEngine* e,
|
||||
bool posGiven, int pos)
|
||||
|
@ -156,8 +159,9 @@ addRequestGroup(const SharedHandle<RequestGroup>& group,
|
|||
}
|
||||
return createGIDResponse(group->getGID());
|
||||
}
|
||||
} // namespace
|
||||
|
||||
static
|
||||
namespace {
|
||||
SharedHandle<RequestGroup>
|
||||
findRequestGroup(const SharedHandle<RequestGroupMan>& rgman, gid_t gid)
|
||||
{
|
||||
|
@ -167,8 +171,10 @@ findRequestGroup(const SharedHandle<RequestGroupMan>& rgman, gid_t gid)
|
|||
}
|
||||
return group;
|
||||
}
|
||||
} // namespace
|
||||
|
||||
static void getPosParam(const XmlRpcRequest& req, size_t posParamIndex,
|
||||
namespace {
|
||||
void getPosParam(const XmlRpcRequest& req, size_t posParamIndex,
|
||||
bool& posGiven, size_t& pos)
|
||||
{
|
||||
const Integer* p = req.getIntegerParam(posParamIndex);
|
||||
|
@ -183,8 +189,10 @@ static void getPosParam(const XmlRpcRequest& req, size_t posParamIndex,
|
|||
}
|
||||
posGiven = false;
|
||||
}
|
||||
} // namespace
|
||||
|
||||
static gid_t getRequiredGidParam
|
||||
namespace {
|
||||
gid_t getRequiredGidParam
|
||||
(const XmlRpcRequest& req, size_t posParamIndex)
|
||||
{
|
||||
const String* gidParam = req.getStringParam(posParamIndex);
|
||||
|
@ -194,9 +202,11 @@ static gid_t getRequiredGidParam
|
|||
throw DL_ABORT_EX(MSG_GID_NOT_PROVIDED);
|
||||
}
|
||||
}
|
||||
} // namespace
|
||||
|
||||
namespace {
|
||||
template<typename OutputIterator>
|
||||
static void extractUris(OutputIterator out, const List* src)
|
||||
void extractUris(OutputIterator out, const List* src)
|
||||
{
|
||||
if(src) {
|
||||
for(List::ValueType::const_iterator i = src->begin(), eoi = src->end();
|
||||
|
@ -208,6 +218,7 @@ static void extractUris(OutputIterator out, const List* src)
|
|||
}
|
||||
}
|
||||
}
|
||||
} // namespace
|
||||
|
||||
SharedHandle<ValueBase> AddUriXmlRpcMethod::process
|
||||
(const XmlRpcRequest& req, DownloadEngine* e)
|
||||
|
@ -302,7 +313,8 @@ SharedHandle<ValueBase> AddMetalinkXmlRpcMethod::process
|
|||
}
|
||||
#endif // ENABLE_METALINK
|
||||
|
||||
static SharedHandle<ValueBase> removeDownload
|
||||
namespace {
|
||||
SharedHandle<ValueBase> removeDownload
|
||||
(const XmlRpcRequest& req, DownloadEngine* e, bool forceRemove)
|
||||
{
|
||||
gid_t gid = getRequiredGidParam(req, 0);
|
||||
|
@ -332,6 +344,7 @@ static SharedHandle<ValueBase> removeDownload
|
|||
}
|
||||
return createGIDResponse(gid);
|
||||
}
|
||||
} // namespace
|
||||
|
||||
SharedHandle<ValueBase> RemoveXmlRpcMethod::process
|
||||
(const XmlRpcRequest& req, DownloadEngine* e)
|
||||
|
@ -345,7 +358,8 @@ SharedHandle<ValueBase> ForceRemoveXmlRpcMethod::process
|
|||
return removeDownload(req, e, true);
|
||||
}
|
||||
|
||||
static bool pauseRequestGroup
|
||||
namespace {
|
||||
bool pauseRequestGroup
|
||||
(const SharedHandle<RequestGroup>& group, bool reserved, bool forcePause)
|
||||
{
|
||||
if((reserved && !group->isPauseRequested()) ||
|
||||
|
@ -368,8 +382,10 @@ static bool pauseRequestGroup
|
|||
return false;
|
||||
}
|
||||
}
|
||||
} // namespace
|
||||
|
||||
static SharedHandle<ValueBase> pauseDownload
|
||||
namespace {
|
||||
SharedHandle<ValueBase> pauseDownload
|
||||
(const XmlRpcRequest& req, DownloadEngine* e, bool forcePause)
|
||||
{
|
||||
gid_t gid = getRequiredGidParam(req, 0);
|
||||
|
@ -389,6 +405,7 @@ static SharedHandle<ValueBase> pauseDownload
|
|||
util::itos(gid).c_str()).str());
|
||||
}
|
||||
}
|
||||
} // namespace
|
||||
|
||||
SharedHandle<ValueBase> PauseXmlRpcMethod::process
|
||||
(const XmlRpcRequest& req, DownloadEngine* e)
|
||||
|
@ -402,16 +419,19 @@ SharedHandle<ValueBase> ForcePauseXmlRpcMethod::process
|
|||
return pauseDownload(req, e, true);
|
||||
}
|
||||
|
||||
namespace {
|
||||
template<typename InputIterator>
|
||||
static void pauseRequestGroups
|
||||
void pauseRequestGroups
|
||||
(InputIterator first, InputIterator last, bool reserved, bool forcePause)
|
||||
{
|
||||
for(; first != last; ++first) {
|
||||
pauseRequestGroup(*first, reserved, forcePause);
|
||||
}
|
||||
}
|
||||
} // namespace
|
||||
|
||||
static SharedHandle<ValueBase> pauseAllDownloads
|
||||
namespace {
|
||||
SharedHandle<ValueBase> pauseAllDownloads
|
||||
(const XmlRpcRequest& req, DownloadEngine* e, bool forcePause)
|
||||
{
|
||||
const std::deque<SharedHandle<RequestGroup> >& groups =
|
||||
|
@ -423,6 +443,7 @@ static SharedHandle<ValueBase> pauseAllDownloads
|
|||
true, forcePause);
|
||||
return VLB_OK;
|
||||
}
|
||||
} // namespace
|
||||
|
||||
SharedHandle<ValueBase> PauseAllXmlRpcMethod::process
|
||||
(const XmlRpcRequest& req, DownloadEngine* e)
|
||||
|
@ -465,8 +486,9 @@ SharedHandle<ValueBase> UnpauseAllXmlRpcMethod::process
|
|||
return VLB_OK;
|
||||
}
|
||||
|
||||
namespace {
|
||||
template<typename InputIterator>
|
||||
static void createUriEntry
|
||||
void createUriEntry
|
||||
(const SharedHandle<List>& uriList,
|
||||
InputIterator first, InputIterator last,
|
||||
const SharedHandle<String>& status)
|
||||
|
@ -478,8 +500,10 @@ static void createUriEntry
|
|||
uriList->append(entry);
|
||||
}
|
||||
}
|
||||
} // namespace
|
||||
|
||||
static void createUriEntry
|
||||
namespace {
|
||||
void createUriEntry
|
||||
(const SharedHandle<List>& uriList, const SharedHandle<FileEntry>& file)
|
||||
{
|
||||
createUriEntry(uriList,
|
||||
|
@ -491,9 +515,11 @@ static void createUriEntry
|
|||
file->getRemainingUris().end(),
|
||||
VLB_WAITING);
|
||||
}
|
||||
} // namespace
|
||||
|
||||
namespace {
|
||||
template<typename InputIterator>
|
||||
static void createFileEntry
|
||||
void createFileEntry
|
||||
(const SharedHandle<List>& files, InputIterator first, InputIterator last)
|
||||
{
|
||||
size_t index = 1;
|
||||
|
@ -510,12 +536,15 @@ static void createFileEntry
|
|||
files->append(entry);
|
||||
}
|
||||
}
|
||||
} // namespace
|
||||
|
||||
static bool requested_key
|
||||
namespace {
|
||||
bool requested_key
|
||||
(const std::vector<std::string>& keys, const std::string& k)
|
||||
{
|
||||
return keys.empty() || std::find(keys.begin(), keys.end(), k) != keys.end();
|
||||
}
|
||||
} // namespace
|
||||
|
||||
void gatherProgressCommon
|
||||
(const SharedHandle<Dict>& entryDict,
|
||||
|
@ -624,7 +653,8 @@ void gatherBitTorrentMetadata
|
|||
}
|
||||
}
|
||||
|
||||
static void gatherProgressBitTorrent
|
||||
namespace {
|
||||
void gatherProgressBitTorrent
|
||||
(const SharedHandle<Dict>& entryDict,
|
||||
const SharedHandle<TorrentAttribute>& torrentAttrs,
|
||||
const BtObject& btObject,
|
||||
|
@ -651,8 +681,10 @@ static void gatherProgressBitTorrent
|
|||
}
|
||||
}
|
||||
}
|
||||
} // namespace
|
||||
|
||||
static void gatherPeer
|
||||
namespace {
|
||||
void gatherPeer
|
||||
(const SharedHandle<List>& peers, const SharedHandle<PeerStorage>& ps)
|
||||
{
|
||||
std::vector<SharedHandle<Peer> > activePeers;
|
||||
|
@ -679,9 +711,11 @@ static void gatherPeer
|
|||
peers->append(peerEntry);
|
||||
}
|
||||
}
|
||||
} // namespace
|
||||
#endif // ENABLE_BITTORRENT
|
||||
|
||||
static void gatherProgress
|
||||
namespace {
|
||||
void gatherProgress
|
||||
(const SharedHandle<Dict>& entryDict,
|
||||
const SharedHandle<RequestGroup>& group,
|
||||
DownloadEngine* e,
|
||||
|
@ -697,6 +731,7 @@ static void gatherProgress
|
|||
}
|
||||
#endif // ENABLE_BITTORRENT
|
||||
}
|
||||
} // namespace
|
||||
|
||||
void gatherStoppedDownload
|
||||
(const SharedHandle<Dict>& entryDict, const SharedHandle<DownloadResult>& ds,
|
||||
|
@ -1047,8 +1082,9 @@ SharedHandle<ValueBase> GetVersionXmlRpcMethod::process
|
|||
return result;
|
||||
}
|
||||
|
||||
namespace {
|
||||
template<typename InputIterator>
|
||||
static void pushRequestOption
|
||||
void pushRequestOption
|
||||
(const SharedHandle<Dict>& dict,
|
||||
InputIterator optionFirst, InputIterator optionLast)
|
||||
{
|
||||
|
@ -1059,6 +1095,7 @@ static void pushRequestOption
|
|||
}
|
||||
}
|
||||
}
|
||||
} // namespace
|
||||
|
||||
SharedHandle<ValueBase> GetOptionXmlRpcMethod::process
|
||||
(const XmlRpcRequest& req, DownloadEngine* e)
|
||||
|
@ -1234,7 +1271,8 @@ SharedHandle<ValueBase> ChangeUriXmlRpcMethod::process
|
|||
return res;
|
||||
}
|
||||
|
||||
static SharedHandle<ValueBase> goingShutdown
|
||||
namespace {
|
||||
SharedHandle<ValueBase> goingShutdown
|
||||
(const XmlRpcRequest& req, DownloadEngine* e, bool forceHalt)
|
||||
{
|
||||
// Schedule shutdown after 3seconds to give time to client to
|
||||
|
@ -1243,6 +1281,7 @@ static SharedHandle<ValueBase> goingShutdown
|
|||
LogFactory::getInstance()->info("Scheduled shutdown in 3 seconds.");
|
||||
return VLB_OK;
|
||||
}
|
||||
} // namespace
|
||||
|
||||
SharedHandle<ValueBase> ShutdownXmlRpcMethod::process
|
||||
(const XmlRpcRequest& req, DownloadEngine* e)
|
||||
|
|
|
@ -46,8 +46,9 @@ namespace aria2 {
|
|||
|
||||
namespace xmlrpc {
|
||||
|
||||
namespace {
|
||||
template<typename OutputStream>
|
||||
static void encodeValue(const SharedHandle<ValueBase>& value, OutputStream& o)
|
||||
void encodeValue(const SharedHandle<ValueBase>& value, OutputStream& o)
|
||||
{
|
||||
class XmlValueBaseVisitor:public ValueBaseVisitor {
|
||||
private:
|
||||
|
@ -93,9 +94,11 @@ static void encodeValue(const SharedHandle<ValueBase>& value, OutputStream& o)
|
|||
XmlValueBaseVisitor visitor(o);
|
||||
value->accept(visitor);
|
||||
}
|
||||
} // namespace
|
||||
|
||||
namespace {
|
||||
template<typename OutputStream>
|
||||
static std::string encodeAll
|
||||
std::string encodeAll
|
||||
(OutputStream& o, int code, const SharedHandle<ValueBase>& param)
|
||||
{
|
||||
o << "<?xml version=\"1.0\"?>" << "<methodResponse>";
|
||||
|
@ -111,6 +114,7 @@ static std::string encodeAll
|
|||
o << "</methodResponse>";
|
||||
return o.str();
|
||||
}
|
||||
} // namespace
|
||||
|
||||
std::string XmlRpcResponse::toXml(bool gzip) const
|
||||
{
|
||||
|
|
|
@ -39,12 +39,14 @@ namespace aria2 {
|
|||
|
||||
namespace base32 {
|
||||
|
||||
static const char B32TABLE[] = {
|
||||
namespace {
|
||||
const char B32TABLE[] = {
|
||||
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H',
|
||||
'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P',
|
||||
'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X',
|
||||
'Y', 'Z', '2', '3', '4', '5', '6', '7'
|
||||
};
|
||||
} // namespace
|
||||
|
||||
std::string encode(const std::string& src)
|
||||
{
|
||||
|
|
|
@ -44,9 +44,12 @@ namespace aria2 {
|
|||
|
||||
namespace bencode2 {
|
||||
|
||||
static SharedHandle<ValueBase> decodeiter(std::istream& ss, size_t depth);
|
||||
namespace {
|
||||
SharedHandle<ValueBase> decodeiter(std::istream& ss, size_t depth);
|
||||
} // namespace
|
||||
|
||||
static void checkdelim(std::istream& ss, const char delim = ':')
|
||||
namespace {
|
||||
void checkdelim(std::istream& ss, const char delim = ':')
|
||||
{
|
||||
char d;
|
||||
if(!(ss.get(d) && d == delim)) {
|
||||
|
@ -55,8 +58,10 @@ static void checkdelim(std::istream& ss, const char delim = ':')
|
|||
delim).str());
|
||||
}
|
||||
}
|
||||
} // namespace
|
||||
|
||||
static std::string decoderawstring(std::istream& ss)
|
||||
namespace {
|
||||
std::string decoderawstring(std::istream& ss)
|
||||
{
|
||||
int length;
|
||||
ss >> length;
|
||||
|
@ -79,13 +84,17 @@ static std::string decoderawstring(std::istream& ss)
|
|||
}
|
||||
return str;
|
||||
}
|
||||
} // namespace
|
||||
|
||||
static SharedHandle<ValueBase> decodestring(std::istream& ss)
|
||||
namespace {
|
||||
SharedHandle<ValueBase> decodestring(std::istream& ss)
|
||||
{
|
||||
return String::g(decoderawstring(ss));
|
||||
}
|
||||
} // namespace
|
||||
|
||||
static SharedHandle<ValueBase> decodeinteger(std::istream& ss)
|
||||
namespace {
|
||||
SharedHandle<ValueBase> decodeinteger(std::istream& ss)
|
||||
{
|
||||
Integer::ValueType iv;
|
||||
ss >> iv;
|
||||
|
@ -96,8 +105,10 @@ static SharedHandle<ValueBase> decodeinteger(std::istream& ss)
|
|||
checkdelim(ss, 'e');
|
||||
return Integer::g(iv);
|
||||
}
|
||||
} // namespace
|
||||
|
||||
static SharedHandle<ValueBase> decodedict(std::istream& ss, size_t depth)
|
||||
namespace {
|
||||
SharedHandle<ValueBase> decodedict(std::istream& ss, size_t depth)
|
||||
{
|
||||
SharedHandle<Dict> dict = Dict::g();
|
||||
char c;
|
||||
|
@ -113,8 +124,10 @@ static SharedHandle<ValueBase> decodedict(std::istream& ss, size_t depth)
|
|||
throw DL_ABORT_EX("Bencode decoding failed:"
|
||||
" Unexpected EOF in dict context. 'e' expected.");
|
||||
}
|
||||
} // namespace
|
||||
|
||||
static SharedHandle<ValueBase> decodelist(std::istream& ss, size_t depth)
|
||||
namespace {
|
||||
SharedHandle<ValueBase> decodelist(std::istream& ss, size_t depth)
|
||||
{
|
||||
SharedHandle<List> list = List::g();
|
||||
char c;
|
||||
|
@ -129,15 +142,19 @@ static SharedHandle<ValueBase> decodelist(std::istream& ss, size_t depth)
|
|||
throw DL_ABORT_EX("Bencode decoding failed:"
|
||||
" Unexpected EOF in list context. 'e' expected.");
|
||||
}
|
||||
} // namespace
|
||||
|
||||
static void checkDepth(size_t depth)
|
||||
namespace {
|
||||
void checkDepth(size_t depth)
|
||||
{
|
||||
if(depth >= MAX_STRUCTURE_DEPTH) {
|
||||
throw DL_ABORT_EX("Bencode decoding failed: Structure is too deep.");
|
||||
}
|
||||
}
|
||||
} // namespace
|
||||
|
||||
static SharedHandle<ValueBase> decodeiter(std::istream& ss, size_t depth)
|
||||
namespace {
|
||||
SharedHandle<ValueBase> decodeiter(std::istream& ss, size_t depth)
|
||||
{
|
||||
checkDepth(depth);
|
||||
char c;
|
||||
|
@ -157,6 +174,7 @@ static SharedHandle<ValueBase> decodeiter(std::istream& ss, size_t depth)
|
|||
return decodestring(ss);
|
||||
}
|
||||
}
|
||||
} // namespace
|
||||
|
||||
SharedHandle<ValueBase> decode(std::istream& in)
|
||||
{
|
||||
|
|
|
@ -62,43 +62,45 @@ namespace aria2 {
|
|||
|
||||
namespace bittorrent {
|
||||
|
||||
static const std::string C_NAME("name");
|
||||
namespace {
|
||||
const std::string C_NAME("name");
|
||||
|
||||
static const std::string C_NAME_UTF8("name.utf-8");
|
||||
const std::string C_NAME_UTF8("name.utf-8");
|
||||
|
||||
static const std::string C_FILES("files");
|
||||
const std::string C_FILES("files");
|
||||
|
||||
static const std::string C_LENGTH("length");
|
||||
const std::string C_LENGTH("length");
|
||||
|
||||
static const std::string C_PATH("path");
|
||||
const std::string C_PATH("path");
|
||||
|
||||
static const std::string C_PATH_UTF8("path.utf-8");
|
||||
const std::string C_PATH_UTF8("path.utf-8");
|
||||
|
||||
static const std::string C_INFO("info");
|
||||
const std::string C_INFO("info");
|
||||
|
||||
static const std::string C_PIECES("pieces");
|
||||
const std::string C_PIECES("pieces");
|
||||
|
||||
static const std::string C_PIECE_LENGTH("piece length");
|
||||
const std::string C_PIECE_LENGTH("piece length");
|
||||
|
||||
static const std::string C_PRIVATE("private");
|
||||
const std::string C_PRIVATE("private");
|
||||
|
||||
static const std::string C_URL_LIST("url-list");
|
||||
const std::string C_URL_LIST("url-list");
|
||||
|
||||
static const std::string C_ANNOUNCE("announce");
|
||||
const std::string C_ANNOUNCE("announce");
|
||||
|
||||
static const std::string C_ANNOUNCE_LIST("announce-list");
|
||||
const std::string C_ANNOUNCE_LIST("announce-list");
|
||||
|
||||
static const std::string C_NODES("nodes");
|
||||
const std::string C_NODES("nodes");
|
||||
|
||||
static const std::string C_CREATION_DATE("creation date");
|
||||
const std::string C_CREATION_DATE("creation date");
|
||||
|
||||
static const std::string C_COMMENT("comment");
|
||||
const std::string C_COMMENT("comment");
|
||||
|
||||
static const std::string C_COMMENT_UTF8("comment.utf-8");
|
||||
const std::string C_COMMENT_UTF8("comment.utf-8");
|
||||
|
||||
static const std::string C_CREATED_BY("created by");
|
||||
const std::string C_CREATED_BY("created by");
|
||||
|
||||
static const std::string DEFAULT_PEER_ID_PREFIX("aria2-");
|
||||
const std::string DEFAULT_PEER_ID_PREFIX("aria2-");
|
||||
} // namespace
|
||||
|
||||
const std::string BITTORRENT("bittorrent");
|
||||
|
||||
|
@ -106,10 +108,11 @@ const std::string MULTI("multi");
|
|||
|
||||
const std::string SINGLE("single");
|
||||
|
||||
static void extractPieceHash(const SharedHandle<DownloadContext>& ctx,
|
||||
const std::string& hashData,
|
||||
size_t hashLength,
|
||||
size_t numPieces)
|
||||
namespace {
|
||||
void extractPieceHash(const SharedHandle<DownloadContext>& ctx,
|
||||
const std::string& hashData,
|
||||
size_t hashLength,
|
||||
size_t numPieces)
|
||||
{
|
||||
std::vector<std::string> pieceHashes;
|
||||
pieceHashes.reserve(numPieces);
|
||||
|
@ -120,8 +123,10 @@ static void extractPieceHash(const SharedHandle<DownloadContext>& ctx,
|
|||
ctx->setPieceHashes(pieceHashes.begin(), pieceHashes.end());
|
||||
ctx->setPieceHashAlgo(MessageDigestContext::SHA1);
|
||||
}
|
||||
} // namespace
|
||||
|
||||
static void extractUrlList
|
||||
namespace {
|
||||
void extractUrlList
|
||||
(const SharedHandle<TorrentAttribute>& torrent, std::vector<std::string>& uris,
|
||||
const ValueBase* v)
|
||||
{
|
||||
|
@ -162,9 +167,11 @@ static void extractUrlList
|
|||
v->accept(visitor);
|
||||
}
|
||||
}
|
||||
} // namespace
|
||||
|
||||
namespace {
|
||||
template<typename InputIterator, typename OutputIterator>
|
||||
static OutputIterator createUri
|
||||
OutputIterator createUri
|
||||
(InputIterator first, InputIterator last, OutputIterator out,
|
||||
const std::string& filePath)
|
||||
{
|
||||
|
@ -177,8 +184,10 @@ static OutputIterator createUri
|
|||
}
|
||||
return out;
|
||||
}
|
||||
} // namespace
|
||||
|
||||
static void extractFileEntries
|
||||
namespace {
|
||||
void extractFileEntries
|
||||
(const SharedHandle<DownloadContext>& ctx,
|
||||
const SharedHandle<TorrentAttribute>& torrent,
|
||||
const Dict* infoDict,
|
||||
|
@ -308,8 +317,10 @@ static void extractFileEntries
|
|||
ctx->setBasePath(util::applyDir(ctx->getDir(), utf8Name));
|
||||
}
|
||||
}
|
||||
} // namespace
|
||||
|
||||
static void extractAnnounce
|
||||
namespace {
|
||||
void extractAnnounce
|
||||
(const SharedHandle<TorrentAttribute>& torrent, const Dict* rootDict)
|
||||
{
|
||||
const List* announceList = asList(rootDict->get(C_ANNOUNCE_LIST));
|
||||
|
@ -341,8 +352,10 @@ static void extractAnnounce
|
|||
}
|
||||
}
|
||||
}
|
||||
} // namespace
|
||||
|
||||
static void extractNodes
|
||||
namespace {
|
||||
void extractNodes
|
||||
(const SharedHandle<TorrentAttribute>& torrent, const ValueBase* nodesListSrc)
|
||||
{
|
||||
const List* nodesList = asList(nodesListSrc);
|
||||
|
@ -368,8 +381,10 @@ static void extractNodes
|
|||
}
|
||||
}
|
||||
}
|
||||
} // namespace
|
||||
|
||||
static void processRootDictionary
|
||||
namespace {
|
||||
void processRootDictionary
|
||||
(const SharedHandle<DownloadContext>& ctx,
|
||||
const SharedHandle<ValueBase>& root,
|
||||
const std::string& defaultName,
|
||||
|
@ -474,6 +489,7 @@ static void processRootDictionary
|
|||
|
||||
ctx->setAttribute(BITTORRENT, torrent);
|
||||
}
|
||||
} // namespace
|
||||
|
||||
void load(const std::string& torrentFile,
|
||||
const SharedHandle<DownloadContext>& ctx,
|
||||
|
@ -671,7 +687,9 @@ std::string generatePeerId(const std::string& peerIdPrefix)
|
|||
return peerId;
|
||||
}
|
||||
|
||||
static std::string peerId;
|
||||
namespace {
|
||||
std::string peerId;
|
||||
} // namespace
|
||||
|
||||
const std::string& generateStaticPeerId(const std::string& peerIdPrefix)
|
||||
{
|
||||
|
|
|
@ -172,7 +172,8 @@ const std::set<std::string>& listRequestOptions()
|
|||
return requestOptions;
|
||||
}
|
||||
|
||||
static void unfoldURI
|
||||
namespace {
|
||||
void unfoldURI
|
||||
(std::vector<std::string>& result, const std::vector<std::string>& args)
|
||||
{
|
||||
ParameterizedStringParser p;
|
||||
|
@ -184,13 +185,15 @@ static void unfoldURI
|
|||
result.insert(result.end(), v.getURIs().begin(), v.getURIs().end());
|
||||
}
|
||||
}
|
||||
} // namespace
|
||||
|
||||
namespace {
|
||||
template<typename InputIterator>
|
||||
static void splitURI(std::vector<std::string>& result,
|
||||
InputIterator begin,
|
||||
InputIterator end,
|
||||
size_t numSplit,
|
||||
size_t maxIter)
|
||||
void splitURI(std::vector<std::string>& result,
|
||||
InputIterator begin,
|
||||
InputIterator end,
|
||||
size_t numSplit,
|
||||
size_t maxIter)
|
||||
{
|
||||
size_t numURIs = std::distance(begin, end);
|
||||
if(numURIs >= numSplit) {
|
||||
|
@ -205,8 +208,10 @@ static void splitURI(std::vector<std::string>& result,
|
|||
}
|
||||
}
|
||||
}
|
||||
} // namespace
|
||||
|
||||
static SharedHandle<RequestGroup> createRequestGroup
|
||||
namespace {
|
||||
SharedHandle<RequestGroup> createRequestGroup
|
||||
(const SharedHandle<Option>& option, const std::vector<std::string>& uris,
|
||||
bool useOutOption = false)
|
||||
{
|
||||
|
@ -224,22 +229,27 @@ static SharedHandle<RequestGroup> createRequestGroup
|
|||
rg->setDownloadContext(dctx);
|
||||
return rg;
|
||||
}
|
||||
} // namespace
|
||||
|
||||
#if defined ENABLE_BITTORRENT || ENABLE_METALINK
|
||||
static SharedHandle<MetadataInfo> createMetadataInfo(const std::string& uri)
|
||||
namespace {
|
||||
SharedHandle<MetadataInfo> createMetadataInfo(const std::string& uri)
|
||||
{
|
||||
return SharedHandle<MetadataInfo>(new MetadataInfo(uri));
|
||||
}
|
||||
} // namespace
|
||||
|
||||
static SharedHandle<MetadataInfo> createMetadataInfoDataOnly()
|
||||
namespace {
|
||||
SharedHandle<MetadataInfo> createMetadataInfoDataOnly()
|
||||
{
|
||||
return SharedHandle<MetadataInfo>(new MetadataInfo());
|
||||
}
|
||||
} // namespace
|
||||
#endif // ENABLE_BITTORRENT || ENABLE_METALINK
|
||||
|
||||
#ifdef ENABLE_BITTORRENT
|
||||
|
||||
static
|
||||
namespace {
|
||||
SharedHandle<RequestGroup>
|
||||
createBtRequestGroup(const std::string& torrentFilePath,
|
||||
const SharedHandle<Option>& option,
|
||||
|
@ -277,8 +287,9 @@ createBtRequestGroup(const std::string& torrentFilePath,
|
|||
util::removeMetalinkContentTypes(rg);
|
||||
return rg;
|
||||
}
|
||||
} // namespace
|
||||
|
||||
static
|
||||
namespace {
|
||||
SharedHandle<RequestGroup>
|
||||
createBtMagnetRequestGroup(const std::string& magnetLink,
|
||||
const SharedHandle<Option>& option,
|
||||
|
@ -308,6 +319,7 @@ createBtMagnetRequestGroup(const std::string& magnetLink,
|
|||
rg->setMetadataInfo(createMetadataInfo(magnetLink));
|
||||
return rg;
|
||||
}
|
||||
} // namespace
|
||||
|
||||
void createRequestGroupForBitTorrent
|
||||
(std::vector<SharedHandle<RequestGroup> >& result,
|
||||
|
@ -467,7 +479,8 @@ void createRequestGroupForUri
|
|||
}
|
||||
}
|
||||
|
||||
static void createRequestGroupForUriList
|
||||
namespace {
|
||||
void createRequestGroupForUriList
|
||||
(std::vector<SharedHandle<RequestGroup> >& result,
|
||||
const SharedHandle<Option>& option,
|
||||
std::istream& in)
|
||||
|
@ -493,6 +506,7 @@ static void createRequestGroupForUriList
|
|||
createRequestGroupForUri(result, requestOption, uris);
|
||||
}
|
||||
}
|
||||
} // namespace
|
||||
|
||||
void createRequestGroupForUriList
|
||||
(std::vector<SharedHandle<RequestGroup> >& result,
|
||||
|
|
12
src/main.cc
12
src/main.cc
|
@ -109,16 +109,19 @@ std::ostream& getSummaryOut(const SharedHandle<Option>& op)
|
|||
}
|
||||
|
||||
#ifdef ENABLE_BITTORRENT
|
||||
static void showTorrentFile(const std::string& uri)
|
||||
namespace {
|
||||
void showTorrentFile(const std::string& uri)
|
||||
{
|
||||
SharedHandle<DownloadContext> dctx(new DownloadContext());
|
||||
bittorrent::load(uri, dctx);
|
||||
bittorrent::print(std::cout, dctx);
|
||||
}
|
||||
} // namespace
|
||||
#endif // ENABLE_BITTORRENT
|
||||
|
||||
#ifdef ENABLE_METALINK
|
||||
static void showMetalinkFile
|
||||
namespace {
|
||||
void showMetalinkFile
|
||||
(const std::string& uri, const SharedHandle<Option>& op)
|
||||
{
|
||||
std::vector<SharedHandle<MetalinkEntry> > metalinkEntries;
|
||||
|
@ -128,10 +131,12 @@ static void showMetalinkFile
|
|||
util::toStream(fileEntries.begin(), fileEntries.end(), std::cout);
|
||||
std::cout << std::endl;
|
||||
}
|
||||
} // namespace
|
||||
#endif // ENABLE_METALINK
|
||||
|
||||
#if defined ENABLE_BITTORRENT || defined ENABLE_METALINK
|
||||
static void showFiles
|
||||
namespace {
|
||||
void showFiles
|
||||
(const std::vector<std::string>& uris, const SharedHandle<Option>& op)
|
||||
{
|
||||
ProtocolDetector dt;
|
||||
|
@ -160,6 +165,7 @@ static void showFiles
|
|||
}
|
||||
}
|
||||
}
|
||||
} // namespace
|
||||
#endif // ENABLE_BITTORRENT || ENABLE_METALINK
|
||||
|
||||
extern void option_processing(Option& option, std::vector<std::string>& uris,
|
||||
|
|
|
@ -56,7 +56,8 @@ struct DigestAlgoEntry {
|
|||
typedef std::map<std::string, DigestAlgoEntry>
|
||||
DigestAlgoMap;
|
||||
|
||||
static const DigestAlgoMap& getDigestAlgos()
|
||||
namespace {
|
||||
const DigestAlgoMap& getDigestAlgos()
|
||||
{
|
||||
enum AlgoStrength {
|
||||
STRENGTH_MD5 = 0,
|
||||
|
@ -84,6 +85,7 @@ static const DigestAlgoMap& getDigestAlgos()
|
|||
static const DigestAlgoMap algomap(vbegin(digests), vend(digests));
|
||||
return algomap;
|
||||
}
|
||||
} // namespace
|
||||
|
||||
std::string MessageDigestContext::getCanonicalAlgo
|
||||
(const std::string& algostring)
|
||||
|
|
|
@ -65,9 +65,10 @@ namespace aria2 {
|
|||
extern void showVersion();
|
||||
extern void showUsage(const std::string& keyword, const OptionParser& oparser);
|
||||
|
||||
static void overrideWithEnv(Option& op, const OptionParser& optionParser,
|
||||
const std::string& pref,
|
||||
const std::string& envName)
|
||||
namespace {
|
||||
void overrideWithEnv(Option& op, const OptionParser& optionParser,
|
||||
const std::string& pref,
|
||||
const std::string& envName)
|
||||
{
|
||||
char* value = getenv(envName.c_str());
|
||||
if(value) {
|
||||
|
@ -81,6 +82,7 @@ static void overrideWithEnv(Option& op, const OptionParser& optionParser,
|
|||
}
|
||||
}
|
||||
}
|
||||
} // namespace
|
||||
|
||||
void option_processing(Option& op, std::vector<std::string>& uris,
|
||||
int argc, char* const argv[])
|
||||
|
|
16
src/util.cc
16
src/util.cc
|
@ -413,7 +413,8 @@ std::string toHex(const std::string& src)
|
|||
return toHex(reinterpret_cast<const unsigned char*>(src.c_str()), src.size());
|
||||
}
|
||||
|
||||
static unsigned int hexCharToUInt(unsigned char ch)
|
||||
namespace {
|
||||
unsigned int hexCharToUInt(unsigned char ch)
|
||||
{
|
||||
|
||||
if('a' <= ch && ch <= 'f') {
|
||||
|
@ -429,6 +430,7 @@ static unsigned int hexCharToUInt(unsigned char ch)
|
|||
}
|
||||
return ch;
|
||||
}
|
||||
} // namespace
|
||||
|
||||
std::string fromHex(const std::string& src)
|
||||
{
|
||||
|
@ -634,7 +636,8 @@ IntSequence parseIntRange(const std::string& src)
|
|||
return values;
|
||||
}
|
||||
|
||||
static void computeHeadPieces
|
||||
namespace {
|
||||
void computeHeadPieces
|
||||
(std::vector<size_t>& indexes,
|
||||
const std::vector<SharedHandle<FileEntry> >& fileEntries,
|
||||
size_t pieceLength,
|
||||
|
@ -656,8 +659,10 @@ static void computeHeadPieces
|
|||
}
|
||||
}
|
||||
}
|
||||
} // namespace
|
||||
|
||||
static void computeTailPieces
|
||||
namespace {
|
||||
void computeTailPieces
|
||||
(std::vector<size_t>& indexes,
|
||||
const std::vector<SharedHandle<FileEntry> >& fileEntries,
|
||||
size_t pieceLength,
|
||||
|
@ -680,6 +685,7 @@ static void computeTailPieces
|
|||
}
|
||||
}
|
||||
}
|
||||
} // namespace
|
||||
|
||||
void parsePrioritizePieceRange
|
||||
(std::vector<size_t>& result, const std::string& src,
|
||||
|
@ -740,8 +746,9 @@ std::string iso8859ToUtf8(const std::string& src)
|
|||
return dest;
|
||||
}
|
||||
|
||||
namespace {
|
||||
template<typename OutputIterator>
|
||||
static void parseParam(OutputIterator out, const std::string& header)
|
||||
void parseParam(OutputIterator out, const std::string& header)
|
||||
{
|
||||
for(std::string::const_iterator i = header.begin(), eoi = header.end();
|
||||
i != eoi;) {
|
||||
|
@ -778,6 +785,7 @@ static void parseParam(OutputIterator out, const std::string& header)
|
|||
++i;
|
||||
}
|
||||
}
|
||||
} // namespace
|
||||
|
||||
std::string getContentDispositionFilename(const std::string& header)
|
||||
{
|
||||
|
|
|
@ -42,7 +42,8 @@ public:
|
|||
|
||||
CPPUNIT_TEST_SUITE_REGISTRATION( AnnounceListTest );
|
||||
|
||||
static std::vector<std::vector<std::string> > toVector
|
||||
namespace {
|
||||
std::vector<std::vector<std::string> > toVector
|
||||
(const List* announceList)
|
||||
{
|
||||
std::vector<std::vector<std::string> > dest;
|
||||
|
@ -59,6 +60,7 @@ static std::vector<std::vector<std::string> > toVector
|
|||
}
|
||||
return dest;
|
||||
}
|
||||
} // namespace
|
||||
|
||||
void AnnounceListTest::testSingleElementList() {
|
||||
std::string peersString = "ll8:tracker1el8:tracker2el8:tracker3ee";
|
||||
|
|
|
@ -47,7 +47,8 @@ void BtRegistryTest::testGetDownloadContext()
|
|||
CPPUNIT_ASSERT_EQUAL(dctx.get(), btRegistry.getDownloadContext(1).get());
|
||||
}
|
||||
|
||||
static void addTwoDownloadContext(BtRegistry& btRegistry)
|
||||
namespace {
|
||||
void addTwoDownloadContext(BtRegistry& btRegistry)
|
||||
{
|
||||
SharedHandle<DownloadContext> dctx1(new DownloadContext());
|
||||
SharedHandle<DownloadContext> dctx2(new DownloadContext());
|
||||
|
@ -58,6 +59,7 @@ static void addTwoDownloadContext(BtRegistry& btRegistry)
|
|||
btRegistry.put(1, btObject1);
|
||||
btRegistry.put(2, btObject2);
|
||||
}
|
||||
} // namespace
|
||||
|
||||
void BtRegistryTest::testGetDownloadContext_infoHash()
|
||||
{
|
||||
|
|
|
@ -289,12 +289,14 @@ void DHTBucketTest::testSplit()
|
|||
|
||||
}
|
||||
|
||||
static void createID(unsigned char* id, unsigned char firstChar, unsigned char lastChar)
|
||||
namespace {
|
||||
void createID(unsigned char* id, unsigned char firstChar, unsigned char lastChar)
|
||||
{
|
||||
memset(id, 0, DHT_ID_LENGTH);
|
||||
id[0] = firstChar;
|
||||
id[DHT_ID_LENGTH-1] = lastChar;
|
||||
}
|
||||
} // namespace
|
||||
|
||||
void DHTBucketTest::testAddNode()
|
||||
{
|
||||
|
|
|
@ -64,12 +64,14 @@ void DHTRoutingTableTest::testAddNode_localNode()
|
|||
CPPUNIT_ASSERT(!table.addNode(newNode));
|
||||
}
|
||||
|
||||
static void createID(unsigned char* id, unsigned char firstChar, unsigned char lastChar)
|
||||
namespace {
|
||||
void createID(unsigned char* id, unsigned char firstChar, unsigned char lastChar)
|
||||
{
|
||||
memset(id, 0, DHT_ID_LENGTH);
|
||||
id[0] = firstChar;
|
||||
id[DHT_ID_LENGTH-1] = lastChar;
|
||||
}
|
||||
} // namespace
|
||||
|
||||
void DHTRoutingTableTest::testGetClosestKNodes()
|
||||
{
|
||||
|
|
|
@ -95,8 +95,9 @@ public:
|
|||
|
||||
CPPUNIT_TEST_SUITE_REGISTRATION(DefaultBtAnnounceTest);
|
||||
|
||||
namespace {
|
||||
template<typename InputIterator>
|
||||
static SharedHandle<List> createAnnounceTier
|
||||
SharedHandle<List> createAnnounceTier
|
||||
(InputIterator first, InputIterator last)
|
||||
{
|
||||
SharedHandle<List> announceTier = List::g();
|
||||
|
@ -105,16 +106,20 @@ static SharedHandle<List> createAnnounceTier
|
|||
}
|
||||
return announceTier;
|
||||
}
|
||||
} // namespace
|
||||
|
||||
static SharedHandle<List> createAnnounceTier(const std::string& uri)
|
||||
namespace {
|
||||
SharedHandle<List> createAnnounceTier(const std::string& uri)
|
||||
{
|
||||
SharedHandle<List> announceTier = List::g();
|
||||
announceTier->append(String::g(uri));
|
||||
return announceTier;
|
||||
}
|
||||
} // namespace
|
||||
|
||||
static void setAnnounceList(const SharedHandle<DownloadContext>& dctx,
|
||||
const SharedHandle<List>& announceList)
|
||||
namespace {
|
||||
void setAnnounceList(const SharedHandle<DownloadContext>& dctx,
|
||||
const SharedHandle<List>& announceList)
|
||||
{
|
||||
std::vector<std::vector<std::string> > dest;
|
||||
for(List::ValueType::const_iterator tierIter = announceList->begin(),
|
||||
|
@ -130,6 +135,7 @@ static void setAnnounceList(const SharedHandle<DownloadContext>& dctx,
|
|||
}
|
||||
bittorrent::getTorrentAttrs(dctx)->announceList.swap(dest);
|
||||
}
|
||||
} // namespace
|
||||
|
||||
void DefaultBtAnnounceTest::testNoMoreAnnounce()
|
||||
{
|
||||
|
|
|
@ -41,7 +41,8 @@ public:
|
|||
|
||||
CPPUNIT_TEST_SUITE_REGISTRATION( FileEntryTest );
|
||||
|
||||
static SharedHandle<FileEntry> createFileEntry()
|
||||
namespace {
|
||||
SharedHandle<FileEntry> createFileEntry()
|
||||
{
|
||||
const char* uris[] = { "http://localhost/aria2.zip",
|
||||
"ftp://localhost/aria2.zip",
|
||||
|
@ -50,6 +51,7 @@ static SharedHandle<FileEntry> createFileEntry()
|
|||
fileEntry->setUris(std::vector<std::string>(&uris[0], &uris[3]));
|
||||
return fileEntry;
|
||||
}
|
||||
} // namespace
|
||||
|
||||
void FileEntryTest::testSetupDir()
|
||||
{
|
||||
|
|
|
@ -92,10 +92,12 @@ public:
|
|||
|
||||
CPPUNIT_TEST_SUITE_REGISTRATION(FtpConnectionTest);
|
||||
|
||||
static void waitRead(const SharedHandle<SocketCore>& socket)
|
||||
namespace {
|
||||
void waitRead(const SharedHandle<SocketCore>& socket)
|
||||
{
|
||||
while(!socket->isReadable(0));
|
||||
}
|
||||
} // namespace
|
||||
|
||||
void FtpConnectionTest::testReceiveResponse()
|
||||
{
|
||||
|
|
|
@ -44,8 +44,9 @@ public:
|
|||
|
||||
CPPUNIT_TEST_SUITE_REGISTRATION(MSEHandshakeTest);
|
||||
|
||||
static std::pair<SharedHandle<SocketCore>,
|
||||
SharedHandle<SocketCore> > createSocketPair()
|
||||
namespace {
|
||||
std::pair<SharedHandle<SocketCore>, SharedHandle<SocketCore> >
|
||||
createSocketPair()
|
||||
{
|
||||
SharedHandle<SocketCore> initiatorSock(new SocketCore());
|
||||
|
||||
|
@ -64,6 +65,7 @@ static std::pair<SharedHandle<SocketCore>,
|
|||
return std::pair<SharedHandle<SocketCore>,
|
||||
SharedHandle<SocketCore> >(initiatorSock, receiverSock);
|
||||
}
|
||||
} // namespace
|
||||
|
||||
void MSEHandshakeTest::doHandshake(const SharedHandle<MSEHandshake>& initiator, const SharedHandle<MSEHandshake>& receiver)
|
||||
{
|
||||
|
@ -90,7 +92,8 @@ void MSEHandshakeTest::doHandshake(const SharedHandle<MSEHandshake>& initiator,
|
|||
while(!initiator->receivePad());
|
||||
}
|
||||
|
||||
static SharedHandle<MSEHandshake>
|
||||
namespace {
|
||||
SharedHandle<MSEHandshake>
|
||||
createMSEHandshake(SharedHandle<SocketCore> socket, bool initiator,
|
||||
const Option* option)
|
||||
{
|
||||
|
@ -98,6 +101,7 @@ createMSEHandshake(SharedHandle<SocketCore> socket, bool initiator,
|
|||
h->initEncryptionFacility(initiator);
|
||||
return h;
|
||||
}
|
||||
} // namespace
|
||||
|
||||
void MSEHandshakeTest::testHandshake()
|
||||
{
|
||||
|
|
|
@ -20,10 +20,12 @@ public:
|
|||
|
||||
CPPUNIT_TEST_SUITE_REGISTRATION(MagnetTest);
|
||||
|
||||
static const std::string& nthStr(const SharedHandle<ValueBase>& v, size_t index)
|
||||
namespace {
|
||||
const std::string& nthStr(const SharedHandle<ValueBase>& v, size_t index)
|
||||
{
|
||||
return asString(asList(v)->get(index))->s();
|
||||
}
|
||||
} // namespace
|
||||
|
||||
void MagnetTest::testParse()
|
||||
{
|
||||
|
|
|
@ -150,10 +150,12 @@ public:
|
|||
|
||||
CPPUNIT_TEST_SUITE_REGISTRATION(XmlRpcMethodTest);
|
||||
|
||||
static std::string getString(const Dict* dict, const std::string& key)
|
||||
namespace {
|
||||
std::string getString(const Dict* dict, const std::string& key)
|
||||
{
|
||||
return asString(dict->get(key))->s();
|
||||
}
|
||||
} // namespace
|
||||
|
||||
void XmlRpcMethodTest::testAddUri()
|
||||
{
|
||||
|
@ -587,8 +589,8 @@ void XmlRpcMethodTest::testTellStatus_withoutGid()
|
|||
CPPUNIT_ASSERT_EQUAL(1, res.code);
|
||||
}
|
||||
|
||||
static void addUri(const std::string& uri,
|
||||
const SharedHandle<DownloadEngine>& e)
|
||||
namespace {
|
||||
void addUri(const std::string& uri, const SharedHandle<DownloadEngine>& e)
|
||||
{
|
||||
AddUriXmlRpcMethod m;
|
||||
XmlRpcRequest req(AddUriXmlRpcMethod::getMethodName(), List::g());
|
||||
|
@ -597,10 +599,11 @@ static void addUri(const std::string& uri,
|
|||
req.params->append(urisParam);
|
||||
CPPUNIT_ASSERT_EQUAL(0, m.execute(req, e.get()).code);
|
||||
}
|
||||
} // namespace
|
||||
|
||||
#ifdef ENABLE_BITTORRENT
|
||||
|
||||
static void addTorrent
|
||||
namespace {
|
||||
void addTorrent
|
||||
(const std::string& torrentFile, const SharedHandle<DownloadEngine>& e)
|
||||
{
|
||||
AddTorrentXmlRpcMethod m;
|
||||
|
@ -608,7 +611,7 @@ static void addTorrent
|
|||
req.params->append(readFile(torrentFile));
|
||||
XmlRpcResponse res = m.execute(req, e.get());
|
||||
}
|
||||
|
||||
} // namespace
|
||||
#endif // ENABLE_BITTORRENT
|
||||
|
||||
void XmlRpcMethodTest::testTellWaiting()
|
||||
|
|
|
@ -72,16 +72,22 @@ void array_funTest::testArrayLength()
|
|||
CPPUNIT_ASSERT_EQUAL((size_t)0, A2_ARRAY_LEN(zeroLengthArray));
|
||||
}
|
||||
|
||||
namespace {
|
||||
// Check operator[] in const context.
|
||||
static void arrayPtrConst(const array_ptr<struct array_funTest::X>& ax)
|
||||
void arrayPtrConst(const array_ptr<struct array_funTest::X>& ax)
|
||||
{
|
||||
CPPUNIT_ASSERT_EQUAL(100, ax[3].m);
|
||||
CPPUNIT_ASSERT_EQUAL(99, ax[2].m);
|
||||
}
|
||||
} // namespace
|
||||
|
||||
static void arrayPtrCast(struct array_funTest::X* x) {}
|
||||
namespace {
|
||||
void arrayPtrCast(struct array_funTest::X* x) {}
|
||||
} // namespace
|
||||
|
||||
static void arrayPtrConstCast(const struct array_funTest::X* x) {}
|
||||
namespace {
|
||||
void arrayPtrConstCast(const struct array_funTest::X* x) {}
|
||||
} // namespace
|
||||
|
||||
void array_funTest::testArrayPtr()
|
||||
{
|
||||
|
@ -96,10 +102,12 @@ void array_funTest::testArrayPtr()
|
|||
arrayPtrConstCast(ax);
|
||||
}
|
||||
|
||||
static void arrayWrapperConst(const array_wrapper<int, 10>& array)
|
||||
namespace {
|
||||
void arrayWrapperConst(const array_wrapper<int, 10>& array)
|
||||
{
|
||||
CPPUNIT_ASSERT_EQUAL(9, array[9]);
|
||||
}
|
||||
} // namespace
|
||||
|
||||
void array_funTest::testArrayWrapper()
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue