From c6035b2e24410e7a576f83e92257f4bb26d593c9 Mon Sep 17 00:00:00 2001 From: Tatsuhiro Tsujikawa Date: Thu, 22 Oct 2009 15:09:00 +0000 Subject: [PATCH] 2009-10-22 Tatsuhiro Tsujikawa Moved static functions in Util class to namespace util. * src * test --- ChangeLog | 6 + src/AbstractCommand.cc | 8 +- src/AbstractDiskWriter.cc | 2 +- src/AnnounceList.cc | 2 +- src/AuthConfigFactory.cc | 4 +- src/BtBitfieldMessage.cc | 2 +- src/BtDependency.cc | 2 +- src/BtHandshakeMessage.cc | 4 +- src/BtHandshakeMessageValidator.h | 6 +- src/BtPieceMessage.cc | 6 +- src/BtPortMessage.cc | 2 +- src/BtPostDownloadHandler.cc | 2 +- src/BtSetup.cc | 2 +- src/ChunkedDecoder.cc | 2 +- src/ConsoleStatCalc.cc | 22 +- src/ContentTypeRequestGroupCriteria.cc | 2 +- src/Cookie.cc | 16 +- src/CookieParser.cc | 8 +- src/DHTAbstractNodeLookupTask.cc | 6 +- src/DHTAnnouncePeerMessage.cc | 8 +- src/DHTBucket.cc | 8 +- src/DHTBucketRefreshTask.cc | 2 +- src/DHTFindNodeMessage.cc | 2 +- src/DHTFindNodeReplyMessage.cc | 2 +- src/DHTGetPeersMessage.cc | 2 +- src/DHTGetPeersReplyMessage.cc | 6 +- src/DHTMessageFactoryImpl.cc | 8 +- src/DHTMessageTracker.cc | 4 +- src/DHTMessageTrackerEntry.cc | 4 +- src/DHTNode.cc | 8 +- src/DHTPeerAnnounceStorage.cc | 6 +- src/DHTPeerLookupTask.cc | 4 +- src/DHTQueryMessage.cc | 6 +- src/DHTResponseMessage.cc | 6 +- src/DHTRoutingTable.cc | 4 +- src/DHTSetup.cc | 4 +- src/DHTUnknownMessage.cc | 6 +- src/DefaultBtAnnounce.cc | 18 +- src/DefaultBtProgressInfoFile.cc | 12 +- src/DownloadCommand.cc | 2 +- src/DownloadEngine.cc | 4 +- src/ExpatMetalinkProcessor.cc | 4 +- src/ExpatXmlRpcRequestProcessor.cc | 4 +- src/FeatureConfig.cc | 2 +- src/File.cc | 4 +- src/FileAllocationCommand.cc | 2 +- src/FileEntry.cc | 2 +- src/FixedWidthNumberDecorator.h | 2 +- src/FtpConnection.cc | 48 ++-- src/FtpNegotiationCommand.cc | 4 +- src/HandshakeExtensionMessage.cc | 8 +- src/HttpConnection.cc | 4 +- src/HttpHeader.cc | 28 +-- src/HttpHeaderProcessor.cc | 2 +- src/HttpRequest.cc | 12 +- src/HttpResponse.cc | 26 +- src/HttpResponseCommand.cc | 4 +- src/HttpServer.cc | 10 +- src/HttpServerCommand.cc | 2 +- src/HttpSkipResponseCommand.cc | 2 +- src/IndexBtMessage.cc | 2 +- src/IteratableChecksumValidator.cc | 4 +- src/IteratableChunkChecksumValidator.cc | 6 +- src/MSEHandshake.cc | 4 +- src/MessageDigestHelper.cc | 4 +- src/Metalink2RequestGroup.cc | 6 +- src/MetalinkEntry.cc | 2 +- src/MetalinkParserController.cc | 4 +- src/MetalinkParserStateImpl.cc | 14 +- src/MultiDiskAdaptor.cc | 8 +- src/MultiUrlRequestInfo.cc | 8 +- src/NameMatchOptionHandler.h | 2 +- src/NameResolver.cc | 2 +- src/Netrc.cc | 4 +- src/NsCookieParser.cc | 6 +- src/OptionHandlerFactory.cc | 6 +- src/OptionHandlerImpl.h | 36 +-- src/OptionParser.cc | 4 +- src/ParameterizedStringParser.cc | 28 +-- src/Peer.cc | 2 +- src/PeerReceiveHandshakeCommand.cc | 2 +- src/Piece.cc | 6 +- src/RangeBtMessage.cc | 6 +- src/Request.cc | 14 +- src/RequestGroup.cc | 16 +- src/RequestGroupMan.cc | 6 +- src/ServerStatMan.cc | 20 +- src/SimpleLogger.cc | 2 +- src/SingleFileAllocationIterator.cc | 2 +- src/SocketCore.cc | 6 +- src/Sqlite3MozCookieParser.cc | 2 +- src/TimeA2.cc | 16 +- src/UTPexExtensionMessage.cc | 4 +- src/UriListParser.cc | 6 +- src/Util.cc | 149 ++++++----- src/Util.h | 318 +++++++++++------------- src/XML2SAXMetalinkProcessor.cc | 4 +- src/Xml2XmlRpcRequestProcessor.cc | 4 +- src/XmlRpcMethodImpl.cc | 56 ++--- src/XmlRpcRequestParserStateImpl.cc | 2 +- src/XmlRpcResponse.cc | 4 +- src/bittorrent_helper.cc | 30 +-- src/download_helper.cc | 4 +- src/main.cc | 6 +- src/messageDigest.cc | 2 +- src/option_processing.cc | 2 +- src/version_usage.cc | 2 +- test/BDETest.cc | 4 +- test/BittorrentHelperTest.cc | 24 +- test/BtBitfieldMessageTest.cc | 4 +- test/BtHandshakeMessageTest.cc | 14 +- test/DHKeyExchangeTest.cc | 4 +- test/DHTAnnouncePeerMessageTest.cc | 4 +- test/DHTBucketTest.cc | 42 ++-- test/DHTFindNodeReplyMessageTest.cc | 2 +- test/DHTGetPeersMessageTest.cc | 4 +- test/DHTGetPeersReplyMessageTest.cc | 12 +- test/DHTMessageFactoryImplTest.cc | 54 ++-- test/DHTNodeTest.cc | 2 +- test/DHTRoutingTableDeserializerTest.cc | 2 +- test/DHTRoutingTableSerializerTest.cc | 2 +- test/DefaultBtProgressInfoFileTest.cc | 36 +-- test/FeatureConfigTest.cc | 4 +- test/HttpRequestTest.cc | 2 +- test/Sqlite3MozCookieParserTest.cc | 2 +- test/TimeSeedCriteriaTest.cc | 2 +- test/UTPexExtensionMessageTest.cc | 4 +- test/UriListParserTest.cc | 2 +- test/UtilTest.cc | 306 +++++++++++------------ 129 files changed, 893 insertions(+), 882 deletions(-) diff --git a/ChangeLog b/ChangeLog index e568f7b7..7396c41a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2009-10-22 Tatsuhiro Tsujikawa + + Moved static functions in Util class to namespace util. + * src + * test + 2009-10-22 Tatsuhiro Tsujikawa Moved generateRandomData to Util.cc Moved flipBit to bitfield.cc. diff --git a/src/AbstractCommand.cc b/src/AbstractCommand.cc index 0f0511d5..a0774350 100644 --- a/src/AbstractCommand.cc +++ b/src/AbstractCommand.cc @@ -403,10 +403,10 @@ public: bool operator()(const std::string& domain) const { - if(Util::startsWith(domain, ".")) { - return Util::endsWith(_hostname, domain); + if(util::startsWith(domain, ".")) { + return util::endsWith(_hostname, domain); } else { - return Util::endsWith(_hostname, "."+domain); + return util::endsWith(_hostname, "."+domain); } } }; @@ -415,7 +415,7 @@ static bool inNoProxy(const SharedHandle& req, const std::string& noProxy) { std::vector entries; - split(noProxy, std::back_inserter(entries), ",", true); + util::split(noProxy, std::back_inserter(entries), ",", true); if(entries.empty()) { return false; } diff --git a/src/AbstractDiskWriter.cc b/src/AbstractDiskWriter.cc index 32eeaf1f..0491b896 100644 --- a/src/AbstractDiskWriter.cc +++ b/src/AbstractDiskWriter.cc @@ -108,7 +108,7 @@ void AbstractDiskWriter::openExistingFile(uint64_t totalLength) void AbstractDiskWriter::createFile(int addFlags) { assert(!_filename.empty()); - Util::mkdirs(File(_filename).getDirname()); + util::mkdirs(File(_filename).getDirname()); if((fd = open(_filename.c_str(), O_CREAT|O_RDWR|O_TRUNC|O_BINARY|addFlags, OPEN_MODE)) < 0) { throw DL_ABORT_EX(StringFormat(EX_FILE_OPEN, diff --git a/src/AnnounceList.cc b/src/AnnounceList.cc index e63d0082..b98825aa 100644 --- a/src/AnnounceList.cc +++ b/src/AnnounceList.cc @@ -73,7 +73,7 @@ void AnnounceList::reconfigure(const BDE& announceList) elemItr != elemList.listEnd(); ++elemItr) { const BDE& data = *elemItr; if(data.isString()) { - urls.push_back(Util::trim(data.s())); + urls.push_back(util::trim(data.s())); } } if(!urls.empty()) { diff --git a/src/AuthConfigFactory.cc b/src/AuthConfigFactory.cc index 86d05425..dd9c0a79 100644 --- a/src/AuthConfigFactory.cc +++ b/src/AuthConfigFactory.cc @@ -190,7 +190,7 @@ AuthConfigFactory::BasicCred::BasicCred _user(user), _password(password), _host(host), _path(path), _activated(activated) { - if(!Util::endsWith(_path, "/")) { + if(!util::endsWith(_path, "/")) { _path += "/"; } } @@ -228,7 +228,7 @@ AuthConfigFactory::findBasicCred(const std::string& host, std::deque::iterator i = std::lower_bound(_basicCreds.begin(), _basicCreds.end(), bc); for(; i != _basicCreds.end() && (*i)._host == host; ++i) { - if(Util::startsWith(bc._path, (*i)._path)) { + if(util::startsWith(bc._path, (*i)._path)) { return i; } } diff --git a/src/BtBitfieldMessage.cc b/src/BtBitfieldMessage.cc index 4ea2b69e..9451cf5d 100644 --- a/src/BtBitfieldMessage.cc +++ b/src/BtBitfieldMessage.cc @@ -100,7 +100,7 @@ size_t BtBitfieldMessage::getMessageLength() { } std::string BtBitfieldMessage::toString() const { - return strconcat(NAME, " ", Util::toHex(bitfield, bitfieldLength)); + return strconcat(NAME, " ", util::toHex(bitfield, bitfieldLength)); } } // namespace aria2 diff --git a/src/BtDependency.cc b/src/BtDependency.cc index 8af66ba9..936923d4 100644 --- a/src/BtDependency.cc +++ b/src/BtDependency.cc @@ -70,7 +70,7 @@ bool BtDependency::resolve() DiskAdaptorHandle diskAdaptor = dependee->getPieceStorage()->getDiskAdaptor(); diskAdaptor->openExistingFile(); - std::string content = Util::toString(diskAdaptor); + std::string content = util::toString(diskAdaptor); bittorrent::loadFromMemory (content, context, File(dependee->getFirstFilePath()).getBasename()); if(context->getFileEntries().size() != diff --git a/src/BtHandshakeMessage.cc b/src/BtHandshakeMessage.cc index 3c0aa3dd..1be54862 100644 --- a/src/BtHandshakeMessage.cc +++ b/src/BtHandshakeMessage.cc @@ -106,9 +106,9 @@ size_t BtHandshakeMessage::getMessageLength() { std::string BtHandshakeMessage::toString() const { return strconcat(NAME, " peerId=", - Util::urlencode(peerId, PEER_ID_LENGTH), + util::urlencode(peerId, PEER_ID_LENGTH), ", reserved=", - Util::toHex(reserved, RESERVED_LENGTH)); + util::toHex(reserved, RESERVED_LENGTH)); } bool BtHandshakeMessage::isFastExtensionSupported() const { diff --git a/src/BtHandshakeMessageValidator.h b/src/BtHandshakeMessageValidator.h index 5a6c8e3d..59a4ce0f 100644 --- a/src/BtHandshakeMessageValidator.h +++ b/src/BtHandshakeMessageValidator.h @@ -66,13 +66,13 @@ public: if(memcmp(BtHandshakeMessage::BT_PSTR, message->getPstr(), 19) != 0) { throw DL_ABORT_EX (StringFormat("invalid handshake pstr=%s", - Util::urlencode(message->getPstr(), 19).c_str()).str()); + util::urlencode(message->getPstr(), 19).c_str()).str()); } if(memcmp(infoHash, message->getInfoHash(), 20) != 0) { throw DL_ABORT_EX (StringFormat("invalid handshake info hash: expected:%s, actual:%s", - Util::toHex(infoHash, 20).c_str(), - Util::toHex(message->getInfoHash(), 20).c_str()).str()); + util::toHex(infoHash, 20).c_str(), + util::toHex(message->getInfoHash(), 20).c_str()).str()); } return true; } diff --git a/src/BtPieceMessage.cc b/src/BtPieceMessage.cc index 6953f2b6..4ff4e897 100644 --- a/src/BtPieceMessage.cc +++ b/src/BtPieceMessage.cc @@ -91,7 +91,7 @@ void BtPieceMessage::doReceivedAction() { pieceStorage->getDiskAdaptor()->writeData(block, blockLength, offset); piece->completeBlock(slot.getBlockIndex()); logger->debug(MSG_PIECE_BITFIELD, cuid, - Util::toHex(piece->getBitfield(), + util::toHex(piece->getBitfield(), piece->getBitfieldLength()).c_str()); piece->updateHash(begin, block, blockLength); dispatcher->removeOutstandingRequest(slot); @@ -168,8 +168,8 @@ size_t BtPieceMessage::sendPieceData(off_t offset, size_t length) const { } std::string BtPieceMessage::toString() const { - return strconcat(NAME, " index=", Util::itos(index), ", begin=", - Util::itos(begin), ", length=", Util::itos(blockLength)); + return strconcat(NAME, " index=", util::itos(index), ", begin=", + util::itos(begin), ", length=", util::itos(blockLength)); } bool BtPieceMessage::checkPieceHash(const PieceHandle& piece) { diff --git a/src/BtPortMessage.cc b/src/BtPortMessage.cc index 5ceaa0c7..28a4a8d3 100644 --- a/src/BtPortMessage.cc +++ b/src/BtPortMessage.cc @@ -110,7 +110,7 @@ size_t BtPortMessage::getMessageLength() { } std::string BtPortMessage::toString() const { - return strconcat(NAME, " port=", Util::uitos(_port)); + return strconcat(NAME, " port=", util::uitos(_port)); } void BtPortMessage::setLocalNode(const WeakHandle& localNode) diff --git a/src/BtPostDownloadHandler.cc b/src/BtPostDownloadHandler.cc index 1916f01c..2888495e 100644 --- a/src/BtPostDownloadHandler.cc +++ b/src/BtPostDownloadHandler.cc @@ -74,7 +74,7 @@ void BtPostDownloadHandler::getNextRequestGroups std::string content; try { requestGroup->getPieceStorage()->getDiskAdaptor()->openExistingFile(); - content = Util::toString(requestGroup->getPieceStorage()->getDiskAdaptor()); + content = util::toString(requestGroup->getPieceStorage()->getDiskAdaptor()); requestGroup->getPieceStorage()->getDiskAdaptor()->closeFile(); } catch(Exception& e) { requestGroup->getPieceStorage()->getDiskAdaptor()->closeFile(); diff --git a/src/BtSetup.cc b/src/BtSetup.cc index 4754859a..67775860 100644 --- a/src/BtSetup.cc +++ b/src/BtSetup.cc @@ -149,7 +149,7 @@ void BtSetup::setup(std::deque& commands, if(PeerListenCommand::getNumInstance() == 0) { PeerListenCommand* listenCommand = PeerListenCommand::getInstance(e); - IntSequence seq = Util::parseIntRange(option->get(PREF_LISTEN_PORT)); + IntSequence seq = util::parseIntRange(option->get(PREF_LISTEN_PORT)); uint16_t port; if(listenCommand->bindPort(port, seq)) { btRuntime->setListenPort(port); diff --git a/src/ChunkedDecoder.cc b/src/ChunkedDecoder.cc index bc91343c..77462fe8 100644 --- a/src/ChunkedDecoder.cc +++ b/src/ChunkedDecoder.cc @@ -59,7 +59,7 @@ static bool readChunkSize(uint64_t& chunkSize, std::string& in) if(extPos == std::string::npos || crlfPos < extPos) { extPos = crlfPos; } - chunkSize = Util::parseULLInt(in.substr(0, extPos), 16); + chunkSize = util::parseULLInt(in.substr(0, extPos), 16); in.erase(0, crlfPos+2); return true; } diff --git a/src/ConsoleStatCalc.cc b/src/ConsoleStatCalc.cc index 8add12b6..5219f35e 100644 --- a/src/ConsoleStatCalc.cc +++ b/src/ConsoleStatCalc.cc @@ -98,10 +98,10 @@ static void printProgress #endif // ENABLE_BITTORRENT { o << "SIZE:" - << Util::abbrevSize(rg->getCompletedLength()) + << util::abbrevSize(rg->getCompletedLength()) << "B" << "/" - << Util::abbrevSize(rg->getTotalLength()) + << util::abbrevSize(rg->getTotalLength()) << "B"; if(rg->getTotalLength() > 0) { o << "(" @@ -128,18 +128,18 @@ static void printProgress if(!rg->downloadFinished()) { o << " " << "SPD:" - << Util::abbrevSize(stat.getDownloadSpeed()) << "Bs"; + << util::abbrevSize(stat.getDownloadSpeed()) << "Bs"; } if(stat.getSessionUploadLength() > 0) { o << " " << "UP:" - << Util::abbrevSize(stat.getUploadSpeed()) << "Bs" - << "(" << Util::abbrevSize(stat.getAllTimeUploadLength()) << "B)"; + << util::abbrevSize(stat.getUploadSpeed()) << "Bs" + << "(" << util::abbrevSize(stat.getAllTimeUploadLength()) << "B)"; } if(eta > 0) { o << " " << "ETA:" - << Util::secfmt(eta); + << util::secfmt(eta); } o << "]"; } @@ -241,7 +241,7 @@ ConsoleStatCalc::calculateStat(const DownloadEngine* e) TransferStat stat = e->_requestGroupMan->calculateStat(); o << " " << "[TOTAL SPD:" - << Util::abbrevSize(stat.getDownloadSpeed()) << "Bs" << "]"; + << util::abbrevSize(stat.getDownloadSpeed()) << "Bs" << "]"; } { @@ -250,10 +250,10 @@ ConsoleStatCalc::calculateStat(const DownloadEngine* e) o << " " << "[FileAlloc:" << "#" << entry->getRequestGroup()->getGID() << " " - << Util::abbrevSize(entry->getCurrentLength()) + << util::abbrevSize(entry->getCurrentLength()) << "B" << "/" - << Util::abbrevSize(entry->getTotalLength()) + << util::abbrevSize(entry->getTotalLength()) << "B" << "("; if(entry->getTotalLength() > 0) { @@ -277,10 +277,10 @@ ConsoleStatCalc::calculateStat(const DownloadEngine* e) o << " " << "[Checksum:" << "#" << entry->getRequestGroup()->getGID() << " " - << Util::abbrevSize(entry->getCurrentLength()) + << util::abbrevSize(entry->getCurrentLength()) << "B" << "/" - << Util::abbrevSize(entry->getTotalLength()) + << util::abbrevSize(entry->getTotalLength()) << "B" << "(" << 100*entry->getCurrentLength()/entry->getTotalLength() diff --git a/src/ContentTypeRequestGroupCriteria.cc b/src/ContentTypeRequestGroupCriteria.cc index 1b9ade2c..ce3a3a2f 100644 --- a/src/ContentTypeRequestGroupCriteria.cc +++ b/src/ContentTypeRequestGroupCriteria.cc @@ -48,7 +48,7 @@ bool tailMatch (InputIterator first, InputIterator last, const std::string& target) { for(; first != last; ++first) { - if(Util::endsWith(target, *first)) { + if(util::endsWith(target, *first)) { return true; } } diff --git a/src/Cookie.cc b/src/Cookie.cc index f5d8006c..3d16b9e0 100644 --- a/src/Cookie.cc +++ b/src/Cookie.cc @@ -56,16 +56,16 @@ static std::string prependDotIfNotExists(const std::string& domain) static std::string normalizeDomain(const std::string& domain) { - if(domain.empty() || Util::isNumbersAndDotsNotation(domain)) { + if(domain.empty() || util::isNumbersAndDotsNotation(domain)) { return domain; } std::string md = prependDotIfNotExists(domain); - // TODO use Util::split to strict verification + // TODO use util::split to strict verification std::string::size_type p = md.find_last_of("."); if(p == 0 || p == std::string::npos) { md += ".local"; } - return Util::toLower(prependDotIfNotExists(md)); + return util::toLower(prependDotIfNotExists(md)); } Cookie::Cookie(const std::string& name, @@ -112,12 +112,12 @@ static bool pathInclude(const std::string& requestPath, const std::string& path) if(requestPath == path) { return true; } - if(Util::startsWith(requestPath, path)) { + if(util::startsWith(requestPath, path)) { if(*path.rbegin() != '/' && requestPath[path.size()] != '/') { return false; } } else if(*path.rbegin() != '/' || *requestPath.rbegin() == '/' || - !Util::startsWith(requestPath+"/", path)) { + !util::startsWith(requestPath+"/", path)) { return false; } return true; @@ -135,7 +135,7 @@ static bool domainMatch(const std::string& normReqHost, // Also original Netscape implementation behaves exactly the same. // _domain always starts ".". See Cookie::Cookie(). - return Util::endsWith(normReqHost, domain); + return util::endsWith(normReqHost, domain); } bool Cookie::match(const std::string& requestHost, @@ -172,7 +172,7 @@ bool Cookie::validate(const std::string& requestHost, if(_domain.size() < 4 || _domain.find(".", 1) == std::string::npos) { return false; } - if(!Util::endsWith(normReqHost, _domain)) { + if(!util::endsWith(normReqHost, _domain)) { return false; } // From RFC2965 3.3.2 Rejecting Cookies @@ -211,7 +211,7 @@ std::string Cookie::toNsCookieFormat() const { std::stringstream ss; ss << _domain << "\t"; - if(Util::startsWith(_domain, ".")) { + if(util::startsWith(_domain, ".")) { ss << "TRUE"; } else { ss << "FALSE"; diff --git a/src/CookieParser.cc b/src/CookieParser.cc index 278a0209..1a9d5be9 100644 --- a/src/CookieParser.cc +++ b/src/CookieParser.cc @@ -63,12 +63,12 @@ Cookie CookieParser::parse(const std::string& cookieStr) const Cookie CookieParser::parse(const std::string& cookieStr, const std::string& defaultDomain, const std::string& defaultPath) const { std::vector terms; - split(cookieStr, std::back_inserter(terms), ";", true); + util::split(cookieStr, std::back_inserter(terms), ";", true); if(terms.empty()) { return Cookie(); } std::pair nameValue; - Util::split(nameValue, terms.front(), '='); + util::split(nameValue, terms.front(), '='); std::map values; values[C_DOMAIN] = defaultDomain; @@ -77,7 +77,7 @@ Cookie CookieParser::parse(const std::string& cookieStr, const std::string& defa for(std::vector::iterator itr = terms.begin()+1; itr != terms.end(); ++itr) { std::pair nv; - Util::split(nv, *itr, '='); + util::split(nv, *itr, '='); values[nv.first] = nv.second; } time_t expiry = 0; @@ -99,7 +99,7 @@ Cookies CookieParser::parse(std::istream& s) const Cookies cookies; std::string line; while(getline(s, line)) { - if(Util::trim(line).empty() || Util::startsWith(line, A2STR::SHARP_C)) { + if(util::trim(line).empty() || util::startsWith(line, A2STR::SHARP_C)) { continue; } Cookie cookie = parse(line); diff --git a/src/DHTAbstractNodeLookupTask.cc b/src/DHTAbstractNodeLookupTask.cc index dfc7cb75..fbee6455 100644 --- a/src/DHTAbstractNodeLookupTask.cc +++ b/src/DHTAbstractNodeLookupTask.cc @@ -86,7 +86,7 @@ void DHTAbstractNodeLookupTask::onReceived(const SharedHandle& messa } if(_inFlightMessage == 0) { _logger->debug("Finished node_lookup for node ID %s", - Util::toHex(_targetID, DHT_ID_LENGTH).c_str()); + util::toHex(_targetID, DHT_ID_LENGTH).c_str()); onFinish(); updateBucket(); _finished = true; @@ -96,7 +96,7 @@ void DHTAbstractNodeLookupTask::onReceived(const SharedHandle& messa void DHTAbstractNodeLookupTask::onTimeout(const SharedHandle& node) { _logger->debug("node lookup message timeout for node ID=%s", - Util::toHex(node->getID(), DHT_ID_LENGTH).c_str()); + util::toHex(node->getID(), DHT_ID_LENGTH).c_str()); --_inFlightMessage; for(std::deque >::iterator i = _entries.begin(); i != _entries.end(); ++i) { if((*i)->_node == node) { @@ -109,7 +109,7 @@ void DHTAbstractNodeLookupTask::onTimeout(const SharedHandle& node) } if(_inFlightMessage == 0) { _logger->debug("Finished node_lookup for node ID %s", - Util::toHex(_targetID, DHT_ID_LENGTH).c_str()); + util::toHex(_targetID, DHT_ID_LENGTH).c_str()); onFinish(); updateBucket(); _finished = true; diff --git a/src/DHTAnnouncePeerMessage.cc b/src/DHTAnnouncePeerMessage.cc index c76084e7..07ef5178 100644 --- a/src/DHTAnnouncePeerMessage.cc +++ b/src/DHTAnnouncePeerMessage.cc @@ -107,7 +107,7 @@ void DHTAnnouncePeerMessage::validate() const _remoteNode->getPort())) { throw DL_ABORT_EX (StringFormat("Invalid token=%s from %s:%u", - Util::toHex(_token).c_str(), + util::toHex(_token).c_str(), _remoteNode->getIPAddress().c_str(), _remoteNode->getPort()).str()); } @@ -125,9 +125,9 @@ void DHTAnnouncePeerMessage::setTokenTracker(const WeakHandle& std::string DHTAnnouncePeerMessage::toStringOptional() const { - return strconcat("token=", Util::toHex(_token), - ", info_hash=", Util::toHex(_infoHash, INFO_HASH_LENGTH), - ", tcpPort=", Util::uitos(_tcpPort)); + return strconcat("token=", util::toHex(_token), + ", info_hash=", util::toHex(_infoHash, INFO_HASH_LENGTH), + ", tcpPort=", util::uitos(_tcpPort)); } } // namespace aria2 diff --git a/src/DHTBucket.cc b/src/DHTBucket.cc index c991aebd..abcdb53d 100644 --- a/src/DHTBucket.cc +++ b/src/DHTBucket.cc @@ -203,12 +203,12 @@ SharedHandle DHTBucket::split() // TODO create toString() and use it. _logger->debug("New bucket. prefixLength=%u, Range:%s-%s", static_cast(rBucket->getPrefixLength()), - Util::toHex(rBucket->getMinID(), DHT_ID_LENGTH).c_str(), - Util::toHex(rBucket->getMaxID(), DHT_ID_LENGTH).c_str()); + util::toHex(rBucket->getMinID(), DHT_ID_LENGTH).c_str(), + util::toHex(rBucket->getMaxID(), DHT_ID_LENGTH).c_str()); _logger->debug("Existing bucket. prefixLength=%u, Range:%s-%s", static_cast(_prefixLength), - Util::toHex(getMinID(), DHT_ID_LENGTH).c_str(), - Util::toHex(getMaxID(), DHT_ID_LENGTH).c_str()); + util::toHex(getMinID(), DHT_ID_LENGTH).c_str(), + util::toHex(getMaxID(), DHT_ID_LENGTH).c_str()); return rBucket; } diff --git a/src/DHTBucketRefreshTask.cc b/src/DHTBucketRefreshTask.cc index fdd3281e..90a743fe 100644 --- a/src/DHTBucketRefreshTask.cc +++ b/src/DHTBucketRefreshTask.cc @@ -65,7 +65,7 @@ void DHTBucketRefreshTask::startup() task->setTaskQueue(_taskQueue); task->setLocalNode(_localNode); - _logger->info("Dispating bucket refresh. targetID=%s", Util::toHex(targetID, DHT_ID_LENGTH).c_str()); + _logger->info("Dispating bucket refresh. targetID=%s", util::toHex(targetID, DHT_ID_LENGTH).c_str()); _taskQueue->addPeriodicTask1(task); } } diff --git a/src/DHTFindNodeMessage.cc b/src/DHTFindNodeMessage.cc index 6888bf31..f35c40dd 100644 --- a/src/DHTFindNodeMessage.cc +++ b/src/DHTFindNodeMessage.cc @@ -87,7 +87,7 @@ void DHTFindNodeMessage::validate() const {} std::string DHTFindNodeMessage::toStringOptional() const { - return "targetNodeID="+Util::toHex(_targetNodeID, DHT_ID_LENGTH); + return "targetNodeID="+util::toHex(_targetNodeID, DHT_ID_LENGTH); } } // namespace aria2 diff --git a/src/DHTFindNodeReplyMessage.cc b/src/DHTFindNodeReplyMessage.cc index fd6108ca..cadab099 100644 --- a/src/DHTFindNodeReplyMessage.cc +++ b/src/DHTFindNodeReplyMessage.cc @@ -103,7 +103,7 @@ void DHTFindNodeReplyMessage::setClosestKNodes(const std::dequeinfo("Received Error DHT message. code=%s, msg=%s", - Util::itos(getInteger(e, 0).i()).c_str(), - Util::urlencode(getString(e, 1).s()).c_str()); + util::itos(getInteger(e, 0).i()).c_str(), + util::urlencode(getString(e, 1).s()).c_str()); } else { _logger->debug("e doesn't have 2 elements."); } @@ -242,7 +242,7 @@ DHTMessageFactoryImpl::createResponseMessage(const std::string& messageType, } else if(y.s() != DHTResponseMessage::R) { throw DL_ABORT_EX (StringFormat("Malformed DHT message. y != r: y=%s", - Util::urlencode(y.s()).c_str()).str()); + util::urlencode(y.s()).c_str()).str()); } const BDE& rDict = getDictionary(dict, DHTResponseMessage::R); const BDE& id = getString(rDict, DHTMessage::ID); diff --git a/src/DHTMessageTracker.cc b/src/DHTMessageTracker.cc index 9f4b0fe2..af994e50 100644 --- a/src/DHTMessageTracker.cc +++ b/src/DHTMessageTracker.cc @@ -78,7 +78,7 @@ DHTMessageTracker::messageArrived(const BDE& dict, ipaddr.c_str(), port).str()); } _logger->debug("Searching tracker entry for TransactionID=%s, Remote=%s:%u", - Util::toHex(tid.s()).c_str(), ipaddr.c_str(), port); + util::toHex(tid.s()).c_str(), ipaddr.c_str(), port); for(std::deque >::iterator i = _entries.begin(); i != _entries.end(); ++i) { if((*i)->match(tid.s(), ipaddr, port)) { @@ -93,7 +93,7 @@ DHTMessageTracker::messageArrived(const BDE& dict, targetNode->getPort()); int64_t rtt = entry->getElapsedMillis(); - _logger->debug("RTT is %s", Util::itos(rtt).c_str()); + _logger->debug("RTT is %s", util::itos(rtt).c_str()); message->getRemoteNode()->updateRTT(rtt); SharedHandle callback = entry->getCallback(); return std::pair, SharedHandle >(message, callback); diff --git a/src/DHTMessageTrackerEntry.cc b/src/DHTMessageTrackerEntry.cc index 95e5ca25..6267370b 100644 --- a/src/DHTMessageTrackerEntry.cc +++ b/src/DHTMessageTrackerEntry.cc @@ -67,9 +67,9 @@ bool DHTMessageTrackerEntry::match(const std::string& transactionID, const std:: if(_targetNode->getIPAddress() == ipaddr) { return true; } - if(Util::endsWith(_targetNode->getIPAddress(), ipaddr)) { + if(util::endsWith(_targetNode->getIPAddress(), ipaddr)) { return _targetNode->getIPAddress() == "::ffff:"+ipaddr; - } else if(Util::endsWith(ipaddr, _targetNode->getIPAddress())) { + } else if(util::endsWith(ipaddr, _targetNode->getIPAddress())) { return ipaddr == "::ffff:"+_targetNode->getIPAddress(); } return false; diff --git a/src/DHTNode.cc b/src/DHTNode.cc index a28565ed..ca33f7ea 100644 --- a/src/DHTNode.cc +++ b/src/DHTNode.cc @@ -113,10 +113,10 @@ void DHTNode::timeout() std::string DHTNode::toString() const { - return strconcat("DHTNode ID=", Util::toHex(_id, DHT_ID_LENGTH), - ", Host=", _ipaddr, ":", Util::uitos(_port), - ", Condition=", Util::uitos(_condition), - ", RTT=", Util::uitos(_rtt)); + return strconcat("DHTNode ID=", util::toHex(_id, DHT_ID_LENGTH), + ", Host=", _ipaddr, ":", util::uitos(_port), + ", Condition=", util::uitos(_condition), + ", RTT=", util::uitos(_rtt)); } void DHTNode::setID(const unsigned char* id) diff --git a/src/DHTPeerAnnounceStorage.cc b/src/DHTPeerAnnounceStorage.cc index f2e54dd1..764f0156 100644 --- a/src/DHTPeerAnnounceStorage.cc +++ b/src/DHTPeerAnnounceStorage.cc @@ -88,7 +88,7 @@ DHTPeerAnnounceStorage::addPeerAnnounce(const unsigned char* infoHash, const std::string& ipaddr, uint16_t port) { _logger->debug("Adding %s:%u to peer announce list: infoHash=%s", - ipaddr.c_str(), port, Util::toHex(infoHash, DHT_ID_LENGTH).c_str()); + ipaddr.c_str(), port, util::toHex(infoHash, DHT_ID_LENGTH).c_str()); getPeerAnnounceEntry(infoHash)->addPeerAddrEntry(PeerAddrEntry(ipaddr, port)); } @@ -97,7 +97,7 @@ void DHTPeerAnnounceStorage::addPeerAnnounce (const unsigned char* infoHash, const SharedHandle& peerStorage) { _logger->debug("Adding localhost to peer announce list: infoHash=%s", - Util::toHex(infoHash, DHT_ID_LENGTH).c_str()); + util::toHex(infoHash, DHT_ID_LENGTH).c_str()); SharedHandle entry = getPeerAnnounceEntry(infoHash); entry->setPeerStorage(peerStorage); @@ -172,7 +172,7 @@ void DHTPeerAnnounceStorage::announcePeer() SharedHandle task = _taskFactory->createPeerAnnounceTask((*i)->getInfoHash()); _taskQueue->addPeriodicTask2(task); _logger->debug("Added 1 peer announce: infoHash=%s", - Util::toHex((*i)->getInfoHash(), DHT_ID_LENGTH).c_str()); + util::toHex((*i)->getInfoHash(), DHT_ID_LENGTH).c_str()); } } } diff --git a/src/DHTPeerLookupTask.cc b/src/DHTPeerLookupTask.cc index 6d4a0a9c..fc74f898 100644 --- a/src/DHTPeerLookupTask.cc +++ b/src/DHTPeerLookupTask.cc @@ -71,7 +71,7 @@ void DHTPeerLookupTask::onReceivedInternal(const SharedHandle& messa return; } SharedHandle remoteNode = m->getRemoteNode(); - _tokenStorage[Util::toHex(remoteNode->getID(), DHT_ID_LENGTH)] = m->getToken(); + _tokenStorage[util::toHex(remoteNode->getID(), DHT_ID_LENGTH)] = m->getToken(); _peerStorage->addPeer(m->getValues()); _peers.insert(_peers.end(), m->getValues().begin(), m->getValues().end()); @@ -96,7 +96,7 @@ void DHTPeerLookupTask::onFinish() (node, _targetID, // this is infoHash _btRuntime->getListenPort(), - _tokenStorage[Util::toHex(node->getID(), DHT_ID_LENGTH)]); + _tokenStorage[util::toHex(node->getID(), DHT_ID_LENGTH)]); _dispatcher->addMessageToQueue(m); } } diff --git a/src/DHTQueryMessage.cc b/src/DHTQueryMessage.cc index fad0c8dd..b0424294 100644 --- a/src/DHTQueryMessage.cc +++ b/src/DHTQueryMessage.cc @@ -70,10 +70,10 @@ bool DHTQueryMessage::isReply() const std::string DHTQueryMessage::toString() const { return strconcat("dht query ", getMessageType(), - " TransactionID=", Util::toHex(_transactionID), + " TransactionID=", util::toHex(_transactionID), " Remote:", _remoteNode->getIPAddress(), - ":", Util::uitos(_remoteNode->getPort()), - ", id=", Util::toHex(_remoteNode->getID(), DHT_ID_LENGTH), + ":", util::uitos(_remoteNode->getPort()), + ", id=", util::toHex(_remoteNode->getID(), DHT_ID_LENGTH), ", ", toStringOptional()); } diff --git a/src/DHTResponseMessage.cc b/src/DHTResponseMessage.cc index 4c46a707..7180bc3f 100644 --- a/src/DHTResponseMessage.cc +++ b/src/DHTResponseMessage.cc @@ -67,10 +67,10 @@ bool DHTResponseMessage::isReply() const std::string DHTResponseMessage::toString() const { return strconcat("dht response ", getMessageType(), - " TransactionID=", Util::toHex(_transactionID), + " TransactionID=", util::toHex(_transactionID), " Remote:", _remoteNode->getIPAddress(), - ":", Util::uitos(_remoteNode->getPort()), - ", id=", Util::toHex(_remoteNode->getID(), DHT_ID_LENGTH), + ":", util::uitos(_remoteNode->getPort()), + ", id=", util::toHex(_remoteNode->getID(), DHT_ID_LENGTH), ", ", toStringOptional()); } diff --git a/src/DHTRoutingTable.cc b/src/DHTRoutingTable.cc index a3bd3140..f1e50e6e 100644 --- a/src/DHTRoutingTable.cc +++ b/src/DHTRoutingTable.cc @@ -88,8 +88,8 @@ bool DHTRoutingTable::addNode(const SharedHandle& node, bool good) return true; } else if(bucket->splitAllowed()) { _logger->debug("Splitting bucket. Range:%s-%s", - Util::toHex(bucket->getMinID(), DHT_ID_LENGTH).c_str(), - Util::toHex(bucket->getMaxID(), DHT_ID_LENGTH).c_str()); + util::toHex(bucket->getMinID(), DHT_ID_LENGTH).c_str(), + util::toHex(bucket->getMaxID(), DHT_ID_LENGTH).c_str()); SharedHandle r = bucket->split(); bnode->setBucket(SharedHandle()); diff --git a/src/DHTSetup.cc b/src/DHTSetup.cc index fddf21d6..4bb9cdad 100644 --- a/src/DHTSetup.cc +++ b/src/DHTSetup.cc @@ -111,7 +111,7 @@ void DHTSetup::setup(std::deque& commands, SharedHandle connection(new DHTConnectionImpl()); { - IntSequence seq = Util::parseIntRange(option->get(PREF_DHT_LISTEN_PORT)); + IntSequence seq = util::parseIntRange(option->get(PREF_DHT_LISTEN_PORT)); uint16_t port; if(!connection->bind(port, seq)) { throw DL_ABORT_EX("Error occurred while binding port for DHT"); @@ -119,7 +119,7 @@ void DHTSetup::setup(std::deque& commands, localNode->setPort(port); } _logger->debug("Initialized local node ID=%s", - Util::toHex(localNode->getID(), DHT_ID_LENGTH).c_str()); + util::toHex(localNode->getID(), DHT_ID_LENGTH).c_str()); SharedHandle routingTable(new DHTRoutingTable(localNode)); diff --git a/src/DHTUnknownMessage.cc b/src/DHTUnknownMessage.cc index 8d316f43..931111f9 100644 --- a/src/DHTUnknownMessage.cc +++ b/src/DHTUnknownMessage.cc @@ -92,9 +92,9 @@ std::string DHTUnknownMessage::toString() const } std::string sample(&_data[0], &_data[sampleLength]); - return strconcat("dht unknown Remote:", _ipaddr, ":", Util::uitos(_port), - " length=", Util::uitos(_length), - ", first 8 bytes(hex)=", Util::toHex(sample)); + return strconcat("dht unknown Remote:", _ipaddr, ":", util::uitos(_port), + " length=", util::uitos(_length), + ", first 8 bytes(hex)=", util::toHex(sample)); } } // namespace aria2 diff --git a/src/DefaultBtAnnounce.cc b/src/DefaultBtAnnounce.cc index 3cdeb360..99b686f9 100644 --- a/src/DefaultBtAnnounce.cc +++ b/src/DefaultBtAnnounce.cc @@ -79,7 +79,7 @@ DefaultBtAnnounce::~DefaultBtAnnounce() { void DefaultBtAnnounce::generateKey() { - key = Util::randomAlpha(8, _randomizer); + key = util::randomAlpha(8, _randomizer); } bool DefaultBtAnnounce::isDefaultAnnounceReady() { @@ -147,25 +147,25 @@ std::string DefaultBtAnnounce::getAnnounceUrl() { std::string url = announceList.getAnnounce(); url += uriHasQuery(url) ? "&" : "?"; url += "info_hash="; - url += Util::torrentUrlencode(bittorrent::getInfoHash(_downloadContext), + url += util::torrentUrlencode(bittorrent::getInfoHash(_downloadContext), INFO_HASH_LENGTH); url += "&peer_id="; - url += Util::torrentUrlencode(bittorrent::getStaticPeerId(), PEER_ID_LENGTH); + url += util::torrentUrlencode(bittorrent::getStaticPeerId(), PEER_ID_LENGTH); url += "&uploaded="; - url += Util::uitos(stat.getSessionUploadLength()); + url += util::uitos(stat.getSessionUploadLength()); url += "&downloaded="; - url += Util::uitos(stat.getSessionDownloadLength()); + url += util::uitos(stat.getSessionDownloadLength()); url += "&left="; - url += Util::uitos(left); + url += util::uitos(left); url += "&compact=1"; url += "&key="; url += key; url += "&numwant="; - url += Util::uitos(numWant); + url += util::uitos(numWant); url += "&no_peer_id=1"; if(btRuntime->getListenPort() > 0) { url += "&port="; - url += Util::uitos(btRuntime->getListenPort()); + url += util::uitos(btRuntime->getListenPort()); } std::string event = announceList.getEventString(); if(!event.empty()) { @@ -173,7 +173,7 @@ std::string DefaultBtAnnounce::getAnnounceUrl() { url += event; } if(!trackerId.empty()) { - url += "&trackerid="+Util::torrentUrlencode(trackerId); + url += "&trackerid="+util::torrentUrlencode(trackerId); } if(option->getAsBool(PREF_BT_REQUIRE_CRYPTO)) { url += "&requirecrypto=1"; diff --git a/src/DefaultBtProgressInfoFile.cc b/src/DefaultBtProgressInfoFile.cc index 92c6f3b0..6d80f914 100644 --- a/src/DefaultBtProgressInfoFile.cc +++ b/src/DefaultBtProgressInfoFile.cc @@ -230,7 +230,7 @@ void DefaultBtProgressInfoFile::load() unsigned char versionBuf[2]; in.read((char*)versionBuf, sizeof(versionBuf)); CHECK_STREAM(in, sizeof(versionBuf)); - std::string versionHex = Util::toHex(versionBuf, sizeof(versionBuf)); + std::string versionHex = util::toHex(versionBuf, sizeof(versionBuf)); int version; if(DefaultBtProgressInfoFile::V0000 == versionHex) { version = 0; @@ -273,8 +273,8 @@ void DefaultBtProgressInfoFile::load() memcmp(savedInfoHash, infoHash, INFO_HASH_LENGTH) != 0) { throw DL_ABORT_EX (StringFormat("info hash mismatch. expected: %s, actual: %s", - Util::toHex(infoHash, INFO_HASH_LENGTH).c_str(), - Util::toHex(savedInfoHash, infoHashLength).c_str() + util::toHex(infoHash, INFO_HASH_LENGTH).c_str(), + util::toHex(savedInfoHash, infoHashLength).c_str() ).str()); } } @@ -297,8 +297,8 @@ void DefaultBtProgressInfoFile::load() if(totalLength != _dctx->getTotalLength()) { throw DL_ABORT_EX (StringFormat("total length mismatch. expected: %s, actual: %s", - Util::itos(_dctx->getTotalLength()).c_str(), - Util::itos(totalLength).c_str()).str()); + util::itos(_dctx->getTotalLength()).c_str(), + util::itos(totalLength).c_str()).str()); } uint64_t uploadLength; in.read(reinterpret_cast(&uploadLength), sizeof(uploadLength)); @@ -411,7 +411,7 @@ void DefaultBtProgressInfoFile::load() " progress."); } BitfieldMan dest(_dctx->getPieceLength(), totalLength); - Util::convertBitfield(&dest, &src); + util::convertBitfield(&dest, &src); _pieceStorage->setBitfield(dest.getBitfield(), dest.getBitfieldLength()); } _logger->info(MSG_LOADED_SEGMENT_FILE); diff --git a/src/DownloadCommand.cc b/src/DownloadCommand.cc index 77a572cb..fe8a3f14 100644 --- a/src/DownloadCommand.cc +++ b/src/DownloadCommand.cc @@ -320,7 +320,7 @@ void DownloadCommand::validatePieceHash(const SharedHandle& segment, } else { logger->info(EX_INVALID_CHUNK_CHECKSUM, segment->getIndex(), - Util::itos(segment->getPosition(), true).c_str(), + util::itos(segment->getPosition(), true).c_str(), expectedPieceHash.c_str(), actualPieceHash.c_str()); segment->clear(); diff --git a/src/DownloadEngine.cc b/src/DownloadEngine.cc index f6ae285f..03a51844 100644 --- a/src/DownloadEngine.cc +++ b/src/DownloadEngine.cc @@ -274,7 +274,7 @@ void DownloadEngine::poolSocket(const std::string& ipaddr, uint16_t port, const SocketPoolEntry& entry) { - std::string addr = strconcat(ipaddr, ":", Util::uitos(port)); + std::string addr = strconcat(ipaddr, ":", util::uitos(port)); logger->info("Pool socket for %s", addr.c_str()); std::multimap::value_type p(addr, entry); _socketPool.insert(p); @@ -353,7 +353,7 @@ std::multimap::iterator DownloadEngine::findSocketPoolEntry(const std::string& ipaddr, uint16_t port) { std::string addr = ipaddr; - strappend(addr, ":", Util::uitos(port)); + strappend(addr, ":", util::uitos(port)); std::pair::iterator, std::multimap::iterator> range = _socketPool.equal_range(addr); diff --git a/src/ExpatMetalinkProcessor.cc b/src/ExpatMetalinkProcessor.cc index 2100dd47..70f681df 100644 --- a/src/ExpatMetalinkProcessor.cc +++ b/src/ExpatMetalinkProcessor.cc @@ -64,7 +64,7 @@ static void mlStartElement(void* userData, const char* name, const char** attrs) if(*p == 0) { break; } - std::string value = Util::trim(*p++); + std::string value = util::trim(*p++); attrmap[name] = value; } } @@ -79,7 +79,7 @@ static void mlEndElement(void* userData, const char* name) SessionData* sd = reinterpret_cast(userData); std::string characters; if(sd->_stm->needsCharactersBuffering()) { - characters = Util::trim(sd->_charactersStack.front()); + characters = util::trim(sd->_charactersStack.front()); sd->_charactersStack.pop_front(); } sd->_stm->endElement(name, characters); diff --git a/src/ExpatXmlRpcRequestProcessor.cc b/src/ExpatXmlRpcRequestProcessor.cc index 999772e7..60597fdb 100644 --- a/src/ExpatXmlRpcRequestProcessor.cc +++ b/src/ExpatXmlRpcRequestProcessor.cc @@ -67,7 +67,7 @@ static void mlStartElement(void* userData, const char* name, const char** attrs) if(*p == 0) { break; } - std::string value = Util::trim(*p++); + std::string value = util::trim(*p++); attrmap[name] = value; } } @@ -82,7 +82,7 @@ static void mlEndElement(void* userData, const char* name) SessionData* sd = reinterpret_cast(userData); std::string characters; if(sd->_stm->needsCharactersBuffering()) { - characters = Util::trim(sd->_charactersStack.top()); + characters = util::trim(sd->_charactersStack.top()); sd->_charactersStack.pop(); } sd->_stm->endElement(name, characters); diff --git a/src/FeatureConfig.cc b/src/FeatureConfig.cc index e41ce5cd..6a67b886 100644 --- a/src/FeatureConfig.cc +++ b/src/FeatureConfig.cc @@ -158,7 +158,7 @@ std::string FeatureConfig::featureSummary() const s += ", "; } } - return Util::trim(s, ", "); + return util::trim(s, ", "); } } // namespace aria2 diff --git a/src/File.cc b/src/File.cc index 8957a954..944f2d75 100644 --- a/src/File.cc +++ b/src/File.cc @@ -106,13 +106,13 @@ bool File::mkdirs() { return false; } std::vector dirs; - split(name, std::back_inserter(dirs), "/"); + util::split(name, std::back_inserter(dirs), "/"); if(!dirs.size()) { return true; } std::string accDir; - if(Util::startsWith(name, A2STR::SLASH_C)) { + if(util::startsWith(name, A2STR::SLASH_C)) { accDir = A2STR::SLASH_C; } for(std::vector::const_iterator itr = dirs.begin(); diff --git a/src/FileAllocationCommand.cc b/src/FileAllocationCommand.cc index 1f0eda1a..dfa669f3 100644 --- a/src/FileAllocationCommand.cc +++ b/src/FileAllocationCommand.cc @@ -61,7 +61,7 @@ bool FileAllocationCommand::executeInternal() if(_fileAllocationEntry->finished()) { logger->debug(MSG_ALLOCATION_COMPLETED, _timer.difference(), - Util::itos(_requestGroup->getTotalLength(), true).c_str()); + util::itos(_requestGroup->getTotalLength(), true).c_str()); _e->_fileAllocationMan->dropPickedEntry(); std::deque commands; diff --git a/src/FileEntry.cc b/src/FileEntry.cc index f079eda9..ba092b34 100644 --- a/src/FileEntry.cc +++ b/src/FileEntry.cc @@ -61,7 +61,7 @@ FileEntry::~FileEntry() {} void FileEntry::setupDir() { - Util::mkdirs(File(path).getDirname()); + util::mkdirs(File(path).getDirname()); } FileEntry& FileEntry::operator=(const FileEntry& entry) diff --git a/src/FixedWidthNumberDecorator.h b/src/FixedWidthNumberDecorator.h index fac4bf0d..cdcce232 100644 --- a/src/FixedWidthNumberDecorator.h +++ b/src/FixedWidthNumberDecorator.h @@ -51,7 +51,7 @@ public: virtual std::string decorate(unsigned int number) { - std::string s = Util::uitos(number); + std::string s = util::uitos(number); while(s.size() < _width) { s.insert(0, "0"); } diff --git a/src/FtpConnection.cc b/src/FtpConnection.cc index 29636741..3b82c562 100644 --- a/src/FtpConnection.cc +++ b/src/FtpConnection.cc @@ -139,7 +139,7 @@ bool FtpConnection::sendCwd() if(_baseWorkingDir != "/") { request += _baseWorkingDir; } - request += Util::urldecode(req->getDir()); + request += util::urldecode(req->getDir()); request += "\r\n"; logger->info(MSG_SENDING_REQUEST, cuid, request.c_str()); _socketBuffer.feedSendBuffer(request); @@ -152,7 +152,7 @@ bool FtpConnection::sendMdtm() { if(_socketBuffer.sendBufferIsEmpty()) { std::string request = "MDTM "; - request += Util::urlencode(req->getFile()); + request += util::urlencode(req->getFile()); request += "\r\n"; logger->info(MSG_SENDING_REQUEST, cuid, request.c_str()); _socketBuffer.feedSendBuffer(request); @@ -165,7 +165,7 @@ bool FtpConnection::sendSize() { if(_socketBuffer.sendBufferIsEmpty()) { std::string request = "SIZE "; - request += Util::urldecode(req->getFile()); + request += util::urldecode(req->getFile()); request += "\r\n"; logger->info(MSG_SENDING_REQUEST, cuid, request.c_str()); _socketBuffer.feedSendBuffer(request); @@ -204,17 +204,17 @@ bool FtpConnection::sendPort(const SharedHandle& serverSocket) &ipaddr[0], &ipaddr[1], &ipaddr[2], &ipaddr[3]); serverSocket->getAddrInfo(addrinfo); std::string request = "PORT "; - request += Util::uitos(ipaddr[0]); + request += util::uitos(ipaddr[0]); request += ","; - request += Util::uitos(ipaddr[1]); + request += util::uitos(ipaddr[1]); request += ","; - request += Util::uitos(ipaddr[2]); + request += util::uitos(ipaddr[2]); request += ","; - request += Util::uitos(ipaddr[3]); + request += util::uitos(ipaddr[3]); request += ","; - request += Util::uitos(addrinfo.second/256); + request += util::uitos(addrinfo.second/256); request += ","; - request += Util::uitos(addrinfo.second%256); + request += util::uitos(addrinfo.second%256); request += "\r\n"; logger->info(MSG_SENDING_REQUEST, cuid, request.c_str()); _socketBuffer.feedSendBuffer(request); @@ -230,7 +230,7 @@ bool FtpConnection::sendRest(const SegmentHandle& segment) if(segment.isNull()) { request += "0"; } else { - request += Util::itos(segment->getPositionToWrite()); + request += util::itos(segment->getPositionToWrite()); } request += "\r\n"; @@ -245,7 +245,7 @@ bool FtpConnection::sendRetr() { if(_socketBuffer.sendBufferIsEmpty()) { std::string request = "RETR "; - request += Util::urldecode(req->getFile()); + request += util::urldecode(req->getFile()); request += "\r\n"; logger->info(MSG_SENDING_REQUEST, cuid, request.c_str()); _socketBuffer.feedSendBuffer(request); @@ -286,7 +286,7 @@ FtpConnection::findEndOfResponse(unsigned int status, std::string::size_type p; std::string endPattern = A2STR::CRLF; - endPattern += Util::uitos(status); + endPattern += util::uitos(status); endPattern += " "; p = buf.find(endPattern); if(p == std::string::npos) { @@ -378,8 +378,8 @@ unsigned int FtpConnection::receiveSizeResponse(uint64_t& size) std::pair response; if(bulkReceiveResponse(response)) { if(response.first == 213) { - std::pair rp = Util::split(response.second," "); - size = Util::parseULLInt(rp.second); + std::pair rp = util::split(response.second," "); + size = util::parseULLInt(rp.second); } return response.first; } else { @@ -400,17 +400,17 @@ unsigned int FtpConnection::receiveMdtmResponse(Time& time) // and included strptime doesn't parse data for this format. struct tm tm; memset(&tm, 0, sizeof(tm)); - tm.tm_sec = Util::parseInt(&buf[12]); + tm.tm_sec = util::parseInt(&buf[12]); buf[12] = '\0'; - tm.tm_min = Util::parseInt(&buf[10]); + tm.tm_min = util::parseInt(&buf[10]); buf[10] = '\0'; - tm.tm_hour = Util::parseInt(&buf[8]); + tm.tm_hour = util::parseInt(&buf[8]); buf[8] = '\0'; - tm.tm_mday = Util::parseInt(&buf[6]); + tm.tm_mday = util::parseInt(&buf[6]); buf[6] = '\0'; - tm.tm_mon = Util::parseInt(&buf[4])-1; + tm.tm_mon = util::parseInt(&buf[4])-1; buf[4] = '\0'; - tm.tm_year = Util::parseInt(&buf[0])-1900; + tm.tm_year = util::parseInt(&buf[0])-1900; time = Time(timegm(&tm)); } else { time = Time::null(); @@ -435,13 +435,13 @@ unsigned int FtpConnection::receivePasvResponse(std::pair "(%u,%u,%u,%u,%u,%u).", &h1, &h2, &h3, &h4, &p1, &p2); // ip address - dest.first = Util::uitos(h1); + dest.first = util::uitos(h1); dest.first += "."; - dest.first += Util::uitos(h2); + dest.first += util::uitos(h2); dest.first += "."; - dest.first += Util::uitos(h3); + dest.first += util::uitos(h3); dest.first += "."; - dest.first += Util::uitos(h4); + dest.first += util::uitos(h4); // port number dest.second = 256*p1+p2; } else { diff --git a/src/FtpNegotiationCommand.cc b/src/FtpNegotiationCommand.cc index b49840b7..2c7bc051 100644 --- a/src/FtpNegotiationCommand.cc +++ b/src/FtpNegotiationCommand.cc @@ -337,7 +337,7 @@ bool FtpNegotiationCommand::onFileSizeDetermined(uint64_t totalLength) if(getOption()->get(PREF_OUT).empty()) { _fileEntry->setPath (strconcat(getDownloadContext()->getDir(), - "/", Util::urldecode(req->getFile()))); + "/", util::urldecode(req->getFile()))); } _requestGroup->preDownloadProcessing(); if(e->_requestGroupMan->isSameFileBeingDownloaded(_requestGroup)) { @@ -430,7 +430,7 @@ bool FtpNegotiationCommand::recvSize() { if(size > INT64_MAX) { throw DL_ABORT_EX - (StringFormat(EX_TOO_LARGE_FILE, Util::uitos(size, true).c_str()).str()); + (StringFormat(EX_TOO_LARGE_FILE, util::uitos(size, true).c_str()).str()); } if(_requestGroup->getPieceStorage().isNull()) { diff --git a/src/HandshakeExtensionMessage.cc b/src/HandshakeExtensionMessage.cc index 370746f4..6573b2a2 100644 --- a/src/HandshakeExtensionMessage.cc +++ b/src/HandshakeExtensionMessage.cc @@ -75,15 +75,15 @@ std::string HandshakeExtensionMessage::toString() const { std::string s = getExtensionName(); if(!_clientVersion.empty()) { - strappend(s, " client=", Util::urlencode(_clientVersion)); + strappend(s, " client=", util::urlencode(_clientVersion)); } if(_tcpPort > 0) { - strappend(s, ", tcpPort=", Util::uitos(_tcpPort)); + strappend(s, ", tcpPort=", util::uitos(_tcpPort)); } for(std::map::const_iterator itr = _extensions.begin(); itr != _extensions.end(); ++itr) { const std::map::value_type& vt = *itr; - strappend(s, ", ", vt.first, "=", Util::uitos(vt.second)); + strappend(s, ", ", vt.first, "=", util::uitos(vt.second)); } return s; } @@ -126,7 +126,7 @@ HandshakeExtensionMessage::create(const unsigned char* data, size_t length) } HandshakeExtensionMessageHandle msg(new HandshakeExtensionMessage()); msg->_logger->debug("Creating HandshakeExtensionMessage from %s", - Util::urlencode(data, length).c_str()); + util::urlencode(data, length).c_str()); const BDE dict = bencode::decode(data+1, length-1); if(!dict.isDict()) { throw DL_ABORT_EX("Unexpected payload format for extended message handshake"); diff --git a/src/HttpConnection.cc b/src/HttpConnection.cc index df8af57d..19f3583f 100644 --- a/src/HttpConnection.cc +++ b/src/HttpConnection.cc @@ -80,9 +80,9 @@ std::string HttpConnection::eraseConfidentialInfo(const std::string& request) while(getline(istr, line)) { static const std::string AUTH_HEADER("Authorization: Basic"); static const std::string PROXY_AUTH_HEADER("Proxy-Authorization: Basic"); - if(Util::startsWith(line, AUTH_HEADER)) { + if(util::startsWith(line, AUTH_HEADER)) { result += "Authorization: Basic ********\n"; - } else if(Util::startsWith(line, PROXY_AUTH_HEADER)) { + } else if(util::startsWith(line, PROXY_AUTH_HEADER)) { result += "Proxy-Authorization: Basic ********\n"; } else { strappend(result, line, "\n"); diff --git a/src/HttpHeader.cc b/src/HttpHeader.cc index 73b1dccb..ba8a9234 100644 --- a/src/HttpHeader.cc +++ b/src/HttpHeader.cc @@ -85,16 +85,16 @@ const std::string HttpHeader::S401("401"); const std::string HttpHeader::S404("404"); void HttpHeader::put(const std::string& name, const std::string& value) { - std::multimap::value_type vt(Util::toLower(name), value); + std::multimap::value_type vt(util::toLower(name), value); table.insert(vt); } bool HttpHeader::defined(const std::string& name) const { - return table.count(Util::toLower(name)) >= 1; + return table.count(util::toLower(name)) >= 1; } const std::string& HttpHeader::getFirst(const std::string& name) const { - std::multimap::const_iterator itr = table.find(Util::toLower(name)); + std::multimap::const_iterator itr = table.find(util::toLower(name)); if(itr == table.end()) { return A2STR::NIL; } else { @@ -105,7 +105,7 @@ const std::string& HttpHeader::getFirst(const std::string& name) const { std::deque HttpHeader::get(const std::string& name) const { std::deque v; - std::string n(Util::toLower(name)); + std::string n(util::toLower(name)); std::multimap::const_iterator first = table.lower_bound(n); @@ -128,7 +128,7 @@ uint64_t HttpHeader::getFirstAsULLInt(const std::string& name) const { if(value.empty()) { return 0; } else { - return Util::parseULLInt(value); + return util::parseULLInt(value); } } @@ -140,7 +140,7 @@ RangeHandle HttpHeader::getRange() const if(contentLengthStr.empty()) { return SharedHandle(new Range()); } else { - uint64_t contentLength = Util::parseULLInt(contentLengthStr); + uint64_t contentLength = util::parseULLInt(contentLengthStr); if(contentLength == 0) { return SharedHandle(new Range()); } else { @@ -154,7 +154,7 @@ RangeHandle HttpHeader::getRange() const // but some server returns '100-199/100', omitting bytes-unit sepcifier // 'bytes'. std::pair splist; - Util::split(splist, rangeStr, ' '); + util::split(splist, rangeStr, ' '); if(splist.second.empty()) { // we assume bytes-unit specifier omitted. byteRangeSpec = splist.first; @@ -163,14 +163,14 @@ RangeHandle HttpHeader::getRange() const } } std::pair byteRangeSpecPair; - Util::split(byteRangeSpecPair, byteRangeSpec, '/'); + util::split(byteRangeSpecPair, byteRangeSpec, '/'); std::pair byteRangeRespSpecPair; - Util::split(byteRangeRespSpecPair, byteRangeSpecPair.first, '-'); + util::split(byteRangeRespSpecPair, byteRangeSpecPair.first, '-'); - off_t startByte = Util::parseLLInt(byteRangeRespSpecPair.first); - off_t endByte = Util::parseLLInt(byteRangeRespSpecPair.second); - uint64_t entityLength = Util::parseULLInt(byteRangeSpecPair.second); + off_t startByte = util::parseLLInt(byteRangeRespSpecPair.first); + off_t endByte = util::parseLLInt(byteRangeRespSpecPair.second); + uint64_t entityLength = util::parseULLInt(byteRangeSpecPair.second); return SharedHandle(new Range(startByte, endByte, entityLength)); } @@ -199,12 +199,12 @@ void HttpHeader::fill(std::istream& in) { std::string line; while(std::getline(in, line)) { - line = Util::trim(line); + line = util::trim(line); if(line.empty()) { continue; } std::pair hp; - Util::split(hp, line, ':'); + util::split(hp, line, ':'); put(hp.first, hp.second); } } diff --git a/src/HttpHeaderProcessor.cc b/src/HttpHeaderProcessor.cc index 10e472a2..51fe501b 100644 --- a/src/HttpHeaderProcessor.cc +++ b/src/HttpHeaderProcessor.cc @@ -126,7 +126,7 @@ SharedHandle HttpHeaderProcessor::getHttpRequestHeader() throw DL_RETRY_EX(EX_NO_STATUS_HEADER); } std::vector firstLine; - split(_buf.substr(0, delimpos), std::back_inserter(firstLine), " ", true); + util::split(_buf.substr(0, delimpos), std::back_inserter(firstLine)," ",true); if(firstLine.size() != 3) { throw DL_ABORT_EX("Malformed HTTP request header."); } diff --git a/src/HttpRequest.cc b/src/HttpRequest.cc index 7bf407dc..d4dbad6f 100644 --- a/src/HttpRequest.cc +++ b/src/HttpRequest.cc @@ -122,7 +122,7 @@ static std::string getHostText(const std::string& host, uint16_t port) { std::string hosttext = host; if(!(port == 80 || port == 443)) { - strappend(hosttext, ":", Util::uitos(port)); + strappend(hosttext, ":", util::uitos(port)); } return hosttext; } @@ -138,7 +138,7 @@ std::string HttpRequest::createRequest() // Insert user into URI, like ftp://USER@host/ std::string uri = getCurrentURI(); assert(uri.size() >= 6); - uri.insert(6, Util::urlencode(_authConfig->getUser())+"@"); + uri.insert(6, util::urlencode(_authConfig->getUser())+"@"); requestLine += uri; } else { requestLine += getCurrentURI(); @@ -183,10 +183,10 @@ std::string HttpRequest::createRequest() if(!segment.isNull() && segment->getLength() > 0 && (request->isPipeliningEnabled() || getStartByte() > 0)) { requestLine += "Range: bytes="; - requestLine += Util::itos(getStartByte()); + requestLine += util::itos(getStartByte()); requestLine += "-"; if(request->isPipeliningEnabled()) { - requestLine += Util::itos(getEndByte()); + requestLine += util::itos(getEndByte()); } requestLine += "\r\n"; } @@ -237,7 +237,7 @@ std::string HttpRequest::createProxyRequest() const { assert(!_proxyRequest.isNull()); std::string hostport = getURIHost(); - strappend(hostport, ":", Util::uitos(getPort())); + strappend(hostport, ":", util::uitos(getPort())); std::string requestLine = "CONNECT "; strappend(requestLine, hostport, " HTTP/1.1\r\n"); @@ -278,7 +278,7 @@ void HttpRequest::disableContentEncoding() void HttpRequest::addHeader(const std::string& headersString) { std::vector headers; - split(headersString, std::back_inserter(headers), "\n", true); + util::split(headersString, std::back_inserter(headers), "\n", true); _headers.insert(_headers.end(), headers.begin(), headers.end()); } diff --git a/src/HttpResponse.cc b/src/HttpResponse.cc index 6d08c4b0..fce66f7e 100644 --- a/src/HttpResponse.cc +++ b/src/HttpResponse.cc @@ -76,7 +76,7 @@ void HttpResponse::validateResponse() const if(!httpHeader->defined(HttpHeader::LOCATION)) { throw DL_ABORT_EX (StringFormat(EX_LOCATION_HEADER_REQUIRED, - Util::parseUInt(status)).str()); + util::parseUInt(status)).str()); } } else if(!httpHeader->defined(HttpHeader::TRANSFER_ENCODING)) { // compare the received range against the requested range @@ -85,12 +85,12 @@ void HttpResponse::validateResponse() const throw DL_ABORT_EX (StringFormat (EX_INVALID_RANGE_HEADER, - Util::itos(httpRequest->getStartByte(), true).c_str(), - Util::itos(httpRequest->getEndByte(), true).c_str(), - Util::uitos(httpRequest->getEntityLength(), true).c_str(), - Util::itos(responseRange->getStartByte(), true).c_str(), - Util::itos(responseRange->getEndByte(), true).c_str(), - Util::uitos(responseRange->getEntityLength(), true).c_str()).str()); + util::itos(httpRequest->getStartByte(), true).c_str(), + util::itos(httpRequest->getEndByte(), true).c_str(), + util::uitos(httpRequest->getEntityLength(), true).c_str(), + util::itos(responseRange->getStartByte(), true).c_str(), + util::itos(responseRange->getEndByte(), true).c_str(), + util::uitos(responseRange->getEntityLength(), true).c_str()).str()); } } } @@ -98,10 +98,10 @@ void HttpResponse::validateResponse() const std::string HttpResponse::determinFilename() const { std::string contentDisposition = - Util::getContentDispositionFilename + util::getContentDispositionFilename (httpHeader->getFirst(HttpHeader::CONTENT_DISPOSITION)); if(contentDisposition.empty()) { - std::string file = Util::urldecode(httpRequest->getFile()); + std::string file = util::urldecode(httpRequest->getFile()); if(file.empty()) { return "index.html"; } else { @@ -110,7 +110,7 @@ std::string HttpResponse::determinFilename() const } else { logger->info(MSG_CONTENT_DISPOSITION_DETECTED, cuid, contentDisposition.c_str()); - return Util::urldecode(contentDisposition); + return util::urldecode(contentDisposition); } } @@ -219,7 +219,7 @@ std::string HttpResponse::getContentType() const return A2STR::NIL; } else { return - Util::split(httpHeader->getFirst(HttpHeader::CONTENT_TYPE), ";").first; + util::split(httpHeader->getFirst(HttpHeader::CONTENT_TYPE), ";").first; } } @@ -257,7 +257,7 @@ Time HttpResponse::getLastModifiedTime() const bool HttpResponse::supportsPersistentConnection() const { std::string connection = - Util::toLower(httpHeader->getFirst(HttpHeader::CONNECTION)); + util::toLower(httpHeader->getFirst(HttpHeader::CONNECTION)); std::string version = httpHeader->getVersion(); return @@ -265,7 +265,7 @@ bool HttpResponse::supportsPersistentConnection() const (version == HttpHeader::HTTP_1_1 || connection.find("keep-alive") != std::string::npos) && (!httpRequest->isProxyRequestSet() || - Util::toLower(httpHeader->getFirst("Proxy-Connection")).find("keep-alive") + util::toLower(httpHeader->getFirst("Proxy-Connection")).find("keep-alive") != std::string::npos); } diff --git a/src/HttpResponseCommand.cc b/src/HttpResponseCommand.cc index b9819d4a..682f0764 100644 --- a/src/HttpResponseCommand.cc +++ b/src/HttpResponseCommand.cc @@ -196,8 +196,8 @@ void HttpResponseCommand::updateLastModifiedTime(const Time& lastModified) static bool fileIsGzipped(const SharedHandle& httpResponse) { std::string filename = - Util::toLower(httpResponse->getHttpRequest()->getRequest()->getFile()); - return Util::endsWith(filename, ".gz") || Util::endsWith(filename, ".tgz"); + util::toLower(httpResponse->getHttpRequest()->getRequest()->getFile()); + return util::endsWith(filename, ".gz") || util::endsWith(filename, ".tgz"); } bool HttpResponseCommand::shouldInflateContentEncoding diff --git a/src/HttpServer.cc b/src/HttpServer.cc index 1ad764c0..ec39253f 100644 --- a/src/HttpServer.cc +++ b/src/HttpServer.cc @@ -128,7 +128,7 @@ bool HttpServer::supportsPersistentConnection() const } std::string connection = - Util::toLower(_lastRequestHeader->getFirst(HttpHeader::CONNECTION)); + util::toLower(_lastRequestHeader->getFirst(HttpHeader::CONNECTION)); return connection.find(HttpHeader::CLOSE) == std::string::npos && (_lastRequestHeader->getVersion() == HttpHeader::HTTP_1_1 || @@ -148,14 +148,14 @@ void HttpServer::feedResponse(const std::string& status, std::string header = "HTTP/1.1 "; strappend(header, status, "\r\n", "Content-Type: ", contentType, "\r\n", - "Content-Length: ", Util::uitos(text.size()), "\r\n"); + "Content-Length: ", util::uitos(text.size()), "\r\n"); if(!supportsPersistentConnection()) { header += "Connection: close\r\n"; } if(!headers.empty()) { header += headers; - if(!Util::endsWith(headers, "\r\n")) { + if(!util::endsWith(headers, "\r\n")) { header += "\r\n"; } } @@ -188,12 +188,12 @@ bool HttpServer::authenticate() if(authHeader.empty()) { return false; } - std::pair p = Util::split(authHeader, " "); + std::pair p = util::split(authHeader, " "); if(p.first != "Basic") { return false; } std::string userpass = Base64::decode(p.second); - std::pair userpassPair = Util::split(userpass, ":"); + std::pair userpassPair = util::split(userpass, ":"); return _username == userpassPair.first && _password == userpassPair.second; } diff --git a/src/HttpServerCommand.cc b/src/HttpServerCommand.cc index 74518f42..aa69ea13 100644 --- a/src/HttpServerCommand.cc +++ b/src/HttpServerCommand.cc @@ -113,7 +113,7 @@ bool HttpServerCommand::execute() logger->info("Request too long. ContentLength=%s." " See --xml-rpc-max-request-size option to loose" " this limitation.", - Util::uitos(_httpServer->getContentLength()).c_str()); + util::uitos(_httpServer->getContentLength()).c_str()); return true; } Command* command = new HttpServerBodyCommand(cuid, _httpServer, _e, diff --git a/src/HttpSkipResponseCommand.cc b/src/HttpSkipResponseCommand.cc index d22444a9..31322c1b 100644 --- a/src/HttpSkipResponseCommand.cc +++ b/src/HttpSkipResponseCommand.cc @@ -171,7 +171,7 @@ bool HttpSkipResponseCommand::processResponse() throw DL_ABORT_EX2(MSG_RESOURCE_NOT_FOUND, downloadresultcode::RESOURCE_NOT_FOUND); } else { - throw DL_ABORT_EX(StringFormat(EX_BAD_STATUS, Util::parseUInt(_httpResponse->getResponseStatus())).str()); + throw DL_ABORT_EX(StringFormat(EX_BAD_STATUS, util::parseUInt(_httpResponse->getResponseStatus())).str()); } } else { return prepareForRetry(0); diff --git a/src/IndexBtMessage.cc b/src/IndexBtMessage.cc index 3c23666a..589248be 100644 --- a/src/IndexBtMessage.cc +++ b/src/IndexBtMessage.cc @@ -62,7 +62,7 @@ size_t IndexBtMessage::getMessageLength() std::string IndexBtMessage::toString() const { - return strconcat(getName(), " index=", Util::itos(_index)); + return strconcat(getName(), " index=", util::itos(_index)); } } // namespace aria2 diff --git a/src/IteratableChecksumValidator.cc b/src/IteratableChecksumValidator.cc index a3be0a21..5d59ab3f 100644 --- a/src/IteratableChecksumValidator.cc +++ b/src/IteratableChecksumValidator.cc @@ -79,7 +79,7 @@ void IteratableChecksumValidator::validateChunk() _ctx->digestUpdate(_buffer, length); _currentOffset += length; if(finished()) { - std::string actualChecksum = Util::toHex((const unsigned char*)_ctx->digestFinal().c_str(), _ctx->digestLength()); + std::string actualChecksum = util::toHex((const unsigned char*)_ctx->digestFinal().c_str(), _ctx->digestLength()); if(_dctx->getChecksum() == actualChecksum) { _pieceStorage->markAllPiecesDone(); } else { @@ -109,7 +109,7 @@ void IteratableChecksumValidator::init() { #ifdef HAVE_POSIX_MEMALIGN free(_buffer); - _buffer = (unsigned char*)Util::allocateAlignedMemory(ALIGNMENT, BUFSIZE); + _buffer = (unsigned char*)util::allocateAlignedMemory(ALIGNMENT, BUFSIZE); #else // !HAVE_POSIX_MEMALIGN delete [] _buffer; _buffer = new unsigned char[BUFSIZE]; diff --git a/src/IteratableChunkChecksumValidator.cc b/src/IteratableChunkChecksumValidator.cc index b58ab90d..98b1719e 100644 --- a/src/IteratableChunkChecksumValidator.cc +++ b/src/IteratableChunkChecksumValidator.cc @@ -88,7 +88,7 @@ void IteratableChunkChecksumValidator::validateChunk() } else { _logger->info(EX_INVALID_CHUNK_CHECKSUM, _currentIndex, - Util::itos(getCurrentOffset(), true).c_str(), + util::itos(getCurrentOffset(), true).c_str(), _dctx->getPieceHashes()[_currentIndex].c_str(), actualChecksum.c_str()); _bitfield->unsetBit(_currentIndex); @@ -122,7 +122,7 @@ void IteratableChunkChecksumValidator::init() { #ifdef HAVE_POSIX_MEMALIGN free(_buffer); - _buffer = (unsigned char*)Util::allocateAlignedMemory(ALIGNMENT, BUFSIZE); + _buffer = (unsigned char*)util::allocateAlignedMemory(ALIGNMENT, BUFSIZE); #else // !HAVE_POSIX_MEMALIGN delete [] _buffer; _buffer = new unsigned char[BUFSIZE]; @@ -166,7 +166,7 @@ std::string IteratableChunkChecksumValidator::digest(off_t offset, size_t length curoffset += r; woffset = 0; } - return Util::toHex((const unsigned char*)_ctx->digestFinal().c_str(), _ctx->digestLength()); + return util::toHex((const unsigned char*)_ctx->digestFinal().c_str(), _ctx->digestLength()); } diff --git a/src/MSEHandshake.cc b/src/MSEHandshake.cc index 760002bc..0e1f0c74 100644 --- a/src/MSEHandshake.cc +++ b/src/MSEHandshake.cc @@ -453,7 +453,7 @@ bool MSEHandshake::receiveReceiverHashAndPadCLength createReq23Hash(md, torrentAttrs[bittorrent::INFO_HASH].uc()); if(memcmp(md, rbufptr, sizeof(md)) == 0) { _logger->debug("CUID#%d - info hash found: %s", _cuid, - Util::toHex(torrentAttrs[bittorrent::INFO_HASH].s()).c_str()); + util::toHex(torrentAttrs[bittorrent::INFO_HASH].s()).c_str()); downloadContext = *i; break; } @@ -577,7 +577,7 @@ void MSEHandshake::verifyVC(const unsigned char* vcbuf) _decryptor->decrypt(vc, sizeof(vc), vcbuf, sizeof(vc)); if(memcmp(VC, vc, sizeof(VC)) != 0) { throw DL_ABORT_EX - (StringFormat("Invalid VC: %s", Util::toHex(vc, VC_LENGTH).c_str()).str()); + (StringFormat("Invalid VC: %s", util::toHex(vc, VC_LENGTH).c_str()).str()); } } diff --git a/src/MessageDigestHelper.cc b/src/MessageDigestHelper.cc index ba8df4e5..c5a71307 100644 --- a/src/MessageDigestHelper.cc +++ b/src/MessageDigestHelper.cc @@ -106,7 +106,7 @@ std::string MessageDigestHelper::digest(MessageDigestContext* ctx, ctx->digestUpdate(BUF, readLength); } std::string rawMD = ctx->digestFinal(); - return Util::toHex((const unsigned char*)rawMD.c_str(), rawMD.size()); + return util::toHex((const unsigned char*)rawMD.c_str(), rawMD.size()); } std::string MessageDigestHelper::digest(const std::string& algo, const std::string& filename) @@ -123,7 +123,7 @@ std::string MessageDigestHelper::digest(const std::string& algo, const void* dat ctx.digestInit(); ctx.digestUpdate(data, length); std::string rawMD = ctx.digestFinal(); - return Util::toHex((const unsigned char*)rawMD.c_str(), rawMD.size()); + return util::toHex((const unsigned char*)rawMD.c_str(), rawMD.size()); } void MessageDigestHelper::digest(unsigned char* md, size_t mdLength, diff --git a/src/Metalink2RequestGroup.cc b/src/Metalink2RequestGroup.cc index dabd04a6..c70f01e9 100644 --- a/src/Metalink2RequestGroup.cc +++ b/src/Metalink2RequestGroup.cc @@ -130,7 +130,7 @@ Metalink2RequestGroup::createRequestGroup return; } std::deque selectIndexes = - Util::parseIntRange(option->get(PREF_SELECT_FILE)).flush(); + util::parseIntRange(option->get(PREF_SELECT_FILE)).flush(); bool useIndex; if(selectIndexes.size()) { useIndex = true; @@ -143,8 +143,8 @@ Metalink2RequestGroup::createRequestGroup SharedHandle& entry = *itr; if(option->defined(PREF_METALINK_LOCATION)) { std::deque locations; - split(option->get(PREF_METALINK_LOCATION), std::back_inserter(locations), - ",", true); + util::split(option->get(PREF_METALINK_LOCATION), + std::back_inserter(locations), ",", true); entry->setLocationPreference(locations, 100); } if(option->get(PREF_METALINK_PREFERRED_PROTOCOL) != V_NONE) { diff --git a/src/MetalinkEntry.cc b/src/MetalinkEntry.cc index 056e3bbc..8f1d1eaa 100644 --- a/src/MetalinkEntry.cc +++ b/src/MetalinkEntry.cc @@ -64,7 +64,7 @@ public: AddLocationPreference(const std::deque& locations, int preferenceToAdd): _locations(locations), _preferenceToAdd(preferenceToAdd) { - std::transform(_locations.begin(), _locations.end(), _locations.begin(), Util::toUpper); + std::transform(_locations.begin(), _locations.end(), _locations.begin(), util::toUpper); std::sort(_locations.begin(), _locations.end()); } diff --git a/src/MetalinkParserController.cc b/src/MetalinkParserController.cc index 71b45e75..d6cfc923 100644 --- a/src/MetalinkParserController.cc +++ b/src/MetalinkParserController.cc @@ -77,8 +77,8 @@ void MetalinkParserController::setFileNameOfEntry(const std::string& filename) return; } std::vector elements; - split(filename, std::back_inserter(elements), "/"); - std::string path = Util::joinPath(elements.begin(), elements.end()); + util::split(filename, std::back_inserter(elements), "/"); + std::string path = util::joinPath(elements.begin(), elements.end()); if(_tEntry->file.isNull()) { _tEntry->file.reset(new FileEntry(path, 0, 0)); diff --git a/src/MetalinkParserStateImpl.cc b/src/MetalinkParserStateImpl.cc index 03d71080..14239381 100644 --- a/src/MetalinkParserStateImpl.cc +++ b/src/MetalinkParserStateImpl.cc @@ -131,7 +131,7 @@ void FileMetalinkParserState::beginElement maxConnections = -1; } else { try { - maxConnections = Util::parseInt((*itr).second); + maxConnections = util::parseInt((*itr).second); } catch(RecoverableException& e) { maxConnections = -1; } @@ -165,7 +165,7 @@ void SizeMetalinkParserState::endElement const std::string& characters) { try { - stm->setFileLengthOfEntry(Util::parseLLInt(characters)); + stm->setFileLengthOfEntry(util::parseLLInt(characters)); } catch(RecoverableException& e) { // current metalink specification doesn't require size element. } @@ -245,7 +245,7 @@ void VerificationMetalinkParserState::beginElement if(itr == attrs.end()) { return; } else { - length = Util::parseInt((*itr).second); + length = util::parseInt((*itr).second); } } std::string type; @@ -314,7 +314,7 @@ void PiecesMetalinkParserState::beginElement stm->cancelChunkChecksumTransaction(); } else { try { - stm->createNewHashOfChunkChecksum(Util::parseInt((*itr).second)); + stm->createNewHashOfChunkChecksum(util::parseInt((*itr).second)); } catch(RecoverableException& e) { stm->cancelChunkChecksumTransaction(); } @@ -387,7 +387,7 @@ void ResourcesMetalinkParserState::beginElement std::map::const_iterator itr = attrs.find(LOCATION); if(itr != attrs.end()) { - location = Util::toUpper((*itr).second); + location = util::toUpper((*itr).second); } } int preference; @@ -398,7 +398,7 @@ void ResourcesMetalinkParserState::beginElement preference = 0; } else { try { - preference = Util::parseInt((*itr).second); + preference = util::parseInt((*itr).second); } catch(RecoverableException& e) { preference = 0; } @@ -412,7 +412,7 @@ void ResourcesMetalinkParserState::beginElement maxConnections = -1; } else { try { - maxConnections = Util::parseInt((*itr).second); + maxConnections = util::parseInt((*itr).second); } catch(RecoverableException& e) { maxConnections = -1; } diff --git a/src/MultiDiskAdaptor.cc b/src/MultiDiskAdaptor.cc index 928d339b..2d0d1743 100644 --- a/src/MultiDiskAdaptor.cc +++ b/src/MultiDiskAdaptor.cc @@ -271,7 +271,7 @@ void MultiDiskAdaptor::openIfNot { if(!entry->isOpen()) { // logger->debug("DiskWriterEntry: Cache MISS. offset=%s", -// Util::itos(entry->getFileEntry()->getOffset()).c_str()); +// util::itos(entry->getFileEntry()->getOffset()).c_str()); size_t numOpened = _openedDiskWriterEntries.size(); (entry.get()->*open)(); @@ -289,7 +289,7 @@ void MultiDiskAdaptor::openIfNot } } else { // logger->debug("DiskWriterEntry: Cache HIT. offset=%s", -// Util::itos(entry->getFileEntry()->getOffset()).c_str()); +// util::itos(entry->getFileEntry()->getOffset()).c_str()); } } @@ -369,7 +369,7 @@ findFirstDiskWriterEntry(const DiskWriterEntries& diskWriterEntries, off_t offse if(!isInRange(*first, offset)) { throw DL_ABORT_EX (StringFormat(EX_FILE_OFFSET_OUT_OF_RANGE, - Util::itos(offset, true).c_str()).str()); + util::itos(offset, true).c_str()).str()); } return first; } @@ -379,7 +379,7 @@ static void throwOnDiskWriterNotOpened(const SharedHandle& e, { throw DL_ABORT_EX (StringFormat("DiskWriter for offset=%s, filename=%s is not opened.", - Util::itos(offset).c_str(), + util::itos(offset).c_str(), e->getFilePath().c_str()).str()); } diff --git a/src/MultiUrlRequestInfo.cc b/src/MultiUrlRequestInfo.cc index 0fca516a..20318146 100644 --- a/src/MultiUrlRequestInfo.cc +++ b/src/MultiUrlRequestInfo.cc @@ -170,8 +170,8 @@ downloadresultcode::RESULT MultiUrlRequestInfo::execute() // This is done every 1 second. At the same time, it removes finished/error // RequestGroup from DownloadEngine. - Util::setGlobalSignalHandler(SIGINT, handler, 0); - Util::setGlobalSignalHandler(SIGTERM, handler, 0); + util::setGlobalSignalHandler(SIGINT, handler, 0); + util::setGlobalSignalHandler(SIGTERM, handler, 0); e->run(); @@ -199,8 +199,8 @@ downloadresultcode::RESULT MultiUrlRequestInfo::execute() } catch(RecoverableException& e) { _logger->error(EX_EXCEPTION_CAUGHT, e); } - Util::setGlobalSignalHandler(SIGINT, SIG_DFL, 0); - Util::setGlobalSignalHandler(SIGTERM, SIG_DFL, 0); + util::setGlobalSignalHandler(SIGINT, SIG_DFL, 0); + util::setGlobalSignalHandler(SIGTERM, SIG_DFL, 0); return returnValue; } diff --git a/src/NameMatchOptionHandler.h b/src/NameMatchOptionHandler.h index 5d6e4842..c34a8279 100644 --- a/src/NameMatchOptionHandler.h +++ b/src/NameMatchOptionHandler.h @@ -118,7 +118,7 @@ public: std::stringstream s; std::copy(_tags.begin(), _tags.end(), std::ostream_iterator(s, ",")); - return Util::trim(s.str(), ", "); + return util::trim(s.str(), ", "); } virtual const std::string& getName() const diff --git a/src/NameResolver.cc b/src/NameResolver.cc index 02086169..596cfd58 100644 --- a/src/NameResolver.cc +++ b/src/NameResolver.cc @@ -62,7 +62,7 @@ void NameResolver::resolve(std::deque& resolvedAddresses, struct addrinfo* rp; for(rp = res; rp; rp = rp->ai_next) { std::pair addressPort - = Util::getNumericNameInfo(rp->ai_addr, rp->ai_addrlen); + = util::getNumericNameInfo(rp->ai_addr, rp->ai_addrlen); resolvedAddresses.push_back(addressPort.first); } freeaddrinfo(res); diff --git a/src/Netrc.cc b/src/Netrc.cc index d5332945..cbdffac8 100644 --- a/src/Netrc.cc +++ b/src/Netrc.cc @@ -89,11 +89,11 @@ void Netrc::parse(const std::string& path) std::string line; STATE state = GET_TOKEN; while(getline(f, line)) { - if(Util::startsWith(line, "#")) { + if(util::startsWith(line, "#")) { continue; } std::vector tokens; - split(line, std::back_inserter(tokens), " \t", true); + util::split(line, std::back_inserter(tokens), " \t", true); for(std::vector::const_iterator iter = tokens.begin(); iter != tokens.end(); ++iter) { const std::string& token = *iter; diff --git a/src/NsCookieParser.cc b/src/NsCookieParser.cc index 962dcef1..b5ec205c 100644 --- a/src/NsCookieParser.cc +++ b/src/NsCookieParser.cc @@ -53,12 +53,12 @@ static const std::string C_TRUE("TRUE"); static Cookie parseNsCookie(const std::string& nsCookieStr) { std::vector vs; - split(nsCookieStr, std::back_inserter(vs), "\t", true); + util::split(nsCookieStr, std::back_inserter(vs), "\t", true); if(vs.size() < 6 ) { return Cookie(); } - int64_t expireDate = Util::parseLLInt(vs[4]); + int64_t expireDate = util::parseLLInt(vs[4]); // TODO assuming time_t is int32_t... if(expireDate > INT32_MAX) { expireDate = INT32_MAX; @@ -84,7 +84,7 @@ std::deque NsCookieParser::parse(const std::string& filename) std::string line; std::deque cookies; while(getline(s, line)) { - if(Util::startsWith(line, A2STR::SHARP_C)) { + if(util::startsWith(line, A2STR::SHARP_C)) { continue; } try { diff --git a/src/OptionHandlerFactory.cc b/src/OptionHandlerFactory.cc index 2c4593ab..af4a48f0 100644 --- a/src/OptionHandlerFactory.cc +++ b/src/OptionHandlerFactory.cc @@ -115,7 +115,7 @@ OptionHandlers OptionHandlerFactory::createOptionHandlers() SharedHandle op(new DefaultOptionHandler (PREF_CONF_PATH, TEXT_CONF_PATH, - Util::getHomeDir()+"/.aria2/aria2.conf")); + util::getHomeDir()+"/.aria2/aria2.conf")); op->addTag(TAG_ADVANCED); handlers.push_back(op); } @@ -827,7 +827,7 @@ OptionHandlers OptionHandlerFactory::createOptionHandlers() SharedHandle op(new DefaultOptionHandler (PREF_NETRC_PATH, NO_DESCRIPTION, - Util::getHomeDir()+"/.netrc", + util::getHomeDir()+"/.netrc", "/PATH/TO/NETRC")); op->hide(); handlers.push_back(op); @@ -1045,7 +1045,7 @@ OptionHandlers OptionHandlerFactory::createOptionHandlers() SharedHandle op(new DefaultOptionHandler (PREF_DHT_FILE_PATH, TEXT_DHT_FILE_PATH, - Util::getHomeDir()+"/.aria2/dht.dat", + util::getHomeDir()+"/.aria2/dht.dat", "/PATH/TO/DHT_DAT")); op->addTag(TAG_BITTORRENT); handlers.push_back(op); diff --git a/src/OptionHandlerImpl.h b/src/OptionHandlerImpl.h index ecfe412d..ae3194b2 100644 --- a/src/OptionHandlerImpl.h +++ b/src/OptionHandlerImpl.h @@ -159,15 +159,15 @@ public: virtual void parseArg(Option& option, const std::string& optarg) { - IntSequence seq = Util::parseIntRange(optarg); + IntSequence seq = util::parseIntRange(optarg); while(seq.hasNext()) { int32_t v = seq.next(); if(v < _min || _max < v) { std::string msg = _optName; strappend(msg, " ", _("must be between %s and %s.")); throw DL_ABORT_EX - (StringFormat(msg.c_str(), Util::itos(_min).c_str(), - Util::itos(_max).c_str()).str()); + (StringFormat(msg.c_str(), util::itos(_min).c_str(), + util::itos(_max).c_str()).str()); } option.put(_optName, optarg); } @@ -175,7 +175,7 @@ public: virtual std::string createPossibleValuesString() const { - return Util::itos(_min)+"-"+Util::itos(_max); + return util::itos(_min)+"-"+util::itos(_max); } }; @@ -198,26 +198,26 @@ public: virtual void parseArg(Option& option, const std::string& optarg) { - int64_t num = Util::parseLLInt(optarg); + int64_t num = util::parseLLInt(optarg); parseArg(option, num); } void parseArg(Option& option, int64_t number) { if((_min == -1 || _min <= number) && (_max == -1 || number <= _max)) { - option.put(_optName, Util::itos(number)); + option.put(_optName, util::itos(number)); } else { std::string msg = _optName; msg += " "; if(_min == -1 && _max != -1) { msg += StringFormat(_("must be smaller than or equal to %s."), - Util::itos(_max).c_str()).str(); + util::itos(_max).c_str()).str(); } else if(_min != -1 && _max != -1) { msg += StringFormat(_("must be between %s and %s."), - Util::itos(_min).c_str(), Util::itos(_max).c_str()).str(); + util::itos(_min).c_str(), util::itos(_max).c_str()).str(); } else if(_min != -1 && _max == -1) { msg += StringFormat(_("must be greater than or equal to %s."), - Util::itos(_min).c_str()).str(); + util::itos(_min).c_str()).str(); } else { msg += _("must be a number."); } @@ -231,13 +231,13 @@ public: if(_min == -1) { values += "*"; } else { - values += Util::itos(_min); + values += util::itos(_min); } values += "-"; if(_max == -1) { values += "*"; } else { - values += Util::itos(_max); + values += util::itos(_max); } return values; } @@ -258,7 +258,7 @@ public: virtual void parseArg(Option& option, const std::string& optarg) { - int64_t num = Util::getRealSize(optarg); + int64_t num = util::getRealSize(optarg); NumberOptionHandler::parseArg(option, num); } }; @@ -400,7 +400,7 @@ public: virtual void parseArg(Option& option, const std::string& optarg) { // See optarg is in the fomrat of "INDEX=PATH" - Util::parseIndexPath(optarg); + util::parseIndexPath(optarg); std::string value = option.get(_optName); strappend(value, optarg, "\n"); option.put(_optName, value); @@ -492,7 +492,7 @@ public: std::stringstream s; std::copy(_validParamValues.begin(), _validParamValues.end(), std::ostream_iterator(s, ",")); - return Util::trim(s.str(), ", "); + return util::trim(s.str(), ", "); } }; @@ -517,8 +517,8 @@ public: virtual void parseArg(Option& option, const std::string& optarg) { - std::pair proxy = Util::split(optarg, ":"); - int32_t port = Util::parseInt(proxy.second); + std::pair proxy = util::split(optarg, ":"); + int32_t port = util::parseInt(proxy.second); if(proxy.first.empty() || proxy.second.empty() || port <= 0 || 65535 < port) { throw DL_ABORT_EX(_("unrecognized proxy format")); @@ -530,7 +530,7 @@ public: void setHostAndPort(Option& option, const std::string& hostname, uint16_t port) { option.put(_hostOptionName, hostname); - option.put(_portOptionName, Util::uitos(port)); + option.put(_portOptionName, util::uitos(port)); } virtual std::string createPossibleValuesString() const @@ -556,7 +556,7 @@ public: { Request req; std::string url; - if(Util::startsWith(optarg, "http://")) { + if(util::startsWith(optarg, "http://")) { url = optarg; } else { url = "http://"+optarg; diff --git a/src/OptionParser.cc b/src/OptionParser.cc index 04129bb7..275944c4 100644 --- a/src/OptionParser.cc +++ b/src/OptionParser.cc @@ -163,10 +163,10 @@ void OptionParser::parse(Option& option, std::istream& is) int32_t linenum = 0; while(getline(is, line)) { ++linenum; - if(Util::startsWith(line, A2STR::SHARP_C)) { + if(util::startsWith(line, A2STR::SHARP_C)) { continue; } - std::pair nv = Util::split(line, A2STR::EQUAL_C); + std::pair nv = util::split(line, A2STR::EQUAL_C); OptionHandlerHandle handler = getOptionHandlerByName(nv.first); handler->parse(option, nv.second); } diff --git a/src/ParameterizedStringParser.cc b/src/ParameterizedStringParser.cc index 74f81ce4..3752f1c6 100644 --- a/src/ParameterizedStringParser.cc +++ b/src/ParameterizedStringParser.cc @@ -91,8 +91,8 @@ PStringDatumHandle ParameterizedStringParser::createSelect(const std::string& sr throw DL_ABORT_EX("Missing '}' in the parameterized string."); } std::deque values; - split(src.substr(offset, rightParenIndex-offset), std::back_inserter(values), - ",", true); + util::split(src.substr(offset, rightParenIndex-offset), + std::back_inserter(values), ",", true); if(values.empty()) { throw DL_ABORT_EX("Empty {} is not allowed."); } @@ -116,32 +116,32 @@ PStringDatumHandle ParameterizedStringParser::createLoop(const std::string& src, std::string::size_type colonIndex = loopStr.find(":"); if(colonIndex != std::string::npos) { std::string stepStr = loopStr.substr(colonIndex+1); - if(Util::isNumber(stepStr)) { - step = Util::parseUInt(stepStr); + if(util::isNumber(stepStr)) { + step = util::parseUInt(stepStr); } else { throw DL_ABORT_EX("A step count must be a positive number."); } loopStr.erase(colonIndex); } - std::pair range = Util::split(loopStr, "-"); + std::pair range = util::split(loopStr, "-"); if(range.first.empty() || range.second.empty()) { throw DL_ABORT_EX("Loop range missing."); } NumberDecoratorHandle nd; unsigned int start; unsigned int end; - if(Util::isNumber(range.first) && Util::isNumber(range.second)) { + if(util::isNumber(range.first) && util::isNumber(range.second)) { nd.reset(new FixedWidthNumberDecorator(range.first.size())); - start = Util::parseUInt(range.first); - end = Util::parseUInt(range.second); - } else if(Util::isLowercase(range.first) && Util::isLowercase(range.second)) { + start = util::parseUInt(range.first); + end = util::parseUInt(range.second); + } else if(util::isLowercase(range.first) && util::isLowercase(range.second)) { nd.reset(new AlphaNumberDecorator(range.first.size())); - start = Util::alphaToNum(range.first); - end = Util::alphaToNum(range.second); - } else if(Util::isUppercase(range.first) && Util::isUppercase(range.second)) { + start = util::alphaToNum(range.first); + end = util::alphaToNum(range.second); + } else if(util::isUppercase(range.first) && util::isUppercase(range.second)) { nd.reset(new AlphaNumberDecorator(range.first.size(), true)); - start = Util::alphaToNum(range.first); - end = Util::alphaToNum(range.second); + start = util::alphaToNum(range.first); + end = util::alphaToNum(range.second); } else { throw DL_ABORT_EX("Invalid loop range."); } diff --git a/src/Peer.cc b/src/Peer.cc index c6205ec4..eebe23ae 100644 --- a/src/Peer.cc +++ b/src/Peer.cc @@ -60,7 +60,7 @@ Peer::Peer(std::string ipaddr, uint16_t port, bool incoming): memset(_peerId, 0, PEER_ID_LENGTH); resetStatus(); std::string idSeed = ipaddr; - strappend(idSeed, ":", Util::uitos(port)); + strappend(idSeed, ":", util::uitos(port)); #ifdef ENABLE_MESSAGE_DIGEST id = MessageDigestHelper::digestString(MessageDigestContext::SHA1, idSeed); #else diff --git a/src/PeerReceiveHandshakeCommand.cc b/src/PeerReceiveHandshakeCommand.cc index 043ec7c2..69ab8c37 100644 --- a/src/PeerReceiveHandshakeCommand.cc +++ b/src/PeerReceiveHandshakeCommand.cc @@ -102,7 +102,7 @@ bool PeerReceiveHandshakeCommand::executeInternal() if(downloadContext.isNull() || !btRuntime->ready()) { throw DL_ABORT_EX (StringFormat("Unknown info hash %s", - Util::toHex(infoHash).c_str()).str()); + util::toHex(infoHash).c_str()).str()); } TransferStat tstat = downloadContext->getOwnerRequestGroup()->calculateStat(); diff --git a/src/Piece.cc b/src/Piece.cc index 5e59d79c..72d25d7d 100644 --- a/src/Piece.cc +++ b/src/Piece.cc @@ -195,8 +195,8 @@ bool Piece::getAllMissingBlockIndexes } std::string Piece::toString() const { - return strconcat("piece: index=", Util::itos(index), - ", length=", Util::itos(length)); + return strconcat("piece: index=", util::itos(index), + ", length=", util::itos(length)); } void Piece::reconfigure(size_t length) @@ -256,7 +256,7 @@ std::string Piece::getHashString() if(_mdctx.isNull()) { return A2STR::NIL; } else { - return Util::toHex(_mdctx->digestFinal()); + return util::toHex(_mdctx->digestFinal()); } } diff --git a/src/RangeBtMessage.cc b/src/RangeBtMessage.cc index 0e4fcc6d..b060fbd1 100644 --- a/src/RangeBtMessage.cc +++ b/src/RangeBtMessage.cc @@ -80,9 +80,9 @@ size_t RangeBtMessage::getMessageLength() std::string RangeBtMessage::toString() const { - return strconcat(getName(), " index=", Util::uitos(_index), - ", begin=", Util::uitos(_begin), - ", length=", Util::uitos(_length)); + return strconcat(getName(), " index=", util::uitos(_index), + ", begin=", util::uitos(_begin), + ", length=", util::uitos(_length)); } } // namespace aria2 diff --git a/src/Request.cc b/src/Request.cc index e055811f..8341e4cf 100644 --- a/src/Request.cc +++ b/src/Request.cc @@ -101,7 +101,7 @@ static std::string urlencode(const std::string& src) for(int index = src.size()-1; index >= 0; --index) { const unsigned char c = result[index]; // '/' is not urlencoded because src is expected to be a path. - if(!Util::inRFC3986ReservedChars(c) && !Util::inRFC3986UnreservedChars(c)) { + if(!util::inRFC3986ReservedChars(c) && !util::inRFC3986UnreservedChars(c)) { if(c == '%') { if(!isHexNumber(result[index+1]) || !isHexNumber(result[index+2])) { result.replace(index, 1, "%25"); @@ -139,7 +139,7 @@ bool Request::redirectUrl(const std::string& url) { if(url.find("://") == std::string::npos) { // rfc2616 requires absolute URI should be provided by Location header // field, but some servers don't obey this rule. - if(Util::startsWith(url, "/")) { + if(util::startsWith(url, "/")) { // abosulute path return parseUrl(strconcat(protocol, "://", host, url)); } else { @@ -190,15 +190,15 @@ bool Request::parseUrl(const std::string& url) { if(atmarkp != std::string::npos) { std::string authPart = hostPart.substr(0, atmarkp); std::pair userPass = - Util::split(authPart, A2STR::COLON_C); - _username = Util::urldecode(userPass.first); - _password = Util::urldecode(userPass.second); + util::split(authPart, A2STR::COLON_C); + _username = util::urldecode(userPass.first); + _password = util::urldecode(userPass.second); hostPart.erase(0, atmarkp+1); } { std::string::size_type colonpos; // Detect IPv6 literal address in square brackets - if(Util::startsWith(hostPart, "[")) { + if(util::startsWith(hostPart, "[")) { std::string::size_type rbracketpos = hostPart.find("]"); if(rbracketpos == std::string::npos) { return false; @@ -215,7 +215,7 @@ bool Request::parseUrl(const std::string& url) { port = defPort; } else { try { - unsigned int tempPort = Util::parseUInt(hostPart.substr(colonpos+1)); + unsigned int tempPort = util::parseUInt(hostPart.substr(colonpos+1)); if(65535 < tempPort) { return false; } diff --git a/src/RequestGroup.cc b/src/RequestGroup.cc index 6dbb70a4..7961b2bd 100644 --- a/src/RequestGroup.cc +++ b/src/RequestGroup.cc @@ -214,7 +214,7 @@ void RequestGroup::createInitialCommand(std::deque& commands, throw DOWNLOAD_FAILURE_EXCEPTION (StringFormat ("InfoHash %s is already registered.", - Util::toHex(torrentAttrs[bittorrent::INFO_HASH].s()).c_str()).str()); + util::toHex(torrentAttrs[bittorrent::INFO_HASH].s()).c_str()).str()); } if(e->_requestGroupMan->isSameFileBeingDownloaded(this)) { @@ -280,8 +280,8 @@ void RequestGroup::createInitialCommand(std::deque& commands, // truncate the file to _downloadContext->getTotalLength() _logger->debug("File size not match. File is opened in writable mode." " Expected:%s Actual:%s", - Util::uitos(_downloadContext->getTotalLength()).c_str(), - Util::uitos(actualFileSize).c_str()); + util::uitos(_downloadContext->getTotalLength()).c_str(), + util::uitos(actualFileSize).c_str()); } } // Call Load, Save and file allocation command here @@ -568,7 +568,7 @@ bool RequestGroup::tryAutoFileRenaming() return false; } for(unsigned int i = 1; i < 10000; ++i) { - File newfile(strconcat(filepath, ".", Util::uitos(i))); + File newfile(strconcat(filepath, ".", util::uitos(i))); File ctrlfile(newfile.getPath()+DefaultBtProgressInfoFile::getSuffix()); if(!newfile.exists() || (newfile.exists() && ctrlfile.exists())) { _downloadContext->getFirstFileEntry()->setPath(newfile.getPath()); @@ -666,8 +666,8 @@ void RequestGroup::validateTotalLength(uint64_t expectedTotalLength, if(expectedTotalLength != actualTotalLength) { throw DL_ABORT_EX (StringFormat(EX_SIZE_MISMATCH, - Util::itos(expectedTotalLength, true).c_str(), - Util::itos(actualTotalLength, true).c_str()).str()); + util::itos(expectedTotalLength, true).c_str(), + util::itos(actualTotalLength, true).c_str()).str()); } } @@ -942,8 +942,8 @@ void RequestGroup::reportDownloadFinished() double shareRatio = ((stat.getAllTimeUploadLength()*10)/getCompletedLength())/10.0; _logger->notice(MSG_SHARE_RATIO_REPORT, shareRatio, - Util::abbrevSize(stat.getAllTimeUploadLength()).c_str(), - Util::abbrevSize(getCompletedLength()).c_str()); + util::abbrevSize(stat.getAllTimeUploadLength()).c_str(), + util::abbrevSize(getCompletedLength()).c_str()); } #endif // ENABLE_BITTORRENT } diff --git a/src/RequestGroupMan.cc b/src/RequestGroupMan.cc index d0f84d04..ba88d7e4 100644 --- a/src/RequestGroupMan.cc +++ b/src/RequestGroupMan.cc @@ -204,7 +204,7 @@ static void executeHook(const std::string& command, int gid) LogFactory::getInstance()->error("fork() failed." " Cannot execute user command."); } else if(cpid == 0) { - execl(command.c_str(), command.c_str(), Util::itos(gid).c_str(), (char*)0); + execl(command.c_str(), command.c_str(), util::itos(gid).c_str(), (char*)0); perror(("Could not execute user command: "+command).c_str()); exit(EXIT_FAILURE); } @@ -218,7 +218,7 @@ static void executeHook(const std::string& command, int gid) memset(&pi, 0, sizeof (pi)); std::string cmdline = command; - strappend(cmdline, " ", Util::itos(gid)); + strappend(cmdline, " ", util::itos(gid)); DWORD rc = CreateProcess( NULL, @@ -623,7 +623,7 @@ std::string RequestGroupMan::formatDownloadResult(const std::string& status, con << std::setw(4) << status << "|" << std::setw(11); if(downloadResult->sessionTime > 0) { - o << Util::abbrevSize + o << util::abbrevSize (downloadResult->sessionDownloadLength*1000/downloadResult->sessionTime)+ "B/s"; } else { diff --git a/src/ServerStatMan.cc b/src/ServerStatMan.cc index f8422d7a..efb30757 100644 --- a/src/ServerStatMan.cc +++ b/src/ServerStatMan.cc @@ -98,18 +98,18 @@ bool ServerStatMan::load(std::istream& in) std::string line; while(getline(in, line)) { - Util::trimSelf(line); + util::trimSelf(line); if(line.empty()) { continue; } std::vector items; - split(line, std::back_inserter(items), ","); + util::split(line, std::back_inserter(items), ","); std::map m; for(std::vector::const_iterator i = items.begin(); i != items.end(); ++i) { - std::pair p = Util::split(*i, "="); - Util::trimSelf(p.first); - Util::trimSelf(p.second); + std::pair p = util::split(*i, "="); + util::trimSelf(p.first); + util::trimSelf(p.second); m[p.first] = p.second; } if(m[S_HOST].empty() || m[S_PROTOCOL].empty()) { @@ -117,20 +117,20 @@ bool ServerStatMan::load(std::istream& in) } SharedHandle sstat(new ServerStat(m[S_HOST], m[S_PROTOCOL])); try { - sstat->setDownloadSpeed(Util::parseUInt(m[S_DL_SPEED])); + sstat->setDownloadSpeed(util::parseUInt(m[S_DL_SPEED])); // Old serverstat file doesn't contains SC_AVG_SPEED if(m.find(S_SC_AVG_SPEED) != m.end()) { - sstat->setSingleConnectionAvgSpeed(Util::parseUInt(m[S_SC_AVG_SPEED])); + sstat->setSingleConnectionAvgSpeed(util::parseUInt(m[S_SC_AVG_SPEED])); } // Old serverstat file doesn't contains MC_AVG_SPEED if(m.find(S_MC_AVG_SPEED) != m.end()) { - sstat->setMultiConnectionAvgSpeed(Util::parseUInt(m[S_MC_AVG_SPEED])); + sstat->setMultiConnectionAvgSpeed(util::parseUInt(m[S_MC_AVG_SPEED])); } // Old serverstat file doesn't contains COUNTER_SPEED if(m.find(S_COUNTER) != m.end()) { - sstat->setCounter(Util::parseUInt(m[S_COUNTER])); + sstat->setCounter(util::parseUInt(m[S_COUNTER])); } - sstat->setLastUpdated(Time(Util::parseInt(m[S_LAST_UPDATED]))); + sstat->setLastUpdated(Time(util::parseInt(m[S_LAST_UPDATED]))); sstat->setStatus(m[S_STATUS]); add(sstat); } catch(RecoverableException& e) { diff --git a/src/SimpleLogger.cc b/src/SimpleLogger.cc index c3be2526..2baeaa44 100644 --- a/src/SimpleLogger.cc +++ b/src/SimpleLogger.cc @@ -69,7 +69,7 @@ void SimpleLogger::writeLog writeHeader(o, datestr, logLevelLabel); { char buf[1024]; - std::string body = Util::replace(msg, A2STR::CR_C, A2STR::NIL); + std::string body = util::replace(msg, A2STR::CR_C, A2STR::NIL); body += A2STR::LF_C; if(vsnprintf(buf, sizeof(buf), body.c_str(), ap) < 0) { o << "SimpleLogger error, failed to format message.\n"; diff --git a/src/SingleFileAllocationIterator.cc b/src/SingleFileAllocationIterator.cc index c8bf8480..52b8b382 100644 --- a/src/SingleFileAllocationIterator.cc +++ b/src/SingleFileAllocationIterator.cc @@ -63,7 +63,7 @@ SingleFileAllocationIterator::~SingleFileAllocationIterator() void SingleFileAllocationIterator::init() { #ifdef HAVE_POSIX_MEMALIGN - _buffer = (unsigned char*)Util::allocateAlignedMemory(ALIGNMENT, BUFSIZE); + _buffer = (unsigned char*)util::allocateAlignedMemory(ALIGNMENT, BUFSIZE); #else _buffer = new unsigned char[BUFSIZE]; #endif // HAVE_POSIX_MEMALIGN diff --git a/src/SocketCore.cc b/src/SocketCore.cc index 88340e1b..986c256b 100644 --- a/src/SocketCore.cc +++ b/src/SocketCore.cc @@ -226,7 +226,7 @@ void SocketCore::getAddrInfo(std::pair& addrinfo) const if(getsockname(sockfd, addrp, &len) == -1) { throw DL_ABORT_EX(StringFormat(EX_SOCKET_GET_NAME, errorMsg()).str()); } - addrinfo = Util::getNumericNameInfo(addrp, len); + addrinfo = util::getNumericNameInfo(addrp, len); } void SocketCore::getPeerInfo(std::pair& peerinfo) const @@ -237,7 +237,7 @@ void SocketCore::getPeerInfo(std::pair& peerinfo) const if(getpeername(sockfd, addrp, &len) == -1) { throw DL_ABORT_EX(StringFormat(EX_SOCKET_GET_NAME, errorMsg()).str()); } - peerinfo = Util::getNumericNameInfo(addrp, len); + peerinfo = util::getNumericNameInfo(addrp, len); } void SocketCore::establishConnection(const std::string& host, uint16_t port) @@ -1029,7 +1029,7 @@ ssize_t SocketCore::readDataFrom(char* data, size_t len, throw DL_RETRY_EX(StringFormat(EX_SOCKET_RECV, errorMsg()).str()); } } else { - sender = Util::getNumericNameInfo(addrp, sockaddrlen); + sender = util::getNumericNameInfo(addrp, sockaddrlen); } return r; diff --git a/src/Sqlite3MozCookieParser.cc b/src/Sqlite3MozCookieParser.cc index bb6d8ca2..497a4066 100644 --- a/src/Sqlite3MozCookieParser.cc +++ b/src/Sqlite3MozCookieParser.cc @@ -65,7 +65,7 @@ static int cookieRowMapper(void* data, int rowIndex, char** values, char** names) { try { - int64_t expireDate = Util::parseLLInt(toString(values[3])); + int64_t expireDate = util::parseLLInt(toString(values[3])); // TODO assuming time_t is int32_t... if(expireDate > INT32_MAX) { expireDate = INT32_MAX; diff --git a/src/TimeA2.cc b/src/TimeA2.cc index 8ffddc80..05705305 100644 --- a/src/TimeA2.cc +++ b/src/TimeA2.cc @@ -76,7 +76,7 @@ Time& Time::operator=(const Time& time) bool Time::operator<(const Time& time) const { - return Util::difftv(time.tv, tv) > 0; + return util::difftv(time.tv, tv) > 0; } void Time::reset() { @@ -99,36 +99,36 @@ bool Time::elapsed(time_t sec) const { return true; } else if(tv.tv_sec+sec == now) { return - Util::difftv(getCurrentTime(), tv) >= static_cast(sec)*1000000; + util::difftv(getCurrentTime(), tv) >= static_cast(sec)*1000000; } else { return false; } } bool Time::elapsedInMillis(int64_t millis) const { - return Util::difftv(getCurrentTime(), tv)/1000 >= millis; + return util::difftv(getCurrentTime(), tv)/1000 >= millis; } bool Time::isNewer(const Time& time) const { - return Util::difftv(this->tv, time.tv) > 0; + return util::difftv(this->tv, time.tv) > 0; } time_t Time::difference() const { - return Util::difftvsec(getCurrentTime(), tv); + return util::difftvsec(getCurrentTime(), tv); } time_t Time::difference(const struct timeval& now) const { - return Util::difftvsec(now, tv); + return util::difftvsec(now, tv); } int64_t Time::differenceInMillis() const { - return Util::difftv(getCurrentTime(), tv)/1000; + return util::difftv(getCurrentTime(), tv)/1000; } int64_t Time::differenceInMillis(const struct timeval& now) const { - return Util::difftv(now, tv)/1000; + return util::difftv(now, tv)/1000; } bool Time::isZero() const diff --git a/src/UTPexExtensionMessage.cc b/src/UTPexExtensionMessage.cc index 92e71947..7031a90e 100644 --- a/src/UTPexExtensionMessage.cc +++ b/src/UTPexExtensionMessage.cc @@ -87,8 +87,8 @@ UTPexExtensionMessage::createCompactPeerListAndFlag(const Peers& peers) std::string UTPexExtensionMessage::toString() const { - return strconcat("ut_pex added=", Util::uitos(_freshPeers.size()), - ", dropped=", Util::uitos(_droppedPeers.size())); + return strconcat("ut_pex added=", util::uitos(_freshPeers.size()), + ", dropped=", util::uitos(_droppedPeers.size())); } void UTPexExtensionMessage::doReceivedAction() diff --git a/src/UriListParser.cc b/src/UriListParser.cc index 14d6d52c..1a6ed3dc 100644 --- a/src/UriListParser.cc +++ b/src/UriListParser.cc @@ -55,7 +55,7 @@ void UriListParser::getOptions(Option& op) { std::stringstream ss; while(getline(_in, _line)) { - if(Util::startsWith(_line, " ")) { + if(util::startsWith(_line, " ")) { ss << _line << "\n"; } else { break; @@ -73,8 +73,8 @@ void UriListParser::parseNext(std::deque& uris, Option& op) return; } do { - if(!Util::trim(_line).empty()) { - split(_line, std::back_inserter(uris), "\t", true); + if(!util::trim(_line).empty()) { + util::split(_line, std::back_inserter(uris), "\t", true); getOptions(op); return; } diff --git a/src/Util.cc b/src/Util.cc index f20b044e..77532c61 100644 --- a/src/Util.cc +++ b/src/Util.cc @@ -83,16 +83,18 @@ namespace aria2 { -const std::string Util::DEFAULT_TRIM_CHARSET("\r\n\t "); +namespace util { -std::string Util::trim(const std::string& src, const std::string& trimCharset) +const std::string DEFAULT_TRIM_CHARSET("\r\n\t "); + +std::string trim(const std::string& src, const std::string& trimCharset) { std::string temp(src); trimSelf(temp, trimCharset); return temp; } -void Util::trimSelf(std::string& str, const std::string& trimCharset) +void trimSelf(std::string& str, const std::string& trimCharset) { std::string::size_type first = str.find_first_not_of(trimCharset); if(first == std::string::npos) { @@ -104,7 +106,7 @@ void Util::trimSelf(std::string& str, const std::string& trimCharset) } } -void Util::split(std::pair& hp, const std::string& src, char delim) +void split(std::pair& hp, const std::string& src, char delim) { hp.first = A2STR::NIL; hp.second = A2STR::NIL; @@ -118,7 +120,7 @@ void Util::split(std::pair& hp, const std::string& src } } -std::pair Util::split(const std::string& src, const std::string& delims) +std::pair split(const std::string& src, const std::string& delims) { std::pair hp; hp.first = A2STR::NIL; @@ -134,7 +136,7 @@ std::pair Util::split(const std::string& src, const st return hp; } -int64_t Util::difftv(struct timeval tv1, struct timeval tv2) { +int64_t difftv(struct timeval tv1, struct timeval tv2) { if((tv1.tv_sec < tv2.tv_sec) || ((tv1.tv_sec == tv2.tv_sec) && (tv1.tv_usec < tv2.tv_usec))) { return 0; @@ -143,14 +145,14 @@ int64_t Util::difftv(struct timeval tv1, struct timeval tv2) { tv1.tv_usec-tv2.tv_usec); } -int32_t Util::difftvsec(struct timeval tv1, struct timeval tv2) { +int32_t difftvsec(struct timeval tv1, struct timeval tv2) { if(tv1.tv_sec < tv2.tv_sec) { return 0; } return tv1.tv_sec-tv2.tv_sec; } -bool Util::startsWith(const std::string& target, const std::string& part) { +bool startsWith(const std::string& target, const std::string& part) { if(target.size() < part.size()) { return false; } @@ -164,7 +166,7 @@ bool Util::startsWith(const std::string& target, const std::string& part) { } } -bool Util::endsWith(const std::string& target, const std::string& part) { +bool endsWith(const std::string& target, const std::string& part) { if(target.size() < part.size()) { return false; } @@ -178,7 +180,7 @@ bool Util::endsWith(const std::string& target, const std::string& part) { } } -std::string Util::replace(const std::string& target, const std::string& oldstr, const std::string& newstr) { +std::string replace(const std::string& target, const std::string& oldstr, const std::string& newstr) { if(target.empty() || oldstr.empty()) { return target; } @@ -196,7 +198,7 @@ std::string Util::replace(const std::string& target, const std::string& oldstr, return result; } -bool Util::inRFC3986ReservedChars(const char c) +bool inRFC3986ReservedChars(const char c) { static const char reserved[] = { ':' , '/' , '?' , '#' , '[' , ']' , '@', @@ -206,7 +208,7 @@ bool Util::inRFC3986ReservedChars(const char c) &reserved[arrayLength(reserved)]; } -bool Util::inRFC3986UnreservedChars(const char c) +bool inRFC3986UnreservedChars(const char c) { static const char unreserved[] = { '-', '.', '_', '~' }; return @@ -218,7 +220,7 @@ bool Util::inRFC3986UnreservedChars(const char c) &unreserved[arrayLength(unreserved)]; } -std::string Util::urlencode(const unsigned char* target, size_t len) { +std::string urlencode(const unsigned char* target, size_t len) { std::string dest; for(size_t i = 0; i < len; ++i) { if(!inRFC3986UnreservedChars(target[i])) { @@ -230,7 +232,12 @@ std::string Util::urlencode(const unsigned char* target, size_t len) { return dest; } -std::string Util::torrentUrlencode(const unsigned char* target, size_t len) { +std::string urlencode(const std::string& target) +{ + return urlencode((const unsigned char*)target.c_str(), target.size()); +} + +std::string torrentUrlencode(const unsigned char* target, size_t len) { std::string dest; for(size_t i = 0; i < len; ++i) { if(('0' <= target[i] && target[i] <= '9') || @@ -244,14 +251,20 @@ std::string Util::torrentUrlencode(const unsigned char* target, size_t len) { return dest; } -std::string Util::urldecode(const std::string& target) { +std::string torrentUrlencode(const std::string& target) +{ + return torrentUrlencode + (reinterpret_cast(target.c_str()), target.size()); +} + +std::string urldecode(const std::string& target) { std::string result; for(std::string::const_iterator itr = target.begin(); itr != target.end(); ++itr) { if(*itr == '%') { if(itr+1 != target.end() && itr+2 != target.end() && isxdigit(*(itr+1)) && isxdigit(*(itr+2))) { - result += Util::parseInt(std::string(itr+1, itr+3), 16); + result += parseInt(std::string(itr+1, itr+3), 16); itr += 2; } else { result += *itr; @@ -263,7 +276,7 @@ std::string Util::urldecode(const std::string& target) { return result; } -std::string Util::toHex(const unsigned char* src, size_t len) { +std::string toHex(const unsigned char* src, size_t len) { char* temp = new char[len*2+1]; for(size_t i = 0; i < len; ++i) { sprintf(temp+i*2, "%02x", src[i]); @@ -274,12 +287,22 @@ std::string Util::toHex(const unsigned char* src, size_t len) { return hex; } -FILE* Util::openFile(const std::string& filename, const std::string& mode) { +std::string toHex(const char* src, size_t len) +{ + return toHex(reinterpret_cast(src), len); +} + +std::string toHex(const std::string& src) +{ + return toHex(reinterpret_cast(src.c_str()), src.size()); +} + +FILE* openFile(const std::string& filename, const std::string& mode) { FILE* file = fopen(filename.c_str(), mode.c_str()); return file; } -bool Util::isPowerOf(int num, int base) { +bool isPowerOf(int num, int base) { if(base <= 0) { return false; } if(base == 1) { return true; } @@ -292,7 +315,7 @@ bool Util::isPowerOf(int num, int base) { return false; } -std::string Util::secfmt(time_t sec) { +std::string secfmt(time_t sec) { std::string str; if(sec >= 3600) { str = itos(sec/3600); @@ -325,9 +348,9 @@ int getNum(const char* buf, int offset, size_t length) { return x; } -int32_t Util::parseInt(const std::string& s, int32_t base) +int32_t parseInt(const std::string& s, int32_t base) { - std::string trimed = Util::trim(s); + std::string trimed = trim(s); if(trimed.empty()) { throw DL_ABORT_EX(StringFormat(MSG_STRING_INTEGER_CONVERSION_FAILURE, "empty string").str()); @@ -347,9 +370,9 @@ int32_t Util::parseInt(const std::string& s, int32_t base) return v; } -uint32_t Util::parseUInt(const std::string& s, int base) +uint32_t parseUInt(const std::string& s, int base) { - std::string trimed = Util::trim(s); + std::string trimed = trim(s); if(trimed.empty()) { throw DL_ABORT_EX(StringFormat(MSG_STRING_INTEGER_CONVERSION_FAILURE, "empty string").str()); @@ -372,9 +395,9 @@ uint32_t Util::parseUInt(const std::string& s, int base) return v; } -int64_t Util::parseLLInt(const std::string& s, int32_t base) +int64_t parseLLInt(const std::string& s, int32_t base) { - std::string trimed = Util::trim(s); + std::string trimed = trim(s); if(trimed.empty()) { throw DL_ABORT_EX(StringFormat(MSG_STRING_INTEGER_CONVERSION_FAILURE, "empty string").str()); @@ -392,9 +415,9 @@ int64_t Util::parseLLInt(const std::string& s, int32_t base) return v; } -uint64_t Util::parseULLInt(const std::string& s, int base) +uint64_t parseULLInt(const std::string& s, int base) { - std::string trimed = Util::trim(s); + std::string trimed = trim(s); if(trimed.empty()) { throw DL_ABORT_EX(StringFormat(MSG_STRING_INTEGER_CONVERSION_FAILURE, "empty string").str()); @@ -417,34 +440,34 @@ uint64_t Util::parseULLInt(const std::string& s, int base) return v; } -IntSequence Util::parseIntRange(const std::string& src) +IntSequence parseIntRange(const std::string& src) { IntSequence::Values values; std::string temp = src; while(temp.size()) { - std::pair p = Util::split(temp, ","); + std::pair p = split(temp, ","); temp = p.second; if(p.first.empty()) { continue; } if(p.first.find("-") == std::string::npos) { - int32_t v = Util::parseInt(p.first.c_str()); + int32_t v = parseInt(p.first.c_str()); values.push_back(IntSequence::Value(v, v+1)); } else { - std::pair vp = Util::split(p.first.c_str(), "-"); + std::pair vp = split(p.first.c_str(), "-"); if(vp.first.empty() || vp.second.empty()) { throw DL_ABORT_EX (StringFormat(MSG_INCOMPLETE_RANGE, p.first.c_str()).str()); } - int32_t v1 = Util::parseInt(vp.first.c_str()); - int32_t v2 = Util::parseInt(vp.second.c_str()); + int32_t v1 = parseInt(vp.first.c_str()); + int32_t v2 = parseInt(vp.second.c_str()); values.push_back(IntSequence::Value(v1, v2+1)); } } return values; } -std::string Util::getContentDispositionFilename(const std::string& header) { +std::string getContentDispositionFilename(const std::string& header) { static const std::string keyName = "filename="; std::string::size_type attributesp = header.find(keyName); if(attributesp == std::string::npos) { @@ -476,7 +499,7 @@ std::string Util::getContentDispositionFilename(const std::string& header) { } } -std::string Util::randomAlpha(size_t length, const RandomizerHandle& randomizer) { +std::string randomAlpha(size_t length, const RandomizerHandle& randomizer) { static const char *random_chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; std::string str; for(size_t i = 0; i < length; ++i) { @@ -486,19 +509,19 @@ std::string Util::randomAlpha(size_t length, const RandomizerHandle& randomizer) return str; } -std::string Util::toUpper(const std::string& src) { +std::string toUpper(const std::string& src) { std::string temp = src; std::transform(temp.begin(), temp.end(), temp.begin(), ::toupper); return temp; } -std::string Util::toLower(const std::string& src) { +std::string toLower(const std::string& src) { std::string temp = src; std::transform(temp.begin(), temp.end(), temp.begin(), ::tolower); return temp; } -bool Util::isNumbersAndDotsNotation(const std::string& name) { +bool isNumbersAndDotsNotation(const std::string& name) { struct sockaddr_in sockaddr; if(inet_aton(name.c_str(), &sockaddr.sin_addr)) { return true; @@ -507,7 +530,7 @@ bool Util::isNumbersAndDotsNotation(const std::string& name) { } } -void Util::setGlobalSignalHandler(int sig, void (*handler)(int), int flags) { +void setGlobalSignalHandler(int sig, void (*handler)(int), int flags) { #ifdef HAVE_SIGACTION struct sigaction sigact; sigact.sa_handler = handler; @@ -519,7 +542,7 @@ void Util::setGlobalSignalHandler(int sig, void (*handler)(int), int flags) { #endif // HAVE_SIGACTION } -std::string Util::getHomeDir() +std::string getHomeDir() { const char* p = getenv("HOME"); if(p) { @@ -529,7 +552,7 @@ std::string Util::getHomeDir() } } -int64_t Util::getRealSize(const std::string& sizeWithUnit) +int64_t getRealSize(const std::string& sizeWithUnit) { std::string::size_type p = sizeWithUnit.find_first_of("KM"); std::string size; @@ -544,7 +567,7 @@ int64_t Util::getRealSize(const std::string& sizeWithUnit) } size = sizeWithUnit.substr(0, p); } - int64_t v = Util::parseLLInt(size); + int64_t v = parseLLInt(size); if(v < 0) { throw DL_ABORT_EX @@ -556,10 +579,10 @@ int64_t Util::getRealSize(const std::string& sizeWithUnit) return v*mult; } -std::string Util::abbrevSize(int64_t size) +std::string abbrevSize(int64_t size) { if(size < 1024) { - return Util::itos(size, true); + return itos(size, true); } char units[] = { 'K', 'M' }; size_t numUnit = sizeof(units)/sizeof(char); @@ -570,15 +593,15 @@ std::string Util::abbrevSize(int64_t size) r = size&0x3ff; size >>= 10; } - std::string result = Util::itos(size, true); + std::string result = itos(size, true); result += "."; - result += Util::itos(r*10/1024); + result += itos(r*10/1024); result += units[i]; result += "i"; return result; } -void Util::sleep(long seconds) { +void sleep(long seconds) { #ifdef HAVE_SLEEP ::sleep(seconds); #elif defined(HAVE_USLEEP) @@ -590,7 +613,7 @@ void Util::sleep(long seconds) { #endif } -void Util::usleep(long microseconds) { +void usleep(long microseconds) { #ifdef HAVE_USLEEP ::usleep(microseconds); #elif defined(HAVE_WINSOCK2_H) @@ -625,7 +648,7 @@ void Util::usleep(long microseconds) { #endif } -bool Util::isNumber(const std::string& what) +bool isNumber(const std::string& what) { if(what.empty()) { return false; @@ -638,7 +661,7 @@ bool Util::isNumber(const std::string& what) return true; } -bool Util::isLowercase(const std::string& what) +bool isLowercase(const std::string& what) { if(what.empty()) { return false; @@ -651,7 +674,7 @@ bool Util::isLowercase(const std::string& what) return true; } -bool Util::isUppercase(const std::string& what) +bool isUppercase(const std::string& what) { if(what.empty()) { return false; @@ -664,7 +687,7 @@ bool Util::isUppercase(const std::string& what) return true; } -unsigned int Util::alphaToNum(const std::string& alphabets) +unsigned int alphaToNum(const std::string& alphabets) { if(alphabets.empty()) { return 0; @@ -686,7 +709,7 @@ unsigned int Util::alphaToNum(const std::string& alphabets) return num; } -void Util::mkdirs(const std::string& dirpath) +void mkdirs(const std::string& dirpath) { File dir(dirpath); if(dir.isDir()) { @@ -702,7 +725,7 @@ void Util::mkdirs(const std::string& dirpath) } } -void Util::convertBitfield(BitfieldMan* dest, const BitfieldMan* src) +void convertBitfield(BitfieldMan* dest, const BitfieldMan* src) { size_t numBlock = dest->countBlock(); for(size_t index = 0; index < numBlock; ++index) { @@ -713,7 +736,7 @@ void Util::convertBitfield(BitfieldMan* dest, const BitfieldMan* src) } } -std::string Util::toString(const BinaryStreamHandle& binaryStream) +std::string toString(const BinaryStreamHandle& binaryStream) { std::stringstream strm; char data[2048]; @@ -731,7 +754,7 @@ std::string Util::toString(const BinaryStreamHandle& binaryStream) /** * In linux 2.6, alignment and size should be a multiple of 512. */ -void* Util::allocateAlignedMemory(size_t alignment, size_t size) +void* allocateAlignedMemory(size_t alignment, size_t size) { void* buffer; int res; @@ -744,7 +767,7 @@ void* Util::allocateAlignedMemory(size_t alignment, size_t size) #endif // HAVE_POSIX_MEMALIGN std::pair -Util::getNumericNameInfo(const struct sockaddr* sockaddr, socklen_t len) +getNumericNameInfo(const struct sockaddr* sockaddr, socklen_t len) { char host[NI_MAXHOST]; char service[NI_MAXSERV]; @@ -757,7 +780,7 @@ Util::getNumericNameInfo(const struct sockaddr* sockaddr, socklen_t len) return std::pair(host, atoi(service)); // TODO } -std::string Util::htmlEscape(const std::string& src) +std::string htmlEscape(const std::string& src) { std::string dest; for(std::string::const_iterator i = src.begin(); i != src.end(); ++i) { @@ -780,9 +803,9 @@ std::string Util::htmlEscape(const std::string& src) } std::map::value_type -Util::parseIndexPath(const std::string& line) +parseIndexPath(const std::string& line) { - std::pair p = Util::split(line, "="); + std::pair p = split(line, "="); size_t index = parseUInt(p.first); if(p.second.empty()) { throw DL_ABORT_EX(StringFormat("Path with index=%u is empty.", @@ -791,7 +814,7 @@ Util::parseIndexPath(const std::string& line) return std::map::value_type(index, p.second); } -std::map Util::createIndexPathMap(std::istream& i) +std::map createIndexPathMap(std::istream& i) { std::map indexPathMap; std::string line; @@ -801,8 +824,6 @@ std::map Util::createIndexPathMap(std::istream& i) return indexPathMap; } -namespace util { - void generateRandomData(unsigned char* data, size_t length) { #ifdef HAVE_LIBGCRYPT diff --git a/src/Util.h b/src/Util.h index 8640b700..eceb38cb 100644 --- a/src/Util.h +++ b/src/Util.h @@ -82,228 +82,214 @@ inline uint64_t ntoh64(uint64_t x) { return byteswap64(x); } inline uint64_t hton64(uint64_t x) { return byteswap64(x); } #endif // !WORDS_BIGENDIAN -class Util { -public: - static void split(std::pair& hp, - const std::string& src, char delim); +namespace util { - static std::pair - split(const std::string& src, const std::string& delims); +void split(std::pair& hp, + const std::string& src, char delim); - template - static std::string uitos(T value, bool comma = false) - { - std::string str; - if(value == 0) { - str = "0"; - return str; - } - unsigned int count = 0; - while(value) { - ++count; - char digit = value%10+'0'; - str.insert(str.begin(), digit); - value /= 10; - if(comma && count > 3 && count%3 == 1) { - str.insert(str.begin()+1, ','); - } - } +std::pair +split(const std::string& src, const std::string& delims); + +template +std::string uitos(T value, bool comma = false) +{ + std::string str; + if(value == 0) { + str = "0"; return str; } - - template - static std::string itos(T value, bool comma = false) - { - bool flag = false; - if(value < 0) { - flag = true; - value = -value; + unsigned int count = 0; + while(value) { + ++count; + char digit = value%10+'0'; + str.insert(str.begin(), digit); + value /= 10; + if(comma && count > 3 && count%3 == 1) { + str.insert(str.begin()+1, ','); } - std::string str = uitos(value, comma); - if(flag) { - str.insert(str.begin(), '-'); - } - return str; } + return str; +} - /** - * Computes difference in micro-seconds between tv1 and tv2, - * assuming tv1 is newer than tv2. - * If tv1 is older than tv2, then this method returns 0. - */ - static int64_t difftv(struct timeval tv1, struct timeval tv2); - static int32_t difftvsec(struct timeval tv1, struct timeval tv2); - - static const std::string DEFAULT_TRIM_CHARSET; - - static std::string trim(const std::string& src, - const std::string& trimCharset = DEFAULT_TRIM_CHARSET); - - static void trimSelf(std::string& str, - const std::string& trimCharset = DEFAULT_TRIM_CHARSET); - - static bool startsWith(const std::string& target, const std::string& part); - - static bool endsWith(const std::string& target, const std::string& part); - - static std::string replace(const std::string& target, const std::string& oldstr, const std::string& newstr); - - static std::string urlencode(const unsigned char* target, size_t len); - - static std::string urlencode(const std::string& target) - { - return urlencode((const unsigned char*)target.c_str(), target.size()); +template +std::string itos(T value, bool comma = false) +{ + bool flag = false; + if(value < 0) { + flag = true; + value = -value; } - - static bool inRFC3986ReservedChars(const char c); - - static bool inRFC3986UnreservedChars(const char c); - - static std::string urldecode(const std::string& target); - - static std::string torrentUrlencode(const unsigned char* target, size_t len); - - static std::string torrentUrlencode(const std::string& target) - { - return torrentUrlencode(reinterpret_cast(target.c_str()), - target.size()); + std::string str = uitos(value, comma); + if(flag) { + str.insert(str.begin(), '-'); } + return str; +} - static std::string toHex(const unsigned char* src, size_t len); +/** + * Computes difference in micro-seconds between tv1 and tv2, + * assuming tv1 is newer than tv2. + * If tv1 is older than tv2, then this method returns 0. + */ +int64_t difftv(struct timeval tv1, struct timeval tv2); +int32_t difftvsec(struct timeval tv1, struct timeval tv2); - static std::string toHex(const char* src, size_t len) - { - return toHex(reinterpret_cast(src), len); - } +extern const std::string DEFAULT_TRIM_CHARSET; - static std::string toHex(const std::string& src) - { - return toHex(reinterpret_cast(src.c_str()), src.size()); - } +std::string trim(const std::string& src, + const std::string& trimCharset = DEFAULT_TRIM_CHARSET); - static FILE* openFile(const std::string& filename, const std::string& mode); +void trimSelf(std::string& str, + const std::string& trimCharset = DEFAULT_TRIM_CHARSET); - static bool isPowerOf(int num, int base); +bool startsWith(const std::string& target, const std::string& part); - static std::string secfmt(time_t sec); +bool endsWith(const std::string& target, const std::string& part); - static int32_t parseInt(const std::string& s, int32_t base = 10); +std::string replace(const std::string& target, const std::string& oldstr, const std::string& newstr); - static uint32_t parseUInt(const std::string& s, int base = 10); +std::string urlencode(const unsigned char* target, size_t len); + +std::string urlencode(const std::string& target); + +bool inRFC3986ReservedChars(const char c); + +bool inRFC3986UnreservedChars(const char c); + +std::string urldecode(const std::string& target); + +std::string torrentUrlencode(const unsigned char* target, size_t len); + +std::string torrentUrlencode(const std::string& target); + +std::string toHex(const unsigned char* src, size_t len); + +std::string toHex(const char* src, size_t len); + +std::string toHex(const std::string& src); + +FILE* openFile(const std::string& filename, const std::string& mode); + +bool isPowerOf(int num, int base); + +std::string secfmt(time_t sec); + +int32_t parseInt(const std::string& s, int32_t base = 10); + +uint32_t parseUInt(const std::string& s, int base = 10); - static int64_t parseLLInt(const std::string& s, int32_t base = 10); +int64_t parseLLInt(const std::string& s, int32_t base = 10); - static uint64_t parseULLInt(const std::string& s, int base = 10); +uint64_t parseULLInt(const std::string& s, int base = 10); - static IntSequence parseIntRange(const std::string& src); +IntSequence parseIntRange(const std::string& src); - // this function temporarily put here - static std::string getContentDispositionFilename(const std::string& header); +// this function temporarily put here +std::string getContentDispositionFilename(const std::string& header); - static std::string randomAlpha(size_t length, - const SharedHandle& randomizer); +std::string randomAlpha(size_t length, + const SharedHandle& randomizer); - static std::string toUpper(const std::string& src); +std::string toUpper(const std::string& src); - static std::string toLower(const std::string& src); +std::string toLower(const std::string& src); - static bool isNumbersAndDotsNotation(const std::string& name); +bool isNumbersAndDotsNotation(const std::string& name); - static void setGlobalSignalHandler(int signal, void (*handler)(int), int flags); +void setGlobalSignalHandler(int signal, void (*handler)(int), int flags); - static std::string getHomeDir(); +std::string getHomeDir(); - static int64_t getRealSize(const std::string& sizeWithUnit); +int64_t getRealSize(const std::string& sizeWithUnit); - static std::string abbrevSize(int64_t size); +std::string abbrevSize(int64_t size); - template - static void toStream - (InputIterator first, InputIterator last, std::ostream& os) - { - os << _("Files:") << "\n"; - os << "idx|path/length" << "\n"; - os << "===+===========================================================================" << "\n"; - int32_t count = 1; - for(; first != last; ++first, ++count) { +template +void toStream +(InputIterator first, InputIterator last, std::ostream& os) +{ + os << _("Files:") << "\n"; + os << "idx|path/length" << "\n"; + os << "===+===========================================================================" << "\n"; + int32_t count = 1; + for(; first != last; ++first, ++count) { os << std::setw(3) << count << "|" << (*first)->getPath() << "\n"; - os << " |" << Util::abbrevSize((*first)->getLength()) << "B (" - << Util::uitos((*first)->getLength(), true) << ")\n"; + os << " |" << util::abbrevSize((*first)->getLength()) << "B (" + << util::uitos((*first)->getLength(), true) << ")\n"; os << "---+---------------------------------------------------------------------------" << "\n"; - } } +} - static void sleep(long seconds); +void sleep(long seconds); - static void usleep(long microseconds); +void usleep(long microseconds); - static bool isNumber(const std::string& what); +bool isNumber(const std::string& what); - static bool isLowercase(const std::string& what); +bool isLowercase(const std::string& what); - static bool isUppercase(const std::string& what); +bool isUppercase(const std::string& what); - /** - * Converts alphabets to unsigned int, assuming alphabets as a base 26 - * integer and 'a' or 'A' is 0. - * This function assumes alphabets includes only a-z. - * Upper case are allowed but all letters must be upper case. - * If overflow occurs, returns 0. - */ - static unsigned int alphaToNum(const std::string& alphabets); +/** + * Converts alphabets to unsigned int, assuming alphabets as a base 26 + * integer and 'a' or 'A' is 0. + * This function assumes alphabets includes only a-z. + * Upper case are allowed but all letters must be upper case. + * If overflow occurs, returns 0. + */ +unsigned int alphaToNum(const std::string& alphabets); - static void mkdirs(const std::string& dirpath); +void mkdirs(const std::string& dirpath); - static void convertBitfield(BitfieldMan* dest, const BitfieldMan* src); +void convertBitfield(BitfieldMan* dest, const BitfieldMan* src); - // binaryStream has to be opened before calling this function. - static std::string toString(const SharedHandle& binaryStream); +// binaryStream has to be opened before calling this function. +std::string toString(const SharedHandle& binaryStream); #ifdef HAVE_POSIX_MEMALIGN - static void* allocateAlignedMemory(size_t alignment, size_t size); +void* allocateAlignedMemory(size_t alignment, size_t size); #endif // HAVE_POSIX_MEMALIGN - static std::pair - getNumericNameInfo(const struct sockaddr* sockaddr, socklen_t len); +std::pair +getNumericNameInfo(const struct sockaddr* sockaddr, socklen_t len); - static std::string htmlEscape(const std::string& src); +std::string htmlEscape(const std::string& src); - // Joins path element specified in [first, last). If ".." is found, - // it eats the previous element if it exists. If "." is found, it - // is just ignored and it is not appeared in the result. - template - static std::string joinPath(InputIterator first, InputIterator last) - { - std::deque elements; - for(;first != last; ++first) { - if(*first == "..") { - if(!elements.empty()) { - elements.pop_back(); - } - } else if(*first == ".") { - // do nothing - } else { - elements.push_back(*first); +// Joins path element specified in [first, last). If ".." is found, +// it eats the previous element if it exists. If "." is found, it +// is just ignored and it is not appeared in the result. +template +std::string joinPath(InputIterator first, InputIterator last) +{ + std::deque elements; + for(;first != last; ++first) { + if(*first == "..") { + if(!elements.empty()) { + elements.pop_back(); } + } else if(*first == ".") { + // do nothing + } else { + elements.push_back(*first); } - return strjoin(elements.begin(), elements.end(), "/"); } + return strjoin(elements.begin(), elements.end(), "/"); +} - // Parses INDEX=PATH format string. INDEX must be an unsigned - // integer. - static std::map::value_type - parseIndexPath(const std::string& line); +// Parses INDEX=PATH format string. INDEX must be an unsigned +// integer. +std::map::value_type +parseIndexPath(const std::string& line); - static std::map createIndexPathMap(std::istream& i); -}; +std::map createIndexPathMap(std::istream& i); /** * Take a string src which is a deliminated list and add its elements * into result. result is stored in out. */ template -static OutputIterator split(const std::string& src, OutputIterator out, - const std::string& delims, bool doTrim = false) +OutputIterator split(const std::string& src, OutputIterator out, + const std::string& delims, bool doTrim = false) { std::string::size_type p = 0; while(1) { @@ -311,7 +297,7 @@ static OutputIterator split(const std::string& src, OutputIterator out, if(np == std::string::npos) { std::string term = src.substr(p); if(doTrim) { - term = Util::trim(term); + term = util::trim(term); } if(!term.empty()) { *out = term; @@ -321,7 +307,7 @@ static OutputIterator split(const std::string& src, OutputIterator out, } std::string term = src.substr(p, np-p); if(doTrim) { - term = Util::trim(term); + term = util::trim(term); } p = np+1; if(!term.empty()) { @@ -332,8 +318,6 @@ static OutputIterator split(const std::string& src, OutputIterator out, return out; } -namespace util { - void generateRandomData(unsigned char* data, size_t length); } // namespace util diff --git a/src/XML2SAXMetalinkProcessor.cc b/src/XML2SAXMetalinkProcessor.cc index c4514ca3..39061101 100644 --- a/src/XML2SAXMetalinkProcessor.cc +++ b/src/XML2SAXMetalinkProcessor.cc @@ -63,7 +63,7 @@ static void mlStartElement(void* userData, const xmlChar* name, const xmlChar** if(*p == 0) { break; } - std::string value = Util::trim((const char*)*p++); + std::string value = util::trim((const char*)*p++); attrmap[name] = value; } } @@ -78,7 +78,7 @@ static void mlEndElement(void* userData, const xmlChar* name) SessionData* sd = reinterpret_cast(userData); std::string characters; if(sd->_stm->needsCharactersBuffering()) { - characters = Util::trim(sd->_charactersStack.front()); + characters = util::trim(sd->_charactersStack.front()); sd->_charactersStack.pop_front(); } sd->_stm->endElement((const char*)name, characters); diff --git a/src/Xml2XmlRpcRequestProcessor.cc b/src/Xml2XmlRpcRequestProcessor.cc index c6518fb0..0a568606 100644 --- a/src/Xml2XmlRpcRequestProcessor.cc +++ b/src/Xml2XmlRpcRequestProcessor.cc @@ -67,7 +67,7 @@ static void mlStartElement(void* userData, const xmlChar* name, if(*p == 0) { break; } - std::string value = Util::trim((const char*)*p++); + std::string value = util::trim((const char*)*p++); attrmap[name] = value; } } @@ -82,7 +82,7 @@ static void mlEndElement(void* userData, const xmlChar* name) SessionData* sd = reinterpret_cast(userData); std::string characters; if(sd->_stm->needsCharactersBuffering()) { - characters = Util::trim(sd->_charactersStack.top()); + characters = util::trim(sd->_charactersStack.top()); sd->_charactersStack.pop(); } sd->_stm->endElement((const char*)name, characters); diff --git a/src/XmlRpcMethodImpl.cc b/src/XmlRpcMethodImpl.cc index 0eafa1fd..ed97d6e5 100644 --- a/src/XmlRpcMethodImpl.cc +++ b/src/XmlRpcMethodImpl.cc @@ -82,7 +82,7 @@ static const BDE BDE_COMPLETE = BDE("complete"); static BDE createGIDResponse(int32_t gid) { - return BDE(Util::itos(gid)); + return BDE(util::itos(gid)); } static BDE addRequestGroup(const SharedHandle& group, @@ -221,7 +221,7 @@ BDE AddMetalinkXmlRpcMethod::process BDE gids = BDE::list(); for(std::deque >::const_iterator i = result.begin(); i != result.end(); ++i) { - gids << BDE(Util::itos((*i)->getGID())); + gids << BDE(util::itos((*i)->getGID())); } return gids; } else { @@ -239,7 +239,7 @@ BDE RemoveXmlRpcMethod::process(const XmlRpcRequest& req, DownloadEngine* e) throw DL_ABORT_EX(MSG_GID_NOT_PROVIDED); } - int32_t gid = Util::parseInt(params[0].s()); + int32_t gid = util::parseInt(params[0].s()); SharedHandle group = e->_requestGroupMan->findRequestGroup(gid); @@ -265,27 +265,27 @@ BDE RemoveXmlRpcMethod::process(const XmlRpcRequest& req, DownloadEngine* e) static void gatherProgressCommon (BDE& entryDict, const SharedHandle& group) { - entryDict["gid"] = Util::itos(group->getGID()); + entryDict["gid"] = util::itos(group->getGID()); // This is "filtered" total length if --select-file is used. - entryDict["totalLength"] = Util::uitos(group->getTotalLength()); + entryDict["totalLength"] = util::uitos(group->getTotalLength()); // This is "filtered" total length if --select-file is used. - entryDict["completedLength"] = Util::uitos(group->getCompletedLength()); + entryDict["completedLength"] = util::uitos(group->getCompletedLength()); TransferStat stat = group->calculateStat(); - entryDict["downloadSpeed"] = Util::uitos(stat.getDownloadSpeed()); - entryDict["uploadSpeed"] = Util::uitos(stat.getUploadSpeed()); - entryDict["uploadLength"] = Util::uitos(stat.getAllTimeUploadLength()); - entryDict["connections"] = Util::uitos(group->getNumConnection()); + entryDict["downloadSpeed"] = util::uitos(stat.getDownloadSpeed()); + entryDict["uploadSpeed"] = util::uitos(stat.getUploadSpeed()); + entryDict["uploadLength"] = util::uitos(stat.getAllTimeUploadLength()); + entryDict["connections"] = util::uitos(group->getNumConnection()); SharedHandle ps = group->getPieceStorage(); if(!ps.isNull()) { if(ps->getBitfieldLength() > 0) { - entryDict["bitfield"] = Util::toHex(ps->getBitfield(), + entryDict["bitfield"] = util::toHex(ps->getBitfield(), ps->getBitfieldLength()); } } entryDict["pieceLength"] = - Util::uitos(group->getDownloadContext()->getPieceLength()); + util::uitos(group->getDownloadContext()->getPieceLength()); entryDict["numPieces"] = - Util::uitos(group->getDownloadContext()->getNumPieces()); + util::uitos(group->getDownloadContext()->getNumPieces()); } #ifdef ENABLE_BITTORRENT @@ -293,7 +293,7 @@ static void gatherProgressBitTorrent (BDE& entryDict, const BDE& torrentAttrs, const SharedHandle& btreg) { const std::string& infoHash = torrentAttrs[bittorrent::INFO_HASH].s(); - entryDict["infoHash"] = Util::toHex(infoHash); + entryDict["infoHash"] = util::toHex(infoHash); SharedHandle peerStorage = btreg->get(infoHash)._peerStorage; assert(!peerStorage.isNull()); @@ -310,17 +310,17 @@ static void gatherPeer(BDE& peers, const SharedHandle& ps) for(std::deque >::const_iterator i = activePeers.begin(); i != activePeers.end(); ++i) { BDE peerEntry = BDE::dict(); - peerEntry["peerId"] = Util::torrentUrlencode((*i)->getPeerId(), + peerEntry["peerId"] = util::torrentUrlencode((*i)->getPeerId(), PEER_ID_LENGTH); peerEntry["ip"] = (*i)->ipaddr; - peerEntry["port"] = Util::uitos((*i)->port); - peerEntry["bitfield"] = Util::toHex((*i)->getBitfield(), + peerEntry["port"] = util::uitos((*i)->port); + peerEntry["bitfield"] = util::toHex((*i)->getBitfield(), (*i)->getBitfieldLength()); peerEntry["amChoking"] = (*i)->amChoking()?BDE_TRUE:BDE_FALSE; peerEntry["peerChoking"] = (*i)->peerChoking()?BDE_TRUE:BDE_FALSE; TransferStat stat = ps->getTransferStatFor(*i); - peerEntry["downloadSpeed"] = Util::uitos(stat.getDownloadSpeed()); - peerEntry["uploadSpeed"] = Util::uitos(stat.getUploadSpeed()); + peerEntry["downloadSpeed"] = util::uitos(stat.getDownloadSpeed()); + peerEntry["uploadSpeed"] = util::uitos(stat.getUploadSpeed()); peerEntry["seeder"] = (*i)->isSeeder()?BDE_TRUE:BDE_FALSE; peers << peerEntry; } @@ -344,8 +344,8 @@ static void gatherProgress static void gatherStoppedDownload (BDE& entryDict, const SharedHandle& ds) { - entryDict["gid"] = Util::itos(ds->gid); - entryDict["errorCode"] = Util::itos(static_cast(ds->result)); + entryDict["gid"] = util::itos(ds->gid); + entryDict["errorCode"] = util::itos(static_cast(ds->result)); if(ds->result == downloadresultcode::IN_PROGRESS) { entryDict["status"] = BDE_REMOVED; } else if(ds->result == downloadresultcode::FINISHED) { @@ -372,10 +372,10 @@ static void createFileEntry(BDE& files, InputIterator first, InputIterator last) size_t index = 1; for(; first != last; ++first, ++index) { BDE entry = BDE::dict(); - entry["index"] = Util::uitos(index); + entry["index"] = util::uitos(index); entry["path"] = (*first)->getPath(); entry["selected"] = (*first)->isRequested()?BDE_TRUE:BDE_FALSE; - entry["length"] = Util::uitos((*first)->getLength()); + entry["length"] = util::uitos((*first)->getLength()); files << entry; } } @@ -390,7 +390,7 @@ BDE GetFilesXmlRpcMethod::process throw DL_ABORT_EX(MSG_GID_NOT_PROVIDED); } - int32_t gid = Util::parseInt(params[0].s()); + int32_t gid = util::parseInt(params[0].s()); BDE files = BDE::list(); SharedHandle group = findRequestGroup(e->_requestGroupMan, gid); @@ -421,7 +421,7 @@ BDE GetUrisXmlRpcMethod::process throw DL_ABORT_EX(MSG_GID_NOT_PROVIDED); } - int32_t gid = Util::parseInt(params[0].s()); + int32_t gid = util::parseInt(params[0].s()); SharedHandle group = findRequestGroup(e->_requestGroupMan, gid); if(group.isNull()) { @@ -454,7 +454,7 @@ BDE GetPeersXmlRpcMethod::process throw DL_ABORT_EX(MSG_GID_NOT_PROVIDED); } - int32_t gid = Util::parseInt(params[0].s()); + int32_t gid = util::parseInt(params[0].s()); SharedHandle group = findRequestGroup(e->_requestGroupMan, gid); if(group.isNull()) { @@ -486,7 +486,7 @@ BDE TellStatusXmlRpcMethod::process throw DL_ABORT_EX(MSG_GID_NOT_PROVIDED); } - int32_t gid = Util::parseInt(params[0].s()); + int32_t gid = util::parseInt(params[0].s()); SharedHandle group = e->_requestGroupMan->findRequestGroup(gid); @@ -585,7 +585,7 @@ BDE ChangeOptionXmlRpcMethod::process if(params.empty() || !params[0].isString()) { throw DL_ABORT_EX(MSG_GID_NOT_PROVIDED); } - int32_t gid = Util::parseInt(params[0].s()); + int32_t gid = util::parseInt(params[0].s()); SharedHandle group = findRequestGroup(e->_requestGroupMan, gid); if(group.isNull()) { diff --git a/src/XmlRpcRequestParserStateImpl.cc b/src/XmlRpcRequestParserStateImpl.cc index cf088049..b4c4764a 100644 --- a/src/XmlRpcRequestParserStateImpl.cc +++ b/src/XmlRpcRequestParserStateImpl.cc @@ -185,7 +185,7 @@ void IntXmlRpcRequestParserState::endElement const std::string& characters) { try { - int64_t value = Util::parseLLInt(characters); + int64_t value = util::parseLLInt(characters); stm->setCurrentFrameValue(BDE(value)); } catch(RecoverableException& e) { // nothing to do here: We just leave current frame value to BDE::none diff --git a/src/XmlRpcResponse.cc b/src/XmlRpcResponse.cc index 1e194d23..bccc95a5 100644 --- a/src/XmlRpcResponse.cc +++ b/src/XmlRpcResponse.cc @@ -63,7 +63,7 @@ static void encodeStruct o << ""; for(; first != last; ++first) { o << "" - << "" << Util::htmlEscape((*first).first) << ""; + << "" << util::htmlEscape((*first).first) << ""; encodeValue((*first).second, o); o << ""; } @@ -74,7 +74,7 @@ static void encodeValue(const BDE& value, std::ostream& o) { o << ""; if(value.isString()) { - o << "" << Util::htmlEscape(value.s()) << ""; + o << "" << util::htmlEscape(value.s()) << ""; } else if(value.isInteger()) { o << "" << value.i() << ""; } else if(value.isList()) { diff --git a/src/bittorrent_helper.cc b/src/bittorrent_helper.cc index 53c8a006..7b55f12a 100644 --- a/src/bittorrent_helper.cc +++ b/src/bittorrent_helper.cc @@ -133,7 +133,7 @@ static void extractPieceHash(const SharedHandle& ctx, std::vector pieceHashes; pieceHashes.reserve(numPieces); for(size_t i = 0; i < numPieces; ++i) { - pieceHashes.push_back(Util::toHex(hashData.data()+i*hashLength, + pieceHashes.push_back(util::toHex(hashData.data()+i*hashLength, hashLength)); } ctx->setPieceHashes(pieceHashes.begin(), pieceHashes.end()); @@ -167,7 +167,7 @@ static OutputIterator createUri const std::string& filePath) { for(; first != last; ++first) { - if(Util::endsWith(*first, "/")) { + if(util::endsWith(*first, "/")) { *out++ = (*first)+filePath; } else { *out++ = (*first)+"/"+filePath; @@ -196,8 +196,8 @@ static void extractFileEntries if(nameData.isString()) { // Split path by '/' just in case nasty ".." is included in name std::vector pathelems; - split(nameData.s(), std::back_inserter(pathelems), "/"); - name = Util::joinPath(pathelems.begin(), pathelems.end()); + util::split(nameData.s(), std::back_inserter(pathelems), "/"); + name = util::joinPath(pathelems.begin(), pathelems.end()); torrent[NAME] = nameData.s(); } else { name = strconcat(File(defaultName).getBasename(), ".file"); @@ -244,12 +244,12 @@ static void extractFileEntries std::transform(pathList.listBegin(), pathList.listEnd(), pathelem.begin(), std::mem_fun_ref(&BDE::s)); std::string path = name; - strappend(path, "/", Util::joinPath(pathelem.begin(), pathelem.end())); + strappend(path, "/", util::joinPath(pathelem.begin(), pathelem.end())); // Split path with '/' again because each pathList element can // contain "/" inside. std::vector elements; - split(path, std::back_inserter(elements), "/"); - path = Util::joinPath(elements.begin(), elements.end()); + util::split(path, std::back_inserter(elements), "/"); + path = util::joinPath(elements.begin(), elements.end()); std::deque uris; createUri(urlList.begin(), urlList.end(), std::back_inserter(uris), path); @@ -275,7 +275,7 @@ static void extractFileEntries std::deque uris; for(std::vector::const_iterator i = urlList.begin(); i != urlList.end(); ++i) { - if(Util::endsWith(*i, "/")) { + if(util::endsWith(*i, "/")) { uris.push_back((*i)+name); } else { uris.push_back(*i); @@ -323,7 +323,7 @@ static void extractNodes(BDE& torrent, const BDE& nodesList) if(!hostname.isString()) { continue; } - if(Util::trim(hostname.s()).empty()) { + if(util::trim(hostname.s()).empty()) { continue; } const BDE& port = addrPairList[1]; @@ -525,7 +525,7 @@ getInfoHash(const SharedHandle& downloadContext) std::string getInfoHashString(const SharedHandle& downloadContext) { - return Util::toHex(downloadContext->getAttribute(BITTORRENT)[INFO_HASH].s()); + return util::toHex(downloadContext->getAttribute(BITTORRENT)[INFO_HASH].s()); } void print(std::ostream& o, const SharedHandle& dctx) @@ -562,11 +562,11 @@ void print(std::ostream& o, const SharedHandle& dctx) } o << "\n"; } - o << "Info Hash: " << Util::toHex(torrentAttrs[INFO_HASH].s()) << "\n"; - o << "Piece Length: " << Util::abbrevSize(dctx->getPieceLength()) << "B\n"; + o << "Info Hash: " << util::toHex(torrentAttrs[INFO_HASH].s()) << "\n"; + o << "Piece Length: " << util::abbrevSize(dctx->getPieceLength()) << "B\n"; o << "The Number of Pieces: " << dctx->getNumPieces() << "\n"; - o << "Total Length: " << Util::abbrevSize(dctx->getTotalLength()) << "B (" - << Util::uitos(dctx->getTotalLength(), true) << ")\n"; + o << "Total Length: " << util::abbrevSize(dctx->getTotalLength()) << "B (" + << util::uitos(dctx->getTotalLength(), true) << ")\n"; if(!torrentAttrs[URL_LIST].empty()) { const BDE& urlList = torrentAttrs[URL_LIST]; o << "URL List: " << "\n"; @@ -576,7 +576,7 @@ void print(std::ostream& o, const SharedHandle& dctx) } } o << "Name: " << torrentAttrs[NAME].s() << "\n"; - Util::toStream(dctx->getFileEntries().begin(), dctx->getFileEntries().end(), o); + util::toStream(dctx->getFileEntries().begin(), dctx->getFileEntries().end(), o); } void computeFastSet diff --git a/src/download_helper.cc b/src/download_helper.cc index 4a26312c..418ea96c 100644 --- a/src/download_helper.cc +++ b/src/download_helper.cc @@ -210,10 +210,10 @@ createBtRequestGroup(const std::string& torrentFilePath, // throw // exception } - dctx->setFileFilter(Util::parseIntRange(option->get(PREF_SELECT_FILE))); + dctx->setFileFilter(util::parseIntRange(option->get(PREF_SELECT_FILE))); std::istringstream indexOutIn(option->get(PREF_INDEX_OUT)); std::map indexPathMap = - Util::createIndexPathMap(indexOutIn); + util::createIndexPathMap(indexOutIn); for(std::map::const_iterator i = indexPathMap.begin(); i != indexPathMap.end(); ++i) { dctx->setFilePathWithIndex diff --git a/src/main.cc b/src/main.cc index 11ade560..d5b4ab19 100644 --- a/src/main.cc +++ b/src/main.cc @@ -125,7 +125,7 @@ static void showMetalinkFile MetalinkHelper::parseAndQuery(metalinkEntries, uri, op.get()); std::deque > fileEntries; MetalinkEntry::toFileEntry(fileEntries, metalinkEntries); - Util::toStream(fileEntries.begin(), fileEntries.end(), std::cout); + util::toStream(fileEntries.begin(), fileEntries.end(), std::cout); std::cout << std::endl; } #endif // ENABLE_METALINK @@ -209,12 +209,12 @@ downloadresultcode::RESULT main(int argc, char* argv[]) #endif // ENABLE_MESSAGE_DIGEST #ifdef SIGPIPE - Util::setGlobalSignalHandler(SIGPIPE, SIG_IGN, 0); + util::setGlobalSignalHandler(SIGPIPE, SIG_IGN, 0); #endif #ifdef SIGCHLD // Avoid to create zombie process when forked child processes are // died. - Util::setGlobalSignalHandler(SIGCHLD, SIG_IGN, 0); + util::setGlobalSignalHandler(SIGCHLD, SIG_IGN, 0); #endif // SIGCHILD std::deque > requestGroups; #ifdef ENABLE_BITTORRENT diff --git a/src/messageDigest.cc b/src/messageDigest.cc index d16e3b33..1f498edd 100644 --- a/src/messageDigest.cc +++ b/src/messageDigest.cc @@ -79,7 +79,7 @@ std::string MessageDigestContext::getSupportedAlgoString() algos += (*itr).first; algos += ", "; } - return Util::trim(algos, ", "); + return util::trim(algos, ", "); } } // namespace aria2 diff --git a/src/option_processing.cc b/src/option_processing.cc index 3f37ad53..6ae461a6 100644 --- a/src/option_processing.cc +++ b/src/option_processing.cc @@ -109,7 +109,7 @@ void option_processing(Option& op, std::deque& uris, keyword = TAG_BASIC; } else { keyword = op.get("help"); - if(Util::startsWith(keyword, "--")) { + if(util::startsWith(keyword, "--")) { keyword = keyword.substr(2); } std::string::size_type eqpos = keyword.find("="); diff --git a/src/version_usage.cc b/src/version_usage.cc index 351bc161..8658faf6 100644 --- a/src/version_usage.cc +++ b/src/version_usage.cc @@ -85,7 +85,7 @@ void showUsage(const std::string& keyword, const OptionParser& oparser) { std::cout << _("Usage: aria2c [OPTIONS] [URL | TORRENT_FILE |" " METALINK_FILE]...") << "\n" << "\n"; - if(Util::startsWith(keyword, "#")) { + if(util::startsWith(keyword, "#")) { std::deque > handlers = keyword == TAG_ALL ? oparser.findAll():oparser.findByTag(keyword); if(keyword == TAG_ALL) { diff --git a/test/BDETest.cc b/test/BDETest.cc index 44f25d01..e311cf86 100644 --- a/test/BDETest.cc +++ b/test/BDETest.cc @@ -48,8 +48,8 @@ void BDETest::testString() const unsigned char uc[] = { 0x08, 0x19, 0x2a, 0x3b }; BDE data(uc, sizeof(uc)); - CPPUNIT_ASSERT_EQUAL(Util::toHex(uc, sizeof(uc)), - Util::toHex(data.uc(), data.s().size())); + CPPUNIT_ASSERT_EQUAL(util::toHex(uc, sizeof(uc)), + util::toHex(data.uc(), data.s().size())); } void BDETest::testInteger() diff --git a/test/BittorrentHelperTest.cc b/test/BittorrentHelperTest.cc index 29ca2bcc..0d498c61 100644 --- a/test/BittorrentHelperTest.cc +++ b/test/BittorrentHelperTest.cc @@ -131,11 +131,11 @@ void BittorrentHelperTest::testGetPieceHash() { SharedHandle dctx(new DownloadContext()); load("test.torrent", dctx); - CPPUNIT_ASSERT_EQUAL(Util::toHex("AAAAAAAAAAAAAAAAAAAA", 20), + CPPUNIT_ASSERT_EQUAL(util::toHex("AAAAAAAAAAAAAAAAAAAA", 20), dctx->getPieceHash(0)); - CPPUNIT_ASSERT_EQUAL(Util::toHex("BBBBBBBBBBBBBBBBBBBB", 20), + CPPUNIT_ASSERT_EQUAL(util::toHex("BBBBBBBBBBBBBBBBBBBB", 20), dctx->getPieceHash(1)); - CPPUNIT_ASSERT_EQUAL(Util::toHex("CCCCCCCCCCCCCCCCCCCC", 20), + CPPUNIT_ASSERT_EQUAL(util::toHex("CCCCCCCCCCCCCCCCCCCC", 20), dctx->getPieceHash(2)); CPPUNIT_ASSERT_EQUAL(std::string(""), dctx->getPieceHash(3)); @@ -241,7 +241,7 @@ void BittorrentHelperTest::testGetAnnounceTier() { const BDE& tier = announceList[0]; CPPUNIT_ASSERT_EQUAL((size_t)1, tier.size()); CPPUNIT_ASSERT_EQUAL(std::string("http://aria.rednoah.com/announce.php"), - Util::trim(tier[0].s())); + util::trim(tier[0].s())); } @@ -257,7 +257,7 @@ void BittorrentHelperTest::testGetAnnounceTierAnnounceList() { const BDE& tier1 = announceList[0]; CPPUNIT_ASSERT_EQUAL((size_t)1, tier1.size()); CPPUNIT_ASSERT_EQUAL(std::string("http://tracker1"), - Util::trim(tier1[0].s())); + util::trim(tier1[0].s())); const BDE& tier2 = announceList[1]; CPPUNIT_ASSERT_EQUAL((size_t)1, tier2.size()); @@ -586,15 +586,15 @@ void BittorrentHelperTest::testSetFileFilter_single() CPPUNIT_ASSERT(dctx->getFirstFileEntry()->isRequested()); - dctx->setFileFilter(Util::parseIntRange("")); + dctx->setFileFilter(util::parseIntRange("")); CPPUNIT_ASSERT(dctx->getFirstFileEntry()->isRequested()); - dctx->setFileFilter(Util::parseIntRange("1")); + dctx->setFileFilter(util::parseIntRange("1")); CPPUNIT_ASSERT(dctx->getFirstFileEntry()->isRequested()); // For single file torrent, file is always selected whatever range // is passed. - dctx->setFileFilter(Util::parseIntRange("2")); + dctx->setFileFilter(util::parseIntRange("2")); CPPUNIT_ASSERT(dctx->getFirstFileEntry()->isRequested()); } @@ -606,19 +606,19 @@ void BittorrentHelperTest::testSetFileFilter_multi() CPPUNIT_ASSERT(dctx->getFileEntries()[0]->isRequested()); CPPUNIT_ASSERT(dctx->getFileEntries()[1]->isRequested()); - dctx->setFileFilter(Util::parseIntRange("")); + dctx->setFileFilter(util::parseIntRange("")); CPPUNIT_ASSERT(dctx->getFileEntries()[0]->isRequested()); CPPUNIT_ASSERT(dctx->getFileEntries()[1]->isRequested()); - dctx->setFileFilter(Util::parseIntRange("2")); + dctx->setFileFilter(util::parseIntRange("2")); CPPUNIT_ASSERT(!dctx->getFileEntries()[0]->isRequested()); CPPUNIT_ASSERT(dctx->getFileEntries()[1]->isRequested()); - dctx->setFileFilter(Util::parseIntRange("3")); + dctx->setFileFilter(util::parseIntRange("3")); CPPUNIT_ASSERT(!dctx->getFileEntries()[0]->isRequested()); CPPUNIT_ASSERT(!dctx->getFileEntries()[1]->isRequested()); - dctx->setFileFilter(Util::parseIntRange("1,2")); + dctx->setFileFilter(util::parseIntRange("1,2")); CPPUNIT_ASSERT(dctx->getFileEntries()[0]->isRequested()); CPPUNIT_ASSERT(dctx->getFileEntries()[1]->isRequested()); } diff --git a/test/BtBitfieldMessageTest.cc b/test/BtBitfieldMessageTest.cc index 13acdace..68fbd042 100644 --- a/test/BtBitfieldMessageTest.cc +++ b/test/BtBitfieldMessageTest.cc @@ -86,10 +86,10 @@ void BtBitfieldMessageTest::testDoReceivedAction() { unsigned char bitfield[] = { 0xff, 0xff }; msg.setBitfield(bitfield, sizeof(bitfield)); - CPPUNIT_ASSERT_EQUAL(std::string("0000"), Util::toHex(peer->getBitfield(), + CPPUNIT_ASSERT_EQUAL(std::string("0000"), util::toHex(peer->getBitfield(), peer->getBitfieldLength())); msg.doReceivedAction(); - CPPUNIT_ASSERT_EQUAL(std::string("ffff"), Util::toHex(peer->getBitfield(), + CPPUNIT_ASSERT_EQUAL(std::string("ffff"), util::toHex(peer->getBitfield(), peer->getBitfieldLength())); } diff --git a/test/BtHandshakeMessageTest.cc b/test/BtHandshakeMessageTest.cc index d787a654..c70ed360 100644 --- a/test/BtHandshakeMessageTest.cc +++ b/test/BtHandshakeMessageTest.cc @@ -60,14 +60,14 @@ void BtHandshakeMessageTest::testCreate() { SharedHandle message = BtHandshakeMessage::create(&msg[0], sizeof(msg)); CPPUNIT_ASSERT_EQUAL((uint8_t)INT8_MAX, message->getId()); CPPUNIT_ASSERT_EQUAL((uint8_t)19, message->getPstrlen()); - CPPUNIT_ASSERT_EQUAL(Util::toHex((const unsigned char*)BTPSTR.c_str(), BTPSTR.size()), - Util::toHex(message->getPstr(), BtHandshakeMessage::PSTR_LENGTH)); + CPPUNIT_ASSERT_EQUAL(util::toHex((const unsigned char*)BTPSTR.c_str(), BTPSTR.size()), + util::toHex(message->getPstr(), BtHandshakeMessage::PSTR_LENGTH)); CPPUNIT_ASSERT_EQUAL(std::string("0000000000100004"), - Util::toHex(message->getReserved(), BtHandshakeMessage::RESERVED_LENGTH)); + util::toHex(message->getReserved(), BtHandshakeMessage::RESERVED_LENGTH)); CPPUNIT_ASSERT_EQUAL(std::string("ffffffffffffffffffffffffffffffffffffffff"), - Util::toHex(message->getInfoHash(), INFO_HASH_LENGTH)); + util::toHex(message->getInfoHash(), INFO_HASH_LENGTH)); CPPUNIT_ASSERT_EQUAL(std::string("f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0"), - Util::toHex(message->getPeerId(), PEER_ID_LENGTH)); + util::toHex(message->getPeerId(), PEER_ID_LENGTH)); } void BtHandshakeMessageTest::testGetMessage() { @@ -86,8 +86,8 @@ void BtHandshakeMessageTest::testGetMessage() { unsigned char data[68]; createHandshakeMessageData(data); - CPPUNIT_ASSERT_EQUAL(Util::toHex((const unsigned char*)data, 68), - Util::toHex((const unsigned char*)msg->getMessage(), 68)); + CPPUNIT_ASSERT_EQUAL(util::toHex((const unsigned char*)data, 68), + util::toHex((const unsigned char*)msg->getMessage(), 68)); } void BtHandshakeMessageTest::testToString() { diff --git a/test/DHKeyExchangeTest.cc b/test/DHKeyExchangeTest.cc index 457cbd98..8c31d6eb 100644 --- a/test/DHKeyExchangeTest.cc +++ b/test/DHKeyExchangeTest.cc @@ -48,8 +48,8 @@ void DHKeyExchangeTest::testHandshake() dhA.computeSecret(secretA, sizeof(secretA), publicKeyB, sizeof(publicKeyB)); dhB.computeSecret(secretB, sizeof(secretB), publicKeyA, sizeof(publicKeyA)); - CPPUNIT_ASSERT_EQUAL(Util::toHex(secretA, sizeof(secretA)), - Util::toHex(secretB, sizeof(secretB))); + CPPUNIT_ASSERT_EQUAL(util::toHex(secretA, sizeof(secretA)), + util::toHex(secretB, sizeof(secretB))); } } // namespace aria2 diff --git a/test/DHTAnnouncePeerMessageTest.cc b/test/DHTAnnouncePeerMessageTest.cc index 99c2a16c..698d0201 100644 --- a/test/DHTAnnouncePeerMessageTest.cc +++ b/test/DHTAnnouncePeerMessageTest.cc @@ -70,8 +70,8 @@ void DHTAnnouncePeerMessageTest::testGetBencodedMessage() aDict["token"] = token; dict["a"] = aDict; - CPPUNIT_ASSERT_EQUAL(Util::urlencode(bencode::encode(dict)), - Util::urlencode(msgbody)); + CPPUNIT_ASSERT_EQUAL(util::urlencode(bencode::encode(dict)), + util::urlencode(msgbody)); } void DHTAnnouncePeerMessageTest::testDoReceivedAction() diff --git a/test/DHTBucketTest.cc b/test/DHTBucketTest.cc index f5bc44ff..28ce240b 100644 --- a/test/DHTBucketTest.cc +++ b/test/DHTBucketTest.cc @@ -70,7 +70,7 @@ void DHTBucketTest::testGetRandomNodeID() unsigned char nodeID[DHT_ID_LENGTH]; bucket.getRandomNodeID(nodeID); CPPUNIT_ASSERT_EQUAL(std::string("0101"), - Util::toHex(nodeID, sizeof(nodeID)).substr(0, 4)); + util::toHex(nodeID, sizeof(nodeID)).substr(0, 4)); } } @@ -210,10 +210,10 @@ void DHTBucketTest::testSplit() 0xff, 0xff, 0xff, 0xff, 0xff }; unsigned char expectedRMin[DHT_ID_LENGTH]; memset(expectedRMin, 0, DHT_ID_LENGTH); - CPPUNIT_ASSERT_EQUAL(Util::toHex(expectedRMax, DHT_ID_LENGTH), - Util::toHex(r->getMaxID(), DHT_ID_LENGTH)); - CPPUNIT_ASSERT_EQUAL(Util::toHex(expectedRMin, DHT_ID_LENGTH), - Util::toHex(r->getMinID(), DHT_ID_LENGTH)); + CPPUNIT_ASSERT_EQUAL(util::toHex(expectedRMax, DHT_ID_LENGTH), + util::toHex(r->getMaxID(), DHT_ID_LENGTH)); + CPPUNIT_ASSERT_EQUAL(util::toHex(expectedRMin, DHT_ID_LENGTH), + util::toHex(r->getMinID(), DHT_ID_LENGTH)); CPPUNIT_ASSERT_EQUAL((size_t)1, r->getPrefixLength()); } { @@ -223,10 +223,10 @@ void DHTBucketTest::testSplit() 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; - CPPUNIT_ASSERT_EQUAL(Util::toHex(expectedLMax, DHT_ID_LENGTH), - Util::toHex(bucket.getMaxID(), DHT_ID_LENGTH)); - CPPUNIT_ASSERT_EQUAL(Util::toHex(expectedLMin, DHT_ID_LENGTH), - Util::toHex(bucket.getMinID(), DHT_ID_LENGTH)); + CPPUNIT_ASSERT_EQUAL(util::toHex(expectedLMax, DHT_ID_LENGTH), + util::toHex(bucket.getMaxID(), DHT_ID_LENGTH)); + CPPUNIT_ASSERT_EQUAL(util::toHex(expectedLMin, DHT_ID_LENGTH), + util::toHex(bucket.getMinID(), DHT_ID_LENGTH)); CPPUNIT_ASSERT_EQUAL((size_t)1, bucket.getPrefixLength()); } } @@ -245,10 +245,10 @@ void DHTBucketTest::testSplit() 0x00, 0x00, 0x00, 0x00, 0x01 }; unsigned char expectedMin[DHT_ID_LENGTH]; memset(expectedMin, 0, DHT_ID_LENGTH); - CPPUNIT_ASSERT_EQUAL(Util::toHex(expectedMax, DHT_ID_LENGTH), - Util::toHex(bucket->getMaxID(), DHT_ID_LENGTH)); - CPPUNIT_ASSERT_EQUAL(Util::toHex(expectedMin, DHT_ID_LENGTH), - Util::toHex(bucket->getMinID(), DHT_ID_LENGTH)); + CPPUNIT_ASSERT_EQUAL(util::toHex(expectedMax, DHT_ID_LENGTH), + util::toHex(bucket->getMaxID(), DHT_ID_LENGTH)); + CPPUNIT_ASSERT_EQUAL(util::toHex(expectedMin, DHT_ID_LENGTH), + util::toHex(bucket->getMinID(), DHT_ID_LENGTH)); CPPUNIT_ASSERT_EQUAL((size_t)159, bucket->getPrefixLength()); } } @@ -266,10 +266,10 @@ void DHTBucketTest::testSplit() 0xff, 0xff, 0xff, 0xff, 0xff }; unsigned char expectedRMin[DHT_ID_LENGTH]; memset(expectedRMin, 0, DHT_ID_LENGTH); - CPPUNIT_ASSERT_EQUAL(Util::toHex(expectedRMax, DHT_ID_LENGTH), - Util::toHex(r->getMaxID(), DHT_ID_LENGTH)); - CPPUNIT_ASSERT_EQUAL(Util::toHex(expectedRMin, DHT_ID_LENGTH), - Util::toHex(r->getMinID(), DHT_ID_LENGTH)); + CPPUNIT_ASSERT_EQUAL(util::toHex(expectedRMax, DHT_ID_LENGTH), + util::toHex(r->getMaxID(), DHT_ID_LENGTH)); + CPPUNIT_ASSERT_EQUAL(util::toHex(expectedRMin, DHT_ID_LENGTH), + util::toHex(r->getMinID(), DHT_ID_LENGTH)); CPPUNIT_ASSERT_EQUAL((size_t)1, r->getPrefixLength()); } { @@ -279,10 +279,10 @@ void DHTBucketTest::testSplit() 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; - CPPUNIT_ASSERT_EQUAL(Util::toHex(expectedLMax, DHT_ID_LENGTH), - Util::toHex(bucket.getMaxID(), DHT_ID_LENGTH)); - CPPUNIT_ASSERT_EQUAL(Util::toHex(expectedLMin, DHT_ID_LENGTH), - Util::toHex(bucket.getMinID(), DHT_ID_LENGTH)); + CPPUNIT_ASSERT_EQUAL(util::toHex(expectedLMax, DHT_ID_LENGTH), + util::toHex(bucket.getMaxID(), DHT_ID_LENGTH)); + CPPUNIT_ASSERT_EQUAL(util::toHex(expectedLMin, DHT_ID_LENGTH), + util::toHex(bucket.getMinID(), DHT_ID_LENGTH)); CPPUNIT_ASSERT_EQUAL((size_t)1, bucket.getPrefixLength()); } } diff --git a/test/DHTFindNodeReplyMessageTest.cc b/test/DHTFindNodeReplyMessageTest.cc index 9b2cf0d5..0e58e60d 100644 --- a/test/DHTFindNodeReplyMessageTest.cc +++ b/test/DHTFindNodeReplyMessageTest.cc @@ -42,7 +42,7 @@ void DHTFindNodeReplyMessageTest::testGetBencodedMessage() SharedHandle nodes[8]; for(size_t i = 0; i < DHTBucket::K; ++i) { nodes[i].reset(new DHTNode()); - nodes[i]->setIPAddress("192.168.0."+Util::uitos(i+1)); + nodes[i]->setIPAddress("192.168.0."+util::uitos(i+1)); nodes[i]->setPort(6881+i); unsigned char buf[6]; diff --git a/test/DHTGetPeersMessageTest.cc b/test/DHTGetPeersMessageTest.cc index 9c6a8865..bbe96ccb 100644 --- a/test/DHTGetPeersMessageTest.cc +++ b/test/DHTGetPeersMessageTest.cc @@ -88,8 +88,8 @@ void DHTGetPeersMessageTest::testGetBencodedMessage() aDict["info_hash"] = BDE(infoHash, DHT_ID_LENGTH); dict["a"] = aDict; - CPPUNIT_ASSERT_EQUAL(Util::urlencode(bencode::encode(dict)), - Util::urlencode(msgbody)); + CPPUNIT_ASSERT_EQUAL(util::urlencode(bencode::encode(dict)), + util::urlencode(msgbody)); } void DHTGetPeersMessageTest::testDoReceivedAction() diff --git a/test/DHTGetPeersReplyMessageTest.cc b/test/DHTGetPeersReplyMessageTest.cc index c7e5444c..b509b8a3 100644 --- a/test/DHTGetPeersReplyMessageTest.cc +++ b/test/DHTGetPeersReplyMessageTest.cc @@ -53,7 +53,7 @@ void DHTGetPeersReplyMessageTest::testGetBencodedMessage() SharedHandle nodes[8]; for(size_t i = 0; i < DHTBucket::K; ++i) { nodes[i].reset(new DHTNode()); - nodes[i]->setIPAddress("192.168.0."+Util::uitos(i+1)); + nodes[i]->setIPAddress("192.168.0."+util::uitos(i+1)); nodes[i]->setPort(6881+i); unsigned char buf[6]; @@ -70,15 +70,15 @@ void DHTGetPeersReplyMessageTest::testGetBencodedMessage() rDict["nodes"] = compactNodeInfo; - CPPUNIT_ASSERT_EQUAL(Util::urlencode(bencode::encode(dict)), - Util::urlencode(msgbody)); + CPPUNIT_ASSERT_EQUAL(util::urlencode(bencode::encode(dict)), + util::urlencode(msgbody)); } rDict.removeKey("nodes"); { std::deque > peers; BDE valuesList = BDE::list(); for(size_t i = 0; i < 4; ++i) { - SharedHandle peer(new Peer("192.168.0."+Util::uitos(i+1), 6881+i)); + SharedHandle peer(new Peer("192.168.0."+util::uitos(i+1), 6881+i)); unsigned char buffer[6]; CPPUNIT_ASSERT(bittorrent::createcompact (buffer, peer->ipaddr, peer->port)); @@ -90,8 +90,8 @@ void DHTGetPeersReplyMessageTest::testGetBencodedMessage() msg.setValues(peers); std::string msgbody = msg.getBencodedMessage(); - CPPUNIT_ASSERT_EQUAL(Util::urlencode(bencode::encode(dict)), - Util::urlencode(msgbody)); + CPPUNIT_ASSERT_EQUAL(util::urlencode(bencode::encode(dict)), + util::urlencode(msgbody)); } } diff --git a/test/DHTMessageFactoryImplTest.cc b/test/DHTMessageFactoryImplTest.cc index 521c8a52..c312bd6f 100644 --- a/test/DHTMessageFactoryImplTest.cc +++ b/test/DHTMessageFactoryImplTest.cc @@ -96,8 +96,8 @@ void DHTMessageFactoryImplTest::testCreatePingMessage() CPPUNIT_ASSERT(localNode == m->getLocalNode()); CPPUNIT_ASSERT(remoteNode == m->getRemoteNode()); - CPPUNIT_ASSERT_EQUAL(Util::toHex(transactionID, DHT_TRANSACTION_ID_LENGTH), - Util::toHex(m->getTransactionID())); + CPPUNIT_ASSERT_EQUAL(util::toHex(transactionID, DHT_TRANSACTION_ID_LENGTH), + util::toHex(m->getTransactionID())); } void DHTMessageFactoryImplTest::testCreatePingReplyMessage() @@ -121,8 +121,8 @@ void DHTMessageFactoryImplTest::testCreatePingReplyMessage() CPPUNIT_ASSERT(localNode == m->getLocalNode()); CPPUNIT_ASSERT(remoteNode == m->getRemoteNode()); - CPPUNIT_ASSERT_EQUAL(Util::toHex(transactionID, DHT_TRANSACTION_ID_LENGTH), - Util::toHex(m->getTransactionID())); + CPPUNIT_ASSERT_EQUAL(util::toHex(transactionID, DHT_TRANSACTION_ID_LENGTH), + util::toHex(m->getTransactionID())); } void DHTMessageFactoryImplTest::testCreateFindNodeMessage() @@ -147,10 +147,10 @@ void DHTMessageFactoryImplTest::testCreateFindNodeMessage() CPPUNIT_ASSERT(localNode == m->getLocalNode()); CPPUNIT_ASSERT(remoteNode == m->getRemoteNode()); - CPPUNIT_ASSERT_EQUAL(Util::toHex(transactionID, DHT_TRANSACTION_ID_LENGTH), - Util::toHex(m->getTransactionID())); - CPPUNIT_ASSERT_EQUAL(Util::toHex(targetNodeID, DHT_ID_LENGTH), - Util::toHex(m->getTargetNodeID(), DHT_ID_LENGTH)); + CPPUNIT_ASSERT_EQUAL(util::toHex(transactionID, DHT_TRANSACTION_ID_LENGTH), + util::toHex(m->getTransactionID())); + CPPUNIT_ASSERT_EQUAL(util::toHex(targetNodeID, DHT_ID_LENGTH), + util::toHex(m->getTargetNodeID(), DHT_ID_LENGTH)); } void DHTMessageFactoryImplTest::testCreateFindNodeReplyMessage() @@ -165,7 +165,7 @@ void DHTMessageFactoryImplTest::testCreateFindNodeReplyMessage() SharedHandle nodes[8]; for(size_t i = 0; i < DHTBucket::K; ++i) { nodes[i].reset(new DHTNode()); - nodes[i]->setIPAddress("192.168.0."+Util::uitos(i+1)); + nodes[i]->setIPAddress("192.168.0."+util::uitos(i+1)); nodes[i]->setPort(6881+i); unsigned char buf[6]; @@ -193,8 +193,8 @@ void DHTMessageFactoryImplTest::testCreateFindNodeReplyMessage() CPPUNIT_ASSERT_EQUAL((size_t)DHTBucket::K, m->getClosestKNodes().size()); CPPUNIT_ASSERT(nodes[0] == m->getClosestKNodes()[0]); CPPUNIT_ASSERT(nodes[7] == m->getClosestKNodes()[7]); - CPPUNIT_ASSERT_EQUAL(Util::toHex(transactionID, DHT_TRANSACTION_ID_LENGTH), - Util::toHex(m->getTransactionID())); + CPPUNIT_ASSERT_EQUAL(util::toHex(transactionID, DHT_TRANSACTION_ID_LENGTH), + util::toHex(m->getTransactionID())); } catch(Exception& e) { CPPUNIT_FAIL(e.stackTrace()); } @@ -222,10 +222,10 @@ void DHTMessageFactoryImplTest::testCreateGetPeersMessage() CPPUNIT_ASSERT(localNode == m->getLocalNode()); CPPUNIT_ASSERT(remoteNode == m->getRemoteNode()); - CPPUNIT_ASSERT_EQUAL(Util::toHex(transactionID, DHT_TRANSACTION_ID_LENGTH), - Util::toHex(m->getTransactionID())); - CPPUNIT_ASSERT_EQUAL(Util::toHex(infoHash, DHT_ID_LENGTH), - Util::toHex(m->getInfoHash(), DHT_ID_LENGTH)); + CPPUNIT_ASSERT_EQUAL(util::toHex(transactionID, DHT_TRANSACTION_ID_LENGTH), + util::toHex(m->getTransactionID())); + CPPUNIT_ASSERT_EQUAL(util::toHex(infoHash, DHT_ID_LENGTH), + util::toHex(m->getInfoHash(), DHT_ID_LENGTH)); } void DHTMessageFactoryImplTest::testCreateGetPeersReplyMessage_nodes() @@ -240,7 +240,7 @@ void DHTMessageFactoryImplTest::testCreateGetPeersReplyMessage_nodes() SharedHandle nodes[8]; for(size_t i = 0; i < DHTBucket::K; ++i) { nodes[i].reset(new DHTNode()); - nodes[i]->setIPAddress("192.168.0."+Util::uitos(i+1)); + nodes[i]->setIPAddress("192.168.0."+util::uitos(i+1)); nodes[i]->setPort(6881+i); unsigned char buf[6]; @@ -270,8 +270,8 @@ void DHTMessageFactoryImplTest::testCreateGetPeersReplyMessage_nodes() CPPUNIT_ASSERT_EQUAL((size_t)DHTBucket::K, m->getClosestKNodes().size()); CPPUNIT_ASSERT(nodes[0] == m->getClosestKNodes()[0]); CPPUNIT_ASSERT(nodes[7] == m->getClosestKNodes()[7]); - CPPUNIT_ASSERT_EQUAL(Util::toHex(transactionID, DHT_TRANSACTION_ID_LENGTH), - Util::toHex(m->getTransactionID())); + CPPUNIT_ASSERT_EQUAL(util::toHex(transactionID, DHT_TRANSACTION_ID_LENGTH), + util::toHex(m->getTransactionID())); } catch(Exception& e) { CPPUNIT_FAIL(e.stackTrace()); } @@ -289,7 +289,7 @@ void DHTMessageFactoryImplTest::testCreateGetPeersReplyMessage_values() std::deque > peers; BDE valuesList = BDE::list(); for(size_t i = 0; i < 4; ++i) { - SharedHandle peer(new Peer("192.168.0."+Util::uitos(i+1), 6881+i)); + SharedHandle peer(new Peer("192.168.0."+util::uitos(i+1), 6881+i)); unsigned char buffer[6]; CPPUNIT_ASSERT(bittorrent::createcompact (buffer, peer->ipaddr, peer->port)); @@ -316,8 +316,8 @@ void DHTMessageFactoryImplTest::testCreateGetPeersReplyMessage_values() CPPUNIT_ASSERT_EQUAL((size_t)4, m->getValues().size()); CPPUNIT_ASSERT(peers[0] == m->getValues()[0]); CPPUNIT_ASSERT(peers[3] == m->getValues()[3]); - CPPUNIT_ASSERT_EQUAL(Util::toHex(transactionID, DHT_TRANSACTION_ID_LENGTH), - Util::toHex(m->getTransactionID())); + CPPUNIT_ASSERT_EQUAL(util::toHex(transactionID, DHT_TRANSACTION_ID_LENGTH), + util::toHex(m->getTransactionID())); } catch(Exception& e) { CPPUNIT_FAIL(e.stackTrace()); } @@ -351,10 +351,10 @@ void DHTMessageFactoryImplTest::testCreateAnnouncePeerMessage() CPPUNIT_ASSERT(localNode == m->getLocalNode()); CPPUNIT_ASSERT(remoteNode == m->getRemoteNode()); CPPUNIT_ASSERT_EQUAL(token, m->getToken()); - CPPUNIT_ASSERT_EQUAL(Util::toHex(transactionID, DHT_TRANSACTION_ID_LENGTH), - Util::toHex(m->getTransactionID())); - CPPUNIT_ASSERT_EQUAL(Util::toHex(infoHash, DHT_ID_LENGTH), - Util::toHex(m->getInfoHash(), DHT_ID_LENGTH)); + CPPUNIT_ASSERT_EQUAL(util::toHex(transactionID, DHT_TRANSACTION_ID_LENGTH), + util::toHex(m->getTransactionID())); + CPPUNIT_ASSERT_EQUAL(util::toHex(infoHash, DHT_ID_LENGTH), + util::toHex(m->getInfoHash(), DHT_ID_LENGTH)); CPPUNIT_ASSERT_EQUAL(port, m->getTCPPort()); } catch(Exception& e) { CPPUNIT_FAIL(e.stackTrace()); @@ -382,8 +382,8 @@ void DHTMessageFactoryImplTest::testCreateAnnouncePeerReplyMessage() CPPUNIT_ASSERT(localNode == m->getLocalNode()); CPPUNIT_ASSERT(remoteNode == m->getRemoteNode()); - CPPUNIT_ASSERT_EQUAL(Util::toHex(transactionID, DHT_TRANSACTION_ID_LENGTH), - Util::toHex(m->getTransactionID())); + CPPUNIT_ASSERT_EQUAL(util::toHex(transactionID, DHT_TRANSACTION_ID_LENGTH), + util::toHex(m->getTransactionID())); } void DHTMessageFactoryImplTest::testReceivedErrorMessage() diff --git a/test/DHTNodeTest.cc b/test/DHTNodeTest.cc index 1385e133..179ead55 100644 --- a/test/DHTNodeTest.cc +++ b/test/DHTNodeTest.cc @@ -25,7 +25,7 @@ CPPUNIT_TEST_SUITE_REGISTRATION(DHTNodeTest); void DHTNodeTest::testGenerateID() { DHTNode node; - std::cerr << Util::toHex(node.getID(), DHT_ID_LENGTH) << std::endl; + std::cerr << util::toHex(node.getID(), DHT_ID_LENGTH) << std::endl; } } // namespace aria2 diff --git a/test/DHTRoutingTableDeserializerTest.cc b/test/DHTRoutingTableDeserializerTest.cc index be824161..ee4ab142 100644 --- a/test/DHTRoutingTableDeserializerTest.cc +++ b/test/DHTRoutingTableDeserializerTest.cc @@ -39,7 +39,7 @@ void DHTRoutingTableDeserializerTest::testDeserialize() SharedHandle nodesSrc[3]; for(size_t i = 0; i < arrayLength(nodesSrc); ++i) { nodesSrc[i].reset(new DHTNode()); - nodesSrc[i]->setIPAddress("192.168.0."+Util::uitos(i+1)); + nodesSrc[i]->setIPAddress("192.168.0."+util::uitos(i+1)); nodesSrc[i]->setPort(6881+i); } nodesSrc[1]->setIPAddress("non-numerical-name"); diff --git a/test/DHTRoutingTableSerializerTest.cc b/test/DHTRoutingTableSerializerTest.cc index fc8e31be..428b2e34 100644 --- a/test/DHTRoutingTableSerializerTest.cc +++ b/test/DHTRoutingTableSerializerTest.cc @@ -36,7 +36,7 @@ void DHTRoutingTableSerializerTest::testSerialize() SharedHandle nodesSrc[3]; for(size_t i = 0; i < arrayLength(nodesSrc); ++i) { nodesSrc[i].reset(new DHTNode()); - nodesSrc[i]->setIPAddress("192.168.0."+Util::uitos(i+1)); + nodesSrc[i]->setIPAddress("192.168.0."+util::uitos(i+1)); nodesSrc[i]->setPort(6881+i); } nodesSrc[1]->setIPAddress("non-numerical-name"); diff --git a/test/DefaultBtProgressInfoFileTest.cc b/test/DefaultBtProgressInfoFileTest.cc index 9f95d80d..0e077e1a 100644 --- a/test/DefaultBtProgressInfoFileTest.cc +++ b/test/DefaultBtProgressInfoFileTest.cc @@ -135,7 +135,7 @@ void DefaultBtProgressInfoFileTest::testLoad_compat() // bitfield CPPUNIT_ASSERT_EQUAL(std::string("fffffffffffffffffffe"), - Util::toHex(_bitfield->getBitfield(), + util::toHex(_bitfield->getBitfield(), _bitfield->getBitfieldLength())); // the number of in-flight pieces @@ -150,7 +150,7 @@ void DefaultBtProgressInfoFileTest::testLoad_compat() CPPUNIT_ASSERT_EQUAL((size_t)1, piece1->getIndex()); CPPUNIT_ASSERT_EQUAL((size_t)1024, piece1->getLength()); CPPUNIT_ASSERT_EQUAL((size_t)1, piece1->getBitfieldLength()); - CPPUNIT_ASSERT_EQUAL(std::string("00"), Util::toHex(piece1->getBitfield(), + CPPUNIT_ASSERT_EQUAL(std::string("00"), util::toHex(piece1->getBitfield(), piece1->getBitfieldLength())); // piece index 2 @@ -184,7 +184,7 @@ void DefaultBtProgressInfoFileTest::testLoad() // bitfield CPPUNIT_ASSERT_EQUAL(std::string("fffffffffffffffffffe"), - Util::toHex(_bitfield->getBitfield(), + util::toHex(_bitfield->getBitfield(), _bitfield->getBitfieldLength())); // the number of in-flight pieces @@ -199,7 +199,7 @@ void DefaultBtProgressInfoFileTest::testLoad() CPPUNIT_ASSERT_EQUAL((size_t)1, piece1->getIndex()); CPPUNIT_ASSERT_EQUAL((size_t)1024, piece1->getLength()); CPPUNIT_ASSERT_EQUAL((size_t)1, piece1->getBitfieldLength()); - CPPUNIT_ASSERT_EQUAL(std::string("00"), Util::toHex(piece1->getBitfield(), + CPPUNIT_ASSERT_EQUAL(std::string("00"), util::toHex(piece1->getBitfield(), piece1->getBitfieldLength())); // piece index 2 @@ -244,12 +244,12 @@ void DefaultBtProgressInfoFileTest::testSave() unsigned char version[2]; in.read((char*)version, sizeof(version)); CPPUNIT_ASSERT_EQUAL(std::string("0001"), - Util::toHex(version, sizeof(version))); + util::toHex(version, sizeof(version))); unsigned char extension[4]; in.read((char*)extension, sizeof(extension)); CPPUNIT_ASSERT_EQUAL(std::string("00000001"), - Util::toHex(extension, sizeof(extension))); + util::toHex(extension, sizeof(extension))); uint32_t infoHashLength; in.read(reinterpret_cast(&infoHashLength), sizeof(infoHashLength)); @@ -259,7 +259,7 @@ void DefaultBtProgressInfoFileTest::testSave() unsigned char infoHashRead[20]; in.read((char*)infoHashRead, sizeof(infoHashRead)); CPPUNIT_ASSERT_EQUAL(std::string("112233445566778899aabbccddeeff00ffffffff"), - Util::toHex(infoHashRead, sizeof(infoHashRead))); + util::toHex(infoHashRead, sizeof(infoHashRead))); uint32_t pieceLength; in.read((char*)&pieceLength, sizeof(pieceLength)); @@ -284,7 +284,7 @@ void DefaultBtProgressInfoFileTest::testSave() unsigned char bitfieldRead[10]; in.read((char*)bitfieldRead, sizeof(bitfieldRead)); CPPUNIT_ASSERT_EQUAL(std::string("fffffffffffffffffffe"), - Util::toHex(bitfieldRead, sizeof(bitfieldRead))); + util::toHex(bitfieldRead, sizeof(bitfieldRead))); uint32_t numInFlightPiece; in.read((char*)&numInFlightPiece, sizeof(numInFlightPiece)); @@ -310,7 +310,7 @@ void DefaultBtProgressInfoFileTest::testSave() unsigned char pieceBitfield1[1]; in.read((char*)pieceBitfield1, sizeof(pieceBitfield1)); CPPUNIT_ASSERT_EQUAL(std::string("00"), - Util::toHex(pieceBitfield1, sizeof(pieceBitfield1))); + util::toHex(pieceBitfield1, sizeof(pieceBitfield1))); // piece index 2 uint32_t index2; @@ -349,7 +349,7 @@ void DefaultBtProgressInfoFileTest::testLoad_nonBt_compat() // bitfield CPPUNIT_ASSERT_EQUAL(std::string("fffffffffffffffffffe"), - Util::toHex(_bitfield->getBitfield(), + util::toHex(_bitfield->getBitfield(), _bitfield->getBitfieldLength())); // the number of in-flight pieces @@ -364,7 +364,7 @@ void DefaultBtProgressInfoFileTest::testLoad_nonBt_compat() CPPUNIT_ASSERT_EQUAL((size_t)1, piece1->getIndex()); CPPUNIT_ASSERT_EQUAL((size_t)1024, piece1->getLength()); CPPUNIT_ASSERT_EQUAL((size_t)1, piece1->getBitfieldLength()); - CPPUNIT_ASSERT_EQUAL(std::string("00"), Util::toHex(piece1->getBitfield(), + CPPUNIT_ASSERT_EQUAL(std::string("00"), util::toHex(piece1->getBitfield(), piece1->getBitfieldLength())); // piece index 2 @@ -394,7 +394,7 @@ void DefaultBtProgressInfoFileTest::testLoad_nonBt() // bitfield CPPUNIT_ASSERT_EQUAL(std::string("fffffffffffffffffffe"), - Util::toHex(_bitfield->getBitfield(), + util::toHex(_bitfield->getBitfield(), _bitfield->getBitfieldLength())); // the number of in-flight pieces @@ -409,7 +409,7 @@ void DefaultBtProgressInfoFileTest::testLoad_nonBt() CPPUNIT_ASSERT_EQUAL((size_t)1, piece1->getIndex()); CPPUNIT_ASSERT_EQUAL((size_t)1024, piece1->getLength()); CPPUNIT_ASSERT_EQUAL((size_t)1, piece1->getBitfieldLength()); - CPPUNIT_ASSERT_EQUAL(std::string("00"), Util::toHex(piece1->getBitfield(), + CPPUNIT_ASSERT_EQUAL(std::string("00"), util::toHex(piece1->getBitfield(), piece1->getBitfieldLength())); // piece index 2 @@ -436,7 +436,7 @@ void DefaultBtProgressInfoFileTest::testLoad_nonBt_pieceLengthShorter() // bitfield CPPUNIT_ASSERT_EQUAL(std::string("fffffffffffffffffffffffffffffffffffffffc"), - Util::toHex(_bitfield->getBitfield(), + util::toHex(_bitfield->getBitfield(), _bitfield->getBitfieldLength())); // the number of in-flight pieces @@ -477,12 +477,12 @@ void DefaultBtProgressInfoFileTest::testSave_nonBt() unsigned char version[2]; in.read((char*)version, sizeof(version)); CPPUNIT_ASSERT_EQUAL(std::string("0001"), - Util::toHex(version, sizeof(version))); + util::toHex(version, sizeof(version))); unsigned char extension[4]; in.read((char*)extension, sizeof(extension)); CPPUNIT_ASSERT_EQUAL(std::string("00000000"), - Util::toHex(extension, sizeof(extension))); + util::toHex(extension, sizeof(extension))); uint32_t infoHashLength; in.read(reinterpret_cast(&infoHashLength), sizeof(infoHashLength)); @@ -512,7 +512,7 @@ void DefaultBtProgressInfoFileTest::testSave_nonBt() unsigned char bitfieldRead[10]; in.read((char*)bitfieldRead, sizeof(bitfieldRead)); CPPUNIT_ASSERT_EQUAL(std::string("fffffffffffffffffffe"), - Util::toHex(bitfieldRead, sizeof(bitfieldRead))); + util::toHex(bitfieldRead, sizeof(bitfieldRead))); uint32_t numInFlightPiece; in.read((char*)&numInFlightPiece, sizeof(numInFlightPiece)); @@ -538,7 +538,7 @@ void DefaultBtProgressInfoFileTest::testSave_nonBt() unsigned char pieceBitfield1[1]; in.read((char*)pieceBitfield1, sizeof(pieceBitfield1)); CPPUNIT_ASSERT_EQUAL(std::string("00"), - Util::toHex(pieceBitfield1, sizeof(pieceBitfield1))); + util::toHex(pieceBitfield1, sizeof(pieceBitfield1))); // piece index 2 uint32_t index2; diff --git a/test/FeatureConfigTest.cc b/test/FeatureConfigTest.cc index b848735b..c2feb3a8 100644 --- a/test/FeatureConfigTest.cc +++ b/test/FeatureConfigTest.cc @@ -91,8 +91,8 @@ void FeatureConfigTest::testFeatureSummary() { const std::string delim(", "); std::for_each(&features[0], &features[arrayLength(features)], StringAppend(featuresString, delim)); - // USE Util::trimSelf(featureString); - featuresString = Util::trim(featuresString, delim); + // USE util::trimSelf(featureString); + featuresString = util::trim(featuresString, delim); CPPUNIT_ASSERT_EQUAL(featuresString, FeatureConfig::getInstance()->featureSummary()); diff --git a/test/HttpRequestTest.cc b/test/HttpRequestTest.cc index de65245c..99d3e6aa 100644 --- a/test/HttpRequestTest.cc +++ b/test/HttpRequestTest.cc @@ -490,7 +490,7 @@ void HttpRequestTest::testCreateRequest_head() std::stringstream result(httpRequest.createRequest()); std::string line; CPPUNIT_ASSERT(getline(result, line)); - Util::trimSelf(line); + util::trimSelf(line); CPPUNIT_ASSERT_EQUAL(std::string("HEAD /aria2-1.0.0.tar.bz2 HTTP/1.1"), line); } diff --git a/test/Sqlite3MozCookieParserTest.cc b/test/Sqlite3MozCookieParserTest.cc index afb446ec..b0d528c2 100644 --- a/test/Sqlite3MozCookieParserTest.cc +++ b/test/Sqlite3MozCookieParserTest.cc @@ -71,7 +71,7 @@ void Sqlite3MozCookieParserTest::testParse_fileNotFound() CPPUNIT_FAIL("exception must be thrown."); } catch(RecoverableException& e) { // SUCCESS - CPPUNIT_ASSERT(Util::startsWith(e.what(), + CPPUNIT_ASSERT(util::startsWith(e.what(), "Failed to open SQLite3 database:")); } } diff --git a/test/TimeSeedCriteriaTest.cc b/test/TimeSeedCriteriaTest.cc index 5ee8653a..1653f6f6 100644 --- a/test/TimeSeedCriteriaTest.cc +++ b/test/TimeSeedCriteriaTest.cc @@ -22,7 +22,7 @@ CPPUNIT_TEST_SUITE_REGISTRATION(TimeSeedCriteriaTest); void TimeSeedCriteriaTest::testEvaluate() { TimeSeedCriteria cri(1); // Seel 2seconds. 1 seconds are not enough in some systems. - Util::sleep(2); + util::sleep(2); CPPUNIT_ASSERT(cri.evaluate()); cri.reset(); cri.setDuration(10); diff --git a/test/UTPexExtensionMessageTest.cc b/test/UTPexExtensionMessageTest.cc index 8c26caba..e4085bd0 100644 --- a/test/UTPexExtensionMessageTest.cc +++ b/test/UTPexExtensionMessageTest.cc @@ -94,8 +94,8 @@ void UTPexExtensionMessageTest::testGetBencodedData() std::string(&c3[0], &c3[6])+std::string(&c4[0], &c4[6])+ "e"; std::string bd = msg.getBencodedData(); - CPPUNIT_ASSERT_EQUAL(Util::urlencode(expected), - Util::urlencode(bd)); + CPPUNIT_ASSERT_EQUAL(util::urlencode(expected), + util::urlencode(bd)); } void UTPexExtensionMessageTest::testToString() diff --git a/test/UriListParserTest.cc b/test/UriListParserTest.cc index 97fe926c..4ad0f16e 100644 --- a/test/UriListParserTest.cc +++ b/test/UriListParserTest.cc @@ -36,7 +36,7 @@ std::string UriListParserTest::list2String(const std::deque& src) { std::ostringstream strm; std::copy(src.begin(), src.end(), std::ostream_iterator(strm, " ")); - return Util::trim(strm.str()); + return util::trim(strm.str()); } void UriListParserTest::testHasNext() diff --git a/test/UtilTest.cc b/test/UtilTest.cc index 46d73f5b..d0e1eede 100644 --- a/test/UtilTest.cc +++ b/test/UtilTest.cc @@ -107,46 +107,46 @@ CPPUNIT_TEST_SUITE_REGISTRATION( UtilTest ); void UtilTest::testTrim() { std::string str1 = "aria2"; - CPPUNIT_ASSERT_EQUAL(str1, Util::trim("aria2")); - CPPUNIT_ASSERT_EQUAL(str1, Util::trim(" aria2")); - CPPUNIT_ASSERT_EQUAL(str1, Util::trim(" aria2 ")); - CPPUNIT_ASSERT_EQUAL(str1, Util::trim(" aria2 ")); + CPPUNIT_ASSERT_EQUAL(str1, util::trim("aria2")); + CPPUNIT_ASSERT_EQUAL(str1, util::trim(" aria2")); + CPPUNIT_ASSERT_EQUAL(str1, util::trim(" aria2 ")); + CPPUNIT_ASSERT_EQUAL(str1, util::trim(" aria2 ")); std::string str2 = "aria2 debut"; - CPPUNIT_ASSERT_EQUAL(str2, Util::trim("aria2 debut")); - CPPUNIT_ASSERT_EQUAL(str2, Util::trim(" aria2 debut ")); + CPPUNIT_ASSERT_EQUAL(str2, util::trim("aria2 debut")); + CPPUNIT_ASSERT_EQUAL(str2, util::trim(" aria2 debut ")); std::string str3 = ""; - CPPUNIT_ASSERT_EQUAL(str3, Util::trim("")); - CPPUNIT_ASSERT_EQUAL(str3, Util::trim(" ")); - CPPUNIT_ASSERT_EQUAL(str3, Util::trim(" ")); + CPPUNIT_ASSERT_EQUAL(str3, util::trim("")); + CPPUNIT_ASSERT_EQUAL(str3, util::trim(" ")); + CPPUNIT_ASSERT_EQUAL(str3, util::trim(" ")); std::string str4 = "A"; - CPPUNIT_ASSERT_EQUAL(str4, Util::trim("A")); - CPPUNIT_ASSERT_EQUAL(str4, Util::trim(" A ")); - CPPUNIT_ASSERT_EQUAL(str4, Util::trim(" A ")); + CPPUNIT_ASSERT_EQUAL(str4, util::trim("A")); + CPPUNIT_ASSERT_EQUAL(str4, util::trim(" A ")); + CPPUNIT_ASSERT_EQUAL(str4, util::trim(" A ")); } void UtilTest::testSplit() { std::pair p1; - Util::split(p1, "name=value", '='); + util::split(p1, "name=value", '='); CPPUNIT_ASSERT_EQUAL(std::string("name"), p1.first); CPPUNIT_ASSERT_EQUAL(std::string("value"), p1.second); - Util::split(p1, " name = value ", '='); + util::split(p1, " name = value ", '='); CPPUNIT_ASSERT_EQUAL(std::string("name"), p1.first); CPPUNIT_ASSERT_EQUAL(std::string("value"), p1.second); - Util::split(p1, "=value", '='); + util::split(p1, "=value", '='); CPPUNIT_ASSERT_EQUAL(std::string(""), p1.first); CPPUNIT_ASSERT_EQUAL(std::string("value"), p1.second); - Util::split(p1, "name=", '='); + util::split(p1, "name=", '='); CPPUNIT_ASSERT_EQUAL(std::string("name"), p1.first); CPPUNIT_ASSERT_EQUAL(std::string(""), p1.second); - Util::split(p1, "name", '='); + util::split(p1, "name", '='); CPPUNIT_ASSERT_EQUAL(std::string("name"), p1.first); CPPUNIT_ASSERT_EQUAL(std::string(""), p1.second); } void UtilTest::testSplit_many() { std::deque v1; - split("name1=value1; name2=value2; name3=value3", std::back_inserter(v1), - ";", true); + util::split("name1=value1; name2=value2; name3=value3",std::back_inserter(v1), + ";", true); CPPUNIT_ASSERT_EQUAL(3, (int)v1.size()); std::deque::iterator itr = v1.begin(); CPPUNIT_ASSERT_EQUAL(std::string("name1=value1"), *itr++); @@ -155,8 +155,8 @@ void UtilTest::testSplit_many() { v1.clear(); - split("name1=value1; name2=value2; name3=value3", std::back_inserter(v1), - ";", false); + util::split("name1=value1; name2=value2; name3=value3",std::back_inserter(v1), + ";", false); CPPUNIT_ASSERT_EQUAL(3, (int)v1.size()); itr = v1.begin(); CPPUNIT_ASSERT_EQUAL(std::string("name1=value1"), *itr++); @@ -167,43 +167,43 @@ void UtilTest::testSplit_many() { void UtilTest::testEndsWith() { std::string target = "abcdefg"; std::string part = "fg"; - CPPUNIT_ASSERT(Util::endsWith(target, part)); + CPPUNIT_ASSERT(util::endsWith(target, part)); target = "abdefg"; part = "g"; - CPPUNIT_ASSERT(Util::endsWith(target, part)); + CPPUNIT_ASSERT(util::endsWith(target, part)); target = "abdefg"; part = "eg"; - CPPUNIT_ASSERT(!Util::endsWith(target, part)); + CPPUNIT_ASSERT(!util::endsWith(target, part)); target = "g"; part = "eg"; - CPPUNIT_ASSERT(!Util::endsWith(target, part)); + CPPUNIT_ASSERT(!util::endsWith(target, part)); target = "g"; part = "g"; - CPPUNIT_ASSERT(Util::endsWith(target, part)); + CPPUNIT_ASSERT(util::endsWith(target, part)); target = "g"; part = ""; - CPPUNIT_ASSERT(Util::endsWith(target, part)); + CPPUNIT_ASSERT(util::endsWith(target, part)); target = ""; part = ""; - CPPUNIT_ASSERT(Util::endsWith(target, part)); + CPPUNIT_ASSERT(util::endsWith(target, part)); target = ""; part = "g"; - CPPUNIT_ASSERT(!Util::endsWith(target, part)); + CPPUNIT_ASSERT(!util::endsWith(target, part)); } void UtilTest::testReplace() { - CPPUNIT_ASSERT_EQUAL(std::string("abc\n"), Util::replace("abc\r\n", "\r", "")); - CPPUNIT_ASSERT_EQUAL(std::string("abc"), Util::replace("abc\r\n", "\r\n", "")); - CPPUNIT_ASSERT_EQUAL(std::string(""), Util::replace("", "\r\n", "")); - CPPUNIT_ASSERT_EQUAL(std::string("abc"), Util::replace("abc", "", "a")); - CPPUNIT_ASSERT_EQUAL(std::string("xbc"), Util::replace("abc", "a", "x")); + CPPUNIT_ASSERT_EQUAL(std::string("abc\n"), util::replace("abc\r\n", "\r", "")); + CPPUNIT_ASSERT_EQUAL(std::string("abc"), util::replace("abc\r\n", "\r\n", "")); + CPPUNIT_ASSERT_EQUAL(std::string(""), util::replace("", "\r\n", "")); + CPPUNIT_ASSERT_EQUAL(std::string("abc"), util::replace("abc", "", "a")); + CPPUNIT_ASSERT_EQUAL(std::string("xbc"), util::replace("abc", "a", "x")); } void UtilTest::testStartsWith() { @@ -212,79 +212,79 @@ void UtilTest::testStartsWith() { target = "abcdefg"; part = "abc"; - CPPUNIT_ASSERT(Util::startsWith(target, part)); + CPPUNIT_ASSERT(util::startsWith(target, part)); target = "abcdefg"; part = "abx"; - CPPUNIT_ASSERT(!Util::startsWith(target, part)); + CPPUNIT_ASSERT(!util::startsWith(target, part)); target = "abcdefg"; part = "bcd"; - CPPUNIT_ASSERT(!Util::startsWith(target, part)); + CPPUNIT_ASSERT(!util::startsWith(target, part)); target = ""; part = "a"; - CPPUNIT_ASSERT(!Util::startsWith(target, part)); + CPPUNIT_ASSERT(!util::startsWith(target, part)); target = ""; part = ""; - CPPUNIT_ASSERT(Util::startsWith(target, part)); + CPPUNIT_ASSERT(util::startsWith(target, part)); target = "a"; part = ""; - CPPUNIT_ASSERT(Util::startsWith(target, part)); + CPPUNIT_ASSERT(util::startsWith(target, part)); target = "a"; part = "a"; - CPPUNIT_ASSERT(Util::startsWith(target, part)); + CPPUNIT_ASSERT(util::startsWith(target, part)); } void UtilTest::testGetContentDispositionFilename() { std::string h1 = "attachment; filename=\"aria2.tar.bz2\""; - CPPUNIT_ASSERT_EQUAL(std::string("aria2.tar.bz2"), Util::getContentDispositionFilename(h1)); + CPPUNIT_ASSERT_EQUAL(std::string("aria2.tar.bz2"), util::getContentDispositionFilename(h1)); std::string h2 = "attachment; filename=\"\""; - CPPUNIT_ASSERT_EQUAL(std::string(""), Util::getContentDispositionFilename(h2)); + CPPUNIT_ASSERT_EQUAL(std::string(""), util::getContentDispositionFilename(h2)); std::string h3 = "attachment; filename=\""; - CPPUNIT_ASSERT_EQUAL(std::string(""), Util::getContentDispositionFilename(h3)); + CPPUNIT_ASSERT_EQUAL(std::string(""), util::getContentDispositionFilename(h3)); std::string h4 = "attachment;"; - CPPUNIT_ASSERT_EQUAL(std::string(""), Util::getContentDispositionFilename(h4)); + CPPUNIT_ASSERT_EQUAL(std::string(""), util::getContentDispositionFilename(h4)); std::string h5 = "attachment; filename=aria2.tar.bz2"; - CPPUNIT_ASSERT_EQUAL(std::string("aria2.tar.bz2"), Util::getContentDispositionFilename(h5)); + CPPUNIT_ASSERT_EQUAL(std::string("aria2.tar.bz2"), util::getContentDispositionFilename(h5)); std::string h6 = "attachment; filename='aria2.tar.bz2'"; - CPPUNIT_ASSERT_EQUAL(std::string("aria2.tar.bz2"), Util::getContentDispositionFilename(h6)); + CPPUNIT_ASSERT_EQUAL(std::string("aria2.tar.bz2"), util::getContentDispositionFilename(h6)); std::string h7 = "attachment; filename='aria2.tar.bz2"; - CPPUNIT_ASSERT_EQUAL(std::string("aria2.tar.bz2"), Util::getContentDispositionFilename(h7)); + CPPUNIT_ASSERT_EQUAL(std::string("aria2.tar.bz2"), util::getContentDispositionFilename(h7)); std::string h8 = "attachment; filename=aria2.tar.bz2; creation-date=20 Jun 2007 00:00:00 GMT"; - CPPUNIT_ASSERT_EQUAL(std::string("aria2.tar.bz2"), Util::getContentDispositionFilename(h8)); + CPPUNIT_ASSERT_EQUAL(std::string("aria2.tar.bz2"), util::getContentDispositionFilename(h8)); std::string h9 = "attachment; filename=\"aria2.tar.bz2; creation-date=20 Jun 2007 00:00:00 GMT\""; - CPPUNIT_ASSERT_EQUAL(std::string("aria2.tar.bz2; creation-date=20 Jun 2007 00:00:00 GMT"), Util::getContentDispositionFilename(h9)); + CPPUNIT_ASSERT_EQUAL(std::string("aria2.tar.bz2; creation-date=20 Jun 2007 00:00:00 GMT"), util::getContentDispositionFilename(h9)); std::string h10 = "attachment; filename="; - CPPUNIT_ASSERT_EQUAL(std::string(""), Util::getContentDispositionFilename(h10)); + CPPUNIT_ASSERT_EQUAL(std::string(""), util::getContentDispositionFilename(h10)); std::string h11 = "attachment; filename=;"; - CPPUNIT_ASSERT_EQUAL(std::string(""), Util::getContentDispositionFilename(h11)); + CPPUNIT_ASSERT_EQUAL(std::string(""), util::getContentDispositionFilename(h11)); std::string filenameWithDir = "attachment; filename=dir/file"; CPPUNIT_ASSERT_EQUAL(std::string("file"), - Util::getContentDispositionFilename(filenameWithDir)); + util::getContentDispositionFilename(filenameWithDir)); std::string parentDir = "attachment; filename=.."; CPPUNIT_ASSERT_EQUAL(std::string(), - Util::getContentDispositionFilename(parentDir)); + util::getContentDispositionFilename(parentDir)); std::string currentDir = "attachment; filename=."; CPPUNIT_ASSERT_EQUAL(std::string(), - Util::getContentDispositionFilename(currentDir)); + util::getContentDispositionFilename(currentDir)); } class Printer { @@ -297,7 +297,7 @@ public: void UtilTest::testRandomAlpha() { SharedHandle rand(new FixedNumberRandomizer()); - std::string s = Util::randomAlpha(8, rand); + std::string s = util::randomAlpha(8, rand); CPPUNIT_ASSERT_EQUAL(std::string("AAAAAAAA"), s); } @@ -305,67 +305,67 @@ void UtilTest::testToUpper() { std::string src = "608cabc0f2fa18c260cafd974516865c772363d5"; std::string upp = "608CABC0F2FA18C260CAFD974516865C772363D5"; - CPPUNIT_ASSERT_EQUAL(upp, Util::toUpper(src)); + CPPUNIT_ASSERT_EQUAL(upp, util::toUpper(src)); } void UtilTest::testToLower() { std::string src = "608CABC0F2FA18C260CAFD974516865C772363D5"; std::string upp = "608cabc0f2fa18c260cafd974516865c772363d5"; - CPPUNIT_ASSERT_EQUAL(upp, Util::toLower(src)); + CPPUNIT_ASSERT_EQUAL(upp, util::toLower(src)); } void UtilTest::testUrldecode() { std::string src = "http://aria2.sourceforge.net/aria2%200.7.0%20docs.html"; CPPUNIT_ASSERT_EQUAL(std::string("http://aria2.sourceforge.net/aria2 0.7.0 docs.html"), - Util::urldecode(src)); + util::urldecode(src)); std::string src2 = "aria2+aria2"; - CPPUNIT_ASSERT_EQUAL(std::string("aria2+aria2"), Util::urldecode(src2)); + CPPUNIT_ASSERT_EQUAL(std::string("aria2+aria2"), util::urldecode(src2)); std::string src3 = "%5t%20"; - CPPUNIT_ASSERT_EQUAL(std::string("%5t "), Util::urldecode(src3)); + CPPUNIT_ASSERT_EQUAL(std::string("%5t "), util::urldecode(src3)); std::string src4 = "%"; - CPPUNIT_ASSERT_EQUAL(std::string("%"), Util::urldecode(src4)); + CPPUNIT_ASSERT_EQUAL(std::string("%"), util::urldecode(src4)); std::string src5 = "%3"; - CPPUNIT_ASSERT_EQUAL(std::string("%3"), Util::urldecode(src5)); + CPPUNIT_ASSERT_EQUAL(std::string("%3"), util::urldecode(src5)); std::string src6 = "%2f"; - CPPUNIT_ASSERT_EQUAL(std::string("/"), Util::urldecode(src6)); + CPPUNIT_ASSERT_EQUAL(std::string("/"), util::urldecode(src6)); } void UtilTest::testGetRealSize() { - CPPUNIT_ASSERT_EQUAL((int64_t)4294967296LL, Util::getRealSize("4096M")); - CPPUNIT_ASSERT_EQUAL((int64_t)1024, Util::getRealSize("1K")); + CPPUNIT_ASSERT_EQUAL((int64_t)4294967296LL, util::getRealSize("4096M")); + CPPUNIT_ASSERT_EQUAL((int64_t)1024, util::getRealSize("1K")); try { - Util::getRealSize(""); + util::getRealSize(""); CPPUNIT_FAIL("exception must be thrown."); } catch(Exception& e) { std::cerr << e.stackTrace(); } try { - Util::getRealSize("foo"); + util::getRealSize("foo"); CPPUNIT_FAIL("exception must be thrown."); } catch(Exception& e) { std::cerr << e.stackTrace(); } try { - Util::getRealSize("-1"); + util::getRealSize("-1"); CPPUNIT_FAIL("exception must be thrown."); } catch(Exception& e) { std::cerr << e.stackTrace(); } try { - Util::getRealSize("9223372036854775807K"); + util::getRealSize("9223372036854775807K"); CPPUNIT_FAIL("exception must be thrown."); } catch(Exception& e) { std::cerr << e.stackTrace(); } try { - Util::getRealSize("9223372036854775807M"); + util::getRealSize("9223372036854775807M"); CPPUNIT_FAIL("exception must be thrown."); } catch(Exception& e) { std::cerr << e.stackTrace(); @@ -374,12 +374,12 @@ void UtilTest::testGetRealSize() void UtilTest::testAbbrevSize() { - CPPUNIT_ASSERT_EQUAL(std::string("4,096.0Mi"), Util::abbrevSize(4294967296LL)); - CPPUNIT_ASSERT_EQUAL(std::string("1.0Ki"), Util::abbrevSize(1024)); - CPPUNIT_ASSERT_EQUAL(std::string("1,023"), Util::abbrevSize(1023)); - CPPUNIT_ASSERT_EQUAL(std::string("0"), Util::abbrevSize(0)); - CPPUNIT_ASSERT_EQUAL(std::string("1.1Ki"), Util::abbrevSize(1127)); - CPPUNIT_ASSERT_EQUAL(std::string("1.5Mi"), Util::abbrevSize(1572864)); + CPPUNIT_ASSERT_EQUAL(std::string("4,096.0Mi"), util::abbrevSize(4294967296LL)); + CPPUNIT_ASSERT_EQUAL(std::string("1.0Ki"), util::abbrevSize(1024)); + CPPUNIT_ASSERT_EQUAL(std::string("1,023"), util::abbrevSize(1023)); + CPPUNIT_ASSERT_EQUAL(std::string("0"), util::abbrevSize(0)); + CPPUNIT_ASSERT_EQUAL(std::string("1.1Ki"), util::abbrevSize(1127)); + CPPUNIT_ASSERT_EQUAL(std::string("1.5Mi"), util::abbrevSize(1572864)); } @@ -391,7 +391,7 @@ void UtilTest::testToStream() std::deque > entries; entries.push_back(f1); entries.push_back(f2); - Util::toStream(entries.begin(), entries.end(), os); + util::toStream(entries.begin(), entries.end(), os); CPPUNIT_ASSERT_EQUAL( std::string("Files:\n" "idx|path/length\n" @@ -407,41 +407,41 @@ void UtilTest::testToStream() void UtilTest::testIsNumber() { - CPPUNIT_ASSERT_EQUAL(true, Util::isNumber("000")); - CPPUNIT_ASSERT_EQUAL(false, Util::isNumber("a")); - CPPUNIT_ASSERT_EQUAL(false, Util::isNumber("0a")); - CPPUNIT_ASSERT_EQUAL(false, Util::isNumber("")); - CPPUNIT_ASSERT_EQUAL(false, Util::isNumber(" ")); + CPPUNIT_ASSERT_EQUAL(true, util::isNumber("000")); + CPPUNIT_ASSERT_EQUAL(false, util::isNumber("a")); + CPPUNIT_ASSERT_EQUAL(false, util::isNumber("0a")); + CPPUNIT_ASSERT_EQUAL(false, util::isNumber("")); + CPPUNIT_ASSERT_EQUAL(false, util::isNumber(" ")); } void UtilTest::testIsLowercase() { - CPPUNIT_ASSERT_EQUAL(true, Util::isLowercase("alpha")); - CPPUNIT_ASSERT_EQUAL(false, Util::isLowercase("Alpha")); - CPPUNIT_ASSERT_EQUAL(false, Util::isLowercase("1alpha")); - CPPUNIT_ASSERT_EQUAL(false, Util::isLowercase("")); - CPPUNIT_ASSERT_EQUAL(false, Util::isLowercase(" ")); + CPPUNIT_ASSERT_EQUAL(true, util::isLowercase("alpha")); + CPPUNIT_ASSERT_EQUAL(false, util::isLowercase("Alpha")); + CPPUNIT_ASSERT_EQUAL(false, util::isLowercase("1alpha")); + CPPUNIT_ASSERT_EQUAL(false, util::isLowercase("")); + CPPUNIT_ASSERT_EQUAL(false, util::isLowercase(" ")); } void UtilTest::testIsUppercase() { - CPPUNIT_ASSERT_EQUAL(true, Util::isUppercase("ALPHA")); - CPPUNIT_ASSERT_EQUAL(false, Util::isUppercase("Alpha")); - CPPUNIT_ASSERT_EQUAL(false, Util::isUppercase("1ALPHA")); - CPPUNIT_ASSERT_EQUAL(false, Util::isUppercase("")); - CPPUNIT_ASSERT_EQUAL(false, Util::isUppercase(" ")); + CPPUNIT_ASSERT_EQUAL(true, util::isUppercase("ALPHA")); + CPPUNIT_ASSERT_EQUAL(false, util::isUppercase("Alpha")); + CPPUNIT_ASSERT_EQUAL(false, util::isUppercase("1ALPHA")); + CPPUNIT_ASSERT_EQUAL(false, util::isUppercase("")); + CPPUNIT_ASSERT_EQUAL(false, util::isUppercase(" ")); } void UtilTest::testAlphaToNum() { - CPPUNIT_ASSERT_EQUAL(0U, Util::alphaToNum("a")); - CPPUNIT_ASSERT_EQUAL(0U, Util::alphaToNum("aa")); - CPPUNIT_ASSERT_EQUAL(1U, Util::alphaToNum("b")); - CPPUNIT_ASSERT_EQUAL(675U, Util::alphaToNum("zz")); // 25*26+25 - CPPUNIT_ASSERT_EQUAL(675U, Util::alphaToNum("ZZ")); // 25*26+25 - CPPUNIT_ASSERT_EQUAL(0U, Util::alphaToNum("")); - CPPUNIT_ASSERT_EQUAL(4294967295U, Util::alphaToNum("NXMRLXV")); - CPPUNIT_ASSERT_EQUAL(0U, Util::alphaToNum("NXMRLXW")); // uint32_t overflow + CPPUNIT_ASSERT_EQUAL(0U, util::alphaToNum("a")); + CPPUNIT_ASSERT_EQUAL(0U, util::alphaToNum("aa")); + CPPUNIT_ASSERT_EQUAL(1U, util::alphaToNum("b")); + CPPUNIT_ASSERT_EQUAL(675U, util::alphaToNum("zz")); // 25*26+25 + CPPUNIT_ASSERT_EQUAL(675U, util::alphaToNum("ZZ")); // 25*26+25 + CPPUNIT_ASSERT_EQUAL(0U, util::alphaToNum("")); + CPPUNIT_ASSERT_EQUAL(4294967295U, util::alphaToNum("NXMRLXV")); + CPPUNIT_ASSERT_EQUAL(0U, util::alphaToNum("NXMRLXW")); // uint32_t overflow } void UtilTest::testMkdirs() @@ -452,14 +452,14 @@ void UtilTest::testMkdirs() CPPUNIT_ASSERT(d.remove()); } CPPUNIT_ASSERT(!d.exists()); - Util::mkdirs(dir); + util::mkdirs(dir); CPPUNIT_ASSERT(d.isDir()); std::string file = "./UtilTest.cc"; File f(file); CPPUNIT_ASSERT(f.isFile()); try { - Util::mkdirs(file); + util::mkdirs(file); CPPUNIT_FAIL("exception must be thrown."); } catch(DlAbortEx& ex) { std::cerr << ex.stackTrace() << std::endl; @@ -473,16 +473,16 @@ void UtilTest::testConvertBitfield() srcBitfield.setAllBit(); srcBitfield.unsetBit(2);// <- range [768, 1152) // which corresponds to the index [1,2] in destBitfield - Util::convertBitfield(&destBitfield, &srcBitfield); + util::convertBitfield(&destBitfield, &srcBitfield); CPPUNIT_ASSERT_EQUAL(std::string("9fffffffffffffffffffffffffffffff80"), - Util::toHex(destBitfield.getBitfield(), + util::toHex(destBitfield.getBitfield(), destBitfield.getBitfieldLength())); } void UtilTest::testParseIntRange() { - IntSequence seq = Util::parseIntRange("1,3-8,10"); + IntSequence seq = util::parseIntRange("1,3-8,10"); CPPUNIT_ASSERT(seq.hasNext()); CPPUNIT_ASSERT_EQUAL((int32_t)1, seq.next()); @@ -507,31 +507,31 @@ void UtilTest::testParseIntRange() void UtilTest::testParseIntRange_invalidRange() { try { - IntSequence seq = Util::parseIntRange("-1"); + IntSequence seq = util::parseIntRange("-1"); CPPUNIT_FAIL("exception must be thrown."); } catch(Exception& e) { std::cerr << e.stackTrace(); } try { - IntSequence seq = Util::parseIntRange("2147483648"); + IntSequence seq = util::parseIntRange("2147483648"); CPPUNIT_FAIL("exception must be thrown."); } catch(Exception& e) { std::cerr << e.stackTrace(); } try { - IntSequence seq = Util::parseIntRange("2147483647-2147483648"); + IntSequence seq = util::parseIntRange("2147483647-2147483648"); CPPUNIT_FAIL("exception must be thrown."); } catch(Exception& e) { std::cerr << e.stackTrace(); } try { - IntSequence seq = Util::parseIntRange("1-2x"); + IntSequence seq = util::parseIntRange("1-2x"); CPPUNIT_FAIL("exception must be thrown."); } catch(Exception& e) { std::cerr << e.stackTrace(); } try { - IntSequence seq = Util::parseIntRange("3x-4"); + IntSequence seq = util::parseIntRange("3x-4"); CPPUNIT_FAIL("exception must be thrown."); } catch(Exception& e) { std::cerr << e.stackTrace(); @@ -540,28 +540,28 @@ void UtilTest::testParseIntRange_invalidRange() void UtilTest::testParseInt() { - CPPUNIT_ASSERT_EQUAL(-1, Util::parseInt(" -1 ")); - CPPUNIT_ASSERT_EQUAL(2147483647, Util::parseInt("2147483647")); + CPPUNIT_ASSERT_EQUAL(-1, util::parseInt(" -1 ")); + CPPUNIT_ASSERT_EQUAL(2147483647, util::parseInt("2147483647")); try { - Util::parseInt("2147483648"); + util::parseInt("2147483648"); CPPUNIT_FAIL("exception must be thrown."); } catch(Exception& e) { std::cerr << e.stackTrace(); } try { - Util::parseInt("-2147483649"); + util::parseInt("-2147483649"); CPPUNIT_FAIL("exception must be thrown."); } catch(Exception& e) { std::cerr << e.stackTrace(); } try { - Util::parseInt("12x"); + util::parseInt("12x"); CPPUNIT_FAIL("exception must be thrown."); } catch(Exception& e) { std::cerr << e.stackTrace(); } try { - Util::parseInt(""); + util::parseInt(""); CPPUNIT_FAIL("exception must be thrown."); } catch(Exception& e) { std::cerr << e.stackTrace(); @@ -570,15 +570,15 @@ void UtilTest::testParseInt() void UtilTest::testParseUInt() { - CPPUNIT_ASSERT_EQUAL(4294967295U, Util::parseUInt(" 4294967295 ")); + CPPUNIT_ASSERT_EQUAL(4294967295U, util::parseUInt(" 4294967295 ")); try { - Util::parseUInt("-1"); + util::parseUInt("-1"); CPPUNIT_FAIL("exception must be thrown."); } catch(Exception& e) { std::cerr << e.stackTrace(); } try { - Util::parseUInt("4294967296"); + util::parseUInt("4294967296"); CPPUNIT_FAIL("exception must be thrown."); } catch(Exception& e) { std::cerr << e.stackTrace(); @@ -587,29 +587,29 @@ void UtilTest::testParseUInt() void UtilTest::testParseLLInt() { - CPPUNIT_ASSERT_EQUAL((int64_t)-1LL, Util::parseLLInt(" -1 ")); + CPPUNIT_ASSERT_EQUAL((int64_t)-1LL, util::parseLLInt(" -1 ")); CPPUNIT_ASSERT_EQUAL((int64_t)9223372036854775807LL, - Util::parseLLInt("9223372036854775807")); + util::parseLLInt("9223372036854775807")); try { - Util::parseLLInt("9223372036854775808"); + util::parseLLInt("9223372036854775808"); CPPUNIT_FAIL("exception must be thrown."); } catch(Exception& e) { std::cerr << e.stackTrace(); } try { - Util::parseLLInt("-9223372036854775809"); + util::parseLLInt("-9223372036854775809"); CPPUNIT_FAIL("exception must be thrown."); } catch(Exception& e) { std::cerr << e.stackTrace(); } try { - Util::parseLLInt("12x"); + util::parseLLInt("12x"); CPPUNIT_FAIL("exception must be thrown."); } catch(Exception& e) { std::cerr << e.stackTrace(); } try { - Util::parseLLInt(""); + util::parseLLInt(""); CPPUNIT_FAIL("exception must be thrown."); } catch(Exception& e) { std::cerr << e.stackTrace(); @@ -619,15 +619,15 @@ void UtilTest::testParseLLInt() void UtilTest::testParseULLInt() { CPPUNIT_ASSERT_EQUAL((uint64_t)18446744073709551615ULL, - Util::parseULLInt("18446744073709551615")); + util::parseULLInt("18446744073709551615")); try { - Util::parseUInt("-1"); + util::parseUInt("-1"); CPPUNIT_FAIL("exception must be thrown."); } catch(Exception& e) { std::cerr << e.stackTrace(); } try { - Util::parseLLInt("18446744073709551616"); + util::parseLLInt("18446744073709551616"); CPPUNIT_FAIL("exception must be thrown."); } catch(Exception& e) { std::cerr << e.stackTrace(); @@ -641,7 +641,7 @@ void UtilTest::testToString_binaryStream() dw->initAndOpenFile(); dw->writeData((const unsigned char*)data.c_str(), data.size(), 0); - std::string readData = Util::toString(dw); + std::string readData = util::toString(dw); CPPUNIT_ASSERT_EQUAL(data, readData); } @@ -650,31 +650,31 @@ void UtilTest::testItos() { { int i = 0; - CPPUNIT_ASSERT_EQUAL(std::string("0"), Util::itos(i)); + CPPUNIT_ASSERT_EQUAL(std::string("0"), util::itos(i)); } { int i = 100; - CPPUNIT_ASSERT_EQUAL(std::string("100"), Util::itos(i, true)); + CPPUNIT_ASSERT_EQUAL(std::string("100"), util::itos(i, true)); } { int i = 100; - CPPUNIT_ASSERT_EQUAL(std::string("100"), Util::itos(i)); + CPPUNIT_ASSERT_EQUAL(std::string("100"), util::itos(i)); } { int i = 12345; - CPPUNIT_ASSERT_EQUAL(std::string("12,345"), Util::itos(i, true)); + CPPUNIT_ASSERT_EQUAL(std::string("12,345"), util::itos(i, true)); } { int i = 12345; - CPPUNIT_ASSERT_EQUAL(std::string("12345"), Util::itos(i)); + CPPUNIT_ASSERT_EQUAL(std::string("12345"), util::itos(i)); } { int i = -12345; - CPPUNIT_ASSERT_EQUAL(std::string("-12,345"), Util::itos(i, true)); + CPPUNIT_ASSERT_EQUAL(std::string("-12,345"), util::itos(i, true)); } { int64_t i = INT64_MAX; - CPPUNIT_ASSERT_EQUAL(std::string("9,223,372,036,854,775,807"), Util::itos(i, true)); + CPPUNIT_ASSERT_EQUAL(std::string("9,223,372,036,854,775,807"), util::itos(i, true)); } } @@ -682,11 +682,11 @@ void UtilTest::testUitos() { { uint16_t i = 12345; - CPPUNIT_ASSERT_EQUAL(std::string("12345"), Util::uitos(i)); + CPPUNIT_ASSERT_EQUAL(std::string("12345"), util::uitos(i)); } { int16_t i = -12345; - CPPUNIT_ASSERT_EQUAL(std::string("/.-,+"), Util::uitos(i)); + CPPUNIT_ASSERT_EQUAL(std::string("/.-,+"), util::uitos(i)); } } @@ -707,22 +707,22 @@ void UtilTest::testUrlencode() { CPPUNIT_ASSERT_EQUAL (std::string("%3A%2F%3F%23%5B%5D%40%21%25%26%27%28%29%2A%2B%2C%3B%3D"), - Util::urlencode(":/?#[]@!%&'()*+,;=")); + util::urlencode(":/?#[]@!%&'()*+,;=")); std::string unreserved = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" "abcdefghijklmnopqrstuvwxyz" "0123456789" "-._~"; - CPPUNIT_ASSERT_EQUAL(unreserved, Util::urlencode(unreserved)); + CPPUNIT_ASSERT_EQUAL(unreserved, util::urlencode(unreserved)); - CPPUNIT_ASSERT_EQUAL(std::string("1%5EA%20"), Util::urlencode("1^A ")); + CPPUNIT_ASSERT_EQUAL(std::string("1%5EA%20"), util::urlencode("1^A ")); } void UtilTest::testHtmlEscape() { CPPUNIT_ASSERT_EQUAL(std::string("aria2<>"'util"), - Util::htmlEscape("aria2<>\"'util")); + util::htmlEscape("aria2<>\"'util")); } void UtilTest::testJoinPath() @@ -730,48 +730,48 @@ void UtilTest::testJoinPath() const std::string dir1dir2file[] = { "dir1", "dir2", "file" }; CPPUNIT_ASSERT_EQUAL (std::string("dir1/dir2/file"), - Util::joinPath(&dir1dir2file[0], + util::joinPath(&dir1dir2file[0], &dir1dir2file[arrayLength(dir1dir2file)])); const std::string dirparentfile[] = { "dir", "..", "file" }; CPPUNIT_ASSERT_EQUAL (std::string("file"), - Util::joinPath(&dirparentfile[0], + util::joinPath(&dirparentfile[0], &dirparentfile[arrayLength(dirparentfile)])); const std::string dirparentparentfile[] = { "dir", "..", "..", "file" }; CPPUNIT_ASSERT_EQUAL (std::string("file"), - Util::joinPath(&dirparentparentfile[0], + util::joinPath(&dirparentparentfile[0], &dirparentparentfile[arrayLength(dirparentparentfile)])); const std::string dirdotfile[] = { "dir", ".", "file" }; CPPUNIT_ASSERT_EQUAL(std::string("dir/file"), - Util::joinPath(&dirdotfile[0], + util::joinPath(&dirdotfile[0], &dirdotfile[arrayLength(dirdotfile)])); const std::string empty[] = {}; - CPPUNIT_ASSERT_EQUAL(std::string(""), Util::joinPath(&empty[0], &empty[0])); + CPPUNIT_ASSERT_EQUAL(std::string(""), util::joinPath(&empty[0], &empty[0])); const std::string parentdot[] = { "..", "." }; CPPUNIT_ASSERT_EQUAL(std::string(""), - Util::joinPath(&parentdot[0], + util::joinPath(&parentdot[0], &parentdot[arrayLength(parentdot)])); } void UtilTest::testParseIndexPath() { - std::map::value_type p = Util::parseIndexPath("1=foo"); + std::map::value_type p = util::parseIndexPath("1=foo"); CPPUNIT_ASSERT_EQUAL((size_t)1, p.first); CPPUNIT_ASSERT_EQUAL(std::string("foo"), p.second); try { - Util::parseIndexPath("1X=foo"); + util::parseIndexPath("1X=foo"); CPPUNIT_FAIL("exception must be thrown."); } catch(Exception& e) { // success } try { - Util::parseIndexPath("1="); + util::parseIndexPath("1="); CPPUNIT_FAIL("exception must be thrown."); } catch(Exception& e) { // success @@ -783,7 +783,7 @@ void UtilTest::testCreateIndexPathMap() std::stringstream in ("1=/tmp/myfile\n" "100=/myhome/mypicture.png\n"); - std::map m = Util::createIndexPathMap(in); + std::map m = util::createIndexPathMap(in); CPPUNIT_ASSERT_EQUAL((size_t)2, m.size()); CPPUNIT_ASSERT(m.find(1) != m.end()); CPPUNIT_ASSERT_EQUAL(std::string("/tmp/myfile"), m[1]);