diff options
| author | Tatsuhiro Tsujikawa <tatsuhiro.t@gmail.com> | 2010-01-05 16:01:46 +0000 |
|---|---|---|
| committer | Tatsuhiro Tsujikawa <tatsuhiro.t@gmail.com> | 2010-01-05 16:01:46 +0000 |
| commit | 4db349c1f32b4a313d12d114137432441633d00a (patch) | |
| tree | 417451971e264834312cfd8339c79930d680a5d1 | |
| parent | 338e8aca09331d3e7fa4e1e8e1f9d10260986772 (diff) | |
2010-01-06 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
Untabify. Fixed one line in copyright which is longer than 80
columns.
* src
* test
827 files changed, 7348 insertions, 7341 deletions
@@ -1,3 +1,10 @@ +2010-01-06 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net> + + Untabify. Fixed one line in copyright which is longer than 80 + columns. + * src + * test + 2009-12-27 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net> Release 1.8.0 diff --git a/src/A2STR.cc b/src/A2STR.cc index 5f08e7b7..61ee926a 100644 --- a/src/A2STR.cc +++ b/src/A2STR.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/A2STR.h b/src/A2STR.h index d62133c0..66c1b398 100644 --- a/src/A2STR.h +++ b/src/A2STR.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/ARC4Decryptor.h b/src/ARC4Decryptor.h index 9f11a302..25cb56fd 100644 --- a/src/ARC4Decryptor.h +++ b/src/ARC4Decryptor.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -55,7 +55,7 @@ public: void init(const unsigned char* key, size_t keyLength) {} void decrypt(unsigned char* out, size_t outLength, - const unsigned char* in, size_t inLength) {} + const unsigned char* in, size_t inLength) {} }; } // namespace aria2 diff --git a/src/ARC4Encryptor.h b/src/ARC4Encryptor.h index 1df4f61d..2ceee750 100644 --- a/src/ARC4Encryptor.h +++ b/src/ARC4Encryptor.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -55,7 +55,7 @@ public: void init(const unsigned char* key, size_t keyLength) {} void encrypt(unsigned char* out, size_t outLength, - const unsigned char* in, size_t inLength) {} + const unsigned char* in, size_t inLength) {} }; } // namespace aria2 diff --git a/src/AbstractAuthResolver.cc b/src/AbstractAuthResolver.cc index 4767685d..3a58333c 100644 --- a/src/AbstractAuthResolver.cc +++ b/src/AbstractAuthResolver.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/AbstractAuthResolver.h b/src/AbstractAuthResolver.h index 0d50197e..e7096c72 100644 --- a/src/AbstractAuthResolver.h +++ b/src/AbstractAuthResolver.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/AbstractBtMessage.cc b/src/AbstractBtMessage.cc index 43908556..7e6f84bc 100644 --- a/src/AbstractBtMessage.cc +++ b/src/AbstractBtMessage.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/AbstractBtMessage.h b/src/AbstractBtMessage.h index 7e8389f6..059d2897 100644 --- a/src/AbstractBtMessage.h +++ b/src/AbstractBtMessage.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/AbstractCommand.cc b/src/AbstractCommand.cc index 059d0d8b..52fd872a 100644 --- a/src/AbstractCommand.cc +++ b/src/AbstractCommand.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -68,11 +68,11 @@ namespace aria2 { AbstractCommand::AbstractCommand(int32_t cuid, - const SharedHandle<Request>& req, - const SharedHandle<FileEntry>& fileEntry, - RequestGroup* requestGroup, - DownloadEngine* e, - const SocketHandle& s): + const SharedHandle<Request>& req, + const SharedHandle<FileEntry>& fileEntry, + RequestGroup* requestGroup, + DownloadEngine* e, + const SocketHandle& s): Command(cuid), _requestGroup(requestGroup), req(req), _fileEntry(fileEntry), e(e), socket(s), checkSocketIsReadable(false), checkSocketIsWritable(false), @@ -98,7 +98,7 @@ AbstractCommand::~AbstractCommand() { bool AbstractCommand::execute() { logger->debug("CUID#%d - socket: read:%d, write:%d, hup:%d, err:%d", - cuid, _readEvent, _writeEvent, _hupEvent, _errorEvent); + cuid, _readEvent, _writeEvent, _hupEvent, _errorEvent); try { if(_requestGroup->downloadFinished() || _requestGroup->isHaltRequested()) { //logger->debug("CUID#%d - finished.", cuid); @@ -110,19 +110,19 @@ bool AbstractCommand::execute() { !_requestGroup->getPieceStorage()->hasMissingUnusedPiece()) { SharedHandle<Request> fasterRequest = _fileEntry->findFasterRequest(req); if(!fasterRequest.isNull()) { - logger->info("CUID#%d - Use faster Request hostname=%s, port=%u", - cuid, - fasterRequest->getHost().c_str(), - fasterRequest->getPort()); - - // Cancel current Request object and use faster one. - _fileEntry->removeRequest(req); - Command* command = - InitiateConnectionCommandFactory::createInitiateConnectionCommand - (cuid, fasterRequest, _fileEntry, _requestGroup, e); - e->setNoWait(true); - e->commands.push_back(command); - return true; + logger->info("CUID#%d - Use faster Request hostname=%s, port=%u", + cuid, + fasterRequest->getHost().c_str(), + fasterRequest->getPort()); + + // Cancel current Request object and use faster one. + _fileEntry->removeRequest(req); + Command* command = + InitiateConnectionCommandFactory::createInitiateConnectionCommand + (cuid, fasterRequest, _fileEntry, _requestGroup, e); + e->setNoWait(true); + e->commands.push_back(command); + return true; } } if((checkSocketIsReadable && _readEvent) || @@ -134,54 +134,54 @@ bool AbstractCommand::execute() { (!checkSocketIsReadable && !checkSocketIsWritable && !nameResolverCheck)) { checkPoint.reset(); if(!_requestGroup->getPieceStorage().isNull()) { - _segments.clear(); - _requestGroup->getSegmentMan()->getInFlightSegment(_segments, cuid); - if(req.isNull() || req->getMaxPipelinedRequest() == 1 || - _requestGroup->getDownloadContext()->getFileEntries().size() == 1) { - if(_segments.empty()) { - SharedHandle<Segment> segment = - _requestGroup->getSegmentMan()->getSegment(cuid); - if(!segment.isNull()) { - _segments.push_back(segment); - } - } - if(_segments.empty()) { - // TODO socket could be pooled here if pipelining is enabled... - logger->info(MSG_NO_SEGMENT_AVAILABLE, cuid); - // When all segments are ignored in SegmentMan, there are - // no URIs available, so don't retry. - if(_requestGroup->getSegmentMan()->allSegmentsIgnored()) { - return true; - } else { - return prepareForRetry(1); - } - } - } else { - size_t maxSegments = req->getMaxPipelinedRequest(); - if(_segments.size() < maxSegments) { - _requestGroup->getSegmentMan()->getSegment - (_segments, cuid, _fileEntry, maxSegments); - } - if(_segments.empty()) { - return prepareForRetry(0); - } - } + _segments.clear(); + _requestGroup->getSegmentMan()->getInFlightSegment(_segments, cuid); + if(req.isNull() || req->getMaxPipelinedRequest() == 1 || + _requestGroup->getDownloadContext()->getFileEntries().size() == 1) { + if(_segments.empty()) { + SharedHandle<Segment> segment = + _requestGroup->getSegmentMan()->getSegment(cuid); + if(!segment.isNull()) { + _segments.push_back(segment); + } + } + if(_segments.empty()) { + // TODO socket could be pooled here if pipelining is enabled... + logger->info(MSG_NO_SEGMENT_AVAILABLE, cuid); + // When all segments are ignored in SegmentMan, there are + // no URIs available, so don't retry. + if(_requestGroup->getSegmentMan()->allSegmentsIgnored()) { + return true; + } else { + return prepareForRetry(1); + } + } + } else { + size_t maxSegments = req->getMaxPipelinedRequest(); + if(_segments.size() < maxSegments) { + _requestGroup->getSegmentMan()->getSegment + (_segments, cuid, _fileEntry, maxSegments); + } + if(_segments.empty()) { + return prepareForRetry(0); + } + } } return executeInternal(); } else if(_errorEvent) { throw DL_RETRY_EX - (StringFormat(MSG_NETWORK_PROBLEM, - socket->getSocketError().c_str()).str()); + (StringFormat(MSG_NETWORK_PROBLEM, + socket->getSocketError().c_str()).str()); } else { if(checkPoint.elapsed(timeout)) { - // timeout triggers ServerStat error state. + // timeout triggers ServerStat error state. - SharedHandle<ServerStat> ss = - e->_requestGroupMan->getOrCreateServerStat(req->getHost(), - req->getProtocol()); - ss->setError(); + SharedHandle<ServerStat> ss = + e->_requestGroupMan->getOrCreateServerStat(req->getHost(), + req->getProtocol()); + ss->setError(); - throw DL_RETRY_EX2(EX_TIME_OUT, downloadresultcode::TIME_OUT); + throw DL_RETRY_EX2(EX_TIME_OUT, downloadresultcode::TIME_OUT); } e->commands.push_back(this); return false; @@ -191,9 +191,9 @@ bool AbstractCommand::execute() { logger->debug(EX_EXCEPTION_CAUGHT, err); } else { logger->error(MSG_DOWNLOAD_ABORTED, - DL_ABORT_EX2(StringFormat - ("URI=%s", req->getCurrentUrl().c_str()).str(),err), - cuid, req->getUrl().c_str()); + DL_ABORT_EX2(StringFormat + ("URI=%s", req->getCurrentUrl().c_str()).str(),err), + cuid, req->getUrl().c_str()); _fileEntry->addURIResult(req->getUrl(), err.getCode()); _requestGroup->setLastUriResult(req->getUrl(), err.getCode()); } @@ -203,9 +203,9 @@ bool AbstractCommand::execute() { } catch(DlRetryEx& err) { assert(!req.isNull()); logger->info(MSG_RESTARTING_DOWNLOAD, - DL_RETRY_EX2(StringFormat - ("URI=%s", req->getCurrentUrl().c_str()).str(),err), - cuid, req->getUrl().c_str()); + DL_RETRY_EX2(StringFormat + ("URI=%s", req->getCurrentUrl().c_str()).str(),err), + cuid, req->getUrl().c_str()); req->addTryCount(); req->resetRedirectCount(); const unsigned int maxTries = getOption()->getAsInt(PREF_MAX_TRIES); @@ -241,8 +241,8 @@ void AbstractCommand::tryReserved() { // can assume that there are no in-flight request object. if(entry->getLength() == 0 && entry->getRemainingUris().empty()) { logger->debug("CUID#%d - Not trying next request." - " No reserved/pooled request is remaining and" - " total length is still unknown.", cuid); + " No reserved/pooled request is remaining and" + " total length is still unknown.", cuid); return; } } @@ -260,7 +260,7 @@ bool AbstractCommand::prepareForRetry(time_t wait) { if(!req.isNull()) { _fileEntry->poolRequest(req); logger->debug("CUID#%d - Pooling request URI=%s", - cuid, req->getUrl().c_str()); + cuid, req->getUrl().c_str()); if(!_requestGroup->getSegmentMan().isNull()) { _requestGroup->getSegmentMan()->recognizeSegmentFor(_fileEntry); } @@ -272,7 +272,7 @@ bool AbstractCommand::prepareForRetry(time_t wait) { e->commands.push_back(command); } else { SleepCommand* scom = new SleepCommand(cuid, e, _requestGroup, - command, wait); + command, wait); e->commands.push_back(scom); } return true; @@ -282,7 +282,7 @@ void AbstractCommand::onAbort() { if(!req.isNull()) { // TODO This might be a problem if the failure is caused by proxy. e->_requestGroupMan->getOrCreateServerStat(req->getHost(), - req->getProtocol())->setError(); + req->getProtocol())->setError(); _fileEntry->removeIdenticalURI(req->getUrl()); _fileEntry->removeRequest(req); } @@ -307,9 +307,9 @@ void AbstractCommand::setReadCheckSocket(const SocketHandle& socket) { } else { if(checkSocketIsReadable) { if(readCheckTarget != socket) { - e->deleteSocketForReadCheck(readCheckTarget, this); - e->addSocketForReadCheck(socket, this); - readCheckTarget = socket; + e->deleteSocketForReadCheck(readCheckTarget, this); + e->addSocketForReadCheck(socket, this); + readCheckTarget = socket; } } else { e->addSocketForReadCheck(socket, this); @@ -343,9 +343,9 @@ void AbstractCommand::setWriteCheckSocket(const SocketHandle& socket) { } else { if(checkSocketIsWritable) { if(writeCheckTarget != socket) { - e->deleteSocketForWriteCheck(writeCheckTarget, this); - e->addSocketForWriteCheck(socket, this); - writeCheckTarget = socket; + e->deleteSocketForWriteCheck(writeCheckTarget, this); + e->addSocketForWriteCheck(socket, this); + writeCheckTarget = socket; } } else { e->addSocketForWriteCheck(socket, this); @@ -366,7 +366,7 @@ void AbstractCommand::setWriteCheckSocketIf } static const std::string& getProxyStringFor(const std::string& proxyPref, - const SharedHandle<Option>& option) + const SharedHandle<Option>& option) { if(option->defined(proxyPref)) { return option->get(proxyPref); @@ -376,7 +376,7 @@ static const std::string& getProxyStringFor(const std::string& proxyPref, } static bool isProxyUsed(const std::string& proxyPref, - const SharedHandle<Option>& option) + const SharedHandle<Option>& option) { std::string proxy = getProxyStringFor(proxyPref, option); if(proxy.empty()) { @@ -387,7 +387,7 @@ static bool isProxyUsed(const std::string& proxyPref, } static bool isProxyRequest(const std::string& protocol, - const SharedHandle<Option>& option) + const SharedHandle<Option>& option) { return (protocol == Request::PROTO_HTTP && isProxyUsed(PREF_HTTP_PROXY, option)) || @@ -412,7 +412,7 @@ public: }; static bool inNoProxy(const SharedHandle<Request>& req, - const std::string& noProxy) + const std::string& noProxy) { std::vector<std::string> entries; util::split(noProxy, std::back_inserter(entries), ",", true); @@ -421,7 +421,7 @@ static bool inNoProxy(const SharedHandle<Request>& req, } return std::find_if(entries.begin(), entries.end(), - DomainMatch("."+req->getHost())) != entries.end(); + DomainMatch("."+req->getHost())) != entries.end(); } bool AbstractCommand::isProxyDefined() const @@ -431,7 +431,7 @@ bool AbstractCommand::isProxyDefined() const } static const std::string& getProxyString(const SharedHandle<Request>& req, - const SharedHandle<Option>& option) + const SharedHandle<Option>& option) { if(req->getProtocol() == Request::PROTO_HTTP) { return getProxyStringFor(PREF_HTTP_PROXY, option); @@ -486,11 +486,11 @@ bool AbstractCommand::asyncResolveHostname() case AsyncNameResolver::STATUS_ERROR: if(!isProxyRequest(req->getProtocol(), getOption())) { e->_requestGroupMan->getOrCreateServerStat - (req->getHost(), req->getProtocol())->setError(); + (req->getHost(), req->getProtocol())->setError(); } throw DL_ABORT_EX(StringFormat(MSG_NAME_RESOLUTION_FAILED, cuid, - _asyncNameResolver->getHostname().c_str(), - _asyncNameResolver->getError().c_str()).str()); + _asyncNameResolver->getHostname().c_str(), + _asyncNameResolver->getError().c_str()).str()); default: return false; } @@ -548,24 +548,24 @@ bool AbstractCommand::checkIfConnectionEstablished // See also InitiateConnectionCommand::executeInternal() e->markBadIPAddress(connectedHostname, connectedAddr, connectedPort); if(!e->findCachedIPAddress(connectedHostname, connectedPort).empty()) { - logger->info(MSG_CONNECT_FAILED_AND_RETRY, - cuid, connectedAddr.c_str(), connectedPort); - Command* command = - InitiateConnectionCommandFactory::createInitiateConnectionCommand - (cuid, req, _fileEntry, _requestGroup, e); - e->setNoWait(true); - e->commands.push_back(command); - return false; + logger->info(MSG_CONNECT_FAILED_AND_RETRY, + cuid, connectedAddr.c_str(), connectedPort); + Command* command = + InitiateConnectionCommandFactory::createInitiateConnectionCommand + (cuid, req, _fileEntry, _requestGroup, e); + e->setNoWait(true); + e->commands.push_back(command); + return false; } e->removeCachedIPAddress(connectedHostname, connectedPort); // Don't set error if proxy server is used and its method is GET. if(resolveProxyMethod(req->getProtocol()) != V_GET || - !isProxyRequest(req->getProtocol(), getOption())) { - e->_requestGroupMan->getOrCreateServerStat - (req->getHost(), req->getProtocol())->setError(); + !isProxyRequest(req->getProtocol(), getOption())) { + e->_requestGroupMan->getOrCreateServerStat + (req->getHost(), req->getProtocol())->setError(); } throw DL_RETRY_EX - (StringFormat(MSG_ESTABLISHING_CONNECTION_FAILED, error.c_str()).str()); + (StringFormat(MSG_ESTABLISHING_CONNECTION_FAILED, error.c_str()).str()); } } return true; diff --git a/src/AbstractCommand.h b/src/AbstractCommand.h index 1d6d5379..fcb49c2d 100644 --- a/src/AbstractCommand.h +++ b/src/AbstractCommand.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -153,9 +153,9 @@ private: #endif // ENABLE_ASYNC_DNS public: AbstractCommand(int32_t cuid, const SharedHandle<Request>& req, - const SharedHandle<FileEntry>& fileEntry, - RequestGroup* requestGroup, DownloadEngine* e, - const SharedHandle<SocketCore>& s = SharedHandle<SocketCore>()); + const SharedHandle<FileEntry>& fileEntry, + RequestGroup* requestGroup, DownloadEngine* e, + const SharedHandle<SocketCore>& s = SharedHandle<SocketCore>()); virtual ~AbstractCommand(); bool execute(); diff --git a/src/AbstractDiskWriter.cc b/src/AbstractDiskWriter.cc index 78e9ffed..84a5f3bd 100644 --- a/src/AbstractDiskWriter.cc +++ b/src/AbstractDiskWriter.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -110,9 +110,9 @@ void AbstractDiskWriter::createFile(int addFlags) assert(!_filename.empty()); util::mkdirs(File(_filename).getDirname()); if((fd = open(_filename.c_str(), O_CREAT|O_RDWR|O_TRUNC|O_BINARY|addFlags, - OPEN_MODE)) < 0) { + OPEN_MODE)) < 0) { throw DL_ABORT_EX(StringFormat(EX_FILE_OPEN, - _filename.c_str(), strerror(errno)).str()); + _filename.c_str(), strerror(errno)).str()); } } @@ -153,10 +153,10 @@ void AbstractDiskWriter::writeData(const unsigned char* data, size_t len, off_t // DownloadFailureException and abort download instantly. if(errno == ENOSPC) { throw DOWNLOAD_FAILURE_EXCEPTION - (StringFormat(EX_FILE_WRITE, _filename.c_str(), strerror(errno)).str()); + (StringFormat(EX_FILE_WRITE, _filename.c_str(), strerror(errno)).str()); } throw DL_ABORT_EX(StringFormat(EX_FILE_WRITE, - _filename.c_str(), strerror(errno)).str()); + _filename.c_str(), strerror(errno)).str()); } } @@ -166,7 +166,7 @@ ssize_t AbstractDiskWriter::readData(unsigned char* data, size_t len, off_t offs seek(offset); if((ret = readDataInternal(data, len)) < 0) { throw DL_ABORT_EX(StringFormat(EX_FILE_READ, - _filename.c_str(), strerror(errno)).str()); + _filename.c_str(), strerror(errno)).str()); } return ret; } @@ -183,12 +183,12 @@ void AbstractDiskWriter::truncate(uint64_t length) seek(length); if(SetEndOfFile(handle) == 0) { throw DL_ABORT_EX(StringFormat("SetEndOfFile failed. cause: %s", - GetLastError()).str()); + GetLastError()).str()); } #else if(ftruncate(fd, length) == -1) { throw DL_ABORT_EX(StringFormat("ftruncate failed. cause: %s", - strerror(errno)).str()); + strerror(errno)).str()); } #endif } @@ -202,7 +202,7 @@ void AbstractDiskWriter::allocate(off_t offset, uint64_t length) int r = posix_fallocate(fd, offset, length); if(r != 0) { throw DL_ABORT_EX(StringFormat("posix_fallocate failed. cause: %s", - strerror(r)).str()); + strerror(r)).str()); } } #endif // HAVE_POSIX_FALLOCATE diff --git a/src/AbstractDiskWriter.h b/src/AbstractDiskWriter.h index 4f594d38..cc3ce34b 100644 --- a/src/AbstractDiskWriter.h +++ b/src/AbstractDiskWriter.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/AbstractProxyRequestCommand.cc b/src/AbstractProxyRequestCommand.cc index 08dfbe30..df4e9c65 100644 --- a/src/AbstractProxyRequestCommand.cc +++ b/src/AbstractProxyRequestCommand.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/AbstractProxyRequestCommand.h b/src/AbstractProxyRequestCommand.h index 11a8e1cf..93d11dc2 100644 --- a/src/AbstractProxyRequestCommand.h +++ b/src/AbstractProxyRequestCommand.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -55,12 +55,12 @@ protected: virtual bool executeInternal(); public: AbstractProxyRequestCommand(int cuid, - const SharedHandle<Request>& req, - const SharedHandle<FileEntry>& fileEntry, - RequestGroup* requestGroup, - DownloadEngine* e, - const SharedHandle<Request>& proxyRequest, - const SharedHandle<SocketCore>& s); + const SharedHandle<Request>& req, + const SharedHandle<FileEntry>& fileEntry, + RequestGroup* requestGroup, + DownloadEngine* e, + const SharedHandle<Request>& proxyRequest, + const SharedHandle<SocketCore>& s); virtual ~AbstractProxyRequestCommand(); diff --git a/src/AbstractProxyResponseCommand.cc b/src/AbstractProxyResponseCommand.cc index 248a7bd3..b5e40cbe 100644 --- a/src/AbstractProxyResponseCommand.cc +++ b/src/AbstractProxyResponseCommand.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/AbstractProxyResponseCommand.h b/src/AbstractProxyResponseCommand.h index bc6ee33a..fa167046 100644 --- a/src/AbstractProxyResponseCommand.h +++ b/src/AbstractProxyResponseCommand.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/AbstractSegmentManFactory.h b/src/AbstractSegmentManFactory.h index d796e07b..5a87452f 100644 --- a/src/AbstractSegmentManFactory.h +++ b/src/AbstractSegmentManFactory.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/AbstractSingleDiskAdaptor.cc b/src/AbstractSingleDiskAdaptor.cc index df61c928..27a650a9 100644 --- a/src/AbstractSingleDiskAdaptor.cc +++ b/src/AbstractSingleDiskAdaptor.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -103,7 +103,7 @@ FileAllocationIteratorHandle AbstractSingleDiskAdaptor::fileAllocationIterator() #endif // HAVE_POSIX_FALLOCATE { SingleFileAllocationIteratorHandle h - (new SingleFileAllocationIterator(this, size(), totalLength)); + (new SingleFileAllocationIterator(this, size(), totalLength)); h->init(); return h; } diff --git a/src/AbstractSingleDiskAdaptor.h b/src/AbstractSingleDiskAdaptor.h index 559c863b..d38372db 100644 --- a/src/AbstractSingleDiskAdaptor.h +++ b/src/AbstractSingleDiskAdaptor.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -61,7 +61,7 @@ public: virtual void openExistingFile(); virtual void writeData(const unsigned char* data, size_t len, - off_t offset); + off_t offset); virtual ssize_t readData(unsigned char* data, size_t len, off_t offset); diff --git a/src/ActivePeerConnectionCommand.cc b/src/ActivePeerConnectionCommand.cc index 24ec1efd..cb53e14a 100644 --- a/src/ActivePeerConnectionCommand.cc +++ b/src/ActivePeerConnectionCommand.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -86,7 +86,7 @@ bool ActivePeerConnectionCommand::execute() { if(_requestGroup->getDownloadContext()-> getAttribute(bittorrent::BITTORRENT).containsKey(bittorrent::METADATA)) { thresholdSpeed = - _requestGroup->getOption()->getAsInt(PREF_BT_REQUEST_PEER_SPEED_LIMIT); + _requestGroup->getOption()->getAsInt(PREF_BT_REQUEST_PEER_SPEED_LIMIT); } else { thresholdSpeed = 0; } @@ -95,31 +95,31 @@ bool ActivePeerConnectionCommand::execute() { } if(// for seeder state (_pieceStorage->downloadFinished() && _btRuntime->lessThanMaxPeers() && - (maxUploadLimit == 0 || tstat.getUploadSpeed() < maxUploadLimit*0.8)) || + (maxUploadLimit == 0 || tstat.getUploadSpeed() < maxUploadLimit*0.8)) || // for leecher state (!_pieceStorage->downloadFinished() && - (tstat.getDownloadSpeed() < thresholdSpeed || - _btRuntime->lessThanMinPeers()))) { + (tstat.getDownloadSpeed() < thresholdSpeed || + _btRuntime->lessThanMinPeers()))) { unsigned int numConnection = 0; if(_pieceStorage->downloadFinished()) { - if(_btRuntime->getMaxPeers() > _btRuntime->getConnections()) { - numConnection = - std::min(_numNewConnection, - _btRuntime->getMaxPeers()-_btRuntime->getConnections()); - } + if(_btRuntime->getMaxPeers() > _btRuntime->getConnections()) { + numConnection = + std::min(_numNewConnection, + _btRuntime->getMaxPeers()-_btRuntime->getConnections()); + } } else { - numConnection = _numNewConnection; + numConnection = _numNewConnection; } for(unsigned int numAdd = numConnection; - numAdd > 0 && _peerStorage->isPeerAvailable(); --numAdd) { - PeerHandle peer = _peerStorage->getUnusedPeer(); - connectToPeer(peer); + numAdd > 0 && _peerStorage->isPeerAvailable(); --numAdd) { + PeerHandle peer = _peerStorage->getUnusedPeer(); + connectToPeer(peer); } if(_btRuntime->getConnections() == 0 && - !_pieceStorage->downloadFinished()) { - _btAnnounce->overrideMinInterval(BtAnnounce::DEFAULT_ANNOUNCE_INTERVAL); + !_pieceStorage->downloadFinished()) { + _btAnnounce->overrideMinInterval(BtAnnounce::DEFAULT_ANNOUNCE_INTERVAL); } } } @@ -135,12 +135,12 @@ void ActivePeerConnectionCommand::connectToPeer(const PeerHandle& peer) peer->usedBy(e->newCUID()); PeerInitiateConnectionCommand* command = new PeerInitiateConnectionCommand(peer->usedBy(), _requestGroup, peer, e, - _btRuntime); + _btRuntime); command->setPeerStorage(_peerStorage); command->setPieceStorage(_pieceStorage); e->commands.push_back(command); logger->info(MSG_CONNECTING_TO_PEER, - cuid, peer->ipaddr.c_str()); + cuid, peer->ipaddr.c_str()); } void ActivePeerConnectionCommand::setBtRuntime diff --git a/src/ActivePeerConnectionCommand.h b/src/ActivePeerConnectionCommand.h index 3f22b6a6..a34b0d41 100644 --- a/src/ActivePeerConnectionCommand.h +++ b/src/ActivePeerConnectionCommand.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -63,9 +63,9 @@ private: unsigned int _numNewConnection; // the number of the connection to establish. public: ActivePeerConnectionCommand(int cuid, - RequestGroup* requestGroup, - DownloadEngine* e, - time_t interval); + RequestGroup* requestGroup, + DownloadEngine* e, + time_t interval); virtual ~ActivePeerConnectionCommand(); diff --git a/src/AdaptiveURISelector.cc b/src/AdaptiveURISelector.cc index 7ceb09fa..f631ff63 100644 --- a/src/AdaptiveURISelector.cc +++ b/src/AdaptiveURISelector.cc @@ -17,7 +17,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -75,7 +75,7 @@ AdaptiveURISelector::~AdaptiveURISelector() {} std::string AdaptiveURISelector::select(FileEntry* fileEntry) { _logger->debug("AdaptiveURISelector: called %d", - _requestGroup->getNumConnection()); + _requestGroup->getNumConnection()); std::deque<std::string>& uris = fileEntry->getRemainingUris(); if (uris.empty() && _requestGroup->getNumConnection() <= 1) { // here we know the download will fail, trying to find previously @@ -101,13 +101,13 @@ void AdaptiveURISelector::mayRetryWithIncreasedTimeout(FileEntry* fileEntry) std::deque<URIResult> timeouts; fileEntry->extractURIResult(timeouts, downloadresultcode::TIME_OUT); std::transform(timeouts.begin(), timeouts.end(), std::back_inserter(uris), - std::mem_fun_ref(&URIResult::getURI)); + std::mem_fun_ref(&URIResult::getURI)); for(std::deque<std::string>::const_iterator i = uris.begin(); i != uris.end(); ++i) { _logger->debug("AdaptiveURISelector: will retry server with increased" - " timeout (%d s): %s", - _requestGroup->getTimeout(), (*i).c_str()); + " timeout (%d s): %s", + _requestGroup->getTimeout(), (*i).c_str()); } } @@ -122,7 +122,7 @@ std::string AdaptiveURISelector::selectOne(const std::deque<std::string>& uris) bool reservedContext = numPieces > 0 && _nbConnections > std::min(numPieces, - _requestGroup->getNumConcurrentCommand()); + _requestGroup->getNumConcurrentCommand()); bool selectBest = numPieces == 0 || reservedContext; if(numPieces > 0) @@ -132,8 +132,8 @@ std::string AdaptiveURISelector::selectOne(const std::deque<std::string>& uris) if(getNbTestedServers(uris) < 3) { std::string notTested = getFirstNotTestedUri(uris); if(notTested != A2STR::NIL) { - _logger->debug("AdaptiveURISelector: choosing the first non tested" - " mirror: %s", notTested.c_str()); + _logger->debug("AdaptiveURISelector: choosing the first non tested" + " mirror: %s", notTested.c_str()); --_nbServerToEvaluate; return notTested; } @@ -144,20 +144,20 @@ std::string AdaptiveURISelector::selectOne(const std::deque<std::string>& uris) std::string notTested = getFirstNotTestedUri(uris); if(notTested != A2STR::NIL) { /* Here we return the first untested mirror */ - _logger->debug("AdaptiveURISelector: choosing non tested mirror %s for" - " connection #%d", notTested.c_str(), _nbConnections); + _logger->debug("AdaptiveURISelector: choosing non tested mirror %s for" + " connection #%d", notTested.c_str(), _nbConnections); return notTested; } else { - /* Here we return a mirror which need to be tested again */ - std::string toReTest = getFirstToTestUri(uris); - if(toReTest != A2STR::NIL) { - _logger->debug("AdaptiveURISelector: choosing mirror %s which has not" - " been tested recently for connection #%d", - toReTest.c_str(), _nbConnections); - return toReTest; - } else { - return getBestMirror(uris); - } + /* Here we return a mirror which need to be tested again */ + std::string toReTest = getFirstToTestUri(uris); + if(toReTest != A2STR::NIL) { + _logger->debug("AdaptiveURISelector: choosing mirror %s which has not" + " been tested recently for connection #%d", + toReTest.c_str(), _nbConnections); + return toReTest; + } else { + return getBestMirror(uris); + } } } else { @@ -177,14 +177,14 @@ std::string AdaptiveURISelector::getBestMirror if (bests.size() < 2) { std::string uri = getMaxDownloadSpeedUri(uris); _logger->debug("AdaptiveURISelector: choosing the best mirror :" - " %.2fKB/s %s (other mirrors are at least 25%% slower)", - (float) max/1024, uri.c_str()); + " %.2fKB/s %s (other mirrors are at least 25%% slower)", + (float) max/1024, uri.c_str()); return uri; } else { std::string uri = selectRandomUri(bests); _logger->debug("AdaptiveURISelector: choosing randomly one of the best" - " mirrors (range [%.2fKB/s, %.2fKB/s]): %s", - (float) min/1024, (float) max/1024, uri.c_str()); + " mirrors (range [%.2fKB/s, %.2fKB/s]): %s", + (float) min/1024, (float) max/1024, uri.c_str()); return uri; } } @@ -212,11 +212,11 @@ void AdaptiveURISelector::adjustLowestSpeedLimit unsigned int max = getMaxDownloadSpeed(uris); if (max > 0 && lowest > max / 4) { _logger->notice("Lowering lowest-speed-limit since known max speed is too" - " near (new:%d was:%d max:%d)", max / 4, lowest, max); + " near (new:%d was:%d max:%d)", max / 4, lowest, max); command->setLowestDownloadSpeedLimit(max / 4); } else if (max == 0 && lowest > low_lowest) { _logger->notice("Lowering lowest-speed-limit since we have no clue about" - " available speed (now:%d was:%d)", low_lowest, lowest); + " available speed (now:%d was:%d)", low_lowest, lowest); command->setLowestDownloadSpeedLimit(low_lowest); } } @@ -225,7 +225,7 @@ void AdaptiveURISelector::adjustLowestSpeedLimit static unsigned int getUriMaxSpeed(SharedHandle<ServerStat> ss) { return std::max(ss->getSingleConnectionAvgSpeed(), - ss->getMultiConnectionAvgSpeed()); + ss->getMultiConnectionAvgSpeed()); } unsigned int AdaptiveURISelector::getMaxDownloadSpeed @@ -265,12 +265,12 @@ std::deque<std::string> AdaptiveURISelector::getUrisBySpeed { std::deque<std::string> bests; for(std::deque<std::string>::const_iterator i = uris.begin(); - i != uris.end(); ++i) { + i != uris.end(); ++i) { SharedHandle<ServerStat> ss = getServerStats(*i); if(ss.isNull()) continue; if(ss->getSingleConnectionAvgSpeed() > min || - ss->getMultiConnectionAvgSpeed() > min) { + ss->getMultiConnectionAvgSpeed() > min) { bests.push_back(*i); } } @@ -304,7 +304,7 @@ std::string AdaptiveURISelector::getFirstToTestUri unsigned int counter; int power; for(std::deque<std::string>::const_iterator i = uris.begin(); - i != uris.end(); ++i) { + i != uris.end(); ++i) { SharedHandle<ServerStat> ss = getServerStats(*i); if(ss.isNull()) continue; diff --git a/src/AdaptiveURISelector.h b/src/AdaptiveURISelector.h index 1e3c0869..92550f4a 100644 --- a/src/AdaptiveURISelector.h +++ b/src/AdaptiveURISelector.h @@ -17,7 +17,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -61,11 +61,11 @@ private: std::string selectOne(const std::deque<std::string>& uris); void adjustLowestSpeedLimit(const std::deque<std::string>& uris, - DownloadCommand* command) const; + DownloadCommand* command) const; unsigned int getMaxDownloadSpeed(const std::deque<std::string>& uris) const; std::string getMaxDownloadSpeedUri(const std::deque<std::string>& uris) const; std::deque<std::string> getUrisBySpeed(const std::deque<std::string>& uris, - unsigned int min) const; + unsigned int min) const; std::string selectRandomUri(const std::deque<std::string>& uris) const; std::string getFirstNotTestedUri(const std::deque<std::string>& uris) const; std::string getFirstToTestUri(const std::deque<std::string>& uris) const; @@ -74,13 +74,13 @@ private: std::string getBestMirror(const std::deque<std::string>& uris) const; public: AdaptiveURISelector(const SharedHandle<ServerStatMan>& serverStatMan, - RequestGroup* requestGroup); + RequestGroup* requestGroup); virtual ~AdaptiveURISelector(); virtual std::string select(FileEntry* fileEntry); virtual void tuneDownloadCommand(const std::deque<std::string>& uris, - DownloadCommand* command); + DownloadCommand* command); virtual void resetCounters(); }; diff --git a/src/AlphaNumberDecorator.h b/src/AlphaNumberDecorator.h index 5a9cdad7..c8ad33dd 100644 --- a/src/AlphaNumberDecorator.h +++ b/src/AlphaNumberDecorator.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/AnnounceList.cc b/src/AnnounceList.cc index 2e0c01dd..d6f037db 100644 --- a/src/AnnounceList.cc +++ b/src/AnnounceList.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -63,22 +63,22 @@ void AnnounceList::reconfigure(const BDE& announceList) { if(announceList.isList()) { for(BDE::List::const_iterator itr = announceList.listBegin(); - itr != announceList.listEnd(); ++itr) { + itr != announceList.listEnd(); ++itr) { const BDE& elemList = *itr; if(!elemList.isList()) { - continue; + continue; } std::deque<std::string> urls; for(BDE::List::const_iterator elemItr = elemList.listBegin(); - elemItr != elemList.listEnd(); ++elemItr) { - const BDE& data = *elemItr; - if(data.isString()) { - urls.push_back(data.s()); - } + elemItr != elemList.listEnd(); ++elemItr) { + const BDE& data = *elemItr; + if(data.isString()) { + urls.push_back(data.s()); + } } if(!urls.empty()) { - AnnounceTierHandle tier(new AnnounceTier(urls)); - tiers.push_back(tier); + AnnounceTierHandle tier(new AnnounceTier(urls)); + tiers.push_back(tier); } } resetIterator(); @@ -129,9 +129,9 @@ void AnnounceList::announceFailure() { (*currentTier)->nextEventIfAfterStarted(); ++currentTier; if(currentTier == tiers.end()) { - currentTrackerInitialized = false; + currentTrackerInitialized = false; } else { - currentTracker = (*currentTier)->urls.begin(); + currentTracker = (*currentTier)->urls.begin(); } } } @@ -215,7 +215,7 @@ void AnnounceList::setCurrentTier(const AnnounceTiers::iterator& itr) { template<class InputIterator, class Predicate> InputIterator find_wrap_if(InputIterator first, InputIterator last, - InputIterator current, Predicate pred) { + InputIterator current, Predicate pred) { InputIterator itr = std::find_if(current, last, pred); if(itr == last) { itr = std::find_if(first, current, pred); @@ -225,15 +225,15 @@ find_wrap_if(InputIterator first, InputIterator last, void AnnounceList::moveToStoppedAllowedTier() { AnnounceTiers::iterator itr = find_wrap_if(tiers.begin(), tiers.end(), - currentTier, - FindStoppedAllowedTier()); + currentTier, + FindStoppedAllowedTier()); setCurrentTier(itr); } void AnnounceList::moveToCompletedAllowedTier() { AnnounceTiers::iterator itr = find_wrap_if(tiers.begin(), tiers.end(), - currentTier, - FindCompletedAllowedTier()); + currentTier, + FindCompletedAllowedTier()); setCurrentTier(itr); } @@ -242,7 +242,7 @@ void AnnounceList::shuffle() { itr != tiers.end(); ++itr) { std::deque<std::string>& urls = (*itr)->urls; std::random_shuffle(urls.begin(), urls.end(), - *(SimpleRandomizer::getInstance().get())); + *(SimpleRandomizer::getInstance().get())); } } diff --git a/src/AnnounceList.h b/src/AnnounceList.h index 5de67fdd..069903ec 100644 --- a/src/AnnounceList.h +++ b/src/AnnounceList.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/AnnounceTier.h b/src/AnnounceTier.h index 2a706f07..c45bf89c 100644 --- a/src/AnnounceTier.h +++ b/src/AnnounceTier.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/AsyncNameResolver.cc b/src/AsyncNameResolver.cc index 71dd88d4..217cf108 100644 --- a/src/AsyncNameResolver.cc +++ b/src/AsyncNameResolver.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -42,7 +42,7 @@ namespace aria2 { #ifdef HAVE_LIBCARES1_5 void callback(void* arg, int status, int timeouts, struct hostent* host) #else -void callback(void* arg, int status, struct hostent* host) + void callback(void* arg, int status, struct hostent* host) #endif // HAVE_LIBCARES1_5 { AsyncNameResolver* resolverPtr = reinterpret_cast<AsyncNameResolver*>(arg); @@ -98,7 +98,7 @@ int AsyncNameResolver::getsock(sock_t* sockets) const { // TODO cast to int* might cause problem with Windows SOCKET? return ares_getsock(channel, reinterpret_cast<int*>(sockets), - ARES_GETSOCK_MAXNUM); + ARES_GETSOCK_MAXNUM); } void AsyncNameResolver::process(ares_socket_t readfd, ares_socket_t writefd) diff --git a/src/AsyncNameResolver.h b/src/AsyncNameResolver.h index 37cedf15..f2ee0add 100644 --- a/src/AsyncNameResolver.h +++ b/src/AsyncNameResolver.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/AuthConfig.cc b/src/AuthConfig.cc index 29390f24..27288705 100644 --- a/src/AuthConfig.cc +++ b/src/AuthConfig.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/AuthConfig.h b/src/AuthConfig.h index 3740b18c..e8e751b1 100644 --- a/src/AuthConfig.h +++ b/src/AuthConfig.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/AuthConfigFactory.cc b/src/AuthConfigFactory.cc index b1b129b7..1f85f5bc 100644 --- a/src/AuthConfigFactory.cc +++ b/src/AuthConfigFactory.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -64,51 +64,51 @@ AuthConfigFactory::createAuthConfig if(op->getAsBool(PREF_HTTP_AUTH_CHALLENGE)) { if(!request->getUsername().empty()) { - updateBasicCred(BasicCred(request->getUsername(), - request->getPassword(), - request->getHost(), request->getDir(), true)); - return createAuthConfig(request->getUsername(), request->getPassword()); + updateBasicCred(BasicCred(request->getUsername(), + request->getPassword(), + request->getHost(), request->getDir(), true)); + return createAuthConfig(request->getUsername(), request->getPassword()); } std::deque<BasicCred>::const_iterator i = - findBasicCred(request->getHost(), request->getDir()); + findBasicCred(request->getHost(), request->getDir()); if(i == _basicCreds.end()) { - return SharedHandle<AuthConfig>(); + return SharedHandle<AuthConfig>(); } else { - return createAuthConfig((*i)._user, (*i)._password); + return createAuthConfig((*i)._user, (*i)._password); } } else { if(!request->getUsername().empty()) { - return createAuthConfig(request->getUsername(), request->getPassword()); + return createAuthConfig(request->getUsername(), request->getPassword()); } else { - return - createHttpAuthResolver(op)->resolveAuthConfig(request->getHost()); + return + createHttpAuthResolver(op)->resolveAuthConfig(request->getHost()); } } } else if(request->getProtocol() == Request::PROTO_FTP) { if(!request->getUsername().empty()) { if(request->hasPassword()) { - return createAuthConfig(request->getUsername(), request->getPassword()); + return createAuthConfig(request->getUsername(), request->getPassword()); } else { - if(!op->getAsBool(PREF_NO_NETRC)) { - // First, check we have password corresponding to host and - // username - NetrcAuthResolver authResolver; - authResolver.setNetrc(_netrc); + if(!op->getAsBool(PREF_NO_NETRC)) { + // First, check we have password corresponding to host and + // username + NetrcAuthResolver authResolver; + authResolver.setNetrc(_netrc); - SharedHandle<AuthConfig> ac = - authResolver.resolveAuthConfig(request->getHost()); - if(!ac.isNull() && ac->getUser() == request->getUsername()) { - return ac; - } - } - // We don't have password for host and username. Return - // password specified by --ftp-passwd - return - createAuthConfig(request->getUsername(), op->get(PREF_FTP_PASSWD)); + SharedHandle<AuthConfig> ac = + authResolver.resolveAuthConfig(request->getHost()); + if(!ac.isNull() && ac->getUser() == request->getUsername()) { + return ac; + } + } + // We don't have password for host and username. Return + // password specified by --ftp-passwd + return + createAuthConfig(request->getUsername(), op->get(PREF_FTP_PASSWD)); } } else { return - createFtpAuthResolver(op)->resolveAuthConfig(request->getHost()); + createFtpAuthResolver(op)->resolveAuthConfig(request->getHost()); } } else { return SharedHandle<AuthConfig>(); @@ -157,7 +157,7 @@ AuthResolverHandle AuthConfigFactory::createFtpAuthResolver (createAuthConfig(op->get(PREF_FTP_USER), op->get(PREF_FTP_PASSWD))); SharedHandle<AuthConfig> defaultAuthConfig (new AuthConfig(AuthConfigFactory::ANONYMOUS, - AuthConfigFactory::ARIA2USER_AT)); + AuthConfigFactory::ARIA2USER_AT)); resolver->setDefaultAuthConfig(defaultAuthConfig); return resolver; } @@ -191,7 +191,7 @@ bool AuthConfigFactory::activateBasicCred return false; } else { BasicCred bc(authConfig->getUser(), authConfig->getPassword(), - host, path, true); + host, path, true); i = std::lower_bound(_basicCreds.begin(), _basicCreds.end(), bc); _basicCreds.insert(i, bc); return true; @@ -241,7 +241,7 @@ bool AuthConfigFactory::BasicCred::operator<(const BasicCred& cred) const std::deque<AuthConfigFactory::BasicCred>::iterator AuthConfigFactory::findBasicCred(const std::string& host, - const std::string& path) + const std::string& path) { BasicCred bc("", "", host, path); std::deque<BasicCred>::iterator i = diff --git a/src/AuthConfigFactory.h b/src/AuthConfigFactory.h index a578a637..ea6dc711 100644 --- a/src/AuthConfigFactory.h +++ b/src/AuthConfigFactory.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -56,7 +56,7 @@ private: SharedHandle<Netrc> _netrc; SharedHandle<AuthConfig> createAuthConfig(const std::string& user, - const std::string& password) const; + const std::string& password) const; SharedHandle<AuthResolver> createHttpAuthResolver(const Option* op) const; @@ -71,8 +71,8 @@ public: bool _activated; BasicCred(const std::string& user, const std::string& password, - const std::string& host, const std::string& path, - bool activated = false); + const std::string& host, const std::string& path, + bool activated = false); void activate(); diff --git a/src/AuthResolver.h b/src/AuthResolver.h index 650f8d56..ca436af3 100644 --- a/src/AuthResolver.h +++ b/src/AuthResolver.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/AutoSaveCommand.cc b/src/AutoSaveCommand.cc index 4202c68c..c70b671b 100644 --- a/src/AutoSaveCommand.cc +++ b/src/AutoSaveCommand.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/AutoSaveCommand.h b/src/AutoSaveCommand.h index 03c5d33a..663e4890 100644 --- a/src/AutoSaveCommand.h +++ b/src/AutoSaveCommand.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -42,14 +42,14 @@ const BDE BDE::none; BDE::BDE():_type(TYPE_NONE), _bobject(new BObject()) {} BDE::BDE(Integer integer):_type(TYPE_INTEGER), - _bobject(new BInteger(integer)) {} + _bobject(new BInteger(integer)) {} BDE::BDE(const std::string& string):_type(TYPE_STRING), - _bobject(new BString(std::string(string))) {} + _bobject(new BString(std::string(string))) {} BDE::BDE(const char* cstring):_type(TYPE_STRING), - _bobject(new BString(std::string(cstring))) {} + _bobject(new BString(std::string(cstring))) {} BDE::BDE(const char* data, size_t length): _type(TYPE_STRING), @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/BNode.cc b/src/BNode.cc index 6ce9d3b9..218b08e7 100644 --- a/src/BNode.cc +++ b/src/BNode.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -115,7 +115,7 @@ SharedHandle<DHTBucket> BNode::findBucketFor(BNode* b, const unsigned char* key) void BNode::findClosestKNodes(std::deque<SharedHandle<DHTNode> >& nodes, - BNode* b, const unsigned char* key) + BNode* b, const unsigned char* key) { BNode* bnode = findBNodeFor(b, key); if(!bnode) { @@ -149,11 +149,11 @@ void BNode::findClosestKNodes(std::deque<SharedHandle<DHTNode> >& nodes, bnode = bnode->getUp(); } else { if(std::find(visited.begin(), visited.end(), firstfunc(bnode)) == visited.end()) { - bnode = firstfunc(bnode); + bnode = firstfunc(bnode); } else if(std::find(visited.begin(), visited.end(), secondfunc(bnode)) == visited.end()) { - bnode = secondfunc(bnode); + bnode = secondfunc(bnode); } else { - bnode = bnode->getUp(); + bnode = bnode->getUp(); } } if(!bnode) { @@ -163,21 +163,21 @@ void BNode::findClosestKNodes(std::deque<SharedHandle<DHTNode> >& nodes, { SharedHandle<DHTBucket> bucket = bnode->getBucket(); if(!bucket.isNull()) { - std::deque<SharedHandle<DHTNode> > goodNodes; - bucket->getGoodNodes(goodNodes); - size_t r = DHTBucket::K-nodes.size(); - if(goodNodes.size() <= r) { - nodes.insert(nodes.end(), goodNodes.begin(), goodNodes.end()); - } else { - nodes.insert(nodes.end(), goodNodes.begin(), goodNodes.begin()+r); - } + std::deque<SharedHandle<DHTNode> > goodNodes; + bucket->getGoodNodes(goodNodes); + size_t r = DHTBucket::K-nodes.size(); + if(goodNodes.size() <= r) { + nodes.insert(nodes.end(), goodNodes.begin(), goodNodes.end()); + } else { + nodes.insert(nodes.end(), goodNodes.begin(), goodNodes.begin()+r); + } } } } } void BNode::enumerateBucket(std::deque<SharedHandle<DHTBucket> >& buckets, - const BNode* b) + const BNode* b) { std::deque<const BNode*> visited; visited.push_back(b); diff --git a/src/BNode.h b/src/BNode.h index 27c95d4d..740d3a6d 100644 --- a/src/BNode.h +++ b/src/BNode.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -94,10 +94,10 @@ public: static SharedHandle<DHTBucket> findBucketFor(BNode* b, const unsigned char* key); static void findClosestKNodes(std::deque<SharedHandle<DHTNode> >& nodes, - BNode* b, const unsigned char* key); + BNode* b, const unsigned char* key); static void enumerateBucket(std::deque<SharedHandle<DHTBucket> >& buckets, - const BNode* b); + const BNode* b); }; } // namespace aria2 diff --git a/src/Base64.cc b/src/Base64.cc index 5a19185c..407ecb49 100644 --- a/src/Base64.cc +++ b/src/Base64.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -67,7 +67,7 @@ static const int INDEX_TABLE[] = { }; void Base64::encode(unsigned char*& result, size_t& rlength, - const unsigned char* src, size_t slength) + const unsigned char* src, size_t slength) { if(slength == 0) { rlength = 0; @@ -107,9 +107,9 @@ void Base64::encode(unsigned char*& result, size_t& rlength, } void Base64::removeNonBase64Chars(unsigned char*& nsrc, - size_t& nlength, - const unsigned char* src, - size_t slength) + size_t& nlength, + const unsigned char* src, + size_t slength) { unsigned char* temp = new unsigned char[slength]; const unsigned char* end = src+slength; @@ -124,7 +124,7 @@ void Base64::removeNonBase64Chars(unsigned char*& nsrc, } void Base64::decode(unsigned char*& result, size_t& rlength, - const unsigned char* src, size_t slength) + const unsigned char* src, size_t slength) { if(slength == 0) { rlength = 0; diff --git a/src/Base64.h b/src/Base64.h index 7c676c4a..408fa946 100644 --- a/src/Base64.h +++ b/src/Base64.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -47,7 +47,7 @@ private: * Caller must delete nsrc. */ static void removeNonBase64Chars(unsigned char*& nsrc, size_t& nlength, - const unsigned char* src, size_t slength); + const unsigned char* src, size_t slength); public: /** @@ -59,13 +59,13 @@ public: * A caller must deallocate the memory used by result. */ static void encode(unsigned char*& result, size_t& rlength, - const unsigned char* src, size_t slength); + const unsigned char* src, size_t slength); static void encode(unsigned char*& result, size_t& rlength, - const char* src, size_t slength) + const char* src, size_t slength) { encode(result, rlength, reinterpret_cast<const unsigned char*>(src), - slength); + slength); } static std::string encode(const std::string& s); @@ -80,13 +80,13 @@ public: * A caller must deallocate the memory used by result. */ static void decode(unsigned char*& result, size_t& rlength, - const unsigned char* src, size_t slength); + const unsigned char* src, size_t slength); static void decode(unsigned char*& result, size_t& rlength, - const char* src, size_t slength) + const char* src, size_t slength) { decode(result, rlength, reinterpret_cast<const unsigned char*>(src), - slength); + slength); } static std::string decode(const std::string& s); diff --git a/src/BinaryStream.h b/src/BinaryStream.h index 405da444..76107cbf 100644 --- a/src/BinaryStream.h +++ b/src/BinaryStream.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/BitfieldMan.cc b/src/BitfieldMan.cc index 94cec879..e0868193 100644 --- a/src/BitfieldMan.cc +++ b/src/BitfieldMan.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -153,8 +153,8 @@ BitfieldMan::getNthBitIndex(const unsigned char bitfield, size_t nth) const if(bitfield & mask) { nth--; if(nth == 0) { - index = 7-bs; - break; + index = 7-bs; + break; } } } @@ -163,8 +163,8 @@ BitfieldMan::getNthBitIndex(const unsigned char bitfield, size_t nth) const template<typename Array> bool BitfieldMan::getMissingIndexRandomly(size_t& index, - const Array& bitfield, - size_t bitfieldLength) const + const Array& bitfield, + size_t bitfieldLength) const { size_t byte = randomizer->getRandomNumber(bitfieldLength); for(size_t i = 0; i < bitfieldLength; ++i) { @@ -247,8 +247,8 @@ bool BitfieldMan::getFirstMissingIndex(size_t& index, const Array& bitfield, siz size_t tindex = i*8; for(size_t bi = 0; bi < 8 && tindex < blocks; ++bi, mask >>= 1, ++tindex) { if(bits & mask) { - index = tindex; - return true; + index = tindex; + return true; } } } @@ -272,7 +272,7 @@ bool BitfieldMan::getFirstMissingIndex(size_t& index) const { if(filterEnabled) { return getFirstMissingIndex(index, ~array(bitfield)&array(filterBitfield), - bitfieldLength); + bitfieldLength); } else { return getFirstMissingIndex(index, ~array(bitfield), bitfieldLength); } @@ -332,14 +332,14 @@ static bool getSparseMissingUnusedIndex size_t nextIndex = 0; while(nextIndex < blocks) { currentRange.startIndex = - getStartIndex(nextIndex, bitfield, blocks); + getStartIndex(nextIndex, bitfield, blocks); if(currentRange.startIndex == blocks) { - break; + break; } currentRange.endIndex = - getEndIndex(currentRange.startIndex, bitfield, blocks); + getEndIndex(currentRange.startIndex, bitfield, blocks); if(maxRange < currentRange) { - maxRange = currentRange; + maxRange = currentRange; } nextIndex = currentRange.endIndex; } @@ -401,8 +401,8 @@ bool BitfieldMan::getAllMissingIndexes(unsigned char* misbitfield, size_t len) } bool BitfieldMan::getAllMissingIndexes(unsigned char* misbitfield, size_t len, - const unsigned char* peerBitfield, - size_t peerBitfieldLength) const + const unsigned char* peerBitfield, + size_t peerBitfieldLength) const { assert(len == bitfieldLength); if(bitfieldLength != peerBitfieldLength) { @@ -420,9 +420,9 @@ bool BitfieldMan::getAllMissingIndexes(unsigned char* misbitfield, size_t len, } bool BitfieldMan::getAllMissingUnusedIndexes(unsigned char* misbitfield, - size_t len, - const unsigned char* peerBitfield, - size_t peerBitfieldLength) const + size_t len, + const unsigned char* peerBitfield, + size_t peerBitfieldLength) const { assert(len == bitfieldLength); if(bitfieldLength != peerBitfieldLength) { @@ -502,7 +502,7 @@ bool BitfieldMan::isFilteredAllBitSet() const { if(filterEnabled) { for(size_t i = 0; i < bitfieldLength; ++i) { if((bitfield[i]&filterBitfield[i]) != filterBitfield[i]) { - return false; + return false; } } return true; @@ -681,7 +681,7 @@ uint64_t BitfieldMan::getCompletedLength(bool useFilter) const { for(size_t i = 0; i < bitfieldLength; ++i) { temp[i] = bitfield[i]; if(filterEnabled) { - temp[i] &= filterBitfield[i]; + temp[i] &= filterBitfield[i]; } } } else { diff --git a/src/BitfieldMan.h b/src/BitfieldMan.h index 39b22c8d..ee0668bf 100644 --- a/src/BitfieldMan.h +++ b/src/BitfieldMan.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -67,14 +67,14 @@ private: template<typename Array> bool getMissingIndexRandomly(size_t& index, const Array& bitfield, - size_t bitfieldLength) const; + size_t bitfieldLength) const; template<typename Array> bool getFirstMissingIndex(size_t& index, const Array& bitfield, size_t bitfieldLength) const; template<typename Array> bool getAllMissingIndexes(std::deque<size_t>& indexes, - const Array& bitfield, - size_t bitfieldLength) const; + const Array& bitfield, + size_t bitfieldLength) const; bool setBitInternal(unsigned char* bitfield, size_t index, bool on); bool setFilterBit(size_t index); @@ -94,7 +94,7 @@ public: size_t startIndex; size_t endIndex; Range(size_t startIndex = 0, size_t endIndex = 0):startIndex(startIndex), - endIndex(endIndex) {} + endIndex(endIndex) {} size_t getSize() const { return endIndex-startIndex; @@ -177,13 +177,13 @@ public: * affected by filter */ bool getAllMissingIndexes(unsigned char* misbitfield, size_t mislen, - const unsigned char* bitfield, size_t len) const; + const unsigned char* bitfield, size_t len) const; /** * affected by filter */ bool getAllMissingUnusedIndexes(unsigned char* misbitfield, size_t mislen, - const unsigned char* bitfield, - size_t len) const; + const unsigned char* bitfield, + size_t len) const; /** * affected by filter */ diff --git a/src/BitfieldManFactory.cc b/src/BitfieldManFactory.cc index a0446e50..0e24d7d8 100644 --- a/src/BitfieldManFactory.cc +++ b/src/BitfieldManFactory.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/BitfieldManFactory.h b/src/BitfieldManFactory.h index 93a4b712..dbbc97a6 100644 --- a/src/BitfieldManFactory.h +++ b/src/BitfieldManFactory.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/BtAbortOutstandingRequestEvent.h b/src/BtAbortOutstandingRequestEvent.h index 257d41f6..309c2c01 100644 --- a/src/BtAbortOutstandingRequestEvent.h +++ b/src/BtAbortOutstandingRequestEvent.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/BtAllowedFastMessage.cc b/src/BtAllowedFastMessage.cc index 13086b6e..dd319006 100644 --- a/src/BtAllowedFastMessage.cc +++ b/src/BtAllowedFastMessage.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -51,7 +51,7 @@ void BtAllowedFastMessage::doReceivedAction() { if(!peer->isFastExtensionEnabled()) { throw DL_ABORT_EX (StringFormat("%s received while fast extension is disabled", - toString().c_str()).str()); + toString().c_str()).str()); } if(_metadataGetMode) { return; diff --git a/src/BtAllowedFastMessage.h b/src/BtAllowedFastMessage.h index ab22f0a7..792ea912 100644 --- a/src/BtAllowedFastMessage.h +++ b/src/BtAllowedFastMessage.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/BtAnnounce.cc b/src/BtAnnounce.cc index 3719e8eb..64976a26 100644 --- a/src/BtAnnounce.cc +++ b/src/BtAnnounce.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/BtAnnounce.h b/src/BtAnnounce.h index 32759758..4c25aa95 100644 --- a/src/BtAnnounce.h +++ b/src/BtAnnounce.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -93,7 +93,7 @@ public: * Processes the repsponse from the tracker. */ virtual void processAnnounceResponse(const unsigned char* trackerResponse, - size_t trackerResponseLength) = 0; + size_t trackerResponseLength) = 0; /** * Returns true if no more announce is needed. diff --git a/src/BtBitfieldMessage.cc b/src/BtBitfieldMessage.cc index 8ed83fe0..f46d22d8 100644 --- a/src/BtBitfieldMessage.cc +++ b/src/BtBitfieldMessage.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/BtBitfieldMessage.h b/src/BtBitfieldMessage.h index 2a05471e..77be14c3 100644 --- a/src/BtBitfieldMessage.h +++ b/src/BtBitfieldMessage.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -63,7 +63,7 @@ public: } BtBitfieldMessage(const unsigned char* bitfield, - size_t bitfieldLength):SimpleBtMessage(ID, NAME) + size_t bitfieldLength):SimpleBtMessage(ID, NAME) { init(); setBitfield(bitfield, bitfieldLength); diff --git a/src/BtBitfieldMessageValidator.h b/src/BtBitfieldMessageValidator.h index 710dcd7b..259cb1de 100644 --- a/src/BtBitfieldMessageValidator.h +++ b/src/BtBitfieldMessageValidator.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -47,15 +47,15 @@ private: size_t numPiece; public: BtBitfieldMessageValidator(const BtBitfieldMessage* message, - size_t numPiece): + size_t numPiece): message(message), numPiece(numPiece) {} virtual bool validate(Errors& error) { // TODO bittorrent::checkBitfield(message->getBitfield(), - message->getBitfieldLength(), - numPiece); + message->getBitfieldLength(), + numPiece); return true; } }; diff --git a/src/BtCancelMessage.cc b/src/BtCancelMessage.cc index ac8aee16..578c9192 100644 --- a/src/BtCancelMessage.cc +++ b/src/BtCancelMessage.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/BtCancelMessage.h b/src/BtCancelMessage.h index e78cb892..a44a4259 100644 --- a/src/BtCancelMessage.h +++ b/src/BtCancelMessage.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/BtCancelSendingPieceEvent.h b/src/BtCancelSendingPieceEvent.h index 0dabef74..78a7a2ee 100644 --- a/src/BtCancelSendingPieceEvent.h +++ b/src/BtCancelSendingPieceEvent.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/BtCheckIntegrityEntry.cc b/src/BtCheckIntegrityEntry.cc index a4f177bc..a5d1bf64 100644 --- a/src/BtCheckIntegrityEntry.cc +++ b/src/BtCheckIntegrityEntry.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -50,7 +50,7 @@ BtCheckIntegrityEntry::BtCheckIntegrityEntry(RequestGroup* requestGroup): BtCheckIntegrityEntry::~BtCheckIntegrityEntry() {} void BtCheckIntegrityEntry::onDownloadIncomplete(std::deque<Command*>& commands, - DownloadEngine* e) + DownloadEngine* e) { const SharedHandle<DiskAdaptor>& diskAdaptor = _requestGroup->getPieceStorage()->getDiskAdaptor(); @@ -66,7 +66,7 @@ void BtCheckIntegrityEntry::onDownloadIncomplete(std::deque<Command*>& commands, } void BtCheckIntegrityEntry::onDownloadFinished(std::deque<Command*>& commands, - DownloadEngine* e) + DownloadEngine* e) { // TODO Currently,when all the checksums // are valid, then aira2 goes to seeding mode. Sometimes it is better diff --git a/src/BtCheckIntegrityEntry.h b/src/BtCheckIntegrityEntry.h index 3a26d20e..f3f40ef4 100644 --- a/src/BtCheckIntegrityEntry.h +++ b/src/BtCheckIntegrityEntry.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -46,10 +46,10 @@ public: virtual ~BtCheckIntegrityEntry(); virtual void onDownloadFinished(std::deque<Command*>& commands, - DownloadEngine* e); + DownloadEngine* e); virtual void onDownloadIncomplete(std::deque<Command*>& commands, - DownloadEngine* e); + DownloadEngine* e); }; typedef SharedHandle<BtCheckIntegrityEntry> BtCheckIntegrityEntryHandle; diff --git a/src/BtChokeMessage.cc b/src/BtChokeMessage.cc index 606f94ed..45372924 100644 --- a/src/BtChokeMessage.cc +++ b/src/BtChokeMessage.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/BtChokeMessage.h b/src/BtChokeMessage.h index b3445e86..4b8db797 100644 --- a/src/BtChokeMessage.h +++ b/src/BtChokeMessage.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/BtChokingEvent.h b/src/BtChokingEvent.h index 22709e60..daa50bea 100644 --- a/src/BtChokingEvent.h +++ b/src/BtChokingEvent.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/BtConstants.h b/src/BtConstants.h index e9c40dcc..bc70685a 100644 --- a/src/BtConstants.h +++ b/src/BtConstants.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/BtDependency.cc b/src/BtDependency.cc index a7a11640..55058c67 100644 --- a/src/BtDependency.cc +++ b/src/BtDependency.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -51,7 +51,7 @@ namespace aria2 { BtDependency::BtDependency(const RequestGroupWeakHandle& dependant, - const RequestGroupHandle& dependee): + const RequestGroupHandle& dependee): _dependant(dependant), _dependee(dependee), _logger(LogFactory::getInstance()) {} @@ -68,41 +68,41 @@ bool BtDependency::resolve() context->setDir(_dependant->getDownloadContext()->getDir()); try { DiskAdaptorHandle diskAdaptor = - dependee->getPieceStorage()->getDiskAdaptor(); + dependee->getPieceStorage()->getDiskAdaptor(); diskAdaptor->openExistingFile(); std::string content = util::toString(diskAdaptor); if(dependee->getDownloadContext()->hasAttribute(bittorrent::BITTORRENT)) { - const BDE& attrs = - dependee->getDownloadContext()->getAttribute(bittorrent::BITTORRENT); - bittorrent::loadFromMemory - (bittorrent::metadata2Torrent(content, attrs), context, "default"); + const BDE& attrs = + dependee->getDownloadContext()->getAttribute(bittorrent::BITTORRENT); + bittorrent::loadFromMemory + (bittorrent::metadata2Torrent(content, attrs), context, "default"); } else { - bittorrent::loadFromMemory - (content, context, File(dependee->getFirstFilePath()).getBasename()); + bittorrent::loadFromMemory + (content, context, File(dependee->getFirstFilePath()).getBasename()); } if(context->getFileEntries().size() != - _dependant->getDownloadContext()->getFileEntries().size()) { - throw DL_ABORT_EX("The number of file in torrent doesn't match to" - " the dependent."); + _dependant->getDownloadContext()->getFileEntries().size()) { + throw DL_ABORT_EX("The number of file in torrent doesn't match to" + " the dependent."); } // Copy file path in _dependant's FileEntries to newly created // context's FileEntries to endorse the path structure of // _dependant. URIs and singleHostMultiConnection are also copied. for(std::vector<SharedHandle<FileEntry> >::const_iterator s = - _dependant->getDownloadContext()->getFileEntries().begin(), - d = context->getFileEntries().begin(); - d != context->getFileEntries().end(); ++s, ++d) { - (*d)->setPath((*s)->getPath()); - (*d)->addUris((*s)->getRemainingUris().begin(), - (*s)->getRemainingUris().end()); - if(!(*s)->isSingleHostMultiConnectionEnabled()) { - (*d)->disableSingleHostMultiConnection(); - } + _dependant->getDownloadContext()->getFileEntries().begin(), + d = context->getFileEntries().begin(); + d != context->getFileEntries().end(); ++s, ++d) { + (*d)->setPath((*s)->getPath()); + (*d)->addUris((*s)->getRemainingUris().begin(), + (*s)->getRemainingUris().end()); + if(!(*s)->isSingleHostMultiConnectionEnabled()) { + (*d)->disableSingleHostMultiConnection(); + } } } catch(RecoverableException& e) { _logger->error(EX_EXCEPTION_CAUGHT, e); _logger->info("BtDependency for GID#%d failed. Go without Bt.", - _dependant->getGID()); + _dependant->getGID()); return true; } _logger->debug("Dependency resolved for GID#%d", _dependant->getGID()); @@ -113,7 +113,7 @@ bool BtDependency::resolve() // cut reference here _dependee.reset(); _logger->debug("BtDependency for GID#%d failed. Go without Bt.", - _dependant->getGID()); + _dependant->getGID()); return true; } else { return false; diff --git a/src/BtDependency.h b/src/BtDependency.h index 8e61b408..a59424b8 100644 --- a/src/BtDependency.h +++ b/src/BtDependency.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -51,7 +51,7 @@ private: Logger* _logger; public: BtDependency(const WeakHandle<RequestGroup>& dependant, - const SharedHandle<RequestGroup>& dependee); + const SharedHandle<RequestGroup>& dependee); virtual ~BtDependency(); diff --git a/src/BtExtendedMessage.cc b/src/BtExtendedMessage.cc index 70a02f88..465593d1 100644 --- a/src/BtExtendedMessage.cc +++ b/src/BtExtendedMessage.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -99,14 +99,14 @@ std::string BtExtendedMessage::toString() const { BtExtendedMessageHandle BtExtendedMessage::create(const SharedHandle<ExtensionMessageFactory>& factory, - const PeerHandle& peer, - const unsigned char* data, size_t dataLength) + const PeerHandle& peer, + const unsigned char* data, size_t dataLength) { bittorrent::assertPayloadLengthGreater(1, dataLength, NAME); bittorrent::assertID(ID, data, NAME); assert(!factory.isNull()); ExtensionMessageHandle extmsg = factory->createMessage(data+1, - dataLength-1); + dataLength-1); BtExtendedMessageHandle message(new BtExtendedMessage(extmsg)); return message; } diff --git a/src/BtExtendedMessage.h b/src/BtExtendedMessage.h index fdec5f43..e780d20b 100644 --- a/src/BtExtendedMessage.h +++ b/src/BtExtendedMessage.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -54,7 +54,7 @@ private: size_t _msgLength; public: BtExtendedMessage(const SharedHandle<ExtensionMessage>& extensionMessage = - SharedHandle<ExtensionMessage>()); + SharedHandle<ExtensionMessage>()); virtual ~BtExtendedMessage(); @@ -63,10 +63,10 @@ public: static const std::string NAME; static BtExtendedMessageHandle create - (const SharedHandle<ExtensionMessageFactory>& factory, - const SharedHandle<Peer>& peer, - const unsigned char* data, - size_t dataLength); + (const SharedHandle<ExtensionMessageFactory>& factory, + const SharedHandle<Peer>& peer, + const unsigned char* data, + size_t dataLength); virtual void doReceivedAction(); diff --git a/src/BtFileAllocationEntry.cc b/src/BtFileAllocationEntry.cc index e730e92b..d5f66308 100644 --- a/src/BtFileAllocationEntry.cc +++ b/src/BtFileAllocationEntry.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -50,7 +50,7 @@ BtFileAllocationEntry::BtFileAllocationEntry(RequestGroup* requestGroup): BtFileAllocationEntry::~BtFileAllocationEntry() {} void BtFileAllocationEntry::prepareForNextAction(std::deque<Command*>& commands, - DownloadEngine* e) + DownloadEngine* e) { BtSetup().setup(commands, _requestGroup, e, _requestGroup->getOption().get()); if(!_requestGroup->downloadFinished()) { diff --git a/src/BtFileAllocationEntry.h b/src/BtFileAllocationEntry.h index 3a782672..61007219 100644 --- a/src/BtFileAllocationEntry.h +++ b/src/BtFileAllocationEntry.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -46,7 +46,7 @@ public: virtual ~BtFileAllocationEntry(); virtual void prepareForNextAction(std::deque<Command*>& commands, - DownloadEngine* e); + DownloadEngine* e); }; typedef SharedHandle<BtFileAllocationEntry> BtFileAllocationEntryHandle; diff --git a/src/BtHandshakeMessage.cc b/src/BtHandshakeMessage.cc index 61baab93..c2cf0cec 100644 --- a/src/BtHandshakeMessage.cc +++ b/src/BtHandshakeMessage.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -53,7 +53,7 @@ BtHandshakeMessage::BtHandshakeMessage():SimpleBtMessage(ID, NAME) } BtHandshakeMessage::BtHandshakeMessage(const unsigned char* infoHash, - const unsigned char* peerId): + const unsigned char* peerId): SimpleBtMessage(ID, NAME) { init(); @@ -106,9 +106,9 @@ size_t BtHandshakeMessage::getMessageLength() { std::string BtHandshakeMessage::toString() const { return strconcat(NAME, " peerId=", - util::urlencode(peerId, PEER_ID_LENGTH), - ", reserved=", - util::toHex(reserved, RESERVED_LENGTH)); + util::urlencode(peerId, PEER_ID_LENGTH), + ", reserved=", + util::toHex(reserved, RESERVED_LENGTH)); } bool BtHandshakeMessage::isFastExtensionSupported() const { diff --git a/src/BtHandshakeMessage.h b/src/BtHandshakeMessage.h index c8ac4ca7..17083d9d 100644 --- a/src/BtHandshakeMessage.h +++ b/src/BtHandshakeMessage.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/BtHandshakeMessageValidator.h b/src/BtHandshakeMessageValidator.h index 8e618650..a893d708 100644 --- a/src/BtHandshakeMessageValidator.h +++ b/src/BtHandshakeMessageValidator.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -51,7 +51,7 @@ private: unsigned char infoHash[20]; public: BtHandshakeMessageValidator(const BtHandshakeMessage* message, - const unsigned char* infoHash): + const unsigned char* infoHash): message(message) { memcpy(this->infoHash, infoHash, sizeof(this->infoHash)); @@ -61,18 +61,18 @@ public: // TODO if(message->getPstrlen() != 19) { throw DL_ABORT_EX(StringFormat("invalid handshake pstrlen=%u", - message->getPstrlen()).str()); + message->getPstrlen()).str()); } 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()); + (StringFormat("invalid handshake pstr=%s", + 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()); + (StringFormat("invalid handshake info hash: expected:%s, actual:%s", + util::toHex(infoHash, 20).c_str(), + util::toHex(message->getInfoHash(), 20).c_str()).str()); } return true; } diff --git a/src/BtHaveAllMessage.cc b/src/BtHaveAllMessage.cc index 8ccf7acc..05af1954 100644 --- a/src/BtHaveAllMessage.cc +++ b/src/BtHaveAllMessage.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -54,13 +54,13 @@ void BtHaveAllMessage::doReceivedAction() if(!peer->isFastExtensionEnabled()) { throw DL_ABORT_EX (StringFormat("%s received while fast extension is disabled", - toString().c_str()).str()); + toString().c_str()).str()); } if(_metadataGetMode) { return; } pieceStorage->subtractPieceStats(peer->getBitfield(), - peer->getBitfieldLength()); + peer->getBitfieldLength()); peer->setAllBitfield(); pieceStorage->addPieceStats(peer->getBitfield(), peer->getBitfieldLength()); if(peer->isSeeder() && pieceStorage->downloadFinished()) { diff --git a/src/BtHaveAllMessage.h b/src/BtHaveAllMessage.h index 537bf2de..97f9f103 100644 --- a/src/BtHaveAllMessage.h +++ b/src/BtHaveAllMessage.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/BtHaveMessage.cc b/src/BtHaveMessage.cc index d008dad6..c0877bb9 100644 --- a/src/BtHaveMessage.cc +++ b/src/BtHaveMessage.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/BtHaveMessage.h b/src/BtHaveMessage.h index 51087f2b..51c12e8c 100644 --- a/src/BtHaveMessage.h +++ b/src/BtHaveMessage.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/BtHaveNoneMessage.cc b/src/BtHaveNoneMessage.cc index 3c11c11b..2c6cd85d 100644 --- a/src/BtHaveNoneMessage.cc +++ b/src/BtHaveNoneMessage.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -52,7 +52,7 @@ void BtHaveNoneMessage::doReceivedAction() if(!peer->isFastExtensionEnabled()) { throw DL_ABORT_EX (StringFormat("%s received while fast extension is disabled", - toString().c_str()).str()); + toString().c_str()).str()); } } diff --git a/src/BtHaveNoneMessage.h b/src/BtHaveNoneMessage.h index 90a4619d..a1aaf74e 100644 --- a/src/BtHaveNoneMessage.h +++ b/src/BtHaveNoneMessage.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/BtInteractive.h b/src/BtInteractive.h index 938458da..7a4cea57 100644 --- a/src/BtInteractive.h +++ b/src/BtInteractive.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/BtInterestedMessage.cc b/src/BtInterestedMessage.cc index 0ee531ae..3ef69cf1 100644 --- a/src/BtInterestedMessage.cc +++ b/src/BtInterestedMessage.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/BtInterestedMessage.h b/src/BtInterestedMessage.h index 72bd2bf6..e3e90113 100644 --- a/src/BtInterestedMessage.h +++ b/src/BtInterestedMessage.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/BtKeepAliveMessage.cc b/src/BtKeepAliveMessage.cc index b59b9ebb..63cc6377 100644 --- a/src/BtKeepAliveMessage.cc +++ b/src/BtKeepAliveMessage.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/BtKeepAliveMessage.h b/src/BtKeepAliveMessage.h index bec16187..edc88e45 100644 --- a/src/BtKeepAliveMessage.h +++ b/src/BtKeepAliveMessage.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/BtLeecherStateChoke.cc b/src/BtLeecherStateChoke.cc index 03c6357d..1e780476 100644 --- a/src/BtLeecherStateChoke.cc +++ b/src/BtLeecherStateChoke.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -56,7 +56,7 @@ BtLeecherStateChoke::PeerEntry::PeerEntry _peer(peer), _downloadSpeed(peer->calculateDownloadSpeed(now)), // peer must be interested to us and sent block in the last 30 seconds _regularUnchoker(peer->peerInterested() && - !peer->getLastDownloadUpdate().elapsed(30)) {} + !peer->getLastDownloadUpdate().elapsed(30)) {} const SharedHandle<Peer>& BtLeecherStateChoke::PeerEntry::getPeer() const { @@ -123,14 +123,14 @@ void BtLeecherStateChoke::plannedOptimisticUnchoke (std::deque<PeerEntry>& peerEntries) { std::for_each(peerEntries.begin(), peerEntries.end(), - std::mem_fun_ref(&PeerEntry::disableOptUnchoking)); + std::mem_fun_ref(&PeerEntry::disableOptUnchoking)); std::deque<PeerEntry>::iterator i = std::partition(peerEntries.begin(), peerEntries.end(), - PeerFilter(true, true)); + PeerFilter(true, true)); if(i != peerEntries.begin()) { std::random_shuffle(peerEntries.begin(), i, - *(SimpleRandomizer::getInstance().get())); + *(SimpleRandomizer::getInstance().get())); (*peerEntries.begin()).enableOptUnchoking(); _logger->info("POU: %s", (*peerEntries.begin()).getPeer()->ipaddr.c_str()); } @@ -140,7 +140,7 @@ void BtLeecherStateChoke::regularUnchoke(std::deque<PeerEntry>& peerEntries) { std::deque<PeerEntry>::iterator rest = std::partition(peerEntries.begin(), peerEntries.end(), - std::mem_fun_ref(&PeerEntry::isRegularUnchoker)); + std::mem_fun_ref(&PeerEntry::isRegularUnchoker)); struct timeval now; gettimeofday(&now, 0); @@ -155,8 +155,8 @@ void BtLeecherStateChoke::regularUnchoke(std::deque<PeerEntry>& peerEntries) for(;peerIter != rest && count; ++peerIter, --count) { (*peerIter).disableChokingRequired(); _logger->info("RU: %s, dlspd=%u", - (*peerIter).getPeer()->ipaddr.c_str(), - (*peerIter).getDownloadSpeed()); + (*peerIter).getPeer()->ipaddr.c_str(), + (*peerIter).getDownloadSpeed()); if((*peerIter).getPeer()->optUnchoking()) { fastOptUnchoker = true; (*peerIter).disableOptUnchoking(); @@ -164,16 +164,16 @@ void BtLeecherStateChoke::regularUnchoke(std::deque<PeerEntry>& peerEntries) } if(fastOptUnchoker) { std::random_shuffle(peerIter, peerEntries.end(), - *(SimpleRandomizer::getInstance().get())); + *(SimpleRandomizer::getInstance().get())); for(std::deque<PeerEntry>::iterator i = peerIter; i != peerEntries.end(); - ++i) { + ++i) { if((*i).getPeer()->peerInterested()) { - (*i).enableOptUnchoking(); - _logger->info("OU: %s", (*i).getPeer()->ipaddr.c_str()); - break; + (*i).enableOptUnchoking(); + _logger->info("OU: %s", (*i).getPeer()->ipaddr.c_str()); + break; } else { - (*i).disableChokingRequired(); - _logger->info("OU: %s", (*i).getPeer()->ipaddr.c_str()); + (*i).disableChokingRequired(); + _logger->info("OU: %s", (*i).getPeer()->ipaddr.c_str()); } } } @@ -203,15 +203,15 @@ BtLeecherStateChoke::executeChoke(const std::deque<SharedHandle<Peer> >& peerSet std::deque<PeerEntry> peerEntries; std::transform(peerSet.begin(), peerSet.end(), - std::back_inserter(peerEntries), - BtLeecherStateChokeGenPeerEntry()); + std::back_inserter(peerEntries), + BtLeecherStateChokeGenPeerEntry()); peerEntries.erase(std::remove_if(peerEntries.begin(), peerEntries.end(), - std::mem_fun_ref(&PeerEntry::isSnubbing)), - peerEntries.end()); - + std::mem_fun_ref(&PeerEntry::isSnubbing)), + peerEntries.end()); + std::for_each(peerEntries.begin(), peerEntries.end(), - std::mem_fun_ref(&PeerEntry::enableChokingRequired)); + std::mem_fun_ref(&PeerEntry::enableChokingRequired)); // planned optimistic unchoke if(_round == 0) { diff --git a/src/BtLeecherStateChoke.h b/src/BtLeecherStateChoke.h index 80921ae0..21b37540 100644 --- a/src/BtLeecherStateChoke.h +++ b/src/BtLeecherStateChoke.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/BtMessage.h b/src/BtMessage.h index f1b5a581..1ac37429 100644 --- a/src/BtMessage.h +++ b/src/BtMessage.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/BtMessageDispatcher.h b/src/BtMessageDispatcher.h index 1d6c8cfe..ccd8d762 100644 --- a/src/BtMessageDispatcher.h +++ b/src/BtMessageDispatcher.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/BtMessageFactory.h b/src/BtMessageFactory.h index c89ee279..d95243ad 100644 --- a/src/BtMessageFactory.h +++ b/src/BtMessageFactory.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -57,7 +57,7 @@ public: virtual SharedHandle<BtHandshakeMessage> createHandshakeMessage(const unsigned char* infoHash, - const unsigned char* peerId) = 0; + const unsigned char* peerId) = 0; virtual SharedHandle<BtMessage> createRequestMessage(const SharedHandle<Piece>& piece, size_t blockIndex) = 0; diff --git a/src/BtMessageReceiver.h b/src/BtMessageReceiver.h index c77c37c5..861c77ef 100644 --- a/src/BtMessageReceiver.h +++ b/src/BtMessageReceiver.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/BtMessageValidator.h b/src/BtMessageValidator.h index 79e8cd7b..e95c6cee 100644 --- a/src/BtMessageValidator.h +++ b/src/BtMessageValidator.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/BtNotInterestedMessage.cc b/src/BtNotInterestedMessage.cc index 8d8b9352..37c6ab5b 100644 --- a/src/BtNotInterestedMessage.cc +++ b/src/BtNotInterestedMessage.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/BtNotInterestedMessage.h b/src/BtNotInterestedMessage.h index 630b9fac..98fa67ca 100644 --- a/src/BtNotInterestedMessage.h +++ b/src/BtNotInterestedMessage.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/BtPieceMessage.cc b/src/BtPieceMessage.cc index a31ebf58..635da861 100644 --- a/src/BtPieceMessage.cc +++ b/src/BtPieceMessage.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -81,8 +81,8 @@ void BtPieceMessage::doReceivedAction() { return; } RequestSlot slot = dispatcher->getOutstandingRequest(index, - begin, - blockLength); + begin, + blockLength); peer->updateDownloadLength(blockLength); if(!RequestSlot::isNull(slot)) { peer->snubbing(false); @@ -90,24 +90,24 @@ void BtPieceMessage::doReceivedAction() { PieceHandle piece = pieceStorage->getPiece(index); off_t offset = (off_t)index*_downloadContext->getPieceLength()+begin; logger->debug(MSG_PIECE_RECEIVED, - cuid, index, begin, blockLength, offset, slot.getBlockIndex()); + cuid, index, begin, blockLength, offset, slot.getBlockIndex()); pieceStorage->getDiskAdaptor()->writeData(block, blockLength, offset); piece->completeBlock(slot.getBlockIndex()); logger->debug(MSG_PIECE_BITFIELD, cuid, - util::toHex(piece->getBitfield(), - piece->getBitfieldLength()).c_str()); + util::toHex(piece->getBitfield(), + piece->getBitfieldLength()).c_str()); piece->updateHash(begin, block, blockLength); dispatcher->removeOutstandingRequest(slot); if(piece->pieceComplete()) { if(checkPieceHash(piece)) { - onNewPiece(piece); + onNewPiece(piece); } else { - onWrongPiece(piece); + onWrongPiece(piece); } } } else { logger->debug("CUID#%d - RequestSlot not found, index=%d, begin=%d", - cuid, index, begin); + cuid, index, begin); } } @@ -124,7 +124,7 @@ const unsigned char* BtPieceMessage::getMessageHeader() { */ msgHeader = new unsigned char[MESSAGE_HEADER_LENGTH]; bittorrent::createPeerMessageString(msgHeader, MESSAGE_HEADER_LENGTH, - 9+blockLength, ID); + 9+blockLength, ID); bittorrent::setIntParam(&msgHeader[5], index); bittorrent::setIntParam(&msgHeader[9], begin); } @@ -141,16 +141,16 @@ void BtPieceMessage::send() { } if(!sendingInProgress) { logger->info(MSG_SEND_PEER_MESSAGE, - cuid, peer->ipaddr.c_str(), peer->port, - toString().c_str()); + cuid, peer->ipaddr.c_str(), peer->port, + toString().c_str()); getMessageHeader(); peerConnection->sendMessage(msgHeader, getMessageHeaderLength()); off_t pieceDataOffset = (off_t)index*_downloadContext->getPieceLength()+begin; size_t writtenLength = sendPieceData(pieceDataOffset, blockLength); logger->debug("msglength = %lu bytes", - static_cast<unsigned long>(getMessageHeaderLength()+ - blockLength)); + static_cast<unsigned long>(getMessageHeaderLength()+ + blockLength)); peer->updateUploadLength(writtenLength); } else { ssize_t writtenLength = peerConnection->sendPendingData(); @@ -172,13 +172,13 @@ 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)); + util::itos(begin), ", length=", util::itos(blockLength)); } bool BtPieceMessage::checkPieceHash(const PieceHandle& piece) { if(piece->isHashCalculated()) { logger->debug("Hash is available!! index=%lu", - static_cast<unsigned long>(piece->getIndex())); + static_cast<unsigned long>(piece->getIndex())); return piece->getHashString()==_downloadContext->getPieceHash(piece->getIndex()); } else { @@ -224,15 +224,15 @@ void BtPieceMessage::onChokingEvent(const BtChokingEvent& event) !sendingInProgress && !peer->isInAmAllowedIndexSet(index)) { logger->debug(MSG_REJECT_PIECE_CHOKED, - cuid, - index, - begin, - blockLength); + cuid, + index, + begin, + blockLength); if(peer->isFastExtensionEnabled()) { BtMessageHandle rej = messageFactory->createRejectMessage(index, - begin, - blockLength); + begin, + blockLength); dispatcher->addMessageToQueue(rej); } invalidate = true; @@ -248,11 +248,11 @@ void BtPieceMessage::onCancelSendingPieceEvent begin == event.getBegin() && blockLength == event.getLength()) { logger->debug(MSG_REJECT_PIECE_CANCEL, - cuid, index, begin, blockLength); + cuid, index, begin, blockLength); if(peer->isFastExtensionEnabled()) { BtMessageHandle rej = messageFactory->createRejectMessage(index, - begin, - blockLength); + begin, + blockLength); dispatcher->addMessageToQueue(rej); } invalidate = true; diff --git a/src/BtPieceMessage.h b/src/BtPieceMessage.h index b87cc40b..2a337505 100644 --- a/src/BtPieceMessage.h +++ b/src/BtPieceMessage.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/BtPieceMessageValidator.h b/src/BtPieceMessageValidator.h index dd270fbf..dd3afd45 100644 --- a/src/BtPieceMessageValidator.h +++ b/src/BtPieceMessageValidator.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -48,8 +48,8 @@ private: size_t pieceLength; public: BtPieceMessageValidator(const BtPieceMessage* message, - size_t numPiece, - size_t pieceLength): + size_t numPiece, + size_t pieceLength): message(message), numPiece(numPiece), pieceLength(pieceLength) {} diff --git a/src/BtPortMessage.cc b/src/BtPortMessage.cc index 8baf0c0f..b62a05b9 100644 --- a/src/BtPortMessage.cc +++ b/src/BtPortMessage.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/BtPortMessage.h b/src/BtPortMessage.h index 45c8e22d..ca834bb1 100644 --- a/src/BtPortMessage.h +++ b/src/BtPortMessage.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/BtPostDownloadHandler.cc b/src/BtPostDownloadHandler.cc index 87d1db32..acf18bca 100644 --- a/src/BtPostDownloadHandler.cc +++ b/src/BtPostDownloadHandler.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -67,7 +67,7 @@ void BtPostDownloadHandler::getNextRequestGroups RequestGroup* requestGroup) { _logger->debug("Generating RequestGroups for Torrent file %s", - requestGroup->getFirstFilePath().c_str()); + requestGroup->getFirstFilePath().c_str()); std::string content; try { requestGroup->getPieceStorage()->getDiskAdaptor()->openExistingFile(); @@ -79,8 +79,8 @@ void BtPostDownloadHandler::getNextRequestGroups } std::deque<SharedHandle<RequestGroup> > newRgs; createRequestGroupForBitTorrent(newRgs, requestGroup->getOption(), - std::deque<std::string>(), - content); + std::deque<std::string>(), + content); requestGroup->followedBy(newRgs.begin(), newRgs.end()); groups.insert(groups.end(), newRgs.begin(), newRgs.end()); } diff --git a/src/BtPostDownloadHandler.h b/src/BtPostDownloadHandler.h index 0d05f925..b76374d1 100644 --- a/src/BtPostDownloadHandler.h +++ b/src/BtPostDownloadHandler.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -48,7 +48,7 @@ public: virtual void getNextRequestGroups(std::deque<SharedHandle<RequestGroup> >& groups, - RequestGroup* requestGroup); + RequestGroup* requestGroup); }; typedef SharedHandle<BtPostDownloadHandler> BtPostDownloadHandlerHandle; diff --git a/src/BtProgressInfoFile.h b/src/BtProgressInfoFile.h index 94b8c9c2..9c51c7f4 100644 --- a/src/BtProgressInfoFile.h +++ b/src/BtProgressInfoFile.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/BtRegistry.cc b/src/BtRegistry.cc index 2a94cafe..2a01a73d 100644 --- a/src/BtRegistry.cc +++ b/src/BtRegistry.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/BtRegistry.h b/src/BtRegistry.h index 3fc642ee..716fe6a8 100644 --- a/src/BtRegistry.h +++ b/src/BtRegistry.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -59,11 +59,11 @@ struct BtObject { SharedHandle<BtProgressInfoFile> _btProgressInfoFile; BtObject(const SharedHandle<DownloadContext>& downloadContext, - const SharedHandle<PieceStorage>& pieceStorage, - const SharedHandle<PeerStorage>& peerStorage, - const SharedHandle<BtAnnounce>& btAnnounce, - const SharedHandle<BtRuntime>& btRuntime, - const SharedHandle<BtProgressInfoFile>& btProgressInfoFile): + const SharedHandle<PieceStorage>& pieceStorage, + const SharedHandle<PeerStorage>& peerStorage, + const SharedHandle<BtAnnounce>& btAnnounce, + const SharedHandle<BtRuntime>& btRuntime, + const SharedHandle<BtProgressInfoFile>& btProgressInfoFile): _downloadContext(downloadContext), _pieceStorage(pieceStorage), _peerStorage(peerStorage), @@ -102,7 +102,7 @@ public: OutputIterator getAllDownloadContext(OutputIterator dest) { for(std::map<int32_t, BtObject>::const_iterator i = _pool.begin(); - i != _pool.end(); ++i) { + i != _pool.end(); ++i) { *dest++ = (*i).second._downloadContext; } return dest; diff --git a/src/BtRejectMessage.cc b/src/BtRejectMessage.cc index d3e95c70..d6c3a0ad 100644 --- a/src/BtRejectMessage.cc +++ b/src/BtRejectMessage.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -54,7 +54,7 @@ void BtRejectMessage::doReceivedAction() if(!peer->isFastExtensionEnabled()) { throw DL_ABORT_EX (StringFormat("%s received while fast extension is disabled.", - toString().c_str()).str()); + toString().c_str()).str()); } if(_metadataGetMode) { return; diff --git a/src/BtRejectMessage.h b/src/BtRejectMessage.h index 222a18d1..eabe9627 100644 --- a/src/BtRejectMessage.h +++ b/src/BtRejectMessage.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/BtRequestFactory.h b/src/BtRequestFactory.h index 3e4b2282..0c1163fb 100644 --- a/src/BtRequestFactory.h +++ b/src/BtRequestFactory.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/BtRequestMessage.cc b/src/BtRequestMessage.cc index 3a0569f2..3a6b98f7 100644 --- a/src/BtRequestMessage.cc +++ b/src/BtRequestMessage.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -58,14 +58,14 @@ void BtRequestMessage::doReceivedAction() (!peer->amChoking() || (peer->amChoking() && peer->isInAmAllowedIndexSet(getIndex())))) { BtMessageHandle msg = messageFactory->createPieceMessage(getIndex(), - getBegin(), - getLength()); + getBegin(), + getLength()); dispatcher->addMessageToQueue(msg); } else { if(peer->isFastExtensionEnabled()) { BtMessageHandle msg = messageFactory->createRejectMessage(getIndex(), - getBegin(), - getLength()); + getBegin(), + getLength()); dispatcher->addMessageToQueue(msg); } } @@ -74,7 +74,7 @@ void BtRequestMessage::doReceivedAction() void BtRequestMessage::onQueued() { RequestSlot requestSlot(getIndex(), getBegin(), getLength(), _blockIndex, - pieceStorage->getPiece(getIndex())); + pieceStorage->getPiece(getIndex())); dispatcher->addOutstandingRequest(requestSlot); } diff --git a/src/BtRequestMessage.h b/src/BtRequestMessage.h index 3dad0e9b..1f042708 100644 --- a/src/BtRequestMessage.h +++ b/src/BtRequestMessage.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -49,9 +49,9 @@ private: public: BtRequestMessage(size_t index = 0, - uint32_t begin = 0, - uint32_t length = 0, - size_t blockIndex = 0) + uint32_t begin = 0, + uint32_t length = 0, + size_t blockIndex = 0) :RangeBtMessage(ID, NAME, index, begin, length), _blockIndex(blockIndex) {} diff --git a/src/BtRuntime.h b/src/BtRuntime.h index 9fb4f45a..552d59cb 100644 --- a/src/BtRuntime.h +++ b/src/BtRuntime.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/BtSeederStateChoke.cc b/src/BtSeederStateChoke.cc index 94915260..1af79eca 100644 --- a/src/BtSeederStateChoke.cc +++ b/src/BtSeederStateChoke.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -57,7 +57,7 @@ BtSeederStateChoke::PeerEntry::PeerEntry _lastAmUnchoking(peer->getLastAmUnchoking()), _recentUnchoking(!_lastAmUnchoking.elapsed(TIME_FRAME)), _uploadSpeed(peer->calculateUploadSpeed(now)) - {} +{} bool BtSeederStateChoke::PeerEntry::operator<(const PeerEntry& rhs) const @@ -93,15 +93,15 @@ void BtSeederStateChoke::unchoke for(; r != peers.end() && count; ++r, --count) { (*r).getPeer()->chokingRequired(false); _logger->info("RU: %s, ulspd=%u", (*r).getPeer()->ipaddr.c_str(), - (*r).getUploadSpeed()); + (*r).getUploadSpeed()); } if(_round < 2) { std::for_each(peers.begin(), peers.end(), - std::mem_fun_ref(&PeerEntry::disableOptUnchoking)); + std::mem_fun_ref(&PeerEntry::disableOptUnchoking)); if(r != peers.end()) { std::random_shuffle(r, peers.end(), - *(SimpleRandomizer::getInstance().get())); + *(SimpleRandomizer::getInstance().get())); (*r).getPeer()->optUnchoking(true); _logger->info("POU: %s", (*r).getPeer()->ipaddr.c_str()); } @@ -150,11 +150,11 @@ BtSeederStateChoke::executeChoke(const std::deque<SharedHandle<Peer> >& peerSet) std::for_each(peerSet.begin(), peerSet.end(), ChokingRequired()); std::transform(peerSet.begin(), peerSet.end(), - std::back_inserter(peerEntries), GenPeerEntry()); - + std::back_inserter(peerEntries), GenPeerEntry()); + peerEntries.erase(std::remove_if(peerEntries.begin(), peerEntries.end(), - NotInterestedPeer()), - peerEntries.end()); + NotInterestedPeer()), + peerEntries.end()); unchoke(peerEntries); diff --git a/src/BtSeederStateChoke.h b/src/BtSeederStateChoke.h index 2a777cad..edf7e04f 100644 --- a/src/BtSeederStateChoke.h +++ b/src/BtSeederStateChoke.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/BtSetup.cc b/src/BtSetup.cc index 1ebb7476..df59fbcf 100644 --- a/src/BtSetup.cc +++ b/src/BtSetup.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -66,9 +66,9 @@ namespace aria2 { BtSetup::BtSetup():_logger(LogFactory::getInstance()) {} void BtSetup::setup(std::deque<Command*>& commands, - RequestGroup* requestGroup, - DownloadEngine* e, - const Option* option) + RequestGroup* requestGroup, + DownloadEngine* e, + const Option* option) { if(!requestGroup->getDownloadContext()->hasAttribute(bittorrent::BITTORRENT)){ return; @@ -107,7 +107,7 @@ void BtSetup::setup(std::deque<Command*>& commands, c->setPieceStorage(pieceStorage); c->setPeerStorage(peerStorage); c->setBtAnnounce(btAnnounce); - + commands.push_back(c); } @@ -125,24 +125,24 @@ void BtSetup::setup(std::deque<Command*>& commands, SharedHandle<UnionSeedCriteria> unionCri(new UnionSeedCriteria()); if(option->defined(PREF_SEED_TIME)) { SharedHandle<SeedCriteria> cri - (new TimeSeedCriteria(option->getAsInt(PREF_SEED_TIME)*60)); + (new TimeSeedCriteria(option->getAsInt(PREF_SEED_TIME)*60)); unionCri->addSeedCriteria(cri); } { double ratio = option->getAsDouble(PREF_SEED_RATIO); if(ratio > 0.0) { - SharedHandle<ShareRatioSeedCriteria> cri - (new ShareRatioSeedCriteria(option->getAsDouble(PREF_SEED_RATIO), - requestGroup->getDownloadContext())); - cri->setPieceStorage(pieceStorage); - cri->setPeerStorage(peerStorage); + SharedHandle<ShareRatioSeedCriteria> cri + (new ShareRatioSeedCriteria(option->getAsDouble(PREF_SEED_RATIO), + requestGroup->getDownloadContext())); + cri->setPieceStorage(pieceStorage); + cri->setPeerStorage(peerStorage); - unionCri->addSeedCriteria(cri); + unionCri->addSeedCriteria(cri); } } if(unionCri->getSeedCriterion().size() > 0) { SeedCheckCommand* c = - new SeedCheckCommand(e->newCUID(), requestGroup, e, unionCri); + new SeedCheckCommand(e->newCUID(), requestGroup, e, unionCri); c->setPieceStorage(pieceStorage); c->setBtRuntime(btRuntime); commands.push_back(c); diff --git a/src/BtSetup.h b/src/BtSetup.h index ecc26898..4bf79524 100644 --- a/src/BtSetup.h +++ b/src/BtSetup.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -53,9 +53,9 @@ public: BtSetup(); void setup(std::deque<Command*>& commands, - RequestGroup* requestGroup, - DownloadEngine* e, - const Option* option); + RequestGroup* requestGroup, + DownloadEngine* e, + const Option* option); }; } // namespace aria2 diff --git a/src/BtStopDownloadCommand.cc b/src/BtStopDownloadCommand.cc index 9233c872..35de48e9 100644 --- a/src/BtStopDownloadCommand.cc +++ b/src/BtStopDownloadCommand.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -59,7 +59,7 @@ void BtStopDownloadCommand::preProcess() } if(_checkPoint.elapsed(_timeout)) { logger->notice("GID#%d Stop downloading torrent due to" - " --bt-stop-timeout option.", _requestGroup->getGID()); + " --bt-stop-timeout option.", _requestGroup->getGID()); _requestGroup->setHaltRequested(true); _exit = true; } diff --git a/src/BtStopDownloadCommand.h b/src/BtStopDownloadCommand.h index d1b850c8..23449bc4 100644 --- a/src/BtStopDownloadCommand.h +++ b/src/BtStopDownloadCommand.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/BtSuggestPieceMessage.cc b/src/BtSuggestPieceMessage.cc index 4e9cedb8..8485486c 100644 --- a/src/BtSuggestPieceMessage.cc +++ b/src/BtSuggestPieceMessage.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/BtSuggestPieceMessage.h b/src/BtSuggestPieceMessage.h index 820be287..d464c301 100644 --- a/src/BtSuggestPieceMessage.h +++ b/src/BtSuggestPieceMessage.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/BtUnchokeMessage.cc b/src/BtUnchokeMessage.cc index f54bcd35..e60a637b 100644 --- a/src/BtUnchokeMessage.cc +++ b/src/BtUnchokeMessage.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/BtUnchokeMessage.h b/src/BtUnchokeMessage.h index 0691017f..be533021 100644 --- a/src/BtUnchokeMessage.h +++ b/src/BtUnchokeMessage.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/ByteArrayDiskWriter.cc b/src/ByteArrayDiskWriter.cc index 5849142b..11c58880 100644 --- a/src/ByteArrayDiskWriter.cc +++ b/src/ByteArrayDiskWriter.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/ByteArrayDiskWriter.h b/src/ByteArrayDiskWriter.h index a3ed00a5..6f24cca2 100644 --- a/src/ByteArrayDiskWriter.h +++ b/src/ByteArrayDiskWriter.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/ByteArrayDiskWriterFactory.cc b/src/ByteArrayDiskWriterFactory.cc index a252ec79..495488e4 100644 --- a/src/ByteArrayDiskWriterFactory.cc +++ b/src/ByteArrayDiskWriterFactory.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/ByteArrayDiskWriterFactory.h b/src/ByteArrayDiskWriterFactory.h index 4ec4277e..882a2d5a 100644 --- a/src/ByteArrayDiskWriterFactory.h +++ b/src/ByteArrayDiskWriterFactory.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/CUIDCounter.h b/src/CUIDCounter.h index ab6097f7..0c00a2ae 100644 --- a/src/CUIDCounter.h +++ b/src/CUIDCounter.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/CheckIntegrityCommand.cc b/src/CheckIntegrityCommand.cc index c3c0ca73..29fc8b75 100644 --- a/src/CheckIntegrityCommand.cc +++ b/src/CheckIntegrityCommand.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -66,13 +66,13 @@ bool CheckIntegrityCommand::executeInternal() _requestGroup->enableSaveControlFile(); if(_requestGroup->downloadFinished()) { logger->notice(MSG_VERIFICATION_SUCCESSFUL, - _requestGroup->getDownloadContext()->getBasePath().c_str()); + _requestGroup->getDownloadContext()->getBasePath().c_str()); std::deque<Command*> commands; _entry->onDownloadFinished(commands, _e); _e->addCommand(commands); } else { logger->error(MSG_VERIFICATION_FAILED, - _requestGroup->getDownloadContext()->getBasePath().c_str()); + _requestGroup->getDownloadContext()->getBasePath().c_str()); std::deque<Command*> commands; _entry->onDownloadIncomplete(commands,_e); _e->addCommand(commands); @@ -90,7 +90,7 @@ bool CheckIntegrityCommand::handleException(Exception& e) _e->_checkIntegrityMan->dropPickedEntry(); logger->error(MSG_FILE_VALIDATION_FAILURE, e, cuid); logger->error(MSG_DOWNLOAD_NOT_COMPLETE, - cuid, _requestGroup->getDownloadContext()->getBasePath().c_str()); + cuid, _requestGroup->getDownloadContext()->getBasePath().c_str()); return true; } diff --git a/src/CheckIntegrityCommand.h b/src/CheckIntegrityCommand.h index 4cf1378b..7eeab09e 100644 --- a/src/CheckIntegrityCommand.h +++ b/src/CheckIntegrityCommand.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -49,9 +49,9 @@ private: Time _timer; public: CheckIntegrityCommand(int32_t cuid, - RequestGroup* requestGroup, - DownloadEngine* e, - const SharedHandle<CheckIntegrityEntry>& entry); + RequestGroup* requestGroup, + DownloadEngine* e, + const SharedHandle<CheckIntegrityEntry>& entry); virtual ~CheckIntegrityCommand(); diff --git a/src/CheckIntegrityDispatcherCommand.cc b/src/CheckIntegrityDispatcherCommand.cc index ceec1f4a..ccc9c5f3 100644 --- a/src/CheckIntegrityDispatcherCommand.cc +++ b/src/CheckIntegrityDispatcherCommand.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -45,7 +45,7 @@ CheckIntegrityDispatcherCommand::CheckIntegrityDispatcherCommand (int32_t cuid, const SharedHandle<CheckIntegrityMan>& fileAllocMan, DownloadEngine* e):SequentialDispatcherCommand<CheckIntegrityEntry> - (cuid, fileAllocMan, e) + (cuid, fileAllocMan, e) { setStatusRealtime(); } @@ -55,7 +55,7 @@ Command* CheckIntegrityDispatcherCommand::createCommand { int32_t newCUID = _e->newCUID(); logger->info("CUID#%d - Dispatching CheckIntegrityCommand CUID#%d.", - cuid, newCUID); + cuid, newCUID); return new CheckIntegrityCommand (newCUID, entry->getRequestGroup(), _e, entry); } diff --git a/src/CheckIntegrityDispatcherCommand.h b/src/CheckIntegrityDispatcherCommand.h index 480f6851..5eeee085 100644 --- a/src/CheckIntegrityDispatcherCommand.h +++ b/src/CheckIntegrityDispatcherCommand.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/CheckIntegrityEntry.cc b/src/CheckIntegrityEntry.cc index 2d2eb569..34413ffb 100644 --- a/src/CheckIntegrityEntry.cc +++ b/src/CheckIntegrityEntry.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -46,7 +46,7 @@ namespace aria2 { CheckIntegrityEntry::CheckIntegrityEntry(RequestGroup* requestGroup, - Command* nextCommand): + Command* nextCommand): RequestGroupEntry(requestGroup, nextCommand) {} diff --git a/src/CheckIntegrityEntry.h b/src/CheckIntegrityEntry.h index a2991eb6..899d1728 100644 --- a/src/CheckIntegrityEntry.h +++ b/src/CheckIntegrityEntry.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -46,13 +46,13 @@ class DownloadEngine; class FileAllocationEntry; class CheckIntegrityEntry : public RequestGroupEntry, - public ProgressAwareEntry { + public ProgressAwareEntry { protected: SharedHandle<IteratableValidator> _validator; void proceedFileAllocation(std::deque<Command*>& commands, - const SharedHandle<FileAllocationEntry>& entry, - DownloadEngine* e); + const SharedHandle<FileAllocationEntry>& entry, + DownloadEngine* e); public: CheckIntegrityEntry(RequestGroup* requestGroup, Command* nextCommand = 0); @@ -71,10 +71,10 @@ public: virtual void initValidator() = 0; virtual void onDownloadFinished(std::deque<Command*>& commands, - DownloadEngine* e) = 0; + DownloadEngine* e) = 0; virtual void onDownloadIncomplete(std::deque<Command*>& commands, - DownloadEngine* e) = 0; + DownloadEngine* e) = 0; void cutTrailingGarbage(); }; diff --git a/src/CheckIntegrityMan.h b/src/CheckIntegrityMan.h index 4f5d0278..ceeba211 100644 --- a/src/CheckIntegrityMan.h +++ b/src/CheckIntegrityMan.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/Checksum.h b/src/Checksum.h index ed507cb8..31e66d07 100644 --- a/src/Checksum.h +++ b/src/Checksum.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/ChecksumCheckIntegrityEntry.cc b/src/ChecksumCheckIntegrityEntry.cc index 7a0897fa..64cf72a2 100644 --- a/src/ChecksumCheckIntegrityEntry.cc +++ b/src/ChecksumCheckIntegrityEntry.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -56,19 +56,19 @@ bool ChecksumCheckIntegrityEntry::isValidationReady() void ChecksumCheckIntegrityEntry::initValidator() { _validator.reset(new IteratableChecksumValidator - (_requestGroup->getDownloadContext(), - _requestGroup->getPieceStorage())); + (_requestGroup->getDownloadContext(), + _requestGroup->getPieceStorage())); _validator->init(); } void ChecksumCheckIntegrityEntry::onDownloadFinished(std::deque<Command*>& commands, - DownloadEngine* e) + DownloadEngine* e) {} void ChecksumCheckIntegrityEntry::onDownloadIncomplete(std::deque<Command*>& commands, - DownloadEngine* e) + DownloadEngine* e) {} } // namespace aria2 diff --git a/src/ChecksumCheckIntegrityEntry.h b/src/ChecksumCheckIntegrityEntry.h index a747183c..ae30b206 100644 --- a/src/ChecksumCheckIntegrityEntry.h +++ b/src/ChecksumCheckIntegrityEntry.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -51,10 +51,10 @@ public: virtual void initValidator(); virtual void onDownloadFinished(std::deque<Command*>& commands, - DownloadEngine* e); + DownloadEngine* e); virtual void onDownloadIncomplete(std::deque<Command*>& commands, - DownloadEngine* e); + DownloadEngine* e); }; } // namespace aria2 diff --git a/src/ChunkChecksum.h b/src/ChunkChecksum.h index 1387e47b..19b71eab 100644 --- a/src/ChunkChecksum.h +++ b/src/ChunkChecksum.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -52,14 +52,14 @@ public: ChunkChecksum():_checksumLength(0) {} ChunkChecksum(const std::string& algo, - const std::deque<std::string>& checksums, - size_t checksumLength): + const std::deque<std::string>& checksums, + size_t checksumLength): _algo(algo), _checksums(checksums), _checksumLength(checksumLength) {} bool validateChunk(const std::string& actualChecksum, - size_t checksumIndex) const + size_t checksumIndex) const { if(checksumIndex < _checksums.size()) { return actualChecksum == getChecksum(checksumIndex); diff --git a/src/ChunkedDecoder.cc b/src/ChunkedDecoder.cc index a18f3fd9..63cf8d09 100644 --- a/src/ChunkedDecoder.cc +++ b/src/ChunkedDecoder.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -90,20 +90,20 @@ std::string ChunkedDecoder::decode(const unsigned char* inbuf, size_t inlen) while(1) { if(_state == READ_SIZE) { if(readChunkSize(_chunkSize, _buf)) { - if(_chunkSize == 0) { - _state = STREAM_END; - break; - } else { - _state = READ_DATA; - } + if(_chunkSize == 0) { + _state = STREAM_END; + break; + } else { + _state = READ_DATA; + } } else { - break; + break; } } else if(_state == READ_DATA) { if(readData(outbuf, _chunkSize, _buf)) { - _state = READ_SIZE; + _state = READ_SIZE; } else { - break; + break; } } } diff --git a/src/ChunkedDecoder.h b/src/ChunkedDecoder.h index 6aa5d1f2..fc33dead 100644 --- a/src/ChunkedDecoder.h +++ b/src/ChunkedDecoder.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/Command.cc b/src/Command.cc index fd4821b2..03d4b66d 100644 --- a/src/Command.cc +++ b/src/Command.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -41,13 +41,13 @@ namespace aria2 { int32_t Command::uuidGen = 0; Command::Command(cuid_t cuid):uuid(uuidGen++), - status(STATUS_INACTIVE), - cuid(cuid), - logger(LogFactory::getInstance()), - _readEvent(false), - _writeEvent(false), - _errorEvent(false), - _hupEvent(false) {} + status(STATUS_INACTIVE), + cuid(cuid), + logger(LogFactory::getInstance()), + _readEvent(false), + _writeEvent(false), + _errorEvent(false), + _hupEvent(false) {} void Command::transitStatus() { diff --git a/src/Command.h b/src/Command.h index 07ee626d..e4bd42a9 100644 --- a/src/Command.h +++ b/src/Command.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/ConsoleStatCalc.cc b/src/ConsoleStatCalc.cc index 33eb508b..b46a21f1 100644 --- a/src/ConsoleStatCalc.cc +++ b/src/ConsoleStatCalc.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -91,7 +91,7 @@ static void printProgress o << "SEEDING" << "(" << "ratio:"; if(rg->getCompletedLength() > 0) { o << std::fixed << std::setprecision(1) - << ((stat.getAllTimeUploadLength()*10)/rg->getCompletedLength())/10.0; + << ((stat.getAllTimeUploadLength()*10)/rg->getCompletedLength())/10.0; } else { o << "--"; } @@ -100,15 +100,15 @@ static void printProgress #endif // ENABLE_BITTORRENT { o << "SIZE:" - << util::abbrevSize(rg->getCompletedLength()) - << "B" - << "/" - << util::abbrevSize(rg->getTotalLength()) - << "B"; + << util::abbrevSize(rg->getCompletedLength()) + << "B" + << "/" + << util::abbrevSize(rg->getTotalLength()) + << "B"; if(rg->getTotalLength() > 0) { - o << "(" - << 100*rg->getCompletedLength()/rg->getTotalLength() - << "%)"; + o << "(" + << 100*rg->getCompletedLength()/rg->getTotalLength() + << "%)"; } } o << " " @@ -159,11 +159,11 @@ public: const std::vector<SharedHandle<FileEntry> >& fileEntries = rg->getDownloadContext()->getFileEntries(); std::cout << "\n" - << "FILE: "; + << "FILE: "; writeFilePath(fileEntries.begin(), fileEntries.end(), - std::cout, rg->inMemoryDownload()); + std::cout, rg->inMemoryDownload()); std::cout << "\n" - << std::setfill(SEP_CHAR) << std::setw(_cols) << SEP_CHAR << "\n"; + << std::setfill(SEP_CHAR) << std::setw(_cols) << SEP_CHAR << "\n"; } }; @@ -183,13 +183,13 @@ static void printProgressSummary asctime_r(staticNowtmPtr, buf) != 0) { char* lfptr = strchr(buf, '\n'); if(lfptr) { - *lfptr = '\0'; + *lfptr = '\0'; } std::cout << " as of " << buf; } } std::cout << " *** " << "\n" - << std::setfill(SEP_CHAR) << std::setw(cols) << SEP_CHAR << "\n"; + << std::setfill(SEP_CHAR) << std::setw(cols) << SEP_CHAR << "\n"; std::for_each(groups.begin(), groups.end(), PrintSummary(cols, e)); } @@ -218,8 +218,8 @@ ConsoleStatCalc::calculateStat(const DownloadEngine* e) cols = size.ws_col; #ifdef __MINGW32__ if(cols > 0) { - // Windows terminal cannot handle at the end of line properly. - --cols; + // Windows terminal cannot handle at the end of line properly. + --cols; } #endif // __MINGW32__ } @@ -241,8 +241,8 @@ ConsoleStatCalc::calculateStat(const DownloadEngine* e) if(e->_requestGroupMan->countRequestGroup() > 1) { o << "(" - << e->_requestGroupMan->countRequestGroup()-1 - << "more...)"; + << e->_requestGroupMan->countRequestGroup()-1 + << "more...)"; } } @@ -258,25 +258,25 @@ ConsoleStatCalc::calculateStat(const DownloadEngine* e) SharedHandle<FileAllocationEntry> entry=e->_fileAllocationMan->getPickedEntry(); if(!entry.isNull()) { o << " " - << "[FileAlloc:" - << "#" << entry->getRequestGroup()->getGID() << " " - << util::abbrevSize(entry->getCurrentLength()) - << "B" - << "/" - << util::abbrevSize(entry->getTotalLength()) - << "B" - << "("; + << "[FileAlloc:" + << "#" << entry->getRequestGroup()->getGID() << " " + << util::abbrevSize(entry->getCurrentLength()) + << "B" + << "/" + << util::abbrevSize(entry->getTotalLength()) + << "B" + << "("; if(entry->getTotalLength() > 0) { - o << 100*entry->getCurrentLength()/entry->getTotalLength(); + o << 100*entry->getCurrentLength()/entry->getTotalLength(); } else { - o << "--"; + o << "--"; } o << "%)" - << "]"; + << "]"; if(e->_fileAllocationMan->hasNext()) { - o << "(" - << e->_fileAllocationMan->countEntryInQueue() - << "waiting...)"; + o << "(" + << e->_fileAllocationMan->countEntryInQueue() + << "waiting...)"; } } } @@ -285,21 +285,21 @@ ConsoleStatCalc::calculateStat(const DownloadEngine* e) CheckIntegrityEntryHandle entry = e->_checkIntegrityMan->getPickedEntry(); if(!entry.isNull()) { o << " " - << "[Checksum:" - << "#" << entry->getRequestGroup()->getGID() << " " - << util::abbrevSize(entry->getCurrentLength()) - << "B" - << "/" - << util::abbrevSize(entry->getTotalLength()) - << "B" - << "(" - << 100*entry->getCurrentLength()/entry->getTotalLength() - << "%)" - << "]"; + << "[Checksum:" + << "#" << entry->getRequestGroup()->getGID() << " " + << util::abbrevSize(entry->getCurrentLength()) + << "B" + << "/" + << util::abbrevSize(entry->getTotalLength()) + << "B" + << "(" + << 100*entry->getCurrentLength()/entry->getTotalLength() + << "%)" + << "]"; if(e->_checkIntegrityMan->hasNext()) { - o << "(" - << e->_checkIntegrityMan->countEntryInQueue() - << "waiting...)"; + o << "(" + << e->_checkIntegrityMan->countEntryInQueue() + << "waiting...)"; } } } diff --git a/src/ConsoleStatCalc.h b/src/ConsoleStatCalc.h index a71149a7..fe4134a3 100644 --- a/src/ConsoleStatCalc.h +++ b/src/ConsoleStatCalc.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/ContentTypeRequestGroupCriteria.cc b/src/ContentTypeRequestGroupCriteria.cc index 8f726332..ec49b6a1 100644 --- a/src/ContentTypeRequestGroupCriteria.cc +++ b/src/ContentTypeRequestGroupCriteria.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -62,13 +62,13 @@ bool ContentTypeRequestGroupCriteria::match return false; } if(tailMatch(_extensions.begin(), _extensions.end(), - requestGroup->getFirstFilePath())) { + requestGroup->getFirstFilePath())) { return true; } else { return std::find(_contentTypes.begin(), _contentTypes.end(), - requestGroup->getDownloadContext()->getFirstFileEntry()-> - getContentType()) != _contentTypes.end(); + requestGroup->getDownloadContext()->getFirstFileEntry()-> + getContentType()) != _contentTypes.end(); } } diff --git a/src/ContentTypeRequestGroupCriteria.h b/src/ContentTypeRequestGroupCriteria.h index 6d1fa26a..4a20182f 100644 --- a/src/ContentTypeRequestGroupCriteria.h +++ b/src/ContentTypeRequestGroupCriteria.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -49,9 +49,9 @@ private: public: template<typename InputIterator> ContentTypeRequestGroupCriteria(InputIterator contentTypeFirst, - InputIterator contentTypeLast, - InputIterator extensionFirst, - InputIterator extensionLast): + InputIterator contentTypeLast, + InputIterator extensionFirst, + InputIterator extensionLast): _contentTypes(contentTypeFirst, contentTypeLast), _extensions(extensionFirst, extensionLast) {} diff --git a/src/Cookie.cc b/src/Cookie.cc index e541623d..ffd15edd 100644 --- a/src/Cookie.cc +++ b/src/Cookie.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -69,11 +69,11 @@ static std::string normalizeDomain(const std::string& domain) } Cookie::Cookie(const std::string& name, - const std::string& value, - time_t expiry, - const std::string& path, - const std::string& domain, - bool secure): + const std::string& value, + time_t expiry, + const std::string& path, + const std::string& domain, + bool secure): _name(name), _value(value), _expiry(expiry), @@ -82,10 +82,10 @@ Cookie::Cookie(const std::string& name, _secure(secure) {} Cookie::Cookie(const std::string& name, - const std::string& value, - const std::string& path, - const std::string& domain, - bool secure): + const std::string& value, + const std::string& path, + const std::string& domain, + bool secure): _name(name), _value(value), _expiry(0), @@ -117,14 +117,14 @@ static bool pathInclude(const std::string& requestPath, const std::string& path) return false; } } else if(*path.rbegin() != '/' || *requestPath.rbegin() == '/' || - !util::startsWith(requestPath+"/", path)) { + !util::startsWith(requestPath+"/", path)) { return false; } return true; } static bool domainMatch(const std::string& normReqHost, - const std::string& domain) + const std::string& domain) { // RFC2965 stated that: // @@ -139,8 +139,8 @@ static bool domainMatch(const std::string& normReqHost, } bool Cookie::match(const std::string& requestHost, - const std::string& requestPath, - time_t date, bool secure) const + const std::string& requestPath, + time_t date, bool secure) const { std::string normReqHost = normalizeDomain(requestHost); if((secure || (!_secure && !secure)) && diff --git a/src/Cookie.h b/src/Cookie.h index c355bfba..e88ebd25 100644 --- a/src/Cookie.h +++ b/src/Cookie.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -57,21 +57,21 @@ public: * If expires = 0 is given, then the cookie becomes session cookie. */ Cookie(const std::string& name, - const std::string& value, - time_t expires, - const std::string& path, - const std::string& domain, - bool secure); + const std::string& value, + time_t expires, + const std::string& path, + const std::string& domain, + bool secure); /* * Creates session cookie. This is equivalent to * Cookie(name, value, 0, path, domain, secure); */ Cookie(const std::string& name, - const std::string& value, - const std::string& path, - const std::string& domain, - bool secure); + const std::string& value, + const std::string& path, + const std::string& domain, + bool secure); Cookie(); @@ -82,10 +82,10 @@ public: bool good() const; bool match(const std::string& requestHost, const std::string& requestPath, - time_t date, bool secure) const; + time_t date, bool secure) const; bool validate(const std::string& requestHost, - const std::string& requestPath) const; + const std::string& requestPath) const; bool operator==(const Cookie& cookie) const; diff --git a/src/CookieParser.cc b/src/CookieParser.cc index 55112392..bf14af7b 100644 --- a/src/CookieParser.cc +++ b/src/CookieParser.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -88,9 +88,9 @@ Cookie CookieParser::parse(const std::string& cookieStr, const std::string& defa } } return Cookie(nameValue.first, nameValue.second, - expiry, - values[C_PATH], values[C_DOMAIN], - values.find(C_SECURE) != values.end()); + expiry, + values[C_PATH], values[C_DOMAIN], + values.find(C_SECURE) != values.end()); } diff --git a/src/CookieParser.h b/src/CookieParser.h index 651c8190..e67b6259 100644 --- a/src/CookieParser.h +++ b/src/CookieParser.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -50,7 +50,7 @@ public: ~CookieParser() {} Cookie parse(const std::string& cookieStr, const std::string& defaultDomain, - const std::string& defaultPath) const; + const std::string& defaultPath) const; Cookie parse(const std::string& cookieStr) const; diff --git a/src/CookieStorage.cc b/src/CookieStorage.cc index 793e6213..1dee23de 100644 --- a/src/CookieStorage.cc +++ b/src/CookieStorage.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -61,7 +61,7 @@ bool CookieStorage::store(const Cookie& cookie) return false; } std::deque<Cookie>::iterator i = std::find(_cookies.begin(), _cookies.end(), - cookie); + cookie); if(i == _cookies.end()) { if(cookie.isExpired()) { return false; @@ -87,8 +87,8 @@ void CookieStorage::storeCookies(const std::deque<Cookie>& cookies) } bool CookieStorage::parseAndStore(const std::string& setCookieString, - const std::string& requestHost, - const std::string& requestPath) + const std::string& requestHost, + const std::string& requestPath) { Cookie cookie = _parser.parse(setCookieString, requestHost, requestPath); if(cookie.validate(requestHost, requestPath)) { @@ -106,7 +106,7 @@ private: bool _secure; public: CriteriaMatch(const std::string& requestHost, const std::string& requestPath, - time_t date, bool secure): + time_t date, bool secure): _requestHost(requestHost), _requestPath(requestPath), _date(date), @@ -127,12 +127,12 @@ public: }; std::deque<Cookie> CookieStorage::criteriaFind(const std::string& requestHost, - const std::string& requestPath, - time_t date, bool secure) const + const std::string& requestPath, + time_t date, bool secure) const { std::deque<Cookie> res; std::remove_copy_if(_cookies.begin(), _cookies.end(), std::back_inserter(res), - std::not1(CriteriaMatch(requestHost, requestPath, date, secure))); + std::not1(CriteriaMatch(requestHost, requestPath, date, secure))); std::sort(res.begin(), res.end(), OrderByPathDesc()); return res; } @@ -153,7 +153,7 @@ bool CookieStorage::load(const std::string& filename) s.get(header, sizeof(header)); if(!s) { _logger->error("Failed to read header of cookie file %s", - filename.c_str()); + filename.c_str()); return false; } try { @@ -162,8 +162,8 @@ bool CookieStorage::load(const std::string& filename) storeCookies(Sqlite3MozCookieParser().parse(filename)); #else // !HAVE_SQLITE3 throw DL_ABORT_EX - ("Cannot read SQLite3 database because SQLite3 support is disabled by" - " configuration."); + ("Cannot read SQLite3 database because SQLite3 support is disabled by" + " configuration."); #endif // !HAVE_SQLITE3 } else { storeCookies(NsCookieParser().parse(filename)); @@ -182,22 +182,22 @@ bool CookieStorage::saveNsFormat(const std::string& filename) std::ofstream o(tempfilename.c_str(), std::ios::binary); if(!o) { _logger->error("Cannot create cookie file %s, cause %s", - filename.c_str(), strerror(errno)); + filename.c_str(), strerror(errno)); return false; } for(std::deque<Cookie>::const_iterator i = _cookies.begin(); - i != _cookies.end(); ++i) { + i != _cookies.end(); ++i) { o << (*i).toNsCookieFormat() << "\n"; if(!o) { - _logger->error("Failed to save cookies to %s, cause %s", - filename.c_str(), strerror(errno)); - return false; + _logger->error("Failed to save cookies to %s, cause %s", + filename.c_str(), strerror(errno)); + return false; } } o.flush(); if(!o) { _logger->error("Failed to save cookies to %s, cause %s", - filename.c_str(), strerror(errno)); + filename.c_str(), strerror(errno)); return false; } } @@ -205,7 +205,7 @@ bool CookieStorage::saveNsFormat(const std::string& filename) return true; } else { _logger->error("Could not rename file %s as %s", - tempfilename.c_str(), filename.c_str()); + tempfilename.c_str(), filename.c_str()); return false; } } diff --git a/src/CookieStorage.h b/src/CookieStorage.h index 0b0b1571..193d8d1e 100644 --- a/src/CookieStorage.h +++ b/src/CookieStorage.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -69,12 +69,12 @@ public: // Returns true if cookie is stored or updated existing cookie. // Otherwise, returns false. bool parseAndStore(const std::string& setCookieString, - const std::string& requestHost, - const std::string& requestPath); + const std::string& requestHost, + const std::string& requestPath); std::deque<Cookie> criteriaFind(const std::string& requestHost, - const std::string& requestPath, - time_t date, bool secure) const; + const std::string& requestPath, + time_t date, bool secure) const; // Loads Cookies from file denoted by filename. If compiled with // libsqlite3, this method automatically detects the specified file diff --git a/src/CreateRequestCommand.cc b/src/CreateRequestCommand.cc index f23bd192..bfcec970 100644 --- a/src/CreateRequestCommand.cc +++ b/src/CreateRequestCommand.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -50,8 +50,8 @@ namespace aria2 { CreateRequestCommand::CreateRequestCommand(int32_t cuid, - RequestGroup* requestGroup, - DownloadEngine* e): + RequestGroup* requestGroup, + DownloadEngine* e): AbstractCommand (cuid, SharedHandle<Request>(), SharedHandle<FileEntry>(), requestGroup, e) { @@ -75,14 +75,14 @@ bool CreateRequestCommand::executeInternal() _fileEntry->reuseUri(_requestGroup->getNumConcurrentCommand()); } req = _fileEntry->getRequest(_requestGroup->getURISelector(), - getOption()->get(PREF_REFERER), - // Don't use HEAD request when file - // size is known. - // Use HEAD for dry-run mode. - (_fileEntry->getLength() == 0 && - getOption()->getAsBool(PREF_USE_HEAD)) || - getOption()->getAsBool(PREF_DRY_RUN)? - Request::METHOD_HEAD:Request::METHOD_GET); + getOption()->get(PREF_REFERER), + // Don't use HEAD request when file + // size is known. + // Use HEAD for dry-run mode. + (_fileEntry->getLength() == 0 && + getOption()->getAsBool(PREF_USE_HEAD)) || + getOption()->getAsBool(PREF_DRY_RUN)? + Request::METHOD_HEAD:Request::METHOD_GET); if(req.isNull()) { if(!_requestGroup->getSegmentMan().isNull()) { _requestGroup->getSegmentMan()->ignoreSegmentFor(_fileEntry); diff --git a/src/CreateRequestCommand.h b/src/CreateRequestCommand.h index 12dd9aa6..0afe87b8 100644 --- a/src/CreateRequestCommand.h +++ b/src/CreateRequestCommand.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -42,8 +42,8 @@ namespace aria2 { class CreateRequestCommand:public AbstractCommand { public: CreateRequestCommand(int32_t cuid, - RequestGroup* requestGroup, - DownloadEngine* e); + RequestGroup* requestGroup, + DownloadEngine* e); protected: virtual bool executeInternal(); diff --git a/src/DHKeyExchange.h b/src/DHKeyExchange.h index 1cd5cf96..dde43f0b 100644 --- a/src/DHKeyExchange.h +++ b/src/DHKeyExchange.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/DHTAbstractMessage.cc b/src/DHTAbstractMessage.cc index f76bdc13..35d43392 100644 --- a/src/DHTAbstractMessage.cc +++ b/src/DHTAbstractMessage.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -47,8 +47,8 @@ namespace aria2 { DHTAbstractMessage::DHTAbstractMessage(const SharedHandle<DHTNode>& localNode, - const SharedHandle<DHTNode>& remoteNode, - const std::string& transactionID): + const SharedHandle<DHTNode>& remoteNode, + const std::string& transactionID): DHTMessage(localNode, remoteNode, transactionID) {} DHTAbstractMessage::~DHTAbstractMessage() {} diff --git a/src/DHTAbstractMessage.h b/src/DHTAbstractMessage.h index 113a32f0..8a2fb00e 100644 --- a/src/DHTAbstractMessage.h +++ b/src/DHTAbstractMessage.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -57,8 +57,8 @@ protected: WeakHandle<DHTRoutingTable> _routingTable; public: DHTAbstractMessage(const SharedHandle<DHTNode>& localNode, - const SharedHandle<DHTNode>& remoteNode, - const std::string& transactionID = A2STR::NIL); + const SharedHandle<DHTNode>& remoteNode, + const std::string& transactionID = A2STR::NIL); virtual ~DHTAbstractMessage(); diff --git a/src/DHTAbstractNodeLookupTask.cc b/src/DHTAbstractNodeLookupTask.cc index b38f2dbd..459074ce 100644 --- a/src/DHTAbstractNodeLookupTask.cc +++ b/src/DHTAbstractNodeLookupTask.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -67,13 +67,13 @@ void DHTAbstractNodeLookupTask::onReceived(const SharedHandle<DHTMessage>& messa size_t count = 0; for(std::deque<SharedHandle<DHTNodeLookupEntry> >::const_iterator i = - newEntries.begin(); i != newEntries.end(); ++i) { + newEntries.begin(); i != newEntries.end(); ++i) { if(memcmp(_localNode->getID(), (*i)->_node->getID(), DHT_ID_LENGTH) != 0) { _entries.push_front(*i); ++count; _logger->debug("Received nodes: id=%s, ip=%s", - util::toHex((*i)->_node->getID(), DHT_ID_LENGTH).c_str(), - (*i)->_node->getIPAddress().c_str()); + util::toHex((*i)->_node->getID(), DHT_ID_LENGTH).c_str(), + (*i)->_node->getIPAddress().c_str()); } } @@ -90,7 +90,7 @@ void DHTAbstractNodeLookupTask::onReceived(const SharedHandle<DHTMessage>& messa void DHTAbstractNodeLookupTask::onTimeout(const SharedHandle<DHTNode>& 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<SharedHandle<DHTNodeLookupEntry> >::iterator i = _entries.begin(); i != _entries.end(); ++i) { if((*i)->_node == node) { @@ -108,14 +108,14 @@ void DHTAbstractNodeLookupTask::sendMessageAndCheckFinish() } 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; } else { _logger->debug("%d in flight message for node ID %s", - _inFlightMessage, - util::toHex(_targetID, DHT_ID_LENGTH).c_str()); + _inFlightMessage, + util::toHex(_targetID, DHT_ID_LENGTH).c_str()); } } diff --git a/src/DHTAbstractNodeLookupTask.h b/src/DHTAbstractNodeLookupTask.h index ddae245b..8b53f9bc 100644 --- a/src/DHTAbstractNodeLookupTask.h +++ b/src/DHTAbstractNodeLookupTask.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -55,7 +55,7 @@ protected: size_t _inFlightMessage; void toEntries(std::deque<SharedHandle<DHTNodeLookupEntry> >& entries, - const std::deque<SharedHandle<DHTNode> >& nodes) const; + const std::deque<SharedHandle<DHTNode> >& nodes) const; void sendMessage(); @@ -74,7 +74,7 @@ public: virtual void onTimeout(const SharedHandle<DHTNode>& node); virtual void getNodesFromMessage(std::deque<SharedHandle<DHTNode> >& nodes, - const SharedHandle<DHTMessage>& message) = 0; + const SharedHandle<DHTMessage>& message) = 0; virtual void onReceivedInternal(const SharedHandle<DHTMessage>& message) {} diff --git a/src/DHTAbstractTask.cc b/src/DHTAbstractTask.cc index 3665d71e..dfddeb8d 100644 --- a/src/DHTAbstractTask.cc +++ b/src/DHTAbstractTask.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/DHTAbstractTask.h b/src/DHTAbstractTask.h index 82500763..06225e54 100644 --- a/src/DHTAbstractTask.h +++ b/src/DHTAbstractTask.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/DHTAnnouncePeerMessage.cc b/src/DHTAnnouncePeerMessage.cc index 6eaeb032..e0eda66e 100644 --- a/src/DHTAnnouncePeerMessage.cc +++ b/src/DHTAnnouncePeerMessage.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -61,11 +61,11 @@ const std::string DHTAnnouncePeerMessage::PORT("port"); const std::string DHTAnnouncePeerMessage::TOKEN("token"); DHTAnnouncePeerMessage::DHTAnnouncePeerMessage(const SharedHandle<DHTNode>& localNode, - const SharedHandle<DHTNode>& remoteNode, - const unsigned char* infoHash, - uint16_t tcpPort, - const std::string& token, - const std::string& transactionID): + const SharedHandle<DHTNode>& remoteNode, + const unsigned char* infoHash, + uint16_t tcpPort, + const std::string& token, + const std::string& transactionID): DHTQueryMessage(localNode, remoteNode, transactionID), _token(token), _tcpPort(tcpPort) @@ -78,7 +78,7 @@ DHTAnnouncePeerMessage::~DHTAnnouncePeerMessage() {} void DHTAnnouncePeerMessage::doReceivedAction() { _peerAnnounceStorage->addPeerAnnounce(_infoHash, _remoteNode->getIPAddress(), - _tcpPort); + _tcpPort); SharedHandle<DHTMessage> reply = _factory->createAnnouncePeerReplyMessage(_remoteNode, _transactionID); @@ -103,13 +103,13 @@ std::string DHTAnnouncePeerMessage::getMessageType() const void DHTAnnouncePeerMessage::validate() const { if(!_tokenTracker->validateToken(_token, _infoHash, - _remoteNode->getIPAddress(), - _remoteNode->getPort())) { + _remoteNode->getIPAddress(), + _remoteNode->getPort())) { throw DL_ABORT_EX (StringFormat("Invalid token=%s from %s:%u", - util::toHex(_token).c_str(), - _remoteNode->getIPAddress().c_str(), - _remoteNode->getPort()).str()); + util::toHex(_token).c_str(), + _remoteNode->getIPAddress().c_str(), + _remoteNode->getPort()).str()); } } @@ -126,8 +126,8 @@ void DHTAnnouncePeerMessage::setTokenTracker(const WeakHandle<DHTTokenTracker>& std::string DHTAnnouncePeerMessage::toStringOptional() const { return strconcat("token=", util::toHex(_token), - ", info_hash=", util::toHex(_infoHash, INFO_HASH_LENGTH), - ", tcpPort=", util::uitos(_tcpPort)); + ", info_hash=", util::toHex(_infoHash, INFO_HASH_LENGTH), + ", tcpPort=", util::uitos(_tcpPort)); } } // namespace aria2 diff --git a/src/DHTAnnouncePeerMessage.h b/src/DHTAnnouncePeerMessage.h index bc31d59a..a9ee5499 100644 --- a/src/DHTAnnouncePeerMessage.h +++ b/src/DHTAnnouncePeerMessage.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -59,11 +59,11 @@ protected: virtual std::string toStringOptional() const; public: DHTAnnouncePeerMessage(const SharedHandle<DHTNode>& localNode, - const SharedHandle<DHTNode>& remoteNode, - const unsigned char* infoHash, - uint16_t tcpPort, - const std::string& token, - const std::string& transactionID = A2STR::NIL); + const SharedHandle<DHTNode>& remoteNode, + const unsigned char* infoHash, + uint16_t tcpPort, + const std::string& token, + const std::string& transactionID = A2STR::NIL); virtual ~DHTAnnouncePeerMessage(); diff --git a/src/DHTAnnouncePeerReplyMessage.cc b/src/DHTAnnouncePeerReplyMessage.cc index 2a0fb472..b55890c6 100644 --- a/src/DHTAnnouncePeerReplyMessage.cc +++ b/src/DHTAnnouncePeerReplyMessage.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -41,8 +41,8 @@ namespace aria2 { const std::string DHTAnnouncePeerReplyMessage::ANNOUNCE_PEER("announce_peer"); DHTAnnouncePeerReplyMessage::DHTAnnouncePeerReplyMessage(const SharedHandle<DHTNode>& localNode, - const SharedHandle<DHTNode>& remoteNode, - const std::string& transactionID): + const SharedHandle<DHTNode>& remoteNode, + const std::string& transactionID): DHTResponseMessage(localNode, remoteNode, transactionID) {} DHTAnnouncePeerReplyMessage::~DHTAnnouncePeerReplyMessage() {} diff --git a/src/DHTAnnouncePeerReplyMessage.h b/src/DHTAnnouncePeerReplyMessage.h index 732e610e..d5e770e8 100644 --- a/src/DHTAnnouncePeerReplyMessage.h +++ b/src/DHTAnnouncePeerReplyMessage.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -42,8 +42,8 @@ namespace aria2 { class DHTAnnouncePeerReplyMessage:public DHTResponseMessage { public: DHTAnnouncePeerReplyMessage(const SharedHandle<DHTNode>& localNode, - const SharedHandle<DHTNode>& remoteNode, - const std::string& transactionID); + const SharedHandle<DHTNode>& remoteNode, + const std::string& transactionID); virtual ~DHTAnnouncePeerReplyMessage(); diff --git a/src/DHTAutoSaveCommand.cc b/src/DHTAutoSaveCommand.cc index c376bb3a..bbd222a3 100644 --- a/src/DHTAutoSaveCommand.cc +++ b/src/DHTAutoSaveCommand.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -88,13 +88,13 @@ void DHTAutoSaveCommand::save() if(!f.isFile()) { File dir(f.getDirname()); if(!dir.exists()) { - if(!dir.mkdirs()) { - logger->info(EX_MAKE_DIR, dir.getPath().c_str(), strerror(errno)); - return; - } + if(!dir.mkdirs()) { + logger->info(EX_MAKE_DIR, dir.getPath().c_str(), strerror(errno)); + return; + } } else if(!dir.isDir()) { - logger->info(EX_NOT_DIRECTORY, dir.getPath().c_str()); - return; + logger->info(EX_NOT_DIRECTORY, dir.getPath().c_str()); + return; } } } @@ -117,19 +117,19 @@ void DHTAutoSaveCommand::save() { std::ofstream o(tempFile.c_str(), std::ios::out|std::ios::binary); if(!o) { - throw DL_ABORT_EX - (StringFormat("Failed to save DHT routing table to %s. cause:%s", - dhtFile.c_str(), strerror(errno)).str()); + throw DL_ABORT_EX + (StringFormat("Failed to save DHT routing table to %s. cause:%s", + dhtFile.c_str(), strerror(errno)).str()); } serializer.serialize(o); } if(!File(tempFile).renameTo(dhtFile)) { logger->error("Cannot move file from %s to %s.", - tempFile.c_str(), dhtFile.c_str()); + tempFile.c_str(), dhtFile.c_str()); } } catch(RecoverableException& e) { logger->error("Exception caught while saving DHT routing table to %s", - e, dhtFile.c_str()); + e, dhtFile.c_str()); } } diff --git a/src/DHTAutoSaveCommand.h b/src/DHTAutoSaveCommand.h index 66b161b0..a1f5522f 100644 --- a/src/DHTAutoSaveCommand.h +++ b/src/DHTAutoSaveCommand.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/DHTBucket.cc b/src/DHTBucket.cc index e838b522..96e21918 100644 --- a/src/DHTBucket.cc +++ b/src/DHTBucket.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -50,8 +50,8 @@ namespace aria2 { DHTBucket::DHTBucket(size_t prefixLength, - const unsigned char* max, const unsigned char* min, - const SharedHandle<DHTNode>& localNode): + const unsigned char* max, const unsigned char* min, + const SharedHandle<DHTNode>& localNode): _prefixLength(prefixLength), _localNode(localNode), _logger(LogFactory::getInstance()) @@ -94,14 +94,14 @@ bool DHTBucket::isInRange(const unsigned char* nodeID) const // Returns true if nodeID is in [min, max] (inclusive). bool DHTBucket::isInRange(const unsigned char* nodeID, - const unsigned char* max, - const unsigned char* min) const + const unsigned char* max, + const unsigned char* min) const { return !std::lexicographical_compare(&nodeID[0], &nodeID[DHT_ID_LENGTH], - &min[0], &min[DHT_ID_LENGTH]) && + &min[0], &min[DHT_ID_LENGTH]) && !std::lexicographical_compare(&max[0], &max[DHT_ID_LENGTH], - &nodeID[0], &nodeID[DHT_ID_LENGTH]); + &nodeID[0], &nodeID[DHT_ID_LENGTH]); } bool DHTBucket::addNode(const SharedHandle<DHTNode>& node) @@ -114,11 +114,11 @@ bool DHTBucket::addNode(const SharedHandle<DHTNode>& node) return true; } else { if(_nodes.front()->isBad()) { - _nodes.erase(_nodes.begin()); - _nodes.push_back(node); - return true; + _nodes.erase(_nodes.begin()); + _nodes.push_back(node); + return true; } else { - return false; + return false; } } } else { @@ -188,7 +188,7 @@ SharedHandle<DHTBucket> DHTBucket::split() ++_prefixLength; SharedHandle<DHTBucket> rBucket(new DHTBucket(_prefixLength, - rMax, rMin, _localNode)); + rMax, rMin, _localNode)); std::deque<SharedHandle<DHTNode> > lNodes; for(std::deque<SharedHandle<DHTNode> >::iterator i = _nodes.begin(); @@ -202,13 +202,13 @@ SharedHandle<DHTBucket> DHTBucket::split() _nodes = lNodes; // TODO create toString() and use it. _logger->debug("New bucket. prefixLength=%u, Range:%s-%s", - static_cast<unsigned int>(rBucket->getPrefixLength()), - util::toHex(rBucket->getMinID(), DHT_ID_LENGTH).c_str(), - util::toHex(rBucket->getMaxID(), DHT_ID_LENGTH).c_str()); + static_cast<unsigned int>(rBucket->getPrefixLength()), + 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<unsigned int>(_prefixLength), - util::toHex(getMinID(), DHT_ID_LENGTH).c_str(), - util::toHex(getMaxID(), DHT_ID_LENGTH).c_str()); + static_cast<unsigned int>(_prefixLength), + util::toHex(getMinID(), DHT_ID_LENGTH).c_str(), + util::toHex(getMaxID(), DHT_ID_LENGTH).c_str()); return rBucket; } @@ -217,7 +217,7 @@ void DHTBucket::getGoodNodes(std::deque<SharedHandle<DHTNode> >& goodNodes) cons { goodNodes = _nodes; goodNodes.erase(std::remove_if(goodNodes.begin(), goodNodes.end(), - mem_fun_sh(&DHTNode::isBad)), goodNodes.end()); + mem_fun_sh(&DHTNode::isBad)), goodNodes.end()); } SharedHandle<DHTNode> DHTBucket::getNode(const unsigned char* nodeID, const std::string& ipaddr, uint16_t port) const diff --git a/src/DHTBucket.h b/src/DHTBucket.h index 57378b80..bd38e9fa 100644 --- a/src/DHTBucket.h +++ b/src/DHTBucket.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -70,13 +70,13 @@ private: Logger* _logger; bool isInRange(const unsigned char* nodeID, - const unsigned char* max, const unsigned char* min) const; + const unsigned char* max, const unsigned char* min) const; public: DHTBucket(const SharedHandle<DHTNode>& localNode); DHTBucket(size_t prefixLength, - const unsigned char* max, const unsigned char* min, - const SharedHandle<DHTNode>& localNode); + const unsigned char* max, const unsigned char* min, + const SharedHandle<DHTNode>& localNode); ~DHTBucket(); diff --git a/src/DHTBucketRefreshCommand.cc b/src/DHTBucketRefreshCommand.cc index e4923c10..41a51ea7 100644 --- a/src/DHTBucketRefreshCommand.cc +++ b/src/DHTBucketRefreshCommand.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/DHTBucketRefreshCommand.h b/src/DHTBucketRefreshCommand.h index 068ea268..d6056339 100644 --- a/src/DHTBucketRefreshCommand.h +++ b/src/DHTBucketRefreshCommand.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/DHTBucketRefreshTask.cc b/src/DHTBucketRefreshTask.cc index 47af91fc..31071e8c 100644 --- a/src/DHTBucketRefreshTask.cc +++ b/src/DHTBucketRefreshTask.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/DHTBucketRefreshTask.h b/src/DHTBucketRefreshTask.h index 24106da0..3f680d99 100644 --- a/src/DHTBucketRefreshTask.h +++ b/src/DHTBucketRefreshTask.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/DHTConnection.h b/src/DHTConnection.h index c2a8e8f6..5dac2a61 100644 --- a/src/DHTConnection.h +++ b/src/DHTConnection.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -45,10 +45,10 @@ public: virtual ~DHTConnection() {} virtual ssize_t receiveMessage(unsigned char* data, size_t len, - std::string& host, uint16_t& port) = 0; + std::string& host, uint16_t& port) = 0; virtual ssize_t sendMessage(const unsigned char* data, size_t len, - const std::string& host, uint16_t port) = 0; + const std::string& host, uint16_t port) = 0; }; } // namespace aria2 diff --git a/src/DHTConnectionImpl.cc b/src/DHTConnectionImpl.cc index 8668e202..8a882078 100644 --- a/src/DHTConnectionImpl.cc +++ b/src/DHTConnectionImpl.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -48,7 +48,7 @@ namespace aria2 { DHTConnectionImpl::DHTConnectionImpl():_socket(new SocketCore(SOCK_DGRAM)), - _logger(LogFactory::getInstance()) {} + _logger(LogFactory::getInstance()) {} DHTConnectionImpl::~DHTConnectionImpl() {} @@ -56,7 +56,7 @@ bool DHTConnectionImpl::bind(uint16_t& port, IntSequence& ports) { std::deque<int32_t> randPorts = ports.flush(); std::random_shuffle(randPorts.begin(), randPorts.end(), - *SimpleRandomizer::getInstance().get()); + *SimpleRandomizer::getInstance().get()); for(std::deque<int32_t>::const_iterator portItr = randPorts.begin(); portItr != randPorts.end(); ++portItr) { @@ -88,7 +88,7 @@ bool DHTConnectionImpl::bind(uint16_t& port) } ssize_t DHTConnectionImpl::receiveMessage(unsigned char* data, size_t len, - std::string& host, uint16_t& port) + std::string& host, uint16_t& port) { std::pair<std::string, uint16_t> remoteHost; ssize_t length = _socket->readDataFrom(data, len, remoteHost); @@ -102,7 +102,7 @@ ssize_t DHTConnectionImpl::receiveMessage(unsigned char* data, size_t len, } ssize_t DHTConnectionImpl::sendMessage(const unsigned char* data, size_t len, - const std::string& host, uint16_t port) + const std::string& host, uint16_t port) { return _socket->writeData(data, len, host, port); } diff --git a/src/DHTConnectionImpl.h b/src/DHTConnectionImpl.h index a46af47a..2e1b8713 100644 --- a/src/DHTConnectionImpl.h +++ b/src/DHTConnectionImpl.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -72,10 +72,10 @@ public: bool bind(uint16_t& port); virtual ssize_t receiveMessage(unsigned char* data, size_t len, - std::string& host, uint16_t& port); + std::string& host, uint16_t& port); virtual ssize_t sendMessage(const unsigned char* data, size_t len, - const std::string& host, uint16_t port); + const std::string& host, uint16_t port); const SharedHandle<SocketCore>& getSocket() const { diff --git a/src/DHTConstants.h b/src/DHTConstants.h index 16f1aea4..8f7e68a9 100644 --- a/src/DHTConstants.h +++ b/src/DHTConstants.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/DHTEntryPointNameResolveCommand.cc b/src/DHTEntryPointNameResolveCommand.cc index 9ff27565..f00f55b6 100644 --- a/src/DHTEntryPointNameResolveCommand.cc +++ b/src/DHTEntryPointNameResolveCommand.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -83,44 +83,44 @@ bool DHTEntryPointNameResolveCommand::execute() #ifdef ENABLE_ASYNC_DNS if(_e->option->getAsBool(PREF_ASYNC_DNS)) { while(_entryPoints.size()) { - std::string hostname = _entryPoints.front().first; - try { - if(resolveHostname(hostname, _resolver)) { - hostname = _resolver->getResolvedAddresses().front(); - std::pair<std::string, uint16_t> p(hostname, - _entryPoints.front().second); - _resolvedEntryPoints.push_back(p); - addPingTask(p); - } else { - _e->commands.push_back(this); - return false; - } - } catch(RecoverableException& e) { - logger->error(EX_EXCEPTION_CAUGHT, e); - } - _resolver->reset(); - _entryPoints.erase(_entryPoints.begin()); + std::string hostname = _entryPoints.front().first; + try { + if(resolveHostname(hostname, _resolver)) { + hostname = _resolver->getResolvedAddresses().front(); + std::pair<std::string, uint16_t> p(hostname, + _entryPoints.front().second); + _resolvedEntryPoints.push_back(p); + addPingTask(p); + } else { + _e->commands.push_back(this); + return false; + } + } catch(RecoverableException& e) { + logger->error(EX_EXCEPTION_CAUGHT, e); + } + _resolver->reset(); + _entryPoints.erase(_entryPoints.begin()); } } else #endif // ENABLE_ASYNC_DNS { - NameResolver res; - res.setSocktype(SOCK_DGRAM); - while(_entryPoints.size()) { - std::string hostname = _entryPoints.front().first; - try { - std::deque<std::string> addrs; - res.resolve(addrs, hostname); - - std::pair<std::string, uint16_t> p(addrs.front(), - _entryPoints.front().second); - _resolvedEntryPoints.push_back(p); - addPingTask(p); - } catch(RecoverableException& e) { - logger->error(EX_EXCEPTION_CAUGHT, e); - } - _entryPoints.erase(_entryPoints.begin()); - } + NameResolver res; + res.setSocktype(SOCK_DGRAM); + while(_entryPoints.size()) { + std::string hostname = _entryPoints.front().first; + try { + std::deque<std::string> addrs; + res.resolve(addrs, hostname); + + std::pair<std::string, uint16_t> p(addrs.front(), + _entryPoints.front().second); + _resolvedEntryPoints.push_back(p); + addPingTask(p); + } catch(RecoverableException& e) { + logger->error(EX_EXCEPTION_CAUGHT, e); + } + _entryPoints.erase(_entryPoints.begin()); + } } if(_bootstrapEnabled && _resolvedEntryPoints.size()) { _taskQueue->addPeriodicTask1(_taskFactory->createNodeLookupTask(_localNode->getID())); @@ -155,15 +155,15 @@ bool DHTEntryPointNameResolveCommand::resolveHostname return false; case AsyncNameResolver::STATUS_SUCCESS: logger->info(MSG_NAME_RESOLUTION_COMPLETE, cuid, - resolver->getHostname().c_str(), - resolver->getResolvedAddresses().front().c_str()); + resolver->getHostname().c_str(), + resolver->getResolvedAddresses().front().c_str()); return true; break; case AsyncNameResolver::STATUS_ERROR: throw DL_ABORT_EX (StringFormat(MSG_NAME_RESOLUTION_FAILED, cuid, - hostname.c_str(), - resolver->getError().c_str()).str()); + hostname.c_str(), + resolver->getError().c_str()).str()); default: return false; } diff --git a/src/DHTEntryPointNameResolveCommand.h b/src/DHTEntryPointNameResolveCommand.h index 4979402e..dadf2993 100644 --- a/src/DHTEntryPointNameResolveCommand.h +++ b/src/DHTEntryPointNameResolveCommand.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -77,7 +77,7 @@ private: #ifdef ENABLE_ASYNC_DNS bool resolveHostname(const std::string& hostname, - const SharedHandle<AsyncNameResolver>& resolver); + const SharedHandle<AsyncNameResolver>& resolver); void setNameResolverCheck(const SharedHandle<AsyncNameResolver>& resolver); @@ -86,7 +86,7 @@ private: public: DHTEntryPointNameResolveCommand(int32_t cuid, DownloadEngine* e, - const std::deque<std::pair<std:: string, uint16_t> >& entryPoints); + const std::deque<std::pair<std:: string, uint16_t> >& entryPoints); virtual ~DHTEntryPointNameResolveCommand(); diff --git a/src/DHTFindNodeMessage.cc b/src/DHTFindNodeMessage.cc index bd722044..26630b42 100644 --- a/src/DHTFindNodeMessage.cc +++ b/src/DHTFindNodeMessage.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -51,9 +51,9 @@ const std::string DHTFindNodeMessage::FIND_NODE("find_node"); const std::string DHTFindNodeMessage::TARGET_NODE("target"); DHTFindNodeMessage::DHTFindNodeMessage(const SharedHandle<DHTNode>& localNode, - const SharedHandle<DHTNode>& remoteNode, - const unsigned char* targetNodeID, - const std::string& transactionID): + const SharedHandle<DHTNode>& remoteNode, + const unsigned char* targetNodeID, + const std::string& transactionID): DHTQueryMessage(localNode, remoteNode, transactionID) { memcpy(_targetNodeID, targetNodeID, DHT_ID_LENGTH); diff --git a/src/DHTFindNodeMessage.h b/src/DHTFindNodeMessage.h index ea9e6de7..3ac651a3 100644 --- a/src/DHTFindNodeMessage.h +++ b/src/DHTFindNodeMessage.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -47,9 +47,9 @@ protected: virtual std::string toStringOptional() const; public: DHTFindNodeMessage(const SharedHandle<DHTNode>& localNode, - const SharedHandle<DHTNode>& remoteNode, - const unsigned char* targetNodeID, - const std::string& transactionID = A2STR::NIL); + const SharedHandle<DHTNode>& remoteNode, + const unsigned char* targetNodeID, + const std::string& transactionID = A2STR::NIL); virtual ~DHTFindNodeMessage(); diff --git a/src/DHTFindNodeReplyMessage.cc b/src/DHTFindNodeReplyMessage.cc index 64a78a0b..ee08d6d1 100644 --- a/src/DHTFindNodeReplyMessage.cc +++ b/src/DHTFindNodeReplyMessage.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -53,8 +53,8 @@ const std::string DHTFindNodeReplyMessage::FIND_NODE("find_node"); const std::string DHTFindNodeReplyMessage::NODES("nodes"); DHTFindNodeReplyMessage::DHTFindNodeReplyMessage(const SharedHandle<DHTNode>& localNode, - const SharedHandle<DHTNode>& remoteNode, - const std::string& transactionID): + const SharedHandle<DHTNode>& remoteNode, + const std::string& transactionID): DHTResponseMessage(localNode, remoteNode, transactionID) {} DHTFindNodeReplyMessage::~DHTFindNodeReplyMessage() {} @@ -76,12 +76,12 @@ BDE DHTFindNodeReplyMessage::getResponse() unsigned char buffer[DHTBucket::K*26]; // TODO if _closestKNodes.size() > DHTBucket::K ?? for(std::deque<SharedHandle<DHTNode> >::const_iterator i = - _closestKNodes.begin(); + _closestKNodes.begin(); i != _closestKNodes.end() && offset < DHTBucket::K*26; ++i) { SharedHandle<DHTNode> node = *i; memcpy(buffer+offset, node->getID(), DHT_ID_LENGTH); if(bittorrent::createcompact(buffer+20+offset, node->getIPAddress(), - node->getPort())) { + node->getPort())) { offset += 26; } } diff --git a/src/DHTFindNodeReplyMessage.h b/src/DHTFindNodeReplyMessage.h index 0749d0e7..58d952c3 100644 --- a/src/DHTFindNodeReplyMessage.h +++ b/src/DHTFindNodeReplyMessage.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -47,8 +47,8 @@ protected: virtual std::string toStringOptional() const; public: DHTFindNodeReplyMessage(const SharedHandle<DHTNode>& localNode, - const SharedHandle<DHTNode>& remoteNode, - const std::string& transactionID); + const SharedHandle<DHTNode>& remoteNode, + const std::string& transactionID); virtual ~DHTFindNodeReplyMessage(); diff --git a/src/DHTGetPeersCommand.cc b/src/DHTGetPeersCommand.cc index ee65dd84..01383763 100644 --- a/src/DHTGetPeersCommand.cc +++ b/src/DHTGetPeersCommand.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -50,8 +50,8 @@ namespace aria2 { DHTGetPeersCommand::DHTGetPeersCommand(int32_t cuid, - RequestGroup* requestGroup, - DownloadEngine* e): + RequestGroup* requestGroup, + DownloadEngine* e): Command(cuid), _requestGroup(requestGroup), _e(e), @@ -75,7 +75,7 @@ bool DHTGetPeersCommand::execute() ((_numRetry > 0 && _lastGetPeerTime.elapsed(RETRY_INTERVAL)) || _lastGetPeerTime.elapsed(GET_PEER_INTERVAL))) { logger->debug("Issuing PeerLookup for infoHash=%s", - bittorrent::getInfoHashString(_requestGroup->getDownloadContext()).c_str()); + bittorrent::getInfoHashString(_requestGroup->getDownloadContext()).c_str()); _task = _taskFactory->createPeerLookupTask (_requestGroup->getDownloadContext(), _btRuntime, _peerStorage); _taskQueue->addPeriodicTask2(_task); diff --git a/src/DHTGetPeersCommand.h b/src/DHTGetPeersCommand.h index dee0e21a..5cabf374 100644 --- a/src/DHTGetPeersCommand.h +++ b/src/DHTGetPeersCommand.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -77,7 +77,7 @@ private: Time _lastGetPeerTime; public: DHTGetPeersCommand(int32_t cuid, RequestGroup* requestGroup, - DownloadEngine* e); + DownloadEngine* e); virtual ~DHTGetPeersCommand(); diff --git a/src/DHTGetPeersMessage.cc b/src/DHTGetPeersMessage.cc index 0e814a42..66f1b845 100644 --- a/src/DHTGetPeersMessage.cc +++ b/src/DHTGetPeersMessage.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -54,9 +54,9 @@ const std::string DHTGetPeersMessage::GET_PEERS("get_peers"); const std::string DHTGetPeersMessage::INFO_HASH("info_hash"); DHTGetPeersMessage::DHTGetPeersMessage(const SharedHandle<DHTNode>& localNode, - const SharedHandle<DHTNode>& remoteNode, - const unsigned char* infoHash, - const std::string& transactionID): + const SharedHandle<DHTNode>& remoteNode, + const unsigned char* infoHash, + const std::string& transactionID): DHTQueryMessage(localNode, remoteNode, transactionID) { memcpy(_infoHash, infoHash, DHT_ID_LENGTH); @@ -67,8 +67,8 @@ DHTGetPeersMessage::~DHTGetPeersMessage() {} void DHTGetPeersMessage::doReceivedAction() { std::string token = _tokenTracker->generateToken(_infoHash, - _remoteNode->getIPAddress(), - _remoteNode->getPort()); + _remoteNode->getIPAddress(), + _remoteNode->getPort()); // Check to see localhost has the contents which has same infohash std::deque<SharedHandle<Peer> > peers; _peerAnnounceStorage->getPeers(peers, _infoHash); @@ -78,11 +78,11 @@ void DHTGetPeersMessage::doReceivedAction() _routingTable->getClosestKNodes(nodes, _infoHash); reply = _factory->createGetPeersReplyMessage(_remoteNode, nodes, token, - _transactionID); + _transactionID); } else { reply = _factory->createGetPeersReplyMessage(_remoteNode, peers, token, - _transactionID); + _transactionID); } _dispatcher->addMessageToQueue(reply); } diff --git a/src/DHTGetPeersMessage.h b/src/DHTGetPeersMessage.h index 16f283c6..32da011f 100644 --- a/src/DHTGetPeersMessage.h +++ b/src/DHTGetPeersMessage.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -55,9 +55,9 @@ protected: virtual std::string toStringOptional() const; public: DHTGetPeersMessage(const SharedHandle<DHTNode>& localNode, - const SharedHandle<DHTNode>& remoteNode, - const unsigned char* infoHash, - const std::string& transactionID = A2STR::NIL); + const SharedHandle<DHTNode>& remoteNode, + const unsigned char* infoHash, + const std::string& transactionID = A2STR::NIL); virtual ~DHTGetPeersMessage(); diff --git a/src/DHTGetPeersReplyMessage.cc b/src/DHTGetPeersReplyMessage.cc index 63aed379..39368ad9 100644 --- a/src/DHTGetPeersReplyMessage.cc +++ b/src/DHTGetPeersReplyMessage.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -59,9 +59,9 @@ const std::string DHTGetPeersReplyMessage::VALUES("values"); const std::string DHTGetPeersReplyMessage::NODES("nodes"); DHTGetPeersReplyMessage::DHTGetPeersReplyMessage(const SharedHandle<DHTNode>& localNode, - const SharedHandle<DHTNode>& remoteNode, - const std::string& token, - const std::string& transactionID): + const SharedHandle<DHTNode>& remoteNode, + const std::string& token, + const std::string& transactionID): DHTResponseMessage(localNode, remoteNode, transactionID), _token(token) {} @@ -81,13 +81,13 @@ BDE DHTGetPeersReplyMessage::getResponse() size_t offset = 0; unsigned char buffer[DHTBucket::K*26]; for(std::deque<SharedHandle<DHTNode> >::const_iterator i = - _closestKNodes.begin(); - i != _closestKNodes.end() && offset < DHTBucket::K*26; ++i) { + _closestKNodes.begin(); + i != _closestKNodes.end() && offset < DHTBucket::K*26; ++i) { SharedHandle<DHTNode> node = *i; memcpy(buffer+offset, node->getID(), DHT_ID_LENGTH); if(bittorrent::createcompact - (buffer+20+offset, node->getIPAddress(), node->getPort())) { - offset += 26; + (buffer+20+offset, node->getIPAddress(), node->getPort())) { + offset += 26; } } rDict[NODES] = BDE(buffer, offset); @@ -114,11 +114,11 @@ BDE DHTGetPeersReplyMessage::getResponse() static const size_t MAX_VALUES_SIZE = 100; BDE valuesList = BDE::list(); for(std::deque<SharedHandle<Peer> >::const_iterator i = _values.begin(); - i != _values.end() && valuesList.size() < MAX_VALUES_SIZE; ++i) { + i != _values.end() && valuesList.size() < MAX_VALUES_SIZE; ++i) { const SharedHandle<Peer>& peer = *i; unsigned char buffer[6]; if(bittorrent::createcompact(buffer, peer->ipaddr, peer->port)) { - valuesList << BDE(buffer, sizeof(buffer)); + valuesList << BDE(buffer, sizeof(buffer)); } } rDict[VALUES] = valuesList; @@ -146,8 +146,8 @@ void DHTGetPeersReplyMessage::setValues(const std::deque<SharedHandle<Peer> >& p std::string DHTGetPeersReplyMessage::toStringOptional() const { return strconcat("token=", util::toHex(_token), - ", values=", util::uitos(_values.size()), - ", nodes=", util::uitos(_closestKNodes.size())); + ", values=", util::uitos(_values.size()), + ", nodes=", util::uitos(_closestKNodes.size())); } } // namespace aria2 diff --git a/src/DHTGetPeersReplyMessage.h b/src/DHTGetPeersReplyMessage.h index 14c78391..fb66e9af 100644 --- a/src/DHTGetPeersReplyMessage.h +++ b/src/DHTGetPeersReplyMessage.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -56,9 +56,9 @@ protected: virtual std::string toStringOptional() const; public: DHTGetPeersReplyMessage(const SharedHandle<DHTNode>& localNode, - const SharedHandle<DHTNode>& remoteNode, - const std::string& token, - const std::string& transactionID); + const SharedHandle<DHTNode>& remoteNode, + const std::string& token, + const std::string& transactionID); virtual ~DHTGetPeersReplyMessage(); diff --git a/src/DHTIDCloser.h b/src/DHTIDCloser.h index 4bbe99f1..420feb45 100644 --- a/src/DHTIDCloser.h +++ b/src/DHTIDCloser.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -51,7 +51,7 @@ public: DHTIDCloser(const unsigned char* targetID):_closer(targetID, DHT_ID_LENGTH) {} bool operator()(const SharedHandle<DHTNodeLookupEntry>& m1, - const SharedHandle<DHTNodeLookupEntry>& m2) const + const SharedHandle<DHTNodeLookupEntry>& m2) const { return _closer(m1->_node->getID(), m2->_node->getID()); } diff --git a/src/DHTInteractionCommand.cc b/src/DHTInteractionCommand.cc index a5fd28e8..f62dbf6a 100644 --- a/src/DHTInteractionCommand.cc +++ b/src/DHTInteractionCommand.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/DHTInteractionCommand.h b/src/DHTInteractionCommand.h index 8363efa7..e4cfacc8 100644 --- a/src/DHTInteractionCommand.h +++ b/src/DHTInteractionCommand.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/DHTMessage.cc b/src/DHTMessage.cc index 515e6d5d..67e621fc 100644 --- a/src/DHTMessage.cc +++ b/src/DHTMessage.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -45,8 +45,8 @@ const std::string DHTMessage::T("t"); const std::string DHTMessage::ID("id"); DHTMessage::DHTMessage(const SharedHandle<DHTNode>& localNode, - const SharedHandle<DHTNode>& remoteNode, - const std::string& transactionID): + const SharedHandle<DHTNode>& remoteNode, + const std::string& transactionID): _localNode(localNode), _remoteNode(remoteNode), _transactionID(transactionID) { if(transactionID.empty()) { diff --git a/src/DHTMessage.h b/src/DHTMessage.h index a009562d..23716252 100644 --- a/src/DHTMessage.h +++ b/src/DHTMessage.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -57,8 +57,8 @@ protected: void generateTransactionID(); public: DHTMessage(const SharedHandle<DHTNode>& localNode, - const SharedHandle<DHTNode>& remoteNode, - const std::string& transactionID = A2STR::NIL); + const SharedHandle<DHTNode>& remoteNode, + const std::string& transactionID = A2STR::NIL); virtual ~DHTMessage(); diff --git a/src/DHTMessageCallback.h b/src/DHTMessageCallback.h index c5a802ca..d596fed9 100644 --- a/src/DHTMessageCallback.h +++ b/src/DHTMessageCallback.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/DHTMessageCallbackImpl.cc b/src/DHTMessageCallbackImpl.cc index b937fbcd..01a66ff5 100644 --- a/src/DHTMessageCallbackImpl.cc +++ b/src/DHTMessageCallbackImpl.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/DHTMessageCallbackImpl.h b/src/DHTMessageCallbackImpl.h index b631e768..f8334893 100644 --- a/src/DHTMessageCallbackImpl.h +++ b/src/DHTMessageCallbackImpl.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/DHTMessageCallbackListener.h b/src/DHTMessageCallbackListener.h index 4a96af30..9e06fcdb 100644 --- a/src/DHTMessageCallbackListener.h +++ b/src/DHTMessageCallbackListener.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/DHTMessageDispatcher.h b/src/DHTMessageDispatcher.h index 1ebb5da9..69260db5 100644 --- a/src/DHTMessageDispatcher.h +++ b/src/DHTMessageDispatcher.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -50,14 +50,14 @@ public: virtual void addMessageToQueue(const SharedHandle<DHTMessage>& message, - time_t timeout, - const SharedHandle<DHTMessageCallback>& callback = - SharedHandle<DHTMessageCallback>()) = 0; + time_t timeout, + const SharedHandle<DHTMessageCallback>& callback = + SharedHandle<DHTMessageCallback>()) = 0; virtual void addMessageToQueue(const SharedHandle<DHTMessage>& message, - const SharedHandle<DHTMessageCallback>& callback = - SharedHandle<DHTMessageCallback>()) = 0; + const SharedHandle<DHTMessageCallback>& callback = + SharedHandle<DHTMessageCallback>()) = 0; virtual void sendMessages() = 0; diff --git a/src/DHTMessageDispatcherImpl.cc b/src/DHTMessageDispatcherImpl.cc index e308647d..29662f88 100644 --- a/src/DHTMessageDispatcherImpl.cc +++ b/src/DHTMessageDispatcherImpl.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -54,8 +54,8 @@ DHTMessageDispatcherImpl::~DHTMessageDispatcherImpl() {} void DHTMessageDispatcherImpl::addMessageToQueue(const SharedHandle<DHTMessage>& message, - time_t timeout, - const SharedHandle<DHTMessageCallback>& callback) + time_t timeout, + const SharedHandle<DHTMessageCallback>& callback) { SharedHandle<DHTMessageEntry> e(new DHTMessageEntry(message, timeout, callback)); _messageQueue.push_back(e); @@ -63,7 +63,7 @@ DHTMessageDispatcherImpl::addMessageToQueue(const SharedHandle<DHTMessage>& mess void DHTMessageDispatcherImpl::addMessageToQueue(const SharedHandle<DHTMessage>& message, - const SharedHandle<DHTMessageCallback>& callback) + const SharedHandle<DHTMessageCallback>& callback) { addMessageToQueue(message, DHT_MESSAGE_TIMEOUT, callback); } @@ -74,7 +74,7 @@ DHTMessageDispatcherImpl::sendMessage(const SharedHandle<DHTMessageEntry>& entry try { if(entry->_message->send()) { if(!entry->_message->isReply()) { - _tracker->addMessage(entry->_message, entry->_timeout, entry->_callback); + _tracker->addMessage(entry->_message, entry->_timeout, entry->_callback); } _logger->info("Message sent: %s", entry->_message->toString().c_str()); } else { @@ -106,7 +106,7 @@ void DHTMessageDispatcherImpl::sendMessages() } _messageQueue.erase(_messageQueue.begin(), itr); _logger->debug("%lu dht messages remaining in the queue.", - static_cast<unsigned long>(_messageQueue.size())); + static_cast<unsigned long>(_messageQueue.size())); } size_t DHTMessageDispatcherImpl::countMessageInQueue() const diff --git a/src/DHTMessageDispatcherImpl.h b/src/DHTMessageDispatcherImpl.h index 428998b9..88640a52 100644 --- a/src/DHTMessageDispatcherImpl.h +++ b/src/DHTMessageDispatcherImpl.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -60,14 +60,14 @@ public: virtual void addMessageToQueue(const SharedHandle<DHTMessage>& message, - time_t timeout, - const SharedHandle<DHTMessageCallback>& callback = - SharedHandle<DHTMessageCallback>()); + time_t timeout, + const SharedHandle<DHTMessageCallback>& callback = + SharedHandle<DHTMessageCallback>()); virtual void addMessageToQueue(const SharedHandle<DHTMessage>& message, - const SharedHandle<DHTMessageCallback>& callback = - SharedHandle<DHTMessageCallback>()); + const SharedHandle<DHTMessageCallback>& callback = + SharedHandle<DHTMessageCallback>()); virtual void sendMessages(); diff --git a/src/DHTMessageEntry.cc b/src/DHTMessageEntry.cc index 73efbd55..29342d83 100644 --- a/src/DHTMessageEntry.cc +++ b/src/DHTMessageEntry.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -40,8 +40,8 @@ namespace aria2 { DHTMessageEntry::DHTMessageEntry(const SharedHandle<DHTMessage>& message, - time_t timeout, - const SharedHandle<DHTMessageCallback>& callback): + time_t timeout, + const SharedHandle<DHTMessageCallback>& callback): _message(message), _timeout(timeout), _callback(callback) {} diff --git a/src/DHTMessageEntry.h b/src/DHTMessageEntry.h index 64c32850..fb325e11 100644 --- a/src/DHTMessageEntry.h +++ b/src/DHTMessageEntry.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -51,8 +51,8 @@ public: SharedHandle<DHTMessageCallback> _callback; DHTMessageEntry(const SharedHandle<DHTMessage>& message, - time_t timeout, - const SharedHandle<DHTMessageCallback>& callback); + time_t timeout, + const SharedHandle<DHTMessageCallback>& callback); ~DHTMessageEntry(); }; diff --git a/src/DHTMessageFactory.h b/src/DHTMessageFactory.h index 863c5c24..2a823ceb 100644 --- a/src/DHTMessageFactory.h +++ b/src/DHTMessageFactory.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -56,63 +56,63 @@ public: virtual SharedHandle<DHTMessage> createQueryMessage(const BDE& dict, - const std::string& ipaddr, uint16_t port) = 0; + const std::string& ipaddr, uint16_t port) = 0; virtual SharedHandle<DHTMessage> createResponseMessage(const std::string& messageType, - const BDE& dict, - const std::string& ipaddr, uint16_t port) = 0; + const BDE& dict, + const std::string& ipaddr, uint16_t port) = 0; virtual SharedHandle<DHTMessage> createPingMessage(const SharedHandle<DHTNode>& remoteNode, - const std::string& transactionID = A2STR::NIL) = 0; + const std::string& transactionID = A2STR::NIL) = 0; virtual SharedHandle<DHTMessage> createPingReplyMessage(const SharedHandle<DHTNode>& remoteNode, - const unsigned char* id, - const std::string& transactionID) = 0; + const unsigned char* id, + const std::string& transactionID) = 0; virtual SharedHandle<DHTMessage> createFindNodeMessage(const SharedHandle<DHTNode>& remoteNode, - const unsigned char* targetNodeID, - const std::string& transactionID = A2STR::NIL) = 0; + const unsigned char* targetNodeID, + const std::string& transactionID = A2STR::NIL) = 0; virtual SharedHandle<DHTMessage> createFindNodeReplyMessage(const SharedHandle<DHTNode>& remoteNode, - const std::deque<SharedHandle<DHTNode> >& closestKNodes, - const std::string& transactionID) = 0; + const std::deque<SharedHandle<DHTNode> >& closestKNodes, + const std::string& transactionID) = 0; virtual SharedHandle<DHTMessage> createGetPeersMessage(const SharedHandle<DHTNode>& remoteNode, - const unsigned char* infoHash, - const std::string& transactionID = A2STR::NIL) = 0; + const unsigned char* infoHash, + const std::string& transactionID = A2STR::NIL) = 0; virtual SharedHandle<DHTMessage> createGetPeersReplyMessage(const SharedHandle<DHTNode>& remoteNode, - const std::deque<SharedHandle<DHTNode> >& closestKNodes, - const std::string& token, - const std::string& transactionID) = 0; + const std::deque<SharedHandle<DHTNode> >& closestKNodes, + const std::string& token, + const std::string& transactionID) = 0; virtual SharedHandle<DHTMessage> createGetPeersReplyMessage(const SharedHandle<DHTNode>& remoteNode, - const std::deque<SharedHandle<Peer> >& peers, - const std::string& token, - const std::string& transactionID) = 0; + const std::deque<SharedHandle<Peer> >& peers, + const std::string& token, + const std::string& transactionID) = 0; virtual SharedHandle<DHTMessage> createAnnouncePeerMessage(const SharedHandle<DHTNode>& remoteNode, - const unsigned char* infoHash, - uint16_t tcpPort, - const std::string& token, - const std::string& transactionID = A2STR::NIL) = 0; + const unsigned char* infoHash, + uint16_t tcpPort, + const std::string& token, + const std::string& transactionID = A2STR::NIL) = 0; virtual SharedHandle<DHTMessage> createAnnouncePeerReplyMessage(const SharedHandle<DHTNode>& remoteNode, - const std::string& transactionID) = 0; + const std::string& transactionID) = 0; virtual SharedHandle<DHTMessage> createUnknownMessage(const unsigned char* data, size_t length, - const std::string& ipaddr, uint16_t port) = 0; + const std::string& ipaddr, uint16_t port) = 0; }; } // namespace aria2 diff --git a/src/DHTMessageFactoryImpl.cc b/src/DHTMessageFactoryImpl.cc index bf95ff1a..27ebf211 100644 --- a/src/DHTMessageFactoryImpl.cc +++ b/src/DHTMessageFactoryImpl.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -83,7 +83,7 @@ DHTMessageFactoryImpl::getRemoteNode(const unsigned char* id, const std::string& } static const BDE& getDictionary(const BDE& dict, - const std::string& key) + const std::string& key) { const BDE& d = dict[key]; if(d.isDict()) { @@ -95,7 +95,7 @@ static const BDE& getDictionary(const BDE& dict, } static const BDE& getString(const BDE& dict, - const std::string& key) + const std::string& key) { const BDE& c = dict[key]; if(c.isString()) { @@ -107,7 +107,7 @@ static const BDE& getString(const BDE& dict, } static const BDE& getInteger(const BDE& dict, - const std::string& key) + const std::string& key) { const BDE& c = dict[key]; if(c.isInteger()) { @@ -126,7 +126,7 @@ static const BDE& getString(const BDE& list, size_t index) } else { throw DL_ABORT_EX (StringFormat("Malformed DHT message. element[%u] is not String.", - index).str()); + index).str()); } } @@ -138,12 +138,12 @@ static const BDE& getInteger(const BDE& list, size_t index) } else { throw DL_ABORT_EX (StringFormat("Malformed DHT message. element[%u] is not Integer.", - index).str()); + index).str()); } } static const BDE& getList(const BDE& dict, - const std::string& key) + const std::string& key) { const BDE& l = dict[key]; if(l.isList()) { @@ -159,8 +159,8 @@ void DHTMessageFactoryImpl::validateID(const BDE& id) const if(id.s().size() != DHT_ID_LENGTH) { throw DL_ABORT_EX (StringFormat("Malformed DHT message. Invalid ID length." - " Expected:%d, Actual:%d", - DHT_ID_LENGTH, id.s().size()).str()); + " Expected:%d, Actual:%d", + DHT_ID_LENGTH, id.s().size()).str()); } } @@ -170,7 +170,7 @@ void DHTMessageFactoryImpl::validatePort(const BDE& i) const if(!(0 < port && port < UINT16_MAX)) { throw DL_ABORT_EX (StringFormat("Malformed DHT message. Invalid port=%s", - util::itos(port).c_str()).str()); + util::itos(port).c_str()).str()); } } @@ -196,13 +196,13 @@ SharedHandle<DHTMessage> DHTMessageFactoryImpl::createQueryMessage getString(aDict, DHTFindNodeMessage::TARGET_NODE); validateID(targetNodeID); return createFindNodeMessage(remoteNode, targetNodeID.uc(), - transactionID.s()); + transactionID.s()); } else if(messageType.s() == DHTGetPeersMessage::GET_PEERS) { const BDE& infoHash = getString(aDict, DHTGetPeersMessage::INFO_HASH); validateID(infoHash); return createGetPeersMessage(remoteNode, - infoHash.uc(), transactionID.s()); + infoHash.uc(), transactionID.s()); } else if(messageType.s() == DHTAnnouncePeerMessage::ANNOUNCE_PEER) { const BDE& infoHash = getString(aDict, DHTAnnouncePeerMessage::INFO_HASH); @@ -211,20 +211,20 @@ SharedHandle<DHTMessage> DHTMessageFactoryImpl::createQueryMessage validatePort(port); const BDE& token = getString(aDict, DHTAnnouncePeerMessage::TOKEN); return createAnnouncePeerMessage(remoteNode, infoHash.uc(), - static_cast<uint16_t>(port.i()), - token.s(), transactionID.s()); + static_cast<uint16_t>(port.i()), + token.s(), transactionID.s()); } else { throw DL_ABORT_EX (StringFormat("Unsupported message type: %s", - messageType.s().c_str()).str()); + messageType.s().c_str()).str()); } } SharedHandle<DHTMessage> DHTMessageFactoryImpl::createResponseMessage(const std::string& messageType, - const BDE& dict, - const std::string& ipaddr, - uint16_t port) + const BDE& dict, + const std::string& ipaddr, + uint16_t port) { const BDE& transactionID = getString(dict, DHTMessage::T); const BDE& y = getString(dict, DHTMessage::Y); @@ -233,8 +233,8 @@ DHTMessageFactoryImpl::createResponseMessage(const std::string& messageType, const BDE& e = getList(dict, DHTUnknownMessage::E); if(e.size() == 2) { _logger->info("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); @@ -257,14 +257,14 @@ DHTMessageFactoryImpl::createResponseMessage(const std::string& messageType, const BDE& valuesList = rDict[DHTGetPeersReplyMessage::VALUES]; if(valuesList.isList()) { return createGetPeersReplyMessageWithValues(remoteNode, dict, - transactionID.s()); + transactionID.s()); } else { const BDE& nodes = rDict[DHTGetPeersReplyMessage::NODES]; if(nodes.isString()) { - return createGetPeersReplyMessageWithNodes(remoteNode, dict, - transactionID.s()); + return createGetPeersReplyMessageWithNodes(remoteNode, dict, + transactionID.s()); } else { - throw DL_ABORT_EX("Malformed DHT message: missing nodes/values"); + throw DL_ABORT_EX("Malformed DHT message: missing nodes/values"); } } } else if(messageType == DHTAnnouncePeerReplyMessage::ANNOUNCE_PEER) { @@ -293,8 +293,8 @@ SharedHandle<DHTMessage> DHTMessageFactoryImpl::createPingMessage(const SharedHa SharedHandle<DHTMessage> DHTMessageFactoryImpl::createPingReplyMessage(const SharedHandle<DHTNode>& remoteNode, - const unsigned char* id, - const std::string& transactionID) + const unsigned char* id, + const std::string& transactionID) { SharedHandle<DHTPingReplyMessage> m(new DHTPingReplyMessage(_localNode, remoteNode, id, transactionID)); setCommonProperty(m); @@ -303,8 +303,8 @@ DHTMessageFactoryImpl::createPingReplyMessage(const SharedHandle<DHTNode>& remot SharedHandle<DHTMessage> DHTMessageFactoryImpl::createFindNodeMessage(const SharedHandle<DHTNode>& remoteNode, - const unsigned char* targetNodeID, - const std::string& transactionID) + const unsigned char* targetNodeID, + const std::string& transactionID) { SharedHandle<DHTFindNodeMessage> m(new DHTFindNodeMessage(_localNode, remoteNode, targetNodeID, transactionID)); setCommonProperty(m); @@ -313,8 +313,8 @@ DHTMessageFactoryImpl::createFindNodeMessage(const SharedHandle<DHTNode>& remote SharedHandle<DHTMessage> DHTMessageFactoryImpl::createFindNodeReplyMessage(const SharedHandle<DHTNode>& remoteNode, - const std::deque<SharedHandle<DHTNode> >& closestKNodes, - const std::string& transactionID) + const std::deque<SharedHandle<DHTNode> >& closestKNodes, + const std::string& transactionID) { SharedHandle<DHTFindNodeReplyMessage> m(new DHTFindNodeReplyMessage(_localNode, remoteNode, transactionID)); m->setClosestKNodes(closestKNodes); @@ -351,21 +351,21 @@ DHTMessageFactoryImpl::createFindNodeReplyMessage { const BDE& nodesData = getString(getDictionary(dict, DHTResponseMessage::R), - DHTFindNodeReplyMessage::NODES); + DHTFindNodeReplyMessage::NODES); std::deque<SharedHandle<DHTNode> > nodes = extractNodes(nodesData.uc(), - nodesData.s().size()); + nodesData.s().size()); return createFindNodeReplyMessage(remoteNode, nodes, transactionID); } SharedHandle<DHTMessage> DHTMessageFactoryImpl::createGetPeersMessage(const SharedHandle<DHTNode>& remoteNode, - const unsigned char* infoHash, - const std::string& transactionID) + const unsigned char* infoHash, + const std::string& transactionID) { SharedHandle<DHTGetPeersMessage> m(new DHTGetPeersMessage(_localNode, - remoteNode, - infoHash, - transactionID)); + remoteNode, + infoHash, + transactionID)); m->setPeerAnnounceStorage(_peerAnnounceStorage); m->setTokenTracker(_tokenTracker); setCommonProperty(m); @@ -380,19 +380,19 @@ DHTMessageFactoryImpl::createGetPeersReplyMessageWithNodes { const BDE& rDict = getDictionary(dict, DHTResponseMessage::R); const BDE& nodesData = getString(rDict, - DHTGetPeersReplyMessage::NODES); + DHTGetPeersReplyMessage::NODES); std::deque<SharedHandle<DHTNode> > nodes = extractNodes(nodesData.uc(), - nodesData.s().size()); + nodesData.s().size()); const BDE& token = getString(rDict, DHTGetPeersReplyMessage::TOKEN); return createGetPeersReplyMessage(remoteNode, nodes, token.s(), - transactionID); + transactionID); } SharedHandle<DHTMessage> DHTMessageFactoryImpl::createGetPeersReplyMessage(const SharedHandle<DHTNode>& remoteNode, - const std::deque<SharedHandle<DHTNode> >& closestKNodes, - const std::string& token, - const std::string& transactionID) + const std::deque<SharedHandle<DHTNode> >& closestKNodes, + const std::string& token, + const std::string& transactionID) { SharedHandle<DHTGetPeersReplyMessage> m (new DHTGetPeersReplyMessage(_localNode, remoteNode, token, transactionID)); @@ -409,28 +409,28 @@ DHTMessageFactoryImpl::createGetPeersReplyMessageWithValues { const BDE& rDict = getDictionary(dict, DHTResponseMessage::R); const BDE& valuesList = getList(rDict, - DHTGetPeersReplyMessage::VALUES); + DHTGetPeersReplyMessage::VALUES); std::deque<SharedHandle<Peer> > peers; for(BDE::List::const_iterator i = valuesList.listBegin(); i != valuesList.listEnd(); ++i) { const BDE& data = *i; if(data.isString() && data.s().size() == 6) { std::pair<std::string, uint16_t> addr = - bittorrent::unpackcompact(data.uc()); + bittorrent::unpackcompact(data.uc()); PeerHandle peer(new Peer(addr.first, addr.second)); peers.push_back(peer); } } const BDE& token = getString(rDict, DHTGetPeersReplyMessage::TOKEN); return createGetPeersReplyMessage(remoteNode, peers, token.s(), - transactionID); + transactionID); } SharedHandle<DHTMessage> DHTMessageFactoryImpl::createGetPeersReplyMessage(const SharedHandle<DHTNode>& remoteNode, - const std::deque<SharedHandle<Peer> >& values, - const std::string& token, - const std::string& transactionID) + const std::deque<SharedHandle<Peer> >& values, + const std::string& token, + const std::string& transactionID) { SharedHandle<DHTGetPeersReplyMessage> m(new DHTGetPeersReplyMessage(_localNode, remoteNode, token, transactionID)); m->setValues(values); @@ -440,10 +440,10 @@ DHTMessageFactoryImpl::createGetPeersReplyMessage(const SharedHandle<DHTNode>& r SharedHandle<DHTMessage> DHTMessageFactoryImpl::createAnnouncePeerMessage(const SharedHandle<DHTNode>& remoteNode, - const unsigned char* infoHash, - uint16_t tcpPort, - const std::string& token, - const std::string& transactionID) + const unsigned char* infoHash, + uint16_t tcpPort, + const std::string& token, + const std::string& transactionID) { SharedHandle<DHTAnnouncePeerMessage> m (new DHTAnnouncePeerMessage(_localNode, remoteNode, infoHash, tcpPort, token, transactionID)); @@ -455,7 +455,7 @@ DHTMessageFactoryImpl::createAnnouncePeerMessage(const SharedHandle<DHTNode>& re SharedHandle<DHTMessage> DHTMessageFactoryImpl::createAnnouncePeerReplyMessage(const SharedHandle<DHTNode>& remoteNode, - const std::string& transactionID) + const std::string& transactionID) { SharedHandle<DHTAnnouncePeerReplyMessage> m (new DHTAnnouncePeerReplyMessage(_localNode, remoteNode, transactionID)); @@ -465,7 +465,7 @@ DHTMessageFactoryImpl::createAnnouncePeerReplyMessage(const SharedHandle<DHTNode SharedHandle<DHTMessage> DHTMessageFactoryImpl::createUnknownMessage(const unsigned char* data, size_t length, - const std::string& ipaddr, uint16_t port) + const std::string& ipaddr, uint16_t port) { SharedHandle<DHTUnknownMessage> m diff --git a/src/DHTMessageFactoryImpl.h b/src/DHTMessageFactoryImpl.h index ef0cd70b..5c026ca9 100644 --- a/src/DHTMessageFactoryImpl.h +++ b/src/DHTMessageFactoryImpl.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -83,79 +83,79 @@ public: virtual SharedHandle<DHTMessage> createQueryMessage(const BDE& dict, - const std::string& ipaddr, uint16_t port); + const std::string& ipaddr, uint16_t port); virtual SharedHandle<DHTMessage> createResponseMessage(const std::string& messageType, - const BDE& dict, - const std::string& ipaddr, uint16_t port); + const BDE& dict, + const std::string& ipaddr, uint16_t port); virtual SharedHandle<DHTMessage> createPingMessage(const SharedHandle<DHTNode>& remoteNode, - const std::string& transactionID = A2STR::NIL); + const std::string& transactionID = A2STR::NIL); virtual SharedHandle<DHTMessage> createPingReplyMessage(const SharedHandle<DHTNode>& remoteNode, - const unsigned char* id, - const std::string& transactionID); + const unsigned char* id, + const std::string& transactionID); virtual SharedHandle<DHTMessage> createFindNodeMessage(const SharedHandle<DHTNode>& remoteNode, - const unsigned char* targetNodeID, - const std::string& transactionID = A2STR::NIL); + const unsigned char* targetNodeID, + const std::string& transactionID = A2STR::NIL); SharedHandle<DHTMessage> createFindNodeReplyMessage(const SharedHandle<DHTNode>& remoteNode, - const BDE& dict, - const std::string& transactionID); + const BDE& dict, + const std::string& transactionID); virtual SharedHandle<DHTMessage> createFindNodeReplyMessage(const SharedHandle<DHTNode>& remoteNode, - const std::deque<SharedHandle<DHTNode> >& closestKNodes, - const std::string& transactionID); + const std::deque<SharedHandle<DHTNode> >& closestKNodes, + const std::string& transactionID); virtual SharedHandle<DHTMessage> createGetPeersMessage(const SharedHandle<DHTNode>& remoteNode, - const unsigned char* infoHash, - const std::string& transactionID = A2STR::NIL); + const unsigned char* infoHash, + const std::string& transactionID = A2STR::NIL); virtual SharedHandle<DHTMessage> createGetPeersReplyMessage(const SharedHandle<DHTNode>& remoteNode, - const std::deque<SharedHandle<DHTNode> >& closestKNodes, - const std::string& token, - const std::string& transactionID); + const std::deque<SharedHandle<DHTNode> >& closestKNodes, + const std::string& token, + const std::string& transactionID); SharedHandle<DHTMessage> createGetPeersReplyMessageWithNodes(const SharedHandle<DHTNode>& remoteNode, - const BDE& dict, - const std::string& transactionID); + const BDE& dict, + const std::string& transactionID); virtual SharedHandle<DHTMessage> createGetPeersReplyMessage(const SharedHandle<DHTNode>& remoteNode, - const std::deque<SharedHandle<Peer> >& peers, - const std::string& token, - const std::string& transactionID); + const std::deque<SharedHandle<Peer> >& peers, + const std::string& token, + const std::string& transactionID); SharedHandle<DHTMessage> createGetPeersReplyMessageWithValues(const SharedHandle<DHTNode>& remoteNode, - const BDE& dict, - const std::string& transactionID); + const BDE& dict, + const std::string& transactionID); virtual SharedHandle<DHTMessage> createAnnouncePeerMessage(const SharedHandle<DHTNode>& remoteNode, - const unsigned char* infoHash, - uint16_t tcpPort, - const std::string& token, - const std::string& transactionID = A2STR::NIL); + const unsigned char* infoHash, + uint16_t tcpPort, + const std::string& token, + const std::string& transactionID = A2STR::NIL); virtual SharedHandle<DHTMessage> createAnnouncePeerReplyMessage(const SharedHandle<DHTNode>& remoteNode, - const std::string& transactionID); + const std::string& transactionID); virtual SharedHandle<DHTMessage> createUnknownMessage(const unsigned char* data, size_t length, - const std::string& ipaddr, uint16_t port); + const std::string& ipaddr, uint16_t port); void setRoutingTable(const WeakHandle<DHTRoutingTable>& routingTable); diff --git a/src/DHTMessageReceiver.cc b/src/DHTMessageReceiver.cc index 9146e165..25697a4b 100644 --- a/src/DHTMessageReceiver.cc +++ b/src/DHTMessageReceiver.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -67,8 +67,8 @@ SharedHandle<DHTMessage> DHTMessageReceiver::receiveMessage() uint16_t remotePort; unsigned char data[64*1024]; ssize_t length = _connection->receiveMessage(data, sizeof(data), - remoteAddr, - remotePort); + remoteAddr, + remotePort); if(length <= 0) { return SharedHandle<DHTMessage>(); } @@ -78,36 +78,36 @@ SharedHandle<DHTMessage> DHTMessageReceiver::receiveMessage() if(dict.isDict()) { const BDE& y = dict[DHTMessage::Y]; if(y.isString()) { - if(y.s() == DHTResponseMessage::R || y.s() == DHTUnknownMessage::E) { - isReply = true; - } + if(y.s() == DHTResponseMessage::R || y.s() == DHTUnknownMessage::E) { + isReply = true; + } } else { - _logger->info("Malformed DHT message. Missing 'y' key. From:%s:%u", - remoteAddr.c_str(), remotePort); - return handleUnknownMessage(data, sizeof(data), remoteAddr, remotePort); + _logger->info("Malformed DHT message. Missing 'y' key. From:%s:%u", + remoteAddr.c_str(), remotePort); + return handleUnknownMessage(data, sizeof(data), remoteAddr, remotePort); } } else { _logger->info("Malformed DHT message. This is not a bencoded directory." - " From:%s:%u", remoteAddr.c_str(), remotePort); + " From:%s:%u", remoteAddr.c_str(), remotePort); return handleUnknownMessage(data, sizeof(data), remoteAddr, remotePort); } SharedHandle<DHTMessage> message; SharedHandle<DHTMessageCallback> callback; if(isReply) { std::pair<SharedHandle<DHTMessage>, SharedHandle<DHTMessageCallback> > p = - _tracker->messageArrived(dict, remoteAddr, remotePort); + _tracker->messageArrived(dict, remoteAddr, remotePort); message = p.first; callback = p.second; if(message.isNull()) { - // timeout or malicious? message - return handleUnknownMessage(data, sizeof(data), remoteAddr, remotePort); + // timeout or malicious? message + return handleUnknownMessage(data, sizeof(data), remoteAddr, remotePort); } } else { message = _factory->createQueryMessage(dict, remoteAddr, remotePort); if(message->getLocalNode() == message->getRemoteNode()) { - // drop message from localnode - _logger->info("Recieved DHT message from localnode."); - return handleUnknownMessage(data, sizeof(data), remoteAddr, remotePort); + // drop message from localnode + _logger->info("Recieved DHT message from localnode."); + return handleUnknownMessage(data, sizeof(data), remoteAddr, remotePort); } } _logger->info("Message received: %s", message->toString().c_str()); @@ -133,9 +133,9 @@ void DHTMessageReceiver::handleTimeout() SharedHandle<DHTMessage> DHTMessageReceiver::handleUnknownMessage(const unsigned char* data, - size_t length, - const std::string& remoteAddr, - uint16_t remotePort) + size_t length, + const std::string& remoteAddr, + uint16_t remotePort) { SharedHandle<DHTMessage> m = _factory->createUnknownMessage(data, length, remoteAddr, remotePort); diff --git a/src/DHTMessageReceiver.h b/src/DHTMessageReceiver.h index 85924c81..cafc7ada 100644 --- a/src/DHTMessageReceiver.h +++ b/src/DHTMessageReceiver.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -62,7 +62,7 @@ private: SharedHandle<DHTMessage> handleUnknownMessage(const unsigned char* data, size_t length, - const std::string& remoteAddr, uint16_t remotePort); + const std::string& remoteAddr, uint16_t remotePort); public: DHTMessageReceiver(const SharedHandle<DHTMessageTracker>& tracker); diff --git a/src/DHTMessageTracker.cc b/src/DHTMessageTracker.cc index e3fc44a6..4b112ce7 100644 --- a/src/DHTMessageTracker.cc +++ b/src/DHTMessageTracker.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -70,17 +70,17 @@ void DHTMessageTracker::addMessage(const SharedHandle<DHTMessage>& message, cons std::pair<SharedHandle<DHTMessage>, SharedHandle<DHTMessageCallback> > DHTMessageTracker::messageArrived(const BDE& dict, - const std::string& ipaddr, uint16_t port) + const std::string& ipaddr, uint16_t port) { const BDE& tid = dict[DHTMessage::T]; if(!tid.isString()) { throw DL_ABORT_EX(StringFormat("Malformed DHT message. From:%s:%u", - ipaddr.c_str(), port).str()); + 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<SharedHandle<DHTMessageTrackerEntry> >::iterator i = - _entries.begin(); i != _entries.end(); ++i) { + _entries.begin(); i != _entries.end(); ++i) { if((*i)->match(tid.s(), ipaddr, port)) { SharedHandle<DHTMessageTrackerEntry> entry = *i; _entries.erase(i); @@ -88,9 +88,9 @@ DHTMessageTracker::messageArrived(const BDE& dict, SharedHandle<DHTNode> targetNode = entry->getTargetNode(); SharedHandle<DHTMessage> message = - _factory->createResponseMessage(entry->getMessageType(), dict, - targetNode->getIPAddress(), - targetNode->getPort()); + _factory->createResponseMessage(entry->getMessageType(), dict, + targetNode->getIPAddress(), + targetNode->getPort()); int64_t rtt = entry->getElapsedMillis(); _logger->debug("RTT is %s", util::itos(rtt).c_str()); @@ -109,24 +109,24 @@ void DHTMessageTracker::handleTimeout() i != _entries.end();) { if((*i)->isTimeout()) { try { - SharedHandle<DHTMessageTrackerEntry> entry = *i; - i = _entries.erase(i); - SharedHandle<DHTNode> node = entry->getTargetNode(); - _logger->debug("Message timeout: To:%s:%u", - node->getIPAddress().c_str(), node->getPort()); - node->updateRTT(entry->getElapsedMillis()); - node->timeout(); - if(node->isBad()) { - _logger->debug("Marked bad: %s:%u", - node->getIPAddress().c_str(), node->getPort()); - _routingTable->dropNode(node); - } - SharedHandle<DHTMessageCallback> callback = entry->getCallback(); - if(!callback.isNull()) { - callback->onTimeout(node); - } + SharedHandle<DHTMessageTrackerEntry> entry = *i; + i = _entries.erase(i); + SharedHandle<DHTNode> node = entry->getTargetNode(); + _logger->debug("Message timeout: To:%s:%u", + node->getIPAddress().c_str(), node->getPort()); + node->updateRTT(entry->getElapsedMillis()); + node->timeout(); + if(node->isBad()) { + _logger->debug("Marked bad: %s:%u", + node->getIPAddress().c_str(), node->getPort()); + _routingTable->dropNode(node); + } + SharedHandle<DHTMessageCallback> callback = entry->getCallback(); + if(!callback.isNull()) { + callback->onTimeout(node); + } } catch(RecoverableException& e) { - _logger->info("Exception thrown while handling timeouts.", e); + _logger->info("Exception thrown while handling timeouts.", e); } } else { ++i; diff --git a/src/DHTMessageTracker.h b/src/DHTMessageTracker.h index 62c47af1..0a174b38 100644 --- a/src/DHTMessageTracker.h +++ b/src/DHTMessageTracker.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -68,17 +68,17 @@ public: ~DHTMessageTracker(); void addMessage(const SharedHandle<DHTMessage>& message, - time_t timeout, - const SharedHandle<DHTMessageCallback>& callback = - SharedHandle<DHTMessageCallback>()); + time_t timeout, + const SharedHandle<DHTMessageCallback>& callback = + SharedHandle<DHTMessageCallback>()); void addMessage(const SharedHandle<DHTMessage>& message, - const SharedHandle<DHTMessageCallback>& callback = - SharedHandle<DHTMessageCallback>()); + const SharedHandle<DHTMessageCallback>& callback = + SharedHandle<DHTMessageCallback>()); std::pair<SharedHandle<DHTMessage>, SharedHandle<DHTMessageCallback> > messageArrived(const BDE& dict, - const std::string& ipaddr, uint16_t port); + const std::string& ipaddr, uint16_t port); void handleTimeout(); diff --git a/src/DHTMessageTrackerEntry.cc b/src/DHTMessageTrackerEntry.cc index 1ff741c7..72423f1f 100644 --- a/src/DHTMessageTrackerEntry.cc +++ b/src/DHTMessageTrackerEntry.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -42,8 +42,8 @@ namespace aria2 { DHTMessageTrackerEntry::DHTMessageTrackerEntry(const SharedHandle<DHTMessage>& sentMessage, - time_t timeout, - const SharedHandle<DHTMessageCallback>& callback): + time_t timeout, + const SharedHandle<DHTMessageCallback>& callback): _targetNode(sentMessage->getRemoteNode()), _transactionID(sentMessage->getTransactionID()), _messageType(sentMessage->getMessageType()), diff --git a/src/DHTMessageTrackerEntry.h b/src/DHTMessageTrackerEntry.h index dc46203e..bdc2f8f0 100644 --- a/src/DHTMessageTrackerEntry.h +++ b/src/DHTMessageTrackerEntry.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -62,9 +62,9 @@ private: time_t _timeout; public: DHTMessageTrackerEntry(const SharedHandle<DHTMessage>& sentMessage, - time_t timeout, - const SharedHandle<DHTMessageCallback>& callback = - SharedHandle<DHTMessageCallback>()); + time_t timeout, + const SharedHandle<DHTMessageCallback>& callback = + SharedHandle<DHTMessageCallback>()); bool isTimeout() const; diff --git a/src/DHTNode.cc b/src/DHTNode.cc index 82beff41..0cca4902 100644 --- a/src/DHTNode.cc +++ b/src/DHTNode.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -114,9 +114,9 @@ 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)); + ", Host=", _ipaddr, ":", util::uitos(_port), + ", Condition=", util::uitos(_condition), + ", RTT=", util::uitos(_rtt)); } void DHTNode::setID(const unsigned char* id) diff --git a/src/DHTNode.h b/src/DHTNode.h index e4452a83..ed2f21e3 100644 --- a/src/DHTNode.h +++ b/src/DHTNode.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/DHTNodeLookupEntry.cc b/src/DHTNodeLookupEntry.cc index 2f64761b..b0b1a0ca 100644 --- a/src/DHTNodeLookupEntry.cc +++ b/src/DHTNodeLookupEntry.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/DHTNodeLookupEntry.h b/src/DHTNodeLookupEntry.h index 36051afd..6e567d5f 100644 --- a/src/DHTNodeLookupEntry.h +++ b/src/DHTNodeLookupEntry.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/DHTNodeLookupTask.cc b/src/DHTNodeLookupTask.cc index b1cc73ef..33802457 100644 --- a/src/DHTNodeLookupTask.cc +++ b/src/DHTNodeLookupTask.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -49,7 +49,7 @@ DHTNodeLookupTask::DHTNodeLookupTask(const unsigned char* targetNodeID): void DHTNodeLookupTask::getNodesFromMessage(std::deque<SharedHandle<DHTNode> >& nodes, - const SharedHandle<DHTMessage>& message) + const SharedHandle<DHTMessage>& message) { SharedHandle<DHTFindNodeReplyMessage> m (dynamic_pointer_cast<DHTFindNodeReplyMessage>(message)); diff --git a/src/DHTNodeLookupTask.h b/src/DHTNodeLookupTask.h index 77d42f5c..988b5046 100644 --- a/src/DHTNodeLookupTask.h +++ b/src/DHTNodeLookupTask.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -44,7 +44,7 @@ public: DHTNodeLookupTask(const unsigned char* targetNodeID); virtual void getNodesFromMessage(std::deque<SharedHandle<DHTNode> >& nodes, - const SharedHandle<DHTMessage>& message); + const SharedHandle<DHTMessage>& message); virtual SharedHandle<DHTMessage> createMessage(const SharedHandle<DHTNode>& remoteNode); }; diff --git a/src/DHTPeerAnnounceCommand.cc b/src/DHTPeerAnnounceCommand.cc index 2b8ddc4c..6271f9b9 100644 --- a/src/DHTPeerAnnounceCommand.cc +++ b/src/DHTPeerAnnounceCommand.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/DHTPeerAnnounceCommand.h b/src/DHTPeerAnnounceCommand.h index dbbb6e4e..8ab2ee25 100644 --- a/src/DHTPeerAnnounceCommand.h +++ b/src/DHTPeerAnnounceCommand.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/DHTPeerAnnounceEntry.cc b/src/DHTPeerAnnounceEntry.cc index 8b854ce9..5710982c 100644 --- a/src/DHTPeerAnnounceEntry.cc +++ b/src/DHTPeerAnnounceEntry.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -83,7 +83,7 @@ public: void DHTPeerAnnounceEntry::removeStalePeerAddrEntry(time_t timeout) { _peerAddrEntries.erase(std::remove_if(_peerAddrEntries.begin(), _peerAddrEntries.end(), - FindStaleEntry(timeout)), _peerAddrEntries.end()); + FindStaleEntry(timeout)), _peerAddrEntries.end()); } bool DHTPeerAnnounceEntry::empty() const diff --git a/src/DHTPeerAnnounceEntry.h b/src/DHTPeerAnnounceEntry.h index 168534fa..fee6197a 100644 --- a/src/DHTPeerAnnounceEntry.h +++ b/src/DHTPeerAnnounceEntry.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/DHTPeerAnnounceStorage.cc b/src/DHTPeerAnnounceStorage.cc index 8bbbd65d..e9f18deb 100644 --- a/src/DHTPeerAnnounceStorage.cc +++ b/src/DHTPeerAnnounceStorage.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -59,7 +59,7 @@ class InfoHashLess { public: bool operator()(const SharedHandle<DHTPeerAnnounceEntry>& lhs, - const SharedHandle<DHTPeerAnnounceEntry>& rhs) + const SharedHandle<DHTPeerAnnounceEntry>& rhs) { return memcmp(lhs->getInfoHash(), rhs->getInfoHash(), DHT_ID_LENGTH) < 0; } @@ -84,10 +84,10 @@ DHTPeerAnnounceStorage::getPeerAnnounceEntry(const unsigned char* infoHash) void DHTPeerAnnounceStorage::addPeerAnnounce(const unsigned char* infoHash, - const std::string& ipaddr, uint16_t port) + 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)); } @@ -99,7 +99,7 @@ bool DHTPeerAnnounceStorage::contains(const unsigned char* infoHash) const } void DHTPeerAnnounceStorage::getPeers(std::deque<SharedHandle<Peer> >& peers, - const unsigned char* infoHash) + const unsigned char* infoHash) { SharedHandle<DHTPeerAnnounceEntry> entry(new DHTPeerAnnounceEntry(infoHash)); @@ -124,14 +124,14 @@ public: void DHTPeerAnnounceStorage::handleTimeout() { _logger->debug("Now purge peer announces(%lu entries) which are timed out.", - static_cast<unsigned long>(_entries.size())); + static_cast<unsigned long>(_entries.size())); std::for_each(_entries.begin(), _entries.end(), RemoveStalePeerAddrEntry()); _entries.erase(std::remove_if(_entries.begin(), _entries.end(), - mem_fun_sh(&DHTPeerAnnounceEntry::empty)), - _entries.end()); + mem_fun_sh(&DHTPeerAnnounceEntry::empty)), + _entries.end()); _logger->debug("Currently %lu peer announce entries", - static_cast<unsigned long>(_entries.size())); + static_cast<unsigned long>(_entries.size())); } void DHTPeerAnnounceStorage::announcePeer() @@ -143,7 +143,7 @@ void DHTPeerAnnounceStorage::announcePeer() SharedHandle<DHTTask> 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/DHTPeerAnnounceStorage.h b/src/DHTPeerAnnounceStorage.h index 8b08b839..fec036dc 100644 --- a/src/DHTPeerAnnounceStorage.h +++ b/src/DHTPeerAnnounceStorage.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -64,12 +64,12 @@ public: ~DHTPeerAnnounceStorage(); void addPeerAnnounce(const unsigned char* infoHash, - const std::string& ipaddr, uint16_t port); + const std::string& ipaddr, uint16_t port); bool contains(const unsigned char* infoHash) const; void getPeers(std::deque<SharedHandle<Peer> >& peers, - const unsigned char* infoHash); + const unsigned char* infoHash); // drop peer announce entry which is not updated in the past // DHT_PEER_ANNOUNCE_PURGE_INTERVAL seconds. diff --git a/src/DHTPeerLookupTask.cc b/src/DHTPeerLookupTask.cc index 76fd5f44..0fa6402c 100644 --- a/src/DHTPeerLookupTask.cc +++ b/src/DHTPeerLookupTask.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -55,7 +55,7 @@ DHTPeerLookupTask::DHTPeerLookupTask void DHTPeerLookupTask::getNodesFromMessage(std::deque<SharedHandle<DHTNode> >& nodes, - const SharedHandle<DHTMessage>& message) + const SharedHandle<DHTMessage>& message) { SharedHandle<DHTGetPeersReplyMessage> m(dynamic_pointer_cast<DHTGetPeersReplyMessage>(message)); if(!m.isNull()) { @@ -92,11 +92,11 @@ void DHTPeerLookupTask::onFinish() if((*i)->_used) { const SharedHandle<DHTNode>& node = (*i)->_node; SharedHandle<DHTMessage> m = - _factory->createAnnouncePeerMessage - (node, - _targetID, // this is infoHash - _btRuntime->getListenPort(), - _tokenStorage[util::toHex(node->getID(), DHT_ID_LENGTH)]); + _factory->createAnnouncePeerMessage + (node, + _targetID, // this is infoHash + _btRuntime->getListenPort(), + _tokenStorage[util::toHex(node->getID(), DHT_ID_LENGTH)]); _dispatcher->addMessageToQueue(m); } } diff --git a/src/DHTPeerLookupTask.h b/src/DHTPeerLookupTask.h index d448f74a..bec9d322 100644 --- a/src/DHTPeerLookupTask.h +++ b/src/DHTPeerLookupTask.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -58,7 +58,7 @@ public: DHTPeerLookupTask(const SharedHandle<DownloadContext>& downloadContext); virtual void getNodesFromMessage(std::deque<SharedHandle<DHTNode> >& nodes, - const SharedHandle<DHTMessage>& message); + const SharedHandle<DHTMessage>& message); virtual void onReceivedInternal(const SharedHandle<DHTMessage>& message); diff --git a/src/DHTPingMessage.cc b/src/DHTPingMessage.cc index 2ee39920..45dc6401 100644 --- a/src/DHTPingMessage.cc +++ b/src/DHTPingMessage.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -45,8 +45,8 @@ namespace aria2 { const std::string DHTPingMessage::PING("ping"); DHTPingMessage::DHTPingMessage(const SharedHandle<DHTNode>& localNode, - const SharedHandle<DHTNode>& remoteNode, - const std::string& transactionID): + const SharedHandle<DHTNode>& remoteNode, + const std::string& transactionID): DHTQueryMessage(localNode, remoteNode, transactionID) {} DHTPingMessage::~DHTPingMessage() {} diff --git a/src/DHTPingMessage.h b/src/DHTPingMessage.h index eec9a5a0..46fd17c7 100644 --- a/src/DHTPingMessage.h +++ b/src/DHTPingMessage.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -43,8 +43,8 @@ namespace aria2 { class DHTPingMessage:public DHTQueryMessage { public: DHTPingMessage(const SharedHandle<DHTNode>& localNode, - const SharedHandle<DHTNode>& remoteNode, - const std::string& transactionID = A2STR::NIL); + const SharedHandle<DHTNode>& remoteNode, + const std::string& transactionID = A2STR::NIL); virtual ~DHTPingMessage(); diff --git a/src/DHTPingReplyMessage.cc b/src/DHTPingReplyMessage.cc index 887c626e..2f4a0f57 100644 --- a/src/DHTPingReplyMessage.cc +++ b/src/DHTPingReplyMessage.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -44,9 +44,9 @@ namespace aria2 { const std::string DHTPingReplyMessage::PING("ping"); DHTPingReplyMessage::DHTPingReplyMessage(const SharedHandle<DHTNode>& localNode, - const SharedHandle<DHTNode>& remoteNode, - const unsigned char* id, - const std::string& transactionID): + const SharedHandle<DHTNode>& remoteNode, + const unsigned char* id, + const std::string& transactionID): DHTResponseMessage(localNode, remoteNode, transactionID) { memcpy(_id, id, DHT_ID_LENGTH); diff --git a/src/DHTPingReplyMessage.h b/src/DHTPingReplyMessage.h index 93ca50f7..5ac8098d 100644 --- a/src/DHTPingReplyMessage.h +++ b/src/DHTPingReplyMessage.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -45,9 +45,9 @@ private: unsigned char _id[DHT_ID_LENGTH]; public: DHTPingReplyMessage(const SharedHandle<DHTNode>& localNode, - const SharedHandle<DHTNode>& remoteNode, - const unsigned char* id, - const std::string& transactionID); + const SharedHandle<DHTNode>& remoteNode, + const unsigned char* id, + const std::string& transactionID); virtual ~DHTPingReplyMessage(); diff --git a/src/DHTPingTask.cc b/src/DHTPingTask.cc index c7ab1049..c13e6227 100644 --- a/src/DHTPingTask.cc +++ b/src/DHTPingTask.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/DHTPingTask.h b/src/DHTPingTask.h index 8294a8e3..d08162d6 100644 --- a/src/DHTPingTask.h +++ b/src/DHTPingTask.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/DHTQueryMessage.cc b/src/DHTQueryMessage.cc index 71166005..d905b52d 100644 --- a/src/DHTQueryMessage.cc +++ b/src/DHTQueryMessage.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -45,8 +45,8 @@ const std::string DHTQueryMessage::Q("q"); const std::string DHTQueryMessage::A("a"); DHTQueryMessage::DHTQueryMessage(const SharedHandle<DHTNode>& localNode, - const SharedHandle<DHTNode>& remoteNode, - const std::string& transactionID): + const SharedHandle<DHTNode>& remoteNode, + const std::string& transactionID): DHTAbstractMessage(localNode, remoteNode, transactionID) {} DHTQueryMessage::~DHTQueryMessage() {} @@ -70,11 +70,11 @@ bool DHTQueryMessage::isReply() const std::string DHTQueryMessage::toString() const { return strconcat("dht query ", getMessageType(), - " TransactionID=", util::toHex(_transactionID), - " Remote:", _remoteNode->getIPAddress(), - ":", util::uitos(_remoteNode->getPort()), - ", id=", util::toHex(_remoteNode->getID(), DHT_ID_LENGTH), - ", ", toStringOptional()); + " TransactionID=", util::toHex(_transactionID), + " Remote:", _remoteNode->getIPAddress(), + ":", util::uitos(_remoteNode->getPort()), + ", id=", util::toHex(_remoteNode->getID(), DHT_ID_LENGTH), + ", ", toStringOptional()); } } // namespace aria2 diff --git a/src/DHTQueryMessage.h b/src/DHTQueryMessage.h index 5f6b13ba..b19f278a 100644 --- a/src/DHTQueryMessage.h +++ b/src/DHTQueryMessage.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -45,8 +45,8 @@ protected: virtual std::string toStringOptional() const { return A2STR::NIL; } public: DHTQueryMessage(const SharedHandle<DHTNode>& localNode, - const SharedHandle<DHTNode>& remoteNode, - const std::string& transactionID = A2STR::NIL); + const SharedHandle<DHTNode>& remoteNode, + const std::string& transactionID = A2STR::NIL); virtual ~DHTQueryMessage(); diff --git a/src/DHTRegistry.cc b/src/DHTRegistry.cc index 3bebacf1..5168911c 100644 --- a/src/DHTRegistry.cc +++ b/src/DHTRegistry.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/DHTRegistry.h b/src/DHTRegistry.h index c1160a39..885f1d53 100644 --- a/src/DHTRegistry.h +++ b/src/DHTRegistry.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/DHTReplaceNodeTask.cc b/src/DHTReplaceNodeTask.cc index 9c480b2e..d9c9512f 100644 --- a/src/DHTReplaceNodeTask.cc +++ b/src/DHTReplaceNodeTask.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -44,7 +44,7 @@ namespace aria2 { DHTReplaceNodeTask::DHTReplaceNodeTask(const SharedHandle<DHTBucket>& bucket, - const SharedHandle<DHTNode>& newNode): + const SharedHandle<DHTNode>& newNode): _bucket(bucket), _newNode(newNode), _numRetry(0), @@ -74,7 +74,7 @@ void DHTReplaceNodeTask::sendMessage() void DHTReplaceNodeTask::onReceived(const SharedHandle<DHTMessage>& message) { _logger->info("ReplaceNode: Ping reply received from %s.", - message->getRemoteNode()->toString().c_str()); + message->getRemoteNode()->toString().c_str()); _finished = true; } @@ -83,13 +83,13 @@ void DHTReplaceNodeTask::onTimeout(const SharedHandle<DHTNode>& node) ++_numRetry; if(_numRetry >= MAX_RETRY) { _logger->info("ReplaceNode: Ping failed %u times. Replace %s with %s.", - _numRetry, node->toString().c_str(), _newNode->toString().c_str()); + _numRetry, node->toString().c_str(), _newNode->toString().c_str()); node->markBad(); _bucket->addNode(_newNode); _finished = true; } else { _logger->info("ReplaceNode: Ping reply timeout from %s. Try once more.", - node->toString().c_str()); + node->toString().c_str()); sendMessage(); } } diff --git a/src/DHTReplaceNodeTask.h b/src/DHTReplaceNodeTask.h index dce4c278..d6a699a1 100644 --- a/src/DHTReplaceNodeTask.h +++ b/src/DHTReplaceNodeTask.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -58,7 +58,7 @@ private: void sendMessage(); public: DHTReplaceNodeTask(const SharedHandle<DHTBucket>& bucket, - const SharedHandle<DHTNode>& newNode); + const SharedHandle<DHTNode>& newNode); virtual ~DHTReplaceNodeTask(); diff --git a/src/DHTResponseMessage.cc b/src/DHTResponseMessage.cc index 92768e4a..d8632dd4 100644 --- a/src/DHTResponseMessage.cc +++ b/src/DHTResponseMessage.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -43,8 +43,8 @@ namespace aria2 { const std::string DHTResponseMessage::R("r"); DHTResponseMessage::DHTResponseMessage(const SharedHandle<DHTNode>& localNode, - const SharedHandle<DHTNode>& remoteNode, - const std::string& transactionID): + const SharedHandle<DHTNode>& remoteNode, + const std::string& transactionID): DHTAbstractMessage(localNode, remoteNode, transactionID) {} DHTResponseMessage::~DHTResponseMessage() {} @@ -67,11 +67,11 @@ bool DHTResponseMessage::isReply() const std::string DHTResponseMessage::toString() const { return strconcat("dht response ", getMessageType(), - " TransactionID=", util::toHex(_transactionID), - " Remote:", _remoteNode->getIPAddress(), - ":", util::uitos(_remoteNode->getPort()), - ", id=", util::toHex(_remoteNode->getID(), DHT_ID_LENGTH), - ", ", toStringOptional()); + " TransactionID=", util::toHex(_transactionID), + " Remote:", _remoteNode->getIPAddress(), + ":", util::uitos(_remoteNode->getPort()), + ", id=", util::toHex(_remoteNode->getID(), DHT_ID_LENGTH), + ", ", toStringOptional()); } } // namespace aria2 diff --git a/src/DHTResponseMessage.h b/src/DHTResponseMessage.h index 646011cb..c074f2af 100644 --- a/src/DHTResponseMessage.h +++ b/src/DHTResponseMessage.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -45,8 +45,8 @@ protected: virtual std::string toStringOptional() const { return A2STR::NIL; } public: DHTResponseMessage(const SharedHandle<DHTNode>& localNode, - const SharedHandle<DHTNode>& remoteNode, - const std::string& transactionID); + const SharedHandle<DHTNode>& remoteNode, + const std::string& transactionID); virtual ~DHTResponseMessage(); diff --git a/src/DHTRoutingTable.cc b/src/DHTRoutingTable.cc index d4d1defc..1f41a2dc 100644 --- a/src/DHTRoutingTable.cc +++ b/src/DHTRoutingTable.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -77,7 +77,7 @@ bool DHTRoutingTable::addNode(const SharedHandle<DHTNode>& node, bool good) _logger->debug("Trying to add node:%s", node->toString().c_str()); if(_localNode == node) { _logger->debug("Adding node with the same ID with localnode is not" - " allowed."); + " allowed."); return false; } BNode* bnode = BNode::findBNodeFor(_root, node->getID()); @@ -88,8 +88,8 @@ bool DHTRoutingTable::addNode(const SharedHandle<DHTNode>& 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<DHTBucket> r = bucket->split(); bnode->setBucket(SharedHandle<DHTBucket>()); @@ -100,15 +100,15 @@ bool DHTRoutingTable::addNode(const SharedHandle<DHTNode>& node, bool good) ++_numBucket; if(r->isInRange(node)) { - bucket = r; - bnode = rbnode; + bucket = r; + bnode = rbnode; } else { - bnode = lbnode; + bnode = lbnode; } } else { if(good) { - bucket->cacheNode(node); - _logger->debug("Cached node=%s", node->toString().c_str()); + bucket->cacheNode(node); + _logger->debug("Cached node=%s", node->toString().c_str()); } return false; } @@ -117,7 +117,7 @@ bool DHTRoutingTable::addNode(const SharedHandle<DHTNode>& node, bool good) } void DHTRoutingTable::getClosestKNodes(std::deque<SharedHandle<DHTNode> >& nodes, - const unsigned char* key) const + const unsigned char* key) const { BNode::findClosestKNodes(nodes, _root, key); } @@ -129,10 +129,10 @@ size_t DHTRoutingTable::countBucket() const void DHTRoutingTable::showBuckets() const {/* - for(std::deque<SharedHandle<DHTBucket> >::const_iterator itr = _buckets.begin(); itr != _buckets.end(); ++itr) { - cerr << "prefix = " << (*itr)->getPrefixLength() << ", " - << "nodes = " << (*itr)->countNode() << endl; - } + for(std::deque<SharedHandle<DHTBucket> >::const_iterator itr = _buckets.begin(); itr != _buckets.end(); ++itr) { + cerr << "prefix = " << (*itr)->getPrefixLength() << ", " + << "nodes = " << (*itr)->countNode() << endl; + } */ } @@ -157,10 +157,10 @@ void DHTRoutingTable::dropNode(const SharedHandle<DHTNode>& node) getBucketFor(node)->dropNode(node); } /* -void DHTRoutingTable::moveBucketHead(const SharedHandle<DHTNode>& node) -{ + void DHTRoutingTable::moveBucketHead(const SharedHandle<DHTNode>& node) + { getBucketFor(node)->moveToHead(node); -} + } */ void DHTRoutingTable::moveBucketTail(const SharedHandle<DHTNode>& node) { diff --git a/src/DHTRoutingTable.h b/src/DHTRoutingTable.h index b8a9b6a3..fc7d94d3 100644 --- a/src/DHTRoutingTable.h +++ b/src/DHTRoutingTable.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -74,7 +74,7 @@ public: bool addGoodNode(const SharedHandle<DHTNode>& node); void getClosestKNodes(std::deque<SharedHandle<DHTNode> >& nodes, - const unsigned char* key) const; + const unsigned char* key) const; size_t countBucket() const; diff --git a/src/DHTRoutingTableDeserializer.cc b/src/DHTRoutingTableDeserializer.cc index 78f1ca1e..51691b82 100644 --- a/src/DHTRoutingTableDeserializer.cc +++ b/src/DHTRoutingTableDeserializer.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -57,22 +57,22 @@ DHTRoutingTableDeserializer::DHTRoutingTableDeserializer() {} DHTRoutingTableDeserializer::~DHTRoutingTableDeserializer() {} static void readBytes(unsigned char* buf, size_t buflen, - std::istream& in, size_t readlen) + std::istream& in, size_t readlen) { assert(readlen <= buflen); in.read(reinterpret_cast<char*>(buf), readlen); } -#define CHECK_STREAM(in, length) \ - if(in.gcount() != length) { \ - throw DL_ABORT_EX \ - (StringFormat("Failed to load DHT routing table. cause:%s", \ - "Unexpected EOF").str()); \ - } \ - if(!in) { \ - throw DL_ABORT_EX \ - (StringFormat("Failed to load DHT routing table. cause:%s", \ - strerror(errno)).str()); \ +#define CHECK_STREAM(in, length) \ + if(in.gcount() != length) { \ + throw DL_ABORT_EX \ + (StringFormat("Failed to load DHT routing table. cause:%s", \ + "Unexpected EOF").str()); \ + } \ + if(!in) { \ + throw DL_ABORT_EX \ + (StringFormat("Failed to load DHT routing table. cause:%s", \ + strerror(errno)).str()); \ } void DHTRoutingTableDeserializer::deserialize(std::istream& in) @@ -118,7 +118,7 @@ void DHTRoutingTableDeserializer::deserialize(std::istream& in) } else { throw DL_ABORT_EX (StringFormat("Failed to load DHT routing table. cause:%s", - "bad header").str()); + "bad header").str()); } uint32_t temp32; diff --git a/src/DHTRoutingTableDeserializer.h b/src/DHTRoutingTableDeserializer.h index 712d8b36..4c9a67be 100644 --- a/src/DHTRoutingTableDeserializer.h +++ b/src/DHTRoutingTableDeserializer.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/DHTRoutingTableSerializer.cc b/src/DHTRoutingTableSerializer.cc index f20485cb..61b2ea83 100644 --- a/src/DHTRoutingTableSerializer.cc +++ b/src/DHTRoutingTableSerializer.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -128,7 +128,7 @@ void DHTRoutingTableSerializer::serialize(std::ostream& o) if(!o) { throw DL_ABORT_EX (StringFormat("Failed to save DHT routing table. cause:%s", - strerror(errno)).str()); + strerror(errno)).str()); } } diff --git a/src/DHTRoutingTableSerializer.h b/src/DHTRoutingTableSerializer.h index 5b4f0cd3..a0b60f91 100644 --- a/src/DHTRoutingTableSerializer.h +++ b/src/DHTRoutingTableSerializer.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/DHTSetup.cc b/src/DHTSetup.cc index 1cf421df..7f2406e0 100644 --- a/src/DHTSetup.cc +++ b/src/DHTSetup.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -81,7 +81,7 @@ DHTSetup::DHTSetup():_logger(LogFactory::getInstance()) {} DHTSetup::~DHTSetup() {} void DHTSetup::setup(std::deque<Command*>& commands, - DownloadEngine* e, const Option* option) + DownloadEngine* e, const Option* option) { if(_initialized) { return; @@ -97,13 +97,13 @@ void DHTSetup::setup(std::deque<Command*>& commands, try { std::ifstream in(dhtFile.c_str(), std::ios::binary); if(!in) { - throw DL_ABORT_EX("Could not open file"); + throw DL_ABORT_EX("Could not open file"); } deserializer.deserialize(in); localNode = deserializer.getLocalNode(); } catch(RecoverableException& e) { _logger->error("Exception caught while loading DHT routing table from %s", - e, dhtFile.c_str()); + e, dhtFile.c_str()); } if(localNode.isNull()) { localNode.reset(new DHTNode()); @@ -114,12 +114,12 @@ void DHTSetup::setup(std::deque<Command*>& commands, 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"); + throw DL_ABORT_EX("Error occurred while binding port for DHT"); } 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<DHTRoutingTable> routingTable(new DHTRoutingTable(localNode)); @@ -184,32 +184,32 @@ void DHTSetup::setup(std::deque<Command*>& commands, } if(!desnodes.empty() && deserializer.getSerializedTime().elapsed(DHT_BUCKET_REFRESH_INTERVAL)) { SharedHandle<DHTBucketRefreshTask> task - (dynamic_pointer_cast<DHTBucketRefreshTask>(taskFactory->createBucketRefreshTask())); + (dynamic_pointer_cast<DHTBucketRefreshTask>(taskFactory->createBucketRefreshTask())); task->setForceRefresh(true); taskQueue->addPeriodicTask1(task); } if(!option->get(PREF_DHT_ENTRY_POINT_HOST).empty()) { { - std::pair<std::string, uint16_t> addr(option->get(PREF_DHT_ENTRY_POINT_HOST), - option->getAsInt(PREF_DHT_ENTRY_POINT_PORT)); - std::deque<std::pair<std::string, uint16_t> > entryPoints; - entryPoints.push_back(addr); - DHTEntryPointNameResolveCommand* command = - new DHTEntryPointNameResolveCommand(e->newCUID(), e, entryPoints); - command->setBootstrapEnabled(true); - command->setTaskQueue(taskQueue); - command->setTaskFactory(taskFactory); - command->setRoutingTable(routingTable); - command->setLocalNode(localNode); - tempCommands.push_back(command); + std::pair<std::string, uint16_t> addr(option->get(PREF_DHT_ENTRY_POINT_HOST), + option->getAsInt(PREF_DHT_ENTRY_POINT_PORT)); + std::deque<std::pair<std::string, uint16_t> > entryPoints; + entryPoints.push_back(addr); + DHTEntryPointNameResolveCommand* command = + new DHTEntryPointNameResolveCommand(e->newCUID(), e, entryPoints); + command->setBootstrapEnabled(true); + command->setTaskQueue(taskQueue); + command->setTaskFactory(taskFactory); + command->setRoutingTable(routingTable); + command->setLocalNode(localNode); + tempCommands.push_back(command); } } else { _logger->info("No DHT entry point specified."); } { DHTInteractionCommand* command = - new DHTInteractionCommand(e->newCUID(), e); + new DHTInteractionCommand(e->newCUID(), e); command->setMessageDispatcher(dispatcher); command->setMessageReceiver(receiver); command->setTaskQueue(taskQueue); @@ -218,14 +218,14 @@ void DHTSetup::setup(std::deque<Command*>& commands, } { DHTTokenUpdateCommand* command = - new DHTTokenUpdateCommand(e->newCUID(), e, DHT_TOKEN_UPDATE_INTERVAL); + new DHTTokenUpdateCommand(e->newCUID(), e, DHT_TOKEN_UPDATE_INTERVAL); command->setTokenTracker(tokenTracker); tempCommands.push_back(command); } { DHTBucketRefreshCommand* command = - new DHTBucketRefreshCommand(e->newCUID(), e, - DHT_BUCKET_REFRESH_CHECK_INTERVAL); + new DHTBucketRefreshCommand(e->newCUID(), e, + DHT_BUCKET_REFRESH_CHECK_INTERVAL); command->setTaskQueue(taskQueue); command->setRoutingTable(routingTable); command->setTaskFactory(taskFactory); @@ -233,14 +233,14 @@ void DHTSetup::setup(std::deque<Command*>& commands, } { DHTPeerAnnounceCommand* command = - new DHTPeerAnnounceCommand(e->newCUID(), e, - DHT_PEER_ANNOUNCE_CHECK_INTERVAL); + new DHTPeerAnnounceCommand(e->newCUID(), e, + DHT_PEER_ANNOUNCE_CHECK_INTERVAL); command->setPeerAnnounceStorage(peerAnnounceStorage); tempCommands.push_back(command); } { DHTAutoSaveCommand* command = - new DHTAutoSaveCommand(e->newCUID(), e, 30*60); + new DHTAutoSaveCommand(e->newCUID(), e, 30*60); command->setLocalNode(localNode); command->setRoutingTable(routingTable); tempCommands.push_back(command); diff --git a/src/DHTSetup.h b/src/DHTSetup.h index 6cf9376b..6bddaec5 100644 --- a/src/DHTSetup.h +++ b/src/DHTSetup.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -56,7 +56,7 @@ public: ~DHTSetup(); void setup(std::deque<Command*>& commands, - DownloadEngine* e, const Option* option); + DownloadEngine* e, const Option* option); static bool initialized(); }; diff --git a/src/DHTTask.h b/src/DHTTask.h index 09cce633..b5c13283 100644 --- a/src/DHTTask.h +++ b/src/DHTTask.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/DHTTaskFactory.h b/src/DHTTaskFactory.h index 91988e1a..9fdd2503 100644 --- a/src/DHTTaskFactory.h +++ b/src/DHTTaskFactory.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -53,7 +53,7 @@ public: virtual SharedHandle<DHTTask> createPingTask(const SharedHandle<DHTNode>& remoteNode, - size_t numRetry = 0) = 0; + size_t numRetry = 0) = 0; virtual SharedHandle<DHTTask> createNodeLookupTask(const unsigned char* targetID) = 0; @@ -62,15 +62,15 @@ public: virtual SharedHandle<DHTTask> createPeerLookupTask(const SharedHandle<DownloadContext>& ctx, - const SharedHandle<BtRuntime>& btRuntime, - const SharedHandle<PeerStorage>& peerStorage) = 0; + const SharedHandle<BtRuntime>& btRuntime, + const SharedHandle<PeerStorage>& peerStorage) = 0; virtual SharedHandle<DHTTask> createPeerAnnounceTask(const unsigned char* infoHash) = 0; virtual SharedHandle<DHTTask> createReplaceNodeTask(const SharedHandle<DHTBucket>& bucket, - const SharedHandle<DHTNode>& newNode) = 0; + const SharedHandle<DHTNode>& newNode) = 0; }; } // namespace aria2 diff --git a/src/DHTTaskFactoryImpl.cc b/src/DHTTaskFactoryImpl.cc index 6d794b88..ee5ade9a 100644 --- a/src/DHTTaskFactoryImpl.cc +++ b/src/DHTTaskFactoryImpl.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -59,7 +59,7 @@ DHTTaskFactoryImpl::~DHTTaskFactoryImpl() {} SharedHandle<DHTTask> DHTTaskFactoryImpl::createPingTask(const SharedHandle<DHTNode>& remoteNode, - size_t numRetry) + size_t numRetry) { SharedHandle<DHTPingTask> task(new DHTPingTask(remoteNode, numRetry)); setCommonProperty(task); @@ -105,7 +105,7 @@ DHTTaskFactoryImpl::createPeerAnnounceTask(const unsigned char* infoHash) SharedHandle<DHTTask> DHTTaskFactoryImpl::createReplaceNodeTask(const SharedHandle<DHTBucket>& bucket, - const SharedHandle<DHTNode>& newNode) + const SharedHandle<DHTNode>& newNode) { SharedHandle<DHTReplaceNodeTask> task(new DHTReplaceNodeTask(bucket, newNode)); setCommonProperty(task); diff --git a/src/DHTTaskFactoryImpl.h b/src/DHTTaskFactoryImpl.h index e6f2e5b2..52f94b3f 100644 --- a/src/DHTTaskFactoryImpl.h +++ b/src/DHTTaskFactoryImpl.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -69,7 +69,7 @@ public: virtual SharedHandle<DHTTask> createPingTask(const SharedHandle<DHTNode>& remoteNode, - size_t numRetry = 0); + size_t numRetry = 0); virtual SharedHandle<DHTTask> createNodeLookupTask(const unsigned char* targetID); @@ -78,15 +78,15 @@ public: virtual SharedHandle<DHTTask> createPeerLookupTask(const SharedHandle<DownloadContext>& ctx, - const SharedHandle<BtRuntime>& btRuntime, - const SharedHandle<PeerStorage>& peerStorage); + const SharedHandle<BtRuntime>& btRuntime, + const SharedHandle<PeerStorage>& peerStorage); virtual SharedHandle<DHTTask> createPeerAnnounceTask(const unsigned char* infoHash); virtual SharedHandle<DHTTask> createReplaceNodeTask(const SharedHandle<DHTBucket>& bucket, - const SharedHandle<DHTNode>& newNode); + const SharedHandle<DHTNode>& newNode); void setRoutingTable(const WeakHandle<DHTRoutingTable> routingTable); diff --git a/src/DHTTaskQueue.h b/src/DHTTaskQueue.h index fd03d782..81aa07c3 100644 --- a/src/DHTTaskQueue.h +++ b/src/DHTTaskQueue.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/DHTTaskQueueImpl.cc b/src/DHTTaskQueueImpl.cc index bbec4374..a7ccae9b 100644 --- a/src/DHTTaskQueueImpl.cc +++ b/src/DHTTaskQueueImpl.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -42,13 +42,13 @@ DHTTaskQueueImpl::DHTTaskQueueImpl() {} DHTTaskQueueImpl::~DHTTaskQueueImpl() {} void DHTTaskQueueImpl::executeTask(SharedHandle<DHTTask>& task, - std::deque<SharedHandle<DHTTask> >& taskQueue) + std::deque<SharedHandle<DHTTask> >& taskQueue) { while(1) { if(task.isNull() || task->finished()) { task.reset(); if(taskQueue.empty()) { - break; + break; } task = taskQueue.front(); taskQueue.erase(taskQueue.begin()); diff --git a/src/DHTTaskQueueImpl.h b/src/DHTTaskQueueImpl.h index b573dba6..12c85d66 100644 --- a/src/DHTTaskQueueImpl.h +++ b/src/DHTTaskQueueImpl.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/DHTTokenTracker.cc b/src/DHTTokenTracker.cc index 54cc5c32..760551bf 100644 --- a/src/DHTTokenTracker.cc +++ b/src/DHTTokenTracker.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -60,14 +60,14 @@ DHTTokenTracker::DHTTokenTracker(const unsigned char* initialSecret) DHTTokenTracker::~DHTTokenTracker() {} std::string DHTTokenTracker::generateToken(const unsigned char* infoHash, - const std::string& ipaddr, uint16_t port, - const unsigned char* secret) const + const std::string& ipaddr, uint16_t port, + const unsigned char* secret) const { unsigned char src[DHT_ID_LENGTH+6+SECRET_SIZE]; if(!bittorrent::createcompact(src+DHT_ID_LENGTH, ipaddr, port)) { throw DL_ABORT_EX (StringFormat("Token generation failed: ipaddr=%s, port=%u", - ipaddr.c_str(), port).str()); + ipaddr.c_str(), port).str()); } memcpy(src, infoHash, DHT_ID_LENGTH); memcpy(src+DHT_ID_LENGTH+6, secret, SECRET_SIZE); @@ -77,14 +77,14 @@ std::string DHTTokenTracker::generateToken(const unsigned char* infoHash, } std::string DHTTokenTracker::generateToken(const unsigned char* infoHash, - const std::string& ipaddr, uint16_t port) const + const std::string& ipaddr, uint16_t port) const { return generateToken(infoHash, ipaddr, port, _secret[0]); } bool DHTTokenTracker::validateToken(const std::string& token, - const unsigned char* infoHash, - const std::string& ipaddr, uint16_t port) const + const unsigned char* infoHash, + const std::string& ipaddr, uint16_t port) const { for(int i = 0; i < 2; ++i) { if(generateToken(infoHash, ipaddr, port, _secret[i]) == token) { diff --git a/src/DHTTokenTracker.h b/src/DHTTokenTracker.h index 32c4b3ac..a1453aab 100644 --- a/src/DHTTokenTracker.h +++ b/src/DHTTokenTracker.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -47,8 +47,8 @@ private: unsigned char _secret[2][SECRET_SIZE]; std::string generateToken(const unsigned char* infoHash, - const std::string& ipaddr, uint16_t port, - const unsigned char* secret) const; + const std::string& ipaddr, uint16_t port, + const unsigned char* secret) const; public: DHTTokenTracker(); @@ -58,11 +58,11 @@ public: // TODO handle exception thrown by this function. std::string generateToken(const unsigned char* infoHash, - const std::string& ipaddr, uint16_t port) const; + const std::string& ipaddr, uint16_t port) const; bool validateToken(const std::string& token, - const unsigned char* infoHash, - const std::string& ipaddr, uint16_t port) const; + const unsigned char* infoHash, + const std::string& ipaddr, uint16_t port) const; void updateTokenSecret(); }; diff --git a/src/DHTTokenUpdateCommand.cc b/src/DHTTokenUpdateCommand.cc index e29dcebb..943c56fe 100644 --- a/src/DHTTokenUpdateCommand.cc +++ b/src/DHTTokenUpdateCommand.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -44,8 +44,8 @@ namespace aria2 { DHTTokenUpdateCommand::DHTTokenUpdateCommand(int32_t cuid, - DownloadEngine* e, - time_t interval): + DownloadEngine* e, + time_t interval): TimeBasedCommand(cuid, e, interval) {} DHTTokenUpdateCommand::~DHTTokenUpdateCommand() {} diff --git a/src/DHTTokenUpdateCommand.h b/src/DHTTokenUpdateCommand.h index 3dfa9220..8f011fb8 100644 --- a/src/DHTTokenUpdateCommand.h +++ b/src/DHTTokenUpdateCommand.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/DHTUnknownMessage.cc b/src/DHTUnknownMessage.cc index 55f074e4..21d0d8c1 100644 --- a/src/DHTUnknownMessage.cc +++ b/src/DHTUnknownMessage.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -48,8 +48,8 @@ const std::string DHTUnknownMessage::E("e"); const std::string DHTUnknownMessage::UNKNOWN("unknown"); DHTUnknownMessage::DHTUnknownMessage(const SharedHandle<DHTNode>& localNode, - const unsigned char* data, size_t length, - const std::string& ipaddr, uint16_t port): + const unsigned char* data, size_t length, + const std::string& ipaddr, uint16_t port): DHTMessage(localNode, SharedHandle<DHTNode>()), _length(length), _ipaddr(ipaddr), @@ -93,8 +93,8 @@ 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)); + " length=", util::uitos(_length), + ", first 8 bytes(hex)=", util::toHex(sample)); } } // namespace aria2 diff --git a/src/DHTUnknownMessage.h b/src/DHTUnknownMessage.h index 08ec0ce8..5b0fd648 100644 --- a/src/DHTUnknownMessage.h +++ b/src/DHTUnknownMessage.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -48,8 +48,8 @@ private: public: // _remoteNode is always null DHTUnknownMessage(const SharedHandle<DHTNode>& localNode, - const unsigned char* data, size_t length, - const std::string& ipaddr, uint16_t port); + const unsigned char* data, size_t length, + const std::string& ipaddr, uint16_t port); virtual ~DHTUnknownMessage(); diff --git a/src/DNSCache.h b/src/DNSCache.h index c2c97f4e..71d8dcfa 100644 --- a/src/DNSCache.h +++ b/src/DNSCache.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -72,10 +72,10 @@ private: std::vector<AddrEntry>::iterator find(const std::string& addr) { for(std::vector<AddrEntry>::iterator i = _addrEntries.begin(); - i != _addrEntries.end(); ++i) { - if((*i)._addr == addr) { - return i; - } + i != _addrEntries.end(); ++i) { + if((*i)._addr == addr) { + return i; + } } return _addrEntries.end(); } @@ -83,10 +83,10 @@ private: std::vector<AddrEntry>::const_iterator find(const std::string& addr) const { for(std::vector<AddrEntry>::const_iterator i = _addrEntries.begin(); - i != _addrEntries.end(); ++i) { - if((*i)._addr == addr) { - return i; - } + i != _addrEntries.end(); ++i) { + if((*i)._addr == addr) { + return i; + } } return _addrEntries.end(); } @@ -99,10 +99,10 @@ private: const std::string& getGoodAddr() const { for(std::vector<AddrEntry>::const_iterator i = _addrEntries.begin(); - i != _addrEntries.end(); ++i) { - if((*i)._good) { - return (*i)._addr; - } + i != _addrEntries.end(); ++i) { + if((*i)._good) { + return (*i)._addr; + } } return A2STR::NIL; } @@ -111,7 +111,7 @@ private: { std::vector<AddrEntry>::iterator i = find(addr); if(i != _addrEntries.end()) { - (*i)._good = false; + (*i)._good = false; } } @@ -119,7 +119,7 @@ private: { int r = _hostname.compare(e._hostname); if(r != 0) { - return r < 0; + return r < 0; } return _port < e._port; } @@ -155,7 +155,7 @@ public: _entries.insert(i, target); } else { if(!(*i).contains(ipaddr)) { - (*i).add(ipaddr); + (*i).add(ipaddr); } } } diff --git a/src/Decoder.h b/src/Decoder.h index f8cb4cc9..92a7aedd 100644 --- a/src/Decoder.h +++ b/src/Decoder.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/DefaultAuthResolver.cc b/src/DefaultAuthResolver.cc index 82d808aa..80c3ae16 100644 --- a/src/DefaultAuthResolver.cc +++ b/src/DefaultAuthResolver.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/DefaultAuthResolver.h b/src/DefaultAuthResolver.h index e11e68db..bc84146a 100644 --- a/src/DefaultAuthResolver.h +++ b/src/DefaultAuthResolver.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/DefaultBtAnnounce.cc b/src/DefaultBtAnnounce.cc index b6563658..f42e94c9 100644 --- a/src/DefaultBtAnnounce.cc +++ b/src/DefaultBtAnnounce.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -78,21 +78,21 @@ DefaultBtAnnounce::~DefaultBtAnnounce() { bool DefaultBtAnnounce::isDefaultAnnounceReady() { return (trackers == 0 && - prevAnnounceTime.elapsed(_userDefinedInterval==0? - minInterval:_userDefinedInterval) && - !announceList.allTiersFailed()); + prevAnnounceTime.elapsed(_userDefinedInterval==0? + minInterval:_userDefinedInterval) && + !announceList.allTiersFailed()); } bool DefaultBtAnnounce::isStoppedAnnounceReady() { return (trackers == 0 && - btRuntime->isHalt() && - announceList.countStoppedAllowedTier()); + btRuntime->isHalt() && + announceList.countStoppedAllowedTier()); } bool DefaultBtAnnounce::isCompletedAnnounceReady() { return (trackers == 0 && - pieceStorage->allDownloadFinished() && - announceList.countCompletedAllowedTier()); + pieceStorage->allDownloadFinished() && + announceList.countCompletedAllowedTier()); } bool DefaultBtAnnounce::isAnnounceReady() { @@ -142,7 +142,7 @@ std::string DefaultBtAnnounce::getAnnounceUrl() { url += uriHasQuery(url) ? "&" : "?"; url += "info_hash="; url += util::torrentUrlencode(bittorrent::getInfoHash(_downloadContext), - INFO_HASH_LENGTH); + INFO_HASH_LENGTH); url += "&peer_id="; url += util::torrentUrlencode(bittorrent::getStaticPeerId(), PEER_ID_LENGTH); url += "&uploaded="; @@ -209,7 +209,7 @@ void DefaultBtAnnounce::resetAnnounce() { void DefaultBtAnnounce::processAnnounceResponse(const unsigned char* trackerResponse, - size_t trackerResponseLength) + size_t trackerResponseLength) { logger->debug("Now processing tracker response."); const BDE dict = @@ -271,8 +271,8 @@ DefaultBtAnnounce::processAnnounceResponse(const unsigned char* trackerResponse, bool DefaultBtAnnounce::noMoreAnnounce() { return (trackers == 0 && - btRuntime->isHalt() && - !announceList.countStoppedAllowedTier()); + btRuntime->isHalt() && + !announceList.countStoppedAllowedTier()); } void DefaultBtAnnounce::shuffleAnnounce() { diff --git a/src/DefaultBtAnnounce.h b/src/DefaultBtAnnounce.h index dd4dce21..78ccd2ac 100644 --- a/src/DefaultBtAnnounce.h +++ b/src/DefaultBtAnnounce.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -69,7 +69,7 @@ private: SharedHandle<PeerStorage> peerStorage; public: DefaultBtAnnounce(const SharedHandle<DownloadContext>& downloadContext, - const Option* option); + const Option* option); virtual ~DefaultBtAnnounce(); @@ -115,7 +115,7 @@ public: virtual void resetAnnounce(); virtual void processAnnounceResponse(const unsigned char* trackerResponse, - size_t trackerResponseLength); + size_t trackerResponseLength); virtual bool noMoreAnnounce(); diff --git a/src/DefaultBtInteractive.cc b/src/DefaultBtInteractive.cc index 3655b2b2..bb1cf183 100644 --- a/src/DefaultBtInteractive.cc +++ b/src/DefaultBtInteractive.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -107,7 +107,7 @@ BtMessageHandle DefaultBtInteractive::receiveHandshake(bool quickReply) { return SharedHandle<BtMessage>(); } if(memcmp(message->getPeerId(), bittorrent::getStaticPeerId(), - PEER_ID_LENGTH) == 0) { + PEER_ID_LENGTH) == 0) { throw DL_ABORT_EX (StringFormat ("CUID#%d - Drop connection from the same Peer ID", cuid).str()); @@ -131,8 +131,8 @@ BtMessageHandle DefaultBtInteractive::receiveHandshake(bool quickReply) { logger->info(MSG_DHT_ENABLED_PEER, cuid); } logger->info(MSG_RECEIVE_PEER_MESSAGE, cuid, - peer->ipaddr.c_str(), peer->port, - message->toString().c_str()); + peer->ipaddr.c_str(), peer->port, + message->toString().c_str()); return message; } @@ -202,13 +202,13 @@ void DefaultBtInteractive::addAllowedFastMessageToQueue() { if(peer->isFastExtensionEnabled()) { std::vector<size_t> fastSet; bittorrent::computeFastSet(fastSet, peer->ipaddr, - _downloadContext->getNumPieces(), - bittorrent::getInfoHash(_downloadContext), - allowedFastSetSize); + _downloadContext->getNumPieces(), + bittorrent::getInfoHash(_downloadContext), + allowedFastSetSize); for(std::vector<size_t>::const_iterator itr = fastSet.begin(); - itr != fastSet.end(); ++itr) { + itr != fastSet.end(); ++itr) { dispatcher->addMessageToQueue - (messageFactory->createAllowedFastMessage(*itr)); + (messageFactory->createAllowedFastMessage(*itr)); } } } @@ -237,7 +237,7 @@ void DefaultBtInteractive::checkHave() { } } else { for(std::deque<size_t>::iterator itr = indexes.begin(); - itr != indexes.end(); ++itr) { + itr != indexes.end(); ++itr) { dispatcher->addMessageToQueue(messageFactory->createHaveMessage(*itr)); } } @@ -265,8 +265,8 @@ size_t DefaultBtInteractive::receiveMessages() { } ++msgcount; logger->info(MSG_RECEIVE_PEER_MESSAGE, cuid, - peer->ipaddr.c_str(), peer->port, - message->toString().c_str()); + peer->ipaddr.c_str(), peer->port, + message->toString().c_str()); message->doReceivedAction(); switch(message->getId()) { @@ -275,12 +275,12 @@ size_t DefaultBtInteractive::receiveMessages() { break; case BtChokeMessage::ID: if(!peer->peerChoking()) { - floodingStat.incChokeUnchokeCount(); + floodingStat.incChokeUnchokeCount(); } break; case BtUnchokeMessage::ID: if(peer->peerChoking()) { - floodingStat.incChokeUnchokeCount(); + floodingStat.incChokeUnchokeCount(); } break; case BtPieceMessage::ID: @@ -294,7 +294,7 @@ size_t DefaultBtInteractive::receiveMessages() { if(countOldOutstandingRequest > 0 && dispatcher->countOutstandingRequest() == 0){ _maxOutstandingRequest = std::min((size_t)UB_MAX_OUTSTANDING_REQUEST, - _maxOutstandingRequest*2); + _maxOutstandingRequest*2); } return msgcount; } @@ -304,13 +304,13 @@ void DefaultBtInteractive::decideInterest() { if(!peer->amInterested()) { logger->debug(MSG_PEER_INTERESTED, cuid); dispatcher-> - addMessageToQueue(messageFactory->createInterestedMessage()); + addMessageToQueue(messageFactory->createInterestedMessage()); } } else { if(peer->amInterested()) { logger->debug(MSG_PEER_NOT_INTERESTED, cuid); dispatcher-> - addMessageToQueue(messageFactory->createNotInterestedMessage()); + addMessageToQueue(messageFactory->createNotInterestedMessage()); } } } @@ -322,33 +322,33 @@ void DefaultBtInteractive::fillPiece(size_t maxMissingBlock) { if(peer->peerChoking()) { if(peer->isFastExtensionEnabled()) { - std::deque<size_t> excludedIndexes; - btRequestFactory->getTargetPieceIndexes(excludedIndexes); - while(numMissingBlock < maxMissingBlock) { - SharedHandle<Piece> piece = - _pieceStorage->getMissingFastPiece(peer, excludedIndexes); - if(piece.isNull()) { - break; - } else { - btRequestFactory->addTargetPiece(piece); - numMissingBlock += piece->countMissingBlock(); - excludedIndexes.push_back(piece->getIndex()); - } - } + std::deque<size_t> excludedIndexes; + btRequestFactory->getTargetPieceIndexes(excludedIndexes); + while(numMissingBlock < maxMissingBlock) { + SharedHandle<Piece> piece = + _pieceStorage->getMissingFastPiece(peer, excludedIndexes); + if(piece.isNull()) { + break; + } else { + btRequestFactory->addTargetPiece(piece); + numMissingBlock += piece->countMissingBlock(); + excludedIndexes.push_back(piece->getIndex()); + } + } } } else { std::deque<size_t> excludedIndexes; btRequestFactory->getTargetPieceIndexes(excludedIndexes); while(numMissingBlock < maxMissingBlock) { - SharedHandle<Piece> piece = - _pieceStorage->getMissingPiece(peer, excludedIndexes); - if(piece.isNull()) { - break; - } else { - btRequestFactory->addTargetPiece(piece); - numMissingBlock += piece->countMissingBlock(); - excludedIndexes.push_back(piece->getIndex()); - } + SharedHandle<Piece> piece = + _pieceStorage->getMissingPiece(peer, excludedIndexes); + if(piece.isNull()) { + break; + } else { + btRequestFactory->addTargetPiece(piece); + numMissingBlock += piece->countMissingBlock(); + excludedIndexes.push_back(piece->getIndex()); + } } } } @@ -376,9 +376,9 @@ void DefaultBtInteractive::cancelAllPiece() { std::vector<size_t> metadataRequests = _utMetadataRequestTracker->getAllTrackedIndex(); for(std::vector<size_t>::const_iterator i = metadataRequests.begin(); - i != metadataRequests.end(); ++i) { + i != metadataRequests.end(); ++i) { logger->debug("Cancel metadata: piece=%lu", - static_cast<unsigned long>(*i)); + static_cast<unsigned long>(*i)); _pieceStorage->cancelPiece(_pieceStorage->getPiece(*i)); } } @@ -410,8 +410,8 @@ void DefaultBtInteractive::checkActiveInteraction() inactiveCheckPoint.elapsed(interval)) { // TODO change the message throw DL_ABORT_EX - (StringFormat("Disconnect peer because we are not interested each other" - " after %u second(s).", interval).str()); + (StringFormat("Disconnect peer because we are not interested each other" + " after %u second(s).", interval).str()); } } // Since the peers which are *just* connected and do nothing to improve @@ -421,7 +421,7 @@ void DefaultBtInteractive::checkActiveInteraction() const time_t interval = 60; if(inactiveCheckPoint.elapsed(interval)) { throw DL_ABORT_EX - (StringFormat(EX_DROP_INACTIVE_CONNECTION, interval).str()); + (StringFormat(EX_DROP_INACTIVE_CONNECTION, interval).str()); } } } @@ -434,19 +434,19 @@ void DefaultBtInteractive::addPeerExchangeMessage() const Peers& peers = _peerStorage->getPeers(); { for(std::deque<SharedHandle<Peer> >::const_iterator i = - peers.begin(); i != peers.end() && !m->freshPeersAreFull(); ++i) { - if(peer->ipaddr != (*i)->ipaddr) { - m->addFreshPeer(*i); - } + peers.begin(); i != peers.end() && !m->freshPeersAreFull(); ++i) { + if(peer->ipaddr != (*i)->ipaddr) { + m->addFreshPeer(*i); + } } } { for(std::deque<SharedHandle<Peer> >::const_reverse_iterator i = - peers.rbegin(); i != peers.rend() && !m->droppedPeersAreFull(); - ++i) { - if(peer->ipaddr != (*i)->ipaddr) { - m->addDroppedPeer(*i); - } + peers.rbegin(); i != peers.rend() && !m->droppedPeersAreFull(); + ++i) { + if(peer->ipaddr != (*i)->ipaddr) { + m->addDroppedPeer(*i); + } } } BtMessageHandle msg = messageFactory->createBtExtendedMessage(m); @@ -468,24 +468,24 @@ void DefaultBtInteractive::doInteractionProcessing() { _downloadContext->getTotalLength() > 0) { size_t num = _utMetadataRequestTracker->avail(); if(num > 0) { - std::deque<SharedHandle<BtMessage> > requests; - _utMetadataRequestFactory->create(requests, num, _pieceStorage); - dispatcher->addMessageToQueue(requests); + std::deque<SharedHandle<BtMessage> > requests; + _utMetadataRequestFactory->create(requests, num, _pieceStorage); + dispatcher->addMessageToQueue(requests); } if(_perSecCheckPoint.elapsed(1)) { - _perSecCheckPoint.reset(); - // Drop timeout request after queuing message to give a chance - // to other connection to request piece. - std::vector<size_t> indexes = - _utMetadataRequestTracker->removeTimeoutEntry(); - for(std::vector<size_t>::const_iterator i = indexes.begin(); - i != indexes.end(); ++i) { - _pieceStorage->cancelPiece(_pieceStorage->getPiece(*i)); - } + _perSecCheckPoint.reset(); + // Drop timeout request after queuing message to give a chance + // to other connection to request piece. + std::vector<size_t> indexes = + _utMetadataRequestTracker->removeTimeoutEntry(); + for(std::vector<size_t>::const_iterator i = indexes.begin(); + i != indexes.end(); ++i) { + _pieceStorage->cancelPiece(_pieceStorage->getPiece(*i)); + } } if(_pieceStorage->downloadFinished()) { - _downloadContext->getOwnerRequestGroup()->setForceHaltRequested - (true, RequestGroup::NONE); + _downloadContext->getOwnerRequestGroup()->setForceHaltRequested + (true, RequestGroup::NONE); } } } else { diff --git a/src/DefaultBtInteractive.h b/src/DefaultBtInteractive.h index 923e5d07..b3511e75 100644 --- a/src/DefaultBtInteractive.h +++ b/src/DefaultBtInteractive.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -160,7 +160,7 @@ private: public: DefaultBtInteractive(const SharedHandle<DownloadContext>& downloadContext, - const SharedHandle<Peer>& peer); + const SharedHandle<Peer>& peer); virtual ~DefaultBtInteractive(); diff --git a/src/DefaultBtMessageDispatcher.cc b/src/DefaultBtMessageDispatcher.cc index fa201198..22e96d32 100644 --- a/src/DefaultBtMessageDispatcher.cc +++ b/src/DefaultBtMessageDispatcher.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -87,9 +87,9 @@ void DefaultBtMessageDispatcher::sendMessages() { messageQueue.pop_front(); if(msg->isUploading() && !msg->isSendingInProgress()) { if(_requestGroupMan->doesOverallUploadSpeedExceed() || - _downloadContext->getOwnerRequestGroup()->doesUploadSpeedExceed()) { - tempQueue.push_back(msg); - continue; + _downloadContext->getOwnerRequestGroup()->doesUploadSpeedExceed()) { + tempQueue.push_back(msg); + continue; } } msg->send(); @@ -106,10 +106,10 @@ void DefaultBtMessageDispatcher::sendMessages() { // the same order as it is queued. if(!messageQueue.empty() && messageQueue.front()->isSendingInProgress()) { messageQueue.insert(messageQueue.begin()+1, - tempQueue.begin(), tempQueue.end()); + tempQueue.begin(), tempQueue.end()); } else { messageQueue.insert(messageQueue.begin(), - tempQueue.begin(), tempQueue.end()); + tempQueue.begin(), tempQueue.end()); } } } @@ -121,8 +121,8 @@ void DefaultBtMessageDispatcher::doCancelSendingPieceAction(size_t index, uint32 BtMessages tempQueue = messageQueue; - forEachMemFunSH(tempQueue.begin(), tempQueue.end(), - &BtMessage::onCancelSendingPieceEvent, event); + forEachMemFunSH(tempQueue.begin(), tempQueue.end(), + &BtMessage::onCancelSendingPieceEvent, event); } // Cancel sending piece message to peer. @@ -145,9 +145,9 @@ public: void operator()(const RequestSlot& slot) const { _logger->debug(MSG_DELETING_REQUEST_SLOT, - _cuid, - slot.getIndex(), - slot.getBlockIndex()); + _cuid, + slot.getIndex(), + slot.getBlockIndex()); _logger->debug("index=%d, begin=%d", slot.getIndex(), slot.getBegin()); _piece->cancelBlock(slot.getBlockIndex()); } @@ -170,7 +170,7 @@ void DefaultBtMessageDispatcher::doAbortOutstandingRequestAction(const PieceHand BtMessages tempQueue = messageQueue; forEachMemFunSH(tempQueue.begin(), tempQueue.end(), - &BtMessage::onAbortOutstandingRequestEvent, event); + &BtMessage::onAbortOutstandingRequestEvent, event); } class ProcessChokedRequestSlot { @@ -181,8 +181,8 @@ private: Logger* _logger; public: ProcessChokedRequestSlot(int32_t cuid, - const SharedHandle<Peer>& peer, - const SharedHandle<PieceStorage>& pieceStorage): + const SharedHandle<Peer>& peer, + const SharedHandle<PieceStorage>& pieceStorage): _cuid(cuid), _peer(peer), _pieceStorage(pieceStorage), @@ -192,9 +192,9 @@ public: { if(!_peer->isInPeerAllowedIndexSet(slot.getIndex())) { _logger->debug(MSG_DELETING_REQUEST_SLOT_CHOKED, - _cuid, - slot.getIndex(), - slot.getBlockIndex()); + _cuid, + slot.getIndex(), + slot.getBlockIndex()); _logger->debug("index=%d, begin=%d", slot.getIndex(), slot.getBegin()); SharedHandle<Piece> piece = _pieceStorage->getPiece(slot.getIndex()); piece->cancelBlock(slot.getBlockIndex()); @@ -220,11 +220,11 @@ public: void DefaultBtMessageDispatcher::doChokedAction() { std::for_each(requestSlots.begin(), requestSlots.end(), - ProcessChokedRequestSlot(cuid, peer, _pieceStorage)); + ProcessChokedRequestSlot(cuid, peer, _pieceStorage)); requestSlots.erase(std::remove_if(requestSlots.begin(), requestSlots.end(), - FindChokedRequestSlot(peer)), - requestSlots.end()); + FindChokedRequestSlot(peer)), + requestSlots.end()); } // localhost dispatched choke message to the peer. @@ -234,7 +234,7 @@ void DefaultBtMessageDispatcher::doChokingAction() BtMessages tempQueue = messageQueue; forEachMemFunSH(tempQueue.begin(), tempQueue.end(), - &BtMessage::onChokingEvent, event); + &BtMessage::onChokingEvent, event); } class ProcessStaleRequestSlot { @@ -249,11 +249,11 @@ private: Logger* _logger; public: ProcessStaleRequestSlot(int32_t cuid, const SharedHandle<Peer>& peer, - const SharedHandle<PieceStorage>& pieceStorage, - BtMessageDispatcher* dispatcher, - const WeakHandle<BtMessageFactory>& factory, - const struct timeval& now, - time_t requestTimeout): + const SharedHandle<PieceStorage>& pieceStorage, + BtMessageDispatcher* dispatcher, + const WeakHandle<BtMessageFactory>& factory, + const struct timeval& now, + time_t requestTimeout): _cuid(cuid), _peer(peer), _pieceStorage(pieceStorage), @@ -267,20 +267,20 @@ public: { if(slot.isTimeout(_now, _requestTimeout)) { _logger->debug(MSG_DELETING_REQUEST_SLOT_TIMEOUT, - _cuid, - slot.getBlockIndex()); + _cuid, + slot.getBlockIndex()); _logger->debug("index=%d, begin=%d", slot.getIndex(), slot.getBegin()); slot.getPiece()->cancelBlock(slot.getBlockIndex()); _peer->snubbing(true); } else if(slot.getPiece()->hasBlock(slot.getBlockIndex())) { _logger->debug(MSG_DELETING_REQUEST_SLOT_ACQUIRED, - _cuid, - slot.getBlockIndex()); + _cuid, + slot.getBlockIndex()); _logger->debug("index=%d, begin=%d", slot.getIndex(), slot.getBegin()); _messageDispatcher->addMessageToQueue - (_messageFactory->createCancelMessage(slot.getIndex(), - slot.getBegin(), - slot.getLength())); + (_messageFactory->createCancelMessage(slot.getIndex(), + slot.getBegin(), + slot.getLength())); } } }; @@ -292,8 +292,8 @@ private: time_t _requestTimeout; public: FindStaleRequestSlot(const SharedHandle<PieceStorage>& pieceStorage, - const struct timeval& now, - time_t requestTimeout): + const struct timeval& now, + time_t requestTimeout): _pieceStorage(pieceStorage), _now(now), _requestTimeout(requestTimeout) {} @@ -304,9 +304,9 @@ public: return true; } else { if(slot.getPiece()->hasBlock(slot.getBlockIndex())) { - return true; + return true; } else { - return false; + return false; } } } @@ -318,18 +318,18 @@ void DefaultBtMessageDispatcher::checkRequestSlotAndDoNecessaryThing() gettimeofday(&now, 0); std::for_each(requestSlots.begin(), requestSlots.end(), - ProcessStaleRequestSlot(cuid, - peer, - _pieceStorage, - this, - messageFactory, - now, - requestTimeout)); + ProcessStaleRequestSlot(cuid, + peer, + _pieceStorage, + this, + messageFactory, + now, + requestTimeout)); requestSlots.erase(std::remove_if(requestSlots.begin(), requestSlots.end(), - FindStaleRequestSlot(_pieceStorage, - now, - requestTimeout)), - requestSlots.end()); + FindStaleRequestSlot(_pieceStorage, + now, + requestTimeout)), + requestSlots.end()); } bool DefaultBtMessageDispatcher::isSendingInProgress() @@ -404,7 +404,7 @@ void DefaultBtMessageDispatcher::addOutstandingRequest(const RequestSlot& slot) size_t DefaultBtMessageDispatcher::countOutstandingUpload() { return std::count_if(messageQueue.begin(), messageQueue.end(), - mem_fun_sh(&BtMessage::isUploading)); + mem_fun_sh(&BtMessage::isUploading)); } void DefaultBtMessageDispatcher::setPeer(const SharedHandle<Peer>& peer) diff --git a/src/DefaultBtMessageDispatcher.h b/src/DefaultBtMessageDispatcher.h index 0b5caae6..7805c143 100644 --- a/src/DefaultBtMessageDispatcher.h +++ b/src/DefaultBtMessageDispatcher.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/DefaultBtMessageFactory.cc b/src/DefaultBtMessageFactory.cc index 51be6c1f..1635979f 100644 --- a/src/DefaultBtMessageFactory.cc +++ b/src/DefaultBtMessageFactory.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -71,8 +71,8 @@ namespace aria2 { DefaultBtMessageFactory::DefaultBtMessageFactory():cuid(0), - _dhtEnabled(false), - _metadataGetMode(false) + _dhtEnabled(false), + _metadataGetMode(false) {} DefaultBtMessageFactory::~DefaultBtMessageFactory() {} @@ -95,52 +95,52 @@ DefaultBtMessageFactory::createBtMessage(const unsigned char* data, size_t dataL break; case BtInterestedMessage::ID: { - SharedHandle<BtInterestedMessage> m = - BtInterestedMessage::create(data, dataLength); - m->setPeerStorage(_peerStorage); - msg = m; + SharedHandle<BtInterestedMessage> m = + BtInterestedMessage::create(data, dataLength); + m->setPeerStorage(_peerStorage); + msg = m; } break; case BtNotInterestedMessage::ID: { - SharedHandle<BtNotInterestedMessage> m = - BtNotInterestedMessage::create(data, dataLength); - m->setPeerStorage(_peerStorage); - msg = m; + SharedHandle<BtNotInterestedMessage> m = + BtNotInterestedMessage::create(data, dataLength); + m->setPeerStorage(_peerStorage); + msg = m; } break; case BtHaveMessage::ID: msg = BtHaveMessage::create(data, dataLength); { - if(!_metadataGetMode) { - SharedHandle<BtMessageValidator> v - (new IndexBtMessageValidator(static_cast<BtHaveMessage*>(msg.get()), - _downloadContext->getNumPieces())); - msg->setBtMessageValidator(v); - } + if(!_metadataGetMode) { + SharedHandle<BtMessageValidator> v + (new IndexBtMessageValidator(static_cast<BtHaveMessage*>(msg.get()), + _downloadContext->getNumPieces())); + msg->setBtMessageValidator(v); + } } break; case BtBitfieldMessage::ID: msg = BtBitfieldMessage::create(data, dataLength); { - if(!_metadataGetMode) { - SharedHandle<BtMessageValidator> v - (new BtBitfieldMessageValidator - (static_cast<BtBitfieldMessage*>(msg.get()), - _downloadContext->getNumPieces())); - msg->setBtMessageValidator(v); - } + if(!_metadataGetMode) { + SharedHandle<BtMessageValidator> v + (new BtBitfieldMessageValidator + (static_cast<BtBitfieldMessage*>(msg.get()), + _downloadContext->getNumPieces())); + msg->setBtMessageValidator(v); + } } break; case BtRequestMessage::ID: { BtRequestMessageHandle temp = BtRequestMessage::create(data, dataLength); if(!_metadataGetMode) { - SharedHandle<BtMessageValidator> validator - (new RangeBtMessageValidator - (temp.get(), - _downloadContext->getNumPieces(), - _pieceStorage->getPieceLength(temp->getIndex()))); - temp->setBtMessageValidator(validator); + SharedHandle<BtMessageValidator> validator + (new RangeBtMessageValidator + (temp.get(), + _downloadContext->getNumPieces(), + _pieceStorage->getPieceLength(temp->getIndex()))); + temp->setBtMessageValidator(validator); } msg = temp; break; @@ -148,12 +148,12 @@ DefaultBtMessageFactory::createBtMessage(const unsigned char* data, size_t dataL case BtCancelMessage::ID: { BtCancelMessageHandle temp = BtCancelMessage::create(data, dataLength); if(!_metadataGetMode) { - SharedHandle<BtMessageValidator> validator - (new RangeBtMessageValidator - (temp.get(), - _downloadContext->getNumPieces(), - _pieceStorage->getPieceLength(temp->getIndex()))); - temp->setBtMessageValidator(validator); + SharedHandle<BtMessageValidator> validator + (new RangeBtMessageValidator + (temp.get(), + _downloadContext->getNumPieces(), + _pieceStorage->getPieceLength(temp->getIndex()))); + temp->setBtMessageValidator(validator); } msg = temp; break; @@ -161,11 +161,11 @@ DefaultBtMessageFactory::createBtMessage(const unsigned char* data, size_t dataL case BtPieceMessage::ID: { BtPieceMessageHandle temp = BtPieceMessage::create(data, dataLength); if(!_metadataGetMode) { - BtMessageValidatorHandle validator - (new BtPieceMessageValidator(temp.get(), - _downloadContext->getNumPieces(), - _pieceStorage->getPieceLength(temp->getIndex()))); - temp->setBtMessageValidator(validator); + BtMessageValidatorHandle validator + (new BtPieceMessageValidator(temp.get(), + _downloadContext->getNumPieces(), + _pieceStorage->getPieceLength(temp->getIndex()))); + temp->setBtMessageValidator(validator); } temp->setDownloadContext(_downloadContext); msg = temp; @@ -180,12 +180,12 @@ DefaultBtMessageFactory::createBtMessage(const unsigned char* data, size_t dataL case BtRejectMessage::ID: { BtRejectMessageHandle temp = BtRejectMessage::create(data, dataLength); if(!_metadataGetMode) { - SharedHandle<BtMessageValidator> validator - (new RangeBtMessageValidator - (temp.get(), - _downloadContext->getNumPieces(), - _pieceStorage->getPieceLength(temp->getIndex()))); - temp->setBtMessageValidator(validator); + SharedHandle<BtMessageValidator> validator + (new RangeBtMessageValidator + (temp.get(), + _downloadContext->getNumPieces(), + _pieceStorage->getPieceLength(temp->getIndex()))); + temp->setBtMessageValidator(validator); } msg = temp; break; @@ -193,10 +193,10 @@ DefaultBtMessageFactory::createBtMessage(const unsigned char* data, size_t dataL case BtSuggestPieceMessage::ID: { BtSuggestPieceMessageHandle temp = BtSuggestPieceMessage::create(data, dataLength); if(!_metadataGetMode) { - SharedHandle<BtMessageValidator> validator - (new IndexBtMessageValidator(temp.get(), - _downloadContext->getNumPieces())); - temp->setBtMessageValidator(validator); + SharedHandle<BtMessageValidator> validator + (new IndexBtMessageValidator(temp.get(), + _downloadContext->getNumPieces())); + temp->setBtMessageValidator(validator); } msg = temp; break; @@ -204,10 +204,10 @@ DefaultBtMessageFactory::createBtMessage(const unsigned char* data, size_t dataL case BtAllowedFastMessage::ID: { BtAllowedFastMessageHandle temp = BtAllowedFastMessage::create(data, dataLength); if(!_metadataGetMode) { - SharedHandle<BtMessageValidator> validator - (new IndexBtMessageValidator(temp.get(), - _downloadContext->getNumPieces())); - temp->setBtMessageValidator(validator); + SharedHandle<BtMessageValidator> validator + (new IndexBtMessageValidator(temp.get(), + _downloadContext->getNumPieces())); + temp->setBtMessageValidator(validator); } msg = temp; break; @@ -223,10 +223,10 @@ DefaultBtMessageFactory::createBtMessage(const unsigned char* data, size_t dataL } case BtExtendedMessage::ID: { if(peer->isExtendedMessagingEnabled()) { - msg = BtExtendedMessage::create(_extensionMessageFactory, - peer, data, dataLength); + msg = BtExtendedMessage::create(_extensionMessageFactory, + peer, data, dataLength); } else { - throw DL_ABORT_EX("Received extended message from peer during a session with extended messaging disabled."); + throw DL_ABORT_EX("Received extended message from peer during a session with extended messaging disabled."); } break; } @@ -265,7 +265,7 @@ DefaultBtMessageFactory::createHandshakeMessage(const unsigned char* data, size_ SharedHandle<BtHandshakeMessage> DefaultBtMessageFactory::createHandshakeMessage(const unsigned char* infoHash, - const unsigned char* peerId) + const unsigned char* peerId) { SharedHandle<BtHandshakeMessage> msg(new BtHandshakeMessage(infoHash, peerId)); BtMessageValidatorHandle validator @@ -282,9 +282,9 @@ DefaultBtMessageFactory::createRequestMessage(const PieceHandle& piece, size_t b { BtRequestMessageHandle msg (new BtRequestMessage(piece->getIndex(), - blockIndex*piece->getBlockLength(), - piece->getBlockLength(blockIndex), - blockIndex)); + blockIndex*piece->getBlockLength(), + piece->getBlockLength(blockIndex), + blockIndex)); SharedHandle<BtMessageValidator> validator (new RangeBtMessageValidator (msg.get(), @@ -315,8 +315,8 @@ DefaultBtMessageFactory::createPieceMessage(size_t index, uint32_t begin, size_t BtPieceMessageHandle msg(new BtPieceMessage(index, begin, length)); BtMessageValidatorHandle validator (new BtPieceMessageValidator(msg.get(), - _downloadContext->getNumPieces(), - _pieceStorage->getPieceLength(index))); + _downloadContext->getNumPieces(), + _pieceStorage->getPieceLength(index))); msg->setBtMessageValidator(validator); msg->setDownloadContext(_downloadContext); setCommonProperty(msg); @@ -371,10 +371,10 @@ DefaultBtMessageFactory::createBitfieldMessage() { BtBitfieldMessageHandle msg (new BtBitfieldMessage(_pieceStorage->getBitfield(), - _pieceStorage->getBitfieldLength())); + _pieceStorage->getBitfieldLength())); SharedHandle<BtMessageValidator> v (new BtBitfieldMessageValidator(msg.get(), - _downloadContext->getNumPieces())); + _downloadContext->getNumPieces())); msg->setBtMessageValidator(v); setCommonProperty(msg); return msg; diff --git a/src/DefaultBtMessageFactory.h b/src/DefaultBtMessageFactory.h index 411767af..811b2315 100644 --- a/src/DefaultBtMessageFactory.h +++ b/src/DefaultBtMessageFactory.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -95,7 +95,7 @@ public: virtual SharedHandle<BtHandshakeMessage> createHandshakeMessage(const unsigned char* infoHash, - const unsigned char* peerId); + const unsigned char* peerId); virtual SharedHandle<BtMessage> createRequestMessage(const SharedHandle<Piece>& piece, size_t blockIndex); diff --git a/src/DefaultBtMessageReceiver.cc b/src/DefaultBtMessageReceiver.cc index 9e5ee0f4..0d4d462d 100644 --- a/src/DefaultBtMessageReceiver.cc +++ b/src/DefaultBtMessageReceiver.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -73,7 +73,7 @@ DefaultBtMessageReceiver::receiveHandshake(bool quickReply) handshakeSent = true; // check info_hash if(memcmp(bittorrent::getInfoHash(_downloadContext), &data[28], - INFO_HASH_LENGTH) == 0) { + INFO_HASH_LENGTH) == 0) { sendHandshake(); } } diff --git a/src/DefaultBtMessageReceiver.h b/src/DefaultBtMessageReceiver.h index a5bbbf27..c66b46f0 100644 --- a/src/DefaultBtMessageReceiver.h +++ b/src/DefaultBtMessageReceiver.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/DefaultBtProgressInfoFile.cc b/src/DefaultBtProgressInfoFile.cc index 37aeb7a5..73ba5d4a 100644 --- a/src/DefaultBtProgressInfoFile.cc +++ b/src/DefaultBtProgressInfoFile.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -110,7 +110,7 @@ void DefaultBtProgressInfoFile::save() std::ofstream o(filenameTemp.c_str(), std::ios::out|std::ios::binary); if(!o) { throw DL_ABORT_EX(StringFormat(EX_SEGMENT_FILE_WRITE, - _filename.c_str(), strerror(errno)).str()); + _filename.c_str(), strerror(errno)).str()); } #ifdef ENABLE_BITTORRENT bool torrentDownload = isTorrentDownload(); @@ -138,7 +138,7 @@ void DefaultBtProgressInfoFile::save() const unsigned char* infoHash = bittorrent::getInfoHash(_dctx); uint32_t infoHashLengthNL = htonl(INFO_HASH_LENGTH); o.write(reinterpret_cast<const char*>(&infoHashLengthNL), - sizeof(infoHashLengthNL)); + sizeof(infoHashLengthNL)); // infoHash: o.write(reinterpret_cast<const char*>(infoHash), INFO_HASH_LENGTH); #endif // ENABLE_BITTORRENT @@ -147,16 +147,16 @@ void DefaultBtProgressInfoFile::save() // length: 32 bits uint32_t infoHashLength = 0; o.write(reinterpret_cast<const char*>(&infoHashLength), - sizeof(infoHashLength)); + sizeof(infoHashLength)); } // pieceLength: 32 bits uint32_t pieceLengthNL = htonl(_dctx->getPieceLength()); o.write(reinterpret_cast<const char*>(&pieceLengthNL), - sizeof(pieceLengthNL)); + sizeof(pieceLengthNL)); // totalLength: 64 bits uint64_t totalLengthNL = hton64(_dctx->getTotalLength()); o.write(reinterpret_cast<const char*>(&totalLengthNL), - sizeof(totalLengthNL)); + sizeof(totalLengthNL)); // uploadLength: 64 bits uint64_t uploadLengthNL = 0; #ifdef ENABLE_BITTORRENT @@ -166,54 +166,54 @@ void DefaultBtProgressInfoFile::save() } #endif // ENABLE_BITTORRENT o.write(reinterpret_cast<const char*>(&uploadLengthNL), - sizeof(uploadLengthNL)); + sizeof(uploadLengthNL)); // bitfieldLength: 32 bits uint32_t bitfieldLengthNL = htonl(_pieceStorage->getBitfieldLength()); o.write(reinterpret_cast<const char*>(&bitfieldLengthNL), - sizeof(bitfieldLengthNL)); + sizeof(bitfieldLengthNL)); // bitfield o.write(reinterpret_cast<const char*>(_pieceStorage->getBitfield()), - _pieceStorage->getBitfieldLength()); + _pieceStorage->getBitfieldLength()); // the number of in-flight piece: 32 bits // TODO implement this uint32_t numInFlightPieceNL = htonl(_pieceStorage->countInFlightPiece()); o.write(reinterpret_cast<const char*>(&numInFlightPieceNL), - sizeof(numInFlightPieceNL)); + sizeof(numInFlightPieceNL)); Pieces inFlightPieces; _pieceStorage->getInFlightPieces(inFlightPieces); for(Pieces::const_iterator itr = inFlightPieces.begin(); - itr != inFlightPieces.end(); ++itr) { + itr != inFlightPieces.end(); ++itr) { uint32_t indexNL = htonl((*itr)->getIndex()); o.write(reinterpret_cast<const char*>(&indexNL), sizeof(indexNL)); uint32_t lengthNL = htonl((*itr)->getLength()); o.write(reinterpret_cast<const char*>(&lengthNL), sizeof(lengthNL)); uint32_t bitfieldLengthNL = htonl((*itr)->getBitfieldLength()); o.write(reinterpret_cast<const char*>(&bitfieldLengthNL), - sizeof(bitfieldLengthNL)); + sizeof(bitfieldLengthNL)); o.write(reinterpret_cast<const char*>((*itr)->getBitfield()), - (*itr)->getBitfieldLength()); + (*itr)->getBitfieldLength()); } o.flush(); if(!o) { throw DL_ABORT_EX(StringFormat(EX_SEGMENT_FILE_WRITE, - _filename.c_str(), strerror(errno)).str()); + _filename.c_str(), strerror(errno)).str()); } _logger->info(MSG_SAVED_SEGMENT_FILE); } if(!File(filenameTemp).renameTo(_filename)) { throw DL_ABORT_EX(StringFormat(EX_SEGMENT_FILE_WRITE, - _filename.c_str(), strerror(errno)).str()); + _filename.c_str(), strerror(errno)).str()); } } -#define CHECK_STREAM(in, length) \ - if(in.gcount() != length) { \ - throw DL_ABORT_EX(StringFormat(EX_SEGMENT_FILE_READ, \ - _filename.c_str(),"Unexpected EOF").str()); \ - } \ - if(!in) { \ - throw DL_ABORT_EX(StringFormat(EX_SEGMENT_FILE_READ, \ - _filename.c_str(), strerror(errno)).str()); \ +#define CHECK_STREAM(in, length) \ + if(in.gcount() != length) { \ + throw DL_ABORT_EX(StringFormat(EX_SEGMENT_FILE_READ, \ + _filename.c_str(),"Unexpected EOF").str()); \ + } \ + if(!in) { \ + throw DL_ABORT_EX(StringFormat(EX_SEGMENT_FILE_READ, \ + _filename.c_str(), strerror(errno)).str()); \ } // It is assumed that integers are saved as: @@ -223,9 +223,9 @@ void DefaultBtProgressInfoFile::load() { _logger->info(MSG_LOADING_SEGMENT_FILE, _filename.c_str()); std::ifstream in(_filename.c_str(), std::ios::in|std::ios::binary); - if(!in) { \ - throw DL_ABORT_EX(StringFormat(EX_SEGMENT_FILE_READ, \ - _filename.c_str(), strerror(errno)).str()); + if(!in) { \ + throw DL_ABORT_EX(StringFormat(EX_SEGMENT_FILE_READ, \ + _filename.c_str(), strerror(errno)).str()); } unsigned char versionBuf[2]; in.read(reinterpret_cast<char*>(versionBuf), sizeof(versionBuf)); @@ -239,7 +239,7 @@ void DefaultBtProgressInfoFile::load() } else { throw DL_ABORT_EX (StringFormat("Unsupported ctrl file version: %s", - versionHex.c_str()).str()); + versionHex.c_str()).str()); } unsigned char extension[4]; in.read(reinterpret_cast<char*>(extension), sizeof(extension)); @@ -264,18 +264,18 @@ void DefaultBtProgressInfoFile::load() if(infoHashLength > 0) { array_ptr<unsigned char> savedInfoHash(new unsigned char[infoHashLength]); in.read(reinterpret_cast<char*> - (static_cast<unsigned char*>(savedInfoHash)), infoHashLength); + (static_cast<unsigned char*>(savedInfoHash)), infoHashLength); CHECK_STREAM(in, static_cast<int>(infoHashLength)); #ifdef ENABLE_BITTORRENT if(infoHashCheckEnabled) { const unsigned char* infoHash = bittorrent::getInfoHash(_dctx); if(infoHashLength != INFO_HASH_LENGTH || - 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() - ).str()); + 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() + ).str()); } } #endif // ENABLE_BITTORRENT @@ -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<char*>(&uploadLength), sizeof(uploadLength)); @@ -323,20 +323,20 @@ void DefaultBtProgressInfoFile::load() if(expectedBitfieldLength != bitfieldLength) { throw DL_ABORT_EX (StringFormat("bitfield length mismatch. expected: %d, actual: %d", - expectedBitfieldLength, - bitfieldLength).str()); + expectedBitfieldLength, + bitfieldLength).str()); } array_ptr<unsigned char> savedBitfield(new unsigned char[bitfieldLength]); in.read(reinterpret_cast<char*> - (static_cast<unsigned char*>(savedBitfield)), bitfieldLength); + (static_cast<unsigned char*>(savedBitfield)), bitfieldLength); CHECK_STREAM(in, static_cast<int>(bitfieldLength)); if(pieceLength == _dctx->getPieceLength()) { _pieceStorage->setBitfield(savedBitfield, bitfieldLength); uint32_t numInFlightPiece; in.read(reinterpret_cast<char*>(&numInFlightPiece), - sizeof(numInFlightPiece)); + sizeof(numInFlightPiece)); CHECK_STREAM(in, sizeof(numInFlightPiece)); if(version >= 1) { numInFlightPiece = ntohl(numInFlightPiece); @@ -347,40 +347,40 @@ void DefaultBtProgressInfoFile::load() in.read(reinterpret_cast<char*>(&index), sizeof(index)); CHECK_STREAM(in, sizeof(index)); if(version >= 1) { - index = ntohl(index); + index = ntohl(index); } if(!(index < _dctx->getNumPieces())) { - throw DL_ABORT_EX - (StringFormat("piece index out of range: %u", index).str()); + throw DL_ABORT_EX + (StringFormat("piece index out of range: %u", index).str()); } uint32_t length; in.read(reinterpret_cast<char*>(&length), sizeof(length)); CHECK_STREAM(in, sizeof(length)); if(version >= 1) { - length = ntohl(length); + length = ntohl(length); } if(!(length <=_dctx->getPieceLength())) { - throw DL_ABORT_EX - (StringFormat("piece length out of range: %u", length).str()); + throw DL_ABORT_EX + (StringFormat("piece length out of range: %u", length).str()); } PieceHandle piece(new Piece(index, length)); uint32_t bitfieldLength; in.read(reinterpret_cast<char*>(&bitfieldLength), - sizeof(bitfieldLength)); + sizeof(bitfieldLength)); CHECK_STREAM(in, sizeof(bitfieldLength)); if(version >= 1) { - bitfieldLength = ntohl(bitfieldLength); + bitfieldLength = ntohl(bitfieldLength); } if(piece->getBitfieldLength() != bitfieldLength) { - throw DL_ABORT_EX - (StringFormat("piece bitfield length mismatch." - " expected: %u actual: %u", - piece->getBitfieldLength(), bitfieldLength).str()); + throw DL_ABORT_EX + (StringFormat("piece bitfield length mismatch." + " expected: %u actual: %u", + piece->getBitfieldLength(), bitfieldLength).str()); } array_ptr<unsigned char> pieceBitfield - (new unsigned char[bitfieldLength]); + (new unsigned char[bitfieldLength]); in.read(reinterpret_cast<char*> - (static_cast<unsigned char*>(pieceBitfield)), bitfieldLength); + (static_cast<unsigned char*>(pieceBitfield)), bitfieldLength); CHECK_STREAM(in, static_cast<int>(bitfieldLength)); piece->setBitfield(pieceBitfield, bitfieldLength); @@ -389,14 +389,14 @@ void DefaultBtProgressInfoFile::load() piece->setHashAlgo(_dctx->getPieceHashAlgo()); #endif // ENABLE_MESSAGE_DIGEST - + inFlightPieces.push_back(piece); } _pieceStorage->addInFlightPiece(inFlightPieces); } else { uint32_t numInFlightPiece; in.read(reinterpret_cast<char*>(&numInFlightPiece), - sizeof(numInFlightPiece)); + sizeof(numInFlightPiece)); CHECK_STREAM(in, sizeof(numInFlightPiece)); if(version >= 1) { numInFlightPiece = ntohl(numInFlightPiece); @@ -406,9 +406,9 @@ void DefaultBtProgressInfoFile::load() if((src.getCompletedLength() || numInFlightPiece) && !_option->getAsBool(PREF_ALLOW_PIECE_LENGTH_CHANGE)) { throw DOWNLOAD_FAILURE_EXCEPTION - ("WARNING: Detected a change in piece length. You can proceed with" - " --allow-piece-length-change=true, but you may lose some download" - " progress."); + ("WARNING: Detected a change in piece length. You can proceed with" + " --allow-piece-length-change=true, but you may lose some download" + " progress."); } BitfieldMan dest(_dctx->getPieceLength(), totalLength); util::convertBitfield(&dest, &src); diff --git a/src/DefaultBtProgressInfoFile.h b/src/DefaultBtProgressInfoFile.h index e12de2b7..e868a32a 100644 --- a/src/DefaultBtProgressInfoFile.h +++ b/src/DefaultBtProgressInfoFile.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -64,8 +64,8 @@ private: static const std::string V0001; public: DefaultBtProgressInfoFile(const SharedHandle<DownloadContext>& btContext, - const SharedHandle<PieceStorage>& pieceStorage, - const Option* option); + const SharedHandle<PieceStorage>& pieceStorage, + const Option* option); virtual ~DefaultBtProgressInfoFile(); diff --git a/src/DefaultBtRequestFactory.cc b/src/DefaultBtRequestFactory.cc index 059c411c..d97a8d33 100644 --- a/src/DefaultBtRequestFactory.cc +++ b/src/DefaultBtRequestFactory.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -85,15 +85,15 @@ public: void DefaultBtRequestFactory::removeCompletedPiece() { std::for_each(pieces.begin(), pieces.end(), - AbortCompletedPieceRequest(dispatcher)); + AbortCompletedPieceRequest(dispatcher)); pieces.erase(std::remove_if(pieces.begin(), pieces.end(), - mem_fun_sh(&Piece::pieceComplete)), - pieces.end()); + mem_fun_sh(&Piece::pieceComplete)), + pieces.end()); } void DefaultBtRequestFactory::removeTargetPiece(const PieceHandle& piece) { pieces.erase(std::remove(pieces.begin(), pieces.end(), piece), - pieces.end()); + pieces.end()); dispatcher->doAbortOutstandingRequestAction(piece); _pieceStorage->cancelPiece(piece); } @@ -104,7 +104,7 @@ private: WeakHandle<PieceStorage> _pieceStorage; public: ProcessChokedPiece(const SharedHandle<Peer>& peer, - const WeakHandle<PieceStorage>& pieceStorage): + const WeakHandle<PieceStorage>& pieceStorage): _peer(peer), _pieceStorage(pieceStorage) {} @@ -131,10 +131,10 @@ public: void DefaultBtRequestFactory::doChokedAction() { std::for_each(pieces.begin(), pieces.end(), - ProcessChokedPiece(peer, _pieceStorage)); + ProcessChokedPiece(peer, _pieceStorage)); pieces.erase(std::remove_if(pieces.begin(), pieces.end(), - FindChokedPiece(peer)), - pieces.end()); + FindChokedPiece(peer)), + pieces.end()); } void DefaultBtRequestFactory::removeAllTargetPiece() { @@ -153,11 +153,11 @@ void DefaultBtRequestFactory::createRequestMessages PieceHandle& piece = *itr; size_t blockIndex; while(requests.size() < max && - piece->getMissingUnusedBlockIndex(blockIndex)) { + piece->getMissingUnusedBlockIndex(blockIndex)) { _logger->debug("Creating RequestMessage index=%u, begin=%u, blockIndex=%u", - piece->getIndex(), - blockIndex*piece->getBlockLength(), - blockIndex); + piece->getIndex(), + blockIndex*piece->getBlockLength(), + blockIndex); requests.push_back(messageFactory->createRequestMessage(piece, blockIndex)); } @@ -181,23 +181,23 @@ void DefaultBtRequestFactory::createRequestMessagesOnEndGame unsigned char bits = misbitfield[i]; unsigned char mask = 128; for(size_t bi = 0; bi < 8; ++bi, mask >>= 1, ++blockIndex) { - if(bits & mask) { - missingBlockIndexes.push_back(blockIndex); - } + if(bits & mask) { + missingBlockIndexes.push_back(blockIndex); + } } } std::random_shuffle(missingBlockIndexes.begin(), missingBlockIndexes.end(), - *(SimpleRandomizer::getInstance().get())); + *(SimpleRandomizer::getInstance().get())); for(std::deque<size_t>::const_iterator bitr = missingBlockIndexes.begin(); - bitr != missingBlockIndexes.end() && requests.size() < max; bitr++) { + bitr != missingBlockIndexes.end() && requests.size() < max; bitr++) { const size_t& blockIndex = *bitr; if(!dispatcher->isOutstandingRequest(piece->getIndex(), - blockIndex)) { - _logger->debug("Creating RequestMessage index=%u, begin=%u, blockIndex=%u", - piece->getIndex(), - blockIndex*piece->getBlockLength(), - blockIndex); - requests.push_back(messageFactory->createRequestMessage(piece, blockIndex)); + blockIndex)) { + _logger->debug("Creating RequestMessage index=%u, begin=%u, blockIndex=%u", + piece->getIndex(), + blockIndex*piece->getBlockLength(), + blockIndex); + requests.push_back(messageFactory->createRequestMessage(piece, blockIndex)); } } } @@ -224,14 +224,14 @@ public: size_t DefaultBtRequestFactory::countMissingBlock() { return std::for_each(pieces.begin(), pieces.end(), - CountMissingBlock()).getNumMissingBlock(); + CountMissingBlock()).getNumMissingBlock(); } void DefaultBtRequestFactory::getTargetPieceIndexes (std::deque<size_t>& indexes) const { std::transform(pieces.begin(), pieces.end(), std::back_inserter(indexes), - mem_fun_sh(&Piece::getIndex)); + mem_fun_sh(&Piece::getIndex)); } void DefaultBtRequestFactory::setPieceStorage diff --git a/src/DefaultBtRequestFactory.h b/src/DefaultBtRequestFactory.h index bcf8c8cf..3df8146d 100644 --- a/src/DefaultBtRequestFactory.h +++ b/src/DefaultBtRequestFactory.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/DefaultDiskWriter.cc b/src/DefaultDiskWriter.cc index 2ef52d84..7b475d8f 100644 --- a/src/DefaultDiskWriter.cc +++ b/src/DefaultDiskWriter.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/DefaultDiskWriter.h b/src/DefaultDiskWriter.h index db355ba0..bf12f48d 100644 --- a/src/DefaultDiskWriter.h +++ b/src/DefaultDiskWriter.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/DefaultDiskWriterFactory.cc b/src/DefaultDiskWriterFactory.cc index 96d2aed3..7107eae8 100644 --- a/src/DefaultDiskWriterFactory.cc +++ b/src/DefaultDiskWriterFactory.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/DefaultDiskWriterFactory.h b/src/DefaultDiskWriterFactory.h index 5371f47c..929f5224 100644 --- a/src/DefaultDiskWriterFactory.h +++ b/src/DefaultDiskWriterFactory.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/DefaultExtensionMessageFactory.cc b/src/DefaultExtensionMessageFactory.cc index 6dae3cd4..d9f87aef 100644 --- a/src/DefaultExtensionMessageFactory.cc +++ b/src/DefaultExtensionMessageFactory.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -82,77 +82,77 @@ DefaultExtensionMessageFactory::createMessage(const unsigned char* data, size_t std::string extensionName = _registry->getExtensionName(extensionMessageID); if(extensionName.empty()) { throw DL_ABORT_EX - (StringFormat("No extension registered for extended message ID %u", - extensionMessageID).str()); + (StringFormat("No extension registered for extended message ID %u", + extensionMessageID).str()); } if(extensionName == "ut_pex") { // uTorrent compatible Peer-Exchange UTPexExtensionMessageHandle m = - UTPexExtensionMessage::create(data, length); + UTPexExtensionMessage::create(data, length); m->setPeerStorage(_peerStorage); return m; } else if(extensionName == "ut_metadata") { if(length == 0) { - throw DL_ABORT_EX(StringFormat(MSG_TOO_SMALL_PAYLOAD_SIZE, - "ut_metadata", length).str()); + throw DL_ABORT_EX(StringFormat(MSG_TOO_SMALL_PAYLOAD_SIZE, + "ut_metadata", length).str()); } size_t end; BDE dict = bencode::decode(data+1, length-1, end); if(!dict.isDict()) { - throw DL_ABORT_EX("Bad ut_metadata: dictionary not found"); + throw DL_ABORT_EX("Bad ut_metadata: dictionary not found"); } const BDE& msgType = dict["msg_type"]; if(!msgType.isInteger()) { - throw DL_ABORT_EX("Bad ut_metadata: msg_type not found"); + throw DL_ABORT_EX("Bad ut_metadata: msg_type not found"); } const BDE& index = dict["piece"]; if(!index.isInteger()) { - throw DL_ABORT_EX("Bad ut_metadata: piece not found"); + throw DL_ABORT_EX("Bad ut_metadata: piece not found"); } switch(msgType.i()) { case 0: { - SharedHandle<UTMetadataRequestExtensionMessage> m - (new UTMetadataRequestExtensionMessage(extensionMessageID)); - m->setIndex(index.i()); - m->setDownloadContext(_dctx); - m->setPeer(_peer); - m->setBtMessageFactory(_messageFactory); - m->setBtMessageDispatcher(_dispatcher); - return m; + SharedHandle<UTMetadataRequestExtensionMessage> m + (new UTMetadataRequestExtensionMessage(extensionMessageID)); + m->setIndex(index.i()); + m->setDownloadContext(_dctx); + m->setPeer(_peer); + m->setBtMessageFactory(_messageFactory); + m->setBtMessageDispatcher(_dispatcher); + return m; } case 1: { - if(end == length) { - throw DL_ABORT_EX("Bad ut_metadata data: data not found"); - } - const BDE& totalSize = dict["total_size"]; - if(!totalSize.isInteger()) { - throw DL_ABORT_EX("Bad ut_metadata data: total_size not found"); - } - SharedHandle<UTMetadataDataExtensionMessage> m - (new UTMetadataDataExtensionMessage(extensionMessageID)); - m->setIndex(index.i()); - m->setTotalSize(totalSize.i()); - m->setData(std::string(&data[1+end], &data[length])); - m->setUTMetadataRequestTracker(_tracker); - m->setPieceStorage(_dctx->getOwnerRequestGroup()->getPieceStorage()); - m->setDownloadContext(_dctx); - return m; + if(end == length) { + throw DL_ABORT_EX("Bad ut_metadata data: data not found"); + } + const BDE& totalSize = dict["total_size"]; + if(!totalSize.isInteger()) { + throw DL_ABORT_EX("Bad ut_metadata data: total_size not found"); + } + SharedHandle<UTMetadataDataExtensionMessage> m + (new UTMetadataDataExtensionMessage(extensionMessageID)); + m->setIndex(index.i()); + m->setTotalSize(totalSize.i()); + m->setData(std::string(&data[1+end], &data[length])); + m->setUTMetadataRequestTracker(_tracker); + m->setPieceStorage(_dctx->getOwnerRequestGroup()->getPieceStorage()); + m->setDownloadContext(_dctx); + return m; } case 2: { - SharedHandle<UTMetadataRejectExtensionMessage> m - (new UTMetadataRejectExtensionMessage(extensionMessageID)); - m->setIndex(index.i()); - // No need to inject tracker because peer will be disconnected. - return m; + SharedHandle<UTMetadataRejectExtensionMessage> m + (new UTMetadataRejectExtensionMessage(extensionMessageID)); + m->setIndex(index.i()); + // No need to inject tracker because peer will be disconnected. + return m; } default: - throw DL_ABORT_EX(StringFormat("Bad ut_metadata: unknown msg_type=%u", - msgType.i()).str()); + throw DL_ABORT_EX(StringFormat("Bad ut_metadata: unknown msg_type=%u", + msgType.i()).str()); } } else { throw DL_ABORT_EX - (StringFormat("Unsupported extension message received. extensionMessageID=%u, extensionName=%s", - extensionMessageID, extensionName.c_str()).str()); + (StringFormat("Unsupported extension message received. extensionMessageID=%u, extensionName=%s", + extensionMessageID, extensionName.c_str()).str()); } } } diff --git a/src/DefaultExtensionMessageFactory.h b/src/DefaultExtensionMessageFactory.h index 9e339bfc..9fa36213 100644 --- a/src/DefaultExtensionMessageFactory.h +++ b/src/DefaultExtensionMessageFactory.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/DefaultPeerStorage.cc b/src/DefaultPeerStorage.cc index 78116204..13caadd6 100644 --- a/src/DefaultPeerStorage.cc +++ b/src/DefaultPeerStorage.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -112,7 +112,7 @@ void DefaultPeerStorage::addPeer(const Peers& peers) { const PeerHandle& peer = *itr; if(addPeer(peer)) { logger->debug(MSG_ADDING_PEER, - peer->ipaddr.c_str(), peer->port); + peer->ipaddr.c_str(), peer->port); } } } @@ -130,7 +130,7 @@ public: PeerHandle DefaultPeerStorage::getUnusedPeer() { Peers::const_iterator itr = std::find_if(peers.begin(), peers.end(), - FindFinePeer()); + FindFinePeer()); if(itr == peers.end()) { return SharedHandle<Peer>(); } else { @@ -151,9 +151,9 @@ public: }; PeerHandle DefaultPeerStorage::getPeer(const std::string& ipaddr, - uint16_t port) const { + uint16_t port) const { Peers::const_iterator itr = std::find_if(peers.begin(), peers.end(), - FindPeer(ipaddr, port)); + FindPeer(ipaddr, port)); if(itr == peers.end()) { return SharedHandle<Peer>(); } else { @@ -213,7 +213,7 @@ TransferStat DefaultPeerStorage::calculateStat() struct timeval now; gettimeofday(&now, 0); for(std::deque<SharedHandle<Peer> >::const_iterator i = activePeers.begin(); - i != activePeers.end(); ++i) { + i != activePeers.end(); ++i) { TransferStat s; s.downloadSpeed = (*i)->calculateDownloadSpeed(now); s.uploadSpeed = (*i)->calculateUploadSpeed(now); @@ -230,7 +230,7 @@ TransferStat DefaultPeerStorage::calculateStat() stat.sessionDownloadLength += removedPeerSessionDownloadLength; stat.sessionUploadLength += removedPeerSessionUploadLength; stat.setAllTimeUploadLength(_btRuntime->getUploadLengthAtStartup()+ - stat.getSessionUploadLength()); + stat.getSessionUploadLength()); return stat; } diff --git a/src/DefaultPeerStorage.h b/src/DefaultPeerStorage.h index c52f0094..184d6a56 100644 --- a/src/DefaultPeerStorage.h +++ b/src/DefaultPeerStorage.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/DefaultPieceStorage.cc b/src/DefaultPieceStorage.cc index 5d42ba23..6fa21cbf 100644 --- a/src/DefaultPieceStorage.cc +++ b/src/DefaultPieceStorage.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -66,8 +66,8 @@ DefaultPieceStorage::DefaultPieceStorage (const SharedHandle<DownloadContext>& downloadContext, const Option* option): downloadContext(downloadContext), bitfieldMan(BitfieldManFactory::getFactoryInstance()-> - createBitfieldMan(downloadContext->getPieceLength(), - downloadContext->getTotalLength())), + createBitfieldMan(downloadContext->getPieceLength(), + downloadContext->getTotalLength())), _diskWriterFactory(new DefaultDiskWriterFactory()), endGamePieceNum(END_GAME_PIECE_NUM), logger(LogFactory::getInstance()), @@ -86,18 +86,18 @@ bool DefaultPieceStorage::isEndGame() } bool DefaultPieceStorage::getMissingPieceIndex(size_t& index, - const unsigned char* bitfield, - size_t length) + const unsigned char* bitfield, + size_t length) { const size_t mislen = bitfieldMan->getBitfieldLength(); array_ptr<unsigned char> misbitfield(new unsigned char[mislen]); bool r; if(isEndGame()) { r = bitfieldMan->getAllMissingIndexes(misbitfield, mislen, - bitfield, length); + bitfield, length); } else { r = bitfieldMan->getAllMissingUnusedIndexes(misbitfield, mislen, - bitfield, length); + bitfield, length); } if(r) { // We assume indexes is sorted using comparator less. @@ -140,7 +140,7 @@ PieceHandle DefaultPieceStorage::getPiece(size_t index) if(piece.isNull()) { piece.reset(new Piece(index, bitfieldMan->getBlockLength(index))); if(hasPiece(index)) { - piece->setAllBlock(); + piece->setAllBlock(); } } } @@ -153,7 +153,7 @@ void DefaultPieceStorage::addUsedPiece(const PieceHandle& piece) std::lower_bound(usedPieces.begin(), usedPieces.end(), piece); usedPieces.insert(i, piece); logger->debug("usedPieces.size()=%lu", - static_cast<unsigned long>(usedPieces.size())); + static_cast<unsigned long>(usedPieces.size())); } PieceHandle DefaultPieceStorage::findUsedPiece(size_t index) const @@ -193,7 +193,7 @@ SharedHandle<Piece> DefaultPieceStorage::getMissingPiece bool DefaultPieceStorage::hasMissingPiece(const PeerHandle& peer) { return bitfieldMan->hasMissingPiece(peer->getBitfield(), - peer->getBitfieldLength()); + peer->getBitfieldLength()); } PieceHandle DefaultPieceStorage::getMissingPiece(const SharedHandle<Peer>& peer) @@ -205,7 +205,7 @@ void DefaultPieceStorage::createFastIndexBitfield (BitfieldMan& bitfield, const SharedHandle<Peer>& peer) { for(std::deque<size_t>::const_iterator itr = - peer->getPeerAllowedIndexSet().begin(); + peer->getPeerAllowedIndexSet().begin(); itr != peer->getPeerAllowedIndexSet().end(); ++itr) { if(!bitfieldMan->isBitSet(*itr) && peer->hasPiece(*itr)) { bitfield.setBit(*itr); @@ -218,7 +218,7 @@ PieceHandle DefaultPieceStorage::getMissingFastPiece { if(peer->isFastExtensionEnabled() && peer->countPeerAllowedIndexSet() > 0) { BitfieldMan tempBitfield(bitfieldMan->getBlockLength(), - bitfieldMan->getTotalLength()); + bitfieldMan->getTotalLength()); createFastIndexBitfield(tempBitfield, peer); return getMissingPiece(tempBitfield); } else { @@ -227,7 +227,7 @@ PieceHandle DefaultPieceStorage::getMissingFastPiece } static void unsetExcludedIndexes(BitfieldMan& bitfield, - const std::deque<size_t>& excludedIndexes) + const std::deque<size_t>& excludedIndexes) { for(std::deque<size_t>::const_iterator i = excludedIndexes.begin(); i != excludedIndexes.end(); ++i) { @@ -239,7 +239,7 @@ SharedHandle<Piece> DefaultPieceStorage::getMissingPiece (const SharedHandle<Peer>& peer, const std::deque<size_t>& excludedIndexes) { BitfieldMan tempBitfield(bitfieldMan->getBlockLength(), - bitfieldMan->getTotalLength()); + bitfieldMan->getTotalLength()); tempBitfield.setBitfield(peer->getBitfield(), peer->getBitfieldLength()); unsetExcludedIndexes(tempBitfield, excludedIndexes); return getMissingPiece(tempBitfield); @@ -250,7 +250,7 @@ SharedHandle<Piece> DefaultPieceStorage::getMissingFastPiece { if(peer->isFastExtensionEnabled() && peer->countPeerAllowedIndexSet() > 0) { BitfieldMan tempBitfield(bitfieldMan->getBlockLength(), - bitfieldMan->getTotalLength()); + bitfieldMan->getTotalLength()); createFastIndexBitfield(tempBitfield, peer); unsetExcludedIndexes(tempBitfield, excludedIndexes); return getMissingPiece(tempBitfield); @@ -314,7 +314,7 @@ void DefaultPieceStorage::deleteUsedPiece(const PieceHandle& piece) // } // size_t DefaultPieceStorage::deleteUsedPiecesByFillRate(int fillRate, -// size_t delNum) +// size_t delNum) // { // size_t deleted = 0; // for(Pieces::iterator itr = usedPieces.begin(); @@ -323,9 +323,9 @@ void DefaultPieceStorage::deleteUsedPiece(const PieceHandle& piece) // if(!bitfieldMan->isUseBitSet(piece->getIndex()) && // piece->countCompleteBlock() <= piece->countBlock()*(fillRate/100.0)) { // logger->info(MSG_DELETING_USED_PIECE, -// piece->getIndex(), -// (piece->countCompleteBlock()*100)/piece->countBlock(), -// fillRate); +// piece->getIndex(), +// (piece->countCompleteBlock()*100)/piece->countBlock(), +// fillRate); // itr = usedPieces.erase(itr); // ++deleted; // } else { @@ -341,9 +341,9 @@ void DefaultPieceStorage::completePiece(const PieceHandle& piece) return; } deleteUsedPiece(piece); -// if(!isEndGame()) { -// reduceUsedPieces(100); -// } + // if(!isEndGame()) { + // reduceUsedPieces(100); + // } if(allDownloadFinished()) { return; } @@ -430,7 +430,7 @@ void DefaultPieceStorage::setupFileFilter() downloadContext->getFileEntries(); bool allSelected = true; for(std::vector<SharedHandle<FileEntry> >::const_iterator i = - fileEntries.begin(); i != fileEntries.end(); ++i) { + fileEntries.begin(); i != fileEntries.end(); ++i) { if(!(*i)->isRequested()) { allSelected = false; break; @@ -440,7 +440,7 @@ void DefaultPieceStorage::setupFileFilter() return; } for(std::vector<SharedHandle<FileEntry> >::const_iterator i = - fileEntries.begin(); i != fileEntries.end(); ++i) { + fileEntries.begin(); i != fileEntries.end(); ++i) { if((*i)->isRequested()) { bitfieldMan->addFilter((*i)->getOffset(), (*i)->getLength()); } @@ -475,7 +475,7 @@ void DefaultPieceStorage::initStorage() DirectDiskAdaptorHandle directDiskAdaptor(new DirectDiskAdaptor()); directDiskAdaptor->setTotalLength(downloadContext->getTotalLength()); directDiskAdaptor->setFileEntries(downloadContext->getFileEntries().begin(), - downloadContext->getFileEntries().end()); + downloadContext->getFileEntries().end()); DiskWriterHandle writer = _diskWriterFactory->newDiskWriter(directDiskAdaptor->getFilePath()); @@ -489,7 +489,7 @@ void DefaultPieceStorage::initStorage() logger->debug("Instantiating MultiDiskAdaptor"); MultiDiskAdaptorHandle multiDiskAdaptor(new MultiDiskAdaptor()); multiDiskAdaptor->setFileEntries(downloadContext->getFileEntries().begin(), - downloadContext->getFileEntries().end()); + downloadContext->getFileEntries().end()); if(option->getAsBool(PREF_ENABLE_DIRECT_IO)) { multiDiskAdaptor->allowDirectIO(); } @@ -505,7 +505,7 @@ void DefaultPieceStorage::initStorage() } void DefaultPieceStorage::setBitfield(const unsigned char* bitfield, - size_t bitfieldLength) + size_t bitfieldLength) { bitfieldMan->setBitfield(bitfield, bitfieldLength); addPieceStats(bitfield, bitfieldLength); @@ -538,8 +538,8 @@ void DefaultPieceStorage::advertisePiece(int32_t cuid, size_t index) void DefaultPieceStorage::getAdvertisedPieceIndexes(std::deque<size_t>& indexes, - int32_t myCuid, - const Time& lastCheckTime) + int32_t myCuid, + const Time& lastCheckTime) { for(Haves::const_iterator itr = haves.begin(); itr != haves.end(); itr++) { const Haves::value_type& have = *itr; @@ -598,7 +598,7 @@ void DefaultPieceStorage::markPiecesDone(uint64_t length) PieceHandle p(new Piece(numPiece, bitfieldMan->getBlockLength(numPiece))); for(size_t i = 0; i < r; ++i) { - p->completeBlock(i); + p->completeBlock(i); } #ifdef ENABLE_MESSAGE_DIGEST @@ -639,23 +639,23 @@ void DefaultPieceStorage::setDiskWriterFactory(const DiskWriterFactoryHandle& di } void DefaultPieceStorage::addPieceStats(const unsigned char* bitfield, - size_t bitfieldLength) + size_t bitfieldLength) { _pieceStatMan->addPieceStats(bitfield, bitfieldLength); } void DefaultPieceStorage::subtractPieceStats(const unsigned char* bitfield, - size_t bitfieldLength) + size_t bitfieldLength) { _pieceStatMan->subtractPieceStats(bitfield, bitfieldLength); } void DefaultPieceStorage::updatePieceStats(const unsigned char* newBitfield, - size_t newBitfieldLength, - const unsigned char* oldBitfield) + size_t newBitfieldLength, + const unsigned char* oldBitfield) { _pieceStatMan->updatePieceStats(newBitfield, newBitfieldLength, - oldBitfield); + oldBitfield); } void DefaultPieceStorage::addPieceStats(size_t index) diff --git a/src/DefaultPieceStorage.h b/src/DefaultPieceStorage.h index 63c062d4..4f6b32b1 100644 --- a/src/DefaultPieceStorage.h +++ b/src/DefaultPieceStorage.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -87,21 +87,21 @@ private: SharedHandle<PieceSelector> _pieceSelector; bool getMissingPieceIndex(size_t& index, - const unsigned char* bitfield, size_t length); + const unsigned char* bitfield, size_t length); SharedHandle<Piece> getMissingPiece(const unsigned char* bitfield, - size_t length); + size_t length); SharedHandle<Piece> getMissingPiece(const BitfieldMan& bitfield); #ifdef ENABLE_BITTORRENT void createFastIndexBitfield(BitfieldMan& bitfield, - const SharedHandle<Peer>& peer); + const SharedHandle<Peer>& peer); #endif // ENABLE_BITTORRENT SharedHandle<Piece> checkOutPiece(size_t index); -// size_t deleteUsedPiecesByFillRate(int fillRate, size_t toDelete); -// void reduceUsedPieces(size_t upperBound); + // size_t deleteUsedPiecesByFillRate(int fillRate, size_t toDelete); + // void reduceUsedPieces(size_t upperBound); void deleteUsedPiece(const SharedHandle<Piece>& piece); SharedHandle<Piece> findUsedPiece(size_t index) const; @@ -113,8 +113,8 @@ public: // If it is set to false, a piece whose index is smallest has the highest // priority. DefaultPieceStorage(const SharedHandle<DownloadContext>& downloadContext, - const Option* option); - + const Option* option); + virtual ~DefaultPieceStorage(); #ifdef ENABLE_BITTORRENT @@ -169,7 +169,7 @@ public: virtual bool allDownloadFinished(); virtual void setBitfield(const unsigned char* bitfield, - size_t bitfieldLength); + size_t bitfieldLength); virtual size_t getBitfieldLength(); @@ -195,7 +195,7 @@ public: virtual void getAdvertisedPieceIndexes(std::deque<size_t>& indexes, - int32_t myCuid, const Time& lastCheckTime); + int32_t myCuid, const Time& lastCheckTime); virtual void removeAdvertisedPiece(time_t elapsed); @@ -214,14 +214,14 @@ public: virtual void addPieceStats(size_t index); virtual void addPieceStats(const unsigned char* bitfield, - size_t bitfieldLength); + size_t bitfieldLength); virtual void subtractPieceStats(const unsigned char* bitfield, - size_t bitfieldLength); + size_t bitfieldLength); virtual void updatePieceStats(const unsigned char* newBitfield, - size_t newBitfieldLength, - const unsigned char* oldBitfield); + size_t newBitfieldLength, + const unsigned char* oldBitfield); /** * This method is made private for test purpose only. diff --git a/src/DefaultSegmentManFactory.cc b/src/DefaultSegmentManFactory.cc index 8f020f98..31452774 100644 --- a/src/DefaultSegmentManFactory.cc +++ b/src/DefaultSegmentManFactory.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/DefaultSegmentManFactory.h b/src/DefaultSegmentManFactory.h index f2da752c..497a53ea 100644 --- a/src/DefaultSegmentManFactory.h +++ b/src/DefaultSegmentManFactory.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -47,7 +47,7 @@ public: virtual SharedHandle<SegmentMan> createNewInstance(const SharedHandle<DownloadContext>& dc, - const SharedHandle<PieceStorage>& ps); + const SharedHandle<PieceStorage>& ps); }; typedef SharedHandle<DefaultSegmentManFactory> DefaultSegmentManFactoryHandle; diff --git a/src/Dependency.h b/src/Dependency.h index d08ad925..acfb3d73 100644 --- a/src/Dependency.h +++ b/src/Dependency.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/DirectDiskAdaptor.cc b/src/DirectDiskAdaptor.cc index a6928f6e..55b7bf4d 100644 --- a/src/DirectDiskAdaptor.cc +++ b/src/DirectDiskAdaptor.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/DirectDiskAdaptor.h b/src/DirectDiskAdaptor.h index 21135076..dfbf1504 100644 --- a/src/DirectDiskAdaptor.h +++ b/src/DirectDiskAdaptor.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/DiskAdaptor.cc b/src/DiskAdaptor.cc index 5e17eb2b..fc016d96 100644 --- a/src/DiskAdaptor.cc +++ b/src/DiskAdaptor.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/DiskAdaptor.h b/src/DiskAdaptor.h index 94faf3f2..fd9906d7 100644 --- a/src/DiskAdaptor.h +++ b/src/DiskAdaptor.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/DiskWriter.h b/src/DiskWriter.h index a0cf8417..f8497bc9 100644 --- a/src/DiskWriter.h +++ b/src/DiskWriter.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/DiskWriterFactory.h b/src/DiskWriterFactory.h index 6cb3ae24..53e69a1a 100644 --- a/src/DiskWriterFactory.h +++ b/src/DiskWriterFactory.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/DlAbortEx.h b/src/DlAbortEx.h index 4d6e9281..8c0c76ee 100644 --- a/src/DlAbortEx.h +++ b/src/DlAbortEx.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -49,12 +49,12 @@ public: DlAbortEx(const char* file, int line, const std::string& msg): RecoverableException(file, line, msg) {} DlAbortEx(const char* file, int line, const std::string& msg, - const Exception& cause): + const Exception& cause): RecoverableException(file, line, msg, cause) {} DlAbortEx(const char* file, int line, const RecoverableException& e): RecoverableException(file, line, e) {} DlAbortEx(const char* file, int line, const std::string& msg, - downloadresultcode::RESULT code): + downloadresultcode::RESULT code): RecoverableException(file, line, msg, code) {} }; diff --git a/src/DlRetryEx.h b/src/DlRetryEx.h index 0b861e97..4b48aa96 100644 --- a/src/DlRetryEx.h +++ b/src/DlRetryEx.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -49,12 +49,12 @@ public: DlRetryEx(const char* file, int line, const std::string& msg): RecoverableException(file, line, msg) {} DlRetryEx(const char* file, int line, const std::string& msg, - const Exception& cause): + const Exception& cause): RecoverableException(file, line, msg, cause) {} DlRetryEx(const char* file, int line, const DlRetryEx& e): RecoverableException(file, line, e) {} DlRetryEx(const char* file, int line, const std::string& msg, - downloadresultcode::RESULT code): + downloadresultcode::RESULT code): RecoverableException(file, line, msg, code) {} }; diff --git a/src/DownloadCommand.cc b/src/DownloadCommand.cc index 44c2157c..bf51b209 100644 --- a/src/DownloadCommand.cc +++ b/src/DownloadCommand.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -67,11 +67,11 @@ namespace aria2 { static const size_t BUFSIZE = 16*1024; DownloadCommand::DownloadCommand(int cuid, - const RequestHandle& req, - const SharedHandle<FileEntry>& fileEntry, - RequestGroup* requestGroup, - DownloadEngine* e, - const SocketHandle& s): + const RequestHandle& req, + const SharedHandle<FileEntry>& fileEntry, + RequestGroup* requestGroup, + DownloadEngine* e, + const SocketHandle& s): AbstractCommand(cuid, req, fileEntry, requestGroup, e, s), _buf(new unsigned char[BUFSIZE]) #ifdef ENABLE_MESSAGE_DIGEST @@ -83,11 +83,11 @@ DownloadCommand::DownloadCommand(int cuid, if(getOption()->getAsBool(PREF_REALTIME_CHUNK_CHECKSUM)) { std::string algo = _requestGroup->getDownloadContext()->getPieceHashAlgo(); if(MessageDigestContext::supports(algo)) { - _messageDigestContext.reset(new MessageDigestContext()); - _messageDigestContext->trySetAlgo(algo); - _messageDigestContext->digestInit(); - - _pieceHashValidationEnabled = true; + _messageDigestContext.reset(new MessageDigestContext()); + _messageDigestContext->trySetAlgo(algo); + _messageDigestContext->digestInit(); + + _pieceHashValidationEnabled = true; } } } @@ -119,7 +119,7 @@ bool DownloadCommand::executeInternal() { if(static_cast<uint64_t>(segment->getPosition()+segment->getLength()) <= static_cast<uint64_t>(_fileEntry->getLastOffset())) { bufSize = std::min(segment->getLength()-segment->getWrittenLength(), - BUFSIZE); + BUFSIZE); } else { bufSize = std::min(static_cast<size_t>(_fileEntry->getLastOffset()-segment->getPositionToWrite()), BUFSIZE); } @@ -147,12 +147,12 @@ bool DownloadCommand::executeInternal() { if(_contentEncodingDecoder.isNull()) { diskAdaptor->writeData(bufFinal, bufSizeFinal, - segment->getPositionToWrite()); + segment->getPositionToWrite()); } else { std::string out = _contentEncodingDecoder->decode(bufFinal, bufSizeFinal); diskAdaptor->writeData(reinterpret_cast<const unsigned char*>(out.data()), - out.size(), - segment->getPositionToWrite()); + out.size(), + segment->getPositionToWrite()); bufSizeFinal = out.size(); } @@ -178,16 +178,16 @@ bool DownloadCommand::executeInternal() { segment->getPositionToWrite() == _fileEntry->getLastOffset()) { segmentPartComplete = true; } else if(segment->getLength() == 0 && bufSize == 0 && - !socket->wantRead() && !socket->wantWrite()) { + !socket->wantRead() && !socket->wantWrite()) { segmentPartComplete = true; } } else if(!_transferEncodingDecoder.isNull() && - (segment->complete() || segment->getPositionToWrite() == _fileEntry->getLastOffset())) { + (segment->complete() || segment->getPositionToWrite() == _fileEntry->getLastOffset())) { segmentPartComplete = true; } else if((_transferEncodingDecoder.isNull() || - _transferEncodingDecoder->finished()) && - (_contentEncodingDecoder.isNull() || - _contentEncodingDecoder->finished())) { + _transferEncodingDecoder->finished()) && + (_contentEncodingDecoder.isNull() || + _contentEncodingDecoder->finished())) { segmentPartComplete = true; } @@ -205,25 +205,25 @@ bool DownloadCommand::executeInternal() { #ifdef ENABLE_MESSAGE_DIGEST { - std::string expectedPieceHash = - _requestGroup->getDownloadContext()->getPieceHash(segment->getIndex()); - if(_pieceHashValidationEnabled && !expectedPieceHash.empty()) { - if(segment->isHashCalculated()) { - logger->debug("Hash is available! index=%lu", - static_cast<unsigned long>(segment->getIndex())); - validatePieceHash(segment, expectedPieceHash, segment->getHashString()); - } else { - _messageDigestContext->digestReset(); - validatePieceHash(segment, expectedPieceHash, - MessageDigestHelper::digest - (_messageDigestContext.get(), - _requestGroup->getPieceStorage()->getDiskAdaptor(), - segment->getPosition(), - segment->getLength())); - } - } else { - _requestGroup->getSegmentMan()->completeSegment(cuid, segment); - } + std::string expectedPieceHash = + _requestGroup->getDownloadContext()->getPieceHash(segment->getIndex()); + if(_pieceHashValidationEnabled && !expectedPieceHash.empty()) { + if(segment->isHashCalculated()) { + logger->debug("Hash is available! index=%lu", + static_cast<unsigned long>(segment->getIndex())); + validatePieceHash(segment, expectedPieceHash, segment->getHashString()); + } else { + _messageDigestContext->digestReset(); + validatePieceHash(segment, expectedPieceHash, + MessageDigestHelper::digest + (_messageDigestContext.get(), + _requestGroup->getPieceStorage()->getDiskAdaptor(), + segment->getPosition(), + segment->getLength())); + } + } else { + _requestGroup->getSegmentMan()->completeSegment(cuid, segment); + } } #else // !ENABLE_MESSAGE_DIGEST @@ -253,10 +253,10 @@ void DownloadCommand::checkLowestDownloadSpeed() const unsigned int nowSpeed = peerStat->calculateDownloadSpeed(); if(lowestDownloadSpeedLimit > 0 && nowSpeed <= lowestDownloadSpeedLimit) { throw DL_ABORT_EX2(StringFormat(EX_TOO_SLOW_DOWNLOAD_SPEED, - nowSpeed, - lowestDownloadSpeedLimit, - req->getHost().c_str()).str(), - downloadresultcode::TOO_SLOW_DOWNLOAD_SPEED); + nowSpeed, + lowestDownloadSpeedLimit, + req->getHost().c_str()).str(), + downloadresultcode::TOO_SLOW_DOWNLOAD_SPEED); } } } @@ -268,10 +268,10 @@ bool DownloadCommand::prepareForNextSegment() { // here. if(_requestGroup->getDownloadContext()->getFileEntries().size() == 1) { const SharedHandle<FileEntry>& fileEntry = - _requestGroup->getDownloadContext()->getFirstFileEntry(); + _requestGroup->getDownloadContext()->getFirstFileEntry(); if(fileEntry->getLength() == 0) { - fileEntry->setLength - (_requestGroup->getPieceStorage()->getCompletedLength()); + fileEntry->setLength + (_requestGroup->getPieceStorage()->getCompletedLength()); } } #ifdef ENABLE_MESSAGE_DIGEST @@ -291,16 +291,16 @@ bool DownloadCommand::prepareForNextSegment() { if(_segments.size() == 1) { SegmentHandle tempSegment = _segments.front(); if(!tempSegment->complete()) { - return prepareForRetry(0); + return prepareForRetry(0); } SegmentHandle nextSegment = - _requestGroup->getSegmentMan()->getSegment(cuid, - tempSegment->getIndex()+1); + _requestGroup->getSegmentMan()->getSegment(cuid, + tempSegment->getIndex()+1); if(!nextSegment.isNull() && nextSegment->getWrittenLength() == 0) { - e->commands.push_back(this); - return false; + e->commands.push_back(this); + return false; } else { - return prepareForRetry(0); + return prepareForRetry(0); } } else { return prepareForRetry(0); @@ -311,18 +311,18 @@ bool DownloadCommand::prepareForNextSegment() { #ifdef ENABLE_MESSAGE_DIGEST void DownloadCommand::validatePieceHash(const SharedHandle<Segment>& segment, - const std::string& expectedPieceHash, - const std::string& actualPieceHash) + const std::string& expectedPieceHash, + const std::string& actualPieceHash) { if(actualPieceHash == expectedPieceHash) { logger->info(MSG_GOOD_CHUNK_CHECKSUM, actualPieceHash.c_str()); _requestGroup->getSegmentMan()->completeSegment(cuid, segment); } else { logger->info(EX_INVALID_CHUNK_CHECKSUM, - segment->getIndex(), - util::itos(segment->getPosition(), true).c_str(), - expectedPieceHash.c_str(), - actualPieceHash.c_str()); + segment->getIndex(), + util::itos(segment->getPosition(), true).c_str(), + expectedPieceHash.c_str(), + actualPieceHash.c_str()); segment->clear(); _requestGroup->getSegmentMan()->cancelSegment(cuid); throw DL_RETRY_EX diff --git a/src/DownloadCommand.h b/src/DownloadCommand.h index f047f1ea..9f3c937c 100644 --- a/src/DownloadCommand.h +++ b/src/DownloadCommand.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -62,8 +62,8 @@ private: #endif // ENABLE_MESSAGE_DIGEST void validatePieceHash(const SharedHandle<Segment>& segment, - const std::string& expectedPieceHash, - const std::string& actualPieceHash); + const std::string& expectedPieceHash, + const std::string& actualPieceHash); void checkLowestDownloadSpeed() const; protected: @@ -77,11 +77,11 @@ protected: public: DownloadCommand(int cuid, - const SharedHandle<Request>& req, - const SharedHandle<FileEntry>& fileEntry, - RequestGroup* requestGroup, - DownloadEngine* e, - const SharedHandle<SocketCore>& s); + const SharedHandle<Request>& req, + const SharedHandle<FileEntry>& fileEntry, + RequestGroup* requestGroup, + DownloadEngine* e, + const SharedHandle<SocketCore>& s); virtual ~DownloadCommand(); void setTransferEncodingDecoder(const SharedHandle<Decoder>& decoder); diff --git a/src/DownloadContext.cc b/src/DownloadContext.cc index b450d8fd..5cceecbe 100644 --- a/src/DownloadContext.cc +++ b/src/DownloadContext.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -50,8 +50,8 @@ DownloadContext::DownloadContext(): _downloadStopTime(_downloadStartTime) {} DownloadContext::DownloadContext(size_t pieceLength, - uint64_t totalLength, - const std::string& path): + uint64_t totalLength, + const std::string& path): _dir("."), _pieceLength(pieceLength), _knowsTotalLength(true), @@ -111,7 +111,7 @@ void DownloadContext::setFilePathWithIndex _fileEntries[index-1]->setPath(path); } else { throw DL_ABORT_EX(StringFormat("No such file with index=%u", - static_cast<unsigned int>(index)).str()); + static_cast<unsigned int>(index)).str()); } } @@ -120,13 +120,13 @@ void DownloadContext::setFileFilter(IntSequence seq) std::deque<int32_t> fileIndexes = seq.flush(); std::sort(fileIndexes.begin(), fileIndexes.end()); fileIndexes.erase(std::unique(fileIndexes.begin(), fileIndexes.end()), - fileIndexes.end()); + fileIndexes.end()); bool selectAll = fileIndexes.empty() || _fileEntries.size() == 1; int32_t index = 1; for(std::vector<SharedHandle<FileEntry> >::const_iterator i = - _fileEntries.begin(); i != _fileEntries.end(); ++i, ++index) { + _fileEntries.begin(); i != _fileEntries.end(); ++i, ++index) { (*i)->setRequested (selectAll || std::binary_search(fileIndexes.begin(), fileIndexes.end(), index)); @@ -168,7 +168,7 @@ bool DownloadContext::hasAttribute(const std::string& key) const void DownloadContext::releaseRuntimeResource() { for(std::vector<SharedHandle<FileEntry> >::const_iterator i = - _fileEntries.begin(); i != _fileEntries.end(); ++i) { + _fileEntries.begin(); i != _fileEntries.end(); ++i) { (*i)->releaseRuntimeResource(); } } diff --git a/src/DownloadContext.h b/src/DownloadContext.h index b924ac8d..271b1a0e 100644 --- a/src/DownloadContext.h +++ b/src/DownloadContext.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -90,8 +90,8 @@ public: // Convenient constructor that creates single file download. DownloadContext(size_t pieceLength, - uint64_t totalLength, - const std::string& path = A2STR::NIL); + uint64_t totalLength, + const std::string& path = A2STR::NIL); const std::string& getPieceHash(size_t index) const { diff --git a/src/DownloadEngine.cc b/src/DownloadEngine.cc index aa7df8bf..ebd784c3 100644 --- a/src/DownloadEngine.cc +++ b/src/DownloadEngine.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -107,7 +107,7 @@ void DownloadEngine::cleanQueue() { } static void executeCommand(std::deque<Command*>& commands, - Command::STATUS statusFilter) + Command::STATUS statusFilter) { size_t max = commands.size(); for(size_t i = 0; i < max; ++i) { @@ -116,8 +116,8 @@ static void executeCommand(std::deque<Command*>& commands, if(com->statusMatch(statusFilter)) { com->transitStatus(); if(com->execute()) { - delete com; - com = 0; + delete com; + com = 0; } } else { commands.push_back(com); @@ -164,31 +164,31 @@ void DownloadEngine::waitData() } bool DownloadEngine::addSocketForReadCheck(const SocketHandle& socket, - Command* command) + Command* command) { return _eventPoll->addEvents(socket->getSockfd(), command, - EventPoll::EVENT_READ); + EventPoll::EVENT_READ); } bool DownloadEngine::deleteSocketForReadCheck(const SocketHandle& socket, - Command* command) + Command* command) { return _eventPoll->deleteEvents(socket->getSockfd(), command, - EventPoll::EVENT_READ); + EventPoll::EVENT_READ); } bool DownloadEngine::addSocketForWriteCheck(const SocketHandle& socket, - Command* command) + Command* command) { return _eventPoll->addEvents(socket->getSockfd(), command, - EventPoll::EVENT_WRITE); + EventPoll::EVENT_WRITE); } bool DownloadEngine::deleteSocketForWriteCheck(const SocketHandle& socket, - Command* command) + Command* command) { return _eventPoll->deleteEvents(socket->getSockfd(), command, - EventPoll::EVENT_WRITE); + EventPoll::EVENT_WRITE); } void DownloadEngine::calculateStatistics() @@ -264,8 +264,8 @@ void DownloadEngine::addRoutineCommand(Command* command) } void DownloadEngine::poolSocket(const std::string& ipaddr, - uint16_t port, - const SocketPoolEntry& entry) + uint16_t port, + const SocketPoolEntry& entry) { std::string addr = strconcat(ipaddr, ":", util::uitos(port)); logger->info("Pool socket for %s", addr.c_str()); @@ -277,9 +277,9 @@ void DownloadEngine::poolSocket(const std::string& ipaddr, logger->debug("Scaning SocketPool and erasing timed out entry."); _lastSocketPoolScan.reset(); for(std::multimap<std::string, SocketPoolEntry>::iterator i = - _socketPool.begin(); i != _socketPool.end(); ++i) { + _socketPool.begin(); i != _socketPool.end(); ++i) { if(!(*i).second.isTimeout()) { - newPool.insert(*i); + newPool.insert(*i); } } logger->debug @@ -311,9 +311,9 @@ void DownloadEngine::poolSocket } void DownloadEngine::poolSocket(const SharedHandle<Request>& request, - bool proxyDefined, - const SharedHandle<SocketCore>& socket, - time_t timeout) + bool proxyDefined, + const SharedHandle<SocketCore>& socket, + time_t timeout) { if(proxyDefined) { // If proxy is defined, then pool socket with its hostname. @@ -329,7 +329,7 @@ void DownloadEngine::poolSocket (const SharedHandle<Request>& request, bool proxyDefined, const SharedHandle<SocketCore>& socket, - const std::map<std::string, std::string>& options, + const std::map<std::string, std::string>& options, time_t timeout) { if(proxyDefined) { @@ -376,7 +376,7 @@ DownloadEngine::popPooledSocket(const std::string& ipaddr, uint16_t port) SharedHandle<SocketCore> DownloadEngine::popPooledSocket(std::map<std::string, std::string>& options, - const std::string& ipaddr, uint16_t port) + const std::string& ipaddr, uint16_t port) { SharedHandle<SocketCore> s; std::multimap<std::string, SocketPoolEntry>::iterator i = diff --git a/src/DownloadEngine.h b/src/DownloadEngine.h index cee79586..a4f8aaca 100644 --- a/src/DownloadEngine.h +++ b/src/DownloadEngine.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -92,8 +92,8 @@ private: Time _registeredTime; public: SocketPoolEntry(const SharedHandle<SocketCore>& socket, - const std::map<std::string, std::string>& option, - time_t timeout); + const std::map<std::string, std::string>& option, + time_t timeout); ~SocketPoolEntry(); @@ -145,8 +145,8 @@ private: void afterEachIteration(); void poolSocket(const std::string& ipaddr, - uint16_t port, - const SocketPoolEntry& entry); + uint16_t port, + const SocketPoolEntry& entry); std::multimap<std::string, SocketPoolEntry>::iterator findSocketPoolEntry(const std::string& ipaddr, uint16_t port); @@ -166,20 +166,20 @@ public: void cleanQueue(); bool addSocketForReadCheck(const SharedHandle<SocketCore>& socket, - Command* command); + Command* command); bool deleteSocketForReadCheck(const SharedHandle<SocketCore>& socket, - Command* command); + Command* command); bool addSocketForWriteCheck(const SharedHandle<SocketCore>& socket, - Command* command); + Command* command); bool deleteSocketForWriteCheck(const SharedHandle<SocketCore>& socket, - Command* command); + Command* command); #ifdef ENABLE_ASYNC_DNS bool addNameResolverCheck(const SharedHandle<AsyncNameResolver>& resolver, - Command* command); + Command* command); bool deleteNameResolverCheck(const SharedHandle<AsyncNameResolver>& resolver, - Command* command); + Command* command); #endif // ENABLE_ASYNC_DNS void addCommand(const std::deque<Command*>& commands); @@ -198,27 +198,27 @@ public: void addRoutineCommand(Command* command); void poolSocket(const std::string& ipaddr, uint16_t port, - const SharedHandle<SocketCore>& sock, - const std::map<std::string, std::string>& options, - time_t timeout = 15); + const SharedHandle<SocketCore>& sock, + const std::map<std::string, std::string>& options, + time_t timeout = 15); void poolSocket(const std::string& ipaddr, uint16_t port, - const SharedHandle<SocketCore>& sock, - time_t timeout = 15); + const SharedHandle<SocketCore>& sock, + time_t timeout = 15); void poolSocket(const SharedHandle<Request>& request, - bool proxyDefined, - const SharedHandle<SocketCore>& socket, - const std::map<std::string, std::string>& options, - time_t timeout = 15); + bool proxyDefined, + const SharedHandle<SocketCore>& socket, + const std::map<std::string, std::string>& options, + time_t timeout = 15); void poolSocket(const SharedHandle<Request>& request, - bool proxyDefined, - const SharedHandle<SocketCore>& socket, - time_t timeout = 15); + bool proxyDefined, + const SharedHandle<SocketCore>& socket, + time_t timeout = 15); SharedHandle<SocketCore> popPooledSocket(const std::string& ipaddr, - uint16_t port); + uint16_t port); SharedHandle<SocketCore> popPooledSocket (std::map<std::string, std::string>& options, diff --git a/src/DownloadEngineFactory.cc b/src/DownloadEngineFactory.cc index 9841c44f..19556adc 100644 --- a/src/DownloadEngineFactory.cc +++ b/src/DownloadEngineFactory.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -87,7 +87,7 @@ DownloadEngineFactory::newDownloadEngine eventPoll = ep; } else { throw DL_ABORT_EX("Initializing EpollEventPoll failed." - " Try --event-poll=select"); + " Try --event-poll=select"); } } else #endif // HAVE_EPLL @@ -101,7 +101,7 @@ DownloadEngineFactory::newDownloadEngine RequestGroupManHandle requestGroupMan(new RequestGroupMan(requestGroups, MAX_CONCURRENT_DOWNLOADS, - op)); + op)); e->_requestGroupMan = requestGroupMan; e->_fileAllocationMan.reset(new FileAllocationMan()); #ifdef ENABLE_MESSAGE_DIGEST @@ -109,23 +109,23 @@ DownloadEngineFactory::newDownloadEngine #endif // ENABLE_MESSAGE_DIGEST e->addRoutineCommand(new FillRequestGroupCommand(e->newCUID(), e.get(), 1)); e->addRoutineCommand(new FileAllocationDispatcherCommand - (e->newCUID(), e->_fileAllocationMan, e.get())); + (e->newCUID(), e->_fileAllocationMan, e.get())); #ifdef ENABLE_MESSAGE_DIGEST e->addRoutineCommand(new CheckIntegrityDispatcherCommand - (e->newCUID(), e->_checkIntegrityMan, e.get())); + (e->newCUID(), e->_checkIntegrityMan, e.get())); #endif // ENABLE_MESSAGE_DIGEST if(op->getAsInt(PREF_AUTO_SAVE_INTERVAL) > 0) { e->addRoutineCommand (new AutoSaveCommand(e->newCUID(), e.get(), - op->getAsInt(PREF_AUTO_SAVE_INTERVAL))); + op->getAsInt(PREF_AUTO_SAVE_INTERVAL))); } e->addRoutineCommand(new HaveEraseCommand(e->newCUID(), e.get(), 10)); { time_t stopSec = op->getAsInt(PREF_STOP); if(stopSec > 0) { e->addRoutineCommand(new TimedHaltCommand(e->newCUID(), e.get(), - stopSec)); + stopSec)); } } #ifdef ENABLE_XML_RPC diff --git a/src/DownloadEngineFactory.h b/src/DownloadEngineFactory.h index a381e4e9..cbbbf335 100644 --- a/src/DownloadEngineFactory.h +++ b/src/DownloadEngineFactory.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -54,7 +54,7 @@ public: SharedHandle<DownloadEngine> newDownloadEngine(Option* op, - const std::deque<SharedHandle<RequestGroup> >& requestGroups); + const std::deque<SharedHandle<RequestGroup> >& requestGroups); }; } // namespace aria2 diff --git a/src/DownloadFailureException.h b/src/DownloadFailureException.h index b9fb1132..3dc57600 100644 --- a/src/DownloadFailureException.h +++ b/src/DownloadFailureException.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -53,20 +53,20 @@ public: DownloadFailureException(const char* file, int line, const std::string& msg): RecoverableException(file, line, msg) {} DownloadFailureException(const char* file, int line, const std::string& msg, - const Exception& cause): + const Exception& cause): RecoverableException(file, line, msg, cause) {} DownloadFailureException(const char* file, int line, - const DownloadFailureException& e): + const DownloadFailureException& e): RecoverableException(file, line, e) {} DownloadFailureException(const char* file, int line, - const std::string& msg, - downloadresultcode::RESULT code): + const std::string& msg, + downloadresultcode::RESULT code): RecoverableException(file, line, msg, code) {} }; -#define DOWNLOAD_FAILURE_EXCEPTION(arg)\ +#define DOWNLOAD_FAILURE_EXCEPTION(arg) \ DownloadFailureException(__FILE__, __LINE__, arg) -#define DOWNLOAD_FAILURE_EXCEPTION2(arg1, arg2)\ +#define DOWNLOAD_FAILURE_EXCEPTION2(arg1, arg2) \ DownloadFailureException(__FILE__, __LINE__, arg1, arg2) } // namespace aria2 diff --git a/src/DownloadHandler.cc b/src/DownloadHandler.cc index 8840a630..264473d1 100644 --- a/src/DownloadHandler.cc +++ b/src/DownloadHandler.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/DownloadHandler.h b/src/DownloadHandler.h index 9c6681e3..e7db61ff 100644 --- a/src/DownloadHandler.h +++ b/src/DownloadHandler.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/DownloadHandlerConstants.cc b/src/DownloadHandlerConstants.cc index 9fb3b73a..235d7926 100644 --- a/src/DownloadHandlerConstants.cc +++ b/src/DownloadHandlerConstants.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/DownloadHandlerConstants.h b/src/DownloadHandlerConstants.h index 61c20f1a..c6b9be47 100644 --- a/src/DownloadHandlerConstants.h +++ b/src/DownloadHandlerConstants.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/DownloadHandlerFactory.cc b/src/DownloadHandlerFactory.cc index 128372a5..0a3712dc 100644 --- a/src/DownloadHandlerFactory.cc +++ b/src/DownloadHandlerFactory.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -75,9 +75,9 @@ DownloadHandlerFactory::getMetalinkPreDownloadHandler() RequestGroupCriteriaHandle criteria (new ContentTypeRequestGroupCriteria (DownloadHandlerConstants::getMetalinkContentTypes().begin(), - DownloadHandlerConstants::getMetalinkContentTypes().end(), - DownloadHandlerConstants::getMetalinkExtensions().begin(), - DownloadHandlerConstants::getMetalinkExtensions().end())); + DownloadHandlerConstants::getMetalinkContentTypes().end(), + DownloadHandlerConstants::getMetalinkExtensions().begin(), + DownloadHandlerConstants::getMetalinkExtensions().end())); _metalinkPreDownloadHandler->setCriteria(criteria); } return _metalinkPreDownloadHandler; @@ -105,9 +105,9 @@ DownloadHandlerFactory::getBtPreDownloadHandler() RequestGroupCriteriaHandle criteria (new ContentTypeRequestGroupCriteria (DownloadHandlerConstants::getBtContentTypes().begin(), - DownloadHandlerConstants::getBtContentTypes().end(), - DownloadHandlerConstants::getBtExtensions().begin(), - DownloadHandlerConstants::getBtExtensions().end())); + DownloadHandlerConstants::getBtContentTypes().end(), + DownloadHandlerConstants::getBtExtensions().begin(), + DownloadHandlerConstants::getBtExtensions().end())); _btPreDownloadHandler->setCriteria(criteria); } return _btPreDownloadHandler; diff --git a/src/DownloadHandlerFactory.h b/src/DownloadHandlerFactory.h index 0b3b7816..5bea803d 100644 --- a/src/DownloadHandlerFactory.h +++ b/src/DownloadHandlerFactory.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/DownloadResult.h b/src/DownloadResult.h index fb564775..234f3af6 100644 --- a/src/DownloadResult.h +++ b/src/DownloadResult.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -74,13 +74,13 @@ public: int32_t belongsTo; DownloadResult(int32_t gid, - const std::vector<SharedHandle<FileEntry> >& fileEntries, - bool inMemoryDownload, - uint64_t sessionDownloadLength, - int64_t sessionTime, - downloadresultcode::RESULT result, - const std::vector<int32_t> followedBy, - int32_t belongsTo): + const std::vector<SharedHandle<FileEntry> >& fileEntries, + bool inMemoryDownload, + uint64_t sessionDownloadLength, + int64_t sessionTime, + downloadresultcode::RESULT result, + const std::vector<int32_t> followedBy, + int32_t belongsTo): gid(gid), fileEntries(fileEntries), inMemoryDownload(inMemoryDownload), diff --git a/src/DownloadResultCode.h b/src/DownloadResultCode.h index 8a99f730..a0fb3f41 100644 --- a/src/DownloadResultCode.h +++ b/src/DownloadResultCode.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/EpollEventPoll.cc b/src/EpollEventPoll.cc index a48807e5..60cb6d31 100644 --- a/src/EpollEventPoll.cc +++ b/src/EpollEventPoll.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -102,13 +102,13 @@ void EpollEventPoll::ADNSEvent::processEvents(int events) ares_socket_t readfd; ares_socket_t writefd; if(events&(EpollEventPoll::EVENT_READ|EpollEventPoll::EVENT_ERROR| - EpollEventPoll::EVENT_HUP)) { + EpollEventPoll::EVENT_HUP)) { readfd = _socket; } else { readfd = ARES_SOCKET_BAD; } if(events&(EpollEventPoll::EVENT_WRITE|EpollEventPoll::EVENT_ERROR| - EpollEventPoll::EVENT_HUP)) { + EpollEventPoll::EVENT_HUP)) { writefd = _socket; } else { writefd = ARES_SOCKET_BAD; @@ -139,8 +139,8 @@ EpollEventPoll::SocketEntry::SocketEntry(sock_t socket):_socket(socket) void EpollEventPoll::SocketEntry::addCommandEvent(const CommandEvent& cev) { std::deque<CommandEvent>::iterator i = std::find(_commandEvents.begin(), - _commandEvents.end(), - cev); + _commandEvents.end(), + cev); if(i == _commandEvents.end()) { _commandEvents.push_back(cev); } else { @@ -151,8 +151,8 @@ void EpollEventPoll::SocketEntry::addCommandEvent(const CommandEvent& cev) void EpollEventPoll::SocketEntry::removeCommandEvent(const CommandEvent& cev) { std::deque<CommandEvent>::iterator i = std::find(_commandEvents.begin(), - _commandEvents.end(), - cev); + _commandEvents.end(), + cev); if(i == _commandEvents.end()) { // not found } else { @@ -168,8 +168,8 @@ void EpollEventPoll::SocketEntry::removeCommandEvent(const CommandEvent& cev) void EpollEventPoll::SocketEntry::addADNSEvent(const ADNSEvent& aev) { std::deque<ADNSEvent>::iterator i = std::find(_adnsEvents.begin(), - _adnsEvents.end(), - aev); + _adnsEvents.end(), + aev); if(i == _adnsEvents.end()) { _adnsEvents.push_back(aev); } @@ -178,8 +178,8 @@ void EpollEventPoll::SocketEntry::addADNSEvent(const ADNSEvent& aev) void EpollEventPoll::SocketEntry::removeADNSEvent(const ADNSEvent& aev) { std::deque<ADNSEvent>::iterator i = std::find(_adnsEvents.begin(), - _adnsEvents.end(), - aev); + _adnsEvents.end(), + aev); if(i == _adnsEvents.end()) { // not found } else { @@ -193,14 +193,14 @@ void EpollEventPoll::SocketEntry::processEvents(int events) { std::for_each(_commandEvents.begin(), _commandEvents.end(), std::bind2nd(std::mem_fun_ref - (&EpollEventPoll::CommandEvent::processEvents), + (&EpollEventPoll::CommandEvent::processEvents), events)); #ifdef ENABLE_ASYNC_DNS std::for_each(_adnsEvents.begin(), _adnsEvents.end(), - std::bind2nd(std::mem_fun_ref - (&EpollEventPoll::ADNSEvent::processEvents), - events)); + std::bind2nd(std::mem_fun_ref + (&EpollEventPoll::ADNSEvent::processEvents), + events)); #endif // ENABLE_ASYNC_DNS @@ -234,16 +234,16 @@ struct epoll_event& EpollEventPoll::SocketEntry::getEpEvent() _epEvent.events = std::accumulate(_adnsEvents.begin(), - _adnsEvents.end(), - std::accumulate(_commandEvents.begin(), - _commandEvents.end(), 0, accumulateEvent), - accumulateEvent); + _adnsEvents.end(), + std::accumulate(_commandEvents.begin(), + _commandEvents.end(), 0, accumulateEvent), + accumulateEvent); #else // !ENABLE_ASYNC_DNS _epEvent.events = std::accumulate(_commandEvents.begin(), _commandEvents.end(), 0, - accumulateEvent); + accumulateEvent); #endif // !ENABLE_ASYNC_DNS return _epEvent; @@ -308,8 +308,8 @@ EpollEventPoll::~EpollEventPoll() while((r = close(_epfd)) == -1 && errno == EINTR); if(r == -1) { _logger->error("Error occurred while closing epoll file descriptor" - " %d: %s", - _epfd, strerror(errno)); + " %d: %s", + _epfd, strerror(errno)); } } delete [] _epEvents; @@ -327,7 +327,7 @@ void EpollEventPoll::poll(const struct timeval& tv) int res; while((res = epoll_wait(_epfd, _epEvents, EPOLL_EVENTS_MAX, timeout)) == -1 && - errno == EINTR); + errno == EINTR); if(res > 0) { for(int i = 0; i < res; ++i) { @@ -359,7 +359,7 @@ static int translateEvents(EventPoll::EventType events) } bool EpollEventPoll::addEvents(sock_t socket, - const EpollEventPoll::Event& event) + const EpollEventPoll::Event& event) { SharedHandle<SocketEntry> socketEntry(new SocketEntry(socket)); std::deque<SharedHandle<SocketEntry> >::iterator i = @@ -376,7 +376,7 @@ bool EpollEventPoll::addEvents(sock_t socket, // SocketEntries. In this case, EPOLL_CTL_MOD is failed with ENOENT. r = epoll_ctl(_epfd, EPOLL_CTL_ADD, (*i)->getSocket(), - &(*i)->getEpEvent()); + &(*i)->getEpEvent()); } } else { _socketEntries.insert(i, socketEntry); @@ -384,7 +384,7 @@ bool EpollEventPoll::addEvents(sock_t socket, event.addSelf(socketEntry); r = epoll_ctl(_epfd, EPOLL_CTL_ADD, socketEntry->getSocket(), - &socketEntry->getEpEvent()); + &socketEntry->getEpEvent()); } if(r == -1) { _logger->debug("Failed to add socket event %d:%s", socket, strerror(errno)); @@ -395,7 +395,7 @@ bool EpollEventPoll::addEvents(sock_t socket, } bool EpollEventPoll::addEvents(sock_t socket, Command* command, - EventPoll::EventType events) + EventPoll::EventType events) { int epEvents = translateEvents(events); return addEvents(socket, CommandEvent(command, epEvents)); @@ -403,14 +403,14 @@ bool EpollEventPoll::addEvents(sock_t socket, Command* command, #ifdef ENABLE_ASYNC_DNS bool EpollEventPoll::addEvents(sock_t socket, Command* command, int events, - const SharedHandle<AsyncNameResolver>& rs) + const SharedHandle<AsyncNameResolver>& rs) { return addEvents(socket, ADNSEvent(rs, command, socket, events)); } #endif // ENABLE_ASYNC_DNS bool EpollEventPoll::deleteEvents(sock_t socket, - const EpollEventPoll::Event& event) + const EpollEventPoll::Event& event) { SharedHandle<SocketEntry> socketEntry(new SocketEntry(socket)); std::deque<SharedHandle<SocketEntry> >::iterator i = @@ -430,10 +430,10 @@ bool EpollEventPoll::deleteEvents(sock_t socket, // If socket is closed, then it seems it is automatically removed from // epoll, so following EPOLL_CTL_MOD may fail. r = epoll_ctl(_epfd, EPOLL_CTL_MOD, (*i)->getSocket(), - &(*i)->getEpEvent()); + &(*i)->getEpEvent()); if(r == -1) { - _logger->debug("Failed to delete socket event, but may be ignored:%s", - strerror(errno)); + _logger->debug("Failed to delete socket event, but may be ignored:%s", + strerror(errno)); } } if(r == -1) { @@ -450,14 +450,14 @@ bool EpollEventPoll::deleteEvents(sock_t socket, #ifdef ENABLE_ASYNC_DNS bool EpollEventPoll::deleteEvents(sock_t socket, Command* command, - const SharedHandle<AsyncNameResolver>& rs) + const SharedHandle<AsyncNameResolver>& rs) { return deleteEvents(socket, ADNSEvent(rs, command, socket, 0)); } #endif // ENABLE_ASYNC_DNS bool EpollEventPoll::deleteEvents(sock_t socket, Command* command, - EventPoll::EventType events) + EventPoll::EventType events) { int epEvents = translateEvents(events); return deleteEvents(socket, CommandEvent(command, epEvents)); diff --git a/src/EpollEventPoll.h b/src/EpollEventPoll.h index aa36ef1b..6027f414 100644 --- a/src/EpollEventPoll.h +++ b/src/EpollEventPoll.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -122,7 +122,7 @@ private: int _events; public: ADNSEvent(const SharedHandle<AsyncNameResolver>& resolver, Command* command, - sock_t socket, int events); + sock_t socket, int events); bool operator==(const ADNSEvent& event) const { @@ -205,12 +205,12 @@ private: public: AsyncNameResolverEntry(const SharedHandle<AsyncNameResolver>& nameResolver, - Command* command); + Command* command); bool operator==(const AsyncNameResolverEntry& entry) { return _nameResolver == entry._nameResolver && - _command == entry._command; + _command == entry._command; } void addSocketEvents(EpollEventPoll* socketPoll); @@ -245,10 +245,10 @@ private: bool deleteEvents(sock_t socket, const Event& event); bool addEvents(sock_t socket, Command* command, int events, - const SharedHandle<AsyncNameResolver>& rs); + const SharedHandle<AsyncNameResolver>& rs); bool deleteEvents(sock_t socket, Command* command, - const SharedHandle<AsyncNameResolver>& rs); + const SharedHandle<AsyncNameResolver>& rs); public: EpollEventPoll(); @@ -260,14 +260,14 @@ public: virtual void poll(const struct timeval& tv); virtual bool addEvents(sock_t socket, - Command* command, EventPoll::EventType events); + Command* command, EventPoll::EventType events); virtual bool deleteEvents(sock_t socket, - Command* command, EventPoll::EventType events); + Command* command, EventPoll::EventType events); #ifdef ENABLE_ASYNC_DNS virtual bool addNameResolver(const SharedHandle<AsyncNameResolver>& resolver, - Command* command); + Command* command); virtual bool deleteNameResolver (const SharedHandle<AsyncNameResolver>& resolver, Command* command); #endif // ENABLE_ASYNC_DNS diff --git a/src/EventPoll.h b/src/EventPoll.h index b4dcec97..431badc1 100644 --- a/src/EventPoll.h +++ b/src/EventPoll.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -63,11 +63,11 @@ public: virtual bool addEvents(sock_t socket, Command* command, EventType events) = 0; virtual bool deleteEvents(sock_t socket, Command* command, - EventType events) = 0; + EventType events) = 0; #ifdef ENABLE_ASYNC_DNS virtual bool addNameResolver(const SharedHandle<AsyncNameResolver>& resolver, - Command* command) = 0; + Command* command) = 0; virtual bool deleteNameResolver (const SharedHandle<AsyncNameResolver>& resolver, Command* command) = 0; #endif // ENABLE_ASYNC_DNS diff --git a/src/Exception.cc b/src/Exception.cc index 0dbf11fe..81b2219b 100644 --- a/src/Exception.cc +++ b/src/Exception.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -42,7 +42,7 @@ Exception::Exception(const char* file, int line, const std::string& msg): _file(file), _line(line), _msg(msg) {} Exception::Exception(const char* file, int line, const std::string& msg, - const Exception& cause): + const Exception& cause): _file(file), _line(line), _msg(msg), _cause(cause.copy()) {} Exception::Exception(const char* file, int line, const Exception& e): diff --git a/src/Exception.h b/src/Exception.h index db6d56f8..852457fd 100644 --- a/src/Exception.h +++ b/src/Exception.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -58,7 +58,7 @@ public: explicit Exception(const char* file, int line, const std::string& msg); Exception(const char* file, int line, const std::string& msg, - const Exception& cause); + const Exception& cause); Exception(const char* file, int line, const Exception& e); diff --git a/src/ExpatMetalinkProcessor.cc b/src/ExpatMetalinkProcessor.cc index b7ec677c..503c6e99 100644 --- a/src/ExpatMetalinkProcessor.cc +++ b/src/ExpatMetalinkProcessor.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -62,7 +62,7 @@ static void mlStartElement(void* userData, const char* name, const char** attrs) while(*p != 0) { std::string name = *p++; if(*p == 0) { - break; + break; } std::string value = util::trim(*p++); attrmap[name] = value; @@ -101,7 +101,7 @@ MetalinkProcessor::parseFile(const std::string& filename) return parseFromBinaryStream(dw); } - + SharedHandle<Metalinker> MetalinkProcessor::parseFromBinaryStream(const SharedHandle<BinaryStream>& binaryStream) { @@ -120,11 +120,11 @@ MetalinkProcessor::parseFromBinaryStream(const SharedHandle<BinaryStream>& binar while(1) { ssize_t res = binaryStream->readData(buf, bufSize, readOffset); if(res == 0) { - break; + break; } if(XML_Parse(parser, reinterpret_cast<const char*>(buf), res, 0) == - XML_STATUS_ERROR) { - throw DL_ABORT_EX(MSG_CANNOT_PARSE_METALINK); + XML_STATUS_ERROR) { + throw DL_ABORT_EX(MSG_CANNOT_PARSE_METALINK); } readOffset += res; } diff --git a/src/ExpatMetalinkProcessor.h b/src/ExpatMetalinkProcessor.h index ea973d62..ee7457bb 100644 --- a/src/ExpatMetalinkProcessor.h +++ b/src/ExpatMetalinkProcessor.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/ExpatXmlRpcRequestProcessor.cc b/src/ExpatXmlRpcRequestProcessor.cc index 46d8b4b3..924f032a 100644 --- a/src/ExpatXmlRpcRequestProcessor.cc +++ b/src/ExpatXmlRpcRequestProcessor.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -65,7 +65,7 @@ static void mlStartElement(void* userData, const char* name, const char** attrs) while(*p != 0) { std::string name = *p++; if(*p == 0) { - break; + break; } std::string value = util::trim(*p++); attrmap[name] = value; diff --git a/src/ExpatXmlRpcRequestProcessor.h b/src/ExpatXmlRpcRequestProcessor.h index fa333b0c..68a685a8 100644 --- a/src/ExpatXmlRpcRequestProcessor.h +++ b/src/ExpatXmlRpcRequestProcessor.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/ExtensionMessage.h b/src/ExtensionMessage.h index d5435f31..19f46aba 100644 --- a/src/ExtensionMessage.h +++ b/src/ExtensionMessage.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/ExtensionMessageFactory.h b/src/ExtensionMessageFactory.h index 114e501b..3ddf56b7 100644 --- a/src/ExtensionMessageFactory.h +++ b/src/ExtensionMessageFactory.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/ExtensionMessageRegistry.h b/src/ExtensionMessageRegistry.h index e79a6619..bb108ce8 100644 --- a/src/ExtensionMessageRegistry.h +++ b/src/ExtensionMessageRegistry.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -73,10 +73,10 @@ public: const std::string& getExtensionName(uint8_t id) const { for(Extensions::const_iterator itr = _extensions.begin(); - itr != _extensions.end(); ++itr) { + itr != _extensions.end(); ++itr) { const Extensions::value_type& p = *itr; if(p.second == id) { - return p.first; + return p.first; } } return A2STR::NIL; diff --git a/src/FallocFileAllocationIterator.cc b/src/FallocFileAllocationIterator.cc index 7cda5626..2a6adef8 100644 --- a/src/FallocFileAllocationIterator.cc +++ b/src/FallocFileAllocationIterator.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -45,7 +45,7 @@ void FallocFileAllocationIterator::allocateChunk() { if(static_cast<uint64_t>(_offset) > _totalLength) { throw DL_ABORT_EX("FallocFileAllocationIterator: offset is larger than" - " totalLength"); + " totalLength"); } _stream->allocate(_offset, _totalLength-_offset); _offset = _totalLength; diff --git a/src/FallocFileAllocationIterator.h b/src/FallocFileAllocationIterator.h index 6f6cfa65..22f7e47e 100644 --- a/src/FallocFileAllocationIterator.h +++ b/src/FallocFileAllocationIterator.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -48,7 +48,7 @@ private: uint64_t _totalLength; public: FallocFileAllocationIterator(BinaryStream* stream, off_t offset, - uint64_t totalLength); + uint64_t totalLength); virtual void allocateChunk(); diff --git a/src/FatalException.h b/src/FatalException.h index a1f639c4..aa27fd91 100644 --- a/src/FatalException.h +++ b/src/FatalException.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -49,14 +49,14 @@ public: FatalException(const char* file, int line, const std::string& msg): Exception(file, line, msg) {} FatalException(const char* file, int line, const std::string& msg, - const Exception& cause): + const Exception& cause): Exception(file, line, msg, cause) {} FatalException(const FatalException& e):Exception(e) {} }; -#define FATAL_EXCEPTION(arg)\ +#define FATAL_EXCEPTION(arg) \ FatalException(__FILE__, __LINE__, arg) -#define FATAL_EXCEPTION2(arg1, arg2)\ +#define FATAL_EXCEPTION2(arg1, arg2) \ FatalException(__FILE__, __LINE__, arg1, arg2) } // namespace aria2 diff --git a/src/FeatureConfig.cc b/src/FeatureConfig.cc index c3a94931..35065528 100644 --- a/src/FeatureConfig.cc +++ b/src/FeatureConfig.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/FeatureConfig.h b/src/FeatureConfig.h index 89b08fcb..0877ecb3 100644 --- a/src/FeatureConfig.h +++ b/src/FeatureConfig.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/FeedbackURISelector.cc b/src/FeedbackURISelector.cc index f20d4286..41abf154 100644 --- a/src/FeedbackURISelector.cc +++ b/src/FeedbackURISelector.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -53,7 +53,7 @@ FeedbackURISelector::~FeedbackURISelector() {} class ServerStatFaster { public: bool operator()(const std::pair<SharedHandle<ServerStat>, std::string> lhs, - const std::pair<SharedHandle<ServerStat>, std::string> rhs) + const std::pair<SharedHandle<ServerStat>, std::string> rhs) const { return lhs.first->getDownloadSpeed() > rhs.first->getDownloadSpeed(); @@ -78,23 +78,23 @@ std::string FeedbackURISelector::select(FileEntry* fileEntry) Request r; r.setUrl(*i); SharedHandle<ServerStat> ss = _serverStatMan->find(r.getHost(), - r.getProtocol()); + r.getProtocol()); if(!ss.isNull() && ss->isOK() && ss->getDownloadSpeed() > SPEED_THRESHOLD) { cands.push_back(std::pair<SharedHandle<ServerStat>, std::string>(ss, *i)); } } if(cands.empty()) { for(std::deque<std::string>::iterator i = uris.begin(); - i != uris.end(); ++i) { + i != uris.end(); ++i) { Request r; r.setUrl(*i); SharedHandle<ServerStat> ss = _serverStatMan->find(r.getHost(), - r.getProtocol()); + r.getProtocol()); // Skip ERROR state URI if(ss.isNull() || ss->isOK()) { - std::string nextURI = *i; - uris.erase(uris.begin(), i+1); - return nextURI; + std::string nextURI = *i; + uris.erase(uris.begin(), i+1); + return nextURI; } } // All URIs are inspected but aria2 cannot find usable one. diff --git a/src/FeedbackURISelector.h b/src/FeedbackURISelector.h index 46e5c8fa..bb6e525e 100644 --- a/src/FeedbackURISelector.h +++ b/src/FeedbackURISelector.h @@ -4,7 +4,7 @@ * * Copyright (C) 2006 Tatsuhiro Tsujikawa * -nn * This program is free software; you can redistribute it and/or modify + nn * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. @@ -16,7 +16,7 @@ nn * This program is free software; you can redistribute it and/or modify * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/File.cc b/src/File.cc index 23ab3933..bc115bfa 100644 --- a/src/File.cc +++ b/src/File.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/FileAllocationCommand.cc b/src/FileAllocationCommand.cc index 993c4f0b..0c4403ba 100644 --- a/src/FileAllocationCommand.cc +++ b/src/FileAllocationCommand.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -60,8 +60,8 @@ bool FileAllocationCommand::executeInternal() _fileAllocationEntry->allocateChunk(); if(_fileAllocationEntry->finished()) { logger->debug(MSG_ALLOCATION_COMPLETED, - _timer.difference(), - util::itos(_requestGroup->getTotalLength(), true).c_str()); + _timer.difference(), + util::itos(_requestGroup->getTotalLength(), true).c_str()); _e->_fileAllocationMan->dropPickedEntry(); std::deque<Command*> commands; @@ -80,7 +80,7 @@ bool FileAllocationCommand::handleException(Exception& e) _e->_fileAllocationMan->dropPickedEntry(); logger->error(MSG_FILE_ALLOCATION_FAILURE, e, cuid); logger->error(MSG_DOWNLOAD_NOT_COMPLETE, cuid, - _requestGroup->getDownloadContext()->getBasePath().c_str()); + _requestGroup->getDownloadContext()->getBasePath().c_str()); return true; } diff --git a/src/FileAllocationCommand.h b/src/FileAllocationCommand.h index d17cab46..08e82bdf 100644 --- a/src/FileAllocationCommand.h +++ b/src/FileAllocationCommand.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -49,8 +49,8 @@ private: Time _timer; public: FileAllocationCommand(int cuid, RequestGroup* requestGroup, - DownloadEngine* e, - const SharedHandle<FileAllocationEntry>& fileAllocationEntry); + DownloadEngine* e, + const SharedHandle<FileAllocationEntry>& fileAllocationEntry); virtual ~FileAllocationCommand(); diff --git a/src/FileAllocationDispatcherCommand.cc b/src/FileAllocationDispatcherCommand.cc index c86f26cb..777abf3e 100644 --- a/src/FileAllocationDispatcherCommand.cc +++ b/src/FileAllocationDispatcherCommand.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -45,7 +45,7 @@ FileAllocationDispatcherCommand::FileAllocationDispatcherCommand (int32_t cuid, const SharedHandle<FileAllocationMan>& fileAllocMan, DownloadEngine* e):SequentialDispatcherCommand<FileAllocationEntry> - (cuid, fileAllocMan, e) {} + (cuid, fileAllocMan, e) {} Command* FileAllocationDispatcherCommand::createCommand (const SharedHandle<FileAllocationEntry>& entry) diff --git a/src/FileAllocationDispatcherCommand.h b/src/FileAllocationDispatcherCommand.h index beba1504..8615d974 100644 --- a/src/FileAllocationDispatcherCommand.h +++ b/src/FileAllocationDispatcherCommand.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/FileAllocationEntry.cc b/src/FileAllocationEntry.cc index aba0b0c5..216c0685 100644 --- a/src/FileAllocationEntry.cc +++ b/src/FileAllocationEntry.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/FileAllocationEntry.h b/src/FileAllocationEntry.h index 56a42617..811ade92 100644 --- a/src/FileAllocationEntry.h +++ b/src/FileAllocationEntry.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -62,7 +62,7 @@ public: void allocateChunk(); virtual void prepareForNextAction(std::deque<Command*>& commands, - DownloadEngine* e) = 0; + DownloadEngine* e) = 0; void disableDirectIO(); }; diff --git a/src/FileAllocationIterator.h b/src/FileAllocationIterator.h index 9db182f0..479c2305 100644 --- a/src/FileAllocationIterator.h +++ b/src/FileAllocationIterator.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/FileAllocationMan.h b/src/FileAllocationMan.h index 5244d581..8ee4c098 100644 --- a/src/FileAllocationMan.h +++ b/src/FileAllocationMan.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/FileEntry.cc b/src/FileEntry.cc index 7d030f54..5c3bf593 100644 --- a/src/FileEntry.cc +++ b/src/FileEntry.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -44,9 +44,9 @@ namespace aria2 { FileEntry::FileEntry(const std::string& path, - uint64_t length, - off_t offset, - const std::deque<std::string>& uris): + uint64_t length, + off_t offset, + const std::deque<std::string>& uris): path(path), _uris(uris), length(length), offset(offset), extracted(false), requested(true), _singleHostMultiConnection(true), @@ -105,7 +105,7 @@ std::string FileEntry::selectUri(const SharedHandle<URISelector>& uriSelector) template<typename InputIterator> static bool inFlightHost(InputIterator first, InputIterator last, - const std::string& hostname) + const std::string& hostname) { // TODO redirection should be considered here. We need to parse // original URI to get hostname. @@ -129,25 +129,25 @@ FileEntry::getRequest while(1) { std::string uri = selector->select(this); if(uri.empty()) { - return req; + return req; } req.reset(new Request()); if(req->setUrl(uri)) { - if(!_singleHostMultiConnection) { - if(inFlightHost(_inFlightRequests.begin(), _inFlightRequests.end(), - req->getHost())) { - pending.push_back(uri); - req.reset(); - continue; - } - } - req->setReferer(referer); - req->setMethod(method); - _spentUris.push_back(uri); - _inFlightRequests.push_back(req); - break; + if(!_singleHostMultiConnection) { + if(inFlightHost(_inFlightRequests.begin(), _inFlightRequests.end(), + req->getHost())) { + pending.push_back(uri); + req.reset(); + continue; + } + } + req->setReferer(referer); + req->setMethod(method); + _spentUris.push_back(uri); + _inFlightRequests.push_back(req); + break; } else { - req.reset(); + req.reset(); } } _uris.insert(_uris.begin(), pending.begin(), pending.end()); @@ -187,7 +187,7 @@ FileEntry::findFasterRequest(const SharedHandle<Request>& base) class RequestFaster { public: bool operator()(const SharedHandle<Request>& lhs, - const SharedHandle<Request>& rhs) const + const SharedHandle<Request>& rhs) const { if(lhs->getPeerStat().isNull()) { return false; @@ -210,7 +210,7 @@ void FileEntry::storePool(const SharedHandle<Request>& request) } std::deque<SharedHandle<Request> >::iterator i = std::lower_bound(_requestPool.begin(), _requestPool.end(), request, - RequestFaster()); + RequestFaster()); _requestPool.insert(i, request); } @@ -223,7 +223,7 @@ void FileEntry::poolRequest(const SharedHandle<Request>& request) bool FileEntry::removeRequest(const SharedHandle<Request>& request) { for(std::deque<SharedHandle<Request> >::iterator i = - _inFlightRequests.begin(); i != _inFlightRequests.end(); ++i) { + _inFlightRequests.begin(); i != _inFlightRequests.end(); ++i) { if((*i).get() == request.get()) { _inFlightRequests.erase(i); return true; @@ -243,7 +243,7 @@ void FileEntry::removeURIWhoseHostnameIs(const std::string& hostname) } } _logger->debug("Removed %d duplicate hostname URIs for path=%s", - _uris.size()-newURIs.size(), getPath().c_str()); + _uris.size()-newURIs.size(), getPath().c_str()); _uris = newURIs; } @@ -274,7 +274,7 @@ void FileEntry::extractURIResult { std::deque<URIResult>::iterator i = std::stable_partition(_uriResults.begin(), _uriResults.end(), - FindURIResultByResult(r)); + FindURIResultByResult(r)); std::copy(_uriResults.begin(), i, std::back_inserter(res)); _uriResults.erase(_uriResults.begin(), i); } @@ -287,30 +287,30 @@ void FileEntry::reuseUri(size_t num) std::deque<std::string> errorUris(_uriResults.size()); std::transform(_uriResults.begin(), _uriResults.end(), - errorUris.begin(), std::mem_fun_ref(&URIResult::getURI)); + errorUris.begin(), std::mem_fun_ref(&URIResult::getURI)); std::sort(errorUris.begin(), errorUris.end()); errorUris.erase(std::unique(errorUris.begin(), errorUris.end()), - errorUris.end()); + errorUris.end()); std::deque<std::string> reusableURIs; std::set_difference(uris.begin(), uris.end(), - errorUris.begin(), errorUris.end(), - std::back_inserter(reusableURIs)); + errorUris.begin(), errorUris.end(), + std::back_inserter(reusableURIs)); size_t ininum = reusableURIs.size(); _logger->debug("Found %u reusable URIs", - static_cast<unsigned int>(ininum)); + static_cast<unsigned int>(ininum)); // Reuse at least num URIs here to avoid to // run this process repeatedly. if(ininum > 0 && ininum < num) { _logger->debug("fewer than num=%u", - num); + num); for(size_t i = 0; i < num/ininum; ++i) { _uris.insert(_uris.end(), reusableURIs.begin(), reusableURIs.end()); } _uris.insert(_uris.end(), reusableURIs.begin(), - reusableURIs.begin()+(num%ininum)); + reusableURIs.begin()+(num%ininum)); _logger->debug("Duplication complete: now %u URIs for reuse", - static_cast<unsigned int>(_uris.size())); + static_cast<unsigned int>(_uris.size())); } } diff --git a/src/FileEntry.h b/src/FileEntry.h index c51b939c..2dfe7eda 100644 --- a/src/FileEntry.h +++ b/src/FileEntry.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -77,7 +77,7 @@ public: FileEntry(); FileEntry(const std::string& path, uint64_t length, off_t offset, - const std::deque<std::string>& uris = std::deque<std::string>()); + const std::deque<std::string>& uris = std::deque<std::string>()); ~FileEntry(); @@ -290,19 +290,19 @@ void writeFilePath std::deque<std::string> uris; e->getUris(uris); if(uris.empty()) { - o << "n/a"; + o << "n/a"; } else { - o << uris.front(); + o << uris.front(); } } else { if(memory) { - o << "[MEMORY]" << File(e->getPath()).getBasename(); + o << "[MEMORY]" << File(e->getPath()).getBasename(); } else { - o << e->getPath(); + o << e->getPath(); } size_t count = countRequestedFileEntry(first, last); if(count > 1) { - o << " (" << count-1 << "more)"; + o << " (" << count-1 << "more)"; } } } diff --git a/src/FillRequestGroupCommand.cc b/src/FillRequestGroupCommand.cc index 1a544b72..7681c5db 100644 --- a/src/FillRequestGroupCommand.cc +++ b/src/FillRequestGroupCommand.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -44,8 +44,8 @@ namespace aria2 { FillRequestGroupCommand::FillRequestGroupCommand(int32_t cuid, - DownloadEngine* e, - time_t interval): + DownloadEngine* e, + time_t interval): Command(cuid), _e(e), _interval(interval) diff --git a/src/FillRequestGroupCommand.h b/src/FillRequestGroupCommand.h index e28f952d..409fbd77 100644 --- a/src/FillRequestGroupCommand.h +++ b/src/FillRequestGroupCommand.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/FixedWidthNumberDecorator.h b/src/FixedWidthNumberDecorator.h index 6d3dcc45..79e96813 100644 --- a/src/FixedWidthNumberDecorator.h +++ b/src/FixedWidthNumberDecorator.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/FtpConnection.cc b/src/FtpConnection.cc index 1bcc837e..d540cad2 100644 --- a/src/FtpConnection.cc +++ b/src/FtpConnection.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -63,9 +63,9 @@ const std::string FtpConnection::A("A"); const std::string FtpConnection::I("I"); FtpConnection::FtpConnection(int32_t cuid, const SocketHandle& socket, - const RequestHandle& req, - const SharedHandle<AuthConfig>& authConfig, - const Option* op): + const RequestHandle& req, + const SharedHandle<AuthConfig>& authConfig, + const Option* op): cuid(cuid), socket(socket), req(req), _authConfig(authConfig), option(op), logger(LogFactory::getInstance()), @@ -134,7 +134,7 @@ bool FtpConnection::sendCwd() { if(_socketBuffer.sendBufferIsEmpty()) { logger->info("CUID#%d - Using base working directory '%s'", - cuid, _baseWorkingDir.c_str()); + cuid, _baseWorkingDir.c_str()); std::string request = "CWD "; if(_baseWorkingDir != "/") { request += _baseWorkingDir; @@ -201,7 +201,7 @@ bool FtpConnection::sendPort(const SharedHandle<SocketCore>& serverSocket) socket->getAddrInfo(addrinfo); unsigned int ipaddr[4]; sscanf(addrinfo.first.c_str(), "%u.%u.%u.%u", - &ipaddr[0], &ipaddr[1], &ipaddr[2], &ipaddr[3]); + &ipaddr[0], &ipaddr[1], &ipaddr[2], &ipaddr[3]); serverSocket->getAddrInfo(addrinfo); std::string request = "PORT "; request += util::uitos(ipaddr[0]); @@ -275,7 +275,7 @@ unsigned int FtpConnection::getStatus(const std::string& response) const // If the whole response has not been received, then returns std::string::npos. std::string::size_type FtpConnection::findEndOfResponse(unsigned int status, - const std::string& buf) const + const std::string& buf) const { if(buf.size() <= 4) { return std::string::npos; @@ -317,14 +317,14 @@ bool FtpConnection::bulkReceiveResponse(std::pair<unsigned int, std::string>& re socket->readData(buf, size); if(size == 0) { if(socket->wantRead() || socket->wantWrite()) { - return false; + return false; } throw DL_RETRY_EX(EX_GOT_EOF); } if(strbuf.size()+size > MAX_RECV_BUFFER) { throw DL_RETRY_EX - (StringFormat("Max FTP recv buffer reached. length=%lu", - static_cast<unsigned long>(strbuf.size()+size)).str()); + (StringFormat("Max FTP recv buffer reached. length=%lu", + static_cast<unsigned long>(strbuf.size()+size)).str()); } strbuf.append(&buf[0], &buf[size]); } @@ -396,24 +396,24 @@ unsigned int FtpConnection::receiveMdtmResponse(Time& time) char buf[15]; // YYYYMMDDhhmmss+\0, milli second part is dropped. sscanf(response.second.c_str(), "%*u %14s", buf); if(strlen(buf) == 14) { - // We don't use Time::parse(buf,"%Y%m%d%H%M%S") here because Mac OS X - // 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]); - buf[12] = '\0'; - tm.tm_min = util::parseInt(&buf[10]); - buf[10] = '\0'; - tm.tm_hour = util::parseInt(&buf[8]); - buf[8] = '\0'; - tm.tm_mday = util::parseInt(&buf[6]); - buf[6] = '\0'; - tm.tm_mon = util::parseInt(&buf[4])-1; - buf[4] = '\0'; - tm.tm_year = util::parseInt(&buf[0])-1900; - time = Time(timegm(&tm)); + // We don't use Time::parse(buf,"%Y%m%d%H%M%S") here because Mac OS X + // 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]); + buf[12] = '\0'; + tm.tm_min = util::parseInt(&buf[10]); + buf[10] = '\0'; + tm.tm_hour = util::parseInt(&buf[8]); + buf[8] = '\0'; + tm.tm_mday = util::parseInt(&buf[6]); + buf[6] = '\0'; + tm.tm_mon = util::parseInt(&buf[4])-1; + buf[4] = '\0'; + tm.tm_year = util::parseInt(&buf[0])-1900; + time = Time(timegm(&tm)); } else { - time = Time::null(); + time = Time::null(); } } return response.first; @@ -431,21 +431,21 @@ unsigned int FtpConnection::receivePasvResponse(std::pair<std::string, uint16_t> unsigned int h1, h2, h3, h4, p1, p2; std::string::size_type p = response.second.find("("); if(p >= 4) { - sscanf(response.second.substr(response.second.find("(")).c_str(), - "(%u,%u,%u,%u,%u,%u).", - &h1, &h2, &h3, &h4, &p1, &p2); - // ip address - dest.first = util::uitos(h1); - dest.first += "."; - dest.first += util::uitos(h2); - dest.first += "."; - dest.first += util::uitos(h3); - dest.first += "."; - dest.first += util::uitos(h4); - // port number - dest.second = 256*p1+p2; + sscanf(response.second.substr(response.second.find("(")).c_str(), + "(%u,%u,%u,%u,%u,%u).", + &h1, &h2, &h3, &h4, &p1, &p2); + // ip address + dest.first = util::uitos(h1); + dest.first += "."; + dest.first += util::uitos(h2); + dest.first += "."; + dest.first += util::uitos(h3); + dest.first += "."; + dest.first += util::uitos(h4); + // port number + dest.second = 256*p1+p2; } else { - throw DL_RETRY_EX(EX_INVALID_RESPONSE); + throw DL_RETRY_EX(EX_INVALID_RESPONSE); } } return response.first; @@ -463,10 +463,10 @@ unsigned int FtpConnection::receivePwdResponse(std::string& pwd) std::string::size_type last; if((first = response.second.find("\"")) != std::string::npos && - (last = response.second.find("\"", ++first)) != std::string::npos) { - pwd = response.second.substr(first, last-first); + (last = response.second.find("\"", ++first)) != std::string::npos) { + pwd = response.second.substr(first, last-first); } else { - throw DL_ABORT_EX(EX_INVALID_RESPONSE); + throw DL_ABORT_EX(EX_INVALID_RESPONSE); } } return response.first; diff --git a/src/FtpConnection.h b/src/FtpConnection.h index 8845b0b1..b6a3c67e 100644 --- a/src/FtpConnection.h +++ b/src/FtpConnection.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -72,7 +72,7 @@ private: unsigned int getStatus(const std::string& response) const; std::string::size_type findEndOfResponse(unsigned int status, - const std::string& buf) const; + const std::string& buf) const; bool bulkReceiveResponse(std::pair<unsigned int, std::string>& response); static const std::string A; @@ -83,9 +83,9 @@ private: static const size_t MAX_RECV_BUFFER = 65536; public: FtpConnection(int32_t cuid, const SharedHandle<SocketCore>& socket, - const SharedHandle<Request>& req, - const SharedHandle<AuthConfig>& authConfig, - const Option* op); + const SharedHandle<Request>& req, + const SharedHandle<AuthConfig>& authConfig, + const Option* op); ~FtpConnection(); bool sendUser(); bool sendPass(); diff --git a/src/FtpDownloadCommand.cc b/src/FtpDownloadCommand.cc index d66c0f20..6d3020d6 100644 --- a/src/FtpDownloadCommand.cc +++ b/src/FtpDownloadCommand.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/FtpDownloadCommand.h b/src/FtpDownloadCommand.h index 1a2b3139..acc7bb92 100644 --- a/src/FtpDownloadCommand.h +++ b/src/FtpDownloadCommand.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -50,13 +50,13 @@ protected: virtual bool prepareForNextSegment(); public: FtpDownloadCommand(int cuid, - const SharedHandle<Request>& req, - const SharedHandle<FileEntry>& fileEntry, - RequestGroup* requestGroup, - const SharedHandle<FtpConnection>& ftpConnection, - DownloadEngine* e, - const SharedHandle<SocketCore>& dataSocket, - const SharedHandle<SocketCore>& ctrlSocket); + const SharedHandle<Request>& req, + const SharedHandle<FileEntry>& fileEntry, + RequestGroup* requestGroup, + const SharedHandle<FtpConnection>& ftpConnection, + DownloadEngine* e, + const SharedHandle<SocketCore>& dataSocket, + const SharedHandle<SocketCore>& ctrlSocket); virtual ~FtpDownloadCommand(); }; diff --git a/src/FtpFinishDownloadCommand.cc b/src/FtpFinishDownloadCommand.cc index dbf56edc..6c54e63b 100644 --- a/src/FtpFinishDownloadCommand.cc +++ b/src/FtpFinishDownloadCommand.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/FtpFinishDownloadCommand.h b/src/FtpFinishDownloadCommand.h index 81adf934..261e12d0 100644 --- a/src/FtpFinishDownloadCommand.h +++ b/src/FtpFinishDownloadCommand.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -50,12 +50,12 @@ protected: virtual bool executeInternal(); public: FtpFinishDownloadCommand(int cuid, - const SharedHandle<Request>& req, - const SharedHandle<FileEntry>& fileEntry, - RequestGroup* requestGroup, - const SharedHandle<FtpConnection>& ftpConnection, - DownloadEngine* e, - const SharedHandle<SocketCore>& socket); + const SharedHandle<Request>& req, + const SharedHandle<FileEntry>& fileEntry, + RequestGroup* requestGroup, + const SharedHandle<FtpConnection>& ftpConnection, + DownloadEngine* e, + const SharedHandle<SocketCore>& socket); virtual ~FtpFinishDownloadCommand(); }; diff --git a/src/FtpInitiateConnectionCommand.cc b/src/FtpInitiateConnectionCommand.cc index c2293204..8ef6fc67 100644 --- a/src/FtpInitiateConnectionCommand.cc +++ b/src/FtpInitiateConnectionCommand.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -81,49 +81,49 @@ Command* FtpInitiateConnectionCommand::createNextCommand socket->establishConnection(addr, port); if(proxyMethod == V_GET) { - // Use GET for FTP via HTTP proxy. - req->setMethod(Request::METHOD_GET); - SharedHandle<HttpConnection> hc - (new HttpConnection(cuid, socket, getOption().get())); - - HttpRequestCommand* c = - new HttpRequestCommand(cuid, req, _fileEntry, - _requestGroup, hc, e, socket); - c->setConnectedAddr(hostname, addr, port); - c->setProxyRequest(proxyRequest); - command = c; + // Use GET for FTP via HTTP proxy. + req->setMethod(Request::METHOD_GET); + SharedHandle<HttpConnection> hc + (new HttpConnection(cuid, socket, getOption().get())); + + HttpRequestCommand* c = + new HttpRequestCommand(cuid, req, _fileEntry, + _requestGroup, hc, e, socket); + c->setConnectedAddr(hostname, addr, port); + c->setProxyRequest(proxyRequest); + command = c; } else if(proxyMethod == V_TUNNEL) { - FtpTunnelRequestCommand* c = - new FtpTunnelRequestCommand(cuid, req, _fileEntry, - _requestGroup, e, - proxyRequest, socket); - c->setConnectedAddr(hostname, addr, port); - command = c; + FtpTunnelRequestCommand* c = + new FtpTunnelRequestCommand(cuid, req, _fileEntry, + _requestGroup, e, + proxyRequest, socket); + c->setConnectedAddr(hostname, addr, port); + command = c; } else { - // TODO - throw DL_ABORT_EX("ERROR"); + // TODO + throw DL_ABORT_EX("ERROR"); } } else { if(proxyMethod == V_TUNNEL) { - command = - new FtpNegotiationCommand(cuid, req, _fileEntry, - _requestGroup, e, pooledSocket, - FtpNegotiationCommand::SEQ_SEND_CWD, - options["baseWorkingDir"]); + command = + new FtpNegotiationCommand(cuid, req, _fileEntry, + _requestGroup, e, pooledSocket, + FtpNegotiationCommand::SEQ_SEND_CWD, + options["baseWorkingDir"]); } else if(proxyMethod == V_GET) { - // Use GET for FTP via HTTP proxy. - req->setMethod(Request::METHOD_GET); - SharedHandle<HttpConnection> hc - (new HttpConnection(cuid, pooledSocket, getOption().get())); - - HttpRequestCommand* c = - new HttpRequestCommand(cuid, req, _fileEntry, - _requestGroup, hc, e, pooledSocket); - c->setProxyRequest(proxyRequest); - command = c; + // Use GET for FTP via HTTP proxy. + req->setMethod(Request::METHOD_GET); + SharedHandle<HttpConnection> hc + (new HttpConnection(cuid, pooledSocket, getOption().get())); + + HttpRequestCommand* c = + new HttpRequestCommand(cuid, req, _fileEntry, + _requestGroup, hc, e, pooledSocket); + c->setProxyRequest(proxyRequest); + command = c; } else { - // TODO - throw DL_ABORT_EX("ERROR"); + // TODO + throw DL_ABORT_EX("ERROR"); } } } else { @@ -135,16 +135,16 @@ Command* FtpInitiateConnectionCommand::createNextCommand socket.reset(new SocketCore()); socket->establishConnection(addr, port); FtpNegotiationCommand* c = - new FtpNegotiationCommand(cuid, req, _fileEntry, - _requestGroup, e, socket); + new FtpNegotiationCommand(cuid, req, _fileEntry, + _requestGroup, e, socket); c->setConnectedAddr(hostname, addr, port); command = c; } else { command = - new FtpNegotiationCommand(cuid, req, _fileEntry, - _requestGroup, e, pooledSocket, - FtpNegotiationCommand::SEQ_SEND_CWD, - options["baseWorkingDir"]); + new FtpNegotiationCommand(cuid, req, _fileEntry, + _requestGroup, e, pooledSocket, + FtpNegotiationCommand::SEQ_SEND_CWD, + options["baseWorkingDir"]); } } return command; diff --git a/src/FtpInitiateConnectionCommand.h b/src/FtpInitiateConnectionCommand.h index e4654bef..f6bbd7c9 100644 --- a/src/FtpInitiateConnectionCommand.h +++ b/src/FtpInitiateConnectionCommand.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -47,8 +47,8 @@ protected: const SharedHandle<Request>& proxyRequest); public: FtpInitiateConnectionCommand(int cuid, const SharedHandle<Request>& req, - const SharedHandle<FileEntry>& fileEntry, - RequestGroup* requestGroup, DownloadEngine* e); + const SharedHandle<FileEntry>& fileEntry, + RequestGroup* requestGroup, DownloadEngine* e); virtual ~FtpInitiateConnectionCommand(); }; diff --git a/src/FtpNegotiationCommand.cc b/src/FtpNegotiationCommand.cc index 010bf573..e660efe2 100644 --- a/src/FtpNegotiationCommand.cc +++ b/src/FtpNegotiationCommand.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -79,9 +79,9 @@ FtpNegotiationCommand::FtpNegotiationCommand const std::string& baseWorkingDir): AbstractCommand(cuid, req, fileEntry, requestGroup, e, s), sequence(seq), ftp(new FtpConnection(cuid, socket, req, - e->getAuthConfigFactory()->createAuthConfig - (req, requestGroup->getOption().get()), - getOption().get())) + e->getAuthConfigFactory()->createAuthConfig + (req, requestGroup->getOption().get()), + getOption().get())) { ftp->setBaseWorkingDir(baseWorkingDir); if(seq == SEQ_RECV_GREETING) { @@ -270,7 +270,7 @@ bool FtpNegotiationCommand::recvCwd() { _requestGroup->increaseAndValidateFileNotFoundCount(); if (status == 550) throw DL_ABORT_EX2(MSG_RESOURCE_NOT_FOUND, - downloadresultcode::RESOURCE_NOT_FOUND); + downloadresultcode::RESOURCE_NOT_FOUND); else throw DL_ABORT_EX(StringFormat(EX_BAD_STATUS, status).str()); } @@ -306,13 +306,13 @@ bool FtpNegotiationCommand::recvMdtm() time_t t = lastModifiedTime.getTime(); struct tm* tms = gmtime(&t); // returned struct is statically allocated. if(tms) { - logger->debug("MDTM result was parsed as: %s GMT", asctime(tms)); + logger->debug("MDTM result was parsed as: %s GMT", asctime(tms)); } else { - logger->debug("gmtime() failed for MDTM result."); + logger->debug("gmtime() failed for MDTM result."); } } else { logger->debug("MDTM response was returned, but it seems not to be a time" - " value as in specified in RFC3659."); + " value as in specified in RFC3659."); } } else { logger->info("CUID#%d - MDTM command failed.", cuid); @@ -337,13 +337,13 @@ bool FtpNegotiationCommand::onFileSizeDetermined(uint64_t totalLength) if(_fileEntry->getPath().empty()) { _fileEntry->setPath (strconcat(getDownloadContext()->getDir(), - "/", util::urldecode(req->getFile()))); + "/", util::urldecode(req->getFile()))); } _requestGroup->preDownloadProcessing(); if(e->_requestGroupMan->isSameFileBeingDownloaded(_requestGroup)) { throw DOWNLOAD_FAILURE_EXCEPTION (StringFormat(EX_DUPLICATE_FILE_DOWNLOAD, - _requestGroup->getFirstFilePath().c_str()).str()); + _requestGroup->getFirstFilePath().c_str()).str()); } if(totalLength == 0) { @@ -365,8 +365,8 @@ bool FtpNegotiationCommand::onFileSizeDetermined(uint64_t totalLength) sequence = SEQ_DOWNLOAD_ALREADY_COMPLETED; logger->notice(MSG_DOWNLOAD_ALREADY_COMPLETED, - _requestGroup->getGID(), - _requestGroup->getFirstFilePath().c_str()); + _requestGroup->getGID(), + _requestGroup->getFirstFilePath().c_str()); poolConnection(); @@ -387,9 +387,9 @@ bool FtpNegotiationCommand::onFileSizeDetermined(uint64_t totalLength) } else { _requestGroup->adjustFilename (SharedHandle<BtProgressInfoFile>(new DefaultBtProgressInfoFile - (_requestGroup->getDownloadContext(), - SharedHandle<PieceStorage>(), - getOption().get()))); + (_requestGroup->getDownloadContext(), + SharedHandle<PieceStorage>(), + getOption().get()))); _requestGroup->initPieceStorage(); if(getOption()->getAsBool(PREF_DRY_RUN)) { @@ -404,8 +404,8 @@ bool FtpNegotiationCommand::onFileSizeDetermined(uint64_t totalLength) sequence = SEQ_DOWNLOAD_ALREADY_COMPLETED; logger->notice(MSG_DOWNLOAD_ALREADY_COMPLETED, - _requestGroup->getGID(), - _requestGroup->getFirstFilePath().c_str()); + _requestGroup->getGID(), + _requestGroup->getFirstFilePath().c_str()); poolConnection(); @@ -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()) { @@ -521,8 +521,8 @@ bool FtpNegotiationCommand::recvPasv() { } // make a data connection to the server. logger->info(MSG_CONNECTING_TO_SERVER, cuid, - dest.first.c_str(), - dest.second); + dest.first.c_str(), + dest.second); dataSocket.reset(new SocketCore()); dataSocket->establishConnection(dest.first, dest.second); @@ -585,7 +585,7 @@ bool FtpNegotiationCommand::recvRetr() { _requestGroup->increaseAndValidateFileNotFoundCount(); if (status == 550) throw DL_ABORT_EX2(MSG_RESOURCE_NOT_FOUND, - downloadresultcode::RESOURCE_NOT_FOUND); + downloadresultcode::RESOURCE_NOT_FOUND); else throw DL_ABORT_EX(StringFormat(EX_BAD_STATUS, status).str()); } diff --git a/src/FtpNegotiationCommand.h b/src/FtpNegotiationCommand.h index afa75865..04613733 100644 --- a/src/FtpNegotiationCommand.h +++ b/src/FtpNegotiationCommand.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -127,13 +127,13 @@ protected: virtual bool executeInternal(); public: FtpNegotiationCommand(int32_t cuid, - const SharedHandle<Request>& req, - const SharedHandle<FileEntry>& fileEntry, - RequestGroup* requestGroup, - DownloadEngine* e, - const SharedHandle<SocketCore>& s, - Seq seq = SEQ_RECV_GREETING, - const std::string& baseWorkingDir = "/"); + const SharedHandle<Request>& req, + const SharedHandle<FileEntry>& fileEntry, + RequestGroup* requestGroup, + DownloadEngine* e, + const SharedHandle<SocketCore>& s, + Seq seq = SEQ_RECV_GREETING, + const std::string& baseWorkingDir = "/"); virtual ~FtpNegotiationCommand(); void setConnectedAddr diff --git a/src/FtpTunnelRequestCommand.cc b/src/FtpTunnelRequestCommand.cc index 6df82183..6ec8890f 100644 --- a/src/FtpTunnelRequestCommand.cc +++ b/src/FtpTunnelRequestCommand.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -50,7 +50,7 @@ FtpTunnelRequestCommand::FtpTunnelRequestCommand const SocketHandle& s) : AbstractProxyRequestCommand(cuid, req, fileEntry, requestGroup, e, - proxyRequest, s) + proxyRequest, s) {} FtpTunnelRequestCommand::~FtpTunnelRequestCommand() {} diff --git a/src/FtpTunnelRequestCommand.h b/src/FtpTunnelRequestCommand.h index 338a2bab..7dd9d54e 100644 --- a/src/FtpTunnelRequestCommand.h +++ b/src/FtpTunnelRequestCommand.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -44,12 +44,12 @@ class SocketCore; class FtpTunnelRequestCommand : public AbstractProxyRequestCommand { public: FtpTunnelRequestCommand(int cuid, - const SharedHandle<Request>& req, - const SharedHandle<FileEntry>& fileEntry, - RequestGroup* requestGroup, - DownloadEngine* e, - const SharedHandle<Request>& proxyRequest, - const SharedHandle<SocketCore>& s); + const SharedHandle<Request>& req, + const SharedHandle<FileEntry>& fileEntry, + RequestGroup* requestGroup, + DownloadEngine* e, + const SharedHandle<Request>& proxyRequest, + const SharedHandle<SocketCore>& s); virtual ~FtpTunnelRequestCommand(); virtual Command* getNextCommand(); diff --git a/src/FtpTunnelResponseCommand.cc b/src/FtpTunnelResponseCommand.cc index de1d4c55..1cf96a8e 100644 --- a/src/FtpTunnelResponseCommand.cc +++ b/src/FtpTunnelResponseCommand.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -52,7 +52,7 @@ FtpTunnelResponseCommand::FtpTunnelResponseCommand DownloadEngine* e, const SocketHandle& s) :AbstractProxyResponseCommand(cuid, req, fileEntry, requestGroup, - httpConnection,e, s) + httpConnection,e, s) {} FtpTunnelResponseCommand::~FtpTunnelResponseCommand() {} @@ -60,7 +60,7 @@ FtpTunnelResponseCommand::~FtpTunnelResponseCommand() {} Command* FtpTunnelResponseCommand::getNextCommand() { return new FtpNegotiationCommand(cuid, req, _fileEntry, - _requestGroup, e, socket); + _requestGroup, e, socket); } } // namespace aria2 diff --git a/src/FtpTunnelResponseCommand.h b/src/FtpTunnelResponseCommand.h index 704a5dca..c0f7712b 100644 --- a/src/FtpTunnelResponseCommand.h +++ b/src/FtpTunnelResponseCommand.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -44,12 +44,12 @@ class SocketCore; class FtpTunnelResponseCommand : public AbstractProxyResponseCommand { public: FtpTunnelResponseCommand(int cuid, - const SharedHandle<Request>& req, - const SharedHandle<FileEntry>& fileEntry, - RequestGroup* requestGroup, - const SharedHandle<HttpConnection>& httpConnection, - DownloadEngine* e, - const SharedHandle<SocketCore>& s); + const SharedHandle<Request>& req, + const SharedHandle<FileEntry>& fileEntry, + RequestGroup* requestGroup, + const SharedHandle<HttpConnection>& httpConnection, + DownloadEngine* e, + const SharedHandle<SocketCore>& s); virtual ~FtpTunnelResponseCommand(); virtual Command* getNextCommand(); diff --git a/src/GZipDecoder.cc b/src/GZipDecoder.cc index 126e2eaf..afdb60cd 100644 --- a/src/GZipDecoder.cc +++ b/src/GZipDecoder.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -95,7 +95,7 @@ std::string GZipDecoder::decode(const unsigned char* in, size_t length) _finished = true; } else if(ret != Z_OK) { throw DL_ABORT_EX(StringFormat("libz::inflate() failed. cause:%s", - _strm->msg).str()); + _strm->msg).str()); } size_t produced = OUTBUF_LENGTH-_strm->avail_out; diff --git a/src/GZipDecoder.h b/src/GZipDecoder.h index 79151d5a..8701c4ea 100644 --- a/src/GZipDecoder.h +++ b/src/GZipDecoder.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/GrowSegment.cc b/src/GrowSegment.cc index 3d78c303..3bf180d7 100644 --- a/src/GrowSegment.cc +++ b/src/GrowSegment.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/GrowSegment.h b/src/GrowSegment.h index d589d1aa..2e6dc80e 100644 --- a/src/GrowSegment.h +++ b/src/GrowSegment.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -93,7 +93,7 @@ public: #ifdef ENABLE_MESSAGE_DIGEST virtual bool updateHash(uint32_t begin, - const unsigned char* data, size_t dataLength) + const unsigned char* data, size_t dataLength) { return false; } diff --git a/src/HandleRegistry.h b/src/HandleRegistry.h index 5d841381..a6cfc514 100644 --- a/src/HandleRegistry.h +++ b/src/HandleRegistry.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/HandshakeExtensionMessage.cc b/src/HandshakeExtensionMessage.cc index 8151adbe..76f662ba 100644 --- a/src/HandshakeExtensionMessage.cc +++ b/src/HandshakeExtensionMessage.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -121,7 +121,7 @@ void HandshakeExtensionMessage::doReceivedAction() if(_metadataSize > 0) { if(attrs.containsKey(bittorrent::METADATA_SIZE)) { if(_metadataSize != (size_t)attrs[bittorrent::METADATA_SIZE].i()) { - throw DL_ABORT_EX("Wrong metadata_size. Which one is correct!?"); + throw DL_ABORT_EX("Wrong metadata_size. Which one is correct!?"); } } else { attrs[bittorrent::METADATA_SIZE] = _metadataSize; @@ -130,12 +130,12 @@ void HandshakeExtensionMessage::doReceivedAction() _dctx->getOwnerRequestGroup()->initPieceStorage(); SharedHandle<PieceStorage> pieceStorage = - _dctx->getOwnerRequestGroup()->getPieceStorage(); + _dctx->getOwnerRequestGroup()->getPieceStorage(); pieceStorage->setEndGamePieceNum(0); } } else if(!attrs.containsKey(bittorrent::METADATA)) { throw DL_ABORT_EX("Peer didn't provide metadata_size." - " It seems that it doesn't have whole metadata."); + " It seems that it doesn't have whole metadata."); } } @@ -160,11 +160,11 @@ HandshakeExtensionMessage::create(const unsigned char* data, size_t length) if(length < 1) { throw DL_ABORT_EX (StringFormat(MSG_TOO_SMALL_PAYLOAD_SIZE, - EXTENSION_NAME.c_str(), length).str()); + EXTENSION_NAME.c_str(), length).str()); } 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"); @@ -180,9 +180,9 @@ HandshakeExtensionMessage::create(const unsigned char* data, size_t length) const BDE& extDict = dict["m"]; if(extDict.isDict()) { for(BDE::Dict::const_iterator i = extDict.dictBegin(); - i != extDict.dictEnd(); ++i) { + i != extDict.dictEnd(); ++i) { if((*i).second.isInteger()) { - msg->_extensions[(*i).first] = (*i).second.i(); + msg->_extensions[(*i).first] = (*i).second.i(); } } } diff --git a/src/HandshakeExtensionMessage.h b/src/HandshakeExtensionMessage.h index 421a85f5..3bb829ea 100644 --- a/src/HandshakeExtensionMessage.h +++ b/src/HandshakeExtensionMessage.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/HaveEraseCommand.cc b/src/HaveEraseCommand.cc index 910ee761..8fc8ea7a 100644 --- a/src/HaveEraseCommand.cc +++ b/src/HaveEraseCommand.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/HaveEraseCommand.h b/src/HaveEraseCommand.h index e2750486..5848f856 100644 --- a/src/HaveEraseCommand.h +++ b/src/HaveEraseCommand.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/HttpConnection.cc b/src/HttpConnection.cc index 4d2fb3a0..93e8056c 100644 --- a/src/HttpConnection.cc +++ b/src/HttpConnection.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -65,8 +65,8 @@ HttpRequestEntry::HttpRequestEntry(const HttpRequestHandle& httpRequest): HttpRequestEntry::~HttpRequestEntry() {} HttpConnection::HttpConnection(int32_t cuid, - const SocketHandle& socket, - const Option* op): + const SocketHandle& socket, + const Option* op): cuid(cuid), socket(socket), _socketBuffer(socket), option(op), logger(LogFactory::getInstance()) diff --git a/src/HttpConnection.h b/src/HttpConnection.h index 276d479e..7042310b 100644 --- a/src/HttpConnection.h +++ b/src/HttpConnection.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -89,8 +89,8 @@ private: std::string eraseConfidentialInfo(const std::string& request); public: HttpConnection(int32_t cuid, - const SharedHandle<SocketCore>& socket, - const Option* op); + const SharedHandle<SocketCore>& socket, + const Option* op); /** * Sends Http request. diff --git a/src/HttpDownloadCommand.cc b/src/HttpDownloadCommand.cc index f9f55573..7826e2dd 100644 --- a/src/HttpDownloadCommand.cc +++ b/src/HttpDownloadCommand.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -70,8 +70,8 @@ bool HttpDownloadCommand::prepareForNextSegment() { if(req->isPipeliningEnabled() && !downloadFinished) { HttpRequestCommand* command = new HttpRequestCommand(cuid, req, _fileEntry, - _requestGroup, _httpConnection, e, - socket); + _requestGroup, _httpConnection, e, + socket); // Set proxy request here. aria2 sends the HTTP request specialized for // proxy. if(resolveProxyMethod(req->getProtocol()) == V_GET) { @@ -82,9 +82,9 @@ bool HttpDownloadCommand::prepareForNextSegment() { } else { if(req->isPipeliningEnabled() || (req->isKeepAliveEnabled() && - ((!_transferEncodingDecoder.isNull() && - _requestGroup->downloadFinished()) || - _fileEntry->getLastOffset() == _segments.front()->getPositionToWrite()))) { + ((!_transferEncodingDecoder.isNull() && + _requestGroup->downloadFinished()) || + _fileEntry->getLastOffset() == _segments.front()->getPositionToWrite()))) { e->poolSocket(req, isProxyDefined(), socket); } // The request was sent assuming that server supported pipelining, but @@ -97,12 +97,12 @@ bool HttpDownloadCommand::prepareForNextSegment() { const SharedHandle<Segment>& segment = _segments.front(); off_t lastOffset =_fileEntry->gtoloff - (std::min(static_cast<off_t>(segment->getPosition()+segment->getLength()), - _fileEntry->getLastOffset())); + (std::min(static_cast<off_t>(segment->getPosition()+segment->getLength()), + _fileEntry->getLastOffset())); if(lastOffset == - _httpResponse->getHttpHeader()->getRange()->getEndByte()+1) { - return prepareForRetry(0); + _httpResponse->getHttpHeader()->getRange()->getEndByte()+1) { + return prepareForRetry(0); } } return DownloadCommand::prepareForNextSegment(); diff --git a/src/HttpDownloadCommand.h b/src/HttpDownloadCommand.h index e1e995da..20d14586 100644 --- a/src/HttpDownloadCommand.h +++ b/src/HttpDownloadCommand.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -50,13 +50,13 @@ protected: virtual bool prepareForNextSegment(); public: HttpDownloadCommand(int cuid, - const SharedHandle<Request>& req, - const SharedHandle<FileEntry>& fileEntry, - RequestGroup* requestGroup, - const SharedHandle<HttpResponse>& httpResponse, - const SharedHandle<HttpConnection>& httpConnection, - DownloadEngine* e, - const SharedHandle<SocketCore>& s); + const SharedHandle<Request>& req, + const SharedHandle<FileEntry>& fileEntry, + RequestGroup* requestGroup, + const SharedHandle<HttpResponse>& httpResponse, + const SharedHandle<HttpConnection>& httpConnection, + DownloadEngine* e, + const SharedHandle<SocketCore>& s); virtual ~HttpDownloadCommand(); }; diff --git a/src/HttpHeader.cc b/src/HttpHeader.cc index e70db2cc..17b042ff 100644 --- a/src/HttpHeader.cc +++ b/src/HttpHeader.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -142,9 +142,9 @@ RangeHandle HttpHeader::getRange() const } else { uint64_t contentLength = util::parseULLInt(contentLengthStr); if(contentLength == 0) { - return SharedHandle<Range>(new Range()); + return SharedHandle<Range>(new Range()); } else { - return SharedHandle<Range>(new Range(0, contentLength-1, contentLength)); + return SharedHandle<Range>(new Range(0, contentLength-1, contentLength)); } } } diff --git a/src/HttpHeader.h b/src/HttpHeader.h index 6611a794..aff2b07c 100644 --- a/src/HttpHeader.h +++ b/src/HttpHeader.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/HttpHeaderProcessor.cc b/src/HttpHeaderProcessor.cc index 53d036bd..79078136 100644 --- a/src/HttpHeaderProcessor.cc +++ b/src/HttpHeaderProcessor.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/HttpHeaderProcessor.h b/src/HttpHeaderProcessor.h index ac4ac5db..ed5aac71 100644 --- a/src/HttpHeaderProcessor.h +++ b/src/HttpHeaderProcessor.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/HttpInitiateConnectionCommand.cc b/src/HttpInitiateConnectionCommand.cc index 54ff1916..80758027 100644 --- a/src/HttpInitiateConnectionCommand.cc +++ b/src/HttpInitiateConnectionCommand.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -77,37 +77,37 @@ Command* HttpInitiateConnectionCommand::createNextCommand socket->establishConnection(addr, port); if(proxyMethod == V_TUNNEL) { - HttpProxyRequestCommand* c = - new HttpProxyRequestCommand(cuid, req, _fileEntry, - _requestGroup, e, - proxyRequest, socket); - c->setConnectedAddr(hostname, addr, port); - command = c; + HttpProxyRequestCommand* c = + new HttpProxyRequestCommand(cuid, req, _fileEntry, + _requestGroup, e, + proxyRequest, socket); + c->setConnectedAddr(hostname, addr, port); + command = c; } else if(proxyMethod == V_GET) { - SharedHandle<HttpConnection> httpConnection - (new HttpConnection(cuid, socket, getOption().get())); - HttpRequestCommand* c = new HttpRequestCommand(cuid, req, - _fileEntry, - _requestGroup, - httpConnection, e, - socket); - c->setConnectedAddr(hostname, addr, port); - c->setProxyRequest(proxyRequest); - command = c; + SharedHandle<HttpConnection> httpConnection + (new HttpConnection(cuid, socket, getOption().get())); + HttpRequestCommand* c = new HttpRequestCommand(cuid, req, + _fileEntry, + _requestGroup, + httpConnection, e, + socket); + c->setConnectedAddr(hostname, addr, port); + c->setProxyRequest(proxyRequest); + command = c; } else { - // TODO - throw DL_ABORT_EX("ERROR"); + // TODO + throw DL_ABORT_EX("ERROR"); } } else { SharedHandle<HttpConnection> httpConnection - (new HttpConnection(cuid, pooledSocket, getOption().get())); + (new HttpConnection(cuid, pooledSocket, getOption().get())); HttpRequestCommand* c = new HttpRequestCommand(cuid, req, - _fileEntry, - _requestGroup, - httpConnection, e, - pooledSocket); + _fileEntry, + _requestGroup, + httpConnection, e, + pooledSocket); if(proxyMethod == V_GET) { - c->setProxyRequest(proxyRequest); + c->setProxyRequest(proxyRequest); } command = c; } @@ -124,7 +124,7 @@ Command* HttpInitiateConnectionCommand::createNextCommand SharedHandle<HttpConnection> httpConnection(new HttpConnection(cuid, socket, getOption().get())); HttpRequestCommand* c = new HttpRequestCommand(cuid, req, _fileEntry, _requestGroup, - httpConnection, e, socket); + httpConnection, e, socket); if(pooledSocket.isNull()) { c->setConnectedAddr(hostname, addr, port); } diff --git a/src/HttpInitiateConnectionCommand.h b/src/HttpInitiateConnectionCommand.h index c50ed564..6d16a7da 100644 --- a/src/HttpInitiateConnectionCommand.h +++ b/src/HttpInitiateConnectionCommand.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -47,9 +47,9 @@ protected: const SharedHandle<Request>& proxyRequest); public: HttpInitiateConnectionCommand(int cuid, const SharedHandle<Request>& req, - const SharedHandle<FileEntry>& fileEntry, - RequestGroup* requestGroup, - DownloadEngine* e); + const SharedHandle<FileEntry>& fileEntry, + RequestGroup* requestGroup, + DownloadEngine* e); virtual ~HttpInitiateConnectionCommand(); }; diff --git a/src/HttpListenCommand.cc b/src/HttpListenCommand.cc index 4fd8b3e6..5bb714be 100644 --- a/src/HttpListenCommand.cc +++ b/src/HttpListenCommand.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -71,10 +71,10 @@ bool HttpListenCommand::execute() socket->getPeerInfo(peerInfo); logger->info("XML-RPC: Accepted the connection from %s:%u.", - peerInfo.first.c_str(), peerInfo.second); + peerInfo.first.c_str(), peerInfo.second); HttpServerCommand* c = - new HttpServerCommand(_e->newCUID(), _e, socket); + new HttpServerCommand(_e->newCUID(), _e, socket); _e->setNoWait(true); _e->commands.push_back(c); } diff --git a/src/HttpListenCommand.h b/src/HttpListenCommand.h index fd165292..ee77b296 100644 --- a/src/HttpListenCommand.h +++ b/src/HttpListenCommand.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/HttpProxyRequestCommand.cc b/src/HttpProxyRequestCommand.cc index f55fcc34..f32974f7 100644 --- a/src/HttpProxyRequestCommand.cc +++ b/src/HttpProxyRequestCommand.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -50,7 +50,7 @@ HttpProxyRequestCommand::HttpProxyRequestCommand const SocketHandle& s) : AbstractProxyRequestCommand(cuid, req, fileEntry, requestGroup, e, - proxyRequest, s) + proxyRequest, s) {} HttpProxyRequestCommand::~HttpProxyRequestCommand() {} diff --git a/src/HttpProxyRequestCommand.h b/src/HttpProxyRequestCommand.h index 25dc686c..3e28645e 100644 --- a/src/HttpProxyRequestCommand.h +++ b/src/HttpProxyRequestCommand.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -44,12 +44,12 @@ class SocketCore; class HttpProxyRequestCommand : public AbstractProxyRequestCommand { public: HttpProxyRequestCommand(int cuid, - const SharedHandle<Request>& req, - const SharedHandle<FileEntry>& fileEntry, - RequestGroup* requestGroup, - DownloadEngine* e, - const SharedHandle<Request>& proxyRequest, - const SharedHandle<SocketCore>& s); + const SharedHandle<Request>& req, + const SharedHandle<FileEntry>& fileEntry, + RequestGroup* requestGroup, + DownloadEngine* e, + const SharedHandle<Request>& proxyRequest, + const SharedHandle<SocketCore>& s); virtual ~HttpProxyRequestCommand(); virtual Command* getNextCommand(); diff --git a/src/HttpProxyResponseCommand.cc b/src/HttpProxyResponseCommand.cc index 6bf4be5d..281520dd 100644 --- a/src/HttpProxyResponseCommand.cc +++ b/src/HttpProxyResponseCommand.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -52,7 +52,7 @@ HttpProxyResponseCommand::HttpProxyResponseCommand DownloadEngine* e, const SocketHandle& s) :AbstractProxyResponseCommand(cuid, req, fileEntry, requestGroup, - httpConnection, e, s) + httpConnection, e, s) {} HttpProxyResponseCommand::~HttpProxyResponseCommand() {} @@ -60,7 +60,7 @@ HttpProxyResponseCommand::~HttpProxyResponseCommand() {} Command* HttpProxyResponseCommand::getNextCommand() { return new HttpRequestCommand(cuid, req, _fileEntry, - _requestGroup, httpConnection, e, socket); + _requestGroup, httpConnection, e, socket); } } // namespace aria2 diff --git a/src/HttpProxyResponseCommand.h b/src/HttpProxyResponseCommand.h index 679f9a17..6fba8441 100644 --- a/src/HttpProxyResponseCommand.h +++ b/src/HttpProxyResponseCommand.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -44,12 +44,12 @@ class SocketCore; class HttpProxyResponseCommand : public AbstractProxyResponseCommand { public: HttpProxyResponseCommand(int cuid, - const SharedHandle<Request>& req, - const SharedHandle<FileEntry>& fileEntry, - RequestGroup* requestGroup, - const SharedHandle<HttpConnection>& httpConnection, - DownloadEngine* e, - const SharedHandle<SocketCore>& s); + const SharedHandle<Request>& req, + const SharedHandle<FileEntry>& fileEntry, + RequestGroup* requestGroup, + const SharedHandle<HttpConnection>& httpConnection, + DownloadEngine* e, + const SharedHandle<SocketCore>& s); virtual ~HttpProxyResponseCommand(); virtual Command* getNextCommand(); diff --git a/src/HttpRequest.cc b/src/HttpRequest.cc index 84ad260d..a053e897 100644 --- a/src/HttpRequest.cc +++ b/src/HttpRequest.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -55,7 +55,7 @@ namespace aria2 { const std::string HttpRequest::USER_AGENT("aria2"); HttpRequest::HttpRequest():_contentEncodingEnabled(true), - userAgent(USER_AGENT) + userAgent(USER_AGENT) {} void HttpRequest::setSegment(const SharedHandle<Segment>& segment) @@ -98,7 +98,7 @@ RangeHandle HttpRequest::getRange() const return SharedHandle<Range>(new Range()); } else { return SharedHandle<Range>(new Range(getStartByte(), getEndByte(), - _fileEntry->getLength())); + _fileEntry->getLength())); } } @@ -202,7 +202,7 @@ std::string HttpRequest::createRequest() } if(!_authConfig.isNull()) { strappend(requestLine, "Authorization: Basic ", - Base64::encode(_authConfig->getAuthText()), "\r\n"); + Base64::encode(_authConfig->getAuthText()), "\r\n"); } if(getPreviousURI().size()) { strappend(requestLine, "Referer: ", getPreviousURI(), "\r\n"); @@ -211,12 +211,12 @@ std::string HttpRequest::createRequest() std::string cookiesValue; std::deque<Cookie> cookies = _cookieStorage->criteriaFind(getHost(), - getDir(), - Time().getTime(), - getProtocol() == Request::PROTO_HTTPS ? - true : false); + getDir(), + Time().getTime(), + getProtocol() == Request::PROTO_HTTPS ? + true : false); for(std::deque<Cookie>::const_iterator itr = cookies.begin(); - itr != cookies.end(); ++itr) { + itr != cookies.end(); ++itr) { strappend(cookiesValue, (*itr).toString(), ";"); } if(!cookiesValue.empty()) { @@ -244,11 +244,11 @@ std::string HttpRequest::createProxyRequest() const strappend(requestLine, "User-Agent: ", userAgent, "\r\n"); strappend(requestLine, "Host: ", hostport, "\r\n"); // TODO Is "Proxy-Connection" needed here? -// if(request->isKeepAliveEnabled() || request->isPipeliningEnabled()) { -// requestLine += "Proxy-Connection: Keep-Alive\r\n"; -// }else { -// requestLine += "Proxy-Connection: close\r\n"; -// } + // if(request->isKeepAliveEnabled() || request->isPipeliningEnabled()) { + // requestLine += "Proxy-Connection: Keep-Alive\r\n"; + // }else { + // requestLine += "Proxy-Connection: close\r\n"; + // } if(!_proxyRequest->getUsername().empty()) { requestLine += getProxyAuthString(); } @@ -259,10 +259,10 @@ std::string HttpRequest::createProxyRequest() const std::string HttpRequest::getProxyAuthString() const { return strconcat("Proxy-Authorization: Basic ", - Base64::encode(strconcat(_proxyRequest->getUsername(), - ":", - _proxyRequest->getPassword())), - "\r\n"); + Base64::encode(strconcat(_proxyRequest->getUsername(), + ":", + _proxyRequest->getPassword())), + "\r\n"); } void HttpRequest::enableContentEncoding() diff --git a/src/HttpRequest.h b/src/HttpRequest.h index f4e0a04b..0635b60b 100644 --- a/src/HttpRequest.h +++ b/src/HttpRequest.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/HttpRequestCommand.cc b/src/HttpRequestCommand.cc index d4bea72c..5183c642 100644 --- a/src/HttpRequestCommand.cc +++ b/src/HttpRequestCommand.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -76,14 +76,14 @@ HttpRequestCommand::~HttpRequestCommand() {} static SharedHandle<HttpRequest> createHttpRequest(const SharedHandle<Request>& req, - const SharedHandle<FileEntry>& fileEntry, - const SharedHandle<Segment>& segment, - uint64_t totalLength, - const SharedHandle<Option>& option, - const RequestGroup* rg, - const SharedHandle<CookieStorage>& cookieStorage, - const SharedHandle<AuthConfigFactory>& authConfigFactory, - const SharedHandle<Request>& proxyRequest) + const SharedHandle<FileEntry>& fileEntry, + const SharedHandle<Segment>& segment, + uint64_t totalLength, + const SharedHandle<Option>& option, + const RequestGroup* rg, + const SharedHandle<CookieStorage>& cookieStorage, + const SharedHandle<AuthConfigFactory>& authConfigFactory, + const SharedHandle<Request>& proxyRequest) { HttpRequestHandle httpRequest(new HttpRequest()); httpRequest->setUserAgent(option->get(PREF_USER_AGENT)); @@ -95,7 +95,7 @@ createHttpRequest(const SharedHandle<Request>& req, httpRequest->setAuthConfigFactory(authConfigFactory, option.get()); httpRequest->setProxyRequest(proxyRequest); httpRequest->addAcceptType(rg->getAcceptTypes().begin(), - rg->getAcceptTypes().end()); + rg->getAcceptTypes().end()); return httpRequest; } @@ -119,32 +119,32 @@ bool HttpRequestCommand::executeInternal() { if(_segments.empty()) { HttpRequestHandle httpRequest - (createHttpRequest(req, - _fileEntry, - SharedHandle<Segment>(), - _requestGroup->getTotalLength(), - getOption(), - _requestGroup, - e->getCookieStorage(), - e->getAuthConfigFactory(), - _proxyRequest)); + (createHttpRequest(req, + _fileEntry, + SharedHandle<Segment>(), + _requestGroup->getTotalLength(), + getOption(), + _requestGroup, + e->getCookieStorage(), + e->getAuthConfigFactory(), + _proxyRequest)); _httpConnection->sendRequest(httpRequest); } else { for(Segments::iterator itr = _segments.begin(); itr != _segments.end(); ++itr) { - const SegmentHandle& segment = *itr; - if(!_httpConnection->isIssued(segment)) { - HttpRequestHandle httpRequest - (createHttpRequest(req, - _fileEntry, - segment, - _requestGroup->getTotalLength(), - getOption(), - _requestGroup, - e->getCookieStorage(), - e->getAuthConfigFactory(), - _proxyRequest)); - _httpConnection->sendRequest(httpRequest); - } + const SegmentHandle& segment = *itr; + if(!_httpConnection->isIssued(segment)) { + HttpRequestHandle httpRequest + (createHttpRequest(req, + _fileEntry, + segment, + _requestGroup->getTotalLength(), + getOption(), + _requestGroup, + e->getCookieStorage(), + e->getAuthConfigFactory(), + _proxyRequest)); + _httpConnection->sendRequest(httpRequest); + } } } } else { @@ -152,8 +152,8 @@ bool HttpRequestCommand::executeInternal() { } if(_httpConnection->sendBufferIsEmpty()) { Command* command = new HttpResponseCommand(cuid, req, _fileEntry, - _requestGroup, - _httpConnection, e, socket); + _requestGroup, + _httpConnection, e, socket); e->commands.push_back(command); return true; } else { diff --git a/src/HttpRequestCommand.h b/src/HttpRequestCommand.h index 761f0e05..ccfd5f69 100644 --- a/src/HttpRequestCommand.h +++ b/src/HttpRequestCommand.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -55,12 +55,12 @@ protected: virtual bool executeInternal(); public: HttpRequestCommand(int cuid, - const SharedHandle<Request>& req, - const SharedHandle<FileEntry>& fileEntry, - RequestGroup* requestGroup, - const SharedHandle<HttpConnection>& httpConnection, - DownloadEngine* e, - const SharedHandle<SocketCore>& s); + const SharedHandle<Request>& req, + const SharedHandle<FileEntry>& fileEntry, + RequestGroup* requestGroup, + const SharedHandle<HttpConnection>& httpConnection, + DownloadEngine* e, + const SharedHandle<SocketCore>& s); virtual ~HttpRequestCommand(); void setProxyRequest(const SharedHandle<Request>& proxyRequest); diff --git a/src/HttpResponse.cc b/src/HttpResponse.cc index f56abdd1..e377adeb 100644 --- a/src/HttpResponse.cc +++ b/src/HttpResponse.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -61,7 +61,7 @@ namespace aria2 { HttpResponse::HttpResponse():cuid(0), - logger(LogFactory::getInstance()) + logger(LogFactory::getInstance()) {} HttpResponse::~HttpResponse() {} @@ -75,22 +75,22 @@ void HttpResponse::validateResponse() const if(status >= HttpHeader::S300) { if(!httpHeader->defined(HttpHeader::LOCATION)) { throw DL_ABORT_EX - (StringFormat(EX_LOCATION_HEADER_REQUIRED, - util::parseUInt(status)).str()); + (StringFormat(EX_LOCATION_HEADER_REQUIRED, + util::parseUInt(status)).str()); } } else if(!httpHeader->defined(HttpHeader::TRANSFER_ENCODING)) { // compare the received range against the requested range RangeHandle responseRange = httpHeader->getRange(); if(!httpRequest->isRangeSatisfied(responseRange)) { 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()); + (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()); } } } @@ -109,7 +109,7 @@ std::string HttpResponse::determinFilename() const } } else { logger->info(MSG_CONTENT_DISPOSITION_DETECTED, - cuid, contentDisposition.c_str()); + cuid, contentDisposition.c_str()); return util::urldecode(contentDisposition); } } @@ -120,8 +120,8 @@ void HttpResponse::retrieveCookie() for(std::deque<std::string>::const_iterator itr = v.begin(); itr != v.end(); ++itr) { httpRequest->getCookieStorage()->parseAndStore(*itr, - httpRequest->getHost(), - httpRequest->getDir()); + httpRequest->getHost(), + httpRequest->getDir()); } } @@ -137,12 +137,12 @@ void HttpResponse::processRedirect() if(httpRequest->getRequest()->redirectUrl(getRedirectURI())) { logger->info(MSG_REDIRECT, cuid, - httpRequest->getRequest()->getCurrentUrl().c_str()); + httpRequest->getRequest()->getCurrentUrl().c_str()); } else { throw DL_RETRY_EX (StringFormat("CUID#%d - Redirect to %s failed. It may not be a valid" - " URI.", cuid, - httpRequest->getRequest()->getCurrentUrl().c_str()).str()); + " URI.", cuid, + httpRequest->getRequest()->getCurrentUrl().c_str()).str()); } } diff --git a/src/HttpResponse.h b/src/HttpResponse.h index d89a380f..8d754c9f 100644 --- a/src/HttpResponse.h +++ b/src/HttpResponse.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/HttpResponseCommand.cc b/src/HttpResponseCommand.cc index 675d0d9f..ca96d488 100644 --- a/src/HttpResponseCommand.cc +++ b/src/HttpResponseCommand.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -131,15 +131,15 @@ bool HttpResponseCommand::executeInternal() _fileEntry->setLength(totalLength); if(_fileEntry->getPath().empty()) { _fileEntry->setPath - (strconcat(getDownloadContext()->getDir(), - "/", httpResponse->determinFilename())); + (strconcat(getDownloadContext()->getDir(), + "/", httpResponse->determinFilename())); } _fileEntry->setContentType(httpResponse->getContentType()); _requestGroup->preDownloadProcessing(); if(e->_requestGroupMan->isSameFileBeingDownloaded(_requestGroup)) { throw DOWNLOAD_FAILURE_EXCEPTION - (StringFormat(EX_DUPLICATE_FILE_DOWNLOAD, - _requestGroup->getFirstFilePath().c_str()).str()); + (StringFormat(EX_DUPLICATE_FILE_DOWNLOAD, + _requestGroup->getFirstFilePath().c_str()).str()); } // update last modified time updateLastModifiedTime(httpResponse->getLastModifiedTime()); @@ -150,11 +150,11 @@ bool HttpResponseCommand::executeInternal() // we ignore content-length when inflate is required _fileEntry->setLength(0); if(req->getMethod() == Request::METHOD_GET && - (totalLength != 0 || - !httpResponse->getHttpHeader()->defined(HttpHeader::CONTENT_LENGTH))){ - // DownloadContext::knowsTotalLength() == true only when - // server says the size of file is 0 explicitly. - getDownloadContext()->markTotalLengthIsUnknown(); + (totalLength != 0 || + !httpResponse->getHttpHeader()->defined(HttpHeader::CONTENT_LENGTH))){ + // DownloadContext::knowsTotalLength() == true only when + // server says the size of file is 0 explicitly. + getDownloadContext()->markTotalLengthIsUnknown(); } return handleOtherEncoding(httpResponse); } else { @@ -163,7 +163,7 @@ bool HttpResponseCommand::executeInternal() } else { // validate totalsize _requestGroup->validateTotalLength(_fileEntry->getLength(), - httpResponse->getEntityLength()); + httpResponse->getEntityLength()); // update last modified time updateLastModifiedTime(httpResponse->getLastModifiedTime()); if(_requestGroup->getTotalLength() == 0) { @@ -173,12 +173,12 @@ bool HttpResponseCommand::executeInternal() // anyway. _requestGroup->getPieceStorage()->getDiskAdaptor()->truncate(0); e->commands.push_back - (createHttpDownloadCommand(httpResponse, - getTransferEncodingDecoder(httpResponse), - getContentEncodingDecoder(httpResponse))); + (createHttpDownloadCommand(httpResponse, + getTransferEncodingDecoder(httpResponse), + getContentEncodingDecoder(httpResponse))); } else { e->commands.push_back(createHttpDownloadCommand(httpResponse, - getTransferEncodingDecoder(httpResponse))); + getTransferEncodingDecoder(httpResponse))); } return true; } @@ -217,9 +217,9 @@ bool HttpResponseCommand::handleDefaultEncoding(const HttpResponseHandle& httpRe HttpRequestHandle httpRequest = httpResponse->getHttpRequest(); _requestGroup->adjustFilename (SharedHandle<BtProgressInfoFile>(new DefaultBtProgressInfoFile - (_requestGroup->getDownloadContext(), - SharedHandle<PieceStorage>(), - getOption().get()))); + (_requestGroup->getDownloadContext(), + SharedHandle<PieceStorage>(), + getOption().get()))); _requestGroup->initPieceStorage(); if(getOption()->getAsBool(PREF_DRY_RUN)) { @@ -232,8 +232,8 @@ bool HttpResponseCommand::handleDefaultEncoding(const HttpResponseHandle& httpRe _requestGroup->getPieceStorage()->markAllPiecesDone(); logger->notice(MSG_DOWNLOAD_ALREADY_COMPLETED, - _requestGroup->getGID(), - _requestGroup->getFirstFilePath().c_str()); + _requestGroup->getGID(), + _requestGroup->getFirstFilePath().c_str()); return true; } @@ -277,8 +277,8 @@ static SharedHandle<Decoder> getTransferEncodingDecoder decoder = httpResponse->getTransferEncodingDecoder(); if(decoder.isNull()) { throw DL_ABORT_EX - (StringFormat(EX_TRANSFER_ENCODING_NOT_SUPPORTED, - httpResponse->getTransferEncoding().c_str()).str()); + (StringFormat(EX_TRANSFER_ENCODING_NOT_SUPPORTED, + httpResponse->getTransferEncoding().c_str()).str()); } decoder->init(); } @@ -293,10 +293,10 @@ static SharedHandle<Decoder> getContentEncodingDecoder decoder = httpResponse->getContentEncodingDecoder(); if(decoder.isNull()) { LogFactory::getInstance()->info - ("Content-Encoding %s is specified, but the current implementation" - "doesn't support it. The decoding process is skipped and the" - "downloaded content will be still encoded.", - httpResponse->getContentEncoding().c_str()); + ("Content-Encoding %s is specified, but the current implementation" + "doesn't support it. The decoding process is skipped and the" + "downloaded content will be still encoded.", + httpResponse->getContentEncoding().c_str()); } else { decoder->init(); } @@ -326,8 +326,8 @@ bool HttpResponseCommand::handleOtherEncoding(const HttpResponseHandle& httpResp _requestGroup->getPieceStorage()->markAllPiecesDone(); logger->notice(MSG_DOWNLOAD_ALREADY_COMPLETED, - _requestGroup->getGID(), - _requestGroup->getFirstFilePath().c_str()); + _requestGroup->getGID(), + _requestGroup->getFirstFilePath().c_str()); poolConnection(); return true; @@ -346,8 +346,8 @@ bool HttpResponseCommand::handleOtherEncoding(const HttpResponseHandle& httpResp } e->commands.push_back (createHttpDownloadCommand(httpResponse, - getTransferEncodingDecoder(httpResponse), - getContentEncodingDecoder(httpResponse))); + getTransferEncodingDecoder(httpResponse), + getContentEncodingDecoder(httpResponse))); return true; } @@ -385,7 +385,7 @@ HttpDownloadCommand* HttpResponseCommand::createHttpDownloadCommand HttpDownloadCommand* command = new HttpDownloadCommand(cuid, req, _fileEntry, _requestGroup, - httpResponse, httpConnection, e, socket); + httpResponse, httpConnection, e, socket); command->setStartupIdleTime(getOption()->getAsInt(PREF_STARTUP_IDLE_TIME)); command->setLowestDownloadSpeedLimit (getOption()->getAsInt(PREF_LOWEST_SPEED_LIMIT)); diff --git a/src/HttpResponseCommand.h b/src/HttpResponseCommand.h index ad35dafb..2e43ac81 100644 --- a/src/HttpResponseCommand.h +++ b/src/HttpResponseCommand.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -56,10 +56,10 @@ private: HttpDownloadCommand* createHttpDownloadCommand(const SharedHandle<HttpResponse>& httpResponse, - const SharedHandle<Decoder>& transferEncodingDecoder - = SharedHandle<Decoder>(), - const SharedHandle<Decoder>& contentEncodingDecoder - = SharedHandle<Decoder>()); + const SharedHandle<Decoder>& transferEncodingDecoder + = SharedHandle<Decoder>(), + const SharedHandle<Decoder>& contentEncodingDecoder + = SharedHandle<Decoder>()); void updateLastModifiedTime(const Time& lastModified); @@ -74,12 +74,12 @@ protected: public: HttpResponseCommand(int32_t cuid, - const SharedHandle<Request>& req, - const SharedHandle<FileEntry>& fileEntry, - RequestGroup* requestGroup, - const SharedHandle<HttpConnection>& httpConnection, - DownloadEngine* e, - const SharedHandle<SocketCore>& s); + const SharedHandle<Request>& req, + const SharedHandle<FileEntry>& fileEntry, + RequestGroup* requestGroup, + const SharedHandle<HttpConnection>& httpConnection, + DownloadEngine* e, + const SharedHandle<SocketCore>& s); ~HttpResponseCommand(); }; diff --git a/src/HttpServer.cc b/src/HttpServer.cc index 9483196c..12ad34a2 100644 --- a/src/HttpServer.cc +++ b/src/HttpServer.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -50,7 +50,7 @@ namespace aria2 { HttpServer::HttpServer(const SharedHandle<SocketCore>& socket, - DownloadEngine* e): + DownloadEngine* e): _socket(socket), _socketBuffer(socket), _e(e), @@ -81,7 +81,7 @@ SharedHandle<HttpHeader> HttpServer::receiveRequest() SharedHandle<HttpHeader> header = _headerProcessor->getHttpRequestHeader(); if(!header.isNull()) { _logger->info("HTTP Server received request\n%s", - _headerProcessor->getHeaderString().c_str()); + _headerProcessor->getHeaderString().c_str()); _lastRequestHeader = header; _lastBody.clear(); _lastBody.str(""); @@ -101,8 +101,8 @@ bool HttpServer::receiveBody() const size_t BUFLEN = 4096; char buf[BUFLEN]; size_t length = std::min(BUFLEN, - static_cast<size_t> - (_lastContentLength-_lastBody.tellg())); + static_cast<size_t> + (_lastContentLength-_lastBody.tellg())); _socket->readData(buf, length); if(length == 0 && !(_socket->wantRead() || _socket->wantWrite())) { throw DL_ABORT_EX(EX_EOF_FROM_PEER); @@ -141,14 +141,14 @@ void HttpServer::feedResponse(const std::string& text, const std::string& conten } void HttpServer::feedResponse(const std::string& status, - const std::string& headers, - const std::string& text, - const std::string& contentType) + const std::string& headers, + const std::string& text, + const std::string& contentType) { 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-Type: ", contentType, "\r\n", + "Content-Length: ", util::uitos(text.size()), "\r\n"); if(!supportsPersistentConnection()) { header += "Connection: close\r\n"; @@ -163,7 +163,7 @@ void HttpServer::feedResponse(const std::string& status, header += "\r\n"; _logger->debug("HTTP Server sends response:\n%s", header.c_str()); - + _socketBuffer.feedSendBuffer(header); _socketBuffer.feedSendBuffer(text); } diff --git a/src/HttpServer.h b/src/HttpServer.h index 3142ad6d..8fc57386 100644 --- a/src/HttpServer.h +++ b/src/HttpServer.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -80,9 +80,9 @@ public: void feedResponse(const std::string& text, const std::string& contentType); void feedResponse(const std::string& status, - const std::string& headers, - const std::string& text, - const std::string& contentType); + const std::string& headers, + const std::string& text, + const std::string& contentType); bool authenticate(); diff --git a/src/HttpServerBodyCommand.cc b/src/HttpServerBodyCommand.cc index c40efde1..07ac5d7a 100644 --- a/src/HttpServerBodyCommand.cc +++ b/src/HttpServerBodyCommand.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -82,39 +82,39 @@ bool HttpServerBodyCommand::execute() _timeout.reset(); if(_httpServer->receiveBody()) { - // Do something for requestpath and body - if(_httpServer->getRequestPath() == "/rpc") { - xmlrpc::XmlRpcRequest req = - xmlrpc::XmlRpcRequestProcessor().parseMemory(_httpServer->getBody()); - - SharedHandle<xmlrpc::XmlRpcMethod> method = - xmlrpc::XmlRpcMethodFactory::create(req._methodName); - xmlrpc::XmlRpcResponse res = method->execute(req, _e); - _httpServer->feedResponse(res.toXml(), "text/xml"); - Command* command = - new HttpServerResponseCommand(cuid, _httpServer, _e, _socket); - _e->commands.push_back(command); - _e->setNoWait(true); - return true; - } else { - return true; - } + // Do something for requestpath and body + if(_httpServer->getRequestPath() == "/rpc") { + xmlrpc::XmlRpcRequest req = + xmlrpc::XmlRpcRequestProcessor().parseMemory(_httpServer->getBody()); + + SharedHandle<xmlrpc::XmlRpcMethod> method = + xmlrpc::XmlRpcMethodFactory::create(req._methodName); + xmlrpc::XmlRpcResponse res = method->execute(req, _e); + _httpServer->feedResponse(res.toXml(), "text/xml"); + Command* command = + new HttpServerResponseCommand(cuid, _httpServer, _e, _socket); + _e->commands.push_back(command); + _e->setNoWait(true); + return true; + } else { + return true; + } } else { - _e->commands.push_back(this); - return false; - } + _e->commands.push_back(this); + return false; + } } else { if(_timeout.elapsed(30)) { - logger->info("HTTP request body timeout."); - return true; + logger->info("HTTP request body timeout."); + return true; } else { - _e->commands.push_back(this); - return false; + _e->commands.push_back(this); + return false; } } } catch(RecoverableException& e) { logger->info("CUID#%d - Error occurred while reading HTTP request body", - e, cuid); + e, cuid); return true; } diff --git a/src/HttpServerBodyCommand.h b/src/HttpServerBodyCommand.h index 0a8468a4..b3276ac2 100644 --- a/src/HttpServerBodyCommand.h +++ b/src/HttpServerBodyCommand.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -53,9 +53,9 @@ private: Time _timeout; public: HttpServerBodyCommand(int32_t cuid, - const SharedHandle<HttpServer>& httpServer, - DownloadEngine* e, - const SharedHandle<SocketCore>& socket); + const SharedHandle<HttpServer>& httpServer, + DownloadEngine* e, + const SharedHandle<SocketCore>& socket); virtual ~HttpServerBodyCommand(); diff --git a/src/HttpServerCommand.cc b/src/HttpServerCommand.cc index b6c20754..03edd761 100644 --- a/src/HttpServerCommand.cc +++ b/src/HttpServerCommand.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -51,7 +51,7 @@ namespace aria2 { HttpServerCommand::HttpServerCommand(int32_t cuid, DownloadEngine* e, - const SharedHandle<SocketCore>& socket): + const SharedHandle<SocketCore>& socket): Command(cuid), _e(e), _socket(socket), @@ -60,13 +60,13 @@ HttpServerCommand::HttpServerCommand(int32_t cuid, DownloadEngine* e, setStatus(Command::STATUS_ONESHOT_REALTIME); _e->addSocketForReadCheck(_socket, this); _httpServer->setUsernamePassword(_e->option->get(PREF_XML_RPC_USER), - _e->option->get(PREF_XML_RPC_PASSWD)); + _e->option->get(PREF_XML_RPC_PASSWD)); } HttpServerCommand::HttpServerCommand(int32_t cuid, - const SharedHandle<HttpServer>& httpServer, - DownloadEngine* e, - const SharedHandle<SocketCore>& socket): + const SharedHandle<HttpServer>& httpServer, + DownloadEngine* e, + const SharedHandle<SocketCore>& socket): Command(cuid), _e(e), _socket(socket), @@ -93,46 +93,46 @@ bool HttpServerCommand::execute() header = _httpServer->receiveRequest(); if(header.isNull()) { - _e->commands.push_back(this); - return false; + _e->commands.push_back(this); + return false; } if(!_httpServer->authenticate()) { - _httpServer->disableKeepAlive(); - _httpServer->feedResponse("401 Unauthorized", - "WWW-Authenticate: Basic realm=\"aria2\"", - "","text/html"); - Command* command = - new HttpServerResponseCommand(cuid, _httpServer, _e, _socket); - _e->commands.push_back(command); - _e->setNoWait(true); - return true; + _httpServer->disableKeepAlive(); + _httpServer->feedResponse("401 Unauthorized", + "WWW-Authenticate: Basic realm=\"aria2\"", + "","text/html"); + Command* command = + new HttpServerResponseCommand(cuid, _httpServer, _e, _socket); + _e->commands.push_back(command); + _e->setNoWait(true); + return true; } if(static_cast<uint64_t> - (_e->option->getAsInt(PREF_XML_RPC_MAX_REQUEST_SIZE)) < - _httpServer->getContentLength()) { - logger->info("Request too long. ContentLength=%s." - " See --xml-rpc-max-request-size option to loose" - " this limitation.", - util::uitos(_httpServer->getContentLength()).c_str()); - return true; + (_e->option->getAsInt(PREF_XML_RPC_MAX_REQUEST_SIZE)) < + _httpServer->getContentLength()) { + logger->info("Request too long. ContentLength=%s." + " See --xml-rpc-max-request-size option to loose" + " this limitation.", + util::uitos(_httpServer->getContentLength()).c_str()); + return true; } Command* command = new HttpServerBodyCommand(cuid, _httpServer, _e, - _socket); + _socket); _e->commands.push_back(command); _e->setNoWait(true); return true; } else { if(_timeout.elapsed(30)) { - logger->info("HTTP request timeout."); - return true; + logger->info("HTTP request timeout."); + return true; } else { - _e->commands.push_back(this); - return false; + _e->commands.push_back(this); + return false; } } } catch(RecoverableException& e) { logger->info("CUID#%d - Error occurred while reading HTTP request", - e, cuid); + e, cuid); return true; } diff --git a/src/HttpServerCommand.h b/src/HttpServerCommand.h index f126ab3f..65a378e7 100644 --- a/src/HttpServerCommand.h +++ b/src/HttpServerCommand.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -53,12 +53,12 @@ private: Time _timeout; public: HttpServerCommand(int32_t cuid, DownloadEngine* e, - const SharedHandle<SocketCore>& socket); + const SharedHandle<SocketCore>& socket); HttpServerCommand(int32_t cuid, - const SharedHandle<HttpServer>& httpServer, - DownloadEngine* e, - const SharedHandle<SocketCore>& socket); + const SharedHandle<HttpServer>& httpServer, + DownloadEngine* e, + const SharedHandle<SocketCore>& socket); virtual ~HttpServerCommand(); diff --git a/src/HttpServerResponseCommand.cc b/src/HttpServerResponseCommand.cc index 42e04945..5245ccf1 100644 --- a/src/HttpServerResponseCommand.cc +++ b/src/HttpServerResponseCommand.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -52,7 +52,7 @@ HttpServerResponseCommand::HttpServerResponseCommand Command(cuid), _e(e), _socket(socket), - _httpServer(httpServer) + _httpServer(httpServer) { setStatus(Command::STATUS_ONESHOT_REALTIME); _e->addSocketForWriteCheck(_socket, this); @@ -72,7 +72,7 @@ bool HttpServerResponseCommand::execute() _httpServer->sendResponse(); } catch(RecoverableException& e) { logger->info("CUID#%d - Error occurred while transmitting response body.", - e, cuid); + e, cuid); return true; } if(_httpServer->sendBufferIsEmpty()) { @@ -80,13 +80,13 @@ bool HttpServerResponseCommand::execute() if(_httpServer->supportsPersistentConnection()) { logger->info("CUID#%d - Persist connection.", cuid); _e->commands.push_back - (new HttpServerCommand(cuid, _httpServer, _e, _socket)); + (new HttpServerCommand(cuid, _httpServer, _e, _socket)); } return true; } else { if(_timeout.elapsed(10)) { logger->info("CUID#%d - HttpServer: Timeout while trasmitting response.", - cuid); + cuid); return true; } else { _e->commands.push_back(this); diff --git a/src/HttpServerResponseCommand.h b/src/HttpServerResponseCommand.h index 52523cf2..c1fbc9de 100644 --- a/src/HttpServerResponseCommand.h +++ b/src/HttpServerResponseCommand.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -53,9 +53,9 @@ private: Time _timeout; public: HttpServerResponseCommand(int32_t cuid, - const SharedHandle<HttpServer>& httpServer, - DownloadEngine* e, - const SharedHandle<SocketCore>& socket); + const SharedHandle<HttpServer>& httpServer, + DownloadEngine* e, + const SharedHandle<SocketCore>& socket); virtual ~HttpServerResponseCommand(); diff --git a/src/HttpSkipResponseCommand.cc b/src/HttpSkipResponseCommand.cc index 09a874a3..521ce010 100644 --- a/src/HttpSkipResponseCommand.cc +++ b/src/HttpSkipResponseCommand.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -122,7 +122,7 @@ bool HttpSkipResponseCommand::executeInternal() if(_transferEncodingDecoder.isNull()) { if(bufSize == 0) { if(!socket->wantRead() && !socket->wantWrite()) { - return processResponse(); + return processResponse(); } } else { finished = (_totalLength == _receivedBytes); @@ -160,16 +160,16 @@ bool HttpSkipResponseCommand::processResponse() } else if(_httpResponse->getResponseStatus() >= HttpHeader::S400) { if(_httpResponse->getResponseStatus() == HttpHeader::S401) { if(getOption()->getAsBool(PREF_HTTP_AUTH_CHALLENGE) && - !_httpResponse->getHttpRequest()->authenticationUsed() && - e->getAuthConfigFactory()->activateBasicCred - (req->getHost(), req->getDir(), getOption().get())) { - return prepareForRetry(0); + !_httpResponse->getHttpRequest()->authenticationUsed() && + e->getAuthConfigFactory()->activateBasicCred + (req->getHost(), req->getDir(), getOption().get())) { + return prepareForRetry(0); } else { - throw DL_ABORT_EX(EX_AUTH_FAILED); + throw DL_ABORT_EX(EX_AUTH_FAILED); } }else if(_httpResponse->getResponseStatus() == HttpHeader::S404) { throw DL_ABORT_EX2(MSG_RESOURCE_NOT_FOUND, - downloadresultcode::RESOURCE_NOT_FOUND); + downloadresultcode::RESOURCE_NOT_FOUND); } else { throw DL_ABORT_EX(StringFormat(EX_BAD_STATUS, util::parseUInt(_httpResponse->getResponseStatus())).str()); } diff --git a/src/HttpSkipResponseCommand.h b/src/HttpSkipResponseCommand.h index d3cbe7bb..1109f389 100644 --- a/src/HttpSkipResponseCommand.h +++ b/src/HttpSkipResponseCommand.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -62,13 +62,13 @@ protected: virtual bool executeInternal(); public: HttpSkipResponseCommand(int cuid, - const SharedHandle<Request>& req, - const SharedHandle<FileEntry>& fileEntry, - RequestGroup* requestGroup, - const SharedHandle<HttpConnection>& httpConnection, - const SharedHandle<HttpResponse>& httpResponse, - DownloadEngine* e, - const SharedHandle<SocketCore>& s); + const SharedHandle<Request>& req, + const SharedHandle<FileEntry>& fileEntry, + RequestGroup* requestGroup, + const SharedHandle<HttpConnection>& httpConnection, + const SharedHandle<HttpResponse>& httpResponse, + DownloadEngine* e, + const SharedHandle<SocketCore>& s); virtual ~HttpSkipResponseCommand(); diff --git a/src/InOrderURISelector.cc b/src/InOrderURISelector.cc index b08d74e7..7e64d6c5 100644 --- a/src/InOrderURISelector.cc +++ b/src/InOrderURISelector.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/InOrderURISelector.h b/src/InOrderURISelector.h index 98a29700..5cbfec10 100644 --- a/src/InOrderURISelector.h +++ b/src/InOrderURISelector.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/IndexBtMessage.cc b/src/IndexBtMessage.cc index 576db3a0..bede58fb 100644 --- a/src/IndexBtMessage.cc +++ b/src/IndexBtMessage.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/IndexBtMessage.h b/src/IndexBtMessage.h index 1bc73f03..fc26d744 100644 --- a/src/IndexBtMessage.h +++ b/src/IndexBtMessage.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/IndexBtMessageValidator.h b/src/IndexBtMessageValidator.h index 5dc91e82..50751cad 100644 --- a/src/IndexBtMessageValidator.h +++ b/src/IndexBtMessageValidator.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -47,7 +47,7 @@ private: size_t _numPiece; public: IndexBtMessageValidator(const IndexBtMessage* message, - size_t numPiece): + size_t numPiece): _message(message), _numPiece(numPiece) {} diff --git a/src/InitiateConnectionCommand.cc b/src/InitiateConnectionCommand.cc index a0a282e0..22d873a9 100644 --- a/src/InitiateConnectionCommand.cc +++ b/src/InitiateConnectionCommand.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -85,29 +85,29 @@ bool InitiateConnectionCommand::executeInternal() { #ifdef ENABLE_ASYNC_DNS if(getOption()->getAsBool(PREF_ASYNC_DNS)) { if(!isAsyncNameResolverInitialized()) { - initAsyncNameResolver(hostname); + initAsyncNameResolver(hostname); } if(asyncResolveHostname()) { - addrs = getResolvedAddresses(); + addrs = getResolvedAddresses(); } else { - e->commands.push_back(this); - return false; + e->commands.push_back(this); + return false; } } else #endif // ENABLE_ASYNC_DNS { - NameResolver res; - res.setSocktype(SOCK_STREAM); - if(e->option->getAsBool(PREF_DISABLE_IPV6)) { - res.setFamily(AF_INET); - } - res.resolve(addrs, hostname); + NameResolver res; + res.setSocktype(SOCK_STREAM); + if(e->option->getAsBool(PREF_DISABLE_IPV6)) { + res.setFamily(AF_INET); + } + res.resolve(addrs, hostname); } logger->info(MSG_NAME_RESOLUTION_COMPLETE, cuid, - hostname.c_str(), - strjoin(addrs.begin(), addrs.end(), ",").c_str()); + hostname.c_str(), + strjoin(addrs.begin(), addrs.end(), ",").c_str()); for(std::deque<std::string>::const_iterator i = addrs.begin(); - i != addrs.end(); ++i) { + i != addrs.end(); ++i) { e->cacheIPAddress(hostname, *i, port); } ipaddr = e->findCachedIPAddress(hostname, port); @@ -117,7 +117,7 @@ bool InitiateConnectionCommand::executeInternal() { } try { Command* command = createNextCommand(hostname, ipaddr, port, - addrs, proxyRequest); + addrs, proxyRequest); e->commands.push_back(command); return true; } catch(RecoverableException& ex) { @@ -128,8 +128,8 @@ bool InitiateConnectionCommand::executeInternal() { logger->info(EX_EXCEPTION_CAUGHT, ex); logger->info(MSG_CONNECT_FAILED_AND_RETRY, cuid, ipaddr.c_str(), port); Command* command = - InitiateConnectionCommandFactory::createInitiateConnectionCommand - (cuid, req, _fileEntry, _requestGroup, e); + InitiateConnectionCommandFactory::createInitiateConnectionCommand + (cuid, req, _fileEntry, _requestGroup, e); e->setNoWait(true); e->commands.push_back(command); return true; diff --git a/src/InitiateConnectionCommand.h b/src/InitiateConnectionCommand.h index ecf0ad93..00043c2a 100644 --- a/src/InitiateConnectionCommand.h +++ b/src/InitiateConnectionCommand.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -61,9 +61,9 @@ protected: const SharedHandle<Request>& proxyRequest) = 0; public: InitiateConnectionCommand(int cuid, const SharedHandle<Request>& req, - const SharedHandle<FileEntry>& fileEntry, - RequestGroup* requestGroup, - DownloadEngine* e); + const SharedHandle<FileEntry>& fileEntry, + RequestGroup* requestGroup, + DownloadEngine* e); virtual ~InitiateConnectionCommand(); }; diff --git a/src/InitiateConnectionCommandFactory.cc b/src/InitiateConnectionCommandFactory.cc index bca5c97c..9498e92a 100644 --- a/src/InitiateConnectionCommandFactory.cc +++ b/src/InitiateConnectionCommandFactory.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -74,8 +74,8 @@ InitiateConnectionCommandFactory::createInitiateConnectionCommand } else if(req->getProtocol() == Request::PROTO_FTP) { if(req->getFile().empty()) { throw DL_ABORT_EX - (StringFormat("FTP URL %s doesn't contain file path.", - req->getUrl().c_str()).str()); + (StringFormat("FTP URL %s doesn't contain file path.", + req->getUrl().c_str()).str()); } return new FtpInitiateConnectionCommand(cuid, req, fileEntry, requestGroup, e); @@ -83,7 +83,7 @@ InitiateConnectionCommandFactory::createInitiateConnectionCommand // these protocols are not supported yet throw DL_ABORT_EX (StringFormat("%s is not supported yet.", - req->getProtocol().c_str()).str()); + req->getProtocol().c_str()).str()); } } diff --git a/src/InitiateConnectionCommandFactory.h b/src/InitiateConnectionCommandFactory.h index 5ba88e90..936df12f 100644 --- a/src/InitiateConnectionCommandFactory.h +++ b/src/InitiateConnectionCommandFactory.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -50,10 +50,10 @@ class InitiateConnectionCommandFactory { public: static Command* createInitiateConnectionCommand(int32_t cuid, - const SharedHandle<Request>& req, - const SharedHandle<FileEntry>& fileEntry, - RequestGroup* requestGroup, - DownloadEngine* e); + const SharedHandle<Request>& req, + const SharedHandle<FileEntry>& fileEntry, + RequestGroup* requestGroup, + DownloadEngine* e); }; } // namespace aria2 diff --git a/src/InitiatorMSEHandshakeCommand.cc b/src/InitiatorMSEHandshakeCommand.cc index 87717751..893c4405 100644 --- a/src/InitiatorMSEHandshakeCommand.cc +++ b/src/InitiatorMSEHandshakeCommand.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -114,12 +114,12 @@ bool InitiatorMSEHandshakeCommand::executeInternal() { case INITIATOR_WAIT_KEY: { if(_mseHandshake->receivePublicKey()) { _mseHandshake->initCipher - (bittorrent::getInfoHash(_requestGroup->getDownloadContext()));; + (bittorrent::getInfoHash(_requestGroup->getDownloadContext()));; if(_mseHandshake->sendInitiatorStep2()) { - _sequence = INITIATOR_FIND_VC_MARKER; + _sequence = INITIATOR_FIND_VC_MARKER; } else { - setWriteCheckSocket(socket); - _sequence = INITIATOR_SEND_STEP2_PENDING; + setWriteCheckSocket(socket); + _sequence = INITIATOR_SEND_STEP2_PENDING; } } break; @@ -145,17 +145,17 @@ bool InitiatorMSEHandshakeCommand::executeInternal() { case INITIATOR_RECEIVE_PAD_D: { if(_mseHandshake->receivePad()) { SharedHandle<PeerConnection> peerConnection - (new PeerConnection(cuid, socket)); + (new PeerConnection(cuid, socket)); if(_mseHandshake->getNegotiatedCryptoType() == MSEHandshake::CRYPTO_ARC4) { - peerConnection->enableEncryption(_mseHandshake->getEncryptor(), - _mseHandshake->getDecryptor()); + peerConnection->enableEncryption(_mseHandshake->getEncryptor(), + _mseHandshake->getDecryptor()); } PeerInteractionCommand* c = - new PeerInteractionCommand - (cuid, _requestGroup, peer, e, _btRuntime, _pieceStorage, _peerStorage, - socket, - PeerInteractionCommand::INITIATOR_SEND_HANDSHAKE, - peerConnection); + new PeerInteractionCommand + (cuid, _requestGroup, peer, e, _btRuntime, _pieceStorage, _peerStorage, + socket, + PeerInteractionCommand::INITIATOR_SEND_HANDSHAKE, + peerConnection); e->commands.push_back(c); return true; } @@ -174,8 +174,8 @@ bool InitiatorMSEHandshakeCommand::prepareForNextPeer(time_t wait) SharedHandle<Peer> peer = _peerStorage->getUnusedPeer(); peer->usedBy(e->newCUID()); PeerInitiateConnectionCommand* command = - new PeerInitiateConnectionCommand(peer->usedBy(), _requestGroup, peer, - e, _btRuntime); + new PeerInitiateConnectionCommand(peer->usedBy(), _requestGroup, peer, + e, _btRuntime); command->setPeerStorage(_peerStorage); command->setPieceStorage(_pieceStorage); e->commands.push_back(command); @@ -186,7 +186,7 @@ bool InitiatorMSEHandshakeCommand::prepareForNextPeer(time_t wait) logger->info("CUID#%d - Retry using legacy BitTorrent handshake.", cuid); PeerInitiateConnectionCommand* command = new PeerInitiateConnectionCommand(cuid, _requestGroup, peer, e, - _btRuntime, false); + _btRuntime, false); command->setPeerStorage(_peerStorage); command->setPieceStorage(_pieceStorage); e->commands.push_back(command); diff --git a/src/InitiatorMSEHandshakeCommand.h b/src/InitiatorMSEHandshakeCommand.h index 996a72e9..8edd05fb 100644 --- a/src/InitiatorMSEHandshakeCommand.h +++ b/src/InitiatorMSEHandshakeCommand.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -77,12 +77,12 @@ protected: virtual bool exitBeforeExecute(); public: InitiatorMSEHandshakeCommand - (int32_t cuid, - RequestGroup* requestGroup, - const SharedHandle<Peer>& peer, - DownloadEngine* e, - const SharedHandle<BtRuntime>& btRuntime, - const SharedHandle<SocketCore>& s); + (int32_t cuid, + RequestGroup* requestGroup, + const SharedHandle<Peer>& peer, + DownloadEngine* e, + const SharedHandle<BtRuntime>& btRuntime, + const SharedHandle<SocketCore>& s); virtual ~InitiatorMSEHandshakeCommand(); diff --git a/src/IntSequence.h b/src/IntSequence.h index 89aca51c..8fa2d202 100644 --- a/src/IntSequence.h +++ b/src/IntSequence.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/IteratableChecksumValidator.cc b/src/IteratableChecksumValidator.cc index 3b99d75c..1e36107b 100644 --- a/src/IteratableChecksumValidator.cc +++ b/src/IteratableChecksumValidator.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -74,17 +74,17 @@ void IteratableChecksumValidator::validateChunk() { if(!finished()) { size_t length = _pieceStorage->getDiskAdaptor()->readData(_buffer, - BUFSIZE, - _currentOffset); + BUFSIZE, + _currentOffset); _ctx->digestUpdate(_buffer, length); _currentOffset += length; if(finished()) { std::string actualChecksum = util::toHex(_ctx->digestFinal()); if(_dctx->getChecksum() == actualChecksum) { - _pieceStorage->markAllPiecesDone(); + _pieceStorage->markAllPiecesDone(); } else { - BitfieldMan bitfield(_dctx->getPieceLength(), _dctx->getTotalLength()); - _pieceStorage->setBitfield(bitfield.getBitfield(), bitfield.getBitfieldLength()); + BitfieldMan bitfield(_dctx->getPieceLength(), _dctx->getTotalLength()); + _pieceStorage->setBitfield(bitfield.getBitfield(), bitfield.getBitfieldLength()); } } } diff --git a/src/IteratableChecksumValidator.h b/src/IteratableChecksumValidator.h index 62112e95..63536717 100644 --- a/src/IteratableChecksumValidator.h +++ b/src/IteratableChecksumValidator.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -61,7 +61,7 @@ private: public: IteratableChecksumValidator(const SharedHandle<DownloadContext>& dctx, - const SharedHandle<PieceStorage>& pieceStorage); + const SharedHandle<PieceStorage>& pieceStorage); virtual ~IteratableChecksumValidator(); diff --git a/src/IteratableChunkChecksumValidator.cc b/src/IteratableChunkChecksumValidator.cc index 189e6d29..a700767d 100644 --- a/src/IteratableChunkChecksumValidator.cc +++ b/src/IteratableChunkChecksumValidator.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -59,7 +59,7 @@ namespace aria2 { IteratableChunkChecksumValidator:: IteratableChunkChecksumValidator(const SharedHandle<DownloadContext>& dctx, - const PieceStorageHandle& pieceStorage): + const PieceStorageHandle& pieceStorage): _dctx(dctx), _pieceStorage(pieceStorage), _bitfield(new BitfieldMan(_dctx->getPieceLength(), _dctx->getTotalLength())), @@ -84,14 +84,14 @@ void IteratableChunkChecksumValidator::validateChunk() try { actualChecksum = calculateActualChecksum(); if(actualChecksum == _dctx->getPieceHashes()[_currentIndex]) { - _bitfield->setBit(_currentIndex); + _bitfield->setBit(_currentIndex); } else { - _logger->info(EX_INVALID_CHUNK_CHECKSUM, - _currentIndex, - util::itos(getCurrentOffset(), true).c_str(), - _dctx->getPieceHashes()[_currentIndex].c_str(), - actualChecksum.c_str()); - _bitfield->unsetBit(_currentIndex); + _logger->info(EX_INVALID_CHUNK_CHECKSUM, + _currentIndex, + util::itos(getCurrentOffset(), true).c_str(), + _dctx->getPieceHashes()[_currentIndex].c_str(), + actualChecksum.c_str()); + _bitfield->unsetBit(_currentIndex); } } catch(RecoverableException& ex) { _logger->debug("Caught exception while validating piece index=%d. Some part of file may be missing. Continue operation.", ex, _currentIndex); @@ -151,11 +151,11 @@ std::string IteratableChunkChecksumValidator::digest(off_t offset, size_t length } while(curoffset < max) { size_t r = _pieceStorage->getDiskAdaptor()->readData(_buffer, BUFSIZE, - curoffset); + curoffset); if(r == 0 || r < static_cast<size_t>(woffset)) { throw DL_ABORT_EX - (StringFormat(EX_FILE_READ, _dctx->getBasePath().c_str(), - strerror(errno)).str()); + (StringFormat(EX_FILE_READ, _dctx->getBasePath().c_str(), + strerror(errno)).str()); } size_t wlength; if(max < static_cast<off_t>(curoffset+r)) { diff --git a/src/IteratableChunkChecksumValidator.h b/src/IteratableChunkChecksumValidator.h index 8443fadd..2b829e5d 100644 --- a/src/IteratableChunkChecksumValidator.h +++ b/src/IteratableChunkChecksumValidator.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -62,7 +62,7 @@ private: public: IteratableChunkChecksumValidator(const SharedHandle<DownloadContext>& dctx, - const SharedHandle<PieceStorage>& pieceStorage); + const SharedHandle<PieceStorage>& pieceStorage); virtual ~IteratableChunkChecksumValidator(); diff --git a/src/IteratableValidator.h b/src/IteratableValidator.h index 0db070ee..0512b3fd 100644 --- a/src/IteratableValidator.h +++ b/src/IteratableValidator.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/LibgcryptARC4Context.h b/src/LibgcryptARC4Context.h index b4dfe56a..982e17ec 100644 --- a/src/LibgcryptARC4Context.h +++ b/src/LibgcryptARC4Context.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -52,7 +52,7 @@ private: { throw DL_ABORT_EX (StringFormat("Exception in libgcrypt routine(ARC4Context class): %s", - gcry_strerror(err)).str()); + gcry_strerror(err)).str()); } public: LibgcryptARC4Context():_cipherCtx(0) {} @@ -77,19 +77,19 @@ public: { gcry_error_t r = gcry_cipher_open(&_cipherCtx, algo, mode, flags); if(r) { - handleError(r); + handleError(r); } } { gcry_error_t r = gcry_cipher_setkey(_cipherCtx, key, keyLength); if(r) { - handleError(r); + handleError(r); } } { gcry_error_t r = gcry_cipher_setiv(_cipherCtx, 0, 0); if(r) { - handleError(r); + handleError(r); } } } diff --git a/src/LibgcryptARC4Decryptor.h b/src/LibgcryptARC4Decryptor.h index 230e0926..87ffca8d 100644 --- a/src/LibgcryptARC4Decryptor.h +++ b/src/LibgcryptARC4Decryptor.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -53,7 +53,7 @@ private: { throw DL_ABORT_EX (StringFormat("Exception in libgcrypt routine(ARC4Decryptor class): %s", - gcry_strerror(err)).str()); + gcry_strerror(err)).str()); } public: ARC4Decryptor() {} @@ -66,10 +66,10 @@ public: } void decrypt(unsigned char* out, size_t outLength, - const unsigned char* in, size_t inLength) + const unsigned char* in, size_t inLength) { gcry_error_t r = gcry_cipher_decrypt(_ctx.getCipherContext(), - out, outLength, in, inLength); + out, outLength, in, inLength); if(r) { handleError(r); } diff --git a/src/LibgcryptARC4Encryptor.h b/src/LibgcryptARC4Encryptor.h index e1cf18b9..9337ff88 100644 --- a/src/LibgcryptARC4Encryptor.h +++ b/src/LibgcryptARC4Encryptor.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -53,7 +53,7 @@ private: { throw DL_ABORT_EX (StringFormat("Exception in libgcrypt routine(ARC4Encryptor class): %s", - gcry_strerror(err)).str()); + gcry_strerror(err)).str()); } public: ARC4Encryptor() {} @@ -66,10 +66,10 @@ public: } void encrypt(unsigned char* out, size_t outLength, - const unsigned char* in, size_t inLength) + const unsigned char* in, size_t inLength) { gcry_error_t r = gcry_cipher_encrypt(_ctx.getCipherContext(), - out, outLength, in, inLength); + out, outLength, in, inLength); if(r) { handleError(r); } diff --git a/src/LibgcryptDHKeyExchange.h b/src/LibgcryptDHKeyExchange.h index 78d2ccbe..20e68941 100644 --- a/src/LibgcryptDHKeyExchange.h +++ b/src/LibgcryptDHKeyExchange.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -58,7 +58,7 @@ private: { throw DL_ABORT_EX (StringFormat("Exception in libgcrypt routine(DHKeyExchange class): %s", - gcry_strerror(err)).str()); + gcry_strerror(err)).str()); } public: DHKeyExchange(): @@ -77,24 +77,24 @@ public: } void init(const unsigned char* prime, size_t primeBits, - const unsigned char* generator, - size_t privateKeyBits) + const unsigned char* generator, + size_t privateKeyBits) { gcry_mpi_release(_prime); gcry_mpi_release(_generator); gcry_mpi_release(_privateKey); { gcry_error_t r = gcry_mpi_scan(&_prime, GCRYMPI_FMT_HEX, - prime, 0, 0); + prime, 0, 0); if(r) { - handleError(r); + handleError(r); } } { gcry_error_t r = gcry_mpi_scan(&_generator, GCRYMPI_FMT_HEX, - generator, 0, 0); + generator, 0, 0); if(r) { - handleError(r); + handleError(r); } } _privateKey = gcry_mpi_new(0); @@ -113,15 +113,15 @@ public: { if(outLength < _keyLength) { throw DL_ABORT_EX - (StringFormat("Insufficient buffer for public key. expect:%u, actual:%u", - _keyLength, outLength).str()); + (StringFormat("Insufficient buffer for public key. expect:%u, actual:%u", + _keyLength, outLength).str()); } memset(out, 0, outLength); size_t publicKeyBytes = (gcry_mpi_get_nbits(_publicKey)+7)/8; size_t offset = _keyLength-publicKeyBytes; size_t nwritten; gcry_error_t r = gcry_mpi_print(GCRYMPI_FMT_USG, out+offset, - outLength-offset, &nwritten, _publicKey); + outLength-offset, &nwritten, _publicKey); if(r) { handleError(r); } @@ -134,20 +134,20 @@ public: } size_t computeSecret(unsigned char* out, size_t outLength, - const unsigned char* peerPublicKeyData, - size_t peerPublicKeyLength) const + const unsigned char* peerPublicKeyData, + size_t peerPublicKeyLength) const { if(outLength < _keyLength) { throw DL_ABORT_EX - (StringFormat("Insufficient buffer for secret. expect:%u, actual:%u", - _keyLength, outLength).str()); + (StringFormat("Insufficient buffer for secret. expect:%u, actual:%u", + _keyLength, outLength).str()); } gcry_mpi_t peerPublicKey; { gcry_error_t r = gcry_mpi_scan(&peerPublicKey, GCRYMPI_FMT_USG, peerPublicKeyData, - peerPublicKeyLength, 0); + peerPublicKeyLength, 0); if(r) { - handleError(r); + handleError(r); } } gcry_mpi_t secret = gcry_mpi_new(0); @@ -160,10 +160,10 @@ public: size_t nwritten; { gcry_error_t r = gcry_mpi_print(GCRYMPI_FMT_USG, out+offset, - outLength-offset, &nwritten, secret); + outLength-offset, &nwritten, secret); gcry_mpi_release(secret); if(r) { - handleError(r); + handleError(r); } } return nwritten; diff --git a/src/LibgnutlsTLSContext.cc b/src/LibgnutlsTLSContext.cc index d32e207a..4e18d5a3 100644 --- a/src/LibgnutlsTLSContext.cc +++ b/src/LibgnutlsTLSContext.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -46,18 +46,18 @@ namespace aria2 { TLSContext::TLSContext():_certCred(0), - _peerVerificationEnabled(false), - _logger(LogFactory::getInstance()) + _peerVerificationEnabled(false), + _logger(LogFactory::getInstance()) { int r = gnutls_certificate_allocate_credentials(&_certCred); if(r == GNUTLS_E_SUCCESS) { _good = true; gnutls_certificate_set_verify_flags(_certCred, - GNUTLS_VERIFY_ALLOW_X509_V1_CA_CRT); + GNUTLS_VERIFY_ALLOW_X509_V1_CA_CRT); } else { _good =false; _logger->error("gnutls_certificate_allocate_credentials() failed." - " Cause: %s", gnutls_strerror(r)); + " Cause: %s", gnutls_strerror(r)); } } @@ -79,21 +79,21 @@ bool TLSContext::bad() const } bool TLSContext::addClientKeyFile(const std::string& certfile, - const std::string& keyfile) + const std::string& keyfile) { int ret = gnutls_certificate_set_x509_key_file(_certCred, - certfile.c_str(), - keyfile.c_str(), - GNUTLS_X509_FMT_PEM); + certfile.c_str(), + keyfile.c_str(), + GNUTLS_X509_FMT_PEM); if(ret == GNUTLS_E_SUCCESS) { _logger->info("Client Key File(cert=%s, key=%s) were successfully added.", - certfile.c_str(), keyfile.c_str()); + certfile.c_str(), keyfile.c_str()); return true; } else { _logger->error("Failed to load client certificate from %s and" - " private key from %s. Cause: %s", - certfile.c_str(), keyfile.c_str(), - gnutls_strerror(ret)); + " private key from %s. Cause: %s", + certfile.c_str(), keyfile.c_str(), + gnutls_strerror(ret)); return false; } } @@ -101,11 +101,11 @@ bool TLSContext::addClientKeyFile(const std::string& certfile, bool TLSContext::addTrustedCACertFile(const std::string& certfile) { int ret = gnutls_certificate_set_x509_trust_file(_certCred, - certfile.c_str(), - GNUTLS_X509_FMT_PEM); + certfile.c_str(), + GNUTLS_X509_FMT_PEM); if(ret < 0) { _logger->error(MSG_LOADING_TRUSTED_CA_CERT_FAILED, - certfile.c_str(), gnutls_strerror(ret)); + certfile.c_str(), gnutls_strerror(ret)); return false; } else { _logger->info("%d certificate(s) were imported.", ret); diff --git a/src/LibgnutlsTLSContext.h b/src/LibgnutlsTLSContext.h index 66a56461..5eb8fa4d 100644 --- a/src/LibgnutlsTLSContext.h +++ b/src/LibgnutlsTLSContext.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -63,7 +63,7 @@ public: // private key `keyfile' must be decrypted. bool addClientKeyFile(const std::string& certfile, - const std::string& keyfile); + const std::string& keyfile); // certfile can contain multiple certificates. bool addTrustedCACertFile(const std::string& certfile); diff --git a/src/LibsslARC4Context.h b/src/LibsslARC4Context.h index f56793fa..ab36a034 100644 --- a/src/LibsslARC4Context.h +++ b/src/LibsslARC4Context.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -53,7 +53,7 @@ private: { throw DL_ABORT_EX (StringFormat("Exception in libssl routine(ARC4Context class): %s", - ERR_error_string(ERR_get_error(), 0)).str()); + ERR_error_string(ERR_get_error(), 0)).str()); } public: LibsslARC4Context():_cipherCtx(0) {} diff --git a/src/LibsslARC4Decryptor.h b/src/LibsslARC4Decryptor.h index 8db88181..a4522d4c 100644 --- a/src/LibsslARC4Decryptor.h +++ b/src/LibsslARC4Decryptor.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -54,7 +54,7 @@ private: { throw DL_ABORT_EX (StringFormat("Exception in libssl routine(ARC4Decryptor class): %s", - ERR_error_string(ERR_get_error(), 0)).str()); + ERR_error_string(ERR_get_error(), 0)).str()); } public: ARC4Decryptor() {} @@ -67,7 +67,7 @@ public: } void decrypt(unsigned char* out, size_t outLength, - const unsigned char* in, size_t inLength) + const unsigned char* in, size_t inLength) { int soutLength = outLength; if(!EVP_CipherUpdate(_ctx.getCipherContext(), out, &soutLength, in, inLength)) { diff --git a/src/LibsslARC4Encryptor.h b/src/LibsslARC4Encryptor.h index 438efe4d..b79feccc 100644 --- a/src/LibsslARC4Encryptor.h +++ b/src/LibsslARC4Encryptor.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -54,7 +54,7 @@ private: { throw DL_ABORT_EX (StringFormat("Exception in libssl routine(ARC4Encryptor class): %s", - ERR_error_string(ERR_get_error(), 0)).str()); + ERR_error_string(ERR_get_error(), 0)).str()); } public: ARC4Encryptor() {} @@ -67,7 +67,7 @@ public: } void encrypt(unsigned char* out, size_t outLength, - const unsigned char* in, size_t inLength) + const unsigned char* in, size_t inLength) { int soutLength = outLength; if(!EVP_CipherUpdate(_ctx.getCipherContext(), out, &soutLength, in, inLength)) { diff --git a/src/LibsslDHKeyExchange.h b/src/LibsslDHKeyExchange.h index c22001c3..62bea23c 100644 --- a/src/LibsslDHKeyExchange.h +++ b/src/LibsslDHKeyExchange.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -64,15 +64,15 @@ private: { throw DL_ABORT_EX (StringFormat("Exception in libssl routine %s(DHKeyExchange class): %s", - funName.c_str(), ERR_error_string(ERR_get_error(), 0)).str()); + funName.c_str(), ERR_error_string(ERR_get_error(), 0)).str()); } public: DHKeyExchange():_bnCtx(0), - _keyLength(0), - _prime(0), - _generator(0), - _privateKey(0), - _publicKey(0) {} + _keyLength(0), + _prime(0), + _generator(0), + _privateKey(0), + _publicKey(0) {} ~DHKeyExchange() { @@ -84,8 +84,8 @@ public: } void init(const unsigned char* prime, size_t primeBits, - const unsigned char* generator, - size_t privateKeyBits) + const unsigned char* generator, + size_t privateKeyBits) { BN_CTX_free(_bnCtx); _bnCtx = BN_CTX_new(); @@ -124,8 +124,8 @@ public: { if(outLength < _keyLength) { throw DL_ABORT_EX - (StringFormat("Insufficient buffer for public key. expect:%u, actual:%u", - _keyLength, outLength).str()); + (StringFormat("Insufficient buffer for public key. expect:%u, actual:%u", + _keyLength, outLength).str()); } memset(out, 0, outLength); size_t publicKeyBytes = BN_num_bytes(_publicKey); @@ -133,7 +133,7 @@ public: size_t nwritten = BN_bn2bin(_publicKey, out+offset); if(nwritten != publicKeyBytes) { throw DL_ABORT_EX - (StringFormat("BN_bn2bin in DHKeyExchange::getPublicKey, %u bytes written, but %u bytes expected.", nwritten, publicKeyBytes).str()); + (StringFormat("BN_bn2bin in DHKeyExchange::getPublicKey, %u bytes written, but %u bytes expected.", nwritten, publicKeyBytes).str()); } return nwritten; } @@ -146,13 +146,13 @@ public: } size_t computeSecret(unsigned char* out, size_t outLength, - const unsigned char* peerPublicKeyData, - size_t peerPublicKeyLength) const + const unsigned char* peerPublicKeyData, + size_t peerPublicKeyLength) const { if(outLength < _keyLength) { throw DL_ABORT_EX - (StringFormat("Insufficient buffer for secret. expect:%u, actual:%u", - _keyLength, outLength).str()); + (StringFormat("Insufficient buffer for secret. expect:%u, actual:%u", + _keyLength, outLength).str()); } @@ -172,7 +172,7 @@ public: BN_free(secret); if(nwritten != secretBytes) { throw DL_ABORT_EX - (StringFormat("BN_bn2bin in DHKeyExchange::getPublicKey, %u bytes written, but %u bytes expected.", nwritten, secretBytes).str()); + (StringFormat("BN_bn2bin in DHKeyExchange::getPublicKey, %u bytes written, but %u bytes expected.", nwritten, secretBytes).str()); } return nwritten; } diff --git a/src/LibsslTLSContext.cc b/src/LibsslTLSContext.cc index f0eb3366..12b62cc7 100644 --- a/src/LibsslTLSContext.cc +++ b/src/LibsslTLSContext.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -44,8 +44,8 @@ namespace aria2 { TLSContext::TLSContext():_sslCtx(0), - _peerVerificationEnabled(false), - _logger(LogFactory::getInstance()) + _peerVerificationEnabled(false), + _logger(LogFactory::getInstance()) { _sslCtx = SSL_CTX_new(SSLv23_client_method()); if(_sslCtx) { @@ -53,7 +53,7 @@ TLSContext::TLSContext():_sslCtx(0), } else { _good = false; _logger->error("SSL_CTX_new() failed. Cause: %s", - ERR_error_string(ERR_get_error(), 0)); + ERR_error_string(ERR_get_error(), 0)); } SSL_CTX_set_mode(_sslCtx, SSL_MODE_AUTO_RETRY); } @@ -74,21 +74,21 @@ bool TLSContext::bad() const } bool TLSContext::addClientKeyFile(const std::string& certfile, - const std::string& keyfile) + const std::string& keyfile) { if(SSL_CTX_use_PrivateKey_file(_sslCtx, keyfile.c_str(), - SSL_FILETYPE_PEM) != 1) { + SSL_FILETYPE_PEM) != 1) { _logger->error("Failed to load client private key from %s. Cause: %s", - keyfile.c_str(), ERR_error_string(ERR_get_error(), 0)); + keyfile.c_str(), ERR_error_string(ERR_get_error(), 0)); return false; } if(SSL_CTX_use_certificate_chain_file(_sslCtx, certfile.c_str()) != 1) { _logger->error("Failed to load client certificate from %s. Cause: %s", - certfile.c_str(), ERR_error_string(ERR_get_error(), 0)); + certfile.c_str(), ERR_error_string(ERR_get_error(), 0)); return false; } _logger->info("Client Key File(cert=%s, key=%s) were successfully added.", - certfile.c_str(), keyfile.c_str()); + certfile.c_str(), keyfile.c_str()); return true; } @@ -96,7 +96,7 @@ bool TLSContext::addTrustedCACertFile(const std::string& certfile) { if(SSL_CTX_load_verify_locations(_sslCtx, certfile.c_str(), 0) != 1) { _logger->error(MSG_LOADING_TRUSTED_CA_CERT_FAILED, - certfile.c_str(), ERR_error_string(ERR_get_error(), 0)); + certfile.c_str(), ERR_error_string(ERR_get_error(), 0)); return false; } else { _logger->info("Trusted CA certificates were successfully added."); diff --git a/src/LibsslTLSContext.h b/src/LibsslTLSContext.h index efcc19d5..260531f5 100644 --- a/src/LibsslTLSContext.h +++ b/src/LibsslTLSContext.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -63,7 +63,7 @@ public: // private key `keyfile' must be decrypted. bool addClientKeyFile(const std::string& certfile, - const std::string& keyfile); + const std::string& keyfile); // certfile can contain multiple certificates. bool addTrustedCACertFile(const std::string& certfile); diff --git a/src/LogFactory.cc b/src/LogFactory.cc index 13f104b7..d6e829b6 100644 --- a/src/LogFactory.cc +++ b/src/LogFactory.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/LogFactory.h b/src/LogFactory.h index cb71eaeb..4c57b739 100644 --- a/src/LogFactory.h +++ b/src/LogFactory.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/Logger.cc b/src/Logger.cc index 3d40d4e0..75c1f914 100644 --- a/src/Logger.cc +++ b/src/Logger.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/Logger.h b/src/Logger.h index fe141ffd..a3eb7849 100644 --- a/src/Logger.h +++ b/src/Logger.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -84,41 +84,41 @@ public: virtual ~Logger(); -#define WRITE_LOG(LEVEL, LEVEL_LABEL, MSG) \ - if(LEVEL >= _logLevel && _file.is_open()) { \ - va_list ap; \ - va_start(ap, MSG); \ - writeLog(_file, LEVEL, LEVEL_LABEL, MSG, ap); \ - va_end(ap); \ - _file << std::flush; \ - } \ - if(_stdoutField&LEVEL) { \ - std::cout << "\n"; \ - va_list ap; \ - va_start(ap, MSG); \ - writeLog(std::cout, LEVEL, LEVEL_LABEL, MSG, ap); \ - va_end(ap); \ - std::cout << std::flush; \ - } \ - -#define WRITE_LOG_EX(LEVEL, LEVEL_LABEL, MSG, EX) \ - if(LEVEL >= _logLevel && _file.is_open()) { \ - va_list ap; \ - va_start(ap, EX); \ - writeLog(_file, LEVEL, LEVEL_LABEL, MSG, ap); \ - va_end(ap); \ - writeStackTrace(_file, LEVEL, LEVEL_LABEL, EX); \ - _file << std::flush; \ - } \ - if(_stdoutField&LEVEL) { \ - std::cout << "\n"; \ - va_list ap; \ - va_start(ap, EX); \ - writeLog(std::cout, LEVEL, LEVEL_LABEL, MSG, ap); \ - va_end(ap); \ - writeStackTrace(std::cout, LEVEL, LEVEL_LABEL, EX); \ - std::cout << std::flush; \ - } \ +#define WRITE_LOG(LEVEL, LEVEL_LABEL, MSG) \ + if(LEVEL >= _logLevel && _file.is_open()) { \ + va_list ap; \ + va_start(ap, MSG); \ + writeLog(_file, LEVEL, LEVEL_LABEL, MSG, ap); \ + va_end(ap); \ + _file << std::flush; \ + } \ + if(_stdoutField&LEVEL) { \ + std::cout << "\n"; \ + va_list ap; \ + va_start(ap, MSG); \ + writeLog(std::cout, LEVEL, LEVEL_LABEL, MSG, ap); \ + va_end(ap); \ + std::cout << std::flush; \ + } \ + +#define WRITE_LOG_EX(LEVEL, LEVEL_LABEL, MSG, EX) \ + if(LEVEL >= _logLevel && _file.is_open()) { \ + va_list ap; \ + va_start(ap, EX); \ + writeLog(_file, LEVEL, LEVEL_LABEL, MSG, ap); \ + va_end(ap); \ + writeStackTrace(_file, LEVEL, LEVEL_LABEL, EX); \ + _file << std::flush; \ + } \ + if(_stdoutField&LEVEL) { \ + std::cout << "\n"; \ + va_list ap; \ + va_start(ap, EX); \ + writeLog(std::cout, LEVEL, LEVEL_LABEL, MSG, ap); \ + va_end(ap); \ + writeStackTrace(std::cout, LEVEL, LEVEL_LABEL, EX); \ + std::cout << std::flush; \ + } \ void debug(const char* msg, ...) { diff --git a/src/LongestSequencePieceSelector.cc b/src/LongestSequencePieceSelector.cc index 243175e9..bcbb9b8b 100644 --- a/src/LongestSequencePieceSelector.cc +++ b/src/LongestSequencePieceSelector.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/LongestSequencePieceSelector.h b/src/LongestSequencePieceSelector.h index d2284994..d6f68bf1 100644 --- a/src/LongestSequencePieceSelector.h +++ b/src/LongestSequencePieceSelector.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/MSEHandshake.cc b/src/MSEHandshake.cc index 0f293ae0..ae778d4a 100644 --- a/src/MSEHandshake.cc +++ b/src/MSEHandshake.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -65,8 +65,8 @@ const unsigned char* MSEHandshake::GENERATOR = reinterpret_cast<const unsigned c const unsigned char MSEHandshake::VC[] = { 0, 0, 0, 0, 0, 0, 0, 0 }; MSEHandshake::MSEHandshake(int32_t cuid, - const SocketHandle& socket, - const Option* op): + const SocketHandle& socket, + const Option* op): _cuid(cuid), _socket(socket), _option(op), @@ -133,7 +133,7 @@ bool MSEHandshake::sendPublicKey() size_t padLength = SimpleRandomizer::getInstance()->getRandomNumber(MAX_PAD_LENGTH+1); _dh->generateNonce(buffer+KEY_LENGTH, padLength); _socketBuffer.feedSendBuffer(std::string(&buffer[0], - &buffer[KEY_LENGTH+padLength])); + &buffer[KEY_LENGTH+padLength])); } _socketBuffer.send(); return _socketBuffer.sendBufferIsEmpty(); @@ -164,16 +164,16 @@ void MSEHandshake::initCipher(const unsigned char* infoHash) unsigned char localCipherKey[20]; MessageDigestHelper::digest(localCipherKey, sizeof(localCipherKey), - MessageDigestContext::SHA1, - s, sizeof(s)); + MessageDigestContext::SHA1, + s, sizeof(s)); _encryptor.reset(new ARC4Encryptor()); _encryptor->init(localCipherKey, sizeof(localCipherKey)); unsigned char peerCipherKey[20]; memcpy(s, _initiator?"keyB":"keyA", 4); MessageDigestHelper::digest(peerCipherKey, sizeof(peerCipherKey), - MessageDigestContext::SHA1, - s, sizeof(s)); + MessageDigestContext::SHA1, + s, sizeof(s)); _decryptor.reset(new ARC4Decryptor()); _decryptor->init(peerCipherKey, sizeof(peerCipherKey)); @@ -188,7 +188,7 @@ void MSEHandshake::initCipher(const unsigned char* infoHash) enc.init(peerCipherKey, sizeof(peerCipherKey)); // discard first 1024 bytes ARC4 output. enc.encrypt(to, 1024, from, 1024); - enc.encrypt(_initiatorVCMarker, sizeof(_initiatorVCMarker), VC, sizeof(VC)); + enc.encrypt(_initiatorVCMarker, sizeof(_initiatorVCMarker), VC, sizeof(VC)); } } @@ -213,7 +213,7 @@ void MSEHandshake::createReq1Hash(unsigned char* md) const memcpy(buffer, "req1", 4); memcpy(buffer+4, _secret, KEY_LENGTH); MessageDigestHelper::digest(md, 20, MessageDigestContext::SHA1, - buffer, 4+KEY_LENGTH); + buffer, 4+KEY_LENGTH); } void MSEHandshake::createReq23Hash(unsigned char* md, const unsigned char* infoHash) const @@ -223,14 +223,14 @@ void MSEHandshake::createReq23Hash(unsigned char* md, const unsigned char* infoH memcpy(x+4, infoHash, INFO_HASH_LENGTH); unsigned char xh[20]; MessageDigestHelper::digest(xh, sizeof(xh), MessageDigestContext::SHA1, - x, sizeof(x)); + x, sizeof(x)); unsigned char y[4+96]; memcpy(y, "req3", 4); memcpy(y+4, _secret, KEY_LENGTH); unsigned char yh[20]; MessageDigestHelper::digest(yh, sizeof(yh), MessageDigestContext::SHA1, - y, sizeof(y)); + y, sizeof(y)); for(size_t i = 0; i < 20; ++i) { md[i] = xh[i]^yh[i]; @@ -241,8 +241,8 @@ uint16_t MSEHandshake::decodeLength16(const unsigned char* buffer) { uint16_t be; _decryptor->decrypt(reinterpret_cast<unsigned char*>(&be), - sizeof(be), - buffer, sizeof(be)); + sizeof(be), + buffer, sizeof(be)); return ntohs(be); } @@ -272,7 +272,7 @@ bool MSEHandshake::sendInitiatorStep2() unsigned char cryptoProvide[CRYPTO_BITFIELD_LENGTH]; memset(cryptoProvide, 0, sizeof(cryptoProvide)); if(_option->get(PREF_BT_MIN_CRYPTO_LEVEL) == V_PLAIN) { - cryptoProvide[3] = CRYPTO_PLAIN_TEXT; + cryptoProvide[3] = CRYPTO_PLAIN_TEXT; } cryptoProvide[3] |= CRYPTO_ARC4; memcpy(buffer+VC_LENGTH, cryptoProvide, sizeof(cryptoProvide)); @@ -280,9 +280,9 @@ bool MSEHandshake::sendInitiatorStep2() // len(padC) uint16_t padCLength = SimpleRandomizer::getInstance()->getRandomNumber(MAX_PAD_LENGTH+1); { - uint16_t padCLengthBE = htons(padCLength); - memcpy(buffer+VC_LENGTH+CRYPTO_BITFIELD_LENGTH, &padCLengthBE, - sizeof(padCLengthBE)); + uint16_t padCLengthBE = htons(padCLength); + memcpy(buffer+VC_LENGTH+CRYPTO_BITFIELD_LENGTH, &padCLengthBE, + sizeof(padCLengthBE)); } // padC memset(buffer+VC_LENGTH+CRYPTO_BITFIELD_LENGTH+2, 0, padCLength); @@ -290,12 +290,12 @@ bool MSEHandshake::sendInitiatorStep2() // currently, IA is zero-length. uint16_t iaLength = 0; { - uint16_t iaLengthBE = htons(iaLength); - memcpy(buffer+VC_LENGTH+CRYPTO_BITFIELD_LENGTH+2+padCLength, - &iaLengthBE,sizeof(iaLengthBE)); + uint16_t iaLengthBE = htons(iaLength); + memcpy(buffer+VC_LENGTH+CRYPTO_BITFIELD_LENGTH+2+padCLength, + &iaLengthBE,sizeof(iaLengthBE)); } encryptAndSendData(buffer, - VC_LENGTH+CRYPTO_BITFIELD_LENGTH+2+padCLength+2); + VC_LENGTH+CRYPTO_BITFIELD_LENGTH+2+padCLength+2); } } _socketBuffer.send(); @@ -323,11 +323,11 @@ bool MSEHandshake::findInitiatorVCMarker() std::string vc(&_initiatorVCMarker[0], &_initiatorVCMarker[VC_LENGTH]); if((_markerIndex = buf.find(vc)) == std::string::npos) { if(616-KEY_LENGTH <= _rbufLength+r) { - throw DL_ABORT_EX("Failed to find VC marker."); + throw DL_ABORT_EX("Failed to find VC marker."); } else { - _socket->readData(_rbuf+_rbufLength, r); - _rbufLength += r; - return false; + _socket->readData(_rbuf+_rbufLength, r); + _rbufLength += r; + return false; } } } @@ -354,7 +354,7 @@ bool MSEHandshake::receiveInitiatorCryptoSelectAndPadDLength() { unsigned char cryptoSelect[CRYPTO_BITFIELD_LENGTH]; _decryptor->decrypt(cryptoSelect, sizeof(cryptoSelect), - rbufptr, sizeof(cryptoSelect)); + rbufptr, sizeof(cryptoSelect)); if(cryptoSelect[3]&CRYPTO_PLAIN_TEXT && _option->get(PREF_BT_MIN_CRYPTO_LEVEL) == V_PLAIN) { _logger->debug("CUID#%d - peer prefers plaintext.", _cuid); @@ -366,7 +366,7 @@ bool MSEHandshake::receiveInitiatorCryptoSelectAndPadDLength() } if(_negotiatedCryptoType == CRYPTO_NONE) { throw DL_ABORT_EX - (StringFormat("CUID#%d - No supported crypto type selected.", _cuid).str()); + (StringFormat("CUID#%d - No supported crypto type selected.", _cuid).str()); } } // padD length @@ -415,11 +415,11 @@ bool MSEHandshake::findReceiverHashMarker() std::string req1(&md[0], &md[sizeof(md)]); if((_markerIndex = buf.find(req1)) == std::string::npos) { if(628-KEY_LENGTH <= _rbufLength+r) { - throw DL_ABORT_EX("Failed to find hash marker."); + throw DL_ABORT_EX("Failed to find hash marker."); } else { - _socket->readData(_rbuf+_rbufLength, r); - _rbufLength += r; - return false; + _socket->readData(_rbuf+_rbufLength, r); + _rbufLength += r; + return false; } } } @@ -447,13 +447,13 @@ bool MSEHandshake::receiveReceiverHashAndPadCLength unsigned char* rbufptr = _rbuf; SharedHandle<DownloadContext> downloadContext; for(std::deque<SharedHandle<DownloadContext> >::const_iterator i = - downloadContexts.begin(); i != downloadContexts.end(); ++i) { + downloadContexts.begin(); i != downloadContexts.end(); ++i) { unsigned char md[20]; const BDE& torrentAttrs = (*i)->getAttribute(bittorrent::BITTORRENT); 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; } @@ -470,7 +470,7 @@ bool MSEHandshake::receiveReceiverHashAndPadCLength { unsigned char cryptoProvide[CRYPTO_BITFIELD_LENGTH]; _decryptor->decrypt(cryptoProvide, sizeof(cryptoProvide), - rbufptr, sizeof(cryptoProvide)); + rbufptr, sizeof(cryptoProvide)); // TODO choose the crypto type based on the preference. // For now, choose ARC4. if(cryptoProvide[3]&CRYPTO_PLAIN_TEXT && @@ -483,7 +483,7 @@ bool MSEHandshake::receiveReceiverHashAndPadCLength } if(_negotiatedCryptoType == CRYPTO_NONE) { throw DL_ABORT_EX - (StringFormat("CUID#%d - No supported crypto type provided.", _cuid).str()); + (StringFormat("CUID#%d - No supported crypto type provided.", _cuid).str()); } } // decrypt PadC length @@ -547,7 +547,7 @@ bool MSEHandshake::sendReceiverStep2() { uint16_t padDLengthBE = htons(padDLength); memcpy(buffer+VC_LENGTH+CRYPTO_BITFIELD_LENGTH, &padDLengthBE, - sizeof(padDLengthBE)); + sizeof(padDLengthBE)); } // padD, all zeroed memset(buffer+VC_LENGTH+CRYPTO_BITFIELD_LENGTH+2, 0, padDLength); diff --git a/src/MSEHandshake.h b/src/MSEHandshake.h index 14ef0ad3..6e5075b7 100644 --- a/src/MSEHandshake.h +++ b/src/MSEHandshake.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -123,7 +123,7 @@ private: } uint16_t verifyPadLength(const unsigned char* padlenbuf, - const char* padName); + const char* padName); void verifyVC(const unsigned char* vcbuf); @@ -133,7 +133,7 @@ private: public: MSEHandshake(int32_t cuid, const SharedHandle<SocketCore>& socket, - const Option* op); + const Option* op); ~MSEHandshake(); diff --git a/src/MemoryBufferPreDownloadHandler.cc b/src/MemoryBufferPreDownloadHandler.cc index a9c24be8..bdf60bf8 100644 --- a/src/MemoryBufferPreDownloadHandler.cc +++ b/src/MemoryBufferPreDownloadHandler.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/MemoryBufferPreDownloadHandler.h b/src/MemoryBufferPreDownloadHandler.h index 32cd32eb..c23d156b 100644 --- a/src/MemoryBufferPreDownloadHandler.h +++ b/src/MemoryBufferPreDownloadHandler.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/MessageDigestHelper.cc b/src/MessageDigestHelper.cc index fed76e34..b27bee29 100644 --- a/src/MessageDigestHelper.cc +++ b/src/MessageDigestHelper.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -61,17 +61,17 @@ void MessageDigestHelper::staticSHA1DigestFree() } std::string MessageDigestHelper::staticSHA1Digest(const BinaryStreamHandle& bs, - off_t offset, - uint64_t length) + off_t offset, + uint64_t length) { _sha1Ctx->digestReset(); return digest(_sha1Ctx, bs, offset, length); } std::string MessageDigestHelper::digest(const std::string& algo, - const BinaryStreamHandle& bs, - off_t offset, - uint64_t length) + const BinaryStreamHandle& bs, + off_t offset, + uint64_t length) { MessageDigestContext ctx; ctx.trySetAlgo(algo); @@ -80,8 +80,8 @@ std::string MessageDigestHelper::digest(const std::string& algo, } std::string MessageDigestHelper::digest(MessageDigestContext* ctx, - const SharedHandle<BinaryStream>& bs, - off_t offset, uint64_t length) + const SharedHandle<BinaryStream>& bs, + off_t offset, uint64_t length) { size_t BUFSIZE = 4096; unsigned char BUF[BUFSIZE]; @@ -92,7 +92,7 @@ std::string MessageDigestHelper::digest(MessageDigestContext* ctx, ssize_t readLength = bs->readData(BUF, BUFSIZE, offset); if((size_t)readLength != BUFSIZE) { throw DL_ABORT_EX - (StringFormat(EX_FILE_READ, "n/a", strerror(errno)).str()); + (StringFormat(EX_FILE_READ, "n/a", strerror(errno)).str()); } ctx->digestUpdate(BUF, readLength); offset += readLength; @@ -101,7 +101,7 @@ std::string MessageDigestHelper::digest(MessageDigestContext* ctx, ssize_t readLength = bs->readData(BUF, tail, offset); if((size_t)readLength != tail) { throw DL_ABORT_EX - (StringFormat(EX_FILE_READ, "n/a", strerror(errno)).str()); + (StringFormat(EX_FILE_READ, "n/a", strerror(errno)).str()); } ctx->digestUpdate(BUF, readLength); } @@ -127,12 +127,12 @@ std::string MessageDigestHelper::digest(const std::string& algo, const void* dat } void MessageDigestHelper::digest(unsigned char* md, size_t mdLength, - const std::string& algo, const void* data, size_t length) + const std::string& algo, const void* data, size_t length) { if(mdLength < MessageDigestContext::digestLength(algo)) { throw DL_ABORT_EX (StringFormat("Insufficient space for storing message digest: %d required, but only %d is allocated", - MessageDigestContext::digestLength(algo), mdLength).str()); + MessageDigestContext::digestLength(algo), mdLength).str()); } MessageDigestContext ctx; ctx.trySetAlgo(algo); diff --git a/src/MessageDigestHelper.h b/src/MessageDigestHelper.h index 4bf81ac6..612868e0 100644 --- a/src/MessageDigestHelper.h +++ b/src/MessageDigestHelper.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -76,14 +76,14 @@ public: static void staticSHA1DigestFree(); static std::string staticSHA1Digest(const SharedHandle<BinaryStream>& bs, - off_t offset, uint64_t length); + off_t offset, uint64_t length); /** * ctx must be initialized or reseted before calling this function. */ static std::string digest(MessageDigestContext* ctx, - const SharedHandle<BinaryStream>& bs, - off_t offset, uint64_t length); + const SharedHandle<BinaryStream>& bs, + off_t offset, uint64_t length); /** * Calculates message digest of file denoted by filename. @@ -97,7 +97,7 @@ public: * Throws exception when mdLength is less than the size of message digest. */ static void digest(unsigned char* md, size_t mdLength, - const std::string& algo, const void* data, size_t length); + const std::string& algo, const void* data, size_t length); }; } // namespace aria2 diff --git a/src/Metalink2RequestGroup.cc b/src/Metalink2RequestGroup.cc index ae930749..8ecf109e 100644 --- a/src/Metalink2RequestGroup.cc +++ b/src/Metalink2RequestGroup.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -102,8 +102,8 @@ public: void Metalink2RequestGroup::generate(std::deque<SharedHandle<RequestGroup> >& groups, - const std::string& metalinkFile, - const SharedHandle<Option>& option) + const std::string& metalinkFile, + const SharedHandle<Option>& option) { std::deque<SharedHandle<MetalinkEntry> > entries; MetalinkHelper::parseAndQuery(entries, metalinkFile, option.get()); @@ -112,8 +112,8 @@ Metalink2RequestGroup::generate(std::deque<SharedHandle<RequestGroup> >& groups, void Metalink2RequestGroup::generate(std::deque<SharedHandle<RequestGroup> >& groups, - const SharedHandle<BinaryStream>& binaryStream, - const SharedHandle<Option>& option) + const SharedHandle<BinaryStream>& binaryStream, + const SharedHandle<Option>& option) { std::deque<SharedHandle<MetalinkEntry> > entries; MetalinkHelper::parseAndQuery(entries, binaryStream, option.get()); @@ -145,7 +145,7 @@ Metalink2RequestGroup::createRequestGroup if(option->defined(PREF_METALINK_LOCATION)) { std::deque<std::string> locations; util::split(option->get(PREF_METALINK_LOCATION), - std::back_inserter(locations), ",", true); + std::back_inserter(locations), ",", true); entry->setLocationPreference(locations, 100); } if(option->get(PREF_METALINK_PREFERRED_PROTOCOL) != V_NONE) { @@ -153,8 +153,8 @@ Metalink2RequestGroup::createRequestGroup } if(useIndex) { if(std::find(selectIndexes.begin(), selectIndexes.end(), count+1) == - selectIndexes.end()) { - continue; + selectIndexes.end()) { + continue; } } entry->dropUnsupportedResource(); @@ -172,35 +172,35 @@ Metalink2RequestGroup::createRequestGroup std::deque<std::string> uris; uris.push_back((*itr)->url); { - std::deque<SharedHandle<RequestGroup> > result; - createRequestGroupForUri(result, option, uris, - /* ignoreForceSequential = */true, - /* ignoreLocalPath = */true); - if(!uris.empty()) { - torrentRg = result[0]; - } + std::deque<SharedHandle<RequestGroup> > result; + createRequestGroupForUri(result, option, uris, + /* ignoreForceSequential = */true, + /* ignoreLocalPath = */true); + if(!uris.empty()) { + torrentRg = result[0]; + } } if(!torrentRg.isNull()) { - torrentRg->setNumConcurrentCommand(1); - torrentRg->clearPreDownloadHandler(); - torrentRg->clearPostDownloadHandler(); - // remove "metalink" from Accept Type list to avoid loop in - // tranparent metalink - torrentRg->removeAcceptType(RequestGroup::ACCEPT_METALINK); - // make it in-memory download - SharedHandle<PreDownloadHandler> preh - (new MemoryBufferPreDownloadHandler()); - SharedHandle<RequestGroupCriteria> cri(new TrueRequestGroupCriteria()); - preh->setCriteria(cri); - torrentRg->addPreDownloadHandler(preh); - groups.push_back(torrentRg); + torrentRg->setNumConcurrentCommand(1); + torrentRg->clearPreDownloadHandler(); + torrentRg->clearPostDownloadHandler(); + // remove "metalink" from Accept Type list to avoid loop in + // tranparent metalink + torrentRg->removeAcceptType(RequestGroup::ACCEPT_METALINK); + // make it in-memory download + SharedHandle<PreDownloadHandler> preh + (new MemoryBufferPreDownloadHandler()); + SharedHandle<RequestGroupCriteria> cri(new TrueRequestGroupCriteria()); + preh->setCriteria(cri); + torrentRg->addPreDownloadHandler(preh); + groups.push_back(torrentRg); } } #endif // ENABLE_BITTORRENT entry->reorderResourcesByPreference(); std::deque<std::string> uris; std::for_each(entry->resources.begin(), entry->resources.end(), - AccumulateNonP2PUrl(uris)); + AccumulateNonP2PUrl(uris)); SharedHandle<RequestGroup> rg(new RequestGroup(option)); // If piece hash is specified in the metalink, // make segment size equal to piece hash size. @@ -217,8 +217,8 @@ Metalink2RequestGroup::createRequestGroup SharedHandle<DownloadContext> dctx (new DownloadContext (pieceLength, - entry->getLength(), - strconcat(option->get(PREF_DIR), "/", entry->file->getPath()))); + entry->getLength(), + strconcat(option->get(PREF_DIR), "/", entry->file->getPath()))); dctx->setDir(option->get(PREF_DIR)); dctx->getFirstFileEntry()->setUris(uris); if(option->getAsBool(PREF_METALINK_ENABLE_UNIQUE_PROTOCOL)) { @@ -227,12 +227,12 @@ Metalink2RequestGroup::createRequestGroup #ifdef ENABLE_MESSAGE_DIGEST if(entry->chunkChecksum.isNull()) { if(!entry->checksum.isNull()) { - dctx->setChecksum(entry->checksum->getMessageDigest()); - dctx->setChecksumHashAlgo(entry->checksum->getAlgo()); + dctx->setChecksum(entry->checksum->getMessageDigest()); + dctx->setChecksumHashAlgo(entry->checksum->getAlgo()); } } else { dctx->setPieceHashes(entry->chunkChecksum->getChecksums().begin(), - entry->chunkChecksum->getChecksums().end()); + entry->chunkChecksum->getChecksums().end()); dctx->setPieceHashAlgo(entry->chunkChecksum->getAlgo()); } #endif // ENABLE_MESSAGE_DIGEST @@ -242,7 +242,7 @@ Metalink2RequestGroup::createRequestGroup (entry->maxConnections < 0 ? option->getAsInt(PREF_METALINK_SERVERS) : std::min(option->getAsInt(PREF_METALINK_SERVERS), - static_cast<int32_t>(entry->maxConnections))); + static_cast<int32_t>(entry->maxConnections))); // remove "metalink" from Accept Type list to avoid loop in tranparent // metalink rg->removeAcceptType(RequestGroup::ACCEPT_METALINK); diff --git a/src/Metalink2RequestGroup.h b/src/Metalink2RequestGroup.h index 4836d85a..cacbb333 100644 --- a/src/Metalink2RequestGroup.h +++ b/src/Metalink2RequestGroup.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -54,18 +54,18 @@ private: void createRequestGroup(std::deque<SharedHandle<RequestGroup> >& groups, - std::deque<SharedHandle<MetalinkEntry> > entries, - const SharedHandle<Option>& option); + std::deque<SharedHandle<MetalinkEntry> > entries, + const SharedHandle<Option>& option); public: Metalink2RequestGroup(); void generate(std::deque<SharedHandle<RequestGroup> >& groups, - const std::string& metalinkFile, - const SharedHandle<Option>& option); + const std::string& metalinkFile, + const SharedHandle<Option>& option); void generate(std::deque<SharedHandle<RequestGroup> >& groups, - const SharedHandle<BinaryStream>& binaryStream, - const SharedHandle<Option>& option); + const SharedHandle<BinaryStream>& binaryStream, + const SharedHandle<Option>& option); }; } // namespace aria2 diff --git a/src/MetalinkEntry.cc b/src/MetalinkEntry.cc index af8dfb0a..40b73fab 100644 --- a/src/MetalinkEntry.cc +++ b/src/MetalinkEntry.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -103,10 +103,10 @@ uint64_t MetalinkEntry::getLength() const } void MetalinkEntry::setLocationPreference(const std::deque<std::string>& locations, - int preferenceToAdd) + int preferenceToAdd) { std::for_each(resources.begin(), resources.end(), - AddLocationPreference(locations, preferenceToAdd)); + AddLocationPreference(locations, preferenceToAdd)); } class AddProtocolPreference { @@ -126,23 +126,23 @@ public: }; void MetalinkEntry::setProtocolPreference(const std::string& protocol, - int preferenceToAdd) + int preferenceToAdd) { std::for_each(resources.begin(), resources.end(), - AddProtocolPreference(protocol, preferenceToAdd)); + AddProtocolPreference(protocol, preferenceToAdd)); } class PrefOrder { public: bool operator()(const SharedHandle<MetalinkResource>& res1, - const SharedHandle<MetalinkResource>& res2) { + const SharedHandle<MetalinkResource>& res2) { return res1->preference > res2->preference; } }; void MetalinkEntry::reorderResourcesByPreference() { std::random_shuffle(resources.begin(), resources.end(), - *(SimpleRandomizer::getInstance().get())); + *(SimpleRandomizer::getInstance().get())); std::sort(resources.begin(), resources.end(), PrefOrder()); } @@ -168,8 +168,8 @@ public: void MetalinkEntry::dropUnsupportedResource() { resources.erase(std::remove_if(resources.begin(), resources.end(), - std::not1(Supported())), - resources.end()); + std::not1(Supported())), + resources.end()); } void MetalinkEntry::toFileEntry @@ -177,8 +177,8 @@ void MetalinkEntry::toFileEntry const std::deque<SharedHandle<MetalinkEntry> >& metalinkEntries) { std::transform(metalinkEntries.begin(), metalinkEntries.end(), - std::back_inserter(fileEntries), - mem_fun_sh(&MetalinkEntry::getFile)); + std::back_inserter(fileEntries), + mem_fun_sh(&MetalinkEntry::getFile)); } void MetalinkEntry::setSignature(const SharedHandle<Signature>& signature) diff --git a/src/MetalinkEntry.h b/src/MetalinkEntry.h index 042747ff..866d3ec3 100644 --- a/src/MetalinkEntry.h +++ b/src/MetalinkEntry.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/MetalinkHelper.cc b/src/MetalinkHelper.cc index fba4625e..c26d1d03 100644 --- a/src/MetalinkHelper.cc +++ b/src/MetalinkHelper.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -74,9 +74,9 @@ void MetalinkHelper::query throw DL_ABORT_EX("No file entry found. Probably, the metalink file is not configured properly or broken."); } metalinker->queryEntry(result, - option->get(PREF_METALINK_VERSION), - option->get(PREF_METALINK_LANGUAGE), - option->get(PREF_METALINK_OS)); + option->get(PREF_METALINK_VERSION), + option->get(PREF_METALINK_LANGUAGE), + option->get(PREF_METALINK_OS)); } } // namespace aria2 diff --git a/src/MetalinkHelper.h b/src/MetalinkHelper.h index 73a77d53..0b329576 100644 --- a/src/MetalinkHelper.h +++ b/src/MetalinkHelper.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/MetalinkParserController.cc b/src/MetalinkParserController.cc index 5d154c34..e6309b3e 100644 --- a/src/MetalinkParserController.cc +++ b/src/MetalinkParserController.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -370,7 +370,7 @@ void MetalinkParserController::commitChunkChecksumTransaction() std::sort(_tempChunkChecksums.begin(), _tempChunkChecksums.end(), Ascend1st<std::pair<size_t, std::string> >()); std::deque<std::string> checksums; std::transform(_tempChunkChecksums.begin(), _tempChunkChecksums.end(), - std::back_inserter(checksums), select2nd<std::pair<size_t, std::string> >()); + std::back_inserter(checksums), select2nd<std::pair<size_t, std::string> >()); _tChunkChecksum->setChecksums(checksums); _tEntry->chunkChecksum = _tChunkChecksum; } diff --git a/src/MetalinkParserController.h b/src/MetalinkParserController.h index 7811be23..78343cde 100644 --- a/src/MetalinkParserController.h +++ b/src/MetalinkParserController.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/MetalinkParserState.h b/src/MetalinkParserState.h index eb9f94b1..ecb0b285 100644 --- a/src/MetalinkParserState.h +++ b/src/MetalinkParserState.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/MetalinkParserStateImpl.cc b/src/MetalinkParserStateImpl.cc index 27d0ff5c..e1c53e85 100644 --- a/src/MetalinkParserStateImpl.cc +++ b/src/MetalinkParserStateImpl.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -126,15 +126,15 @@ void FileMetalinkParserState::beginElement int maxConnections; { std::map<std::string, std::string>::const_iterator itr = - attrs.find(MAXCONNECTIONS); + attrs.find(MAXCONNECTIONS); if(itr == attrs.end()) { - maxConnections = -1; + maxConnections = -1; } else { - try { - maxConnections = util::parseInt((*itr).second); - } catch(RecoverableException& e) { - maxConnections = -1; - } + try { + maxConnections = util::parseInt((*itr).second); + } catch(RecoverableException& e) { + maxConnections = -1; + } } } stm->setMaxConnectionsOfEntry(maxConnections); @@ -240,23 +240,23 @@ void VerificationMetalinkParserState::beginElement try { size_t length; { - std::map<std::string, std::string>::const_iterator itr = - attrs.find(LENGTH); - if(itr == attrs.end()) { - return; - } else { - length = util::parseInt((*itr).second); - } + std::map<std::string, std::string>::const_iterator itr = + attrs.find(LENGTH); + if(itr == attrs.end()) { + return; + } else { + length = util::parseInt((*itr).second); + } } std::string type; { - std::map<std::string, std::string>::const_iterator itr = - attrs.find(TYPE); - if(itr == attrs.end()) { - return; - } else { - type = (*itr).second; - } + std::map<std::string, std::string>::const_iterator itr = + attrs.find(TYPE); + if(itr == attrs.end()) { + return; + } else { + type = (*itr).second; + } } stm->newChunkChecksumTransaction(); stm->setLengthOfChunkChecksum(length); @@ -266,23 +266,23 @@ void VerificationMetalinkParserState::beginElement } } else #endif // ENABLE_MESSAGE_DIGEST - if(name == SIGNATURE) { - stm->setSignatureState(); - std::map<std::string, std::string>::const_iterator itr = attrs.find(TYPE); - if(itr == attrs.end()) { - return; - } else { - stm->newSignatureTransaction(); - stm->setTypeOfSignature((*itr).second); + if(name == SIGNATURE) { + stm->setSignatureState(); + std::map<std::string, std::string>::const_iterator itr = attrs.find(TYPE); + if(itr == attrs.end()) { + return; + } else { + stm->newSignatureTransaction(); + stm->setTypeOfSignature((*itr).second); - std::map<std::string, std::string>::const_iterator itr = attrs.find(FILE); - if(itr != attrs.end()) { - stm->setFileOfSignature((*itr).second); + std::map<std::string, std::string>::const_iterator itr = attrs.find(FILE); + if(itr != attrs.end()) { + stm->setFileOfSignature((*itr).second); + } } + } else { + stm->setSkipTagState(); } - } else { - stm->setSkipTagState(); - } } void HashMetalinkParserState::beginElement @@ -314,9 +314,9 @@ void PiecesMetalinkParserState::beginElement stm->cancelChunkChecksumTransaction(); } else { try { - stm->createNewHashOfChunkChecksum(util::parseInt((*itr).second)); + stm->createNewHashOfChunkChecksum(util::parseInt((*itr).second)); } catch(RecoverableException& e) { - stm->cancelChunkChecksumTransaction(); + stm->cancelChunkChecksumTransaction(); } } } else { @@ -377,45 +377,45 @@ void ResourcesMetalinkParserState::beginElement { std::map<std::string, std::string>::const_iterator itr = attrs.find(TYPE); if(itr == attrs.end()) { - return; + return; } else { - type = (*itr).second; + type = (*itr).second; } } std::string location; { std::map<std::string, std::string>::const_iterator itr = - attrs.find(LOCATION); + attrs.find(LOCATION); if(itr != attrs.end()) { - location = util::toUpper((*itr).second); + location = util::toUpper((*itr).second); } } int preference; { std::map<std::string, std::string>::const_iterator itr = - attrs.find(PREFERENCE); + attrs.find(PREFERENCE); if(itr == attrs.end()) { - preference = 0; + preference = 0; } else { - try { - preference = util::parseInt((*itr).second); - } catch(RecoverableException& e) { - preference = 0; - } + try { + preference = util::parseInt((*itr).second); + } catch(RecoverableException& e) { + preference = 0; + } } } int maxConnections; { std::map<std::string, std::string>::const_iterator itr = - attrs.find(MAXCONNECTIONS); + attrs.find(MAXCONNECTIONS); if(itr == attrs.end()) { - maxConnections = -1; + maxConnections = -1; } else { - try { - maxConnections = util::parseInt((*itr).second); - } catch(RecoverableException& e) { - maxConnections = -1; - } + try { + maxConnections = util::parseInt((*itr).second); + } catch(RecoverableException& e) { + maxConnections = -1; + } } } stm->newResourceTransaction(); diff --git a/src/MetalinkParserStateImpl.h b/src/MetalinkParserStateImpl.h index f22f38de..747de7b1 100644 --- a/src/MetalinkParserStateImpl.h +++ b/src/MetalinkParserStateImpl.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -43,12 +43,12 @@ class InitialMetalinkParserState:public MetalinkParserState { public: virtual void beginElement(MetalinkParserStateMachine* stm, - const std::string& name, - const std::map<std::string, std::string>& attrs); + const std::string& name, + const std::map<std::string, std::string>& attrs); virtual void endElement(MetalinkParserStateMachine* stm, - const std::string& name, - const std::string& characters) {} + const std::string& name, + const std::string& characters) {} virtual bool needsCharactersBuffering() const { @@ -60,12 +60,12 @@ class MetalinkMetalinkParserState:public MetalinkParserState { public: virtual void beginElement(MetalinkParserStateMachine* stm, - const std::string& name, - const std::map<std::string, std::string>& attrs); + const std::string& name, + const std::map<std::string, std::string>& attrs); virtual void endElement(MetalinkParserStateMachine* stm, - const std::string& name, - const std::string& characters) {} + const std::string& name, + const std::string& characters) {} virtual bool needsCharactersBuffering() const { @@ -77,12 +77,12 @@ class FilesMetalinkParserState:public MetalinkParserState { public: virtual void beginElement(MetalinkParserStateMachine* stm, - const std::string& name, - const std::map<std::string, std::string>& attrs); + const std::string& name, + const std::map<std::string, std::string>& attrs); virtual void endElement(MetalinkParserStateMachine* stm, - const std::string& name, - const std::string& characters) {} + const std::string& name, + const std::string& characters) {} virtual bool needsCharactersBuffering() const { @@ -94,12 +94,12 @@ class FileMetalinkParserState:public MetalinkParserState { public: virtual void beginElement(MetalinkParserStateMachine* stm, - const std::string& name, - const std::map<std::string, std::string>& attrs); + const std::string& name, + const std::map<std::string, std::string>& attrs); virtual void endElement(MetalinkParserStateMachine* stm, - const std::string& name, - const std::string& characters); + const std::string& name, + const std::string& characters); virtual bool needsCharactersBuffering() const { @@ -111,12 +111,12 @@ class SizeMetalinkParserState:public MetalinkParserState { public: virtual void beginElement(MetalinkParserStateMachine* stm, - const std::string& name, - const std::map<std::string, std::string>& attrs); + const std::string& name, + const std::map<std::string, std::string>& attrs); virtual void endElement(MetalinkParserStateMachine* stm, - const std::string& name, - const std::string& characters); + const std::string& name, + const std::string& characters); virtual bool needsCharactersBuffering() const { @@ -128,12 +128,12 @@ class VersionMetalinkParserState:public MetalinkParserState { public: virtual void beginElement(MetalinkParserStateMachine* stm, - const std::string& name, - const std::map<std::string, std::string>& attrs); + const std::string& name, + const std::map<std::string, std::string>& attrs); virtual void endElement(MetalinkParserStateMachine* stm, - const std::string& name, - const std::string& characters); + const std::string& name, + const std::string& characters); virtual bool needsCharactersBuffering() const { @@ -145,12 +145,12 @@ class LanguageMetalinkParserState:public MetalinkParserState { public: virtual void beginElement(MetalinkParserStateMachine* stm, - const std::string& name, - const std::map<std::string, std::string>& attrs); + const std::string& name, + const std::map<std::string, std::string>& attrs); virtual void endElement(MetalinkParserStateMachine* stm, - const std::string& name, - const std::string& characters); + const std::string& name, + const std::string& characters); virtual bool needsCharactersBuffering() const { @@ -162,12 +162,12 @@ class OSMetalinkParserState:public MetalinkParserState { public: virtual void beginElement(MetalinkParserStateMachine* stm, - const std::string& name, - const std::map<std::string, std::string>& attrs); + const std::string& name, + const std::map<std::string, std::string>& attrs); virtual void endElement(MetalinkParserStateMachine* stm, - const std::string& name, - const std::string& characters); + const std::string& name, + const std::string& characters); virtual bool needsCharactersBuffering() const { @@ -179,12 +179,12 @@ class VerificationMetalinkParserState:public MetalinkParserState { public: virtual void beginElement(MetalinkParserStateMachine* stm, - const std::string& name, - const std::map<std::string, std::string>& attrs); + const std::string& name, + const std::map<std::string, std::string>& attrs); virtual void endElement(MetalinkParserStateMachine* stm, - const std::string& name, - const std::string& characters) {} + const std::string& name, + const std::string& characters) {} virtual bool needsCharactersBuffering() const { @@ -196,12 +196,12 @@ class HashMetalinkParserState:public MetalinkParserState { public: virtual void beginElement(MetalinkParserStateMachine* stm, - const std::string& name, - const std::map<std::string, std::string>& attrs); + const std::string& name, + const std::map<std::string, std::string>& attrs); virtual void endElement(MetalinkParserStateMachine* stm, - const std::string& name, - const std::string& characters); + const std::string& name, + const std::string& characters); virtual bool needsCharactersBuffering() const { @@ -213,12 +213,12 @@ class PiecesMetalinkParserState:public MetalinkParserState { public: virtual void beginElement(MetalinkParserStateMachine* stm, - const std::string& name, - const std::map<std::string, std::string>& attrs); + const std::string& name, + const std::map<std::string, std::string>& attrs); virtual void endElement(MetalinkParserStateMachine* stm, - const std::string& name, - const std::string& characters); + const std::string& name, + const std::string& characters); virtual bool needsCharactersBuffering() const { @@ -230,12 +230,12 @@ class PieceHashMetalinkParserState:public MetalinkParserState { public: virtual void beginElement(MetalinkParserStateMachine* stm, - const std::string& name, - const std::map<std::string, std::string>& attrs); + const std::string& name, + const std::map<std::string, std::string>& attrs); virtual void endElement(MetalinkParserStateMachine* stm, - const std::string& name, - const std::string& characters); + const std::string& name, + const std::string& characters); virtual bool needsCharactersBuffering() const { @@ -247,12 +247,12 @@ class SignatureMetalinkParserState:public MetalinkParserState { public: virtual void beginElement(MetalinkParserStateMachine* stm, - const std::string& name, const std::map<std::string, - std::string>& attrs); + const std::string& name, const std::map<std::string, + std::string>& attrs); virtual void endElement(MetalinkParserStateMachine* stm, - const std::string& name, - const std::string& characters); + const std::string& name, + const std::string& characters); virtual bool needsCharactersBuffering() const { @@ -264,12 +264,12 @@ class ResourcesMetalinkParserState:public MetalinkParserState { public: virtual void beginElement(MetalinkParserStateMachine* stm, - const std::string& name, - const std::map<std::string, std::string>& attrs); + const std::string& name, + const std::map<std::string, std::string>& attrs); virtual void endElement(MetalinkParserStateMachine* stm, - const std::string& name, - const std::string& characters) {} + const std::string& name, + const std::string& characters) {} virtual bool needsCharactersBuffering() const { @@ -281,12 +281,12 @@ class URLMetalinkParserState:public MetalinkParserState { public: virtual void beginElement(MetalinkParserStateMachine* stm, - const std::string& name, - const std::map<std::string, std::string>& attrs); + const std::string& name, + const std::map<std::string, std::string>& attrs); virtual void endElement(MetalinkParserStateMachine* stm, - const std::string& name, - const std::string& characters); + const std::string& name, + const std::string& characters); virtual bool needsCharactersBuffering() const { @@ -298,12 +298,12 @@ class SkipTagMetalinkParserState:public MetalinkParserState { public: virtual void beginElement(MetalinkParserStateMachine* stm, - const std::string& name, - const std::map<std::string, std::string>& attrs); + const std::string& name, + const std::map<std::string, std::string>& attrs); virtual void endElement(MetalinkParserStateMachine* stm, - const std::string& name, - const std::string& characters) {} + const std::string& name, + const std::string& characters) {} virtual bool needsCharactersBuffering() const { diff --git a/src/MetalinkParserStateMachine.cc b/src/MetalinkParserStateMachine.cc index 7ebaa596..18f5adad 100644 --- a/src/MetalinkParserStateMachine.cc +++ b/src/MetalinkParserStateMachine.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/MetalinkParserStateMachine.h b/src/MetalinkParserStateMachine.h index 1b36a4ec..bac78d46 100644 --- a/src/MetalinkParserStateMachine.h +++ b/src/MetalinkParserStateMachine.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/MetalinkPostDownloadHandler.cc b/src/MetalinkPostDownloadHandler.cc index 3d185f79..0fc05e73 100644 --- a/src/MetalinkPostDownloadHandler.cc +++ b/src/MetalinkPostDownloadHandler.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -65,7 +65,7 @@ void MetalinkPostDownloadHandler::getNextRequestGroups RequestGroup* requestGroup) { _logger->debug("Generating RequestGroups for Metalink file %s", - requestGroup->getFirstFilePath().c_str()); + requestGroup->getFirstFilePath().c_str()); SharedHandle<DiskAdaptor> diskAdaptor = requestGroup->getPieceStorage()->getDiskAdaptor(); try { @@ -73,7 +73,7 @@ void MetalinkPostDownloadHandler::getNextRequestGroups //requestOption.put(PREF_DIR, requestGroup->getDownloadContext()->getDir()); std::deque<SharedHandle<RequestGroup> > newRgs; Metalink2RequestGroup().generate(newRgs, diskAdaptor, - requestGroup->getOption()); + requestGroup->getOption()); requestGroup->followedBy(newRgs.begin(), newRgs.end()); groups.insert(groups.end(), newRgs.begin(), newRgs.end()); diskAdaptor->closeFile(); diff --git a/src/MetalinkPostDownloadHandler.h b/src/MetalinkPostDownloadHandler.h index 00566e30..a3fdc8a8 100644 --- a/src/MetalinkPostDownloadHandler.h +++ b/src/MetalinkPostDownloadHandler.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -48,7 +48,7 @@ public: virtual void getNextRequestGroups(std::deque<SharedHandle<RequestGroup> >& groups, - RequestGroup* requestGroup); + RequestGroup* requestGroup); }; typedef SharedHandle<MetalinkPostDownloadHandler> MetalinkPostDownloadHandlerHandle; diff --git a/src/MetalinkProcessor.h b/src/MetalinkProcessor.h index 8d4a7617..f6dabb9d 100644 --- a/src/MetalinkProcessor.h +++ b/src/MetalinkProcessor.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/MetalinkResource.cc b/src/MetalinkResource.cc index bacb4976..b600c7d6 100644 --- a/src/MetalinkResource.cc +++ b/src/MetalinkResource.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/MetalinkResource.h b/src/MetalinkResource.h index 889a5674..b6d1ba94 100644 --- a/src/MetalinkResource.h +++ b/src/MetalinkResource.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/Metalinker.cc b/src/Metalinker.cc index 371a5b9e..18c29ed0 100644 --- a/src/Metalinker.cc +++ b/src/Metalinker.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -49,8 +49,8 @@ private: std::string os; public: EntryQuery(const std::string& version, - const std::string& language, - const std::string& os): + const std::string& language, + const std::string& os): version(version), language(language), os(os) {} @@ -58,17 +58,17 @@ public: bool operator()(const SharedHandle<MetalinkEntry>& entry) const { if(!version.empty()) { if(version != entry->version) { - return false; + return false; } } if(!language.empty()) { if(language != entry->language) { - return false; + return false; } } if(!os.empty()) { if(os != entry->os) { - return false; + return false; } } return true; @@ -82,8 +82,8 @@ void Metalinker::queryEntry const std::string& os) const { std::remove_copy_if(entries.begin(), entries.end(), - std::back_inserter(queryResult), - std::not1(EntryQuery(version, language, os))); + std::back_inserter(queryResult), + std::not1(EntryQuery(version, language, os))); } } // namespace aria2 diff --git a/src/Metalinker.h b/src/Metalinker.h index 7d5414b4..9ef348ab 100644 --- a/src/Metalinker.h +++ b/src/Metalinker.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/MultiDiskAdaptor.cc b/src/MultiDiskAdaptor.cc index 1f6f41e4..3c3d6a7d 100644 --- a/src/MultiDiskAdaptor.cc +++ b/src/MultiDiskAdaptor.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -167,7 +167,7 @@ void MultiDiskAdaptor::resetDiskWriterEntries() } for(std::vector<SharedHandle<FileEntry> >::const_iterator i = - fileEntries.begin(); i != fileEntries.end(); ++i) { + fileEntries.begin(); i != fileEntries.end(); ++i) { diskWriterEntries.push_back (createDiskWriterEntry(*i, (*i)->isRequested())); } @@ -179,80 +179,80 @@ void MultiDiskAdaptor::resetDiskWriterEntries() std::vector<SharedHandle<DiskWriterEntry> >::iterator done = diskWriterEntries.begin(); for(std::vector<SharedHandle<DiskWriterEntry> >::iterator itr = - diskWriterEntries.begin(); itr != diskWriterEntries.end();) { + diskWriterEntries.begin(); itr != diskWriterEntries.end();) { const SharedHandle<FileEntry>& fileEntry = (*itr)->getFileEntry(); if(!fileEntry->isRequested()) { - ++itr; - continue; + ++itr; + continue; } off_t pieceStartOffset = - (fileEntry->getOffset()/pieceLength)*pieceLength; + (fileEntry->getOffset()/pieceLength)*pieceLength; if(itr != diskWriterEntries.begin()) { - for(std::vector<SharedHandle<DiskWriterEntry> >::iterator i = - itr-1; true; --i) { - const SharedHandle<FileEntry>& fileEntry = (*i)->getFileEntry(); - if(pieceStartOffset <= fileEntry->getOffset() || - (uint64_t)pieceStartOffset < - fileEntry->getOffset()+fileEntry->getLength()) { - (*i)->needsFileAllocation(true); - } else { - break; - } - if(i == done) { - break; - } - } + for(std::vector<SharedHandle<DiskWriterEntry> >::iterator i = + itr-1; true; --i) { + const SharedHandle<FileEntry>& fileEntry = (*i)->getFileEntry(); + if(pieceStartOffset <= fileEntry->getOffset() || + (uint64_t)pieceStartOffset < + fileEntry->getOffset()+fileEntry->getLength()) { + (*i)->needsFileAllocation(true); + } else { + break; + } + if(i == done) { + break; + } + } } if(fileEntry->getLength() > 0) { - off_t lastPieceStartOffset = - (fileEntry->getOffset()+fileEntry->getLength()-1)/pieceLength*pieceLength; - logger->debug("Checking adjacent backward file to %s" - " whose lastPieceStartOffset+pieceLength=%lld", - fileEntry->getPath().c_str(), - lastPieceStartOffset+pieceLength); - - ++itr; - // adjacent backward files are not needed to be allocated. They - // just requre DiskWriter - for(; itr != diskWriterEntries.end() && - (!(*itr)->getFileEntry()->isRequested() || - (*itr)->getFileEntry()->getLength() == 0); ++itr) { - logger->debug("file=%s, offset=%lld", - (*itr)->getFileEntry()->getPath().c_str(), - (*itr)->getFileEntry()->getOffset()); - - if((*itr)->getFileEntry()->getOffset() < - static_cast<off_t>(lastPieceStartOffset+pieceLength)) { - logger->debug("%s needs diskwriter", - (*itr)->getFileEntry()->getPath().c_str()); - dwreq[(*itr)->getFileEntry()->getPath()] = true; - } else { - break; - } - } - done = itr-1; + off_t lastPieceStartOffset = + (fileEntry->getOffset()+fileEntry->getLength()-1)/pieceLength*pieceLength; + logger->debug("Checking adjacent backward file to %s" + " whose lastPieceStartOffset+pieceLength=%lld", + fileEntry->getPath().c_str(), + lastPieceStartOffset+pieceLength); + + ++itr; + // adjacent backward files are not needed to be allocated. They + // just requre DiskWriter + for(; itr != diskWriterEntries.end() && + (!(*itr)->getFileEntry()->isRequested() || + (*itr)->getFileEntry()->getLength() == 0); ++itr) { + logger->debug("file=%s, offset=%lld", + (*itr)->getFileEntry()->getPath().c_str(), + (*itr)->getFileEntry()->getOffset()); + + if((*itr)->getFileEntry()->getOffset() < + static_cast<off_t>(lastPieceStartOffset+pieceLength)) { + logger->debug("%s needs diskwriter", + (*itr)->getFileEntry()->getPath().c_str()); + dwreq[(*itr)->getFileEntry()->getPath()] = true; + } else { + break; + } + } + done = itr-1; } else { - done = itr; - ++itr; + done = itr; + ++itr; } } } DefaultDiskWriterFactory dwFactory; for(std::vector<SharedHandle<DiskWriterEntry> >::iterator i = - diskWriterEntries.begin(); i != diskWriterEntries.end(); ++i) { + diskWriterEntries.begin(); i != diskWriterEntries.end(); ++i) { if((*i)->needsFileAllocation() || dwreq.find((*i)->getFileEntry()->getPath()) != dwreq.end() || (*i)->fileExists()) { logger->debug("Creating DiskWriter for filename=%s", - (*i)->getFilePath().c_str()); + (*i)->getFilePath().c_str()); (*i)->setDiskWriter(dwFactory.newDiskWriter((*i)->getFilePath())); if(_directIOAllowed) { - (*i)->getDiskWriter()->allowDirectIO(); + (*i)->getDiskWriter()->allowDirectIO(); } if(_readOnly) { - (*i)->getDiskWriter()->enableReadOnly(); + (*i)->getDiskWriter()->enableReadOnly(); } } } @@ -261,7 +261,7 @@ void MultiDiskAdaptor::resetDiskWriterEntries() void MultiDiskAdaptor::mkdir() const { for(std::vector<SharedHandle<DiskWriterEntry> >::const_iterator i = - diskWriterEntries.begin(); i != diskWriterEntries.end(); ++i) { + diskWriterEntries.begin(); i != diskWriterEntries.end(); ++i) { (*i)->getFileEntry()->setupDir(); } } @@ -270,8 +270,8 @@ void MultiDiskAdaptor::openIfNot (const SharedHandle<DiskWriterEntry>& entry, void (DiskWriterEntry::*open)()) { if(!entry->isOpen()) { -// logger->debug("DiskWriterEntry: Cache MISS. offset=%s", -// util::itos(entry->getFileEntry()->getOffset()).c_str()); + // logger->debug("DiskWriterEntry: Cache MISS. offset=%s", + // util::itos(entry->getFileEntry()->getOffset()).c_str()); size_t numOpened = _openedDiskWriterEntries.size(); (entry.get()->*open)(); @@ -280,7 +280,7 @@ void MultiDiskAdaptor::openIfNot // Choose one DiskWriterEntry randomly and close it. size_t index = SimpleRandomizer::getInstance()->getRandomNumber(numOpened); std::vector<SharedHandle<DiskWriterEntry> >::iterator i = - _openedDiskWriterEntries.begin(); + _openedDiskWriterEntries.begin(); std::advance(i, index); (*i)->closeFile(); (*i) = entry; @@ -288,8 +288,8 @@ void MultiDiskAdaptor::openIfNot _openedDiskWriterEntries.push_back(entry); } } else { -// logger->debug("DiskWriterEntry: Cache HIT. offset=%s", -// util::itos(entry->getFileEntry()->getOffset()).c_str()); + // logger->debug("DiskWriterEntry: Cache HIT. offset=%s", + // util::itos(entry->getFileEntry()->getOffset()).c_str()); } } @@ -337,7 +337,7 @@ static bool isInRange(const DiskWriterEntryHandle entry, off_t offset) } static size_t calculateLength(const DiskWriterEntryHandle entry, - off_t fileOffset, size_t rem) + off_t fileOffset, size_t rem) { size_t length; if(entry->getFileEntry()->getLength() < (uint64_t)fileOffset+rem) { @@ -361,7 +361,7 @@ findFirstDiskWriterEntry(const DiskWriterEntries& diskWriterEntries, off_t offse { DiskWriterEntries::const_iterator first = std::upper_bound(diskWriterEntries.begin(), diskWriterEntries.end(), - offset, OffsetCompare()); + offset, OffsetCompare()); --first; @@ -369,22 +369,22 @@ 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; } static void throwOnDiskWriterNotOpened(const SharedHandle<DiskWriterEntry>& e, - off_t offset) + off_t offset) { throw DL_ABORT_EX (StringFormat("DiskWriter for offset=%s, filename=%s is not opened.", - util::itos(offset).c_str(), - e->getFilePath().c_str()).str()); + util::itos(offset).c_str(), + e->getFilePath().c_str()).str()); } void MultiDiskAdaptor::writeData(const unsigned char* data, size_t len, - off_t offset) + off_t offset) { DiskWriterEntries::const_iterator first = findFirstDiskWriterEntry(diskWriterEntries, offset); @@ -438,7 +438,7 @@ ssize_t MultiDiskAdaptor::readData(unsigned char* data, size_t len, off_t offset bool MultiDiskAdaptor::fileExists() { for(std::vector<SharedHandle<FileEntry> >::iterator i = - fileEntries.begin(); i != fileEntries.end(); ++i) { + fileEntries.begin(); i != fileEntries.end(); ++i) { if((*i)->exists()) { return true; } @@ -450,7 +450,7 @@ uint64_t MultiDiskAdaptor::size() { uint64_t size = 0; for(std::vector<SharedHandle<FileEntry> >::iterator i = - fileEntries.begin(); i != fileEntries.end(); ++i) { + fileEntries.begin(); i != fileEntries.end(); ++i) { size += File((*i)->getPath()).size(); } return size; @@ -490,7 +490,7 @@ void MultiDiskAdaptor::disableReadOnly() void MultiDiskAdaptor::cutTrailingGarbage() { for(std::vector<SharedHandle<DiskWriterEntry> >::const_iterator i = - diskWriterEntries.begin(); i != diskWriterEntries.end(); ++i) { + diskWriterEntries.begin(); i != diskWriterEntries.end(); ++i) { uint64_t length = (*i)->getFileEntry()->getLength(); if(File((*i)->getFilePath()).size() > length) { // We need open file before calling DiskWriter::truncate(uint64_t) @@ -509,11 +509,11 @@ size_t MultiDiskAdaptor::utime(const Time& actime, const Time& modtime) { size_t numOK = 0; for(std::vector<SharedHandle<FileEntry> >::const_iterator i = - fileEntries.begin(); i != fileEntries.end(); ++i) { + fileEntries.begin(); i != fileEntries.end(); ++i) { if((*i)->isRequested()) { File f((*i)->getPath()); if(f.isFile() && f.utime(actime, modtime)) { - ++numOK; + ++numOK; } } } diff --git a/src/MultiDiskAdaptor.h b/src/MultiDiskAdaptor.h index c99a43c3..b8be938d 100644 --- a/src/MultiDiskAdaptor.h +++ b/src/MultiDiskAdaptor.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -135,7 +135,7 @@ private: void mkdir() const; void openIfNot(const SharedHandle<DiskWriterEntry>& entry, - void (DiskWriterEntry::*f)()); + void (DiskWriterEntry::*f)()); static const size_t DEFAULT_MAX_OPEN_FILES = 100; @@ -153,7 +153,7 @@ public: virtual void closeFile(); virtual void writeData(const unsigned char* data, size_t len, - off_t offset); + off_t offset); virtual ssize_t readData(unsigned char* data, size_t len, off_t offset); diff --git a/src/MultiFileAllocationIterator.cc b/src/MultiFileAllocationIterator.cc index a1f772af..5f79633d 100644 --- a/src/MultiFileAllocationIterator.cc +++ b/src/MultiFileAllocationIterator.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -46,7 +46,7 @@ namespace aria2 { MultiFileAllocationIterator::MultiFileAllocationIterator(MultiDiskAdaptor* diskAdaptor): _diskAdaptor(diskAdaptor), _entries(_diskAdaptor->diskWriterEntries.begin(), - _diskAdaptor->diskWriterEntries.end()), + _diskAdaptor->diskWriterEntries.end()), _offset(0) {} @@ -67,20 +67,20 @@ void MultiFileAllocationIterator::allocateChunk() // Calling private function of MultiDiskAdaptor. #ifdef HAVE_POSIX_FALLOCATE if(_diskAdaptor->doesFallocate()) { - _fileAllocationIterator.reset - (new FallocFileAllocationIterator(entry->getDiskWriter().get(), - entry->size(), - fileEntry->getLength())); + _fileAllocationIterator.reset + (new FallocFileAllocationIterator(entry->getDiskWriter().get(), + entry->size(), + fileEntry->getLength())); } else #endif // HAVE_POSIX_FALLOCATE - { - SharedHandle<SingleFileAllocationIterator> fa - (new SingleFileAllocationIterator(entry->getDiskWriter().get(), - entry->size(), - fileEntry->getLength())); - fa->init(); - _fileAllocationIterator = fa; - } + { + SharedHandle<SingleFileAllocationIterator> fa + (new SingleFileAllocationIterator(entry->getDiskWriter().get(), + entry->size(), + fileEntry->getLength())); + fa->init(); + _fileAllocationIterator = fa; + } } } if(finished()) { diff --git a/src/MultiFileAllocationIterator.h b/src/MultiFileAllocationIterator.h index 682e6686..c6892b9e 100644 --- a/src/MultiFileAllocationIterator.h +++ b/src/MultiFileAllocationIterator.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/MultiUrlRequestInfo.cc b/src/MultiUrlRequestInfo.cc index 5a06e51e..95ab5ee5 100644 --- a/src/MultiUrlRequestInfo.cc +++ b/src/MultiUrlRequestInfo.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -94,10 +94,10 @@ MultiUrlRequestInfo::~MultiUrlRequestInfo() {} void MultiUrlRequestInfo::printMessageForContinue() { _summaryOut << "\n" - << _("aria2 will resume download if the transfer is restarted.") - << "\n" - << _("If there are any errors, then see the log file. See '-l' option in help/man page for details.") - << "\n"; + << _("aria2 will resume download if the transfer is restarted.") + << "\n" + << _("If there are any errors, then see the log file. See '-l' option in help/man page for details.") + << "\n"; } downloadresultcode::RESULT MultiUrlRequestInfo::execute() @@ -110,10 +110,10 @@ downloadresultcode::RESULT MultiUrlRequestInfo::execute() if(!_option->blank(PREF_LOAD_COOKIES)) { File cookieFile(_option->get(PREF_LOAD_COOKIES)); if(cookieFile.isFile()) { - e->getCookieStorage()->load(_option->get(PREF_LOAD_COOKIES)); + e->getCookieStorage()->load(_option->get(PREF_LOAD_COOKIES)); } else { - _logger->error(MSG_LOADING_COOKIE_FAILED, - _option->get(PREF_LOAD_COOKIES).c_str()); + _logger->error(MSG_LOADING_COOKIE_FAILED, + _option->get(PREF_LOAD_COOKIES).c_str()); } } @@ -122,12 +122,12 @@ downloadresultcode::RESULT MultiUrlRequestInfo::execute() if(!_option->getAsBool(PREF_NO_NETRC) && netrccf.isFile()) { mode_t mode = netrccf.mode(); if(mode&(S_IRWXG|S_IRWXO)) { - _logger->notice(MSG_INCORRECT_NETRC_PERMISSION, - _option->get(PREF_NETRC_PATH).c_str()); + _logger->notice(MSG_INCORRECT_NETRC_PERMISSION, + _option->get(PREF_NETRC_PATH).c_str()); } else { - SharedHandle<Netrc> netrc(new Netrc()); - netrc->parse(_option->get(PREF_NETRC_PATH)); - authConfigFactory->setNetrc(netrc); + SharedHandle<Netrc> netrc(new Netrc()); + netrc->parse(_option->get(PREF_NETRC_PATH)); + authConfigFactory->setNetrc(netrc); } } e->setAuthConfigFactory(authConfigFactory); @@ -137,11 +137,11 @@ downloadresultcode::RESULT MultiUrlRequestInfo::execute() if(!_option->blank(PREF_CERTIFICATE) && !_option->blank(PREF_PRIVATE_KEY)) { tlsContext->addClientKeyFile(_option->get(PREF_CERTIFICATE), - _option->get(PREF_PRIVATE_KEY)); + _option->get(PREF_PRIVATE_KEY)); } if(!_option->blank(PREF_CA_CERTIFICATE)) { if(!tlsContext->addTrustedCACertFile(_option->get(PREF_CA_CERTIFICATE))) { - _logger->warn(MSG_WARN_NO_CA_CERT); + _logger->warn(MSG_WARN_NO_CA_CERT); } } else if(_option->getAsBool(PREF_CHECK_CERTIFICATE)) { _logger->warn(MSG_WARN_NO_CA_CERT); @@ -157,7 +157,7 @@ downloadresultcode::RESULT MultiUrlRequestInfo::execute() if(!serverStatIf.empty()) { e->_requestGroupMan->loadServerStat(serverStatIf); e->_requestGroupMan->removeStaleServerStat - (_option->getAsInt(PREF_SERVER_STAT_TIMEOUT)); + (_option->getAsInt(PREF_SERVER_STAT_TIMEOUT)); } e->setStatCalc(_statCalc); @@ -182,10 +182,10 @@ downloadresultcode::RESULT MultiUrlRequestInfo::execute() if(!s.allCompleted()) { printMessageForContinue(); if(s.getLastErrorResult() == downloadresultcode::FINISHED && - s.getInProgress() > 0) { - returnValue = downloadresultcode::IN_PROGRESS; + s.getInProgress() > 0) { + returnValue = downloadresultcode::IN_PROGRESS; } else { - returnValue = s.getLastErrorResult(); + returnValue = s.getLastErrorResult(); } } } catch(RecoverableException& e) { diff --git a/src/MultiUrlRequestInfo.h b/src/MultiUrlRequestInfo.h index 91706f3d..c4e94c61 100644 --- a/src/MultiUrlRequestInfo.h +++ b/src/MultiUrlRequestInfo.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/NameMatchOptionHandler.h b/src/NameMatchOptionHandler.h index cb68bab6..fdbfed6d 100644 --- a/src/NameMatchOptionHandler.h +++ b/src/NameMatchOptionHandler.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -75,10 +75,10 @@ protected: virtual void parseArg(Option& option, const std::string& arg) = 0; public: NameMatchOptionHandler(const std::string& optName, - const std::string& description = NO_DESCRIPTION, - const std::string& defaultValue = NO_DEFAULT_VALUE, - ARG_TYPE argType = REQ_ARG, - char shortName = 0): + const std::string& description = NO_DESCRIPTION, + const std::string& defaultValue = NO_DEFAULT_VALUE, + ARG_TYPE argType = REQ_ARG, + char shortName = 0): _optName(optName), _description(description), _defaultValue(defaultValue), @@ -117,7 +117,7 @@ public: { std::stringstream s; std::copy(_tags.begin(), _tags.end(), - std::ostream_iterator<std::string>(s, ",")); + std::ostream_iterator<std::string>(s, ",")); return util::trim(s.str(), ", "); } diff --git a/src/NameResolver.cc b/src/NameResolver.cc index 120f8f8c..7271f8ce 100644 --- a/src/NameResolver.cc +++ b/src/NameResolver.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -47,14 +47,14 @@ namespace aria2 { NameResolver::NameResolver():_socktype(0), _family(AF_UNSPEC) {} void NameResolver::resolve(std::deque<std::string>& resolvedAddresses, - const std::string& hostname) + const std::string& hostname) { struct addrinfo* res; int s; s = callGetaddrinfo(&res, hostname.c_str(), 0, _family, _socktype, 0, 0); if(s) { throw DL_ABORT_EX(StringFormat(EX_RESOLVE_HOSTNAME, - hostname.c_str(), gai_strerror(s)).str()); + hostname.c_str(), gai_strerror(s)).str()); } auto_delete<struct addrinfo*> resDeleter(res, freeaddrinfo); struct addrinfo* rp; diff --git a/src/NameResolver.h b/src/NameResolver.h index c8420dc8..1686aa84 100644 --- a/src/NameResolver.h +++ b/src/NameResolver.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -52,7 +52,7 @@ public: * Reolved addresses are pushed into addresses. */ void resolve(std::deque<std::string>& resolvedAddresses, - const std::string& hostname); + const std::string& hostname); // specify SOCK_STREAM or SOCK_DGRAM void setSocktype(int socktype); diff --git a/src/Netrc.cc b/src/Netrc.cc index cb60e977..253c2e5f 100644 --- a/src/Netrc.cc +++ b/src/Netrc.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -95,46 +95,46 @@ void Netrc::parse(const std::string& path) std::vector<std::string> tokens; util::split(line, std::back_inserter(tokens), " \t", true); for(std::vector<std::string>::const_iterator iter = tokens.begin(); - iter != tokens.end(); ++iter) { + iter != tokens.end(); ++iter) { const std::string& token = *iter; if(state == GET_TOKEN) { - if(token == Netrc::MACHINE) { - storeAuthenticator(authenticator); - authenticator.reset(new Authenticator()); - state = SET_MACHINE; - } else if(token == Netrc::DEFAULT) { - storeAuthenticator(authenticator); - authenticator.reset(new DefaultAuthenticator()); - } else { - if(authenticator.isNull()) { - throw DL_ABORT_EX - (StringFormat("Netrc:parse error. %s encounterd where 'machine'" - " or 'default' expected.", token.c_str()).str()); - } - if(token == Netrc::LOGIN) { - state = SET_LOGIN; - } else if(token == Netrc::PASSWORD) { - state = SET_PASSWORD; - } else if(token == Netrc::ACCOUNT) { - state = SET_ACCOUNT; - } else if(token == Netrc::MACDEF) { - state = SET_MACDEF; - } - } + if(token == Netrc::MACHINE) { + storeAuthenticator(authenticator); + authenticator.reset(new Authenticator()); + state = SET_MACHINE; + } else if(token == Netrc::DEFAULT) { + storeAuthenticator(authenticator); + authenticator.reset(new DefaultAuthenticator()); + } else { + if(authenticator.isNull()) { + throw DL_ABORT_EX + (StringFormat("Netrc:parse error. %s encounterd where 'machine'" + " or 'default' expected.", token.c_str()).str()); + } + if(token == Netrc::LOGIN) { + state = SET_LOGIN; + } else if(token == Netrc::PASSWORD) { + state = SET_PASSWORD; + } else if(token == Netrc::ACCOUNT) { + state = SET_ACCOUNT; + } else if(token == Netrc::MACDEF) { + state = SET_MACDEF; + } + } } else { - if(state == SET_MACHINE) { - authenticator->setMachine(token); - } else if(state == SET_LOGIN) { - authenticator->setLogin(token); - } else if(state == SET_PASSWORD) { - authenticator->setPassword(token); - } else if(state == SET_ACCOUNT) { - authenticator->setAccount(token); - } else if(state == SET_MACDEF) { - skipMacdef(f); - } - state = GET_TOKEN; - } + if(state == SET_MACHINE) { + authenticator->setMachine(token); + } else if(state == SET_LOGIN) { + authenticator->setLogin(token); + } else if(state == SET_PASSWORD) { + authenticator->setPassword(token); + } else if(state == SET_ACCOUNT) { + authenticator->setAccount(token); + } else if(state == SET_MACDEF) { + skipMacdef(f); + } + state = GET_TOKEN; + } } } if(state != GET_TOKEN) { @@ -167,7 +167,7 @@ AuthenticatorHandle Netrc::findAuthenticator(const std::string& hostname) const { Authenticators::const_iterator itr = std::find_if(authenticators.begin(), authenticators.end(), - AuthHostMatch(hostname)); + AuthHostMatch(hostname)); if(itr == authenticators.end()) { return SharedHandle<Authenticator>(); } else { diff --git a/src/Netrc.h b/src/Netrc.h index f92d7854..7be2581c 100644 --- a/src/Netrc.h +++ b/src/Netrc.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -63,9 +63,9 @@ public: Authenticator() {} Authenticator(const std::string& machine, - const std::string& login, - const std::string& password, - const std::string& account) + const std::string& login, + const std::string& password, + const std::string& account) :machine(machine), login(login), password(password), @@ -115,8 +115,8 @@ public: DefaultAuthenticator() {} DefaultAuthenticator(const std::string& login, - const std::string& password, - const std::string& account) + const std::string& password, + const std::string& account) :Authenticator(A2STR::NIL, login, password, account) {} virtual ~DefaultAuthenticator() {} diff --git a/src/NetrcAuthResolver.cc b/src/NetrcAuthResolver.cc index 6ebcf2fe..110c64be 100644 --- a/src/NetrcAuthResolver.cc +++ b/src/NetrcAuthResolver.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -59,10 +59,10 @@ AuthConfigHandle NetrcAuthResolver::findNetrcAuthenticator(const std::string& ho return _defaultAuthConfig; } else { if(_ignoreDefault && auth->getMachine() == "") { - return _defaultAuthConfig; + return _defaultAuthConfig; } else { - return SharedHandle<AuthConfig> - (new AuthConfig(auth->getLogin(), auth->getPassword())); + return SharedHandle<AuthConfig> + (new AuthConfig(auth->getLogin(), auth->getPassword())); } } } diff --git a/src/NetrcAuthResolver.h b/src/NetrcAuthResolver.h index 812f6795..3b222c01 100644 --- a/src/NetrcAuthResolver.h +++ b/src/NetrcAuthResolver.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/NsCookieParser.cc b/src/NsCookieParser.cc index be60e4e6..ed599e75 100644 --- a/src/NsCookieParser.cc +++ b/src/NsCookieParser.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -65,11 +65,11 @@ static Cookie parseNsCookie(const std::string& nsCookieStr) } Cookie c(vs[5], // name - vs.size() >= 7? vs[6]:A2STR::NIL, // value - expireDate, // expires - vs[2], // path - vs[0], // domain - vs[3] == C_TRUE ? true : false); + vs.size() >= 7? vs[6]:A2STR::NIL, // value + expireDate, // expires + vs[2], // path + vs[0], // domain + vs[3] == C_TRUE ? true : false); return c; } @@ -90,7 +90,7 @@ std::deque<Cookie> NsCookieParser::parse(const std::string& filename) try { Cookie c = parseNsCookie(line); if(c.good()) { - cookies.push_back(c); + cookies.push_back(c); } } catch(RecoverableException& e) { // ignore malformed cookie entry diff --git a/src/NsCookieParser.h b/src/NsCookieParser.h index 6882e44f..6204a97d 100644 --- a/src/NsCookieParser.h +++ b/src/NsCookieParser.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/NullProgressInfoFile.h b/src/NullProgressInfoFile.h index 1d4819cb..5fd95e58 100644 --- a/src/NullProgressInfoFile.h +++ b/src/NullProgressInfoFile.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/NullStatCalc.h b/src/NullStatCalc.h index 912d837e..9c29ceb3 100644 --- a/src/NullStatCalc.h +++ b/src/NullStatCalc.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/NumberDecorator.h b/src/NumberDecorator.h index 937a2077..e04671f8 100644 --- a/src/NumberDecorator.h +++ b/src/NumberDecorator.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/Option.cc b/src/Option.cc index 8e81910e..26e65f8f 100644 --- a/src/Option.cc +++ b/src/Option.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/Option.h b/src/Option.h index aa198f59..f002ae2e 100644 --- a/src/Option.h +++ b/src/Option.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/OptionHandler.cc b/src/OptionHandler.cc index 1ac2e52a..b27728fa 100644 --- a/src/OptionHandler.cc +++ b/src/OptionHandler.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/OptionHandler.h b/src/OptionHandler.h index 21a05c2b..362f5c88 100644 --- a/src/OptionHandler.h +++ b/src/OptionHandler.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/OptionHandlerException.cc b/src/OptionHandlerException.cc index f1914f70..6e9c8500 100644 --- a/src/OptionHandlerException.cc +++ b/src/OptionHandlerException.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -41,20 +41,20 @@ const std::string OptionHandlerException::MESSAGE ("We encountered a problem while processing the option '--%s'."); OptionHandlerException::OptionHandlerException(const char* file, int line, - const std::string& optName): + const std::string& optName): RecoverableException (file, line, StringFormat(MESSAGE.c_str(), optName.c_str()).str()), _optName(optName) {} OptionHandlerException::OptionHandlerException(const char* file, int line, - const std::string& optName, - const Exception& cause): + const std::string& optName, + const Exception& cause): RecoverableException (file, line, StringFormat(MESSAGE.c_str(), optName.c_str()).str(), cause), _optName(optName) {} OptionHandlerException::OptionHandlerException(const char* file, int line, - const OptionHandlerException& e): + const OptionHandlerException& e): RecoverableException(file, line, e), _optName(e._optName) {} OptionHandlerException::~OptionHandlerException() throw() {} diff --git a/src/OptionHandlerException.h b/src/OptionHandlerException.h index 42246000..88fb0596 100644 --- a/src/OptionHandlerException.h +++ b/src/OptionHandlerException.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -47,22 +47,22 @@ protected: virtual SharedHandle<Exception> copy() const; public: OptionHandlerException(const char* file, int line, - const std::string& optName); + const std::string& optName); OptionHandlerException(const char* file, int line, const std::string& optName, - const Exception& cause); + const Exception& cause); OptionHandlerException(const char* file, int line, - const OptionHandlerException& e); + const OptionHandlerException& e); virtual ~OptionHandlerException() throw(); const std::string& getOptionName() const throw(); }; -#define OPTION_HANDLER_EXCEPTION(arg)\ +#define OPTION_HANDLER_EXCEPTION(arg) \ OptionHandlerException(__FILE__, __LINE__, arg) -#define OPTION_HANDLER_EXCEPTION2(arg1, arg2)\ +#define OPTION_HANDLER_EXCEPTION2(arg1, arg2) \ OptionHandlerException(__FILE__, __LINE__, arg1, arg2) } // namespace aria2 diff --git a/src/OptionHandlerFactory.cc b/src/OptionHandlerFactory.cc index f6740197..5a0f48c8 100644 --- a/src/OptionHandlerFactory.cc +++ b/src/OptionHandlerFactory.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -51,59 +51,59 @@ OptionHandlers OptionHandlerFactory::createOptionHandlers() // General Options { SharedHandle<OptionHandler> op(new BooleanOptionHandler - (PREF_ALLOW_OVERWRITE, - TEXT_ALLOW_OVERWRITE, - V_FALSE)); + (PREF_ALLOW_OVERWRITE, + TEXT_ALLOW_OVERWRITE, + V_FALSE)); op->addTag(TAG_ADVANCED); op->addTag(TAG_FILE); handlers.push_back(op); } { SharedHandle<OptionHandler> op(new BooleanOptionHandler - (PREF_ALLOW_PIECE_LENGTH_CHANGE, - TEXT_ALLOW_PIECE_LENGTH_CHANGE, - V_FALSE)); + (PREF_ALLOW_PIECE_LENGTH_CHANGE, + TEXT_ALLOW_PIECE_LENGTH_CHANGE, + V_FALSE)); op->addTag(TAG_ADVANCED); handlers.push_back(op); } #ifdef ENABLE_ASYNC_DNS { SharedHandle<OptionHandler> op(new BooleanOptionHandler - (PREF_ASYNC_DNS, - TEXT_ASYNC_DNS, - V_TRUE, - OptionHandler::OPT_ARG)); + (PREF_ASYNC_DNS, + TEXT_ASYNC_DNS, + V_TRUE, + OptionHandler::OPT_ARG)); op->addTag(TAG_ADVANCED); handlers.push_back(op); } #endif // ENABLE_ASYNC_DNS { SharedHandle<OptionHandler> op(new BooleanOptionHandler - (PREF_AUTO_FILE_RENAMING, - TEXT_AUTO_FILE_RENAMING, - V_TRUE, - OptionHandler::OPT_ARG)); + (PREF_AUTO_FILE_RENAMING, + TEXT_AUTO_FILE_RENAMING, + V_TRUE, + OptionHandler::OPT_ARG)); op->addTag(TAG_ADVANCED); op->addTag(TAG_FILE); handlers.push_back(op); } { SharedHandle<OptionHandler> op(new NumberOptionHandler - (PREF_AUTO_SAVE_INTERVAL, - TEXT_AUTO_SAVE_INTERVAL, - "60", - 0, 600)); + (PREF_AUTO_SAVE_INTERVAL, + TEXT_AUTO_SAVE_INTERVAL, + "60", + 0, 600)); op->addTag(TAG_ADVANCED); handlers.push_back(op); } #ifdef ENABLE_MESSAGE_DIGEST { SharedHandle<OptionHandler> op(new BooleanOptionHandler - (PREF_CHECK_INTEGRITY, - TEXT_CHECK_INTEGRITY, - V_FALSE, - OptionHandler::OPT_ARG, - 'V')); + (PREF_CHECK_INTEGRITY, + TEXT_CHECK_INTEGRITY, + V_FALSE, + OptionHandler::OPT_ARG, + 'V')); op->addTag(TAG_BASIC); op->addTag(TAG_BITTORRENT); op->addTag(TAG_METALINK); @@ -113,19 +113,19 @@ OptionHandlers OptionHandlerFactory::createOptionHandlers() #endif // ENABLE_MESSAGE_DIGEST { SharedHandle<OptionHandler> op(new DefaultOptionHandler - (PREF_CONF_PATH, - TEXT_CONF_PATH, - util::getHomeDir()+"/.aria2/aria2.conf")); + (PREF_CONF_PATH, + TEXT_CONF_PATH, + util::getHomeDir()+"/.aria2/aria2.conf")); op->addTag(TAG_ADVANCED); handlers.push_back(op); } { SharedHandle<OptionHandler> op(new BooleanOptionHandler - (PREF_CONTINUE, - TEXT_CONTINUE, - V_FALSE, // TODO ommit? - OptionHandler::NO_ARG, - 'c')); + (PREF_CONTINUE, + TEXT_CONTINUE, + V_FALSE, // TODO ommit? + OptionHandler::NO_ARG, + 'c')); op->addTag(TAG_BASIC); op->addTag(TAG_FTP); op->addTag(TAG_HTTP); @@ -133,51 +133,51 @@ OptionHandlers OptionHandlerFactory::createOptionHandlers() } { SharedHandle<OptionHandler> op(new BooleanOptionHandler - (PREF_DAEMON, - TEXT_DAEMON, - V_FALSE, - OptionHandler::NO_ARG, - 'D')); // TODO ommit? + (PREF_DAEMON, + TEXT_DAEMON, + V_FALSE, + OptionHandler::NO_ARG, + 'D')); // TODO ommit? op->addTag(TAG_ADVANCED); handlers.push_back(op); } { SharedHandle<OptionHandler> op(new DefaultOptionHandler - (PREF_DIR, - TEXT_DIR, - File::getCurrentDir(), - A2STR::NIL, - OptionHandler::REQ_ARG, - 'd')); + (PREF_DIR, + TEXT_DIR, + File::getCurrentDir(), + A2STR::NIL, + OptionHandler::REQ_ARG, + 'd')); op->addTag(TAG_BASIC); op->addTag(TAG_FILE); handlers.push_back(op); } { SharedHandle<OptionHandler> op(new BooleanOptionHandler - (PREF_DISABLE_IPV6, - TEXT_DISABLE_IPV6, - V_FALSE, - OptionHandler::OPT_ARG)); + (PREF_DISABLE_IPV6, + TEXT_DISABLE_IPV6, + V_FALSE, + OptionHandler::OPT_ARG)); op->addTag(TAG_ADVANCED); handlers.push_back(op); } { SharedHandle<NumberOptionHandler> op(new NumberOptionHandler - (PREF_DNS_TIMEOUT, - NO_DESCRIPTION, - "30", - 1, 60)); + (PREF_DNS_TIMEOUT, + NO_DESCRIPTION, + "30", + 1, 60)); op->hide(); handlers.push_back(op); } #ifdef ENABLE_DIRECT_IO { SharedHandle<OptionHandler> op(new BooleanOptionHandler - (PREF_ENABLE_DIRECT_IO, - TEXT_ENABLE_DIRECT_IO, - V_TRUE, - OptionHandler::OPT_ARG)); + (PREF_ENABLE_DIRECT_IO, + TEXT_ENABLE_DIRECT_IO, + V_TRUE, + OptionHandler::OPT_ARG)); op->addTag(TAG_ADVANCED); op->addTag(TAG_FILE); handlers.push_back(op); @@ -186,10 +186,10 @@ OptionHandlers OptionHandlerFactory::createOptionHandlers() #ifdef ENABLE_XML_RPC { SharedHandle<OptionHandler> op(new BooleanOptionHandler - (PREF_ENABLE_XML_RPC, - TEXT_ENABLE_XML_RPC, - V_FALSE, - OptionHandler::OPT_ARG)); + (PREF_ENABLE_XML_RPC, + TEXT_ENABLE_XML_RPC, + V_FALSE, + OptionHandler::OPT_ARG)); op->addTag(TAG_XML_RPC); handlers.push_back(op); } @@ -202,102 +202,102 @@ OptionHandlers OptionHandlerFactory::createOptionHandlers() V_SELECT }; SharedHandle<OptionHandler> op(new ParameterOptionHandler - (PREF_EVENT_POLL, - TEXT_EVENT_POLL, + (PREF_EVENT_POLL, + TEXT_EVENT_POLL, #ifdef HAVE_EPOLL - V_EPOLL, + V_EPOLL, #else // !HAVE_EPOLL - V_SELECT, + V_SELECT, #endif // !HAVE_EPOLL - std::deque<std::string> - (¶ms[0],¶ms[arrayLength(params)]))); + std::deque<std::string> + (¶ms[0],¶ms[arrayLength(params)]))); op->addTag(TAG_ADVANCED); handlers.push_back(op); } { SharedHandle<OptionHandler> op(new ParameterOptionHandler - (PREF_FILE_ALLOCATION, - TEXT_FILE_ALLOCATION, - V_PREALLOC, - V_NONE, V_PREALLOC, + (PREF_FILE_ALLOCATION, + TEXT_FILE_ALLOCATION, + V_PREALLOC, + V_NONE, V_PREALLOC, #ifdef HAVE_POSIX_FALLOCATE - V_FALLOC, + V_FALLOC, #endif // HAVE_POSIX_FALLOCATE - 'a')); + 'a')); op->addTag(TAG_BASIC); op->addTag(TAG_FILE); handlers.push_back(op); } { SharedHandle<OptionHandler> op(new BooleanOptionHandler - (PREF_FORCE_SEQUENTIAL, - TEXT_FORCE_SEQUENTIAL, - V_FALSE, - OptionHandler::OPT_ARG, - 'Z')); + (PREF_FORCE_SEQUENTIAL, + TEXT_FORCE_SEQUENTIAL, + V_FALSE, + OptionHandler::OPT_ARG, + 'Z')); op->addTag(TAG_BASIC); handlers.push_back(op); } { SharedHandle<OptionHandler> op(new DefaultOptionHandler - (PREF_INPUT_FILE, - TEXT_INPUT_FILE, - NO_DEFAULT_VALUE, - "FILENAME,-", - OptionHandler::REQ_ARG, - 'i')); + (PREF_INPUT_FILE, + TEXT_INPUT_FILE, + NO_DEFAULT_VALUE, + "FILENAME,-", + OptionHandler::REQ_ARG, + 'i')); op->addTag(TAG_BASIC); handlers.push_back(op); } { SharedHandle<OptionHandler> op(new DefaultOptionHandler - (PREF_INTERFACE, - TEXT_INTERFACE, - NO_DEFAULT_VALUE, - "interface, IP address, hostname", - OptionHandler::REQ_ARG)); + (PREF_INTERFACE, + TEXT_INTERFACE, + NO_DEFAULT_VALUE, + "interface, IP address, hostname", + OptionHandler::REQ_ARG)); op->addTag(TAG_ADVANCED); handlers.push_back(op); } { SharedHandle<OptionHandler> op(new DefaultOptionHandler - (PREF_LOG, - TEXT_LOG, - NO_DEFAULT_VALUE, - "FILENAME,-", - OptionHandler::REQ_ARG, - 'l')); + (PREF_LOG, + TEXT_LOG, + NO_DEFAULT_VALUE, + "FILENAME,-", + OptionHandler::REQ_ARG, + 'l')); op->addTag(TAG_BASIC); handlers.push_back(op); } { const std::string params[] = { V_DEBUG, V_INFO, V_NOTICE, V_WARN, V_ERROR }; SharedHandle<OptionHandler> op(new ParameterOptionHandler - (PREF_LOG_LEVEL, - TEXT_LOG_LEVEL, - V_DEBUG, - std::deque<std::string> - (¶ms[0], - ¶ms[arrayLength(params)]))); + (PREF_LOG_LEVEL, + TEXT_LOG_LEVEL, + V_DEBUG, + std::deque<std::string> + (¶ms[0], + ¶ms[arrayLength(params)]))); op->addTag(TAG_ADVANCED); handlers.push_back(op); } { SharedHandle<OptionHandler> op(new NumberOptionHandler - (PREF_MAX_CONCURRENT_DOWNLOADS, - TEXT_MAX_CONCURRENT_DOWNLOADS, - "5", - 1, -1, - 'j')); + (PREF_MAX_CONCURRENT_DOWNLOADS, + TEXT_MAX_CONCURRENT_DOWNLOADS, + "5", + 1, -1, + 'j')); op->addTag(TAG_BASIC); handlers.push_back(op); } { SharedHandle<OptionHandler> op(new UnitNumberOptionHandler - (PREF_MAX_DOWNLOAD_LIMIT, - TEXT_MAX_DOWNLOAD_LIMIT, - "0", - 0)); + (PREF_MAX_DOWNLOAD_LIMIT, + TEXT_MAX_DOWNLOAD_LIMIT, + "0", + 0)); op->addTag(TAG_BITTORRENT); op->addTag(TAG_FTP); op->addTag(TAG_HTTP); @@ -305,10 +305,10 @@ OptionHandlers OptionHandlerFactory::createOptionHandlers() } { SharedHandle<OptionHandler> op(new UnitNumberOptionHandler - (PREF_MAX_OVERALL_DOWNLOAD_LIMIT, - TEXT_MAX_OVERALL_DOWNLOAD_LIMIT, - "0", - 0)); + (PREF_MAX_OVERALL_DOWNLOAD_LIMIT, + TEXT_MAX_OVERALL_DOWNLOAD_LIMIT, + "0", + 0)); op->addTag(TAG_BITTORRENT); op->addTag(TAG_FTP); op->addTag(TAG_HTTP); @@ -316,225 +316,225 @@ OptionHandlers OptionHandlerFactory::createOptionHandlers() } { SharedHandle<OptionHandler> op(new BooleanOptionHandler - (PREF_NO_CONF, - TEXT_NO_CONF, - V_FALSE, - OptionHandler::NO_ARG)); + (PREF_NO_CONF, + TEXT_NO_CONF, + V_FALSE, + OptionHandler::NO_ARG)); op->addTag(TAG_ADVANCED); handlers.push_back(op); } { SharedHandle<OptionHandler> op(new UnitNumberOptionHandler - (PREF_NO_FILE_ALLOCATION_LIMIT, - TEXT_NO_FILE_ALLOCATION_LIMIT, - "5M", - 0)); + (PREF_NO_FILE_ALLOCATION_LIMIT, + TEXT_NO_FILE_ALLOCATION_LIMIT, + "5M", + 0)); op->addTag(TAG_ADVANCED); op->addTag(TAG_FILE); handlers.push_back(op); } { SharedHandle<OptionHandler> op(new DefaultOptionHandler - (PREF_ON_DOWNLOAD_COMPLETE, - TEXT_ON_DOWNLOAD_COMPLETE, - NO_DEFAULT_VALUE, - "/path/to/command")); + (PREF_ON_DOWNLOAD_COMPLETE, + TEXT_ON_DOWNLOAD_COMPLETE, + NO_DEFAULT_VALUE, + "/path/to/command")); op->addTag(TAG_ADVANCED); op->addTag(TAG_HOOK); handlers.push_back(op); } { SharedHandle<OptionHandler> op(new DefaultOptionHandler - (PREF_ON_DOWNLOAD_ERROR, - TEXT_ON_DOWNLOAD_ERROR, - NO_DEFAULT_VALUE, - "/path/to/command")); + (PREF_ON_DOWNLOAD_ERROR, + TEXT_ON_DOWNLOAD_ERROR, + NO_DEFAULT_VALUE, + "/path/to/command")); op->addTag(TAG_ADVANCED); op->addTag(TAG_HOOK); handlers.push_back(op); } { SharedHandle<OptionHandler> op(new DefaultOptionHandler - (PREF_ON_DOWNLOAD_START, - TEXT_ON_DOWNLOAD_START, - NO_DEFAULT_VALUE, - "/path/to/command")); + (PREF_ON_DOWNLOAD_START, + TEXT_ON_DOWNLOAD_START, + NO_DEFAULT_VALUE, + "/path/to/command")); op->addTag(TAG_ADVANCED); op->addTag(TAG_HOOK); handlers.push_back(op); } { SharedHandle<OptionHandler> op(new DefaultOptionHandler - (PREF_ON_DOWNLOAD_STOP, - TEXT_ON_DOWNLOAD_STOP, - NO_DEFAULT_VALUE, - "/path/to/command")); + (PREF_ON_DOWNLOAD_STOP, + TEXT_ON_DOWNLOAD_STOP, + NO_DEFAULT_VALUE, + "/path/to/command")); op->addTag(TAG_ADVANCED); op->addTag(TAG_HOOK); handlers.push_back(op); } { SharedHandle<OptionHandler> op(new BooleanOptionHandler - (PREF_PARAMETERIZED_URI, - TEXT_PARAMETERIZED_URI, - V_FALSE, - OptionHandler::OPT_ARG, - 'P')); + (PREF_PARAMETERIZED_URI, + TEXT_PARAMETERIZED_URI, + V_FALSE, + OptionHandler::OPT_ARG, + 'P')); op->addTag(TAG_ADVANCED); handlers.push_back(op); } { SharedHandle<OptionHandler> op(new BooleanOptionHandler - (PREF_QUIET, - TEXT_QUIET, - V_FALSE, - OptionHandler::OPT_ARG, - 'q')); + (PREF_QUIET, + TEXT_QUIET, + V_FALSE, + OptionHandler::OPT_ARG, + 'q')); op->addTag(TAG_ADVANCED); handlers.push_back(op); } #ifdef ENABLE_MESSAGE_DIGEST { SharedHandle<OptionHandler> op(new BooleanOptionHandler - (PREF_REALTIME_CHUNK_CHECKSUM, - TEXT_REALTIME_CHUNK_CHECKSUM, - V_TRUE)); + (PREF_REALTIME_CHUNK_CHECKSUM, + TEXT_REALTIME_CHUNK_CHECKSUM, + V_TRUE)); op->addTag(TAG_METALINK); handlers.push_back(op); } #endif // ENABLE_MESSAGE_DIGEST { SharedHandle<OptionHandler> op(new NumberOptionHandler - (PREF_STOP, - TEXT_STOP, - "0", - 0, INT32_MAX)); + (PREF_STOP, + TEXT_STOP, + "0", + 0, INT32_MAX)); op->addTag(TAG_ADVANCED); handlers.push_back(op); } { SharedHandle<OptionHandler> op(new NumberOptionHandler - (PREF_SUMMARY_INTERVAL, - TEXT_SUMMARY_INTERVAL, - "60", - 0, INT32_MAX)); + (PREF_SUMMARY_INTERVAL, + TEXT_SUMMARY_INTERVAL, + "60", + 0, INT32_MAX)); op->addTag(TAG_ADVANCED); handlers.push_back(op); } #ifdef ENABLE_XML_RPC { SharedHandle<OptionHandler> op(new BooleanOptionHandler - (PREF_XML_RPC_LISTEN_ALL, - TEXT_XML_RPC_LISTEN_ALL, - V_FALSE, - OptionHandler::OPT_ARG)); + (PREF_XML_RPC_LISTEN_ALL, + TEXT_XML_RPC_LISTEN_ALL, + V_FALSE, + OptionHandler::OPT_ARG)); op->addTag(TAG_XML_RPC); handlers.push_back(op); } { SharedHandle<OptionHandler> op(new NumberOptionHandler - (PREF_XML_RPC_LISTEN_PORT, - TEXT_XML_RPC_LISTEN_PORT, - "6800", - 1024, UINT16_MAX)); + (PREF_XML_RPC_LISTEN_PORT, + TEXT_XML_RPC_LISTEN_PORT, + "6800", + 1024, UINT16_MAX)); op->addTag(TAG_XML_RPC); handlers.push_back(op); } { SharedHandle<OptionHandler> op(new UnitNumberOptionHandler - (PREF_XML_RPC_MAX_REQUEST_SIZE, - TEXT_XML_RPC_MAX_REQUEST_SIZE, - "2M", - 0)); + (PREF_XML_RPC_MAX_REQUEST_SIZE, + TEXT_XML_RPC_MAX_REQUEST_SIZE, + "2M", + 0)); op->addTag(TAG_XML_RPC); handlers.push_back(op); - } + } { SharedHandle<OptionHandler> op(new DefaultOptionHandler - (PREF_XML_RPC_USER, - TEXT_XML_RPC_USER)); + (PREF_XML_RPC_USER, + TEXT_XML_RPC_USER)); op->addTag(TAG_XML_RPC); handlers.push_back(op); } { SharedHandle<OptionHandler> op(new DefaultOptionHandler - (PREF_XML_RPC_PASSWD, - TEXT_XML_RPC_PASSWD)); + (PREF_XML_RPC_PASSWD, + TEXT_XML_RPC_PASSWD)); op->addTag(TAG_XML_RPC); handlers.push_back(op); - } + } #endif // ENABLE_XML_RPC // HTTP/FTP options { SharedHandle<OptionHandler> op(new NumberOptionHandler - (PREF_CONNECT_TIMEOUT, - TEXT_CONNECT_TIMEOUT, - "60", - 1, 600)); + (PREF_CONNECT_TIMEOUT, + TEXT_CONNECT_TIMEOUT, + "60", + 1, 600)); op->addTag(TAG_FTP); op->addTag(TAG_HTTP); handlers.push_back(op); } { SharedHandle<OptionHandler> op(new BooleanOptionHandler - (PREF_DRY_RUN, - TEXT_DRY_RUN, - V_FALSE, - OptionHandler::OPT_ARG)); + (PREF_DRY_RUN, + TEXT_DRY_RUN, + V_FALSE, + OptionHandler::OPT_ARG)); op->addTag(TAG_FTP); op->addTag(TAG_HTTP); handlers.push_back(op); } { SharedHandle<OptionHandler> op(new UnitNumberOptionHandler - (PREF_LOWEST_SPEED_LIMIT, - TEXT_LOWEST_SPEED_LIMIT, - "0", - 0)); + (PREF_LOWEST_SPEED_LIMIT, + TEXT_LOWEST_SPEED_LIMIT, + "0", + 0)); op->addTag(TAG_FTP); op->addTag(TAG_HTTP); handlers.push_back(op); } { SharedHandle<OptionHandler> op(new NumberOptionHandler - (PREF_MAX_FILE_NOT_FOUND, - TEXT_MAX_FILE_NOT_FOUND, - "0", - 0)); + (PREF_MAX_FILE_NOT_FOUND, + TEXT_MAX_FILE_NOT_FOUND, + "0", + 0)); op->addTag(TAG_FTP); op->addTag(TAG_HTTP); handlers.push_back(op); } { SharedHandle<OptionHandler> op(new NumberOptionHandler - (PREF_MAX_TRIES, - TEXT_MAX_TRIES, - "5", - 0, -1, - 'm')); + (PREF_MAX_TRIES, + TEXT_MAX_TRIES, + "5", + 0, -1, + 'm')); op->addTag(TAG_FTP); op->addTag(TAG_HTTP); handlers.push_back(op); } { SharedHandle<OptionHandler> op(new BooleanOptionHandler - (PREF_NO_NETRC, - TEXT_NO_NETRC, - V_FALSE, // TODO ommit? - OptionHandler::NO_ARG, - 'n')); + (PREF_NO_NETRC, + TEXT_NO_NETRC, + V_FALSE, // TODO ommit? + OptionHandler::NO_ARG, + 'n')); op->addTag(TAG_FTP); op->addTag(TAG_HTTP); handlers.push_back(op); } { SharedHandle<OptionHandler> op(new DefaultOptionHandler - (PREF_OUT, - TEXT_OUT, - NO_DEFAULT_VALUE, - "FILENAME", - OptionHandler::REQ_ARG, - 'o')); + (PREF_OUT, + TEXT_OUT, + NO_DEFAULT_VALUE, + "FILENAME", + OptionHandler::REQ_ARG, + 'o')); op->addTag(TAG_BASIC); op->addTag(TAG_FTP); op->addTag(TAG_HTTP); @@ -543,69 +543,69 @@ OptionHandlers OptionHandlerFactory::createOptionHandlers() } { SharedHandle<OptionHandler> op(new BooleanOptionHandler - (PREF_REMOTE_TIME, - TEXT_REMOTE_TIME, - V_FALSE, - OptionHandler::OPT_ARG, - 'R')); + (PREF_REMOTE_TIME, + TEXT_REMOTE_TIME, + V_FALSE, + OptionHandler::OPT_ARG, + 'R')); op->addTag(TAG_FTP); op->addTag(TAG_HTTP); handlers.push_back(op); } { SharedHandle<OptionHandler> op(new BooleanOptionHandler - (PREF_REUSE_URI, - NO_DESCRIPTION, - V_TRUE)); + (PREF_REUSE_URI, + NO_DESCRIPTION, + V_TRUE)); op->hide(); handlers.push_back(op); } { SharedHandle<UnitNumberOptionHandler> op(new UnitNumberOptionHandler - (PREF_SEGMENT_SIZE, - NO_DESCRIPTION, - "1M", - 1024, -1)); + (PREF_SEGMENT_SIZE, + NO_DESCRIPTION, + "1M", + 1024, -1)); op->hide(); handlers.push_back(op); } { SharedHandle<OptionHandler> op(new DefaultOptionHandler - (PREF_SERVER_STAT_IF, - TEXT_SERVER_STAT_IF, - NO_DEFAULT_VALUE, - "FILENAME")); + (PREF_SERVER_STAT_IF, + TEXT_SERVER_STAT_IF, + NO_DEFAULT_VALUE, + "FILENAME")); op->addTag(TAG_FTP); op->addTag(TAG_HTTP); handlers.push_back(op); } { SharedHandle<OptionHandler> op(new DefaultOptionHandler - (PREF_SERVER_STAT_OF, - TEXT_SERVER_STAT_OF, - NO_DEFAULT_VALUE, - "FILENAME")); + (PREF_SERVER_STAT_OF, + TEXT_SERVER_STAT_OF, + NO_DEFAULT_VALUE, + "FILENAME")); op->addTag(TAG_FTP); op->addTag(TAG_HTTP); handlers.push_back(op); } { SharedHandle<OptionHandler> op(new NumberOptionHandler - (PREF_SERVER_STAT_TIMEOUT, - TEXT_SERVER_STAT_TIMEOUT, - "86400", - 0, INT32_MAX)); + (PREF_SERVER_STAT_TIMEOUT, + TEXT_SERVER_STAT_TIMEOUT, + "86400", + 0, INT32_MAX)); op->addTag(TAG_FTP); op->addTag(TAG_HTTP); handlers.push_back(op); } { SharedHandle<OptionHandler> op(new NumberOptionHandler - (PREF_SPLIT, - TEXT_SPLIT, - "5", - 1, -1, - 's')); + (PREF_SPLIT, + TEXT_SPLIT, + "5", + 1, -1, + 's')); op->addTag(TAG_BASIC); op->addTag(TAG_FTP); op->addTag(TAG_HTTP); @@ -613,20 +613,20 @@ OptionHandlers OptionHandlerFactory::createOptionHandlers() } { SharedHandle<NumberOptionHandler> op(new NumberOptionHandler - (PREF_STARTUP_IDLE_TIME, - NO_DESCRIPTION, - "10", - 1, 60)); + (PREF_STARTUP_IDLE_TIME, + NO_DESCRIPTION, + "10", + 1, 60)); op->hide(); handlers.push_back(op); } { SharedHandle<OptionHandler> op(new NumberOptionHandler - (PREF_TIMEOUT, - TEXT_TIMEOUT, - "60", - 1, 600, - 't')); + (PREF_TIMEOUT, + TEXT_TIMEOUT, + "60", + 1, 600, + 't')); op->addTag(TAG_FTP); op->addTag(TAG_HTTP); handlers.push_back(op); @@ -634,11 +634,11 @@ OptionHandlers OptionHandlerFactory::createOptionHandlers() { const std::string params[] = { V_INORDER, V_FEEDBACK, V_ADAPTIVE }; SharedHandle<OptionHandler> op(new ParameterOptionHandler - (PREF_URI_SELECTOR, - TEXT_URI_SELECTOR, - V_FEEDBACK, - std::deque<std::string> - (¶ms[0], ¶ms[arrayLength(params)]))); + (PREF_URI_SELECTOR, + TEXT_URI_SELECTOR, + V_FEEDBACK, + std::deque<std::string> + (¶ms[0], ¶ms[arrayLength(params)]))); op->addTag(TAG_FTP); op->addTag(TAG_HTTP); handlers.push_back(op); @@ -646,89 +646,89 @@ OptionHandlers OptionHandlerFactory::createOptionHandlers() // HTTP Specific Options { SharedHandle<OptionHandler> op(new DefaultOptionHandler - (PREF_CA_CERTIFICATE, - TEXT_CA_CERTIFICATE, - CA_BUNDLE)); + (PREF_CA_CERTIFICATE, + TEXT_CA_CERTIFICATE, + CA_BUNDLE)); op->addTag(TAG_HTTP); op->addTag(TAG_HTTPS); handlers.push_back(op); } { SharedHandle<OptionHandler> op(new DefaultOptionHandler - (PREF_CERTIFICATE, - TEXT_CERTIFICATE)); + (PREF_CERTIFICATE, + TEXT_CERTIFICATE)); op->addTag(TAG_HTTP); op->addTag(TAG_HTTPS); handlers.push_back(op); } { SharedHandle<OptionHandler> op(new BooleanOptionHandler - (PREF_CHECK_CERTIFICATE, - TEXT_CHECK_CERTIFICATE, - V_TRUE, - OptionHandler::OPT_ARG)); + (PREF_CHECK_CERTIFICATE, + TEXT_CHECK_CERTIFICATE, + V_TRUE, + OptionHandler::OPT_ARG)); op->addTag(TAG_HTTP); op->addTag(TAG_HTTPS); handlers.push_back(op); } { SharedHandle<OptionHandler> op(new BooleanOptionHandler - (PREF_ENABLE_HTTP_KEEP_ALIVE, - TEXT_ENABLE_HTTP_KEEP_ALIVE, - V_TRUE, - OptionHandler::OPT_ARG)); + (PREF_ENABLE_HTTP_KEEP_ALIVE, + TEXT_ENABLE_HTTP_KEEP_ALIVE, + V_TRUE, + OptionHandler::OPT_ARG)); op->addTag(TAG_HTTP); handlers.push_back(op); } { SharedHandle<OptionHandler> op(new BooleanOptionHandler - (PREF_ENABLE_HTTP_PIPELINING, - TEXT_ENABLE_HTTP_PIPELINING, - V_FALSE, - OptionHandler::OPT_ARG)); + (PREF_ENABLE_HTTP_PIPELINING, + TEXT_ENABLE_HTTP_PIPELINING, + V_FALSE, + OptionHandler::OPT_ARG)); op->addTag(TAG_HTTP); handlers.push_back(op); } { SharedHandle<OptionHandler> op(new CumulativeOptionHandler - (PREF_HEADER, - TEXT_HEADER, - NO_DEFAULT_VALUE, - "\n")); + (PREF_HEADER, + TEXT_HEADER, + NO_DEFAULT_VALUE, + "\n")); op->addTag(TAG_HTTP); handlers.push_back(op); } { SharedHandle<OptionHandler> op(new BooleanOptionHandler - (PREF_HTTP_AUTH_CHALLENGE, - TEXT_HTTP_AUTH_CHALLENGE, - V_FALSE, - OptionHandler::OPT_ARG)); + (PREF_HTTP_AUTH_CHALLENGE, + TEXT_HTTP_AUTH_CHALLENGE, + V_FALSE, + OptionHandler::OPT_ARG)); op->addTag(TAG_HTTP); handlers.push_back(op); } { SharedHandle<OptionHandler> op(new DefaultOptionHandler - (PREF_HTTP_PASSWD, - TEXT_HTTP_PASSWD)); + (PREF_HTTP_PASSWD, + TEXT_HTTP_PASSWD)); op->addTag(TAG_BASIC); op->addTag(TAG_HTTP); handlers.push_back(op); } { SharedHandle<OptionHandler> op(new DefaultOptionHandler - (PREF_HTTP_USER, - TEXT_HTTP_USER)); + (PREF_HTTP_USER, + TEXT_HTTP_USER)); op->addTag(TAG_BASIC); op->addTag(TAG_HTTP); handlers.push_back(op); } { SharedHandle<OptionHandler> op(new DefaultOptionHandler - (PREF_LOAD_COOKIES, - TEXT_LOAD_COOKIES, - NO_DEFAULT_VALUE, - "/path/to/file")); + (PREF_LOAD_COOKIES, + TEXT_LOAD_COOKIES, + NO_DEFAULT_VALUE, + "/path/to/file")); op->addTag(TAG_BASIC); op->addTag(TAG_HTTP); op->addTag(TAG_COOKIE); @@ -736,143 +736,143 @@ OptionHandlers OptionHandlerFactory::createOptionHandlers() } { SharedHandle<NumberOptionHandler> op(new NumberOptionHandler - (PREF_MAX_HTTP_PIPELINING, - NO_DESCRIPTION, - "2", - 1, 8)); + (PREF_MAX_HTTP_PIPELINING, + NO_DESCRIPTION, + "2", + 1, 8)); op->hide(); handlers.push_back(op); } { SharedHandle<OptionHandler> op(new DefaultOptionHandler - (PREF_PRIVATE_KEY, - TEXT_PRIVATE_KEY)); + (PREF_PRIVATE_KEY, + TEXT_PRIVATE_KEY)); op->addTag(TAG_HTTP); op->addTag(TAG_HTTPS); handlers.push_back(op); } { SharedHandle<OptionHandler> op(new DefaultOptionHandler - (PREF_REFERER, - TEXT_REFERER)); + (PREF_REFERER, + TEXT_REFERER)); op->addTag(TAG_HTTP); handlers.push_back(op); } { SharedHandle<OptionHandler> op(new DefaultOptionHandler - (PREF_SAVE_COOKIES, - TEXT_SAVE_COOKIES, - NO_DEFAULT_VALUE, - "/path/to/file")); + (PREF_SAVE_COOKIES, + TEXT_SAVE_COOKIES, + NO_DEFAULT_VALUE, + "/path/to/file")); op->addTag(TAG_HTTP); op->addTag(TAG_COOKIE); handlers.push_back(op); } { SharedHandle<OptionHandler> op(new BooleanOptionHandler - (PREF_USE_HEAD, - TEXT_USE_HEAD, - V_FALSE, - OptionHandler::OPT_ARG)); + (PREF_USE_HEAD, + TEXT_USE_HEAD, + V_FALSE, + OptionHandler::OPT_ARG)); op->addTag(TAG_HTTP); handlers.push_back(op); } { SharedHandle<OptionHandler> op(new DefaultOptionHandler - (PREF_USER_AGENT, - TEXT_USER_AGENT, - "aria2/"PACKAGE_VERSION, - A2STR::NIL, - OptionHandler::REQ_ARG, - 'U')); + (PREF_USER_AGENT, + TEXT_USER_AGENT, + "aria2/"PACKAGE_VERSION, + A2STR::NIL, + OptionHandler::REQ_ARG, + 'U')); op->addTag(TAG_HTTP); handlers.push_back(op); } // FTP Specific Options { SharedHandle<OptionHandler> op(new DefaultOptionHandler - (PREF_FTP_PASSWD, - TEXT_FTP_PASSWD)); + (PREF_FTP_PASSWD, + TEXT_FTP_PASSWD)); op->addTag(TAG_BASIC); op->addTag(TAG_FTP); handlers.push_back(op); } { SharedHandle<OptionHandler> op(new BooleanOptionHandler - (PREF_FTP_PASV, - TEXT_FTP_PASV, - V_TRUE, - OptionHandler::OPT_ARG, - 'p')); + (PREF_FTP_PASV, + TEXT_FTP_PASV, + V_TRUE, + OptionHandler::OPT_ARG, + 'p')); op->addTag(TAG_FTP); handlers.push_back(op); } { SharedHandle<OptionHandler> op(new BooleanOptionHandler - (PREF_FTP_REUSE_CONNECTION, - TEXT_FTP_REUSE_CONNECTION, - V_TRUE, - OptionHandler::OPT_ARG)); + (PREF_FTP_REUSE_CONNECTION, + TEXT_FTP_REUSE_CONNECTION, + V_TRUE, + OptionHandler::OPT_ARG)); op->addTag(TAG_FTP); handlers.push_back(op); } { SharedHandle<OptionHandler> op(new ParameterOptionHandler - (PREF_FTP_TYPE, - TEXT_FTP_TYPE, - V_BINARY, - V_BINARY, V_ASCII)); + (PREF_FTP_TYPE, + TEXT_FTP_TYPE, + V_BINARY, + V_BINARY, V_ASCII)); op->addTag(TAG_FTP); handlers.push_back(op); } { SharedHandle<OptionHandler> op(new DefaultOptionHandler - (PREF_FTP_USER, - TEXT_FTP_USER)); + (PREF_FTP_USER, + TEXT_FTP_USER)); op->addTag(TAG_BASIC); op->addTag(TAG_FTP); handlers.push_back(op); } { SharedHandle<DefaultOptionHandler> op(new DefaultOptionHandler - (PREF_NETRC_PATH, - NO_DESCRIPTION, - util::getHomeDir()+"/.netrc", - "/PATH/TO/NETRC")); + (PREF_NETRC_PATH, + NO_DESCRIPTION, + util::getHomeDir()+"/.netrc", + "/PATH/TO/NETRC")); op->hide(); handlers.push_back(op); } // Proxy options { SharedHandle<OptionHandler> op(new HttpProxyOptionHandler - (PREF_HTTP_PROXY, - TEXT_HTTP_PROXY, - NO_DEFAULT_VALUE)); + (PREF_HTTP_PROXY, + TEXT_HTTP_PROXY, + NO_DEFAULT_VALUE)); op->addTag(TAG_HTTP); handlers.push_back(op); } { SharedHandle<OptionHandler> op(new HttpProxyOptionHandler - (PREF_HTTPS_PROXY, - TEXT_HTTPS_PROXY, - NO_DEFAULT_VALUE)); + (PREF_HTTPS_PROXY, + TEXT_HTTPS_PROXY, + NO_DEFAULT_VALUE)); op->addTag(TAG_HTTP); op->addTag(TAG_HTTPS); handlers.push_back(op); } { SharedHandle<OptionHandler> op(new HttpProxyOptionHandler - (PREF_FTP_PROXY, - TEXT_FTP_PROXY, - NO_DEFAULT_VALUE)); + (PREF_FTP_PROXY, + TEXT_FTP_PROXY, + NO_DEFAULT_VALUE)); op->addTag(TAG_FTP); handlers.push_back(op); } { SharedHandle<OptionHandler> op(new HttpProxyOptionHandler - (PREF_ALL_PROXY, - TEXT_ALL_PROXY, - NO_DEFAULT_VALUE)); + (PREF_ALL_PROXY, + TEXT_ALL_PROXY, + NO_DEFAULT_VALUE)); op->addTag(TAG_FTP); op->addTag(TAG_HTTP); op->addTag(TAG_HTTPS); @@ -880,8 +880,8 @@ OptionHandlers OptionHandlerFactory::createOptionHandlers() } { SharedHandle<OptionHandler> op(new DefaultOptionHandler - (PREF_NO_PROXY, - TEXT_NO_PROXY)); + (PREF_NO_PROXY, + TEXT_NO_PROXY)); op->addTag(TAG_FTP); op->addTag(TAG_HTTP); op->addTag(TAG_HTTPS); @@ -889,10 +889,10 @@ OptionHandlers OptionHandlerFactory::createOptionHandlers() } { SharedHandle<OptionHandler> op(new ParameterOptionHandler - (PREF_PROXY_METHOD, - TEXT_PROXY_METHOD, - V_GET, - V_GET, V_TUNNEL)); + (PREF_PROXY_METHOD, + TEXT_PROXY_METHOD, + V_GET, + V_GET, V_TUNNEL)); op->addTag(TAG_FTP); op->addTag(TAG_HTTP); handlers.push_back(op); @@ -901,21 +901,21 @@ OptionHandlers OptionHandlerFactory::createOptionHandlers() #if defined ENABLE_BITTORRENT || defined ENABLE_METALINK { SharedHandle<OptionHandler> op(new IntegerRangeOptionHandler - (PREF_SELECT_FILE, - TEXT_SELECT_FILE, - NO_DEFAULT_VALUE, - 1, INT32_MAX)); + (PREF_SELECT_FILE, + TEXT_SELECT_FILE, + NO_DEFAULT_VALUE, + 1, INT32_MAX)); op->addTag(TAG_BITTORRENT); op->addTag(TAG_METALINK); handlers.push_back(op); } { SharedHandle<OptionHandler> op(new BooleanOptionHandler - (PREF_SHOW_FILES, - TEXT_SHOW_FILES, - V_FALSE, // TODO ommit? - OptionHandler::NO_ARG, - 'S')); + (PREF_SHOW_FILES, + TEXT_SHOW_FILES, + V_FALSE, // TODO ommit? + OptionHandler::NO_ARG, + 'S')); op->addTag(TAG_BASIC); op->addTag(TAG_BITTORRENT); op->addTag(TAG_METALINK); @@ -926,275 +926,275 @@ OptionHandlers OptionHandlerFactory::createOptionHandlers() #ifdef ENABLE_BITTORRENT { SharedHandle<OptionHandler> op(new DefaultOptionHandler - (PREF_BT_EXTERNAL_IP, - TEXT_BT_EXTERNAL_IP, - NO_DEFAULT_VALUE, - "a numeric IP address")); + (PREF_BT_EXTERNAL_IP, + TEXT_BT_EXTERNAL_IP, + NO_DEFAULT_VALUE, + "a numeric IP address")); op->addTag(TAG_BITTORRENT); handlers.push_back(op); } { SharedHandle<NumberOptionHandler> op(new NumberOptionHandler - (PREF_BT_KEEP_ALIVE_INTERVAL, - NO_DESCRIPTION, - "120", - 1, 120)); + (PREF_BT_KEEP_ALIVE_INTERVAL, + NO_DESCRIPTION, + "120", + 1, 120)); op->hide(); handlers.push_back(op); } { SharedHandle<OptionHandler> op(new BooleanOptionHandler - (PREF_BT_HASH_CHECK_SEED, - TEXT_BT_HASH_CHECK_SEED, - V_TRUE, - OptionHandler::OPT_ARG)); + (PREF_BT_HASH_CHECK_SEED, + TEXT_BT_HASH_CHECK_SEED, + V_TRUE, + OptionHandler::OPT_ARG)); op->addTag(TAG_BITTORRENT); handlers.push_back(op); } { SharedHandle<OptionHandler> op(new NumberOptionHandler - (PREF_BT_MAX_OPEN_FILES, - TEXT_BT_MAX_OPEN_FILES, - "100", - 1)); + (PREF_BT_MAX_OPEN_FILES, + TEXT_BT_MAX_OPEN_FILES, + "100", + 1)); op->addTag(TAG_BITTORRENT); handlers.push_back(op); } { SharedHandle<OptionHandler> op(new NumberOptionHandler - (PREF_BT_MAX_PEERS, - TEXT_BT_MAX_PEERS, - "55", - 0)); + (PREF_BT_MAX_PEERS, + TEXT_BT_MAX_PEERS, + "55", + 0)); op->addTag(TAG_BITTORRENT); handlers.push_back(op); - + } { SharedHandle<OptionHandler> op(new ParameterOptionHandler - (PREF_BT_MIN_CRYPTO_LEVEL, - TEXT_BT_MIN_CRYPTO_LEVEL, - V_PLAIN, - V_PLAIN, V_ARC4)); + (PREF_BT_MIN_CRYPTO_LEVEL, + TEXT_BT_MIN_CRYPTO_LEVEL, + V_PLAIN, + V_PLAIN, V_ARC4)); op->addTag(TAG_BITTORRENT); handlers.push_back(op); } { SharedHandle<OptionHandler> op(new PrioritizePieceOptionHandler - (PREF_BT_PRIORITIZE_PIECE, - TEXT_BT_PRIORITIZE_PIECE)); + (PREF_BT_PRIORITIZE_PIECE, + TEXT_BT_PRIORITIZE_PIECE)); op->addTag(TAG_BITTORRENT); handlers.push_back(op); } { SharedHandle<OptionHandler> op(new UnitNumberOptionHandler - (PREF_BT_REQUEST_PEER_SPEED_LIMIT, - TEXT_BT_REQUEST_PEER_SPEED_LIMIT, - "50K", - 0)); + (PREF_BT_REQUEST_PEER_SPEED_LIMIT, + TEXT_BT_REQUEST_PEER_SPEED_LIMIT, + "50K", + 0)); op->addTag(TAG_BITTORRENT); handlers.push_back(op); } { SharedHandle<OptionHandler> op(new BooleanOptionHandler - (PREF_BT_REQUIRE_CRYPTO, - TEXT_BT_REQUIRE_CRYPTO, - V_FALSE)); + (PREF_BT_REQUIRE_CRYPTO, + TEXT_BT_REQUIRE_CRYPTO, + V_FALSE)); op->addTag(TAG_BITTORRENT); handlers.push_back(op); } { SharedHandle<NumberOptionHandler> op(new NumberOptionHandler - (PREF_BT_REQUEST_TIMEOUT, - NO_DESCRIPTION, - "60", - 1, 600)); + (PREF_BT_REQUEST_TIMEOUT, + NO_DESCRIPTION, + "60", + 1, 600)); op->hide(); handlers.push_back(op); } { SharedHandle<OptionHandler> op(new BooleanOptionHandler - (PREF_BT_SEED_UNVERIFIED, - TEXT_BT_SEED_UNVERIFIED, - V_FALSE, - OptionHandler::OPT_ARG)); + (PREF_BT_SEED_UNVERIFIED, + TEXT_BT_SEED_UNVERIFIED, + V_FALSE, + OptionHandler::OPT_ARG)); op->addTag(TAG_BITTORRENT); handlers.push_back(op); } { SharedHandle<OptionHandler> op(new BooleanOptionHandler - (PREF_BT_SAVE_METADATA, - TEXT_BT_SAVE_METADATA, - V_FALSE, - OptionHandler::OPT_ARG)); + (PREF_BT_SAVE_METADATA, + TEXT_BT_SAVE_METADATA, + V_FALSE, + OptionHandler::OPT_ARG)); op->addTag(TAG_BITTORRENT); handlers.push_back(op); } { SharedHandle<OptionHandler> op(new NumberOptionHandler - (PREF_BT_STOP_TIMEOUT, - TEXT_BT_STOP_TIMEOUT, - "0", - 0)); + (PREF_BT_STOP_TIMEOUT, + TEXT_BT_STOP_TIMEOUT, + "0", + 0)); op->addTag(TAG_BITTORRENT); handlers.push_back(op); } { SharedHandle<NumberOptionHandler> op(new NumberOptionHandler - (PREF_BT_TIMEOUT, - NO_DESCRIPTION, - "180", - 1, 600)); + (PREF_BT_TIMEOUT, + NO_DESCRIPTION, + "180", + 1, 600)); op->hide(); handlers.push_back(op); } { SharedHandle<NumberOptionHandler> op(new NumberOptionHandler - (PREF_BT_TRACKER_INTERVAL, - TEXT_BT_TRACKER_INTERVAL, - "0", - 0)); + (PREF_BT_TRACKER_INTERVAL, + TEXT_BT_TRACKER_INTERVAL, + "0", + 0)); op->addTag(TAG_BITTORRENT); handlers.push_back(op); } { SharedHandle<OptionHandler> op(new HostPortOptionHandler - (PREF_DHT_ENTRY_POINT, - TEXT_DHT_ENTRY_POINT, - NO_DEFAULT_VALUE, - PREF_DHT_ENTRY_POINT_HOST, - PREF_DHT_ENTRY_POINT_PORT)); + (PREF_DHT_ENTRY_POINT, + TEXT_DHT_ENTRY_POINT, + NO_DEFAULT_VALUE, + PREF_DHT_ENTRY_POINT_HOST, + PREF_DHT_ENTRY_POINT_PORT)); op->addTag(TAG_BITTORRENT); handlers.push_back(op); } { SharedHandle<OptionHandler> op(new DefaultOptionHandler - (PREF_DHT_FILE_PATH, - TEXT_DHT_FILE_PATH, - util::getHomeDir()+"/.aria2/dht.dat", - "/PATH/TO/DHT_DAT")); + (PREF_DHT_FILE_PATH, + TEXT_DHT_FILE_PATH, + util::getHomeDir()+"/.aria2/dht.dat", + "/PATH/TO/DHT_DAT")); op->addTag(TAG_BITTORRENT); handlers.push_back(op); } { SharedHandle<OptionHandler> op(new IntegerRangeOptionHandler - (PREF_DHT_LISTEN_PORT, - TEXT_DHT_LISTEN_PORT, - "6881-6999", - 1024, UINT16_MAX)); + (PREF_DHT_LISTEN_PORT, + TEXT_DHT_LISTEN_PORT, + "6881-6999", + 1024, UINT16_MAX)); op->addTag(TAG_BASIC); op->addTag(TAG_BITTORRENT); handlers.push_back(op); } { SharedHandle<OptionHandler> op(new BooleanOptionHandler - (PREF_ENABLE_DHT, - TEXT_ENABLE_DHT, - V_TRUE, - OptionHandler::OPT_ARG)); + (PREF_ENABLE_DHT, + TEXT_ENABLE_DHT, + V_TRUE, + OptionHandler::OPT_ARG)); op->addTag(TAG_BASIC); op->addTag(TAG_BITTORRENT); handlers.push_back(op); } { SharedHandle<OptionHandler> op(new BooleanOptionHandler - (PREF_ENABLE_PEER_EXCHANGE, - TEXT_ENABLE_PEER_EXCHANGE, - V_TRUE, - OptionHandler::OPT_ARG)); + (PREF_ENABLE_PEER_EXCHANGE, + TEXT_ENABLE_PEER_EXCHANGE, + V_TRUE, + OptionHandler::OPT_ARG)); op->addTag(TAG_BITTORRENT); handlers.push_back(op); } { SharedHandle<OptionHandler> op(new ParameterOptionHandler - (PREF_FOLLOW_TORRENT, - TEXT_FOLLOW_TORRENT, - V_TRUE, - V_TRUE, V_MEM, V_FALSE)); + (PREF_FOLLOW_TORRENT, + TEXT_FOLLOW_TORRENT, + V_TRUE, + V_TRUE, V_MEM, V_FALSE)); op->addTag(TAG_BITTORRENT); handlers.push_back(op); } { SharedHandle<OptionHandler> op(new IndexOutOptionHandler - (PREF_INDEX_OUT, - TEXT_INDEX_OUT, - 'O')); + (PREF_INDEX_OUT, + TEXT_INDEX_OUT, + 'O')); op->addTag(TAG_BITTORRENT); handlers.push_back(op); } { SharedHandle<OptionHandler> op(new IntegerRangeOptionHandler - (PREF_LISTEN_PORT, - TEXT_LISTEN_PORT, - "6881-6999", - 1024, UINT16_MAX)); + (PREF_LISTEN_PORT, + TEXT_LISTEN_PORT, + "6881-6999", + 1024, UINT16_MAX)); op->addTag(TAG_BASIC); op->addTag(TAG_BITTORRENT); handlers.push_back(op); } { SharedHandle<OptionHandler> op(new UnitNumberOptionHandler - (PREF_MAX_OVERALL_UPLOAD_LIMIT, - TEXT_MAX_OVERALL_UPLOAD_LIMIT, - "0", - 0)); + (PREF_MAX_OVERALL_UPLOAD_LIMIT, + TEXT_MAX_OVERALL_UPLOAD_LIMIT, + "0", + 0)); op->addTag(TAG_BASIC); op->addTag(TAG_BITTORRENT); handlers.push_back(op); } { SharedHandle<OptionHandler> op(new UnitNumberOptionHandler - (PREF_MAX_UPLOAD_LIMIT, - TEXT_MAX_UPLOAD_LIMIT, - "0", - 0, -1, - 'u')); + (PREF_MAX_UPLOAD_LIMIT, + TEXT_MAX_UPLOAD_LIMIT, + "0", + 0, -1, + 'u')); op->addTag(TAG_BASIC); op->addTag(TAG_BITTORRENT); handlers.push_back(op); } { SharedHandle<NumberOptionHandler> op(new NumberOptionHandler - (PREF_PEER_CONNECTION_TIMEOUT, - NO_DESCRIPTION, - "20", - 1, 600)); + (PREF_PEER_CONNECTION_TIMEOUT, + NO_DESCRIPTION, + "20", + 1, 600)); op->hide(); handlers.push_back(op); } { SharedHandle<OptionHandler> op(new DefaultOptionHandler - (PREF_PEER_ID_PREFIX, - TEXT_PEER_ID_PREFIX, - "aria2/"PACKAGE_VERSION"-")); + (PREF_PEER_ID_PREFIX, + TEXT_PEER_ID_PREFIX, + "aria2/"PACKAGE_VERSION"-")); op->addTag(TAG_BITTORRENT); handlers.push_back(op); } { SharedHandle<OptionHandler> op(new NumberOptionHandler - (PREF_SEED_TIME, - TEXT_SEED_TIME, - NO_DEFAULT_VALUE, - 0)); + (PREF_SEED_TIME, + TEXT_SEED_TIME, + NO_DEFAULT_VALUE, + 0)); op->addTag(TAG_BITTORRENT); handlers.push_back(op); } { SharedHandle<OptionHandler> op(new FloatNumberOptionHandler - (PREF_SEED_RATIO, - TEXT_SEED_RATIO, - "1.0", - 0.0)); + (PREF_SEED_RATIO, + TEXT_SEED_RATIO, + "1.0", + 0.0)); op->addTag(TAG_BITTORRENT); handlers.push_back(op); } { SharedHandle<OptionHandler> op(new LocalFilePathOptionHandler - (PREF_TORRENT_FILE, - TEXT_TORRENT_FILE, - NO_DEFAULT_VALUE, - false, - 'T')); + (PREF_TORRENT_FILE, + TEXT_TORRENT_FILE, + NO_DEFAULT_VALUE, + false, + 'T')); op->addTag(TAG_BASIC); op->addTag(TAG_BITTORRENT); handlers.push_back(op); @@ -1204,79 +1204,79 @@ OptionHandlers OptionHandlerFactory::createOptionHandlers() #ifdef ENABLE_METALINK { SharedHandle<OptionHandler> op(new ParameterOptionHandler - (PREF_FOLLOW_METALINK, - TEXT_FOLLOW_METALINK, - V_TRUE, - V_TRUE, V_MEM, V_FALSE)); + (PREF_FOLLOW_METALINK, + TEXT_FOLLOW_METALINK, + V_TRUE, + V_TRUE, V_MEM, V_FALSE)); op->addTag(TAG_METALINK); handlers.push_back(op); } { SharedHandle<OptionHandler> op(new BooleanOptionHandler - (PREF_METALINK_ENABLE_UNIQUE_PROTOCOL, - TEXT_METALINK_ENABLE_UNIQUE_PROTOCOL, - V_TRUE, - OptionHandler::OPT_ARG)); + (PREF_METALINK_ENABLE_UNIQUE_PROTOCOL, + TEXT_METALINK_ENABLE_UNIQUE_PROTOCOL, + V_TRUE, + OptionHandler::OPT_ARG)); op->addTag(TAG_METALINK); handlers.push_back(op); } { SharedHandle<OptionHandler> op(new LocalFilePathOptionHandler - (PREF_METALINK_FILE, - TEXT_METALINK_FILE, - NO_DEFAULT_VALUE, - true, - 'M')); + (PREF_METALINK_FILE, + TEXT_METALINK_FILE, + NO_DEFAULT_VALUE, + true, + 'M')); op->addTag(TAG_BASIC); op->addTag(TAG_METALINK); handlers.push_back(op); } { SharedHandle<OptionHandler> op(new DefaultOptionHandler - (PREF_METALINK_LANGUAGE, - TEXT_METALINK_LANGUAGE)); + (PREF_METALINK_LANGUAGE, + TEXT_METALINK_LANGUAGE)); op->addTag(TAG_METALINK); handlers.push_back(op); } { SharedHandle<OptionHandler> op(new DefaultOptionHandler - (PREF_METALINK_LOCATION, - TEXT_METALINK_LOCATION)); + (PREF_METALINK_LOCATION, + TEXT_METALINK_LOCATION)); op->addTag(TAG_METALINK); handlers.push_back(op); } { SharedHandle<OptionHandler> op(new DefaultOptionHandler - (PREF_METALINK_OS, - TEXT_METALINK_OS)); + (PREF_METALINK_OS, + TEXT_METALINK_OS)); op->addTag(TAG_METALINK); handlers.push_back(op); } { const std::string params[] = { V_HTTP, V_HTTPS, V_FTP, V_NONE }; SharedHandle<OptionHandler> op(new ParameterOptionHandler - (PREF_METALINK_PREFERRED_PROTOCOL, - TEXT_METALINK_PREFERRED_PROTOCOL, - V_NONE, - std::deque<std::string> - (¶ms[0], ¶ms[arrayLength(params)]))); + (PREF_METALINK_PREFERRED_PROTOCOL, + TEXT_METALINK_PREFERRED_PROTOCOL, + V_NONE, + std::deque<std::string> + (¶ms[0], ¶ms[arrayLength(params)]))); op->addTag(TAG_METALINK); handlers.push_back(op); } { SharedHandle<OptionHandler> op(new NumberOptionHandler - (PREF_METALINK_SERVERS, - TEXT_METALINK_SERVERS, - "5", - 1, -1, - 'C')); + (PREF_METALINK_SERVERS, + TEXT_METALINK_SERVERS, + "5", + 1, -1, + 'C')); op->addTag(TAG_METALINK); handlers.push_back(op); } { SharedHandle<OptionHandler> op(new DefaultOptionHandler - (PREF_METALINK_VERSION, - TEXT_METALINK_VERSION)); + (PREF_METALINK_VERSION, + TEXT_METALINK_VERSION)); op->addTag(TAG_METALINK); handlers.push_back(op); } @@ -1284,40 +1284,40 @@ OptionHandlers OptionHandlerFactory::createOptionHandlers() // Version Option { SharedHandle<OptionHandler> op(new DefaultOptionHandler - ("version", - TEXT_VERSION, - NO_DEFAULT_VALUE, - A2STR::NIL, - OptionHandler::NO_ARG, - 'v')); + ("version", + TEXT_VERSION, + NO_DEFAULT_VALUE, + A2STR::NIL, + OptionHandler::NO_ARG, + 'v')); op->addTag(TAG_BASIC); handlers.push_back(op); } // Help Option { SharedHandle<OptionHandler> op(new DefaultOptionHandler - ("help", - TEXT_HELP, - TAG_BASIC, - StringFormat - ("%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, " - "%s, %s, %s, %s", - TAG_BASIC, - TAG_ADVANCED, - TAG_HTTP, - TAG_HTTPS, - TAG_FTP, - TAG_METALINK, - TAG_BITTORRENT, - TAG_COOKIE, - TAG_HOOK, - TAG_FILE, - TAG_XML_RPC, - TAG_EXPERIMENTAL, - TAG_HELP, - TAG_ALL).str(), - OptionHandler::OPT_ARG, - 'h')); + ("help", + TEXT_HELP, + TAG_BASIC, + StringFormat + ("%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, " + "%s, %s, %s, %s", + TAG_BASIC, + TAG_ADVANCED, + TAG_HTTP, + TAG_HTTPS, + TAG_FTP, + TAG_METALINK, + TAG_BITTORRENT, + TAG_COOKIE, + TAG_HOOK, + TAG_FILE, + TAG_XML_RPC, + TAG_EXPERIMENTAL, + TAG_HELP, + TAG_ALL).str(), + OptionHandler::OPT_ARG, + 'h')); op->addTag(TAG_BASIC); op->addTag(TAG_HELP); handlers.push_back(op); diff --git a/src/OptionHandlerFactory.h b/src/OptionHandlerFactory.h index d8d6d448..961931cf 100644 --- a/src/OptionHandlerFactory.h +++ b/src/OptionHandlerFactory.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/OptionHandlerImpl.h b/src/OptionHandlerImpl.h index 6b64f717..3735956f 100644 --- a/src/OptionHandlerImpl.h +++ b/src/OptionHandlerImpl.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -112,12 +112,12 @@ public: class BooleanOptionHandler : public NameMatchOptionHandler { public: BooleanOptionHandler(const std::string& optName, - const std::string& description = NO_DESCRIPTION, - const std::string& defaultValue = NO_DEFAULT_VALUE, - OptionHandler::ARG_TYPE argType = OptionHandler::REQ_ARG, - char shortName = 0): + const std::string& description = NO_DESCRIPTION, + const std::string& defaultValue = NO_DEFAULT_VALUE, + OptionHandler::ARG_TYPE argType = OptionHandler::REQ_ARG, + char shortName = 0): NameMatchOptionHandler(optName, description, defaultValue, - argType, shortName) {} + argType, shortName) {} virtual ~BooleanOptionHandler() {} @@ -125,8 +125,8 @@ public: { if(optarg == "true" || ((_argType == OptionHandler::OPT_ARG || - _argType == OptionHandler::NO_ARG) - && optarg.empty())) { + _argType == OptionHandler::NO_ARG) + && optarg.empty())) { option.put(_optName, V_TRUE); } else if(optarg == "false") { option.put(_optName, V_FALSE); @@ -149,12 +149,12 @@ private: int32_t _max; public: IntegerRangeOptionHandler(const std::string& optName, - const std::string& description, - const std::string& defaultValue, - int32_t min, int32_t max, - char shortName = 0): + const std::string& description, + const std::string& defaultValue, + int32_t min, int32_t max, + char shortName = 0): NameMatchOptionHandler(optName, description, defaultValue, - OptionHandler::REQ_ARG, shortName), + OptionHandler::REQ_ARG, shortName), _min(min), _max(max) {} virtual ~IntegerRangeOptionHandler() {} @@ -165,11 +165,11 @@ public: 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()); + 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()); } option.put(_optName, optarg); } @@ -187,13 +187,13 @@ private: int64_t _max; public: NumberOptionHandler(const std::string& optName, - const std::string& description = NO_DESCRIPTION, - const std::string& defaultValue = NO_DEFAULT_VALUE, - int64_t min = -1, - int64_t max = -1, - char shortName = 0): + const std::string& description = NO_DESCRIPTION, + const std::string& defaultValue = NO_DEFAULT_VALUE, + int64_t min = -1, + int64_t max = -1, + char shortName = 0): NameMatchOptionHandler(optName, description, defaultValue, - OptionHandler::REQ_ARG, shortName), + OptionHandler::REQ_ARG, shortName), _min(min), _max(max) {} virtual ~NumberOptionHandler() {} @@ -212,16 +212,16 @@ public: 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(); + msg += StringFormat(_("must be smaller than or equal to %s."), + 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(); + msg += StringFormat(_("must be between %s and %s."), + 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(); + msg += StringFormat(_("must be greater than or equal to %s."), + util::itos(_min).c_str()).str(); } else { - msg += _("must be a number."); + msg += _("must be a number."); } throw DL_ABORT_EX(msg); } @@ -248,13 +248,13 @@ public: class UnitNumberOptionHandler : public NumberOptionHandler { public: UnitNumberOptionHandler(const std::string& optName, - const std::string& description = NO_DESCRIPTION, - const std::string& defaultValue = NO_DEFAULT_VALUE, - int64_t min = -1, - int64_t max = -1, - char shortName = 0): + const std::string& description = NO_DESCRIPTION, + const std::string& defaultValue = NO_DEFAULT_VALUE, + int64_t min = -1, + int64_t max = -1, + char shortName = 0): NumberOptionHandler(optName, description, defaultValue, min, max, - shortName) {} + shortName) {} virtual ~UnitNumberOptionHandler() {} @@ -271,12 +271,12 @@ private: double _max; public: FloatNumberOptionHandler(const std::string& optName, - const std::string& description = NO_DESCRIPTION, - const std::string& defaultValue = NO_DEFAULT_VALUE, - double min = -1, double max = -1, - char shortName = 0): + const std::string& description = NO_DESCRIPTION, + const std::string& defaultValue = NO_DEFAULT_VALUE, + double min = -1, double max = -1, + char shortName = 0): NameMatchOptionHandler(optName, description, defaultValue, - OptionHandler::REQ_ARG, shortName), + OptionHandler::REQ_ARG, shortName), _min(min), _max(max) {} virtual ~FloatNumberOptionHandler() {} @@ -290,16 +290,16 @@ public: std::string msg = _optName; msg += " "; if(_min < 0 && _max >= 0) { - msg += StringFormat(_("must be smaller than or equal to %.1f."), - _max).str(); + msg += StringFormat(_("must be smaller than or equal to %.1f."), + _max).str(); } else if(_min >= 0 && _max >= 0) { - msg += StringFormat(_("must be between %.1f and %.1f."), - _min, _max).str(); + msg += StringFormat(_("must be between %.1f and %.1f."), + _min, _max).str(); } else if(_min >= 0 && _max < 0) { - msg += StringFormat(_("must be greater than or equal to %.1f."), - _min).str(); + msg += StringFormat(_("must be greater than or equal to %.1f."), + _min).str(); } else { - msg += _("must be a number."); + msg += _("must be a number."); } throw DL_ABORT_EX(msg); } @@ -332,13 +332,13 @@ private: std::string _possibleValuesString; public: DefaultOptionHandler(const std::string& optName, - const std::string& description = NO_DESCRIPTION, - const std::string& defaultValue = NO_DEFAULT_VALUE, - const std::string& possibleValuesString = A2STR::NIL, - OptionHandler::ARG_TYPE argType = OptionHandler::REQ_ARG, - char shortName = 0): + const std::string& description = NO_DESCRIPTION, + const std::string& defaultValue = NO_DEFAULT_VALUE, + const std::string& possibleValuesString = A2STR::NIL, + OptionHandler::ARG_TYPE argType = OptionHandler::REQ_ARG, + char shortName = 0): NameMatchOptionHandler(optName, description, defaultValue, argType, - shortName), + shortName), _possibleValuesString(possibleValuesString) {} virtual ~DefaultOptionHandler() {} @@ -361,15 +361,15 @@ private: std::string _possibleValuesString; public: CumulativeOptionHandler(const std::string& optName, - const std::string& description, - const std::string& defaultValue, - const std::string& delim, - const std::string& possibleValuesString = A2STR::NIL, - OptionHandler::ARG_TYPE argType = - OptionHandler::REQ_ARG, - char shortName = 0): + const std::string& description, + const std::string& defaultValue, + const std::string& delim, + const std::string& possibleValuesString = A2STR::NIL, + OptionHandler::ARG_TYPE argType = + OptionHandler::REQ_ARG, + char shortName = 0): NameMatchOptionHandler(optName, description, defaultValue, argType, - shortName), + shortName), _delim(delim), _possibleValuesString(possibleValuesString) {} @@ -392,10 +392,10 @@ class IndexOutOptionHandler : public NameMatchOptionHandler { private: public: IndexOutOptionHandler(const std::string& optName, - const std::string& description, - char shortName = 0): + const std::string& description, + char shortName = 0): NameMatchOptionHandler(optName, description, NO_DEFAULT_VALUE, - OptionHandler::REQ_ARG, shortName) {} + OptionHandler::REQ_ARG, shortName) {} virtual ~IndexOutOptionHandler() {} @@ -419,47 +419,47 @@ private: std::deque<std::string> _validParamValues; public: ParameterOptionHandler(const std::string& optName, - const std::string& description, - const std::string& defaultValue, - const std::deque<std::string>& validParamValues, - char shortName = 0): + const std::string& description, + const std::string& defaultValue, + const std::deque<std::string>& validParamValues, + char shortName = 0): NameMatchOptionHandler(optName, description, defaultValue, - OptionHandler::REQ_ARG, shortName), + OptionHandler::REQ_ARG, shortName), _validParamValues(validParamValues) {} ParameterOptionHandler(const std::string& optName, - const std::string& description, - const std::string& defaultValue, - const std::string& validParamValue, - char shortName = 0): + const std::string& description, + const std::string& defaultValue, + const std::string& validParamValue, + char shortName = 0): NameMatchOptionHandler(optName, description, defaultValue, - OptionHandler::REQ_ARG, shortName) + OptionHandler::REQ_ARG, shortName) { _validParamValues.push_back(validParamValue); } ParameterOptionHandler(const std::string& optName, - const std::string& description, - const std::string& defaultValue, - const std::string& validParamValue1, - const std::string& validParamValue2, - char shortName = 0): + const std::string& description, + const std::string& defaultValue, + const std::string& validParamValue1, + const std::string& validParamValue2, + char shortName = 0): NameMatchOptionHandler(optName, description, defaultValue, - OptionHandler::REQ_ARG, shortName) + OptionHandler::REQ_ARG, shortName) { _validParamValues.push_back(validParamValue1); _validParamValues.push_back(validParamValue2); } ParameterOptionHandler(const std::string& optName, - const std::string& description, - const std::string& defaultValue, - const std::string& validParamValue1, - const std::string& validParamValue2, - const std::string& validParamValue3, - char shortName = 0): + const std::string& description, + const std::string& defaultValue, + const std::string& validParamValue1, + const std::string& validParamValue2, + const std::string& validParamValue3, + char shortName = 0): NameMatchOptionHandler(optName, description, defaultValue, - OptionHandler::REQ_ARG, shortName) + OptionHandler::REQ_ARG, shortName) { _validParamValues.push_back(validParamValue1); _validParamValues.push_back(validParamValue2); @@ -476,12 +476,12 @@ public: std::string msg = _optName; strappend(msg, " ", _("must be one of the following:")); if(_validParamValues.size() == 0) { - msg += "''"; + msg += "''"; } else { - for(std::deque<std::string>::const_iterator itr = _validParamValues.begin(); - itr != _validParamValues.end(); ++itr) { - strappend(msg, "'", *itr, "' "); - } + for(std::deque<std::string>::const_iterator itr = _validParamValues.begin(); + itr != _validParamValues.end(); ++itr) { + strappend(msg, "'", *itr, "' "); + } } throw DL_ABORT_EX(msg); } else { @@ -493,7 +493,7 @@ public: { std::stringstream s; std::copy(_validParamValues.begin(), _validParamValues.end(), - std::ostream_iterator<std::string>(s, ",")); + std::ostream_iterator<std::string>(s, ",")); return util::trim(s.str(), ", "); } }; @@ -505,13 +505,13 @@ private: std::string _portOptionName; public: HostPortOptionHandler(const std::string& optName, - const std::string& description, - const std::string& defaultValue, - const std::string& hostOptionName, - const std::string& portOptionName, - char shortName = 0): + const std::string& description, + const std::string& defaultValue, + const std::string& hostOptionName, + const std::string& portOptionName, + char shortName = 0): NameMatchOptionHandler(optName, description, defaultValue, - OptionHandler::REQ_ARG, shortName), + OptionHandler::REQ_ARG, shortName), _hostOptionName(hostOptionName), _portOptionName(portOptionName) {} @@ -544,12 +544,12 @@ public: class HttpProxyOptionHandler : public NameMatchOptionHandler { public: HttpProxyOptionHandler(const std::string& optName, - const std::string& description, - const std::string& defaultValue, - char shortName = 0) + const std::string& description, + const std::string& defaultValue, + char shortName = 0) : NameMatchOptionHandler(optName, description, defaultValue, - OptionHandler::REQ_ARG, shortName) + OptionHandler::REQ_ARG, shortName) {} virtual ~HttpProxyOptionHandler() {} @@ -587,8 +587,8 @@ public: bool acceptStdin = false, char shortName = 0): NameMatchOptionHandler(optName, description, defaultValue, - OptionHandler::REQ_ARG, - shortName), + OptionHandler::REQ_ARG, + shortName), _acceptStdin(acceptStdin) {} virtual void parseArg(Option& option, const std::string& optarg) @@ -598,8 +598,8 @@ public: } else { File f(optarg); if(!f.exists() || f.isDir()) { - throw DL_ABORT_EX - (StringFormat(MSG_NOT_FILE, optarg.c_str()).str()); + throw DL_ABORT_EX + (StringFormat(MSG_NOT_FILE, optarg.c_str()).str()); } option.put(_optName, optarg); } @@ -619,7 +619,7 @@ public: const std::string& defaultValue = NO_DEFAULT_VALUE, char shortName = 0): NameMatchOptionHandler(optName, description, defaultValue, - OptionHandler::REQ_ARG, shortName) {} + OptionHandler::REQ_ARG, shortName) {} virtual void parseArg(Option& option, const std::string& optarg) { diff --git a/src/OptionParser.cc b/src/OptionParser.cc index 0a37a587..5216bd60 100644 --- a/src/OptionParser.cc +++ b/src/OptionParser.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -67,7 +67,7 @@ static size_t countPublicOption(InputIterator first, InputIterator last) template<typename InputIterator> static void putOptions(struct option* longOpts, int* plopt, - InputIterator first, InputIterator last) + InputIterator first, InputIterator last) { for(; first != last; ++first) { if(!(*first)->isHidden()) { @@ -78,23 +78,23 @@ static void putOptions(struct option* longOpts, int* plopt, #endif // !HAVE_OPTION_CONST_NAME switch((*first)->getArgType()) { case OptionHandler::REQ_ARG: - (*longOpts).has_arg = required_argument; - break; + (*longOpts).has_arg = required_argument; + break; case OptionHandler::OPT_ARG: - (*longOpts).has_arg = optional_argument; - break; + (*longOpts).has_arg = optional_argument; + break; case OptionHandler::NO_ARG: - (*longOpts).has_arg = no_argument; - break; + (*longOpts).has_arg = no_argument; + break; default: - abort(); + abort(); } if((*first)->getShortName() == 0) { - (*longOpts).flag = plopt; - (*longOpts).val = (*first)->getOptionID(); + (*longOpts).flag = plopt; + (*longOpts).val = (*first)->getOptionID(); } else { - (*longOpts).flag = 0; - (*longOpts).val = (*first)->getShortName(); + (*longOpts).flag = 0; + (*longOpts).val = (*first)->getShortName(); } ++longOpts; } @@ -112,12 +112,12 @@ static std::string createOptstring(InputIterator first, InputIterator last) for(; first != last; ++first) { if(!(*first)->isHidden()) { if((*first)->getShortName() != 0) { - str += (*first)->getShortName(); - if((*first)->getArgType() == OptionHandler::REQ_ARG) { - str += ":"; - } else if((*first)->getArgType() == OptionHandler::OPT_ARG) { - str += "::"; - } + str += (*first)->getShortName(); + if((*first)->getArgType() == OptionHandler::REQ_ARG) { + str += ":"; + } else if((*first)->getArgType() == OptionHandler::OPT_ARG) { + str += "::"; + } } } } @@ -128,12 +128,12 @@ void OptionParser::parseArg (std::ostream& out, std::deque<std::string>& nonopts, int argc, char* const argv[]) { size_t numPublicOption = countPublicOption(_optionHandlers.begin(), - _optionHandlers.end()); + _optionHandlers.end()); int lopt; array_ptr<struct option> longOpts(new struct option[numPublicOption+1]); putOptions(longOpts, &lopt,_optionHandlers.begin(),_optionHandlers.end()); std::string optstring = createOptstring(_optionHandlers.begin(), - _optionHandlers.end()); + _optionHandlers.end()); while(1) { int c = getopt_long(argc, argv, optstring.c_str(), longOpts, 0); if(c == -1) { @@ -190,7 +190,7 @@ OptionHandlerHandle OptionParser::getOptionHandlerByName SharedHandle<OptionHandler> handler(new DummyOptionHandler(optName)); std::vector<SharedHandle<OptionHandler> >::const_iterator i = std::lower_bound(_optionHandlers.begin(), _optionHandlers.end(), - handler, OptionHandlerNameLesser()); + handler, OptionHandlerNameLesser()); if(i == _optionHandlers.end()) { handler.reset(new NullOptionHandler()); } else { @@ -204,11 +204,11 @@ void OptionParser::setOptionHandlers { _optionHandlers = optionHandlers; for(std::vector<SharedHandle<OptionHandler> >::iterator i = - _optionHandlers.begin(); i != _optionHandlers.end(); ++i) { + _optionHandlers.begin(); i != _optionHandlers.end(); ++i) { (*i)->setOptionID(++_idCounter); } std::sort(_optionHandlers.begin(), _optionHandlers.end(), - OptionHandlerNameLesser()); + OptionHandlerNameLesser()); } void OptionParser::addOptionHandler @@ -217,14 +217,14 @@ void OptionParser::addOptionHandler optionHandler->setOptionID(++_idCounter); std::vector<SharedHandle<OptionHandler> >::iterator i = std::lower_bound(_optionHandlers.begin(), _optionHandlers.end(), - optionHandler, OptionHandlerNameLesser()); + optionHandler, OptionHandlerNameLesser()); _optionHandlers.insert(i, optionHandler); } void OptionParser::parseDefaultValues(Option& option) const { for(std::vector<SharedHandle<OptionHandler> >::const_iterator i = - _optionHandlers.begin(); i != _optionHandlers.end(); ++i) { + _optionHandlers.begin(); i != _optionHandlers.end(); ++i) { if(!(*i)->getDefaultValue().empty()) { (*i)->parse(option, (*i)->getDefaultValue()); } @@ -232,7 +232,7 @@ void OptionParser::parseDefaultValues(Option& option) const } class FindOptionHandlerByTag : - public std::unary_function<SharedHandle<OptionHandler>, bool> { + public std::unary_function<SharedHandle<OptionHandler>, bool> { private: std::string _tag; public: @@ -249,14 +249,14 @@ OptionParser::findByTag(const std::string& tag) const { std::vector<SharedHandle<OptionHandler> > result; std::remove_copy_if(_optionHandlers.begin(), _optionHandlers.end(), - std::back_inserter(result), - std::not1(FindOptionHandlerByTag(tag))); + std::back_inserter(result), + std::not1(FindOptionHandlerByTag(tag))); std::sort(result.begin(), result.end(), OptionHandlerIDLesser()); return result; } class FindOptionHandlerByNameSubstring : - public std::unary_function<SharedHandle<OptionHandler> , bool> { + public std::unary_function<SharedHandle<OptionHandler> , bool> { private: std::string _substring; public: @@ -275,8 +275,8 @@ OptionParser::findByNameSubstring(const std::string& substring) const { std::vector<SharedHandle<OptionHandler> > result; std::remove_copy_if(_optionHandlers.begin(), _optionHandlers.end(), - std::back_inserter(result), - std::not1(FindOptionHandlerByNameSubstring(substring))); + std::back_inserter(result), + std::not1(FindOptionHandlerByNameSubstring(substring))); std::sort(result.begin(), result.end(), OptionHandlerIDLesser()); return result; } @@ -285,8 +285,8 @@ std::vector<SharedHandle<OptionHandler> > OptionParser::findAll() const { std::vector<SharedHandle<OptionHandler> > result; std::remove_copy_if(_optionHandlers.begin(), _optionHandlers.end(), - std::back_inserter(result), - mem_fun_sh(&OptionHandler::isHidden)); + std::back_inserter(result), + mem_fun_sh(&OptionHandler::isHidden)); std::sort(result.begin(), result.end(), OptionHandlerIDLesser()); return result; } @@ -309,7 +309,7 @@ OptionParser::findByName(const std::string& name) const SharedHandle<OptionHandler> handler(new DummyOptionHandler(name)); std::vector<SharedHandle<OptionHandler> >::const_iterator i = std::lower_bound(_optionHandlers.begin(), _optionHandlers.end(), - handler, OptionHandlerNameLesser()); + handler, OptionHandlerNameLesser()); if(i == _optionHandlers.end() || (*i)->isHidden()) { handler.reset(); } else { @@ -334,7 +334,7 @@ public: SharedHandle<OptionHandler> OptionParser::findByID(int id) const { return findOptionHandler(_optionHandlers.begin(), _optionHandlers.end(), - FindOptionHandlerByID(id)); + FindOptionHandlerByID(id)); } class FindOptionHandlerByShortName: @@ -354,7 +354,7 @@ public: SharedHandle<OptionHandler> OptionParser::findByShortName(char shortName) const { return findOptionHandler(_optionHandlers.begin(), _optionHandlers.end(), - FindOptionHandlerByShortName(shortName)); + FindOptionHandlerByShortName(shortName)); } diff --git a/src/OptionParser.h b/src/OptionParser.h index a556edcd..f9ec3ddc 100644 --- a/src/OptionParser.h +++ b/src/OptionParser.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -70,7 +70,7 @@ public: // NAME=VALUE format. Non-option strings are stored in nonopts. // Throws Exception when an unrecognized option is found. void parseArg(std::ostream& out, std::deque<std::string>& nonopts, - int argc, char* const argv[]); + int argc, char* const argv[]); void parse(Option& option, std::istream& ios); diff --git a/src/PStringBuildVisitor.cc b/src/PStringBuildVisitor.cc index a60e5011..b023d1d3 100644 --- a/src/PStringBuildVisitor.cc +++ b/src/PStringBuildVisitor.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -68,7 +68,7 @@ void PStringBuildVisitor::visit(PStringNumLoop& s) unsigned int step = s.getStep(); for(unsigned int i = start; i <= end; i += step) { PStringSegment(s.getNumberDecorator()->decorate(i), - s.getNext()).accept(*this); + s.getNext()).accept(*this); } } diff --git a/src/PStringBuildVisitor.h b/src/PStringBuildVisitor.h index 49ef4a3b..ec428c01 100644 --- a/src/PStringBuildVisitor.h +++ b/src/PStringBuildVisitor.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/PStringDatum.h b/src/PStringDatum.h index 130f3766..7b43b186 100644 --- a/src/PStringDatum.h +++ b/src/PStringDatum.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/PStringNumLoop.h b/src/PStringNumLoop.h index 6e0fdbed..c32a2ec5 100644 --- a/src/PStringNumLoop.h +++ b/src/PStringNumLoop.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -58,9 +58,9 @@ private: public: PStringNumLoop(unsigned int startValue, unsigned int endValue, - unsigned int step, - const NumberDecoratorHandle& nd, - const PStringDatumHandle& next): + unsigned int step, + const NumberDecoratorHandle& nd, + const PStringDatumHandle& next): _startValue(startValue), _endValue(endValue), _step(step), @@ -68,8 +68,8 @@ public: _next(next) {} PStringNumLoop(unsigned int startValue, unsigned int endValue, - unsigned int step, - const NumberDecoratorHandle& nd): + unsigned int step, + const NumberDecoratorHandle& nd): _startValue(startValue), _endValue(endValue), _step(step), diff --git a/src/PStringSegment.cc b/src/PStringSegment.cc index b550d618..84fcab02 100644 --- a/src/PStringSegment.cc +++ b/src/PStringSegment.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -38,7 +38,7 @@ namespace aria2 { PStringSegment::PStringSegment(const std::string& value, - const SharedHandle<PStringDatum>& next): + const SharedHandle<PStringDatum>& next): _value(value), _next(next) {} PStringSegment::PStringSegment(const std::string& value): diff --git a/src/PStringSegment.h b/src/PStringSegment.h index e98a847c..cedd8f7d 100644 --- a/src/PStringSegment.h +++ b/src/PStringSegment.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -50,7 +50,7 @@ private: public: PStringSegment(const std::string& value, - const SharedHandle<PStringDatum>& next); + const SharedHandle<PStringDatum>& next); PStringSegment(const std::string& value); diff --git a/src/PStringSelect.h b/src/PStringSelect.h index 9c9ccab1..a6e3a09f 100644 --- a/src/PStringSelect.h +++ b/src/PStringSelect.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -51,7 +51,7 @@ private: public: PStringSelect(const std::deque<std::string>& values, - const PStringDatumHandle& next): + const PStringDatumHandle& next): _values(values), _next(next) {} diff --git a/src/PStringVisitor.h b/src/PStringVisitor.h index d5298a2f..ac031b68 100644 --- a/src/PStringVisitor.h +++ b/src/PStringVisitor.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/ParameterizedStringParser.cc b/src/ParameterizedStringParser.cc index dc6d750c..b21bbc98 100644 --- a/src/ParameterizedStringParser.cc +++ b/src/ParameterizedStringParser.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -54,7 +54,7 @@ PStringDatumHandle ParameterizedStringParser::parse(const std::string& src) } PStringDatumHandle ParameterizedStringParser::diggPString(const std::string& src, - int& offset) + int& offset) { if(src.size() == (size_t)offset) { return SharedHandle<PStringDatum>(); @@ -70,7 +70,7 @@ PStringDatumHandle ParameterizedStringParser::diggPString(const std::string& src } PStringDatumHandle ParameterizedStringParser::createSegment(const std::string& src, - int& offset) + int& offset) { std::string::size_type nextDelimiterIndex = src.find_first_of("[{", offset); if(nextDelimiterIndex == std::string::npos) { @@ -83,7 +83,7 @@ PStringDatumHandle ParameterizedStringParser::createSegment(const std::string& s } PStringDatumHandle ParameterizedStringParser::createSelect(const std::string& src, - int& offset) + int& offset) { ++offset; std::string::size_type rightParenIndex = src.find("}", offset); @@ -92,7 +92,7 @@ PStringDatumHandle ParameterizedStringParser::createSelect(const std::string& sr } std::deque<std::string> values; util::split(src.substr(offset, rightParenIndex-offset), - std::back_inserter(values), ",", true); + std::back_inserter(values), ",", true); if(values.empty()) { throw DL_ABORT_EX("Empty {} is not allowed."); } @@ -102,7 +102,7 @@ PStringDatumHandle ParameterizedStringParser::createSelect(const std::string& sr } PStringDatumHandle ParameterizedStringParser::createLoop(const std::string& src, - int& offset) + int& offset) { ++offset; std::string::size_type rightParenIndex = src.find("]", offset); diff --git a/src/ParameterizedStringParser.h b/src/ParameterizedStringParser.h index 77dd6804..dcab033a 100644 --- a/src/ParameterizedStringParser.h +++ b/src/ParameterizedStringParser.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/Peer.cc b/src/Peer.cc index 16d694a6..0c09936d 100644 --- a/src/Peer.cc +++ b/src/Peer.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -151,7 +151,7 @@ void Peer::peerInterested(bool b) _res->peerInterested(b); } - // this peer should be choked +// this peer should be choked bool Peer::chokingRequired() const { assert(_res); @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/PeerAbstractCommand.cc b/src/PeerAbstractCommand.cc index dcb1a320..49ebd97b 100644 --- a/src/PeerAbstractCommand.cc +++ b/src/PeerAbstractCommand.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -47,9 +47,9 @@ namespace aria2 { PeerAbstractCommand::PeerAbstractCommand(int32_t cuid, - const PeerHandle& peer, - DownloadEngine* e, - const SocketHandle& s): + const PeerHandle& peer, + DownloadEngine* e, + const SocketHandle& s): Command(cuid), e(e), socket(s), @@ -74,8 +74,8 @@ PeerAbstractCommand::~PeerAbstractCommand() bool PeerAbstractCommand::execute() { logger->debug("CUID#%d -" - " socket: read:%d, write:%d, hup:%d, err:%d, noCheck:%d", - cuid, _readEvent, _writeEvent, _hupEvent, _errorEvent, noCheck); + " socket: read:%d, write:%d, hup:%d, err:%d, noCheck:%d", + cuid, _readEvent, _writeEvent, _hupEvent, _errorEvent, noCheck); if(exitBeforeExecute()) { onAbort(); return true; @@ -88,8 +88,8 @@ bool PeerAbstractCommand::execute() checkPoint.reset(); } else if(_errorEvent) { throw DL_ABORT_EX - (StringFormat(MSG_NETWORK_PROBLEM, - socket->getSocketError().c_str()).str()); + (StringFormat(MSG_NETWORK_PROBLEM, + socket->getSocketError().c_str()).str()); } if(checkPoint.elapsed(timeout)) { throw DL_ABORT_EX(EX_TIME_OUT); @@ -103,7 +103,7 @@ bool PeerAbstractCommand::execute() } catch(RecoverableException& err) { logger->debug(MSG_TORRENT_DOWNLOAD_ABORTED, err, cuid); logger->debug(MSG_PEER_BANNED, - cuid, peer->ipaddr.c_str(), peer->port); + cuid, peer->ipaddr.c_str(), peer->port); onAbort(); return prepareForNextPeer(0); } @@ -131,9 +131,9 @@ void PeerAbstractCommand::setReadCheckSocket(const SocketHandle& socket) } else { if(checkSocketIsReadable) { if(readCheckTarget != socket) { - e->deleteSocketForReadCheck(readCheckTarget, this); - e->addSocketForReadCheck(socket, this); - readCheckTarget = socket; + e->deleteSocketForReadCheck(readCheckTarget, this); + e->addSocketForReadCheck(socket, this); + readCheckTarget = socket; } } else { e->addSocketForReadCheck(socket, this); @@ -159,9 +159,9 @@ void PeerAbstractCommand::setWriteCheckSocket(const SocketHandle& socket) } else { if(checkSocketIsWritable) { if(writeCheckTarget != socket) { - e->deleteSocketForWriteCheck(writeCheckTarget, this); - e->addSocketForWriteCheck(socket, this); - writeCheckTarget = socket; + e->deleteSocketForWriteCheck(writeCheckTarget, this); + e->addSocketForWriteCheck(socket, this); + writeCheckTarget = socket; } } else { e->addSocketForWriteCheck(socket, this); diff --git a/src/PeerAbstractCommand.h b/src/PeerAbstractCommand.h index ed500054..06c5f8a0 100644 --- a/src/PeerAbstractCommand.h +++ b/src/PeerAbstractCommand.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -77,10 +77,10 @@ private: bool noCheck; public: PeerAbstractCommand(int32_t cuid, - const SharedHandle<Peer>& peer, - DownloadEngine* e, - const SharedHandle<SocketCore>& s = - SharedHandle<SocketCore>()); + const SharedHandle<Peer>& peer, + DownloadEngine* e, + const SharedHandle<SocketCore>& s = + SharedHandle<SocketCore>()); virtual ~PeerAbstractCommand(); diff --git a/src/PeerAddrEntry.h b/src/PeerAddrEntry.h index 348a4ca2..9440a17e 100644 --- a/src/PeerAddrEntry.h +++ b/src/PeerAddrEntry.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/PeerChokeCommand.cc b/src/PeerChokeCommand.cc index ca1bb1f0..53c41f05 100644 --- a/src/PeerChokeCommand.cc +++ b/src/PeerChokeCommand.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -40,7 +40,7 @@ namespace aria2 { PeerChokeCommand::PeerChokeCommand(int32_t cuid, - DownloadEngine* e): + DownloadEngine* e): Command(cuid), e(e) {} diff --git a/src/PeerChokeCommand.h b/src/PeerChokeCommand.h index 7f8baf75..c10a38cf 100644 --- a/src/PeerChokeCommand.h +++ b/src/PeerChokeCommand.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -53,7 +53,7 @@ private: SharedHandle<BtRuntime> _btRuntime; public: PeerChokeCommand(int32_t cuid, - DownloadEngine* e); + DownloadEngine* e); virtual ~PeerChokeCommand(); diff --git a/src/PeerConnection.cc b/src/PeerConnection.cc index b0b79b69..16f0406c 100644 --- a/src/PeerConnection.cc +++ b/src/PeerConnection.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -67,7 +67,7 @@ PeerConnection::PeerConnection(int32_t cuid, const SocketHandle& socket) PeerConnection::~PeerConnection() {} ssize_t PeerConnection::sendMessage(const unsigned char* data, - size_t dataLength) + size_t dataLength) { ssize_t writtenLength = sendData(data, dataLength, _encryptionEnabled); logger->debug("sent %d byte(s).", writtenLength); @@ -85,11 +85,11 @@ bool PeerConnection::receiveMessage(unsigned char* data, size_t& dataLength) { readData(lenbuf+lenbufLength, remaining, _encryptionEnabled); if(remaining == 0) { if(socket->wantRead() || socket->wantWrite()) { - return false; + return false; } // we got EOF logger->debug("CUID#%d - In PeerConnection::receiveMessage(), remain=%lu", - cuid, static_cast<unsigned long>(temp)); + cuid, static_cast<unsigned long>(temp)); throw DL_ABORT_EX(EX_EOF_FROM_PEER); } lenbufLength += remaining; @@ -115,14 +115,14 @@ bool PeerConnection::receiveMessage(unsigned char* data, size_t& dataLength) { readData(resbuf+resbufLength, remaining, _encryptionEnabled); if(remaining == 0) { if(socket->wantRead() || socket->wantWrite()) { - return false; + return false; } // we got EOF logger->debug("CUID#%d - In PeerConnection::receiveMessage()," - " payloadlen=%lu, remaining=%lu", - cuid, - static_cast<unsigned long>(currentPayloadLength), - static_cast<unsigned long>(temp)); + " payloadlen=%lu, remaining=%lu", + cuid, + static_cast<unsigned long>(currentPayloadLength), + static_cast<unsigned long>(temp)); throw DL_ABORT_EX(EX_EOF_FROM_PEER); } resbufLength += remaining; @@ -140,7 +140,7 @@ bool PeerConnection::receiveMessage(unsigned char* data, size_t& dataLength) { } bool PeerConnection::receiveHandshake(unsigned char* data, size_t& dataLength, - bool peek) { + bool peek) { assert(BtHandshakeMessage::MESSAGE_LENGTH >= resbufLength); bool retval = true; if(_prevPeek && !peek && resbufLength) { @@ -163,18 +163,18 @@ bool PeerConnection::receiveHandshake(unsigned char* data, size_t& dataLength, size_t temp = remaining; readData(resbuf+resbufLength, remaining, _encryptionEnabled); if(remaining == 0) { - if(socket->wantRead() || socket->wantWrite()) { - return false; - } - // we got EOF - logger->debug - ("CUID#%d - In PeerConnection::receiveHandshake(), remain=%lu", - cuid, static_cast<unsigned long>(temp)); - throw DL_ABORT_EX(EX_EOF_FROM_PEER); + if(socket->wantRead() || socket->wantWrite()) { + return false; + } + // we got EOF + logger->debug + ("CUID#%d - In PeerConnection::receiveHandshake(), remain=%lu", + cuid, static_cast<unsigned long>(temp)); + throw DL_ABORT_EX(EX_EOF_FROM_PEER); } resbufLength += remaining; if(BtHandshakeMessage::MESSAGE_LENGTH > resbufLength) { - retval = false; + retval = false; } } } @@ -200,7 +200,7 @@ void PeerConnection::readData(unsigned char* data, size_t& length, bool encrypti } ssize_t PeerConnection::sendData(const unsigned char* data, - size_t length, bool encryption) + size_t length, bool encryption) { if(encryption) { unsigned char temp[4096]; @@ -220,7 +220,7 @@ ssize_t PeerConnection::sendData(const unsigned char* data, } void PeerConnection::enableEncryption(const SharedHandle<ARC4Encryptor>& encryptor, - const SharedHandle<ARC4Decryptor>& decryptor) + const SharedHandle<ARC4Decryptor>& decryptor) { _encryptor = encryptor; _decryptor = decryptor; diff --git a/src/PeerConnection.h b/src/PeerConnection.h index 18ae037c..b87102da 100644 --- a/src/PeerConnection.h +++ b/src/PeerConnection.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -94,7 +94,7 @@ public: bool receiveHandshake(unsigned char* data, size_t& dataLength, bool peek = false); void enableEncryption(const SharedHandle<ARC4Encryptor>& encryptor, - const SharedHandle<ARC4Decryptor>& decryptor); + const SharedHandle<ARC4Decryptor>& decryptor); void presetBuffer(const unsigned char* data, size_t length); diff --git a/src/PeerInitiateConnectionCommand.cc b/src/PeerInitiateConnectionCommand.cc index a05cc4e0..6cbf9479 100644 --- a/src/PeerInitiateConnectionCommand.cc +++ b/src/PeerInitiateConnectionCommand.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -76,13 +76,13 @@ PeerInitiateConnectionCommand::~PeerInitiateConnectionCommand() bool PeerInitiateConnectionCommand::executeInternal() { logger->info(MSG_CONNECTING_TO_SERVER, cuid, peer->ipaddr.c_str(), - peer->port); + peer->port); socket.reset(new SocketCore()); socket->establishConnection(peer->ipaddr, peer->port); if(_mseHandshakeEnabled) { InitiatorMSEHandshakeCommand* c = new InitiatorMSEHandshakeCommand(cuid, _requestGroup, peer, e, - _btRuntime, socket); + _btRuntime, socket); c->setPeerStorage(_peerStorage); c->setPieceStorage(_pieceStorage); e->commands.push_back(c); @@ -103,7 +103,7 @@ bool PeerInitiateConnectionCommand::prepareForNextPeer(time_t wait) { peer->usedBy(e->newCUID()); PeerInitiateConnectionCommand* command = new PeerInitiateConnectionCommand(peer->usedBy(), _requestGroup, peer, e, - _btRuntime); + _btRuntime); command->setPeerStorage(_peerStorage); command->setPieceStorage(_pieceStorage); e->commands.push_back(command); diff --git a/src/PeerInitiateConnectionCommand.h b/src/PeerInitiateConnectionCommand.h index 0723eade..b72cb1bd 100644 --- a/src/PeerInitiateConnectionCommand.h +++ b/src/PeerInitiateConnectionCommand.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -63,11 +63,11 @@ protected: public: PeerInitiateConnectionCommand(int cuid, - RequestGroup* requestGroup, - const SharedHandle<Peer>& peer, - DownloadEngine* e, - const SharedHandle<BtRuntime>& btRuntime, - bool mseHandshakeEnabled = true); + RequestGroup* requestGroup, + const SharedHandle<Peer>& peer, + DownloadEngine* e, + const SharedHandle<BtRuntime>& btRuntime, + bool mseHandshakeEnabled = true); virtual ~PeerInitiateConnectionCommand(); diff --git a/src/PeerInteractionCommand.cc b/src/PeerInteractionCommand.cc index 2d8d4e2b..7df1c75a 100644 --- a/src/PeerInteractionCommand.cc +++ b/src/PeerInteractionCommand.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -237,7 +237,7 @@ PeerInteractionCommand::PeerInteractionCommand PeerInteractionCommand::~PeerInteractionCommand() { if(peer->getCompletedLength() > 0) { _pieceStorage->subtractPieceStats(peer->getBitfield(), - peer->getBitfieldLength()); + peer->getBitfieldLength()); } peer->releaseSessionResource(); @@ -265,7 +265,7 @@ bool PeerInteractionCommand::executeInternal() { if(btInteractive->countPendingMessage() > 0) { btInteractive->sendPendingMessage(); if(btInteractive->countPendingMessage() > 0) { - break; + break; } } BtMessageHandle handshakeMessage = btInteractive->receiveHandshake(); @@ -299,15 +299,15 @@ bool PeerInteractionCommand::executeInternal() { // Writable check to avoid slow seeding if(btInteractive->isSendingMessageInProgress()) { - setWriteCheckSocket(socket); + setWriteCheckSocket(socket); } if(e->_requestGroupMan->doesOverallDownloadSpeedExceed() || - _requestGroup->doesDownloadSpeedExceed()) { - disableReadCheckSocket(); - setNoCheck(true); + _requestGroup->doesDownloadSpeedExceed()) { + disableReadCheckSocket(); + setNoCheck(true); } else { - setReadCheckSocket(socket); + setReadCheckSocket(socket); } } else { disableReadCheckSocket(); diff --git a/src/PeerInteractionCommand.h b/src/PeerInteractionCommand.h index 8dba1272..4c65c34c 100644 --- a/src/PeerInteractionCommand.h +++ b/src/PeerInteractionCommand.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -75,16 +75,16 @@ protected: virtual bool exitBeforeExecute(); public: PeerInteractionCommand(int32_t cuid, - RequestGroup* requestGroup, - const SharedHandle<Peer>& peer, - DownloadEngine* e, - const SharedHandle<BtRuntime>& btRuntime, - const SharedHandle<PieceStorage>& pieceStorage, - const SharedHandle<PeerStorage>& peerStorage, - const SharedHandle<SocketCore>& s, - Seq sequence, - const SharedHandle<PeerConnection>& peerConnection = - SharedHandle<PeerConnection>()); + RequestGroup* requestGroup, + const SharedHandle<Peer>& peer, + DownloadEngine* e, + const SharedHandle<BtRuntime>& btRuntime, + const SharedHandle<PieceStorage>& pieceStorage, + const SharedHandle<PeerStorage>& peerStorage, + const SharedHandle<SocketCore>& s, + Seq sequence, + const SharedHandle<PeerConnection>& peerConnection = + SharedHandle<PeerConnection>()); virtual ~PeerInteractionCommand(); }; diff --git a/src/PeerListProcessor.h b/src/PeerListProcessor.h index d96aa2be..59709bbc 100644 --- a/src/PeerListProcessor.h +++ b/src/PeerListProcessor.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -61,18 +61,18 @@ public: void extractPeerFromList(const BDE& peerData, OutputIterator dest) { for(BDE::List::const_iterator itr = peerData.listBegin(); - itr != peerData.listEnd(); ++itr) { + itr != peerData.listEnd(); ++itr) { const BDE& peerDict = *itr; if(!peerDict.isDict()) { - continue; + continue; } static const std::string IP = "ip"; static const std::string PORT = "port"; const BDE& ip = peerDict[IP]; const BDE& port = peerDict[PORT]; if(!ip.isString() || !port.isInteger() || - !(0 < port.i() && port.i() < 65536)) { - continue; + !(0 < port.i() && port.i() < 65536)) { + continue; } *dest = SharedHandle<Peer>(new Peer(ip.s(), port.i())); ++dest; @@ -85,14 +85,14 @@ public: size_t length = peerData.s().size(); if(length%6 == 0) { for(size_t i = 0; i < length; i += 6) { - struct in_addr in; - memcpy(&in.s_addr, peerData.s().c_str()+i, sizeof(uint32_t)); - std::string ipaddr = inet_ntoa(in); - uint16_t port_nworder; - memcpy(&port_nworder, peerData.s().c_str()+i+4, sizeof(uint16_t)); - uint16_t port = ntohs(port_nworder); - *dest = SharedHandle<Peer>(new Peer(ipaddr, port)); - ++dest; + struct in_addr in; + memcpy(&in.s_addr, peerData.s().c_str()+i, sizeof(uint32_t)); + std::string ipaddr = inet_ntoa(in); + uint16_t port_nworder; + memcpy(&port_nworder, peerData.s().c_str()+i+4, sizeof(uint16_t)); + uint16_t port = ntohs(port_nworder); + *dest = SharedHandle<Peer>(new Peer(ipaddr, port)); + ++dest; } } } diff --git a/src/PeerListenCommand.cc b/src/PeerListenCommand.cc index 81fa57ab..61f6db40 100644 --- a/src/PeerListenCommand.cc +++ b/src/PeerListenCommand.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -74,7 +74,7 @@ bool PeerListenCommand::bindPort(uint16_t& port, IntSequence& seq) std::deque<int32_t> randPorts = seq.flush(); std::random_shuffle(randPorts.begin(), randPorts.end(), - *SimpleRandomizer::getInstance().get()); + *SimpleRandomizer::getInstance().get()); for(std::deque<int32_t>::const_iterator portItr = randPorts.begin(); portItr != randPorts.end(); ++portItr) { @@ -123,15 +123,15 @@ bool PeerListenCommand::execute() { PeerHandle peer(new Peer(peerInfo.first, peerInfo.second, true)); int32_t cuid = e->newCUID(); Command* command = - new ReceiverMSEHandshakeCommand(cuid, peer, e, peerSocket); + new ReceiverMSEHandshakeCommand(cuid, peer, e, peerSocket); e->commands.push_back(command); logger->debug("Accepted the connection from %s:%u.", - peer->ipaddr.c_str(), - peer->port); + peer->ipaddr.c_str(), + peer->port); logger->debug("Added CUID#%d to receive BitTorrent/MSE handshake.", cuid); } catch(RecoverableException& ex) { logger->debug(MSG_ACCEPT_FAILURE, ex, cuid); - } + } } e->commands.push_back(this); return false; diff --git a/src/PeerListenCommand.h b/src/PeerListenCommand.h index 9cb3e485..1af4d295 100644 --- a/src/PeerListenCommand.h +++ b/src/PeerListenCommand.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/PeerReceiveHandshakeCommand.cc b/src/PeerReceiveHandshakeCommand.cc index 337cd5ec..d4bd1942 100644 --- a/src/PeerReceiveHandshakeCommand.cc +++ b/src/PeerReceiveHandshakeCommand.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -97,8 +97,8 @@ bool PeerReceiveHandshakeCommand::executeInternal() e->getBtRegistry()->getDownloadContext(infoHash); if(downloadContext.isNull()) { throw DL_ABORT_EX - (StringFormat("Unknown info hash %s", - util::toHex(infoHash).c_str()).str()); + (StringFormat("Unknown info hash %s", + util::toHex(infoHash).c_str()).str()); } BtObject btObject = e->getBtRegistry()->get (downloadContext->getOwnerRequestGroup()->getGID()); @@ -107,8 +107,8 @@ bool PeerReceiveHandshakeCommand::executeInternal() SharedHandle<PeerStorage> peerStorage = btObject._peerStorage; if(!btRuntime->ready()) { throw DL_ABORT_EX - (StringFormat("Unknown info hash %s", - util::toHex(infoHash).c_str()).str()); + (StringFormat("Unknown info hash %s", + util::toHex(infoHash).c_str()).str()); } TransferStat tstat = @@ -123,26 +123,26 @@ bool PeerReceiveHandshakeCommand::executeInternal() } if((!pieceStorage->downloadFinished() && - tstat.getDownloadSpeed() < thresholdSpeed) || + tstat.getDownloadSpeed() < thresholdSpeed) || btRuntime->lessThanMaxPeers()) { if(peerStorage->addPeer(peer)) { - peer->usedBy(cuid); - - PeerInteractionCommand* command = - new PeerInteractionCommand - (cuid, - downloadContext->getOwnerRequestGroup(), - peer, - e, - btRuntime, - pieceStorage, - peerStorage, - socket, - PeerInteractionCommand::RECEIVER_WAIT_HANDSHAKE, - _peerConnection); - e->commands.push_back(command); - logger->debug(MSG_INCOMING_PEER_CONNECTION, cuid, peer->usedBy()); + peer->usedBy(cuid); + + PeerInteractionCommand* command = + new PeerInteractionCommand + (cuid, + downloadContext->getOwnerRequestGroup(), + peer, + e, + btRuntime, + pieceStorage, + peerStorage, + socket, + PeerInteractionCommand::RECEIVER_WAIT_HANDSHAKE, + _peerConnection); + e->commands.push_back(command); + logger->debug(MSG_INCOMING_PEER_CONNECTION, cuid, peer->usedBy()); } } return true; diff --git a/src/PeerReceiveHandshakeCommand.h b/src/PeerReceiveHandshakeCommand.h index afeb8bdc..884b9984 100644 --- a/src/PeerReceiveHandshakeCommand.h +++ b/src/PeerReceiveHandshakeCommand.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/PeerSessionResource.cc b/src/PeerSessionResource.cc index 44780e26..118a0962 100644 --- a/src/PeerSessionResource.cc +++ b/src/PeerSessionResource.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -181,8 +181,8 @@ void PeerSessionResource::addPeerAllowedIndex(size_t index) bool PeerSessionResource::peerAllowedIndexSetContains(size_t index) const { return std::binary_search(_peerAllowedIndexSet.begin(), - _peerAllowedIndexSet.end(), - index); + _peerAllowedIndexSet.end(), + index); } void PeerSessionResource::addAmAllowedIndex(size_t index) @@ -193,8 +193,8 @@ void PeerSessionResource::addAmAllowedIndex(size_t index) bool PeerSessionResource::amAllowedIndexSetContains(size_t index) const { return std::binary_search(_amAllowedIndexSet.begin(), - _amAllowedIndexSet.end(), - index); + _amAllowedIndexSet.end(), + index); } void PeerSessionResource::extendedMessagingEnabled(bool b) diff --git a/src/PeerSessionResource.h b/src/PeerSessionResource.h index cfe148af..44cd5910 100644 --- a/src/PeerSessionResource.h +++ b/src/PeerSessionResource.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/PeerStat.h b/src/PeerStat.h index f78294ec..71e89925 100644 --- a/src/PeerStat.h +++ b/src/PeerStat.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -66,7 +66,7 @@ private: public: PeerStat(cuid_t cuid, const std::string& hostname, - const::std::string& protocol): + const::std::string& protocol): cuid(cuid), _hostname(hostname), _protocol(protocol), @@ -77,10 +77,10 @@ public: _sessionUploadLength(0) {} PeerStat(cuid_t cuid = 0):cuid(cuid), status(PeerStat::IDLE), - _avgDownloadSpeed(0), - _avgUploadSpeed(0), - _sessionDownloadLength(0), - _sessionUploadLength(0) {} + _avgDownloadSpeed(0), + _avgUploadSpeed(0), + _sessionDownloadLength(0), + _sessionUploadLength(0) {} ~PeerStat() {} diff --git a/src/PeerStorage.h b/src/PeerStorage.h index 4227db73..e946f6a1 100644 --- a/src/PeerStorage.h +++ b/src/PeerStorage.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/Piece.cc b/src/Piece.cc index fdcd51c0..26f50fe2 100644 --- a/src/Piece.cc +++ b/src/Piece.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -47,13 +47,13 @@ namespace aria2 { Piece::Piece():index(0), length(0), _blockLength(BLOCK_LENGTH), bitfield(0) #ifdef ENABLE_MESSAGE_DIGEST - , _nextBegin(0) + , _nextBegin(0) #endif // ENABLE_MESSAGE_DIGEST {} Piece::Piece(size_t index, size_t length, size_t blockLength):index(index), length(length), _blockLength(blockLength) #ifdef ENABLE_MESSAGE_DIGEST - , _nextBegin(0) + , _nextBegin(0) #endif // ENABLE_MESSAGE_DIGEST { bitfield = @@ -196,7 +196,7 @@ bool Piece::getAllMissingBlockIndexes std::string Piece::toString() const { return strconcat("piece: index=", util::itos(index), - ", length=", util::itos(length)); + ", length=", util::itos(length)); } void Piece::reconfigure(size_t length) diff --git a/src/Piece.h b/src/Piece.h index b220be5a..4a7b8e93 100644 --- a/src/Piece.h +++ b/src/Piece.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -96,7 +96,7 @@ public: bool getMissingBlockIndex(size_t& index) const; bool getFirstMissingBlockIndexWithoutLock(size_t& index) const; bool getAllMissingBlockIndexes(unsigned char* misbitfield, - size_t mislen) const; + size_t mislen) const; void completeBlock(size_t blockIndex); void cancelBlock(size_t blockIndex); diff --git a/src/PieceHashCheckIntegrityEntry.cc b/src/PieceHashCheckIntegrityEntry.cc index 972a40e8..6b784eb8 100644 --- a/src/PieceHashCheckIntegrityEntry.cc +++ b/src/PieceHashCheckIntegrityEntry.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -41,7 +41,7 @@ namespace aria2 { PieceHashCheckIntegrityEntry::PieceHashCheckIntegrityEntry(RequestGroup* requestGroup, - Command* nextCommand): + Command* nextCommand): CheckIntegrityEntry(requestGroup, nextCommand) {} PieceHashCheckIntegrityEntry::~PieceHashCheckIntegrityEntry() {} @@ -60,7 +60,7 @@ void PieceHashCheckIntegrityEntry::initValidator() #ifdef ENABLE_MESSAGE_DIGEST IteratableChunkChecksumValidatorHandle validator (new IteratableChunkChecksumValidator(_requestGroup->getDownloadContext(), - _requestGroup->getPieceStorage())); + _requestGroup->getPieceStorage())); validator->init(); _validator = validator; #endif // ENABLE_MESSAGE_DIGEST diff --git a/src/PieceHashCheckIntegrityEntry.h b/src/PieceHashCheckIntegrityEntry.h index e6462221..eb8148a6 100644 --- a/src/PieceHashCheckIntegrityEntry.h +++ b/src/PieceHashCheckIntegrityEntry.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/PieceSelector.h b/src/PieceSelector.h index e6e70f5d..36047ae3 100644 --- a/src/PieceSelector.h +++ b/src/PieceSelector.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/PieceStatMan.cc b/src/PieceStatMan.cc index 9da7302e..ee0425a8 100644 --- a/src/PieceStatMan.cc +++ b/src/PieceStatMan.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -77,12 +77,12 @@ PieceStatMan::PieceStatMan(size_t pieceNum, bool randomShuffle): // we need some randomness in ordering. if(randomShuffle) { std::random_shuffle(sortedPieceStats.begin(), sortedPieceStats.end(), - *(SimpleRandomizer::getInstance().get())); + *(SimpleRandomizer::getInstance().get())); } { size_t order = 0; for(std::vector<SharedHandle<PieceStat> >::iterator i = - sortedPieceStats.begin(); i != sortedPieceStats.end(); ++i) { + sortedPieceStats.begin(); i != sortedPieceStats.end(); ++i) { _sortedPieceStatIndexes[order] = (*i)->getIndex(); (*i)->setOrder(order++); } @@ -103,7 +103,7 @@ public: }; void PieceStatMan::addPieceStats(const unsigned char* bitfield, - size_t bitfieldLength) + size_t bitfieldLength) { size_t index = 0; for(size_t bi = 0; bi < bitfieldLength; ++bi) { @@ -111,17 +111,17 @@ void PieceStatMan::addPieceStats(const unsigned char* bitfield, for(size_t i = 0; i < 8; ++i, ++index) { unsigned char mask = 128 >> i; if(bitfield[bi]&mask) { - _pieceStats[index]->addCount(); + _pieceStats[index]->addCount(); } } } std::sort(_sortedPieceStatIndexes.begin(), _sortedPieceStatIndexes.end(), - PieceStatRarer(_pieceStats)); + PieceStatRarer(_pieceStats)); } void PieceStatMan::subtractPieceStats(const unsigned char* bitfield, - size_t bitfieldLength) + size_t bitfieldLength) { size_t index = 0; for(size_t bi = 0; bi < bitfieldLength; ++bi) { @@ -129,18 +129,18 @@ void PieceStatMan::subtractPieceStats(const unsigned char* bitfield, for(size_t i = 0; i < 8; ++i, ++index) { unsigned char mask = 128 >> i; if(bitfield[bi]&mask) { - _pieceStats[index]->subCount(); + _pieceStats[index]->subCount(); } } } std::sort(_sortedPieceStatIndexes.begin(), _sortedPieceStatIndexes.end(), - PieceStatRarer(_pieceStats)); + PieceStatRarer(_pieceStats)); } void PieceStatMan::updatePieceStats(const unsigned char* newBitfield, - size_t newBitfieldLength, - const unsigned char* oldBitfield) + size_t newBitfieldLength, + const unsigned char* oldBitfield) { size_t index = 0; for(size_t bi = 0; bi < newBitfieldLength; ++bi) { @@ -148,29 +148,29 @@ void PieceStatMan::updatePieceStats(const unsigned char* newBitfield, for(size_t i = 0; i < 8; ++i, ++index) { unsigned char mask = 128 >> i; if((newBitfield[bi]&mask) && !(oldBitfield[bi]&mask)) { - _pieceStats[index]->addCount(); + _pieceStats[index]->addCount(); } else if(!(newBitfield[bi]&mask) && (oldBitfield[bi]&mask)) { - _pieceStats[index]->subCount(); + _pieceStats[index]->subCount(); } } } std::sort(_sortedPieceStatIndexes.begin(), _sortedPieceStatIndexes.end(), - PieceStatRarer(_pieceStats)); + PieceStatRarer(_pieceStats)); } void PieceStatMan::addPieceStats(size_t index) { std::vector<size_t>::iterator cur = std::lower_bound(_sortedPieceStatIndexes.begin(), - _sortedPieceStatIndexes.end(), - index, PieceStatRarer(_pieceStats)); + _sortedPieceStatIndexes.end(), + index, PieceStatRarer(_pieceStats)); _pieceStats[index]->addCount(); std::vector<size_t>::iterator to = std::upper_bound(cur+1, _sortedPieceStatIndexes.end(), - index, PieceStatRarer(_pieceStats)); + index, PieceStatRarer(_pieceStats)); std::rotate(cur, cur+1, to); } diff --git a/src/PieceStatMan.h b/src/PieceStatMan.h index b5f038be..6d3f0351 100644 --- a/src/PieceStatMan.h +++ b/src/PieceStatMan.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -96,14 +96,14 @@ public: void addPieceStats(size_t index); void addPieceStats(const unsigned char* bitfield, - size_t bitfieldLength); + size_t bitfieldLength); void subtractPieceStats(const unsigned char* bitfield, - size_t bitfieldLength); + size_t bitfieldLength); void updatePieceStats(const unsigned char* newBitfield, - size_t newBitfieldLength, - const unsigned char* oldBitfield); + size_t newBitfieldLength, + const unsigned char* oldBitfield); // Returns piece index in rarest first order. const std::vector<size_t>& getRarerPieceIndexes() const diff --git a/src/PieceStorage.h b/src/PieceStorage.h index ab492625..30514704 100644 --- a/src/PieceStorage.h +++ b/src/PieceStorage.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -180,7 +180,7 @@ public: virtual const unsigned char* getBitfield() = 0; virtual void setBitfield(const unsigned char* bitfield, - size_t bitfieldLength) = 0; + size_t bitfieldLength) = 0; virtual size_t getBitfieldLength() = 0; @@ -205,8 +205,8 @@ public: * command and newer than lastCheckTime. */ virtual void getAdvertisedPieceIndexes(std::deque<size_t>& indexes, - int32_t myCuid, - const Time& lastCheckTime) = 0; + int32_t myCuid, + const Time& lastCheckTime) = 0; /** * Removes have entry if specified seconds have elapsed since its @@ -234,14 +234,14 @@ public: virtual void addPieceStats(size_t index) = 0; virtual void addPieceStats(const unsigned char* bitfield, - size_t bitfieldLength) = 0; + size_t bitfieldLength) = 0; virtual void subtractPieceStats(const unsigned char* bitfield, - size_t bitfieldLength) = 0; + size_t bitfieldLength) = 0; virtual void updatePieceStats(const unsigned char* newBitfield, - size_t newBitfieldLength, - const unsigned char* oldBitfield) = 0; + size_t newBitfieldLength, + const unsigned char* oldBitfield) = 0; }; diff --git a/src/PiecedSegment.cc b/src/PiecedSegment.cc index 1c79a43a..eb506099 100644 --- a/src/PiecedSegment.cc +++ b/src/PiecedSegment.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -93,7 +93,7 @@ void PiecedSegment::updateWrittenLength(size_t bytes) #ifdef ENABLE_MESSAGE_DIGEST bool PiecedSegment::updateHash(uint32_t begin, - const unsigned char* data, size_t dataLength) + const unsigned char* data, size_t dataLength) { return _piece->updateHash(begin, data, dataLength); } diff --git a/src/PiecedSegment.h b/src/PiecedSegment.h index 74d68e04..ec96c112 100644 --- a/src/PiecedSegment.h +++ b/src/PiecedSegment.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -86,7 +86,7 @@ public: // `begin' is a offset inside this segment. virtual bool updateHash(uint32_t begin, - const unsigned char* data, size_t dataLength); + const unsigned char* data, size_t dataLength); virtual bool isHashCalculated() const; diff --git a/src/Platform.cc b/src/Platform.cc index b8959e99..d510a98a 100644 --- a/src/Platform.cc +++ b/src/Platform.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/Platform.h b/src/Platform.h index 0b4146e9..d2e4fcc8 100644 --- a/src/Platform.h +++ b/src/Platform.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/PostDownloadHandler.h b/src/PostDownloadHandler.h index 56456a85..8a5c9b9c 100644 --- a/src/PostDownloadHandler.h +++ b/src/PostDownloadHandler.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -48,7 +48,7 @@ public: virtual void getNextRequestGroups(std::deque<SharedHandle<RequestGroup> >& groups, - RequestGroup* requestGroup) = 0; + RequestGroup* requestGroup) = 0; }; typedef SharedHandle<PostDownloadHandler> PostDownloadHandlerHandle; diff --git a/src/PreDownloadHandler.h b/src/PreDownloadHandler.h index 636ac5e9..fc4501a4 100644 --- a/src/PreDownloadHandler.h +++ b/src/PreDownloadHandler.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/PriorityPieceSelector.cc b/src/PriorityPieceSelector.cc index c11a3672..808732b5 100644 --- a/src/PriorityPieceSelector.cc +++ b/src/PriorityPieceSelector.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/PriorityPieceSelector.h b/src/PriorityPieceSelector.h index cb305b9d..972ca85e 100644 --- a/src/PriorityPieceSelector.h +++ b/src/PriorityPieceSelector.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/ProgressAwareEntry.h b/src/ProgressAwareEntry.h index 2915e254..b6105310 100644 --- a/src/ProgressAwareEntry.h +++ b/src/ProgressAwareEntry.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/ProtocolDetector.cc b/src/ProtocolDetector.cc index c620c5bf..fea523b1 100644 --- a/src/ProtocolDetector.cc +++ b/src/ProtocolDetector.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/ProtocolDetector.h b/src/ProtocolDetector.h index 9bc48823..0cd78c19 100644 --- a/src/ProtocolDetector.h +++ b/src/ProtocolDetector.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/Randomizer.h b/src/Randomizer.h index 88d4953a..b1772cfb 100644 --- a/src/Randomizer.h +++ b/src/Randomizer.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/Range.h b/src/Range.h index 92c44f16..c33aaf6f 100644 --- a/src/Range.h +++ b/src/Range.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/RangeBtMessage.cc b/src/RangeBtMessage.cc index dd54de32..9b350469 100644 --- a/src/RangeBtMessage.cc +++ b/src/RangeBtMessage.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -40,8 +40,8 @@ namespace aria2 { RangeBtMessage::RangeBtMessage(uint8_t id, - const std::string& name, - size_t index, uint32_t begin, size_t length) + const std::string& name, + size_t index, uint32_t begin, size_t length) :SimpleBtMessage(id, name), _index(index), _begin(begin), @@ -81,8 +81,8 @@ size_t RangeBtMessage::getMessageLength() std::string RangeBtMessage::toString() const { return strconcat(getName(), " index=", util::uitos(_index), - ", begin=", util::uitos(_begin), - ", length=", util::uitos(_length)); + ", begin=", util::uitos(_begin), + ", length=", util::uitos(_length)); } } // namespace aria2 diff --git a/src/RangeBtMessage.h b/src/RangeBtMessage.h index a91ee7a5..35c408ce 100644 --- a/src/RangeBtMessage.h +++ b/src/RangeBtMessage.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -63,7 +63,7 @@ protected: } public: RangeBtMessage(uint8_t id, const std::string& name, - size_t index, uint32_t begin, size_t length); + size_t index, uint32_t begin, size_t length); virtual ~RangeBtMessage(); diff --git a/src/RangeBtMessageValidator.h b/src/RangeBtMessageValidator.h index 196c9748..d1be175d 100644 --- a/src/RangeBtMessageValidator.h +++ b/src/RangeBtMessageValidator.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -48,8 +48,8 @@ private: size_t _pieceLength; public: RangeBtMessageValidator(const RangeBtMessage* message, - size_t numPiece, - size_t pieceLength): + size_t numPiece, + size_t pieceLength): _message(message), _numPiece(numPiece), _pieceLength(pieceLength) {} @@ -61,8 +61,8 @@ public: bittorrent::checkBegin(_message->getBegin(), _pieceLength); bittorrent::checkLength(_message->getLength()); bittorrent::checkRange(_message->getBegin(), - _message->getLength(), - _pieceLength); + _message->getLength(), + _pieceLength); return true; } }; diff --git a/src/RarestPieceSelector.cc b/src/RarestPieceSelector.cc index 2672d6a3..235cd634 100644 --- a/src/RarestPieceSelector.cc +++ b/src/RarestPieceSelector.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -68,7 +68,7 @@ bool RarestPieceSelector::select _pieceStatMan->getRarerPieceIndexes(); std::vector<size_t>::const_iterator i = std::find_if(pieceIndexes.begin(), pieceIndexes.end(), - FindRarestPiece(bitfield, nbits)); + FindRarestPiece(bitfield, nbits)); if(i == pieceIndexes.end()) { return false; } else { diff --git a/src/RarestPieceSelector.h b/src/RarestPieceSelector.h index 132d22f8..2f1936c7 100644 --- a/src/RarestPieceSelector.h +++ b/src/RarestPieceSelector.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/RealtimeCommand.cc b/src/RealtimeCommand.cc index 160f1f00..28b325fb 100644 --- a/src/RealtimeCommand.cc +++ b/src/RealtimeCommand.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -41,7 +41,7 @@ namespace aria2 { RealtimeCommand::RealtimeCommand(int cuid, RequestGroup* requestGroup, - DownloadEngine* e): + DownloadEngine* e): Command(cuid), _requestGroup(requestGroup), _e(e) diff --git a/src/RealtimeCommand.h b/src/RealtimeCommand.h index 8892cf8a..1d465320 100644 --- a/src/RealtimeCommand.h +++ b/src/RealtimeCommand.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/ReceiverMSEHandshakeCommand.cc b/src/ReceiverMSEHandshakeCommand.cc index fa609b60..d2dd0476 100644 --- a/src/ReceiverMSEHandshakeCommand.cc +++ b/src/ReceiverMSEHandshakeCommand.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -95,14 +95,14 @@ bool ReceiverMSEHandshakeCommand::executeInternal() break; case MSEHandshake::HANDSHAKE_LEGACY: { if(e->option->getAsBool(PREF_BT_REQUIRE_CRYPTO)) { - throw DL_ABORT_EX("The legacy BitTorrent handshake is not acceptable by the preference."); + throw DL_ABORT_EX("The legacy BitTorrent handshake is not acceptable by the preference."); } SharedHandle<PeerConnection> peerConnection - (new PeerConnection(cuid, socket)); + (new PeerConnection(cuid, socket)); peerConnection->presetBuffer(_mseHandshake->getBuffer(), - _mseHandshake->getBufferLength()); + _mseHandshake->getBufferLength()); Command* c = new PeerReceiveHandshakeCommand(cuid, peer, e, socket, - peerConnection); + peerConnection); e->commands.push_back(c); return true; } @@ -114,10 +114,10 @@ bool ReceiverMSEHandshakeCommand::executeInternal() case RECEIVER_WAIT_KEY: { if(_mseHandshake->receivePublicKey()) { if(_mseHandshake->sendPublicKey()) { - _sequence = RECEIVER_FIND_HASH_MARKER; + _sequence = RECEIVER_FIND_HASH_MARKER; } else { - setWriteCheckSocket(socket); - _sequence = RECEIVER_SEND_KEY_PENDING; + setWriteCheckSocket(socket); + _sequence = RECEIVER_SEND_KEY_PENDING; } } break; @@ -158,11 +158,11 @@ bool ReceiverMSEHandshakeCommand::executeInternal() case RECEIVER_RECEIVE_IA: { if(_mseHandshake->receiveReceiverIA()) { if(_mseHandshake->sendReceiverStep2()) { - createCommand(); - return true; + createCommand(); + return true; } else { - setWriteCheckSocket(socket); - _sequence = RECEIVER_SEND_STEP2_PENDING; + setWriteCheckSocket(socket); + _sequence = RECEIVER_SEND_STEP2_PENDING; } } break; @@ -185,11 +185,11 @@ void ReceiverMSEHandshakeCommand::createCommand() (new PeerConnection(cuid, socket)); if(_mseHandshake->getNegotiatedCryptoType() == MSEHandshake::CRYPTO_ARC4) { peerConnection->enableEncryption(_mseHandshake->getEncryptor(), - _mseHandshake->getDecryptor()); + _mseHandshake->getDecryptor()); } if(_mseHandshake->getIALength() > 0) { peerConnection->presetBuffer(_mseHandshake->getIA(), - _mseHandshake->getIALength()); + _mseHandshake->getIALength()); } // TODO add _mseHandshake->getInfoHash() to PeerReceiveHandshakeCommand // as a hint. If this info hash and one in BitTorrent Handshake does not diff --git a/src/ReceiverMSEHandshakeCommand.h b/src/ReceiverMSEHandshakeCommand.h index a4eb3dea..2d07b616 100644 --- a/src/ReceiverMSEHandshakeCommand.h +++ b/src/ReceiverMSEHandshakeCommand.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -68,9 +68,9 @@ protected: virtual bool exitBeforeExecute(); public: ReceiverMSEHandshakeCommand(int32_t cuid, - const SharedHandle<Peer>& peer, - DownloadEngine* e, - const SharedHandle<SocketCore>& s); + const SharedHandle<Peer>& peer, + DownloadEngine* e, + const SharedHandle<SocketCore>& s); virtual ~ReceiverMSEHandshakeCommand(); }; diff --git a/src/RecoverableException.h b/src/RecoverableException.h index cffe2ac4..b22b52d0 100644 --- a/src/RecoverableException.h +++ b/src/RecoverableException.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -55,17 +55,17 @@ public: _code(downloadresultcode::UNKNOWN_ERROR) {} RecoverableException(const char* file, int line, const std::string& msg, - const Exception& cause): + const Exception& cause): Exception(file, line, msg, cause), _code(downloadresultcode::UNKNOWN_ERROR) {} RecoverableException(const char* file, int line, - const RecoverableException& e): + const RecoverableException& e): Exception(file, line, e), _code(downloadresultcode::UNKNOWN_ERROR) {} RecoverableException(const char* file, int line, const std::string& msg, - downloadresultcode::RESULT result): + downloadresultcode::RESULT result): Exception(file, line, msg), _code(result) {} downloadresultcode::RESULT getCode() const { return _code; } diff --git a/src/Request.cc b/src/Request.cc index 0b4141ea..a6c92dd7 100644 --- a/src/Request.cc +++ b/src/Request.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -94,11 +94,11 @@ static std::string urlencode(const std::string& src) // '/' is not urlencoded because src is expected to be a path. if(!util::inRFC3986ReservedChars(c) && !util::inRFC3986UnreservedChars(c)) { if(c == '%') { - if(!isHexNumber(result[index+1]) || !isHexNumber(result[index+2])) { - result.replace(index, 1, "%25"); - } + if(!isHexNumber(result[index+1]) || !isHexNumber(result[index+2])) { + result.replace(index, 1, "%25"); + } } else { - result.replace(index, 1, StringFormat("%%%02X", c).str()); + result.replace(index, 1, StringFormat("%%%02X", c).str()); } } } @@ -201,11 +201,11 @@ bool Request::parseUrl(const std::string& url) { ++hostPortFirst; std::string::const_iterator userLast = authorityFirst; for(; userLast != userInfoLast; ++userLast) { - if(*userLast == ':') { - _password = util::urldecode(std::string(userLast+1, userInfoLast)); - _hasPassword = true; - break; - } + if(*userLast == ':') { + _password = util::urldecode(std::string(userLast+1, userInfoLast)); + _hasPassword = true; + break; + } } _username = util::urldecode(std::string(authorityFirst, userLast)); break; @@ -217,17 +217,17 @@ bool Request::parseUrl(const std::string& url) { // Detected IPv6 literal address in square brackets for(; hostLast != authorityLast; ++hostLast) { if(*hostLast == ']') { - ++hostLast; - if(hostLast == authorityLast) { - _ipv6LiteralAddress = true; - } else { - if(*hostLast == ':') { - portFirst = hostLast; - ++portFirst; - _ipv6LiteralAddress = true; - } - } - break; + ++hostLast; + if(hostLast == authorityLast) { + _ipv6LiteralAddress = true; + } else { + if(*hostLast == ':') { + portFirst = hostLast; + ++portFirst; + _ipv6LiteralAddress = true; + } + } + break; } } if(!_ipv6LiteralAddress) { @@ -236,9 +236,9 @@ bool Request::parseUrl(const std::string& url) { } else { for(; hostLast != authorityLast; ++hostLast) { if(*hostLast == ':') { - portFirst = hostLast; - ++portFirst; - break; + portFirst = hostLast; + ++portFirst; + break; } } } @@ -254,7 +254,7 @@ bool Request::parseUrl(const std::string& url) { uint32_t tempPort; if(util::parseUIntNoThrow(tempPort, std::string(portFirst, authorityLast))){ if(65535 < tempPort) { - return false; + return false; } _port = tempPort; } else { diff --git a/src/Request.h b/src/Request.h index 48a3b928..0cde6109 100644 --- a/src/Request.h +++ b/src/Request.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/RequestGroup.cc b/src/RequestGroup.cc index e2d49d48..b3f3f43a 100644 --- a/src/RequestGroup.cc +++ b/src/RequestGroup.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -153,7 +153,7 @@ RequestGroup::~RequestGroup() {} const SegmentManHandle& RequestGroup::initSegmentMan() { _segmentMan = _segmentManFactory->createNewInstance(_downloadContext, - _pieceStorage); + _pieceStorage); return _segmentMan; } @@ -182,9 +182,9 @@ downloadresultcode::RESULT RequestGroup::downloadResult() const else { if (_lastUriResult.isNull()) { if(_haltReason == RequestGroup::USER_REQUEST) { - return downloadresultcode::IN_PROGRESS; + return downloadresultcode::IN_PROGRESS; } else { - return downloadresultcode::UNKNOWN_ERROR; + return downloadresultcode::UNKNOWN_ERROR; } } else { return _lastUriResult->getResult(); @@ -206,174 +206,174 @@ void RequestGroup::createInitialCommand { if(_downloadContext->hasAttribute(bittorrent::BITTORRENT)) { const BDE& torrentAttrs = - _downloadContext->getAttribute(bittorrent::BITTORRENT); + _downloadContext->getAttribute(bittorrent::BITTORRENT); bool metadataGetMode = !torrentAttrs.containsKey(bittorrent::METADATA); if(_option->getAsBool(PREF_DRY_RUN)) { - throw DOWNLOAD_FAILURE_EXCEPTION - ("Cancel BitTorrent download in dry-run context."); + throw DOWNLOAD_FAILURE_EXCEPTION + ("Cancel BitTorrent download in dry-run context."); } SharedHandle<BtRegistry> btRegistry = e->getBtRegistry(); if(!btRegistry->getDownloadContext - (torrentAttrs[bittorrent::INFO_HASH].s()).isNull()) { - throw DOWNLOAD_FAILURE_EXCEPTION - (StringFormat - ("InfoHash %s is already registered.", - bittorrent::getInfoHashString(_downloadContext).c_str()).str()); + (torrentAttrs[bittorrent::INFO_HASH].s()).isNull()) { + throw DOWNLOAD_FAILURE_EXCEPTION + (StringFormat + ("InfoHash %s is already registered.", + bittorrent::getInfoHashString(_downloadContext).c_str()).str()); } if(metadataGetMode) { - // Use UnknownLengthPieceStorage. - initPieceStorage(); + // Use UnknownLengthPieceStorage. + initPieceStorage(); } else { - if(e->_requestGroupMan->isSameFileBeingDownloaded(this)) { - throw DOWNLOAD_FAILURE_EXCEPTION - (StringFormat(EX_DUPLICATE_FILE_DOWNLOAD, - _downloadContext->getBasePath().c_str()).str()); - } - initPieceStorage(); - if(_downloadContext->getFileEntries().size() > 1) { - _pieceStorage->setupFileFilter(); - } + if(e->_requestGroupMan->isSameFileBeingDownloaded(this)) { + throw DOWNLOAD_FAILURE_EXCEPTION + (StringFormat(EX_DUPLICATE_FILE_DOWNLOAD, + _downloadContext->getBasePath().c_str()).str()); + } + initPieceStorage(); + if(_downloadContext->getFileEntries().size() > 1) { + _pieceStorage->setupFileFilter(); + } } SharedHandle<DefaultBtProgressInfoFile> progressInfoFile; if(!metadataGetMode) { - progressInfoFile.reset(new DefaultBtProgressInfoFile(_downloadContext, - _pieceStorage, - _option.get())); + progressInfoFile.reset(new DefaultBtProgressInfoFile(_downloadContext, + _pieceStorage, + _option.get())); } BtRuntimeHandle btRuntime(new BtRuntime()); btRuntime->setMaxPeers(_option->getAsInt(PREF_BT_MAX_PEERS)); _btRuntime = btRuntime; if(!progressInfoFile.isNull()) { - progressInfoFile->setBtRuntime(btRuntime); + progressInfoFile->setBtRuntime(btRuntime); } SharedHandle<DefaultPeerStorage> peerStorage - (new DefaultPeerStorage(_option.get())); + (new DefaultPeerStorage(_option.get())); peerStorage->setBtRuntime(btRuntime); peerStorage->setPieceStorage(_pieceStorage); _peerStorage = peerStorage; if(!progressInfoFile.isNull()) { - progressInfoFile->setPeerStorage(peerStorage); + progressInfoFile->setPeerStorage(peerStorage); } SharedHandle<DefaultBtAnnounce> btAnnounce - (new DefaultBtAnnounce(_downloadContext, _option.get())); + (new DefaultBtAnnounce(_downloadContext, _option.get())); btAnnounce->setBtRuntime(btRuntime); btAnnounce->setPieceStorage(_pieceStorage); btAnnounce->setPeerStorage(peerStorage); btAnnounce->setUserDefinedInterval - (_option->getAsInt(PREF_BT_TRACKER_INTERVAL)); + (_option->getAsInt(PREF_BT_TRACKER_INTERVAL)); btAnnounce->shuffleAnnounce(); btRegistry->put(_gid, - BtObject(_downloadContext, - _pieceStorage, - peerStorage, - btAnnounce, - btRuntime, - (progressInfoFile.isNull()? - _progressInfoFile: - SharedHandle<BtProgressInfoFile> - (progressInfoFile)))); + BtObject(_downloadContext, + _pieceStorage, + peerStorage, + btAnnounce, + btRuntime, + (progressInfoFile.isNull()? + _progressInfoFile: + SharedHandle<BtProgressInfoFile> + (progressInfoFile)))); if(metadataGetMode) { - if(_option->getAsBool(PREF_ENABLE_DHT)) { - std::deque<Command*> dhtCommands; - DHTSetup().setup(dhtCommands, e, _option.get()); - e->addCommand(dhtCommands); - } else { - _logger->notice("For BitTorrent Magnet URI, enabling DHT is strongly" - " recommended. See --enable-dht option."); - } - - SharedHandle<CheckIntegrityEntry> entry - (new BtCheckIntegrityEntry(this)); - entry->onDownloadIncomplete(commands, e); - - return; + if(_option->getAsBool(PREF_ENABLE_DHT)) { + std::deque<Command*> dhtCommands; + DHTSetup().setup(dhtCommands, e, _option.get()); + e->addCommand(dhtCommands); + } else { + _logger->notice("For BitTorrent Magnet URI, enabling DHT is strongly" + " recommended. See --enable-dht option."); + } + + SharedHandle<CheckIntegrityEntry> entry + (new BtCheckIntegrityEntry(this)); + entry->onDownloadIncomplete(commands, e); + + return; } // Remove the control file if download file doesn't exist if(progressInfoFile->exists() && !_pieceStorage->getDiskAdaptor()->fileExists()) { - progressInfoFile->removeFile(); - _logger->notice(MSG_REMOVED_DEFUNCT_CONTROL_FILE, - progressInfoFile->getFilename().c_str(), - _downloadContext->getBasePath().c_str()); + progressInfoFile->removeFile(); + _logger->notice(MSG_REMOVED_DEFUNCT_CONTROL_FILE, + progressInfoFile->getFilename().c_str(), + _downloadContext->getBasePath().c_str()); } { - uint64_t actualFileSize = _pieceStorage->getDiskAdaptor()->size(); - if(actualFileSize == _downloadContext->getTotalLength()) { - // First, make DiskAdaptor read-only mode to allow the - // program to seed file in read-only media. - _pieceStorage->getDiskAdaptor()->enableReadOnly(); - } else { - // Open file in writable mode to allow the program - // 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()); - } + uint64_t actualFileSize = _pieceStorage->getDiskAdaptor()->size(); + if(actualFileSize == _downloadContext->getTotalLength()) { + // First, make DiskAdaptor read-only mode to allow the + // program to seed file in read-only media. + _pieceStorage->getDiskAdaptor()->enableReadOnly(); + } else { + // Open file in writable mode to allow the program + // 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()); + } } // Call Load, Save and file allocation command here if(progressInfoFile->exists()) { - // load .aria2 file if it exists. - progressInfoFile->load(); - _pieceStorage->getDiskAdaptor()->openFile(); + // load .aria2 file if it exists. + progressInfoFile->load(); + _pieceStorage->getDiskAdaptor()->openFile(); } else { - if(_pieceStorage->getDiskAdaptor()->fileExists()) { - if(!_option->getAsBool(PREF_CHECK_INTEGRITY) && - !_option->getAsBool(PREF_ALLOW_OVERWRITE) && - !_option->getAsBool(PREF_BT_SEED_UNVERIFIED)) { - // TODO we need this->haltRequested = true? - throw DOWNLOAD_FAILURE_EXCEPTION - (StringFormat - (MSG_FILE_ALREADY_EXISTS, - _downloadContext->getBasePath().c_str()).str()); - } else { - _pieceStorage->getDiskAdaptor()->openFile(); - } - if(_option->getAsBool(PREF_BT_SEED_UNVERIFIED)) { - _pieceStorage->markAllPiecesDone(); - } - } else { - _pieceStorage->getDiskAdaptor()->openFile(); - } + if(_pieceStorage->getDiskAdaptor()->fileExists()) { + if(!_option->getAsBool(PREF_CHECK_INTEGRITY) && + !_option->getAsBool(PREF_ALLOW_OVERWRITE) && + !_option->getAsBool(PREF_BT_SEED_UNVERIFIED)) { + // TODO we need this->haltRequested = true? + throw DOWNLOAD_FAILURE_EXCEPTION + (StringFormat + (MSG_FILE_ALREADY_EXISTS, + _downloadContext->getBasePath().c_str()).str()); + } else { + _pieceStorage->getDiskAdaptor()->openFile(); + } + if(_option->getAsBool(PREF_BT_SEED_UNVERIFIED)) { + _pieceStorage->markAllPiecesDone(); + } + } else { + _pieceStorage->getDiskAdaptor()->openFile(); + } } _progressInfoFile = progressInfoFile; if(torrentAttrs[bittorrent::PRIVATE].i() == 0 && - _option->getAsBool(PREF_ENABLE_DHT)) { - std::deque<Command*> commands; - DHTSetup().setup(commands, e, _option.get()); - e->addCommand(commands); - if(!torrentAttrs[bittorrent::NODES].empty() && DHTSetup::initialized()) { - std::deque<std::pair<std::string, uint16_t> > entryPoints; - const BDE& nodes = torrentAttrs[bittorrent::NODES]; - for(BDE::List::const_iterator i = nodes.listBegin(); - i != nodes.listEnd(); ++i) { - std::pair<std::string, uint16_t> addr - ((*i)[bittorrent::HOSTNAME].s(), (*i)[bittorrent::PORT].i()); - entryPoints.push_back(addr); - } - DHTEntryPointNameResolveCommand* command = - new DHTEntryPointNameResolveCommand(e->newCUID(), e, entryPoints); - command->setTaskQueue(DHTRegistry::_taskQueue); - command->setTaskFactory(DHTRegistry::_taskFactory); - command->setRoutingTable(DHTRegistry::_routingTable); - command->setLocalNode(DHTRegistry::_localNode); - e->commands.push_back(command); - } + _option->getAsBool(PREF_ENABLE_DHT)) { + std::deque<Command*> commands; + DHTSetup().setup(commands, e, _option.get()); + e->addCommand(commands); + if(!torrentAttrs[bittorrent::NODES].empty() && DHTSetup::initialized()) { + std::deque<std::pair<std::string, uint16_t> > entryPoints; + const BDE& nodes = torrentAttrs[bittorrent::NODES]; + for(BDE::List::const_iterator i = nodes.listBegin(); + i != nodes.listEnd(); ++i) { + std::pair<std::string, uint16_t> addr + ((*i)[bittorrent::HOSTNAME].s(), (*i)[bittorrent::PORT].i()); + entryPoints.push_back(addr); + } + DHTEntryPointNameResolveCommand* command = + new DHTEntryPointNameResolveCommand(e->newCUID(), e, entryPoints); + command->setTaskQueue(DHTRegistry::_taskQueue); + command->setTaskFactory(DHTRegistry::_taskFactory); + command->setRoutingTable(DHTRegistry::_routingTable); + command->setLocalNode(DHTRegistry::_localNode); + e->commands.push_back(command); + } } CheckIntegrityEntryHandle entry(new BtCheckIntegrityEntry(this)); // --bt-seed-unverified=true is given and download has completed, skip // validation for piece hashes. if(_option->getAsBool(PREF_BT_SEED_UNVERIFIED) && - _pieceStorage->downloadFinished()) { - entry->onDownloadFinished(commands, e); + _pieceStorage->downloadFinished()) { + entry->onDownloadFinished(commands, e); } else { - processCheckIntegrityEntry(commands, entry, e); + processCheckIntegrityEntry(commands, entry, e); } return; } @@ -393,34 +393,34 @@ void RequestGroup::createInitialCommand }else { if(e->_requestGroupMan->isSameFileBeingDownloaded(this)) { throw DOWNLOAD_FAILURE_EXCEPTION - (StringFormat(EX_DUPLICATE_FILE_DOWNLOAD, - _downloadContext->getBasePath().c_str()).str()); + (StringFormat(EX_DUPLICATE_FILE_DOWNLOAD, + _downloadContext->getBasePath().c_str()).str()); } adjustFilename (SharedHandle<BtProgressInfoFile>(new DefaultBtProgressInfoFile - (_downloadContext, - SharedHandle<PieceStorage>(), - _option.get()))); + (_downloadContext, + SharedHandle<PieceStorage>(), + _option.get()))); initPieceStorage(); BtProgressInfoFileHandle infoFile (new DefaultBtProgressInfoFile(_downloadContext, _pieceStorage, - _option.get())); + _option.get())); if(!infoFile->exists() && downloadFinishedByFileLength()) { _pieceStorage->markAllPiecesDone(); _logger->notice(MSG_DOWNLOAD_ALREADY_COMPLETED, - _gid, _downloadContext->getBasePath().c_str()); + _gid, _downloadContext->getBasePath().c_str()); } else { loadAndOpenFile(infoFile); SharedHandle<CheckIntegrityEntry> checkIntegrityEntry - (new StreamCheckIntegrityEntry(this)); + (new StreamCheckIntegrityEntry(this)); processCheckIntegrityEntry(commands, checkIntegrityEntry, e); } } } void RequestGroup::processCheckIntegrityEntry(std::deque<Command*>& commands, - const CheckIntegrityEntryHandle& entry, - DownloadEngine* e) + const CheckIntegrityEntryHandle& entry, + DownloadEngine* e) { #ifdef ENABLE_MESSAGE_DIGEST if(_option->getAsBool(PREF_CHECK_INTEGRITY) && @@ -450,29 +450,29 @@ void RequestGroup::initPieceStorage() (new DefaultPieceStorage(_downloadContext, _option.get())); if(_downloadContext->hasAttribute(bittorrent::BITTORRENT)) { if(isUriSuppliedForRequsetFileEntry - (_downloadContext->getFileEntries().begin(), - _downloadContext->getFileEntries().end())) { - // Use LongestSequencePieceSelector when HTTP/FTP/BitTorrent - // integrated downloads. Currently multi-file integrated - // download is not supported. - _logger->debug("Using LongestSequencePieceSelector"); - ps->setPieceSelector - (SharedHandle<PieceSelector>(new LongestSequencePieceSelector())); + (_downloadContext->getFileEntries().begin(), + _downloadContext->getFileEntries().end())) { + // Use LongestSequencePieceSelector when HTTP/FTP/BitTorrent + // integrated downloads. Currently multi-file integrated + // download is not supported. + _logger->debug("Using LongestSequencePieceSelector"); + ps->setPieceSelector + (SharedHandle<PieceSelector>(new LongestSequencePieceSelector())); } if(_option->defined(PREF_BT_PRIORITIZE_PIECE)) { - std::vector<size_t> result; - util::parsePrioritizePieceRange - (result, _option->get(PREF_BT_PRIORITIZE_PIECE), - _downloadContext->getFileEntries(), - _downloadContext->getPieceLength()); - if(!result.empty()) { - std::random_shuffle(result.begin(), result.end(), - *(SimpleRandomizer::getInstance().get())); - SharedHandle<PriorityPieceSelector> priSelector - (new PriorityPieceSelector(ps->getPieceSelector())); - priSelector->setPriorityPiece(result.begin(), result.end()); - ps->setPieceSelector(priSelector); - } + std::vector<size_t> result; + util::parsePrioritizePieceRange + (result, _option->get(PREF_BT_PRIORITIZE_PIECE), + _downloadContext->getFileEntries(), + _downloadContext->getPieceLength()); + if(!result.empty()) { + std::random_shuffle(result.begin(), result.end(), + *(SimpleRandomizer::getInstance().get())); + SharedHandle<PriorityPieceSelector> priSelector + (new PriorityPieceSelector(ps->getPieceSelector())); + priSelector->setPriorityPiece(result.begin(), result.end()); + ps->setPieceSelector(priSelector); + } } } #else // !ENABLE_BITTORRENT @@ -532,10 +532,10 @@ void RequestGroup::adjustFilename } else { #ifdef ENABLE_MESSAGE_DIGEST if(outfile.exists() && _option->getAsBool(PREF_CHECK_INTEGRITY)) { - // check-integrity existing file + // check-integrity existing file } else { #endif // ENABLE_MESSAGE_DIGEST - shouldCancelDownloadForSafety(); + shouldCancelDownloadForSafety(); #ifdef ENABLE_MESSAGE_DIGEST } #endif // ENABLE_MESSAGE_DIGEST @@ -554,8 +554,8 @@ void RequestGroup::loadAndOpenFile(const BtProgressInfoFileHandle& progressInfoF if(progressInfoFile->exists() && !_pieceStorage->getDiskAdaptor()->fileExists()) { progressInfoFile->removeFile(); _logger->notice(MSG_REMOVED_DEFUNCT_CONTROL_FILE, - progressInfoFile->getFilename().c_str(), - _downloadContext->getBasePath().c_str()); + progressInfoFile->getFilename().c_str(), + _downloadContext->getBasePath().c_str()); } if(progressInfoFile->exists()) { @@ -564,18 +564,18 @@ void RequestGroup::loadAndOpenFile(const BtProgressInfoFileHandle& progressInfoF } else { File outfile(getFirstFilePath()); if(outfile.exists() && _option->getAsBool(PREF_CONTINUE) && - outfile.size() <= getTotalLength()) { - _pieceStorage->getDiskAdaptor()->openExistingFile(); - _pieceStorage->markPiecesDone(outfile.size()); + outfile.size() <= getTotalLength()) { + _pieceStorage->getDiskAdaptor()->openExistingFile(); + _pieceStorage->markPiecesDone(outfile.size()); } else { #ifdef ENABLE_MESSAGE_DIGEST - if(outfile.exists() && _option->getAsBool(PREF_CHECK_INTEGRITY)) { - _pieceStorage->getDiskAdaptor()->openExistingFile(); - } else { + if(outfile.exists() && _option->getAsBool(PREF_CHECK_INTEGRITY)) { + _pieceStorage->getDiskAdaptor()->openExistingFile(); + } else { #endif // ENABLE_MESSAGE_DIGEST - _pieceStorage->getDiskAdaptor()->initAndOpenFile(); + _pieceStorage->getDiskAdaptor()->initAndOpenFile(); #ifdef ENABLE_MESSAGE_DIGEST - } + } #endif // ENABLE_MESSAGE_DIGEST } } @@ -596,16 +596,16 @@ void RequestGroup::shouldCancelDownloadForSafety() if(outfile.exists()) { if(_option->getAsBool(PREF_AUTO_FILE_RENAMING)) { if(tryAutoFileRenaming()) { - _logger->notice(MSG_FILE_RENAMED, getFirstFilePath().c_str()); + _logger->notice(MSG_FILE_RENAMED, getFirstFilePath().c_str()); } else { - throw DOWNLOAD_FAILURE_EXCEPTION - (StringFormat("File renaming failed: %s", - getFirstFilePath().c_str()).str()); + throw DOWNLOAD_FAILURE_EXCEPTION + (StringFormat("File renaming failed: %s", + getFirstFilePath().c_str()).str()); } } else { throw DOWNLOAD_FAILURE_EXCEPTION - (StringFormat(MSG_FILE_ALREADY_EXISTS, - getFirstFilePath().c_str()).str()); + (StringFormat(MSG_FILE_ALREADY_EXISTS, + getFirstFilePath().c_str()).str()); } } } @@ -628,14 +628,14 @@ bool RequestGroup::tryAutoFileRenaming() } void RequestGroup::createNextCommandWithAdj(std::deque<Command*>& commands, - DownloadEngine* e, int numAdj) + DownloadEngine* e, int numAdj) { int numCommand; if(getTotalLength() == 0) { numCommand = 1+numAdj; } else { numCommand = std::min(_downloadContext->getNumPieces(), - _numConcurrentCommand); + _numConcurrentCommand); numCommand += numAdj; } if(numCommand > 0) { @@ -644,8 +644,8 @@ void RequestGroup::createNextCommandWithAdj(std::deque<Command*>& commands, } void RequestGroup::createNextCommand(std::deque<Command*>& commands, - DownloadEngine* e, - unsigned int numCommand) + DownloadEngine* e, + unsigned int numCommand) { for(; numCommand--; ) { Command* command = new CreateRequestCommand(e->newCUID(), this, e); @@ -694,20 +694,20 @@ uint64_t RequestGroup::getCompletedLength() const } void RequestGroup::validateFilename(const std::string& expectedFilename, - const std::string& actualFilename) const + const std::string& actualFilename) const { if(expectedFilename.empty()) { return; } if(expectedFilename != actualFilename) { throw DL_ABORT_EX(StringFormat(EX_FILENAME_MISMATCH, - expectedFilename.c_str(), - actualFilename.c_str()).str()); + expectedFilename.c_str(), + actualFilename.c_str()).str()); } } void RequestGroup::validateTotalLength(uint64_t expectedTotalLength, - uint64_t actualTotalLength) const + uint64_t actualTotalLength) const { if(expectedTotalLength <= 0) { return; @@ -715,8 +715,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()); } } @@ -809,13 +809,13 @@ void RequestGroup::releaseRuntimeResource(DownloadEngine* e) void RequestGroup::preDownloadProcessing() { _logger->debug("Finding PreDownloadHandler for path %s.", - getFirstFilePath().c_str()); + getFirstFilePath().c_str()); try { for(PreDownloadHandlers::const_iterator itr = _preDownloadHandlers.begin(); - itr != _preDownloadHandlers.end(); ++itr) { + itr != _preDownloadHandlers.end(); ++itr) { if((*itr)->canHandle(this)) { - (*itr)->execute(this); - return; + (*itr)->execute(this); + return; } } } catch(RecoverableException& ex) { @@ -830,13 +830,13 @@ void RequestGroup::postDownloadProcessing (std::deque<SharedHandle<RequestGroup> >& groups) { _logger->debug("Finding PostDownloadHandler for path %s.", - getFirstFilePath().c_str()); + getFirstFilePath().c_str()); try { for(PostDownloadHandlers::const_iterator itr = _postDownloadHandlers.begin(); - itr != _postDownloadHandlers.end(); ++itr) { + itr != _postDownloadHandlers.end(); ++itr) { if((*itr)->canHandle(this)) { - (*itr)->getNextRequestGroups(groups, this); - return; + (*itr)->getNextRequestGroups(groups, this); + return; } } } catch(RecoverableException& ex) { @@ -952,19 +952,19 @@ DownloadResultHandle RequestGroup::createDownloadResult() const return SharedHandle<DownloadResult> (new DownloadResult(_gid, - _downloadContext->getFileEntries(), - _inMemoryDownload, - sessionDownloadLength, - _downloadContext->calculateSessionTime(), - downloadResult(), - _followedByGIDs, - _belongsToGID)); + _downloadContext->getFileEntries(), + _inMemoryDownload, + sessionDownloadLength, + _downloadContext->calculateSessionTime(), + downloadResult(), + _followedByGIDs, + _belongsToGID)); } void RequestGroup::reportDownloadFinished() { _logger->notice(MSG_FILE_DOWNLOAD_COMPLETED, - _downloadContext->getBasePath().c_str()); + _downloadContext->getBasePath().c_str()); _uriSelector->resetCounters(); #ifdef ENABLE_BITTORRENT if(_downloadContext->hasAttribute(bittorrent::BITTORRENT)) { @@ -974,9 +974,9 @@ void RequestGroup::reportDownloadFinished() const BDE& attrs = _downloadContext->getAttribute(bittorrent::BITTORRENT); if(attrs.containsKey(bittorrent::METADATA)) { _logger->notice(MSG_SHARE_RATIO_REPORT, - shareRatio, - util::abbrevSize(stat.getAllTimeUploadLength()).c_str(), - util::abbrevSize(getCompletedLength()).c_str()); + shareRatio, + util::abbrevSize(stat.getAllTimeUploadLength()).c_str(), + util::abbrevSize(getCompletedLength()).c_str()); } } #endif // ENABLE_BITTORRENT @@ -992,7 +992,7 @@ void RequestGroup::addAcceptType(const std::string& type) void RequestGroup::removeAcceptType(const std::string& type) { _acceptTypes.erase(std::remove(_acceptTypes.begin(), _acceptTypes.end(), type), - _acceptTypes.end()); + _acceptTypes.end()); } void RequestGroup::setURISelector(const SharedHandle<URISelector>& uriSelector) @@ -1005,11 +1005,11 @@ void RequestGroup::applyLastModifiedTimeToLocalFiles() if(!_pieceStorage.isNull() && _lastModifiedTime.good()) { time_t t = _lastModifiedTime.getTime(); _logger->info("Applying Last-Modified time: %s in local time zone", - ctime(&t)); + ctime(&t)); size_t n = _pieceStorage->getDiskAdaptor()->utime(Time(), _lastModifiedTime); _logger->info("Last-Modified attrs of %lu files were updated.", - static_cast<unsigned long>(n)); + static_cast<unsigned long>(n)); } } diff --git a/src/RequestGroup.h b/src/RequestGroup.h index da08770b..015a8e1f 100644 --- a/src/RequestGroup.h +++ b/src/RequestGroup.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -167,7 +167,7 @@ private: Logger* _logger; void validateFilename(const std::string& expectedFilename, - const std::string& actualFilename) const; + const std::string& actualFilename) const; void initializePreDownloadHandler(); @@ -201,13 +201,13 @@ public: // If this is HTTP/FTP download and file size is unknown, only 1 command // (usually, HttpInitiateConnection or FtpInitiateConnection) will be created. void createInitialCommand(std::deque<Command*>& commands, - DownloadEngine* e); + DownloadEngine* e); void createNextCommandWithAdj(std::deque<Command*>& commands, - DownloadEngine* e, int numAdj); + DownloadEngine* e, int numAdj); void createNextCommand(std::deque<Command*>& commands, - DownloadEngine* e, unsigned int numCommand); + DownloadEngine* e, unsigned int numCommand); bool downloadFinished() const; @@ -229,7 +229,7 @@ public: void validateFilename(const std::string& actualFilename) const; void validateTotalLength(uint64_t expectedTotalLength, - uint64_t actualTotalLength) const; + uint64_t actualTotalLength) const; void validateTotalLength(uint64_t actualTotalLength) const; @@ -356,8 +356,8 @@ public: void clearPreDownloadHandler(); void processCheckIntegrityEntry(std::deque<Command*>& commands, - const SharedHandle<CheckIntegrityEntry>& entry, - DownloadEngine* e); + const SharedHandle<CheckIntegrityEntry>& entry, + DownloadEngine* e); void initPieceStorage(); diff --git a/src/RequestGroupCriteria.h b/src/RequestGroupCriteria.h index ba7c52ff..daf57abd 100644 --- a/src/RequestGroupCriteria.h +++ b/src/RequestGroupCriteria.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/RequestGroupEntry.cc b/src/RequestGroupEntry.cc index bba57f8b..30c29f69 100644 --- a/src/RequestGroupEntry.cc +++ b/src/RequestGroupEntry.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -40,7 +40,7 @@ namespace aria2 { RequestGroupEntry::RequestGroupEntry(RequestGroup* requestGroup, - Command* nextCommand): + Command* nextCommand): _requestGroup(requestGroup), _nextCommand(nextCommand) { diff --git a/src/RequestGroupEntry.h b/src/RequestGroupEntry.h index 8396da09..a7c56146 100644 --- a/src/RequestGroupEntry.h +++ b/src/RequestGroupEntry.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -49,7 +49,7 @@ protected: Command* _nextCommand; public: RequestGroupEntry(RequestGroup* requestGroup, - Command* nextCommand = 0); + Command* nextCommand = 0); virtual ~RequestGroupEntry(); diff --git a/src/RequestGroupMan.cc b/src/RequestGroupMan.cc index 9fda24fc..ba66655b 100644 --- a/src/RequestGroupMan.cc +++ b/src/RequestGroupMan.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -71,8 +71,8 @@ namespace aria2 { RequestGroupMan::RequestGroupMan(const RequestGroups& requestGroups, - unsigned int maxSimultaneousDownloads, - const Option* option): + unsigned int maxSimultaneousDownloads, + const Option* option): _reservedGroups(requestGroups), _logger(LogFactory::getInstance()), _maxSimultaneousDownloads(maxSimultaneousDownloads), @@ -232,15 +232,15 @@ bool RequestGroupMan::removeReservedGroup(int32_t gid) static void executeHook(const std::string& command, int gid) { LogFactory::getInstance()->info("Executing user command: %s %d", - command.c_str(), gid); + command.c_str(), gid); #ifndef __MINGW32__ pid_t cpid = fork(); if(cpid == -1) { LogFactory::getInstance()->error("fork() failed." - " Cannot execute user command."); + " Cannot execute user command."); } else if(cpid == 0) { execl(command.c_str(), command.c_str(), util::itos(gid).c_str(), - reinterpret_cast<char*>(0)); + reinterpret_cast<char*>(0)); perror(("Could not execute user command: "+command).c_str()); exit(EXIT_FAILURE); } @@ -257,20 +257,20 @@ static void executeHook(const std::string& command, int gid) strappend(cmdline, " ", util::itos(gid)); DWORD rc = CreateProcess( - NULL, - (LPSTR)cmdline.c_str(), - NULL, - NULL, - true, - NULL, - NULL, - 0, - &si, - &pi); + NULL, + (LPSTR)cmdline.c_str(), + NULL, + NULL, + true, + NULL, + NULL, + 0, + &si, + &pi); if(!rc) LogFactory::getInstance()->error("CreateProcess() failed." - " Cannot execute user command."); + " Cannot execute user command."); #endif } @@ -289,7 +289,7 @@ static void executeStopHook !option->blank(PREF_ON_DOWNLOAD_COMPLETE)) { executeHook(option->get(PREF_ON_DOWNLOAD_COMPLETE), result->gid); } else if(result->result != downloadresultcode::IN_PROGRESS && - !option->blank(PREF_ON_DOWNLOAD_ERROR)) { + !option->blank(PREF_ON_DOWNLOAD_ERROR)) { executeHook(option->get(PREF_ON_DOWNLOAD_ERROR), result->gid); } else if(!option->blank(PREF_ON_DOWNLOAD_STOP)) { executeHook(option->get(PREF_ON_DOWNLOAD_STOP), result->gid); @@ -312,9 +312,9 @@ private: // ".sig". std::string signatureFile = group->getFirstFilePath()+".sig"; if(sig->save(signatureFile)) { - _logger->notice(MSG_SIGNATURE_SAVED, signatureFile.c_str()); + _logger->notice(MSG_SIGNATURE_SAVED, signatureFile.c_str()); } else { - _logger->notice(MSG_SIGNATURE_NOT_SAVED, signatureFile.c_str()); + _logger->notice(MSG_SIGNATURE_NOT_SAVED, signatureFile.c_str()); } } } @@ -332,30 +332,30 @@ public: { if(group->getNumCommand() == 0) { try { - group->closeFile(); - if(group->downloadFinished()) { - group->applyLastModifiedTimeToLocalFiles(); - group->reportDownloadFinished(); - if(group->allDownloadFinished()) { - group->removeControlFile(); - saveSignature(group); - } else { - group->saveControlFile(); - } - RequestGroups nextGroups; - group->postDownloadProcessing(nextGroups); - if(!nextGroups.empty()) { - _logger->debug - ("Adding %lu RequestGroups as a result of PostDownloadHandler.", - static_cast<unsigned long>(nextGroups.size())); - _reservedGroups.insert(_reservedGroups.begin(), - nextGroups.begin(), nextGroups.end()); - } - } else { - group->saveControlFile(); - } + group->closeFile(); + if(group->downloadFinished()) { + group->applyLastModifiedTimeToLocalFiles(); + group->reportDownloadFinished(); + if(group->allDownloadFinished()) { + group->removeControlFile(); + saveSignature(group); + } else { + group->saveControlFile(); + } + RequestGroups nextGroups; + group->postDownloadProcessing(nextGroups); + if(!nextGroups.empty()) { + _logger->debug + ("Adding %lu RequestGroups as a result of PostDownloadHandler.", + static_cast<unsigned long>(nextGroups.size())); + _reservedGroups.insert(_reservedGroups.begin(), + nextGroups.begin(), nextGroups.end()); + } + } else { + group->saveControlFile(); + } } catch(RecoverableException& ex) { - _logger->error(EX_EXCEPTION_CAUGHT, ex); + _logger->error(EX_EXCEPTION_CAUGHT, ex); } group->releaseRuntimeResource(_e); _downloadResults.push_back(group->createDownloadResult()); @@ -378,30 +378,30 @@ public: // Collect statistics during download in PeerStats and update/register // ServerStatMan if(!group->getSegmentMan().isNull()) { - bool singleConnection = - group->getSegmentMan()->getPeerStats().size() == 1; - const std::deque<SharedHandle<PeerStat> >& peerStats = - group->getSegmentMan()->getFastestPeerStats(); - for(std::deque<SharedHandle<PeerStat> >::const_iterator i = - peerStats.begin(); i != peerStats.end(); ++i) { - if((*i)->getHostname().empty() || (*i)->getProtocol().empty()) { - continue; - } - int speed = (*i)->getAvgDownloadSpeed(); - if (speed == 0) continue; - - SharedHandle<ServerStat> ss = - _requestGroupMan->getOrCreateServerStat((*i)->getHostname(), - (*i)->getProtocol()); + bool singleConnection = + group->getSegmentMan()->getPeerStats().size() == 1; + const std::deque<SharedHandle<PeerStat> >& peerStats = + group->getSegmentMan()->getFastestPeerStats(); + for(std::deque<SharedHandle<PeerStat> >::const_iterator i = + peerStats.begin(); i != peerStats.end(); ++i) { + if((*i)->getHostname().empty() || (*i)->getProtocol().empty()) { + continue; + } + int speed = (*i)->getAvgDownloadSpeed(); + if (speed == 0) continue; + + SharedHandle<ServerStat> ss = + _requestGroupMan->getOrCreateServerStat((*i)->getHostname(), + (*i)->getProtocol()); ss->increaseCounter(); - ss->updateDownloadSpeed(speed); + ss->updateDownloadSpeed(speed); if(singleConnection) { ss->updateSingleConnectionAvgSpeed(speed); } else { ss->updateMultiConnectionAvgSpeed(speed); } - } + } } } } @@ -417,7 +417,7 @@ public: void RequestGroupMan::updateServerStat() { std::for_each(_requestGroups.begin(), _requestGroups.end(), - CollectServerStat(this)); + CollectServerStat(this)); } void RequestGroupMan::removeStoppedGroup(DownloadEngine* e) @@ -427,13 +427,13 @@ void RequestGroupMan::removeStoppedGroup(DownloadEngine* e) updateServerStat(); std::for_each(_requestGroups.begin(), _requestGroups.end(), - ProcessStoppedRequestGroup(e, _reservedGroups, - _downloadResults)); + ProcessStoppedRequestGroup(e, _reservedGroups, + _downloadResults)); std::deque<SharedHandle<RequestGroup> >::iterator i = std::remove_if(_requestGroups.begin(), - _requestGroups.end(), - FindStoppedRequestGroup()); + _requestGroups.end(), + FindStoppedRequestGroup()); if(i != _requestGroups.end()) { _requestGroups.erase(i, _requestGroups.end()); } @@ -441,7 +441,7 @@ void RequestGroupMan::removeStoppedGroup(DownloadEngine* e) size_t numRemoved = numPrev-_requestGroups.size(); if(numRemoved > 0) { _logger->debug("%lu RequestGroup(s) deleted.", - static_cast<unsigned long>(numRemoved)); + static_cast<unsigned long>(numRemoved)); } } @@ -458,13 +458,13 @@ void RequestGroupMan::configureRequestGroup } else if(uriSelectorValue == V_ADAPTIVE) { requestGroup->setURISelector (SharedHandle<URISelector>(new AdaptiveURISelector(_serverStatMan, - requestGroup.get()))); + requestGroup.get()))); } } static void createInitialCommand(const SharedHandle<RequestGroup>& requestGroup, - std::deque<Command*>& commands, - DownloadEngine* e) + std::deque<Command*>& commands, + DownloadEngine* e) { requestGroup->createInitialCommand(commands, e); } @@ -484,8 +484,8 @@ void RequestGroupMan::fillRequestGroupFromReserver(DownloadEngine* e) Commands commands; try { if(!groupToAdd->isDependencyResolved()) { - temp.push_back(groupToAdd); - continue; + temp.push_back(groupToAdd); + continue; } configureRequestGroup(groupToAdd); createInitialCommand(groupToAdd, commands, e); @@ -521,9 +521,9 @@ void RequestGroupMan::save() (*itr)->removeControlFile(); } else { try { - (*itr)->saveControlFile(); + (*itr)->saveControlFile(); } catch(RecoverableException& e) { - _logger->error(EX_EXCEPTION_CAUGHT, e); + _logger->error(EX_EXCEPTION_CAUGHT, e); } } } @@ -562,7 +562,7 @@ RequestGroupMan::DownloadStat RequestGroupMan::getDownloadStat() const } } return DownloadStat(finished, error, inprogress, _reservedGroups.size(), - lastError); + lastError); } void RequestGroupMan::showDownloadResults(std::ostream& o) const @@ -611,7 +611,7 @@ void RequestGroupMan::showDownloadResults(std::ostream& o) const // Reset download stop time and assign sessionTime here. (*itr)->getDownloadContext()->resetDownloadStopTime(); result->sessionTime = - (*itr)->getDownloadContext()->calculateSessionTime(); + (*itr)->getDownloadContext()->calculateSessionTime(); status = MARK_INPR; ++inpr; } @@ -651,15 +651,15 @@ std::string RequestGroupMan::formatDownloadResult(const std::string& status, con const std::vector<SharedHandle<FileEntry> >& fileEntries = downloadResult->fileEntries; writeFilePath(fileEntries.begin(), fileEntries.end(), o, - downloadResult->inMemoryDownload); + downloadResult->inMemoryDownload); return o.str(); } template<typename StringInputIterator, typename FileEntryInputIterator> static bool sameFilePathExists(StringInputIterator sfirst, - StringInputIterator slast, - FileEntryInputIterator ffirst, - FileEntryInputIterator flast) + StringInputIterator slast, + FileEntryInputIterator ffirst, + FileEntryInputIterator flast) { for(; ffirst != flast; ++ffirst) { if(std::binary_search(sfirst, slast, (*ffirst)->getPath())) { @@ -681,17 +681,17 @@ bool RequestGroupMan::isSameFileBeingDownloaded(RequestGroup* requestGroup) cons itr != _requestGroups.end(); ++itr) { if((*itr).get() != requestGroup) { const std::vector<SharedHandle<FileEntry> >& entries = - (*itr)->getDownloadContext()->getFileEntries(); + (*itr)->getDownloadContext()->getFileEntries(); std::transform(entries.begin(), entries.end(), - std::back_inserter(files), - mem_fun_sh(&FileEntry::getPath)); + std::back_inserter(files), + mem_fun_sh(&FileEntry::getPath)); } } std::sort(files.begin(), files.end()); const std::vector<SharedHandle<FileEntry> >& entries = requestGroup->getDownloadContext()->getFileEntries(); return sameFilePathExists(files.begin(), files.end(), - entries.begin(), entries.end()); + entries.begin(), entries.end()); } void RequestGroupMan::halt() @@ -714,7 +714,7 @@ TransferStat RequestGroupMan::calculateStat() { TransferStat s; for(std::deque<SharedHandle<RequestGroup> >::const_iterator i = - _requestGroups.begin(); i != _requestGroups.end(); ++i) { + _requestGroups.begin(); i != _requestGroups.end(); ++i) { s += (*i)->calculateStat(); } return s; @@ -724,7 +724,7 @@ SharedHandle<DownloadResult> RequestGroupMan::findDownloadResult(int32_t gid) const { for(std::deque<SharedHandle<DownloadResult> >::const_iterator i = - _downloadResults.begin(); i != _downloadResults.end(); ++i) { + _downloadResults.begin(); i != _downloadResults.end(); ++i) { if((*i)->gid == gid) { return *i; } @@ -739,14 +739,14 @@ void RequestGroupMan::purgeDownloadResult() SharedHandle<ServerStat> RequestGroupMan::findServerStat(const std::string& hostname, - const std::string& protocol) const + const std::string& protocol) const { return _serverStatMan->find(hostname, protocol); } SharedHandle<ServerStat> RequestGroupMan::getOrCreateServerStat(const std::string& hostname, - const std::string& protocol) + const std::string& protocol) { SharedHandle<ServerStat> ss = findServerStat(hostname, protocol); if(ss.isNull()) { @@ -785,7 +785,7 @@ bool RequestGroupMan::saveServerStat(const std::string& filename) const std::ofstream out(tempfile.c_str(), std::ios::binary); if(!out) { _logger->error(MSG_OPENING_WRITABLE_SERVER_STAT_FILE_FAILED, - filename.c_str()); + filename.c_str()); return false; } if(!_serverStatMan->save(out)) { diff --git a/src/RequestGroupMan.h b/src/RequestGroupMan.h index c579c095..7f138f72 100644 --- a/src/RequestGroupMan.h +++ b/src/RequestGroupMan.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -78,14 +78,14 @@ private: std::string formatDownloadResult(const std::string& status, - const SharedHandle<DownloadResult>& downloadResult) const; + const SharedHandle<DownloadResult>& downloadResult) const; void configureRequestGroup (const SharedHandle<RequestGroup>& requestGroup) const; public: RequestGroupMan(const std::deque<SharedHandle<RequestGroup> >& requestGroups, - unsigned int maxSimultaneousDownloads, - const Option* option); + unsigned int maxSimultaneousDownloads, + const Option* option); bool downloadFinished(); @@ -113,7 +113,7 @@ public: void insertReservedGroup(size_t pos, const SharedHandle<RequestGroup>& group); size_t countRequestGroup() const; - + SharedHandle<RequestGroup> getRequestGroup(size_t index) const; const std::deque<SharedHandle<RequestGroup> >& getRequestGroups() const @@ -164,11 +164,11 @@ public: downloadresultcode::RESULT _lastErrorResult; public: DownloadStat(size_t completed, - size_t error, - size_t inProgress, - size_t waiting, - downloadresultcode::RESULT lastErrorResult = - downloadresultcode::FINISHED): + size_t error, + size_t inProgress, + size_t waiting, + downloadresultcode::RESULT lastErrorResult = + downloadresultcode::FINISHED): _completed(completed), _error(error), _inProgress(inProgress), @@ -204,10 +204,10 @@ public: void purgeDownloadResult(); SharedHandle<ServerStat> findServerStat(const std::string& hostname, - const std::string& protocol) const; + const std::string& protocol) const; SharedHandle<ServerStat> getOrCreateServerStat(const std::string& hostname, - const std::string& protocol); + const std::string& protocol); bool addServerStat(const SharedHandle<ServerStat>& serverStat); diff --git a/src/RequestSlot.cc b/src/RequestSlot.cc index e007ca62..44ca28ad 100644 --- a/src/RequestSlot.cc +++ b/src/RequestSlot.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/RequestSlot.h b/src/RequestSlot.h index 5c25b816..e9724b2f 100644 --- a/src/RequestSlot.h +++ b/src/RequestSlot.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -72,7 +72,7 @@ private: public: RequestSlot(size_t index, uint32_t begin, size_t length, size_t blockIndex, - const SharedHandle<Piece>& piece = SharedHandle<Piece>()): + const SharedHandle<Piece>& piece = SharedHandle<Piece>()): index(index), begin(begin), length(length), blockIndex(blockIndex), _piece(piece) {} diff --git a/src/SeedCheckCommand.cc b/src/SeedCheckCommand.cc index 680f1fdb..8e97835c 100644 --- a/src/SeedCheckCommand.cc +++ b/src/SeedCheckCommand.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -45,9 +45,9 @@ namespace aria2 { SeedCheckCommand::SeedCheckCommand(int cuid, - RequestGroup* requestGroup, - DownloadEngine* e, - const SeedCriteriaHandle& seedCriteria) + RequestGroup* requestGroup, + DownloadEngine* e, + const SeedCriteriaHandle& seedCriteria) :Command(cuid), _requestGroup(requestGroup), e(e), diff --git a/src/SeedCheckCommand.h b/src/SeedCheckCommand.h index 7795e68f..43c0592b 100644 --- a/src/SeedCheckCommand.h +++ b/src/SeedCheckCommand.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -57,9 +57,9 @@ private: bool checkStarted; public: SeedCheckCommand(int cuid, - RequestGroup* requestGroup, - DownloadEngine* e, - const SharedHandle<SeedCriteria>& seedCriteria); + RequestGroup* requestGroup, + DownloadEngine* e, + const SharedHandle<SeedCriteria>& seedCriteria); virtual ~SeedCheckCommand(); diff --git a/src/SeedCriteria.h b/src/SeedCriteria.h index d30ee910..22efe8a4 100644 --- a/src/SeedCriteria.h +++ b/src/SeedCriteria.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/Segment.h b/src/Segment.h index 917bf236..a5017b82 100644 --- a/src/Segment.h +++ b/src/Segment.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -72,7 +72,7 @@ public: // `begin' is a offset inside this segment. virtual bool updateHash(uint32_t begin, - const unsigned char* data, size_t dataLength) = 0; + const unsigned char* data, size_t dataLength) = 0; virtual bool isHashCalculated() const = 0; diff --git a/src/SegmentMan.cc b/src/SegmentMan.cc index 0d157838..c0c3116b 100644 --- a/src/SegmentMan.cc +++ b/src/SegmentMan.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -60,8 +60,8 @@ SegmentEntry::SegmentEntry(cuid_t cuid, const SegmentHandle& segment): SegmentEntry::~SegmentEntry() {} SegmentMan::SegmentMan(const Option* option, - const SharedHandle<DownloadContext>& downloadContext, - const PieceStorageHandle& pieceStorage): + const SharedHandle<DownloadContext>& downloadContext, + const PieceStorageHandle& pieceStorage): _option(option), logger(LogFactory::getInstance()), _downloadContext(downloadContext), @@ -69,7 +69,7 @@ SegmentMan::SegmentMan(const Option* option, _lastPeerStatDlspdMapUpdated(0), _cachedDlspd(0), _ignoreBitfield(downloadContext->getPieceLength(), - downloadContext->getTotalLength()) + downloadContext->getTotalLength()) { _ignoreBitfield.enableFilter(); } @@ -95,7 +95,7 @@ uint64_t SegmentMan::getTotalLength() const if(_pieceStorage.isNull()) { return 0; } else { - return _pieceStorage->getTotalLength(); + return _pieceStorage->getTotalLength(); } } @@ -111,7 +111,7 @@ void SegmentMan::setDownloadContext } SegmentHandle SegmentMan::checkoutSegment(cuid_t cuid, - const PieceHandle& piece) + const PieceHandle& piece) { if(piece.isNull()) { return SharedHandle<Segment>(); @@ -128,23 +128,23 @@ SegmentHandle SegmentMan::checkoutSegment(cuid_t cuid, usedSegmentEntries.push_back(entry); logger->debug("index=%d, length=%d, segmentLength=%d, writtenLength=%d", - segment->getIndex(), - segment->getLength(), - segment->getSegmentLength(), - segment->getWrittenLength()); + segment->getIndex(), + segment->getLength(), + segment->getSegmentLength(), + segment->getWrittenLength()); if(piece->getLength() > 0) { std::map<size_t, size_t>::iterator positr = _segmentWrittenLengthMemo.find(segment->getIndex()); if(positr != _segmentWrittenLengthMemo.end()) { const size_t writtenLength = (*positr).second; logger->debug("writtenLength(in memo)=%d, writtenLength=%d", - writtenLength, segment->getWrittenLength()); + writtenLength, segment->getWrittenLength()); // If the difference between cached writtenLength and segment's // writtenLength is less than one block, we assume that these // missing bytes are already downloaded. if(segment->getWrittenLength() < writtenLength && - writtenLength-segment->getWrittenLength() < piece->getBlockLength()) { - segment->updateWrittenLength(writtenLength-segment->getWrittenLength()); + writtenLength-segment->getWrittenLength() < piece->getBlockLength()) { + segment->updateWrittenLength(writtenLength-segment->getWrittenLength()); } } } @@ -152,7 +152,7 @@ SegmentHandle SegmentMan::checkoutSegment(cuid_t cuid, } void SegmentMan::getInFlightSegment(std::deque<SharedHandle<Segment> >& segments, - cuid_t cuid) + cuid_t cuid) { for(SegmentEntries::iterator itr = usedSegmentEntries.begin(); itr != usedSegmentEntries.end(); ++itr) { @@ -171,9 +171,9 @@ SegmentHandle SegmentMan::getSegment(cuid_t cuid) { } void SegmentMan::getSegment(std::deque<SharedHandle<Segment> >& segments, - cuid_t cuid, - const SharedHandle<FileEntry>& fileEntry, - size_t maxSegments) + cuid_t cuid, + const SharedHandle<FileEntry>& fileEntry, + size_t maxSegments) { BitfieldMan filter(_ignoreBitfield); filter.enableFilter(); @@ -182,8 +182,8 @@ void SegmentMan::getSegment(std::deque<SharedHandle<Segment> >& segments, while(segments.size() < maxSegments) { SharedHandle<Segment> segment = checkoutSegment(cuid, - _pieceStorage->getSparseMissingUnusedPiece - (filter.getFilterBitfield(), filter.getBitfieldLength())); + _pieceStorage->getSparseMissingUnusedPiece + (filter.getFilterBitfield(), filter.getBitfieldLength())); if(segment.isNull()) { break; } @@ -212,7 +212,7 @@ void SegmentMan::cancelSegment(const SharedHandle<Segment>& segment) _pieceStorage->cancelPiece(segment->getPiece()); _segmentWrittenLengthMemo[segment->getIndex()] = segment->getWrittenLength(); logger->debug("Memorized segment index=%u, writtenLength=%u", - segment->getIndex(), segment->getWrittenLength()); + segment->getIndex(), segment->getWrittenLength()); } void SegmentMan::cancelSegment(cuid_t cuid) { @@ -258,8 +258,8 @@ bool SegmentMan::completeSegment(cuid_t cuid, const SegmentHandle& segment) { _pieceStorage->completePiece(segment->getPiece()); _pieceStorage->advertisePiece(cuid, segment->getPiece()->getIndex()); SegmentEntries::iterator itr = std::find_if(usedSegmentEntries.begin(), - usedSegmentEntries.end(), - FindSegmentEntry(segment)); + usedSegmentEntries.end(), + FindSegmentEntry(segment)); if(itr == usedSegmentEntries.end()) { return false; } else { @@ -310,7 +310,7 @@ void SegmentMan::updateFastestPeerStat(const SharedHandle<PeerStat>& peerStat) { std::deque<SharedHandle<PeerStat> >::iterator i = std::find_if(_fastestPeerStats.begin(), _fastestPeerStats.end(), - PeerStatHostProtoEqual(peerStat)); + PeerStatHostProtoEqual(peerStat)); if(i == _fastestPeerStats.end()) { _fastestPeerStats.push_back(peerStat); } else if((*i)->getAvgDownloadSpeed() < peerStat->getAvgDownloadSpeed()) { @@ -330,11 +330,11 @@ unsigned int SegmentMan::calculateDownloadSpeed() _lastPeerStatDlspdMapUpdated.reset(); _peerStatDlspdMap.clear(); for(std::deque<SharedHandle<PeerStat> >::const_iterator i = - peerStats.begin(); i != peerStats.end(); ++i) { + peerStats.begin(); i != peerStats.end(); ++i) { if((*i)->getStatus() == PeerStat::ACTIVE) { - unsigned int s = (*i)->calculateDownloadSpeed(); - _peerStatDlspdMap[(*i)->getCuid()] = s; - speed += s; + unsigned int s = (*i)->calculateDownloadSpeed(); + _peerStatDlspdMap[(*i)->getCuid()] = s; + speed += s; } } _cachedDlspd = speed; @@ -368,7 +368,7 @@ public: uint64_t SegmentMan::calculateSessionDownloadLength() const { return std::accumulate(_fastestPeerStats.begin(), _fastestPeerStats.end(), - 0LL, PeerStatDownloadLengthOperator()); + 0LL, PeerStatDownloadLengthOperator()); } size_t SegmentMan::countFreePieceFrom(size_t index) const diff --git a/src/SegmentMan.h b/src/SegmentMan.h index 3ebcaf51..b0889dd8 100644 --- a/src/SegmentMan.h +++ b/src/SegmentMan.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -104,13 +104,13 @@ private: BitfieldMan _ignoreBitfield; SharedHandle<Segment> checkoutSegment(cuid_t cuid, - const SharedHandle<Piece>& piece); + const SharedHandle<Piece>& piece); void cancelSegment(const SharedHandle<Segment>& segment); public: SegmentMan(const Option* option, - const SharedHandle<DownloadContext>& downloadContext, - const SharedHandle<PieceStorage>& pieceStorage); + const SharedHandle<DownloadContext>& downloadContext, + const SharedHandle<PieceStorage>& pieceStorage); ~SegmentMan(); @@ -138,16 +138,16 @@ public: * This function doesn't clear passed segments. */ void getInFlightSegment(std::deque<SharedHandle<Segment> >& segments, - cuid_t cuid); + cuid_t cuid); SharedHandle<Segment> getSegment(cuid_t cuid); // Checkouts segments in the range of fileEntry and push back to // segments until segments.size() < maxSegments holds false void getSegment(std::deque<SharedHandle<Segment> >& segments, - cuid_t cuid, - const SharedHandle<FileEntry>& fileEntry, - size_t maxSegments); + cuid_t cuid, + const SharedHandle<FileEntry>& fileEntry, + size_t maxSegments); /** * Returns a segment whose index is index. diff --git a/src/SegmentManFactory.h b/src/SegmentManFactory.h index b06f1640..231e3fb9 100644 --- a/src/SegmentManFactory.h +++ b/src/SegmentManFactory.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -50,7 +50,7 @@ public: virtual SharedHandle<SegmentMan> createNewInstance(const SharedHandle<DownloadContext>& dc, - const SharedHandle<PieceStorage>& ps) = 0; + const SharedHandle<PieceStorage>& ps) = 0; }; typedef SharedHandle<SegmentManFactory> SegmentManFactoryHandle; diff --git a/src/SelectEventPoll.cc b/src/SelectEventPoll.cc index 2f1446fc..19d1eff0 100644 --- a/src/SelectEventPoll.cc +++ b/src/SelectEventPoll.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -118,7 +118,7 @@ int SelectEventPoll::SocketEntry::getEvents() { return std::accumulate(_commandEvents.begin(), _commandEvents.end(), 0, - accumulateEvent); + accumulateEvent); } #ifdef ENABLE_ASYNC_DNS @@ -249,7 +249,7 @@ void SelectEventPoll::updateFdSet() } bool SelectEventPoll::addEvents(sock_t socket, Command* command, - EventPoll::EventType events) + EventPoll::EventType events) { SharedHandle<SocketEntry> socketEntry(new SocketEntry(socket)); std::deque<SharedHandle<SocketEntry> >::iterator i = @@ -271,7 +271,7 @@ bool SelectEventPoll::addEvents(sock_t socket, Command* command, } bool SelectEventPoll::deleteEvents(sock_t socket, Command* command, - EventPoll::EventType events) + EventPoll::EventType events) { SharedHandle<SocketEntry> socketEntry(new SocketEntry(socket)); std::deque<SharedHandle<SocketEntry> >::iterator i = diff --git a/src/SelectEventPoll.h b/src/SelectEventPoll.h index a60b7a6b..4db555d3 100644 --- a/src/SelectEventPoll.h +++ b/src/SelectEventPoll.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -139,12 +139,12 @@ private: public: AsyncNameResolverEntry(const SharedHandle<AsyncNameResolver>& nameResolver, - Command* command); + Command* command); bool operator==(const AsyncNameResolverEntry& entry) { return _nameResolver == entry._nameResolver && - _command == entry._command; + _command == entry._command; } int getFds(fd_set* rfdsPtr, fd_set* wfdsPtr); @@ -179,14 +179,14 @@ public: virtual void poll(const struct timeval& tv); virtual bool addEvents(sock_t socket, - Command* command, EventPoll::EventType events); + Command* command, EventPoll::EventType events); virtual bool deleteEvents(sock_t socket, - Command* command, EventPoll::EventType events); + Command* command, EventPoll::EventType events); #ifdef ENABLE_ASYNC_DNS virtual bool addNameResolver(const SharedHandle<AsyncNameResolver>& resolver, - Command* command); + Command* command); virtual bool deleteNameResolver (const SharedHandle<AsyncNameResolver>& resolver, Command* command); #endif // ENABLE_ASYNC_DNS diff --git a/src/Sequence.h b/src/Sequence.h index 9364d70e..4fdbe185 100644 --- a/src/Sequence.h +++ b/src/Sequence.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/SequentialDispatcherCommand.h b/src/SequentialDispatcherCommand.h index 49b80f17..e7de64fd 100644 --- a/src/SequentialDispatcherCommand.h +++ b/src/SequentialDispatcherCommand.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -53,8 +53,8 @@ protected: DownloadEngine* _e; public: SequentialDispatcherCommand(int32_t cuid, - const SharedHandle<SequentialPicker<T> >& picker, - DownloadEngine* e): + const SharedHandle<SequentialPicker<T> >& picker, + DownloadEngine* e): Command(cuid), _picker(picker), _e(e) { setStatusRealtime(); diff --git a/src/SequentialPicker.h b/src/SequentialPicker.h index 9d2f45dc..1e0779a2 100644 --- a/src/SequentialPicker.h +++ b/src/SequentialPicker.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/ServerStat.cc b/src/ServerStat.cc index 3b522a5e..1e2a36a1 100644 --- a/src/ServerStat.cc +++ b/src/ServerStat.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -102,15 +102,15 @@ void ServerStat::updateSingleConnectionAvgSpeed(unsigned int downloadSpeed) } if(avgDownloadSpeed < (int)(0.80*_singleConnectionAvgSpeed)) { _logger->debug("ServerStat:%s: resetting counter since single connection" - " speed dropped", getHostname().c_str()); + " speed dropped", getHostname().c_str()); _counter = 0; } _logger->debug("ServerStat:%s: _singleConnectionAvgSpeed old:%.2fKB/s" - " new:%.2fKB/s last:%.2fKB/s", - getHostname().c_str(), - (float) _singleConnectionAvgSpeed/1024, - (float) avgDownloadSpeed/1024, - (float) downloadSpeed / 1024); + " new:%.2fKB/s last:%.2fKB/s", + getHostname().c_str(), + (float) _singleConnectionAvgSpeed/1024, + (float) avgDownloadSpeed/1024, + (float) downloadSpeed / 1024); _singleConnectionAvgSpeed = (int)avgDownloadSpeed; } @@ -135,11 +135,11 @@ void ServerStat::updateMultiConnectionAvgSpeed(unsigned int downloadSpeed) ((1.0/5.0)*(float)downloadSpeed); } _logger->debug("ServerStat:%s: _multiConnectionAvgSpeed old:%.2fKB/s" - " new:%.2fKB/s last:%.2fKB/s", - getHostname().c_str(), - (float) _multiConnectionAvgSpeed/1024, - (float) avgDownloadSpeed/1024, - (float) downloadSpeed / 1024); + " new:%.2fKB/s last:%.2fKB/s", + getHostname().c_str(), + (float) _multiConnectionAvgSpeed/1024, + (float) avgDownloadSpeed/1024, + (float) downloadSpeed / 1024); _multiConnectionAvgSpeed = (int)avgDownloadSpeed; } @@ -162,19 +162,19 @@ void ServerStat::setStatus(const std::string& status) { size_t len = arrayLength(STATUS_STRING); const std::string* p = std::find(&STATUS_STRING[0], - &STATUS_STRING[len], - status); + &STATUS_STRING[len], + status); if(p != &STATUS_STRING[len]) { _status = static_cast<STATUS>(ServerStat::OK+ - std::distance(&STATUS_STRING[0], p)); + std::distance(&STATUS_STRING[0], p)); } } void ServerStat::setStatusInternal(STATUS status) { _logger->debug("ServerStat: set status %s for %s (%s)", - STATUS_STRING[status].c_str(), - _hostname.c_str(), _protocol.c_str()); + STATUS_STRING[status].c_str(), + _hostname.c_str(), _protocol.c_str()); _status = status; _lastUpdated.reset(); } diff --git a/src/ServerStat.h b/src/ServerStat.h index 28150573..696d04e0 100644 --- a/src/ServerStat.h +++ b/src/ServerStat.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/ServerStatMan.cc b/src/ServerStatMan.cc index e1e12a8b..ba403420 100644 --- a/src/ServerStatMan.cc +++ b/src/ServerStatMan.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -51,7 +51,7 @@ ServerStatMan::ServerStatMan() {} ServerStatMan::~ServerStatMan() {} SharedHandle<ServerStat> ServerStatMan::find(const std::string& hostname, - const std::string& protocol) const + const std::string& protocol) const { SharedHandle<ServerStat> ss(new ServerStat(hostname, protocol)); std::deque<SharedHandle<ServerStat> >::const_iterator i = @@ -80,7 +80,7 @@ bool ServerStatMan::add(const SharedHandle<ServerStat>& serverStat) bool ServerStatMan::save(std::ostream& out) const { std::copy(_serverStats.begin(), _serverStats.end(), - std::ostream_iterator<SharedHandle<ServerStat> >(out, "\n")); + std::ostream_iterator<SharedHandle<ServerStat> >(out, "\n")); out.flush(); return !out.bad(); } @@ -106,7 +106,7 @@ bool ServerStatMan::load(std::istream& in) util::split(line, std::back_inserter(items), ","); std::map<std::string, std::string> m; for(std::vector<std::string>::const_iterator i = items.begin(); - i != items.end(); ++i) { + i != items.end(); ++i) { std::pair<std::string, std::string> p = util::split(*i, "="); util::trimSelf(p.first); util::trimSelf(p.second); @@ -120,15 +120,15 @@ bool ServerStatMan::load(std::istream& in) 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->setStatus(m[S_STATUS]); @@ -155,8 +155,8 @@ public: void ServerStatMan::removeStaleServerStat(time_t timeout) { _serverStats.erase(std::remove_if(_serverStats.begin(), _serverStats.end(), - FindStaleServerStat(timeout)), - _serverStats.end()); + FindStaleServerStat(timeout)), + _serverStats.end()); } } // namespace aria2 diff --git a/src/ServerStatMan.h b/src/ServerStatMan.h index 574dc085..8bd29a4f 100644 --- a/src/ServerStatMan.h +++ b/src/ServerStatMan.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -51,7 +51,7 @@ public: ~ServerStatMan(); SharedHandle<ServerStat> find(const std::string& hostname, - const std::string& protocol) const; + const std::string& protocol) const; bool add(const SharedHandle<ServerStat>& serverStat); diff --git a/src/ShareRatioSeedCriteria.h b/src/ShareRatioSeedCriteria.h index e4eec635..461c75c8 100644 --- a/src/ShareRatioSeedCriteria.h +++ b/src/ShareRatioSeedCriteria.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -65,7 +65,7 @@ public: TransferStat stat = _peerStorage->calculateStat(); return ratio <= (double)stat.getAllTimeUploadLength()/ - _pieceStorage->getCompletedLength(); + _pieceStorage->getCompletedLength(); } void setRatio(double ratio) { diff --git a/src/SharedHandle.h b/src/SharedHandle.h index 2deacf5f..a512bb54 100644 --- a/src/SharedHandle.h +++ b/src/SharedHandle.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -180,11 +180,11 @@ private: template<typename T1, typename T2> friend bool operator==(const SharedHandle<T1>& t1, - const SharedHandle<T2>& t2); + const SharedHandle<T2>& t2); template<typename T1, typename T2> friend bool operator!=(const SharedHandle<T1>& t1, - const SharedHandle<T2>& t2); + const SharedHandle<T2>& t2); template<typename T1, typename T2> friend bool operator<(const SharedHandle<T1>& t1, const SharedHandle<T2>& t2); @@ -298,11 +298,11 @@ private: template<typename T1, typename T2> friend bool operator==(const WeakHandle<T1>& t1, - const WeakHandle<T2>& t2); + const WeakHandle<T2>& t2); template<typename T1, typename T2> friend bool operator!=(const WeakHandle<T1>& t1, - const WeakHandle<T2>& t2); + const WeakHandle<T2>& t2); template<typename T1, typename T2> friend bool operator<(const WeakHandle<T1>& t1, const WeakHandle<T2>& t2); diff --git a/src/Signature.cc b/src/Signature.cc index ee1d5987..82f718ed 100644 --- a/src/Signature.cc +++ b/src/Signature.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/Signature.h b/src/Signature.h index 893641ea..184d743f 100644 --- a/src/Signature.h +++ b/src/Signature.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/SimpleBtMessage.cc b/src/SimpleBtMessage.cc index b90ad04c..22025c93 100644 --- a/src/SimpleBtMessage.cc +++ b/src/SimpleBtMessage.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -56,9 +56,9 @@ void SimpleBtMessage::send() { const unsigned char* msg = getMessage(); size_t msgLength = getMessageLength(); logger->info(MSG_SEND_PEER_MESSAGE, - cuid, peer->ipaddr.c_str(), peer->port, toString().c_str()); + cuid, peer->ipaddr.c_str(), peer->port, toString().c_str()); logger->debug("msglength = %lu bytes", - static_cast<unsigned long>(msgLength)); + static_cast<unsigned long>(msgLength)); peerConnection->sendMessage(msg, msgLength); } else { peerConnection->sendPendingData(); diff --git a/src/SimpleBtMessage.h b/src/SimpleBtMessage.h index c5647b93..ea737bab 100644 --- a/src/SimpleBtMessage.h +++ b/src/SimpleBtMessage.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/SimpleLogger.cc b/src/SimpleLogger.cc index d9cf1fa5..4b3382e5 100644 --- a/src/SimpleLogger.cc +++ b/src/SimpleLogger.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -65,7 +65,7 @@ void SimpleLogger::writeLog strftime(datestr, sizeof(datestr), "%Y-%m-%d %H:%M:%S", &tm); assert(dateLength <= (size_t)20); snprintf(datestr+dateLength, sizeof(datestr)-dateLength, - ".%06ld", tv.tv_usec); + ".%06ld", tv.tv_usec); writeHeader(o, datestr, logLevelLabel); { char buf[1024]; diff --git a/src/SimpleLogger.h b/src/SimpleLogger.h index ebd0e450..603ddaa5 100644 --- a/src/SimpleLogger.h +++ b/src/SimpleLogger.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/SimpleRandomizer.cc b/src/SimpleRandomizer.cc index f3aba6bc..b0fcb98c 100644 --- a/src/SimpleRandomizer.cc +++ b/src/SimpleRandomizer.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/SimpleRandomizer.h b/src/SimpleRandomizer.h index 62b4f79c..5bf32929 100644 --- a/src/SimpleRandomizer.h +++ b/src/SimpleRandomizer.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/SingleFileAllocationIterator.cc b/src/SingleFileAllocationIterator.cc index 8bb188d8..5dc463db 100644 --- a/src/SingleFileAllocationIterator.cc +++ b/src/SingleFileAllocationIterator.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/SingleFileAllocationIterator.h b/src/SingleFileAllocationIterator.h index 60e56105..5347c3e4 100644 --- a/src/SingleFileAllocationIterator.h +++ b/src/SingleFileAllocationIterator.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/SingletonHolder.h b/src/SingletonHolder.h index a63c2fe9..18edb279 100644 --- a/src/SingletonHolder.h +++ b/src/SingletonHolder.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/SleepCommand.cc b/src/SleepCommand.cc index 5fd18604..9dde2176 100644 --- a/src/SleepCommand.cc +++ b/src/SleepCommand.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -40,8 +40,8 @@ namespace aria2 { SleepCommand::SleepCommand(int32_t cuid, DownloadEngine* e, - RequestGroup* requestGroup, - Command* nextCommand, time_t wait): + RequestGroup* requestGroup, + Command* nextCommand, time_t wait): Command(cuid), engine(e), _requestGroup(requestGroup), nextCommand(nextCommand), wait(wait) {} diff --git a/src/SleepCommand.h b/src/SleepCommand.h index 3e64eebe..4e279a99 100644 --- a/src/SleepCommand.h +++ b/src/SleepCommand.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -52,7 +52,7 @@ private: Time checkPoint; public: SleepCommand(int32_t cuid, DownloadEngine* e, RequestGroup* requestGroup, - Command* nextCommand, time_t wait); + Command* nextCommand, time_t wait); virtual ~SleepCommand(); bool execute(); }; diff --git a/src/Socket.h b/src/Socket.h index 603f7db7..83725e45 100644 --- a/src/Socket.h +++ b/src/Socket.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/SocketBuffer.cc b/src/SocketBuffer.cc index fa0540b6..4797a1e1 100644 --- a/src/SocketBuffer.cc +++ b/src/SocketBuffer.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -60,7 +60,7 @@ ssize_t SocketBuffer::send() return 0; } ssize_t len = _socket->writeData(_sendbuf.c_str(), - _sendbuf.size()); + _sendbuf.size()); _sendbuf.erase(0, len); return len; } diff --git a/src/SocketBuffer.h b/src/SocketBuffer.h index 36c31e46..28fd29ab 100644 --- a/src/SocketBuffer.h +++ b/src/SocketBuffer.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/SocketCore.cc b/src/SocketCore.cc index 0eded16e..cf0cbc4f 100644 --- a/src/SocketCore.cc +++ b/src/SocketCore.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -167,7 +167,7 @@ std::string uitos(T value) } static sock_t bindInternal(int family, int socktype, int protocol, - const struct sockaddr* addr, socklen_t addrlen) + const struct sockaddr* addr, socklen_t addrlen) { sock_t fd = socket(family, socktype, protocol); if(fd == (sock_t) -1) { @@ -175,7 +175,7 @@ static sock_t bindInternal(int family, int socktype, int protocol, } int sockopt = 1; if(setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, (a2_sockopt_t) &sockopt, - sizeof(sockopt)) < 0) { + sizeof(sockopt)) < 0) { CLOSE(fd); return -1; } @@ -193,7 +193,7 @@ static sock_t bindTo { struct addrinfo* res; int s = callGetaddrinfo(&res, host, uitos(port).c_str(), family, sockType, - getaddrinfoFlags, 0); + getaddrinfoFlags, 0); if(s) { error = gai_strerror(s); return -1; @@ -202,7 +202,7 @@ static sock_t bindTo struct addrinfo* rp; for(rp = res; rp; rp = rp->ai_next) { sock_t fd = bindInternal(rp->ai_family, rp->ai_socktype, rp->ai_protocol, - rp->ai_addr, rp->ai_addrlen); + rp->ai_addr, rp->ai_addrlen); if(fd != (sock_t)-1) { return fd; } @@ -222,21 +222,21 @@ void SocketCore::bind(uint16_t port, int flags) } } else { for(std::vector<std::pair<struct sockaddr_storage, socklen_t> >:: - const_iterator i = _bindAddrs.begin(); i != _bindAddrs.end(); ++i) { + const_iterator i = _bindAddrs.begin(); i != _bindAddrs.end(); ++i) { char host[NI_MAXHOST]; int s; s = getnameinfo(reinterpret_cast<const struct sockaddr*>(&(*i).first), - (*i).second, - host, NI_MAXHOST, 0, NI_MAXSERV, - NI_NUMERICHOST); + (*i).second, + host, NI_MAXHOST, 0, NI_MAXSERV, + NI_NUMERICHOST); if(s) { - error = gai_strerror(s); - continue; + error = gai_strerror(s); + continue; } sock_t fd = bindTo(host, port, _protocolFamily, _sockType, flags, error); if(fd != (sock_t)-1) { - sockfd = fd; - break; + sockfd = fd; + break; } } } @@ -305,10 +305,10 @@ void SocketCore::establishConnection(const std::string& host, uint16_t port) struct addrinfo* res; int s; s = callGetaddrinfo(&res, host.c_str(), uitos(port).c_str(), _protocolFamily, - _sockType, 0, 0); + _sockType, 0, 0); if(s) { throw DL_ABORT_EX(StringFormat(EX_RESOLVE_HOSTNAME, - host.c_str(), gai_strerror(s)).str()); + host.c_str(), gai_strerror(s)).str()); } auto_delete<struct addrinfo*> resDeleter(res, freeaddrinfo); struct addrinfo* rp; @@ -325,18 +325,18 @@ void SocketCore::establishConnection(const std::string& host, uint16_t port) if(!_bindAddrs.empty()) { bool bindSuccess = false; for(std::vector<std::pair<struct sockaddr_storage, socklen_t> >:: - const_iterator i = _bindAddrs.begin(); i != _bindAddrs.end(); ++i) { - if(::bind(fd,reinterpret_cast<const struct sockaddr*>(&(*i).first), - (*i).second) == -1) { - LogFactory::getInstance()->debug(EX_SOCKET_BIND, strerror(errno)); - } else { - bindSuccess = true; - break; - } + const_iterator i = _bindAddrs.begin(); i != _bindAddrs.end(); ++i) { + if(::bind(fd,reinterpret_cast<const struct sockaddr*>(&(*i).first), + (*i).second) == -1) { + LogFactory::getInstance()->debug(EX_SOCKET_BIND, strerror(errno)); + } else { + bindSuccess = true; + break; + } } if(!bindSuccess) { - CLOSE(fd); - continue; + CLOSE(fd); + continue; } } @@ -355,7 +355,7 @@ void SocketCore::establishConnection(const std::string& host, uint16_t port) } if(sockfd == (sock_t) -1) { throw DL_ABORT_EX(StringFormat(EX_SOCKET_CONNECT, host.c_str(), - strerror(errno)).str()); + strerror(errno)).str()); } } @@ -470,16 +470,16 @@ bool SocketCore::isWritable(time_t timeout) int r = select(sockfd+1, NULL, &fds, NULL, &tv); if(r == 1) { - return true; + return true; } else if(r == 0) { - // time out - return false; + // time out + return false; } else { - if(SOCKET_ERRNO == A2_EINPROGRESS || SOCKET_ERRNO == EINTR) { - return false; - } else { - throw DL_RETRY_EX(StringFormat(EX_SOCKET_CHECK_WRITABLE, errorMsg()).str()); - } + if(SOCKET_ERRNO == A2_EINPROGRESS || SOCKET_ERRNO == EINTR) { + return false; + } else { + throw DL_RETRY_EX(StringFormat(EX_SOCKET_CHECK_WRITABLE, errorMsg()).str()); + } } } else { abort(); @@ -523,16 +523,16 @@ bool SocketCore::isReadable(time_t timeout) int r = select(sockfd+1, &fds, NULL, NULL, &tv); if(r == 1) { - return true; + return true; } else if(r == 0) { - // time out - return false; + // time out + return false; } else { - if(SOCKET_ERRNO == A2_EINPROGRESS || SOCKET_ERRNO == EINTR) { - return false; - } else { - throw DL_RETRY_EX(StringFormat(EX_SOCKET_CHECK_READABLE, errorMsg()).str()); - } + if(SOCKET_ERRNO == A2_EINPROGRESS || SOCKET_ERRNO == EINTR) { + return false; + } else { + throw DL_RETRY_EX(StringFormat(EX_SOCKET_CHECK_READABLE, errorMsg()).str()); + } } } else { abort(); @@ -577,10 +577,10 @@ ssize_t SocketCore::writeData(const char* data, size_t len) while((ret = send(sockfd, data, len, 0)) == -1 && SOCKET_ERRNO == EINTR); if(ret == -1) { if(SOCKET_ERRNO == EAGAIN) { - _wantWrite = true; - ret = 0; + _wantWrite = true; + ret = 0; } else { - throw DL_RETRY_EX(StringFormat(EX_SOCKET_SEND, errorMsg()).str()); + throw DL_RETRY_EX(StringFormat(EX_SOCKET_SEND, errorMsg()).str()); } } } else { @@ -588,21 +588,21 @@ ssize_t SocketCore::writeData(const char* data, size_t len) ret = SSL_write(ssl, data, len); if(ret == 0) { throw DL_RETRY_EX - (StringFormat - (EX_SOCKET_SEND, ERR_error_string(SSL_get_error(ssl, ret), 0)).str()); + (StringFormat + (EX_SOCKET_SEND, ERR_error_string(SSL_get_error(ssl, ret), 0)).str()); } if(ret < 0) { ret = sslHandleEAGAIN(ret); } if(ret < 0) { throw DL_RETRY_EX - (StringFormat - (EX_SOCKET_SEND, ERR_error_string(SSL_get_error(ssl, ret), 0)).str()); + (StringFormat + (EX_SOCKET_SEND, ERR_error_string(SSL_get_error(ssl, ret), 0)).str()); } #endif // HAVE_LIBSSL #ifdef HAVE_LIBGNUTLS while((ret = gnutls_record_send(sslSession, data, len)) == - GNUTLS_E_INTERRUPTED); + GNUTLS_E_INTERRUPTED); if(ret == GNUTLS_E_AGAIN) { gnutlsRecordCheckDirection(); ret = 0; @@ -626,29 +626,29 @@ void SocketCore::readData(char* data, size_t& len) if(ret == -1) { if(SOCKET_ERRNO == EAGAIN) { - _wantRead = true; - ret = 0; + _wantRead = true; + ret = 0; } else { - throw DL_RETRY_EX(StringFormat(EX_SOCKET_RECV, errorMsg()).str()); + throw DL_RETRY_EX(StringFormat(EX_SOCKET_RECV, errorMsg()).str()); } } } else { #ifdef HAVE_LIBSSL - // for SSL - // TODO handling len == 0 case required + // for SSL + // TODO handling len == 0 case required ret = SSL_read(ssl, data, len); if(ret == 0) { throw DL_RETRY_EX - (StringFormat - (EX_SOCKET_RECV, ERR_error_string(SSL_get_error(ssl, ret), 0)).str()); + (StringFormat + (EX_SOCKET_RECV, ERR_error_string(SSL_get_error(ssl, ret), 0)).str()); } if(ret < 0) { ret = sslHandleEAGAIN(ret); } if(ret < 0) { throw DL_RETRY_EX - (StringFormat - (EX_SOCKET_RECV, ERR_error_string(SSL_get_error(ssl, ret), 0)).str()); + (StringFormat + (EX_SOCKET_RECV, ERR_error_string(SSL_get_error(ssl, ret), 0)).str()); } #endif // HAVE_LIBSSL #ifdef HAVE_LIBGNUTLS @@ -658,7 +658,7 @@ void SocketCore::readData(char* data, size_t& len) ret = 0; } else if(ret < 0) { throw DL_RETRY_EX - (StringFormat(EX_SOCKET_RECV, gnutls_strerror(ret)).str()); + (StringFormat(EX_SOCKET_RECV, gnutls_strerror(ret)).str()); } #endif // HAVE_LIBGNUTLS } @@ -676,29 +676,29 @@ void SocketCore::peekData(char* data, size_t& len) while((ret = recv(sockfd, data, len, MSG_PEEK)) == -1 && SOCKET_ERRNO == EINTR); if(ret == -1) { if(SOCKET_ERRNO == EAGAIN) { - _wantRead = true; - ret = 0; + _wantRead = true; + ret = 0; } else { - throw DL_RETRY_EX(StringFormat(EX_SOCKET_PEEK, errorMsg()).str()); + throw DL_RETRY_EX(StringFormat(EX_SOCKET_PEEK, errorMsg()).str()); } } } else { #ifdef HAVE_LIBSSL - // for SSL - // TODO handling len == 0 case required + // for SSL + // TODO handling len == 0 case required ret = SSL_peek(ssl, data, len); if(ret == 0) { throw DL_RETRY_EX - (StringFormat(EX_SOCKET_PEEK, - ERR_error_string(SSL_get_error(ssl, ret), 0)).str()); + (StringFormat(EX_SOCKET_PEEK, + ERR_error_string(SSL_get_error(ssl, ret), 0)).str()); } if(ret < 0) { ret = sslHandleEAGAIN(ret); } if(ret < 0) { throw DL_RETRY_EX - (StringFormat(EX_SOCKET_PEEK, - ERR_error_string(SSL_get_error(ssl, ret), 0)).str()); + (StringFormat(EX_SOCKET_PEEK, + ERR_error_string(SSL_get_error(ssl, ret), 0)).str()); } #endif // HAVE_LIBSSL #ifdef HAVE_LIBGNUTLS @@ -708,7 +708,7 @@ void SocketCore::peekData(char* data, size_t& len) ret = 0; } else if(ret < 0) { throw DL_RETRY_EX(StringFormat(EX_SOCKET_PEEK, - gnutls_strerror(ret)).str()); + gnutls_strerror(ret)).str()); } #endif // HAVE_LIBGNUTLS } @@ -754,7 +754,7 @@ static ssize_t GNUTLS_RECORD_RECV_NO_INTERRUPT { int ret; while((ret = gnutls_record_recv(sslSession, data, len)) == - GNUTLS_E_INTERRUPTED); + GNUTLS_E_INTERRUPTED); if(ret < 0 && ret != GNUTLS_E_AGAIN) { throw DL_RETRY_EX (StringFormat(EX_SOCKET_RECV, gnutls_strerror(ret)).str()); @@ -803,13 +803,13 @@ void SocketCore::prepareSecureConnection() ssl = SSL_new(_tlsContext->getSSLCtx()); if(!ssl) { throw DL_ABORT_EX - (StringFormat(EX_SSL_INIT_FAILURE, - ERR_error_string(ERR_get_error(), 0)).str()); + (StringFormat(EX_SSL_INIT_FAILURE, + ERR_error_string(ERR_get_error(), 0)).str()); } if(SSL_set_fd(ssl, sockfd) == 0) { throw DL_ABORT_EX - (StringFormat(EX_SSL_INIT_FAILURE, - ERR_error_string(ERR_get_error(), 0)).str()); + (StringFormat(EX_SSL_INIT_FAILURE, + ERR_error_string(ERR_get_error(), 0)).str()); } #endif // HAVE_LIBSSL #ifdef HAVE_LIBGNUTLS @@ -823,11 +823,11 @@ void SocketCore::prepareSecureConnection() r = gnutls_priority_set_direct(sslSession, "NORMAL:!VERS-TLS1.1", &err); if(r != GNUTLS_E_SUCCESS) { throw DL_ABORT_EX - (StringFormat(EX_SSL_INIT_FAILURE, gnutls_strerror(r)).str()); + (StringFormat(EX_SSL_INIT_FAILURE, gnutls_strerror(r)).str()); } // put the x509 credentials to the current session gnutls_credentials_set(sslSession, GNUTLS_CRD_CERTIFICATE, - _tlsContext->getCertCred()); + _tlsContext->getCertCred()); gnutls_transport_set_ptr(sslSession, (gnutls_transport_ptr_t)sockfd); #endif // HAVE_LIBGNUTLS secure = 1; @@ -845,75 +845,75 @@ bool SocketCore::initiateSecureConnection(const std::string& hostname) if (e <= 0) { int ssl_error = SSL_get_error(ssl, e); switch(ssl_error) { - case SSL_ERROR_NONE: - break; - - case SSL_ERROR_WANT_READ: - _wantRead = true; - return false; - case SSL_ERROR_WANT_WRITE: - _wantWrite = true; - return false; - case SSL_ERROR_WANT_X509_LOOKUP: - case SSL_ERROR_ZERO_RETURN: - if (blocking) { - throw DL_ABORT_EX - (StringFormat(EX_SSL_CONNECT_ERROR, ssl_error).str()); - } - break; + case SSL_ERROR_NONE: + break; + + case SSL_ERROR_WANT_READ: + _wantRead = true; + return false; + case SSL_ERROR_WANT_WRITE: + _wantWrite = true; + return false; + case SSL_ERROR_WANT_X509_LOOKUP: + case SSL_ERROR_ZERO_RETURN: + if (blocking) { + throw DL_ABORT_EX + (StringFormat(EX_SSL_CONNECT_ERROR, ssl_error).str()); + } + break; - case SSL_ERROR_SYSCALL: - throw DL_ABORT_EX(EX_SSL_IO_ERROR); + case SSL_ERROR_SYSCALL: + throw DL_ABORT_EX(EX_SSL_IO_ERROR); - case SSL_ERROR_SSL: - throw DL_ABORT_EX(EX_SSL_PROTOCOL_ERROR); + case SSL_ERROR_SSL: + throw DL_ABORT_EX(EX_SSL_PROTOCOL_ERROR); - default: - throw DL_ABORT_EX - (StringFormat(EX_SSL_UNKNOWN_ERROR, ssl_error).str()); + default: + throw DL_ABORT_EX + (StringFormat(EX_SSL_UNKNOWN_ERROR, ssl_error).str()); } } if(_tlsContext->peerVerificationEnabled()) { // verify peer X509* peerCert = SSL_get_peer_certificate(ssl); if(!peerCert) { - throw DL_ABORT_EX(MSG_NO_CERT_FOUND); + throw DL_ABORT_EX(MSG_NO_CERT_FOUND); } auto_delete<X509*> certDeleter(peerCert, X509_free); long verifyResult = SSL_get_verify_result(ssl); if(verifyResult != X509_V_OK) { - throw DL_ABORT_EX - (StringFormat(MSG_CERT_VERIFICATION_FAILED, - X509_verify_cert_error_string(verifyResult)).str()); + throw DL_ABORT_EX + (StringFormat(MSG_CERT_VERIFICATION_FAILED, + X509_verify_cert_error_string(verifyResult)).str()); } X509_NAME* name = X509_get_subject_name(peerCert); if(!name) { - throw DL_ABORT_EX("Could not get X509 name object from the certificate."); + throw DL_ABORT_EX("Could not get X509 name object from the certificate."); } bool hostnameOK = false; int lastpos = -1; while(true) { - lastpos = X509_NAME_get_index_by_NID(name, NID_commonName, lastpos); - if(lastpos == -1) { - break; - } - X509_NAME_ENTRY* entry = X509_NAME_get_entry(name, lastpos); - unsigned char* out; - int outlen = ASN1_STRING_to_UTF8(&out, X509_NAME_ENTRY_get_data(entry)); - if(outlen < 0) { - continue; - } - std::string commonName(&out[0], &out[outlen]); - OPENSSL_free(out); - if(commonName == hostname) { - hostnameOK = true; - break; - } + lastpos = X509_NAME_get_index_by_NID(name, NID_commonName, lastpos); + if(lastpos == -1) { + break; + } + X509_NAME_ENTRY* entry = X509_NAME_get_entry(name, lastpos); + unsigned char* out; + int outlen = ASN1_STRING_to_UTF8(&out, X509_NAME_ENTRY_get_data(entry)); + if(outlen < 0) { + continue; + } + std::string commonName(&out[0], &out[outlen]); + OPENSSL_free(out); + if(commonName == hostname) { + hostnameOK = true; + break; + } } if(!hostnameOK) { - throw DL_ABORT_EX(MSG_HOSTNAME_NOT_MATCH); + throw DL_ABORT_EX(MSG_HOSTNAME_NOT_MATCH); } } #endif // HAVE_LIBSSL @@ -924,7 +924,7 @@ bool SocketCore::initiateSecureConnection(const std::string& hostname) return false; } else if(ret < 0) { throw DL_ABORT_EX - (StringFormat(EX_SSL_INIT_FAILURE, gnutls_strerror(ret)).str()); + (StringFormat(EX_SSL_INIT_FAILURE, gnutls_strerror(ret)).str()); } if(_tlsContext->peerVerificationEnabled()) { @@ -932,73 +932,73 @@ bool SocketCore::initiateSecureConnection(const std::string& hostname) unsigned int status; ret = gnutls_certificate_verify_peers2(sslSession, &status); if(ret < 0) { - throw DL_ABORT_EX - (StringFormat("gnutls_certificate_verify_peer2() failed. Cause: %s", - gnutls_strerror(ret)).str()); + throw DL_ABORT_EX + (StringFormat("gnutls_certificate_verify_peer2() failed. Cause: %s", + gnutls_strerror(ret)).str()); } if(status) { - std::string errors; - if(status & GNUTLS_CERT_INVALID) { - errors += " `not signed by known authorities or invalid'"; - } - if(status & GNUTLS_CERT_REVOKED) { - errors += " `revoked by its CA'"; - } - if(status & GNUTLS_CERT_SIGNER_NOT_FOUND) { - errors += " `issuer is not known'"; - } - if(!errors.empty()) { - throw DL_ABORT_EX - (StringFormat(MSG_CERT_VERIFICATION_FAILED, errors.c_str()).str()); - } + std::string errors; + if(status & GNUTLS_CERT_INVALID) { + errors += " `not signed by known authorities or invalid'"; + } + if(status & GNUTLS_CERT_REVOKED) { + errors += " `revoked by its CA'"; + } + if(status & GNUTLS_CERT_SIGNER_NOT_FOUND) { + errors += " `issuer is not known'"; + } + if(!errors.empty()) { + throw DL_ABORT_EX + (StringFormat(MSG_CERT_VERIFICATION_FAILED, errors.c_str()).str()); + } } // certificate type: only X509 is allowed. if(gnutls_certificate_type_get(sslSession) != GNUTLS_CRT_X509) { - throw DL_ABORT_EX("Certificate type is not X509."); + throw DL_ABORT_EX("Certificate type is not X509."); } unsigned int peerCertsLength; const gnutls_datum_t* peerCerts = gnutls_certificate_get_peers - (sslSession, &peerCertsLength); + (sslSession, &peerCertsLength); if(!peerCerts) { - throw DL_ABORT_EX(MSG_NO_CERT_FOUND); + throw DL_ABORT_EX(MSG_NO_CERT_FOUND); } Time now; for(unsigned int i = 0; i < peerCertsLength; ++i) { - gnutls_x509_crt_t cert; - ret = gnutls_x509_crt_init(&cert); - if(ret < 0) { - throw DL_ABORT_EX - (StringFormat("gnutls_x509_crt_init() failed. Cause: %s", - gnutls_strerror(ret)).str()); - } - auto_delete<gnutls_x509_crt_t> certDeleter - (cert, gnutls_x509_crt_deinit); - ret = gnutls_x509_crt_import(cert, &peerCerts[i], GNUTLS_X509_FMT_DER); - if(ret < 0) { - throw DL_ABORT_EX - (StringFormat("gnutls_x509_crt_import() failed. Cause: %s", - gnutls_strerror(ret)).str()); - } - if(i == 0) { - if(!gnutls_x509_crt_check_hostname(cert, hostname.c_str())) { - throw DL_ABORT_EX(MSG_HOSTNAME_NOT_MATCH); - } - } - time_t activationTime = gnutls_x509_crt_get_activation_time(cert); - if(activationTime == -1) { - throw DL_ABORT_EX("Could not get activation time from certificate."); - } - if(now.getTime() < activationTime) { - throw DL_ABORT_EX("Certificate is not activated yet."); - } - time_t expirationTime = gnutls_x509_crt_get_expiration_time(cert); - if(expirationTime == -1) { - throw DL_ABORT_EX("Could not get expiration time from certificate."); - } - if(expirationTime < now.getTime()) { - throw DL_ABORT_EX("Certificate has expired."); - } + gnutls_x509_crt_t cert; + ret = gnutls_x509_crt_init(&cert); + if(ret < 0) { + throw DL_ABORT_EX + (StringFormat("gnutls_x509_crt_init() failed. Cause: %s", + gnutls_strerror(ret)).str()); + } + auto_delete<gnutls_x509_crt_t> certDeleter + (cert, gnutls_x509_crt_deinit); + ret = gnutls_x509_crt_import(cert, &peerCerts[i], GNUTLS_X509_FMT_DER); + if(ret < 0) { + throw DL_ABORT_EX + (StringFormat("gnutls_x509_crt_import() failed. Cause: %s", + gnutls_strerror(ret)).str()); + } + if(i == 0) { + if(!gnutls_x509_crt_check_hostname(cert, hostname.c_str())) { + throw DL_ABORT_EX(MSG_HOSTNAME_NOT_MATCH); + } + } + time_t activationTime = gnutls_x509_crt_get_activation_time(cert); + if(activationTime == -1) { + throw DL_ABORT_EX("Could not get activation time from certificate."); + } + if(now.getTime() < activationTime) { + throw DL_ABORT_EX("Certificate is not activated yet."); + } + time_t expirationTime = gnutls_x509_crt_get_expiration_time(cert); + if(expirationTime == -1) { + throw DL_ABORT_EX("Could not get expiration time from certificate."); + } + if(expirationTime < now.getTime()) { + throw DL_ABORT_EX("Certificate has expired."); + } } } peekBuf = new char[peekBufMax]; @@ -1027,15 +1027,15 @@ bool SocketCore::initiateSecureConnection(const std::string& hostname) #else static char buf[256]; if (FormatMessage( - FORMAT_MESSAGE_FROM_SYSTEM | - FORMAT_MESSAGE_IGNORE_INSERTS, - NULL, - err, - MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language - (LPTSTR) &buf, - sizeof(buf), - NULL - ) == 0) { + FORMAT_MESSAGE_FROM_SYSTEM | + FORMAT_MESSAGE_IGNORE_INSERTS, + NULL, + err, + MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language + (LPTSTR) &buf, + sizeof(buf), + NULL + ) == 0) { snprintf(buf, sizeof(buf), EX_SOCKET_UNKNOWN_ERROR, err, err); } return buf; @@ -1043,7 +1043,7 @@ bool SocketCore::initiateSecureConnection(const std::string& hostname) } ssize_t SocketCore::writeData(const char* data, size_t len, - const std::string& host, uint16_t port) + const std::string& host, uint16_t port) { _wantRead = false; _wantWrite = false; @@ -1051,7 +1051,7 @@ ssize_t SocketCore::writeData(const char* data, size_t len, struct addrinfo* res; int s; s = callGetaddrinfo(&res, host.c_str(), uitos(port).c_str(), _protocolFamily, - _sockType, 0, 0); + _sockType, 0, 0); if(s) { throw DL_ABORT_EX(StringFormat(EX_SOCKET_SEND, gai_strerror(s)).str()); } @@ -1076,8 +1076,8 @@ ssize_t SocketCore::writeData(const char* data, size_t len, } ssize_t SocketCore::readDataFrom(char* data, size_t len, - std::pair<std::string /* numerichost */, - uint16_t /* port */>& sender) + std::pair<std::string /* numerichost */, + uint16_t /* port */>& sender) { _wantRead = false; _wantWrite = false; @@ -1086,7 +1086,7 @@ ssize_t SocketCore::readDataFrom(char* data, size_t len, struct sockaddr* addrp = reinterpret_cast<struct sockaddr*>(&sockaddr); ssize_t r; while((r = recvfrom(sockfd, data, len, 0, addrp, &sockaddrlen)) == -1 && - EINTR == SOCKET_ERRNO); + EINTR == SOCKET_ERRNO); if(r == -1) { if(SOCKET_ERRNO == EAGAIN) { _wantRead = true; @@ -1108,7 +1108,7 @@ std::string SocketCore::getSocketError() const if(getsockopt(sockfd, SOL_SOCKET, SO_ERROR, (a2_sockopt_t) &error, &optlen) == -1) { throw DL_ABORT_EX(StringFormat("Failed to get socket error: %s", - errorMsg()).str()); + errorMsg()).str()); } if(error != 0) { return errorMsg(error); @@ -1149,37 +1149,37 @@ void SocketCore::bindAddress(const std::string& interface) if(getifaddrs(&ifaddr) == -1) { throw DL_ABORT_EX (StringFormat(MSG_INTERFACE_NOT_FOUND, - interface.c_str(), strerror(errno)).str()); + interface.c_str(), strerror(errno)).str()); } else { auto_delete<struct ifaddrs*> ifaddrDeleter(ifaddr, freeifaddrs); for(struct ifaddrs* ifa = ifaddr; ifa; ifa = ifa->ifa_next) { if(!ifa->ifa_addr) { - continue; + continue; } int family = ifa->ifa_addr->sa_family; if(_protocolFamily == AF_UNSPEC) { - if(family != AF_INET && family != AF_INET6) { - continue; - } + if(family != AF_INET && family != AF_INET6) { + continue; + } } else if(_protocolFamily == AF_INET) { - if(family != AF_INET) { - continue; - } + if(family != AF_INET) { + continue; + } } else if(_protocolFamily == AF_INET6) { - if(family != AF_INET6) { - continue; - } + if(family != AF_INET6) { + continue; + } } else { - continue; + continue; } if(std::string(ifa->ifa_name) == interface) { - socklen_t bindAddrLen = - family == AF_INET?sizeof(struct sockaddr_in): - sizeof(struct sockaddr_in6); - struct sockaddr_storage bindAddr; - memset(&bindAddr, 0, sizeof(bindAddr)); - memcpy(&bindAddr, ifa->ifa_addr, bindAddrLen); - bindAddrs.push_back(std::make_pair(bindAddr, bindAddrLen)); + socklen_t bindAddrLen = + family == AF_INET?sizeof(struct sockaddr_in): + sizeof(struct sockaddr_in6); + struct sockaddr_storage bindAddr; + memset(&bindAddr, 0, sizeof(bindAddr)); + memcpy(&bindAddr, ifa->ifa_addr, bindAddrLen); + bindAddrs.push_back(std::make_pair(bindAddr, bindAddrLen)); } } } @@ -1188,48 +1188,48 @@ void SocketCore::bindAddress(const std::string& interface) struct addrinfo* res; int s; s = callGetaddrinfo(&res, interface.c_str(), 0, _protocolFamily, - SOCK_STREAM, 0, 0); + SOCK_STREAM, 0, 0); if(s) { throw DL_ABORT_EX - (StringFormat(MSG_INTERFACE_NOT_FOUND, - interface.c_str(), gai_strerror(s)).str()); + (StringFormat(MSG_INTERFACE_NOT_FOUND, + interface.c_str(), gai_strerror(s)).str()); } else { auto_delete<struct addrinfo*> resDeleter(res, freeaddrinfo); struct addrinfo* rp; for(rp = res; rp; rp = rp->ai_next) { - socklen_t bindAddrLen = rp->ai_addrlen; - struct sockaddr_storage bindAddr; - memset(&bindAddr, 0, sizeof(bindAddr)); - memcpy(&bindAddr, rp->ai_addr, rp->ai_addrlen); - // Try to bind socket with this address. If it fails, the - // address is not for this machine. - try { - SocketCore socket; - socket.bind - (reinterpret_cast<const struct sockaddr*>(&bindAddr), bindAddrLen); - bindAddrs.push_back(std::make_pair(bindAddr, bindAddrLen)); - } catch(RecoverableException& e) { - continue; - } + socklen_t bindAddrLen = rp->ai_addrlen; + struct sockaddr_storage bindAddr; + memset(&bindAddr, 0, sizeof(bindAddr)); + memcpy(&bindAddr, rp->ai_addr, rp->ai_addrlen); + // Try to bind socket with this address. If it fails, the + // address is not for this machine. + try { + SocketCore socket; + socket.bind + (reinterpret_cast<const struct sockaddr*>(&bindAddr), bindAddrLen); + bindAddrs.push_back(std::make_pair(bindAddr, bindAddrLen)); + } catch(RecoverableException& e) { + continue; + } } } } if(bindAddrs.empty()) { - throw DL_ABORT_EX - (StringFormat(MSG_INTERFACE_NOT_FOUND, - interface.c_str(), "not available").str()); + throw DL_ABORT_EX + (StringFormat(MSG_INTERFACE_NOT_FOUND, + interface.c_str(), "not available").str()); } else { _bindAddrs = bindAddrs; for(std::vector<std::pair<struct sockaddr_storage, socklen_t> >:: - const_iterator i = _bindAddrs.begin(); i != _bindAddrs.end(); ++i) { + const_iterator i = _bindAddrs.begin(); i != _bindAddrs.end(); ++i) { char host[NI_MAXHOST]; int s; s = getnameinfo(reinterpret_cast<const struct sockaddr*>(&(*i).first), - (*i).second, - host, NI_MAXHOST, 0, NI_MAXSERV, - NI_NUMERICHOST); + (*i).second, + host, NI_MAXHOST, 0, NI_MAXSERV, + NI_NUMERICHOST); if(s == 0) { - LogFactory::getInstance()->debug("Sockets will bind to %s", host); + LogFactory::getInstance()->debug("Sockets will bind to %s", host); } } } diff --git a/src/SocketCore.h b/src/SocketCore.h index 59f1f4a4..88958f6e 100644 --- a/src/SocketCore.h +++ b/src/SocketCore.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -244,11 +244,11 @@ public: } ssize_t writeData(const char* data, size_t len, - const std::string& host, uint16_t port); + const std::string& host, uint16_t port); ssize_t writeData(const unsigned char* data, size_t len, - const std::string& host, - uint16_t port) + const std::string& host, + uint16_t port) { return writeData(reinterpret_cast<const char*>(data), len, host, port); } @@ -277,12 +277,12 @@ public: } ssize_t readDataFrom(char* data, size_t len, - std::pair<std::string /* numerichost */, - uint16_t /* port */>& sender); + std::pair<std::string /* numerichost */, + uint16_t /* port */>& sender); ssize_t readDataFrom(unsigned char* data, size_t len, - std::pair<std::string /* numerichost */, - uint16_t /* port */>& sender) + std::pair<std::string /* numerichost */, + uint16_t /* port */>& sender) { return readDataFrom(reinterpret_cast<char*>(data), len, sender); } diff --git a/src/SpeedCalc.cc b/src/SpeedCalc.cc index 598e080c..6226bac2 100644 --- a/src/SpeedCalc.cc +++ b/src/SpeedCalc.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -91,7 +91,7 @@ unsigned int SpeedCalc::calculateSpeed(const struct timeval& now) { void SpeedCalc::update(size_t bytes) { accumulatedLength += bytes; std::transform(&lengthArray[0], &lengthArray[2], &lengthArray[0], - std::bind1st(std::plus<uint64_t>(), (uint64_t)bytes)); + std::bind1st(std::plus<uint64_t>(), (uint64_t)bytes)); if(isIntervalOver()) { changeSw(); } diff --git a/src/SpeedCalc.h b/src/SpeedCalc.h index c7e3513e..47439941 100644 --- a/src/SpeedCalc.h +++ b/src/SpeedCalc.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/Sqlite3MozCookieParser.cc b/src/Sqlite3MozCookieParser.cc index 2dc08667..125aaaac 100644 --- a/src/Sqlite3MozCookieParser.cc +++ b/src/Sqlite3MozCookieParser.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -62,7 +62,7 @@ static std::string toString(const char* str) } static int cookieRowMapper(void* data, int rowIndex, - char** values, char** names) + char** values, char** names) { try { int64_t expireDate = util::parseLLInt(toString(values[3])); @@ -72,13 +72,13 @@ static int cookieRowMapper(void* data, int rowIndex, } Cookie c(toString(values[4]), // name - toString(values[5]), // value - expireDate, // expires - toString(values[1]), // path - toString(values[0]), // domain - strcmp(toString(values[2]).c_str(), "1") == 0 ? true:false //secure - ); - + toString(values[5]), // value + expireDate, // expires + toString(values[1]), // path + toString(values[0]), // domain + strcmp(toString(values[2]).c_str(), "1") == 0 ? true:false //secure + ); + if(c.good()) { reinterpret_cast<std::deque<Cookie>*>(data)->push_back(c); } @@ -100,7 +100,7 @@ Sqlite3MozCookieParser::parse(const std::string& filename) const if(!File(filename).isFile()) { throw DL_ABORT_EX (StringFormat("Failed to open SQLite3 database: %s", - filename.c_str()).str()); + filename.c_str()).str()); } ret = sqlite3_open(filename.c_str(), &db); #endif // !HAVE_SQLITE3_OPEN_V2 @@ -109,7 +109,7 @@ Sqlite3MozCookieParser::parse(const std::string& filename) const sqlite3_close(db); throw DL_ABORT_EX (StringFormat("Failed to open SQLite3 database: %s", - errMsg.c_str()).str()); + errMsg.c_str()).str()); } std::deque<Cookie> cookies; char* sqlite3ErrMsg = 0; @@ -125,7 +125,7 @@ Sqlite3MozCookieParser::parse(const std::string& filename) const sqlite3_close(db); throw DL_ABORT_EX (StringFormat("Failed to read SQLite3 database: %s", - errMsg.c_str()).str()); + errMsg.c_str()).str()); } sqlite3_close(db); return cookies; diff --git a/src/Sqlite3MozCookieParser.h b/src/Sqlite3MozCookieParser.h index ecf07dd7..5276a6ee 100644 --- a/src/Sqlite3MozCookieParser.h +++ b/src/Sqlite3MozCookieParser.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/StatCalc.h b/src/StatCalc.h index 7aea53f6..ab5372f5 100644 --- a/src/StatCalc.h +++ b/src/StatCalc.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/StreamCheckIntegrityEntry.cc b/src/StreamCheckIntegrityEntry.cc index aab617be..8295f6a0 100644 --- a/src/StreamCheckIntegrityEntry.cc +++ b/src/StreamCheckIntegrityEntry.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -41,7 +41,7 @@ namespace aria2 { StreamCheckIntegrityEntry::StreamCheckIntegrityEntry(RequestGroup* requestGroup, - Command* nextCommand): + Command* nextCommand): PieceHashCheckIntegrityEntry(requestGroup, nextCommand) {} @@ -56,7 +56,7 @@ void StreamCheckIntegrityEntry::onDownloadIncomplete } void StreamCheckIntegrityEntry::onDownloadFinished(std::deque<Command*>& commands, - DownloadEngine* e) + DownloadEngine* e) {} } // namespace aria2 diff --git a/src/StreamCheckIntegrityEntry.h b/src/StreamCheckIntegrityEntry.h index 5117957a..9f4e52bf 100644 --- a/src/StreamCheckIntegrityEntry.h +++ b/src/StreamCheckIntegrityEntry.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -46,15 +46,15 @@ private: Time _timer; public: StreamCheckIntegrityEntry(RequestGroup* requestGroup, - Command* nextCommand = 0); + Command* nextCommand = 0); virtual ~StreamCheckIntegrityEntry(); virtual void onDownloadFinished(std::deque<Command*>& commands, - DownloadEngine* e); + DownloadEngine* e); virtual void onDownloadIncomplete(std::deque<Command*>& commands, - DownloadEngine* e); + DownloadEngine* e); }; typedef SharedHandle<StreamCheckIntegrityEntry> StreamCheckIntegrityEntryHandle; diff --git a/src/StreamFileAllocationEntry.cc b/src/StreamFileAllocationEntry.cc index a4f759c5..cf89e788 100644 --- a/src/StreamFileAllocationEntry.cc +++ b/src/StreamFileAllocationEntry.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -46,14 +46,14 @@ namespace aria2 { StreamFileAllocationEntry::StreamFileAllocationEntry(RequestGroup* requestGroup, - Command* nextCommand): + Command* nextCommand): FileAllocationEntry(requestGroup, nextCommand) {} StreamFileAllocationEntry::~StreamFileAllocationEntry() {} void StreamFileAllocationEntry::prepareForNextAction(std::deque<Command*>& commands, - DownloadEngine* e) + DownloadEngine* e) { _requestGroup->getDownloadContext()->resetDownloadStartTime(); if(_nextCommand) { diff --git a/src/StreamFileAllocationEntry.h b/src/StreamFileAllocationEntry.h index be308786..1870f95e 100644 --- a/src/StreamFileAllocationEntry.h +++ b/src/StreamFileAllocationEntry.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -45,12 +45,12 @@ private: Time _timer; public: StreamFileAllocationEntry(RequestGroup* requestGroup, - Command* nextCommand = 0); + Command* nextCommand = 0); virtual ~StreamFileAllocationEntry(); virtual void prepareForNextAction(std::deque<Command*>& commands, - DownloadEngine* e); + DownloadEngine* e); }; typedef SharedHandle<StreamFileAllocationEntry> StreamFileAllocationEntryHandle; diff --git a/src/StringFormat.cc b/src/StringFormat.cc index 33b86d5d..339e5d04 100644 --- a/src/StringFormat.cc +++ b/src/StringFormat.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/StringFormat.h b/src/StringFormat.h index ccc8dd59..682e21f9 100644 --- a/src/StringFormat.h +++ b/src/StringFormat.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/TLSContext.h b/src/TLSContext.h index 786deafd..de59409c 100644 --- a/src/TLSContext.h +++ b/src/TLSContext.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/TimeA2.cc b/src/TimeA2.cc index 955cb07c..5df6f118 100644 --- a/src/TimeA2.cc +++ b/src/TimeA2.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/TimeA2.h b/src/TimeA2.h index 7b9c5478..0794fa4b 100644 --- a/src/TimeA2.h +++ b/src/TimeA2.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/TimeBasedCommand.cc b/src/TimeBasedCommand.cc index 95f01e9b..2d438b27 100644 --- a/src/TimeBasedCommand.cc +++ b/src/TimeBasedCommand.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -38,8 +38,8 @@ namespace aria2 { TimeBasedCommand::TimeBasedCommand(int32_t cuid, DownloadEngine* e, - time_t interval, - bool routineCommand): + time_t interval, + bool routineCommand): Command(cuid), _e(e),_exit(false), _interval(interval), _routineCommand(routineCommand) {} diff --git a/src/TimeBasedCommand.h b/src/TimeBasedCommand.h index ed049170..625b547e 100644 --- a/src/TimeBasedCommand.h +++ b/src/TimeBasedCommand.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -80,7 +80,7 @@ public: public: TimeBasedCommand(int32_t cuid, DownloadEngine* e, time_t interval, - bool routineCommand = false); + bool routineCommand = false); virtual ~TimeBasedCommand(); diff --git a/src/TimeSeedCriteria.h b/src/TimeSeedCriteria.h index 55e74c2f..19549c28 100644 --- a/src/TimeSeedCriteria.h +++ b/src/TimeSeedCriteria.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/TimedHaltCommand.cc b/src/TimedHaltCommand.cc index 6fc0a4e6..334f331e 100644 --- a/src/TimedHaltCommand.cc +++ b/src/TimedHaltCommand.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -42,7 +42,7 @@ namespace aria2 { TimedHaltCommand::TimedHaltCommand(int32_t cuid, DownloadEngine* e, - time_t secondsToHalt): + time_t secondsToHalt): TimeBasedCommand(cuid, e, secondsToHalt, true) {} TimedHaltCommand::~TimedHaltCommand() {} diff --git a/src/TimedHaltCommand.h b/src/TimedHaltCommand.h index 4e29b500..89352107 100644 --- a/src/TimedHaltCommand.h +++ b/src/TimedHaltCommand.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/TrackerWatcherCommand.cc b/src/TrackerWatcherCommand.cc index 3c66e1b7..af9a9f13 100644 --- a/src/TrackerWatcherCommand.cc +++ b/src/TrackerWatcherCommand.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -81,7 +81,7 @@ bool TrackerWatcherCommand::execute() { if(_trackerRequestGroup.isNull()) { return true; } else if(_trackerRequestGroup->getNumCommand() == 0 || - _trackerRequestGroup->downloadFinished()) { + _trackerRequestGroup->downloadFinished()) { return true; } else { _trackerRequestGroup->setForceHaltRequested(true); @@ -112,7 +112,7 @@ bool TrackerWatcherCommand::execute() { logger->error(EX_EXCEPTION_CAUGHT, ex); _btAnnounce->announceFailure(); if(_btAnnounce->isAllAnnounceFailed()) { - _btAnnounce->resetAnnounce(); + _btAnnounce->resetAnnounce(); } } _trackerRequestGroup.reset(); @@ -151,7 +151,7 @@ void TrackerWatcherCommand::processTrackerResponse { _btAnnounce->processAnnounceResponse (reinterpret_cast<const unsigned char*>(trackerResponse.c_str()), - trackerResponse.size()); + trackerResponse.size()); while(!_btRuntime->isHalt() && _btRuntime->lessThanMinPeers()) { PeerHandle peer = _peerStorage->getUnusedPeer(); if(peer.isNull()) { @@ -216,8 +216,8 @@ TrackerWatcherCommand::createRequestGroup(const std::string& uri) static const std::string TRACKER_ANNOUNCE_FILE("[tracker.announce]"); SharedHandle<DownloadContext> dctx (new DownloadContext(getOption()->getAsInt(PREF_SEGMENT_SIZE), - 0, - TRACKER_ANNOUNCE_FILE)); + 0, + TRACKER_ANNOUNCE_FILE)); dctx->setDir(A2STR::NIL); dctx->getFileEntries().front()->setUris(uris); rg->setDownloadContext(dctx); diff --git a/src/TrackerWatcherCommand.h b/src/TrackerWatcherCommand.h index 7ec0c03f..1e9f2b8c 100644 --- a/src/TrackerWatcherCommand.h +++ b/src/TrackerWatcherCommand.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -77,8 +77,8 @@ private: const SharedHandle<Option>& getOption() const; public: TrackerWatcherCommand(int32_t cuid, - RequestGroup* requestGroup, - DownloadEngine* e); + RequestGroup* requestGroup, + DownloadEngine* e); virtual ~TrackerWatcherCommand(); diff --git a/src/TransferStat.cc b/src/TransferStat.cc index cdfd510d..493973b1 100644 --- a/src/TransferStat.cc +++ b/src/TransferStat.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/TransferStat.h b/src/TransferStat.h index 09530c85..e791bb14 100644 --- a/src/TransferStat.h +++ b/src/TransferStat.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -58,8 +58,8 @@ public: } public: TransferStat():downloadSpeed(0), uploadSpeed(0), - sessionDownloadLength(0), sessionUploadLength(0), - allTimeUploadLength(0) {} + sessionDownloadLength(0), sessionUploadLength(0), + allTimeUploadLength(0) {} TransferStat(const TransferStat& stat) { diff --git a/src/TrueRequestGroupCriteria.h b/src/TrueRequestGroupCriteria.h index af9c8c8f..9702f4bf 100644 --- a/src/TrueRequestGroupCriteria.h +++ b/src/TrueRequestGroupCriteria.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/URIResult.cc b/src/URIResult.cc index ecdcbef5..583f26d2 100644 --- a/src/URIResult.cc +++ b/src/URIResult.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/URIResult.h b/src/URIResult.h index f5d956ba..7aa49b80 100644 --- a/src/URIResult.h +++ b/src/URIResult.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/URISelector.h b/src/URISelector.h index 76c259b2..728b867e 100644 --- a/src/URISelector.h +++ b/src/URISelector.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -50,7 +50,7 @@ public: virtual std::string select(FileEntry* fileEntry) = 0; virtual void tuneDownloadCommand(const std::deque<std::string>& uris, - DownloadCommand* command) {}; + DownloadCommand* command) {}; virtual void resetCounters() { return; }; }; diff --git a/src/UTMetadataDataExtensionMessage.cc b/src/UTMetadataDataExtensionMessage.cc index e425e917..813a2bf9 100644 --- a/src/UTMetadataDataExtensionMessage.cc +++ b/src/UTMetadataDataExtensionMessage.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -51,7 +51,7 @@ namespace aria2 { UTMetadataDataExtensionMessage::UTMetadataDataExtensionMessage (uint8_t extensionMessageID):UTMetadataExtensionMessage(extensionMessageID), - _logger(LogFactory::getInstance()) {} + _logger(LogFactory::getInstance()) {} std::string UTMetadataDataExtensionMessage::getPayload() { @@ -71,7 +71,7 @@ void UTMetadataDataExtensionMessage::doReceivedAction() { if(_tracker->tracks(_index)) { _logger->debug("ut_metadata index=%lu found in tracking list", - static_cast<unsigned long>(_index)); + static_cast<unsigned long>(_index)); _tracker->remove(_index); _pieceStorage->getDiskAdaptor()->writeData (reinterpret_cast<const unsigned char*>(_data.c_str()), _data.size(), @@ -81,22 +81,22 @@ void UTMetadataDataExtensionMessage::doReceivedAction() std::string metadata = util::toString(_pieceStorage->getDiskAdaptor()); unsigned char infoHash[INFO_HASH_LENGTH]; MessageDigestHelper::digest(infoHash, INFO_HASH_LENGTH, - MessageDigestContext::SHA1, - metadata.data(), metadata.size()); + MessageDigestContext::SHA1, + metadata.data(), metadata.size()); const BDE& attrs = _dctx->getAttribute(bittorrent::BITTORRENT); if(std::string(&infoHash[0], &infoHash[INFO_HASH_LENGTH]) == - attrs[bittorrent::INFO_HASH].s()){ - _logger->info("Got ut_metadata"); + attrs[bittorrent::INFO_HASH].s()){ + _logger->info("Got ut_metadata"); } else { - _logger->info("Got wrong ut_metadata"); - for(size_t i = 0; i < _dctx->getNumPieces(); ++i) { - _pieceStorage->markPieceMissing(i); - } + _logger->info("Got wrong ut_metadata"); + for(size_t i = 0; i < _dctx->getNumPieces(); ++i) { + _pieceStorage->markPieceMissing(i); + } } } } else { _logger->debug("ut_metadata index=%lu is not tracked", - static_cast<unsigned long>(_index)); + static_cast<unsigned long>(_index)); } } diff --git a/src/UTMetadataDataExtensionMessage.h b/src/UTMetadataDataExtensionMessage.h index 36927555..dc025fdf 100644 --- a/src/UTMetadataDataExtensionMessage.h +++ b/src/UTMetadataDataExtensionMessage.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/UTMetadataExtensionMessage.cc b/src/UTMetadataExtensionMessage.cc index 2842fb5f..d15ac9ef 100644 --- a/src/UTMetadataExtensionMessage.cc +++ b/src/UTMetadataExtensionMessage.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/UTMetadataExtensionMessage.h b/src/UTMetadataExtensionMessage.h index 0a890ac0..1053ecc4 100644 --- a/src/UTMetadataExtensionMessage.h +++ b/src/UTMetadataExtensionMessage.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/UTMetadataPostDownloadHandler.cc b/src/UTMetadataPostDownloadHandler.cc index 6c291c38..fd67cf95 100644 --- a/src/UTMetadataPostDownloadHandler.cc +++ b/src/UTMetadataPostDownloadHandler.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -84,7 +84,7 @@ void UTMetadataPostDownloadHandler::getNextRequestGroups std::deque<SharedHandle<RequestGroup> > newRgs; createRequestGroupForBitTorrent(newRgs, requestGroup->getOption(), - std::deque<std::string>(), torrent); + std::deque<std::string>(), torrent); requestGroup->followedBy(newRgs.begin(), newRgs.end()); groups.insert(groups.end(), newRgs.begin(), newRgs.end()); diff --git a/src/UTMetadataPostDownloadHandler.h b/src/UTMetadataPostDownloadHandler.h index b4953733..56201d73 100644 --- a/src/UTMetadataPostDownloadHandler.h +++ b/src/UTMetadataPostDownloadHandler.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -57,7 +57,7 @@ public: virtual void getNextRequestGroups(std::deque<SharedHandle<RequestGroup> >& groups, - RequestGroup* requestGroup); + RequestGroup* requestGroup); }; } // namespace aria2 diff --git a/src/UTMetadataRejectExtensionMessage.cc b/src/UTMetadataRejectExtensionMessage.cc index fc100d60..e6855c10 100644 --- a/src/UTMetadataRejectExtensionMessage.cc +++ b/src/UTMetadataRejectExtensionMessage.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/UTMetadataRejectExtensionMessage.h b/src/UTMetadataRejectExtensionMessage.h index 6866ed37..54c0f604 100644 --- a/src/UTMetadataRejectExtensionMessage.h +++ b/src/UTMetadataRejectExtensionMessage.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/UTMetadataRequestExtensionMessage.cc b/src/UTMetadataRequestExtensionMessage.cc index 992aee11..0093fe53 100644 --- a/src/UTMetadataRequestExtensionMessage.cc +++ b/src/UTMetadataRequestExtensionMessage.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -79,7 +79,7 @@ void UTMetadataRequestExtensionMessage::doReceivedAction() SharedHandle<BtMessage> msg = _messageFactory->createBtExtendedMessage(m); _dispatcher->addMessageToQueue(msg); }else if(_index*METADATA_PIECE_SIZE < - (size_t)attrs[bittorrent::METADATA_SIZE].i()){ + (size_t)attrs[bittorrent::METADATA_SIZE].i()){ SharedHandle<UTMetadataDataExtensionMessage> m (new UTMetadataDataExtensionMessage(id)); m->setIndex(_index); diff --git a/src/UTMetadataRequestExtensionMessage.h b/src/UTMetadataRequestExtensionMessage.h index 8bb6e7e9..aefda4e0 100644 --- a/src/UTMetadataRequestExtensionMessage.h +++ b/src/UTMetadataRequestExtensionMessage.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/UTMetadataRequestFactory.cc b/src/UTMetadataRequestFactory.cc index 38b5b595..9a4a4905 100644 --- a/src/UTMetadataRequestFactory.cc +++ b/src/UTMetadataRequestFactory.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -60,7 +60,7 @@ void UTMetadataRequestFactory::create } --num; _logger->debug("Creating ut_metadata request index=%lu", - static_cast<unsigned long>(index)); + static_cast<unsigned long>(index)); SharedHandle<UTMetadataRequestExtensionMessage> m (new UTMetadataRequestExtensionMessage (_peer->getExtensionMessageID("ut_metadata"))); diff --git a/src/UTMetadataRequestFactory.h b/src/UTMetadataRequestFactory.h index d16fb6a8..c9496e95 100644 --- a/src/UTMetadataRequestFactory.h +++ b/src/UTMetadataRequestFactory.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -71,7 +71,7 @@ public: // Creates at most num of ut_metadata request message and appends // them to msgs. pieceStorage is used to identify missing piece. void create(std::deque<SharedHandle<BtMessage> >& msgs, size_t num, - const SharedHandle<PieceStorage>& pieceStorage); + const SharedHandle<PieceStorage>& pieceStorage); void setDownloadContext(const SharedHandle<DownloadContext>& dctx) { diff --git a/src/UTMetadataRequestTracker.cc b/src/UTMetadataRequestTracker.cc index cbe11b42..96f23627 100644 --- a/src/UTMetadataRequestTracker.cc +++ b/src/UTMetadataRequestTracker.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -51,14 +51,14 @@ void UTMetadataRequestTracker::add(size_t index) bool UTMetadataRequestTracker::tracks(size_t index) { return std::find(_trackedRequests.begin(), _trackedRequests.end(), - RequestEntry(index)) != _trackedRequests.end(); + RequestEntry(index)) != _trackedRequests.end(); } void UTMetadataRequestTracker::remove(size_t index) { std::vector<RequestEntry>::iterator i = std::find(_trackedRequests.begin(), _trackedRequests.end(), - RequestEntry(index)); + RequestEntry(index)); if(i != _trackedRequests.end()) { _trackedRequests.erase(i); } @@ -72,8 +72,8 @@ std::vector<size_t> UTMetadataRequestTracker::removeTimeoutEntry() i != _trackedRequests.end();) { if((*i).elapsed(TIMEOUT)) { LogFactory::getInstance()->debug - ("ut_metadata request timeout. index=%lu", - static_cast<unsigned long>((*i)._index)); + ("ut_metadata request timeout. index=%lu", + static_cast<unsigned long>((*i)._index)); indexes.push_back((*i)._index); i = _trackedRequests.erase(i); } else { diff --git a/src/UTMetadataRequestTracker.h b/src/UTMetadataRequestTracker.h index 3788496e..ffee2b50 100644 --- a/src/UTMetadataRequestTracker.h +++ b/src/UTMetadataRequestTracker.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/UTPexExtensionMessage.cc b/src/UTPexExtensionMessage.cc index e0c6de54..43c28966 100644 --- a/src/UTPexExtensionMessage.cc +++ b/src/UTPexExtensionMessage.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -88,7 +88,7 @@ UTPexExtensionMessage::createCompactPeerListAndFlag(const Peers& peers) std::string UTPexExtensionMessage::toString() const { return strconcat("ut_pex added=", util::uitos(_freshPeers.size()), - ", dropped=", util::uitos(_droppedPeers.size())); + ", dropped=", util::uitos(_droppedPeers.size())); } void UTPexExtensionMessage::doReceivedAction() @@ -149,7 +149,7 @@ UTPexExtensionMessage::create(const unsigned char* data, size_t len) { if(len < 1) { throw DL_ABORT_EX(StringFormat(MSG_TOO_SMALL_PAYLOAD_SIZE, - EXTENSION_NAME.c_str(), len).str()); + EXTENSION_NAME.c_str(), len).str()); } UTPexExtensionMessageHandle msg(new UTPexExtensionMessage(*data)); @@ -163,7 +163,7 @@ UTPexExtensionMessage::create(const unsigned char* data, size_t len) const BDE& dropped = dict["dropped"]; if(dropped.isString()) { proc.extractPeerFromCompact(dropped, - std::back_inserter(msg->_droppedPeers)); + std::back_inserter(msg->_droppedPeers)); } } return msg; diff --git a/src/UTPexExtensionMessage.h b/src/UTPexExtensionMessage.h index 92cb275e..fd0535bf 100644 --- a/src/UTPexExtensionMessage.h +++ b/src/UTPexExtensionMessage.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/UnionSeedCriteria.h b/src/UnionSeedCriteria.h index 1246f26b..8257c507 100644 --- a/src/UnionSeedCriteria.h +++ b/src/UnionSeedCriteria.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -68,8 +68,8 @@ public: virtual bool evaluate() { SeedCriterion::iterator itr = std::find_if(criterion.begin(), - criterion.end(), - Eval()); + criterion.end(), + Eval()); return itr != criterion.end(); } diff --git a/src/UnknownLengthPieceStorage.cc b/src/UnknownLengthPieceStorage.cc index b74d5a25..573b19bb 100644 --- a/src/UnknownLengthPieceStorage.cc +++ b/src/UnknownLengthPieceStorage.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -62,7 +62,7 @@ void UnknownLengthPieceStorage::initStorage() DirectDiskAdaptorHandle directDiskAdaptor(new DirectDiskAdaptor()); directDiskAdaptor->setTotalLength(_downloadContext->getTotalLength()); directDiskAdaptor->setFileEntries(_downloadContext->getFileEntries().begin(), - _downloadContext->getFileEntries().end()); + _downloadContext->getFileEntries().end()); DiskWriterHandle writer = _diskWriterFactory->newDiskWriter(directDiskAdaptor->getFilePath()); diff --git a/src/UnknownLengthPieceStorage.h b/src/UnknownLengthPieceStorage.h index be81b761..b05414cb 100644 --- a/src/UnknownLengthPieceStorage.h +++ b/src/UnknownLengthPieceStorage.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -61,7 +61,7 @@ private: SharedHandle<Piece> _piece; public: UnknownLengthPieceStorage(const SharedHandle<DownloadContext>& downloadContext, - const Option* option); + const Option* option); virtual ~UnknownLengthPieceStorage(); @@ -194,7 +194,7 @@ public: } virtual void setBitfield(const unsigned char* bitfield, - size_t bitfieldLength) {} + size_t bitfieldLength) {} virtual size_t getBitfieldLength() { @@ -229,7 +229,7 @@ public: */ virtual void getAdvertisedPieceIndexes(std::deque<size_t>& indexes, - int32_t myCuid, const Time& lastCheckTime) + int32_t myCuid, const Time& lastCheckTime) {} /** @@ -263,14 +263,14 @@ public: virtual void addPieceStats(size_t index) {} virtual void addPieceStats(const unsigned char* bitfield, - size_t bitfieldLength) {} + size_t bitfieldLength) {} virtual void subtractPieceStats(const unsigned char* bitfield, - size_t bitfieldLength) {} + size_t bitfieldLength) {} virtual void updatePieceStats(const unsigned char* newBitfield, - size_t newBitfieldLength, - const unsigned char* oldBitfield) {} + size_t newBitfieldLength, + const unsigned char* oldBitfield) {} void setDiskWriterFactory(const SharedHandle<DiskWriterFactory>& diskWriterFactory); diff --git a/src/UriListParser.cc b/src/UriListParser.cc index f2c62b60..38303966 100644 --- a/src/UriListParser.cc +++ b/src/UriListParser.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/UriListParser.h b/src/UriListParser.h index 07de813a..0f22c719 100644 --- a/src/UriListParser.h +++ b/src/UriListParser.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/XML2SAXMetalinkProcessor.cc b/src/XML2SAXMetalinkProcessor.cc index df4e71d0..3a380416 100644 --- a/src/XML2SAXMetalinkProcessor.cc +++ b/src/XML2SAXMetalinkProcessor.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -62,7 +62,7 @@ static void mlStartElement(void* userData, const xmlChar* name, const xmlChar** std::string name = reinterpret_cast<const char*>(*p); ++p; if(*p == 0) { - break; + break; } std::string value = util::trim(reinterpret_cast<const char*>(*p)); ++p; @@ -95,40 +95,40 @@ static void mlCharacters(void* userData, const xmlChar* ch, int len) } static xmlSAXHandler mySAXHandler = -{ - 0, // internalSubsetSAXFunc - 0, // isStandaloneSAXFunc - 0, // hasInternalSubsetSAXFunc - 0, // hasExternalSubsetSAXFunc - 0, // resolveEntitySAXFunc - 0, // getEntitySAXFunc - 0, // entityDeclSAXFunc - 0, // notationDeclSAXFunc - 0, // attributeDeclSAXFunc - 0, // elementDeclSAXFunc - 0, // unparsedEntityDeclSAXFunc - 0, // setDocumentLocatorSAXFunc - 0, // startDocumentSAXFunc - 0, // endDocumentSAXFunc - &mlStartElement, // startElementSAXFunc - &mlEndElement, // endElementSAXFunc - 0, // referenceSAXFunc - &mlCharacters, // charactersSAXFunc - 0, // ignorableWhitespaceSAXFunc - 0, // processingInstructionSAXFunc - 0, // commentSAXFunc - 0, // warningSAXFunc - 0, // errorSAXFunc - 0, // fatalErrorSAXFunc - 0, // getParameterEntitySAXFunc - 0, // cdataBlockSAXFunc - 0, // externalSubsetSAXFunc - 0, // unsigned int initialized - 0, // void * _private - 0, // startElementNsSAX2Func - 0, // endElementNsSAX2Func - 0, // xmlStructuredErrorFunc -}; + { + 0, // internalSubsetSAXFunc + 0, // isStandaloneSAXFunc + 0, // hasInternalSubsetSAXFunc + 0, // hasExternalSubsetSAXFunc + 0, // resolveEntitySAXFunc + 0, // getEntitySAXFunc + 0, // entityDeclSAXFunc + 0, // notationDeclSAXFunc + 0, // attributeDeclSAXFunc + 0, // elementDeclSAXFunc + 0, // unparsedEntityDeclSAXFunc + 0, // setDocumentLocatorSAXFunc + 0, // startDocumentSAXFunc + 0, // endDocumentSAXFunc + &mlStartElement, // startElementSAXFunc + &mlEndElement, // endElementSAXFunc + 0, // referenceSAXFunc + &mlCharacters, // charactersSAXFunc + 0, // ignorableWhitespaceSAXFunc + 0, // processingInstructionSAXFunc + 0, // commentSAXFunc + 0, // warningSAXFunc + 0, // errorSAXFunc + 0, // fatalErrorSAXFunc + 0, // getParameterEntitySAXFunc + 0, // cdataBlockSAXFunc + 0, // externalSubsetSAXFunc + 0, // unsigned int initialized + 0, // void * _private + 0, // startElementNsSAX2Func + 0, // endElementNsSAX2Func + 0, // xmlStructuredErrorFunc + }; SharedHandle<Metalinker> MetalinkProcessor::parseFile(const std::string& filename) @@ -136,13 +136,13 @@ MetalinkProcessor::parseFile(const std::string& filename) _stm.reset(new MetalinkParserStateMachine()); SharedHandle<SessionData> sessionData(new SessionData(_stm)); int retval = xmlSAXUserParseFile(&mySAXHandler, sessionData.get(), - filename.c_str()); + filename.c_str()); if(retval != 0) { throw DL_ABORT_EX(MSG_CANNOT_PARSE_METALINK); } return _stm->getResult(); } - + SharedHandle<Metalinker> MetalinkProcessor::parseFromBinaryStream(const SharedHandle<BinaryStream>& binaryStream) { @@ -164,10 +164,10 @@ MetalinkProcessor::parseFromBinaryStream(const SharedHandle<BinaryStream>& binar while(1) { ssize_t res = binaryStream->readData(buf, bufSize, readOffset); if(res == 0) { - break; + break; } if(xmlParseChunk(ctx, reinterpret_cast<const char*>(buf), res, 0) != 0) { - throw DL_ABORT_EX(MSG_CANNOT_PARSE_METALINK); + throw DL_ABORT_EX(MSG_CANNOT_PARSE_METALINK); } readOffset += res; } diff --git a/src/XML2SAXMetalinkProcessor.h b/src/XML2SAXMetalinkProcessor.h index efc7016c..fe83a0a0 100644 --- a/src/XML2SAXMetalinkProcessor.h +++ b/src/XML2SAXMetalinkProcessor.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/XORCloser.h b/src/XORCloser.h index 70b1be23..ffde011c 100644 --- a/src/XORCloser.h +++ b/src/XORCloser.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -47,16 +47,16 @@ public: XORCloser(const unsigned char* key, size_t length):_key(key), _length(length) {} bool operator()(const unsigned char* key1, - const unsigned char* key2) const + const unsigned char* key2) const { for(size_t i = 0; i < _length; ++i) { unsigned char c1 = _key[i]^key1[i]; unsigned char c2 = _key[i]^key2[i]; if(c1 < c2) { - return true; + return true; } else if(c1 > c2) { - return false; + return false; } } return true; diff --git a/src/Xml2XmlRpcRequestProcessor.cc b/src/Xml2XmlRpcRequestProcessor.cc index c2e69ef1..c30998bb 100644 --- a/src/Xml2XmlRpcRequestProcessor.cc +++ b/src/Xml2XmlRpcRequestProcessor.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -56,7 +56,7 @@ struct SessionData { }; static void mlStartElement(void* userData, const xmlChar* name, - const xmlChar** attrs) + const xmlChar** attrs) { SessionData* sd = reinterpret_cast<SessionData*>(userData); std::map<std::string, std::string> attrmap; @@ -66,7 +66,7 @@ static void mlStartElement(void* userData, const xmlChar* name, std::string name = reinterpret_cast<const char*>(*p); ++p; if(*p == 0) { - break; + break; } std::string value = util::trim(reinterpret_cast<const char*>(*p)); ++p; @@ -99,40 +99,40 @@ static void mlCharacters(void* userData, const xmlChar* ch, int len) } static xmlSAXHandler mySAXHandler = -{ - 0, // internalSubsetSAXFunc - 0, // isStandaloneSAXFunc - 0, // hasInternalSubsetSAXFunc - 0, // hasExternalSubsetSAXFunc - 0, // resolveEntitySAXFunc - 0, // getEntitySAXFunc - 0, // entityDeclSAXFunc - 0, // notationDeclSAXFunc - 0, // attributeDeclSAXFunc - 0, // elementDeclSAXFunc - 0, // unparsedEntityDeclSAXFunc - 0, // setDocumentLocatorSAXFunc - 0, // startDocumentSAXFunc - 0, // endDocumentSAXFunc - &mlStartElement, // startElementSAXFunc - &mlEndElement, // endElementSAXFunc - 0, // referenceSAXFunc - &mlCharacters, // charactersSAXFunc - 0, // ignorableWhitespaceSAXFunc - 0, // processingInstructionSAXFunc - 0, // commentSAXFunc - 0, // warningSAXFunc - 0, // errorSAXFunc - 0, // fatalErrorSAXFunc - 0, // getParameterEntitySAXFunc - 0, // cdataBlockSAXFunc - 0, // externalSubsetSAXFunc - 0, // unsigned int initialized - 0, // void * _private - 0, // startElementNsSAX2Func - 0, // endElementNsSAX2Func - 0, // xmlStructuredErrorFunc -}; + { + 0, // internalSubsetSAXFunc + 0, // isStandaloneSAXFunc + 0, // hasInternalSubsetSAXFunc + 0, // hasExternalSubsetSAXFunc + 0, // resolveEntitySAXFunc + 0, // getEntitySAXFunc + 0, // entityDeclSAXFunc + 0, // notationDeclSAXFunc + 0, // attributeDeclSAXFunc + 0, // elementDeclSAXFunc + 0, // unparsedEntityDeclSAXFunc + 0, // setDocumentLocatorSAXFunc + 0, // startDocumentSAXFunc + 0, // endDocumentSAXFunc + &mlStartElement, // startElementSAXFunc + &mlEndElement, // endElementSAXFunc + 0, // referenceSAXFunc + &mlCharacters, // charactersSAXFunc + 0, // ignorableWhitespaceSAXFunc + 0, // processingInstructionSAXFunc + 0, // commentSAXFunc + 0, // warningSAXFunc + 0, // errorSAXFunc + 0, // fatalErrorSAXFunc + 0, // getParameterEntitySAXFunc + 0, // cdataBlockSAXFunc + 0, // externalSubsetSAXFunc + 0, // unsigned int initialized + 0, // void * _private + 0, // startElementNsSAX2Func + 0, // endElementNsSAX2Func + 0, // xmlStructuredErrorFunc + }; XmlRpcRequest XmlRpcRequestProcessor::parseMemory(const std::string& xml) @@ -141,7 +141,7 @@ XmlRpcRequestProcessor::parseMemory(const std::string& xml) SharedHandle<SessionData> sessionData(new SessionData(_stm.get())); int r = xmlSAXUserParseMemory(&mySAXHandler, sessionData.get(), - xml.data(), xml.size()); + xml.data(), xml.size()); if(r != 0) { throw DL_ABORT_EX(MSG_CANNOT_PARSE_XML_RPC_REQUEST); } diff --git a/src/Xml2XmlRpcRequestProcessor.h b/src/Xml2XmlRpcRequestProcessor.h index 034b5c5f..f6eb59a1 100644 --- a/src/Xml2XmlRpcRequestProcessor.h +++ b/src/Xml2XmlRpcRequestProcessor.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/XmlRpcElements.cc b/src/XmlRpcElements.cc index 5bfb7456..8fd8a7ce 100644 --- a/src/XmlRpcElements.cc +++ b/src/XmlRpcElements.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/XmlRpcElements.h b/src/XmlRpcElements.h index bba2de11..27f94a97 100644 --- a/src/XmlRpcElements.h +++ b/src/XmlRpcElements.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/XmlRpcMethod.cc b/src/XmlRpcMethod.cc index 1772d2e7..a653cdce 100644 --- a/src/XmlRpcMethod.cc +++ b/src/XmlRpcMethod.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -86,29 +86,29 @@ static void gatherOption const std::string& optionName = (*first).first; if(changeableOptions.count(optionName) == 0) { throw DL_ABORT_EX - (StringFormat - ("%s cannot be changed or unknown option.", optionName.c_str()).str()); + (StringFormat + ("%s cannot be changed or unknown option.", optionName.c_str()).str()); } else { SharedHandle<OptionHandler> optionHandler = - optionParser->findByName(optionName); + optionParser->findByName(optionName); if(optionHandler.isNull()) { - throw DL_ABORT_EX - (StringFormat - ("We don't know how to deal with %s option", - optionName.c_str()).str()); + throw DL_ABORT_EX + (StringFormat + ("We don't know how to deal with %s option", + optionName.c_str()).str()); } // header and index-out option can take array as value const BDE& value = (*first).second; if((optionName == PREF_HEADER || optionName == PREF_INDEX_OUT) && - value.isList()){ - for(BDE::List::const_iterator argiter = value.listBegin(); - argiter != value.listEnd(); ++argiter) { - if((*argiter).isString()) { - optionHandler->parse(*option.get(), (*argiter).s()); - } - } + value.isList()){ + for(BDE::List::const_iterator argiter = value.listBegin(); + argiter != value.listEnd(); ++argiter) { + if((*argiter).isString()) { + optionHandler->parse(*option.get(), (*argiter).s()); + } + } } else if(value.isString()) { - optionHandler->parse(*option.get(), value.s()); + optionHandler->parse(*option.get(), value.s()); } } } @@ -118,17 +118,17 @@ void XmlRpcMethod::gatherRequestOption (const SharedHandle<Option>& option, const BDE& optionsDict) { gatherOption(optionsDict.dictBegin(), optionsDict.dictEnd(), - listRequestOptions(), - option, _optionParser); + listRequestOptions(), + option, _optionParser); } // Copy option in the range [optNameFirst, optNameLast) from src to // dest. template<typename InputIterator> static void applyOption(InputIterator optNameFirst, - InputIterator optNameLast, - Option* dest, - Option* src) + InputIterator optNameLast, + Option* dest, + Option* src) { for(; optNameFirst != optNameLast; ++optNameFirst) { if(src->defined(*optNameFirst)) { @@ -154,14 +154,14 @@ void XmlRpcMethod::gatherChangeableOption (const SharedHandle<Option>& option, const BDE& optionsDict) { gatherOption(optionsDict.dictBegin(), optionsDict.dictEnd(), - listChangeableOptions(), - option, _optionParser); + listChangeableOptions(), + option, _optionParser); } void XmlRpcMethod::applyChangeableOption(Option* dest, Option* src) const { applyOption(listChangeableOptions().begin(), listChangeableOptions().end(), - dest, src); + dest, src); } const std::set<std::string>& listChangeableGlobalOptions() @@ -180,15 +180,15 @@ void XmlRpcMethod::gatherChangeableGlobalOption (const SharedHandle<Option>& option, const BDE& optionsDict) { gatherOption(optionsDict.dictBegin(), optionsDict.dictEnd(), - listChangeableGlobalOptions(), - option, _optionParser); + listChangeableGlobalOptions(), + option, _optionParser); } void XmlRpcMethod::applyChangeableGlobalOption(Option* dest, Option* src) const { applyOption(listChangeableGlobalOptions().begin(), - listChangeableGlobalOptions().end(), - dest, src); + listChangeableGlobalOptions().end(), + dest, src); } } // namespace xmlrpc diff --git a/src/XmlRpcMethod.h b/src/XmlRpcMethod.h index 2cc06582..7a41cfaa 100644 --- a/src/XmlRpcMethod.h +++ b/src/XmlRpcMethod.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -74,17 +74,17 @@ protected: virtual BDE process(const XmlRpcRequest& req, DownloadEngine* e) = 0; void gatherRequestOption(const SharedHandle<Option>& option, - const BDE& optionsDict); + const BDE& optionsDict); void gatherChangeableOption(const SharedHandle<Option>& option, - const BDE& optionDict); + const BDE& optionDict); // Copy options which is changeable in XML-RPC changeOption command // to dest. void applyChangeableOption(Option* dest, Option* src) const; void gatherChangeableGlobalOption(const SharedHandle<Option>& option, - const BDE& optionDict); + const BDE& optionDict); // Copy options which is changeable in XML-RPC changeGlobalOption // command to dest. diff --git a/src/XmlRpcMethodFactory.cc b/src/XmlRpcMethodFactory.cc index 3365d115..e0d2efa3 100644 --- a/src/XmlRpcMethodFactory.cc +++ b/src/XmlRpcMethodFactory.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/XmlRpcMethodFactory.h b/src/XmlRpcMethodFactory.h index 431d6810..70c9bd29 100644 --- a/src/XmlRpcMethodFactory.h +++ b/src/XmlRpcMethodFactory.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/XmlRpcMethodImpl.cc b/src/XmlRpcMethodImpl.cc index fe3b89ce..a9be47c8 100644 --- a/src/XmlRpcMethodImpl.cc +++ b/src/XmlRpcMethodImpl.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -123,8 +123,8 @@ static BDE createGIDResponse(int32_t gid) } static BDE addRequestGroup(const SharedHandle<RequestGroup>& group, - DownloadEngine* e, - bool posGiven, int pos) + DownloadEngine* e, + bool posGiven, int pos) { if(posGiven) { e->_requestGroupMan->insertReservedGroup(pos, group); @@ -140,7 +140,7 @@ static bool hasDictParam(const BDE& params, size_t index) } static void getPosParam(const BDE& params, size_t posParamIndex, - bool& posGiven, size_t& pos) + bool& posGiven, size_t& pos) { if(params.size() > posParamIndex && params[posParamIndex].isInteger()) { if(params[posParamIndex].i() >= 0) { @@ -179,8 +179,8 @@ BDE AddUriXmlRpcMethod::process(const XmlRpcRequest& req, DownloadEngine* e) std::deque<SharedHandle<RequestGroup> > result; createRequestGroupForUri(result, requestOption, uris, - /* ignoreForceSeq = */ true, - /* ignoreLocalPath = */ true); + /* ignoreForceSeq = */ true, + /* ignoreLocalPath = */ true); if(!result.empty()) { return addRequestGroup(result.front(), e, posGiven, pos); @@ -202,9 +202,9 @@ BDE AddTorrentXmlRpcMethod::process std::deque<std::string> uris; if(params.size() > 1 && params[1].isList()) { for(BDE::List::const_iterator i = params[1].listBegin(); - i != params[1].listEnd(); ++i) { + i != params[1].listEnd(); ++i) { if((*i).isString()) { - uris.push_back((*i).s()); + uris.push_back((*i).s()); } } } @@ -218,8 +218,8 @@ BDE AddTorrentXmlRpcMethod::process std::deque<SharedHandle<RequestGroup> > result; createRequestGroupForBitTorrent(result, requestOption, - uris, - params[0].s()); + uris, + params[0].s()); if(!result.empty()) { return addRequestGroup(result.front(), e, posGiven, pos); @@ -257,7 +257,7 @@ BDE AddMetalinkXmlRpcMethod::process } BDE gids = BDE::list(); for(std::deque<SharedHandle<RequestGroup> >::const_iterator i = - result.begin(); i != result.end(); ++i) { + result.begin(); i != result.end(); ++i) { gids << BDE(util::itos((*i)->getGID())); } return gids; @@ -284,13 +284,13 @@ BDE RemoveXmlRpcMethod::process(const XmlRpcRequest& req, DownloadEngine* e) group = e->_requestGroupMan->findReservedGroup(gid); if(group.isNull()) { throw DL_ABORT_EX - (StringFormat("Active Download not found for GID#%d", gid).str()); + (StringFormat("Active Download not found for GID#%d", gid).str()); } if(group->isDependencyResolved()) { e->_requestGroupMan->removeReservedGroup(gid); } else { throw DL_ABORT_EX - (StringFormat("GID#%d cannot be removed now", gid).str()); + (StringFormat("GID#%d cannot be removed now", gid).str()); } } else { group->setHaltRequested(true, RequestGroup::USER_REQUEST); @@ -316,7 +316,7 @@ void gatherProgressCommon if(!ps.isNull()) { if(ps->getBitfieldLength() > 0) { entryDict[KEY_BITFIELD] = util::toHex(ps->getBitfield(), - ps->getBitfieldLength()); + ps->getBitfieldLength()); } } entryDict[KEY_PIECE_LENGTH] = @@ -327,7 +327,7 @@ void gatherProgressCommon BDE list = BDE::list(); // The element is GID. for(std::vector<int32_t>::const_iterator i = group->followedBy().begin(); - i != group->followedBy().end(); ++i) { + i != group->followedBy().end(); ++i) { list << util::itos(*i); } entryDict[KEY_FOLLOWED_BY] = list; @@ -359,14 +359,14 @@ static void gatherPeer(BDE& peers, const SharedHandle<PeerStorage>& ps) std::deque<SharedHandle<Peer> > activePeers; ps->getActivePeers(activePeers); for(std::deque<SharedHandle<Peer> >::const_iterator i = - activePeers.begin(); i != activePeers.end(); ++i) { + activePeers.begin(); i != activePeers.end(); ++i) { BDE peerEntry = BDE::dict(); peerEntry[KEY_PEER_ID] = util::torrentUrlencode((*i)->getPeerId(), - PEER_ID_LENGTH); + PEER_ID_LENGTH); peerEntry[KEY_IP] = (*i)->ipaddr; peerEntry[KEY_PORT] = util::uitos((*i)->port); peerEntry[KEY_BITFIELD] = util::toHex((*i)->getBitfield(), - (*i)->getBitfieldLength()); + (*i)->getBitfieldLength()); peerEntry[KEY_AM_CHOKING] = (*i)->amChoking()?BDE_TRUE:BDE_FALSE; peerEntry[KEY_PEER_CHOKING] = (*i)->peerChoking()?BDE_TRUE:BDE_FALSE; TransferStat stat = ps->getTransferStatFor(*i); @@ -408,7 +408,7 @@ void gatherStoppedDownload BDE list = BDE::list(); // The element is GID. for(std::vector<int32_t>::const_iterator i = ds->followedBy.begin(); - i != ds->followedBy.end(); ++i) { + i != ds->followedBy.end(); ++i) { list << util::itos(*i); } entryDict[KEY_FOLLOWED_BY] = list; @@ -462,14 +462,14 @@ BDE GetFilesXmlRpcMethod::process e->_requestGroupMan->findDownloadResult(gid); if(dr.isNull()) { throw DL_ABORT_EX - (StringFormat("No file data is available for GID#%d", gid).str()); + (StringFormat("No file data is available for GID#%d", gid).str()); } else { createFileEntry(files, dr->fileEntries.begin(), dr->fileEntries.end()); } } else { createFileEntry(files, - group->getDownloadContext()->getFileEntries().begin(), - group->getDownloadContext()->getFileEntries().end()); + group->getDownloadContext()->getFileEntries().begin(), + group->getDownloadContext()->getFileEntries().end()); } return files; } @@ -497,7 +497,7 @@ BDE GetUrisXmlRpcMethod::process if(!group->getDownloadContext()->getFileEntries().empty()) { group->getDownloadContext()->getFirstFileEntry()->getUris(uris); for(std::deque<std::string>::const_iterator i = uris.begin(); - i != uris.end(); ++i) { + i != uris.end(); ++i) { BDE entry = BDE::dict(); entry[KEY_URI] = *i; uriList << entry; @@ -553,10 +553,10 @@ BDE TellStatusXmlRpcMethod::process group = e->_requestGroupMan->findReservedGroup(gid); if(group.isNull()) { SharedHandle<DownloadResult> ds = - e->_requestGroupMan->findDownloadResult(gid); + e->_requestGroupMan->findDownloadResult(gid); if(ds.isNull()) { - throw DL_ABORT_EX - (StringFormat("No such download for GID#%d", gid).str()); + throw DL_ABORT_EX + (StringFormat("No such download for GID#%d", gid).str()); } gatherStoppedDownload(entryDict, ds); } else { @@ -577,7 +577,7 @@ BDE TellActiveXmlRpcMethod::process const std::deque<SharedHandle<RequestGroup> >& groups = e->_requestGroupMan->getRequestGroups(); for(std::deque<SharedHandle<RequestGroup> >::const_iterator i = - groups.begin(); i != groups.end(); ++i) { + groups.begin(); i != groups.end(); ++i) { BDE entryDict = BDE::dict(); entryDict[KEY_STATUS] = BDE_ACTIVE; gatherProgress(entryDict, *i, e); @@ -683,7 +683,7 @@ BDE ChangeOptionXmlRpcMethod::process applyChangeableOption(group->getOption().get(), option.get()); if(option->defined(PREF_MAX_DOWNLOAD_LIMIT)) { group->setMaxDownloadSpeedLimit - (option->getAsInt(PREF_MAX_DOWNLOAD_LIMIT)); + (option->getAsInt(PREF_MAX_DOWNLOAD_LIMIT)); } if(option->defined(PREF_MAX_UPLOAD_LIMIT)) { group->setMaxUploadSpeedLimit(option->getAsInt(PREF_MAX_UPLOAD_LIMIT)); @@ -692,7 +692,7 @@ BDE ChangeOptionXmlRpcMethod::process BtObject btObject = e->getBtRegistry()->get(group->getGID()); if(!btObject.isNull()) { if(option->defined(PREF_BT_MAX_PEERS)) { - btObject._btRuntime->setMaxPeers(option->getAsInt(PREF_BT_MAX_PEERS)); + btObject._btRuntime->setMaxPeers(option->getAsInt(PREF_BT_MAX_PEERS)); } } #endif // ENABLE_BITTORRENT @@ -834,19 +834,19 @@ BDE SystemMulticallXmlRpcMethod::process i != methodSpecs.listEnd(); ++i) { if(!(*i).isDict()) { list << createErrorResponse - (DL_ABORT_EX("system.multicall expected struct.")); + (DL_ABORT_EX("system.multicall expected struct.")); continue; } if(!(*i).containsKey(KEY_METHOD_NAME) || !(*i).containsKey(KEY_PARAMS)) { list << createErrorResponse - (DL_ABORT_EX("Missing methodName or params.")); + (DL_ABORT_EX("Missing methodName or params.")); continue; } const std::string& methodName = (*i)[KEY_METHOD_NAME].s(); if(methodName == getMethodName()) { list << createErrorResponse - (DL_ABORT_EX("Recursive system.multicall forbidden.")); + (DL_ABORT_EX("Recursive system.multicall forbidden.")); continue; } SharedHandle<XmlRpcMethod> method = XmlRpcMethodFactory::create(methodName); diff --git a/src/XmlRpcMethodImpl.h b/src/XmlRpcMethodImpl.h index 6fa134ef..108378ab 100644 --- a/src/XmlRpcMethodImpl.h +++ b/src/XmlRpcMethodImpl.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/XmlRpcRequest.h b/src/XmlRpcRequest.h index f1587205..b02a8024 100644 --- a/src/XmlRpcRequest.h +++ b/src/XmlRpcRequest.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/XmlRpcRequestParserController.cc b/src/XmlRpcRequestParserController.cc index 6d69dfcb..71f578df 100644 --- a/src/XmlRpcRequestParserController.cc +++ b/src/XmlRpcRequestParserController.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/XmlRpcRequestParserController.h b/src/XmlRpcRequestParserController.h index 31ba96be..2a125bf4 100644 --- a/src/XmlRpcRequestParserController.h +++ b/src/XmlRpcRequestParserController.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/XmlRpcRequestParserState.h b/src/XmlRpcRequestParserState.h index 6d20e6b9..0284b322 100644 --- a/src/XmlRpcRequestParserState.h +++ b/src/XmlRpcRequestParserState.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -51,12 +51,12 @@ public: virtual ~XmlRpcRequestParserState() {} virtual void beginElement(XmlRpcRequestParserStateMachine* stm, - const std::string& name, - const std::map<std::string, std::string>& attrs)= 0; + const std::string& name, + const std::map<std::string, std::string>& attrs)= 0; virtual void endElement(XmlRpcRequestParserStateMachine* stm, - const std::string& name, - const std::string& characters) = 0; + const std::string& name, + const std::string& characters) = 0; virtual bool needsCharactersBuffering() const = 0; }; diff --git a/src/XmlRpcRequestParserStateImpl.cc b/src/XmlRpcRequestParserStateImpl.cc index a18a7e65..30efcc3d 100644 --- a/src/XmlRpcRequestParserStateImpl.cc +++ b/src/XmlRpcRequestParserStateImpl.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/XmlRpcRequestParserStateImpl.h b/src/XmlRpcRequestParserStateImpl.h index 04b8164f..b7eefd30 100644 --- a/src/XmlRpcRequestParserStateImpl.h +++ b/src/XmlRpcRequestParserStateImpl.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -44,12 +44,12 @@ namespace xmlrpc { class InitialXmlRpcRequestParserState:public XmlRpcRequestParserState { public: virtual void beginElement(XmlRpcRequestParserStateMachine* stm, - const std::string& name, - const std::map<std::string, std::string>& attrs); + const std::string& name, + const std::map<std::string, std::string>& attrs); virtual void endElement(XmlRpcRequestParserStateMachine* stm, - const std::string& name, - const std::string& characters); + const std::string& name, + const std::string& characters); virtual bool needsCharactersBuffering() const { return false; } }; @@ -57,12 +57,12 @@ public: class UnknownElementXmlRpcRequestParserState:public XmlRpcRequestParserState { public: virtual void beginElement(XmlRpcRequestParserStateMachine* stm, - const std::string& name, - const std::map<std::string, std::string>& attrs); + const std::string& name, + const std::map<std::string, std::string>& attrs); virtual void endElement(XmlRpcRequestParserStateMachine* stm, - const std::string& name, - const std::string& characters) {} + const std::string& name, + const std::string& characters) {} virtual bool needsCharactersBuffering() const { return false; } }; @@ -70,12 +70,12 @@ public: class MethodCallXmlRpcRequestParserState:public XmlRpcRequestParserState { public: virtual void beginElement(XmlRpcRequestParserStateMachine* stm, - const std::string& name, - const std::map<std::string, std::string>& attrs); + const std::string& name, + const std::map<std::string, std::string>& attrs); virtual void endElement(XmlRpcRequestParserStateMachine* stm, - const std::string& name, - const std::string& characters) {} + const std::string& name, + const std::string& characters) {} virtual bool needsCharactersBuffering() const { return false; } }; @@ -83,152 +83,152 @@ public: class MethodNameXmlRpcRequestParserState:public XmlRpcRequestParserState { public: virtual void beginElement(XmlRpcRequestParserStateMachine* stm, - const std::string& name, - const std::map<std::string, std::string>& attrs); + const std::string& name, + const std::map<std::string, std::string>& attrs); virtual void endElement(XmlRpcRequestParserStateMachine* stm, - const std::string& name, - const std::string& characters); + const std::string& name, + const std::string& characters); virtual bool needsCharactersBuffering() const { return true; } }; class ParamsXmlRpcRequestParserState:public XmlRpcRequestParserState { virtual void beginElement(XmlRpcRequestParserStateMachine* stm, - const std::string& name, - const std::map<std::string, std::string>& attrs); + const std::string& name, + const std::map<std::string, std::string>& attrs); virtual void endElement(XmlRpcRequestParserStateMachine* stm, - const std::string& name, - const std::string& characters) {} + const std::string& name, + const std::string& characters) {} virtual bool needsCharactersBuffering() const { return false; } }; class ParamXmlRpcRequestParserState:public XmlRpcRequestParserState { virtual void beginElement(XmlRpcRequestParserStateMachine* stm, - const std::string& name, - const std::map<std::string, std::string>& attrs); + const std::string& name, + const std::map<std::string, std::string>& attrs); virtual void endElement(XmlRpcRequestParserStateMachine* stm, - const std::string& name, - const std::string& characters); + const std::string& name, + const std::string& characters); virtual bool needsCharactersBuffering() const { return false; } }; class ValueXmlRpcRequestParserState:public XmlRpcRequestParserState { virtual void beginElement(XmlRpcRequestParserStateMachine* stm, - const std::string& name, - const std::map<std::string, std::string>& attrs); + const std::string& name, + const std::map<std::string, std::string>& attrs); virtual void endElement(XmlRpcRequestParserStateMachine* stm, - const std::string& name, - const std::string& characters) {} + const std::string& name, + const std::string& characters) {} virtual bool needsCharactersBuffering() const { return false; } }; class IntXmlRpcRequestParserState:public XmlRpcRequestParserState { virtual void beginElement(XmlRpcRequestParserStateMachine* stm, - const std::string& name, - const std::map<std::string, std::string>& attrs); + const std::string& name, + const std::map<std::string, std::string>& attrs); virtual void endElement(XmlRpcRequestParserStateMachine* stm, - const std::string& name, - const std::string& characters); + const std::string& name, + const std::string& characters); virtual bool needsCharactersBuffering() const { return true; } }; class StringXmlRpcRequestParserState:public XmlRpcRequestParserState { virtual void beginElement(XmlRpcRequestParserStateMachine* stm, - const std::string& name, - const std::map<std::string, std::string>& attrs); + const std::string& name, + const std::map<std::string, std::string>& attrs); virtual void endElement(XmlRpcRequestParserStateMachine* stm, - const std::string& name, - const std::string& characters); + const std::string& name, + const std::string& characters); virtual bool needsCharactersBuffering() const { return true; } }; class Base64XmlRpcRequestParserState:public XmlRpcRequestParserState { virtual void beginElement(XmlRpcRequestParserStateMachine* stm, - const std::string& name, - const std::map<std::string, std::string>& attrs); + const std::string& name, + const std::map<std::string, std::string>& attrs); virtual void endElement(XmlRpcRequestParserStateMachine* stm, - const std::string& name, - const std::string& characters); + const std::string& name, + const std::string& characters); virtual bool needsCharactersBuffering() const { return true; } }; class StructXmlRpcRequestParserState:public XmlRpcRequestParserState { virtual void beginElement(XmlRpcRequestParserStateMachine* stm, - const std::string& name, - const std::map<std::string, std::string>& attrs); + const std::string& name, + const std::map<std::string, std::string>& attrs); virtual void endElement(XmlRpcRequestParserStateMachine* stm, - const std::string& name, - const std::string& characters) {} + const std::string& name, + const std::string& characters) {} virtual bool needsCharactersBuffering() const { return false; } }; class MemberXmlRpcRequestParserState:public XmlRpcRequestParserState { virtual void beginElement(XmlRpcRequestParserStateMachine* stm, - const std::string& name, - const std::map<std::string, std::string>& attrs); + const std::string& name, + const std::map<std::string, std::string>& attrs); virtual void endElement(XmlRpcRequestParserStateMachine* stm, - const std::string& name, - const std::string& characters); + const std::string& name, + const std::string& characters); virtual bool needsCharactersBuffering() const { return false; } }; class NameXmlRpcRequestParserState:public XmlRpcRequestParserState { virtual void beginElement(XmlRpcRequestParserStateMachine* stm, - const std::string& name, - const std::map<std::string, std::string>& attrs); + const std::string& name, + const std::map<std::string, std::string>& attrs); virtual void endElement(XmlRpcRequestParserStateMachine* stm, - const std::string& name, - const std::string& characters); + const std::string& name, + const std::string& characters); virtual bool needsCharactersBuffering() const { return true; } }; class ArrayXmlRpcRequestParserState:public XmlRpcRequestParserState { virtual void beginElement(XmlRpcRequestParserStateMachine* stm, - const std::string& name, - const std::map<std::string, std::string>& attrs); + const std::string& name, + const std::map<std::string, std::string>& attrs); virtual void endElement(XmlRpcRequestParserStateMachine* stm, - const std::string& name, - const std::string& characters) {} + const std::string& name, + const std::string& characters) {} virtual bool needsCharactersBuffering() const { return false; } }; class DataXmlRpcRequestParserState:public XmlRpcRequestParserState { virtual void beginElement(XmlRpcRequestParserStateMachine* stm, - const std::string& name, - const std::map<std::string, std::string>& attrs); + const std::string& name, + const std::map<std::string, std::string>& attrs); virtual void endElement(XmlRpcRequestParserStateMachine* stm, - const std::string& name, - const std::string& characters) {} + const std::string& name, + const std::string& characters) {} virtual bool needsCharactersBuffering() const { return false; } }; class ArrayValueXmlRpcRequestParserState:public ValueXmlRpcRequestParserState { virtual void endElement(XmlRpcRequestParserStateMachine* stm, - const std::string& name, - const std::string& characters); + const std::string& name, + const std::string& characters); }; } // namespace xmlrpc diff --git a/src/XmlRpcRequestParserStateMachine.cc b/src/XmlRpcRequestParserStateMachine.cc index 4a06d0bc..32ccb1f6 100644 --- a/src/XmlRpcRequestParserStateMachine.cc +++ b/src/XmlRpcRequestParserStateMachine.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/XmlRpcRequestParserStateMachine.h b/src/XmlRpcRequestParserStateMachine.h index 50846acc..b5a515a8 100644 --- a/src/XmlRpcRequestParserStateMachine.h +++ b/src/XmlRpcRequestParserStateMachine.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -80,7 +80,7 @@ public: ~XmlRpcRequestParserStateMachine(); void beginElement(const std::string& name, - const std::map<std::string, std::string>& attrs) + const std::map<std::string, std::string>& attrs) { _stateStack.top()->beginElement(this, name, attrs); } diff --git a/src/XmlRpcRequestProcessor.h b/src/XmlRpcRequestProcessor.h index a8c21a77..c2256c03 100644 --- a/src/XmlRpcRequestProcessor.h +++ b/src/XmlRpcRequestProcessor.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/XmlRpcResponse.cc b/src/XmlRpcResponse.cc index 4cc09b21..b37247fb 100644 --- a/src/XmlRpcResponse.cc +++ b/src/XmlRpcResponse.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/XmlRpcResponse.h b/src/XmlRpcResponse.h index 2af1d579..bcbe46a2 100644 --- a/src/XmlRpcResponse.h +++ b/src/XmlRpcResponse.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/ZeroBtMessage.cc b/src/ZeroBtMessage.cc index 77b38737..cc74682f 100644 --- a/src/ZeroBtMessage.cc +++ b/src/ZeroBtMessage.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/ZeroBtMessage.h b/src/ZeroBtMessage.h index d22c2afd..9dfbd54f 100644 --- a/src/ZeroBtMessage.h +++ b/src/ZeroBtMessage.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/a2algo.h b/src/a2algo.h index 5a5b1b2f..377ca793 100644 --- a/src/a2algo.h +++ b/src/a2algo.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -41,7 +41,7 @@ namespace aria2 { template<typename InputIterator, typename OutputIterator> OutputIterator ncopy(InputIterator first, InputIterator last, - size_t count, OutputIterator destination) + size_t count, OutputIterator destination) { OutputIterator x = destination; while(count--) { @@ -62,7 +62,7 @@ OutputIterator ncopy(InputIterator first, InputIterator last, // and the length 6. template<typename InputIterator> std::pair<InputIterator, size_t> max_sequence(InputIterator first, - InputIterator last) + InputIterator last) { InputIterator maxfirst = last; size_t maxlen = 0; @@ -85,9 +85,9 @@ std::pair<InputIterator, size_t> max_sequence(InputIterator first, } template<typename InputIterator, typename R, typename C, typename A, - typename ACompat> + typename ACompat> static void forEachMemFunSH(InputIterator first, InputIterator last, - R (C::*f)(A), ACompat arg) + R (C::*f)(A), ACompat arg) { for(; first != last; ++first) { ((*first).get()->*f)(arg); diff --git a/src/a2functional.h b/src/a2functional.h index fb098e93..eee08b82 100644 --- a/src/a2functional.h +++ b/src/a2functional.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -91,8 +91,8 @@ mem_fun_sh(ReturnType (ClassType::*f)() const) // mem_fun1_t for SharedHandle template<typename ReturnType, typename ClassType, typename ArgType> class mem_fun1_sh_t:public std::binary_function<SharedHandle<ClassType>, - ArgType, - ReturnType> + ArgType, + ReturnType> { private: ReturnType (ClassType::*f)(ArgType); @@ -115,8 +115,8 @@ mem_fun_sh(ReturnType (ClassType::*f)(ArgType)) template<class BinaryOp, class UnaryOp> class adopt2nd_t:public std::binary_function<typename BinaryOp::first_argument_type, - typename UnaryOp::argument_type, - typename BinaryOp::result_type> { + typename UnaryOp::argument_type, + typename BinaryOp::result_type> { private: BinaryOp _binaryOp; UnaryOp _unaryOp; @@ -126,7 +126,7 @@ public: typename BinaryOp::result_type operator()(const typename BinaryOp::first_argument_type& x, - const typename UnaryOp::argument_type& y) + const typename UnaryOp::argument_type& y) { return _binaryOp(x, _unaryOp(y)); } @@ -206,7 +206,7 @@ public: template<typename InputIterator, typename DelimiterType> std::string strjoin(InputIterator first, InputIterator last, - const DelimiterType& delim) + const DelimiterType& delim) { std::string result; if(first == last) { @@ -243,82 +243,82 @@ strconcat(const T1& a1, const T2& a2, const T3& a3, const T4& a4) template<typename T1, typename T2, typename T3, typename T4, typename T5> inline std::string strconcat(const T1& a1, const T2& a2, const T3& a3, const T4& a4, - const T5& a5) + const T5& a5) { std::string s(a1); s += a2; s += a3; s += a4; s += a5; return s; } template<typename T1, typename T2, typename T3, typename T4, typename T5, - typename T6> + typename T6> inline std::string strconcat(const T1& a1, const T2& a2, const T3& a3, const T4& a4, - const T5& a5, const T6& a6) + const T5& a5, const T6& a6) { std::string s(a1); s += a2; s += a3; s += a4; s += a5; s += a6; return s; } template<typename T1, typename T2, typename T3, typename T4, typename T5, - typename T6, typename T7> + typename T6, typename T7> inline std::string strconcat(const T1& a1, const T2& a2, const T3& a3, const T4& a4, - const T5& a5, const T6& a6, const T7& a7) + const T5& a5, const T6& a6, const T7& a7) { std::string s(a1); s += a2; s += a3; s += a4; s += a5; s += a6; s += a7; return s; } template<typename T1, typename T2, typename T3, typename T4, typename T5, - typename T6, typename T7, typename T8> + typename T6, typename T7, typename T8> inline std::string strconcat(const T1& a1, const T2& a2, const T3& a3, const T4& a4, - const T5& a5, const T6& a6, const T7& a7, const T8& a8) + const T5& a5, const T6& a6, const T7& a7, const T8& a8) { std::string s(a1); s += a2; s += a3; s += a4; s += a5; s += a6; s += a7; s += a8; return s; } template<typename T1, typename T2, typename T3, typename T4, typename T5, - typename T6, typename T7, typename T8, typename T9> + typename T6, typename T7, typename T8, typename T9> inline std::string strconcat(const T1& a1, const T2& a2, const T3& a3, const T4& a4, - const T5& a5, const T6& a6, const T7& a7, const T8& a8, - const T9& a9) + const T5& a5, const T6& a6, const T7& a7, const T8& a8, + const T9& a9) { std::string s(a1); s += a2; s += a3; s += a4; s += a5; s += a6; s += a7; s += a8; s += a9; return s; } template<typename T1, typename T2, typename T3, typename T4, typename T5, - typename T6, typename T7, typename T8, typename T9, typename T10> + typename T6, typename T7, typename T8, typename T9, typename T10> inline std::string strconcat(const T1& a1, const T2& a2, const T3& a3, const T4& a4, - const T5& a5, const T6& a6, const T7& a7, const T8& a8, - const T9& a9, const T10& a10) + const T5& a5, const T6& a6, const T7& a7, const T8& a8, + const T9& a9, const T10& a10) { std::string s(a1); s += a2; s += a3; s += a4; s += a5; s += a6; s += a7; s += a8; s += a9; s += a10; return s; } template<typename T1, typename T2, typename T3, typename T4, typename T5, - typename T6, typename T7, typename T8, typename T9, typename T10, - typename T11> + typename T6, typename T7, typename T8, typename T9, typename T10, + typename T11> inline std::string strconcat(const T1& a1, const T2& a2, const T3& a3, const T4& a4, - const T5& a5, const T6& a6, const T7& a7, const T8& a8, - const T9& a9, const T10& a10, const T11& a11) + const T5& a5, const T6& a6, const T7& a7, const T8& a8, + const T9& a9, const T10& a10, const T11& a11) { std::string s(a1); s += a2; s += a3; s += a4; s += a5; s += a6; s += a7; s += a8; s += a9; s += a10; s += a11; return s; } template<typename T1, typename T2, typename T3, typename T4, typename T5, - typename T6, typename T7, typename T8, typename T9, typename T10, - typename T11, typename T12> + typename T6, typename T7, typename T8, typename T9, typename T10, + typename T11, typename T12> inline std::string strconcat(const T1& a1, const T2& a2, const T3& a3, const T4& a4, - const T5& a5, const T6& a6, const T7& a7, const T8& a8, - const T9& a9, const T10& a10, const T11& a11, - const T12& a12) + const T5& a5, const T6& a6, const T7& a7, const T8& a8, + const T9& a9, const T10& a10, const T11& a11, + const T12& a12) { std::string s(a1); s += a2; s += a3; s += a4; s += a5; s += a6; s += a7; s += a8; s += a9; s += a10; s += a11; s += a12; return s; @@ -332,50 +332,50 @@ inline void strappend(std::string& base, const T1& a1, const T2& a2) template<typename T1, typename T2, typename T3> inline void strappend(std::string& base, - const T1& a1, const T2& a2, const T3& a3) + const T1& a1, const T2& a2, const T3& a3) { base += a1; base += a2; base += a3; } template<typename T1, typename T2, typename T3, typename T4> inline void strappend(std::string& base, - const T1& a1, const T2& a2, const T3& a3, const T4& a4) + const T1& a1, const T2& a2, const T3& a3, const T4& a4) { base += a1; base += a2; base += a3; base += a4; } template<typename T1, typename T2, typename T3, typename T4, typename T5> inline void strappend(std::string& base, - const T1& a1, const T2& a2, const T3& a3, const T4& a4, - const T5& a5) + const T1& a1, const T2& a2, const T3& a3, const T4& a4, + const T5& a5) { base += a1; base += a2; base += a3; base += a4; base += a5; } template<typename T1, typename T2, typename T3, typename T4, typename T5, - typename T6> + typename T6> inline void strappend(std::string& base, - const T1& a1, const T2& a2, const T3& a3, const T4& a4, - const T5& a5, const T6& a6) + const T1& a1, const T2& a2, const T3& a3, const T4& a4, + const T5& a5, const T6& a6) { base += a1; base += a2; base += a3; base += a4; base += a5; base += a6; } template<typename T1, typename T2, typename T3, typename T4, typename T5, - typename T6, typename T7> + typename T6, typename T7> inline void strappend(std::string& base, - const T1& a1, const T2& a2, const T3& a3, const T4& a4, - const T5& a5, const T6& a6, const T7& a7) + const T1& a1, const T2& a2, const T3& a3, const T4& a4, + const T5& a5, const T6& a6, const T7& a7) { base += a1; base += a2; base += a3; base += a4; base += a5; base += a6; base += a7; } template<typename T1, typename T2, typename T3, typename T4, typename T5, - typename T6, typename T7, typename T8> + typename T6, typename T7, typename T8> inline void strappend(std::string& base, - const T1& a1, const T2& a2, const T3& a3, const T4& a4, - const T5& a5, const T6& a6, const T7& a7, const T8& a8) + const T1& a1, const T2& a2, const T3& a3, const T4& a4, + const T5& a5, const T6& a6, const T7& a7, const T8& a8) { base += a1; base += a2; base += a3; base += a4; base += a5; base += a6; base += a7; base += a8; @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -60,41 +60,41 @@ // st_mode flags #ifndef S_IRUSR -# define S_IRUSR 0000400 /* read permission, owner */ -#endif /* S_IRUSR */ +# define S_IRUSR 0000400 /* read permission, owner */ +#endif /* S_IRUSR */ #ifndef S_IWUSR -# define S_IWUSR 0000200 /* write permission, owner */ -#endif /* S_IWUSR */ +# define S_IWUSR 0000200 /* write permission, owner */ +#endif /* S_IWUSR */ #ifndef S_IXUSR -# define S_IXUSR 0000100/* execute/search permission, owner */ +# define S_IXUSR 0000100/* execute/search permission, owner */ #endif /* S_IXUSR */ #ifndef S_IRWXU -# define S_IRWXU (S_IRUSR | S_IWUSR | S_IXUSR) -#endif /* S_IRWXU */ +# define S_IRWXU (S_IRUSR | S_IWUSR | S_IXUSR) +#endif /* S_IRWXU */ #ifndef S_IRGRP -# define S_IRGRP 0000040 /* read permission, group */ -#endif /* S_IRGRP */ +# define S_IRGRP 0000040 /* read permission, group */ +#endif /* S_IRGRP */ #ifndef S_IWGRP -# define S_IWGRP 0000020 /* write permission, grougroup */ -#endif /* S_IWGRP */ +# define S_IWGRP 0000020 /* write permission, grougroup */ +#endif /* S_IWGRP */ #ifndef S_IXGRP -# define S_IXGRP 0000010/* execute/search permission, group */ +# define S_IXGRP 0000010/* execute/search permission, group */ #endif /* S_IXGRP */ #ifndef S_IRWXG -# define S_IRWXG (S_IRGRP | S_IWGRP | S_IXGRP) -#endif /* S_IRWXG */ +# define S_IRWXG (S_IRGRP | S_IWGRP | S_IXGRP) +#endif /* S_IRWXG */ #ifndef S_IROTH -# define S_IROTH 0000004 /* read permission, other */ -#endif /* S_IROTH */ +# define S_IROTH 0000004 /* read permission, other */ +#endif /* S_IROTH */ #ifndef S_IWOTH -# define S_IWOTH 0000002 /* write permission, other */ -#endif /* S_IWOTH */ +# define S_IWOTH 0000002 /* write permission, other */ +#endif /* S_IWOTH */ #ifndef S_IXOTH -# define S_IXOTH 0000001/* execute/search permission, other */ +# define S_IXOTH 0000001/* execute/search permission, other */ #endif /* S_IXOTH */ #ifndef S_IRWXO -# define S_IRWXO (S_IROTH | S_IWOTH | S_IXOTH) -#endif /* S_IRWXO */ +# define S_IRWXO (S_IROTH | S_IWOTH | S_IXOTH) +#endif /* S_IRWXO */ // Use 'nul' instead of /dev/null in win32. #ifdef HAVE_WINSOCK2_H diff --git a/src/a2netcompat.h b/src/a2netcompat.h index b3f825b5..30d3a5f1 100644 --- a/src/a2netcompat.h +++ b/src/a2netcompat.h @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/a2time.h b/src/a2time.h index 48105a3f..04822803 100644 --- a/src/a2time.h +++ b/src/a2time.h @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/array_fun.h b/src/array_fun.h index c6d53475..d70ad367 100644 --- a/src/array_fun.h +++ b/src/array_fun.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/asctime_r.c b/src/asctime_r.c index 5d7ee3db..3b4a8b5c 100644 --- a/src/asctime_r.c +++ b/src/asctime_r.c @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/asctime_r.h b/src/asctime_r.h index f1e33957..21e31da5 100644 --- a/src/asctime_r.h +++ b/src/asctime_r.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/base32.cc b/src/base32.cc index 3b15843c..9c30596d 100644 --- a/src/base32.cc +++ b/src/base32.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -58,8 +58,8 @@ std::string encode(const std::string& src) if(count == 5) { char temp[8]; for(size_t j = 0; j < 8; ++j) { - temp[7-j] = B32TABLE[buf&0x1f]; - buf >>= 5; + temp[7-j] = B32TABLE[buf&0x1f]; + buf >>= 5; } ret += std::string(&temp[0], &temp[8]); count = 0; @@ -106,15 +106,15 @@ std::string decode(const std::string& src) char ch = src[i+j]; unsigned char value; if('A' <= ch && ch <= 'Z') { - value = ch-'A'; + value = ch-'A'; } else if('2' <= ch && ch <= '7') { - value = ch-'2'+26; + value = ch-'2'+26; } else if(ch == '=') { - done = true; - break; + done = true; + break; } else { - ret.clear(); - return ret; + ret.clear(); + return ret; } buf <<= 5; buf += value; diff --git a/src/base32.h b/src/base32.h index 3c7a815c..e068f721 100644 --- a/src/base32.h +++ b/src/base32.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/bencode.cc b/src/bencode.cc index 949a96bb..eac003f8 100644 --- a/src/bencode.cc +++ b/src/bencode.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -52,7 +52,7 @@ static void checkdelim(std::istream& ss, const char delim = ':') if(!(ss.get(d) && d == delim)) { throw DL_ABORT_EX (StringFormat("Bencode decoding failed: Delimiter '%c' not found.", - delim).str()); + delim).str()); } } @@ -62,7 +62,7 @@ static std::string decoderawstring(std::istream& ss) ss >> length; if(!ss || length < 0) { throw DL_ABORT_EX("Bencode decoding failed:" - " A positive integer expected but none found."); + " A positive integer expected but none found."); } // TODO check length, it must be less than or equal to INT_MAX checkdelim(ss); @@ -73,8 +73,8 @@ static std::string decoderawstring(std::istream& ss) if(ss.gcount() != static_cast<int>(length)) { throw DL_ABORT_EX (StringFormat("Bencode decoding failed:" - " Expected %lu bytes of data, but only %d read.", - static_cast<unsigned long>(length), ss.gcount()).str()); + " Expected %lu bytes of data, but only %d read.", + static_cast<unsigned long>(length), ss.gcount()).str()); } return str; } @@ -90,7 +90,7 @@ static BDE decodeinteger(std::istream& ss) ss >> integer; if(!ss) { throw DL_ABORT_EX("Bencode decoding failed:" - " Integer expected but none found"); + " Integer expected but none found"); } checkdelim(ss, 'e'); return BDE(integer); @@ -110,7 +110,7 @@ static BDE decodedict(std::istream& ss, size_t depth) } } throw DL_ABORT_EX("Bencode decoding failed:" - " Unexpected EOF in dict context. 'e' expected."); + " Unexpected EOF in dict context. 'e' expected."); } static BDE decodelist(std::istream& ss, size_t depth) @@ -126,7 +126,7 @@ static BDE decodelist(std::istream& ss, size_t depth) } } throw DL_ABORT_EX("Bencode decoding failed:" - " Unexpected EOF in list context. 'e' expected."); + " Unexpected EOF in list context. 'e' expected."); } static void checkDepth(size_t depth) @@ -142,8 +142,8 @@ static BDE decodeiter(std::istream& ss, size_t depth) char c; if(!ss.get(c)) { throw DL_ABORT_EX("Bencode decoding failed:" - " Unexpected EOF in term context." - " 'd', 'l', 'i' or digit is expected."); + " Unexpected EOF in term context." + " 'd', 'l', 'i' or digit is expected."); } if(c == 'd') { return decodedict(ss, depth+1); @@ -198,7 +198,7 @@ BDE decodeFromFile(const std::string& filename) } else { throw DL_ABORT_EX (StringFormat("Bencode decoding failed:" - " Cannot open file '%s'.", filename.c_str()).str()); + " Cannot open file '%s'.", filename.c_str()).str()); } } diff --git a/src/bencode.h b/src/bencode.h index 280c0af2..b865b8ae 100644 --- a/src/bencode.h +++ b/src/bencode.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/bitfield.cc b/src/bitfield.cc index 30c861e0..8c989969 100644 --- a/src/bitfield.cc +++ b/src/bitfield.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/bitfield.h b/src/bitfield.h index 869010de..e4088b88 100644 --- a/src/bitfield.h +++ b/src/bitfield.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/bittorrent_helper.cc b/src/bittorrent_helper.cc index 050a5af0..7c523f2f 100644 --- a/src/bittorrent_helper.cc +++ b/src/bittorrent_helper.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -132,15 +132,15 @@ const std::string METADATA_SIZE("metadataSize"); const std::string METADATA("metadata"); static void extractPieceHash(const SharedHandle<DownloadContext>& ctx, - const std::string& hashData, - size_t hashLength, - size_t numPieces) + const std::string& hashData, + size_t hashLength, + size_t numPieces) { std::vector<std::string> pieceHashes; pieceHashes.reserve(numPieces); for(size_t i = 0; i < numPieces; ++i) { pieceHashes.push_back(util::toHex(hashData.data()+i*hashLength, - hashLength)); + hashLength)); } ctx->setPieceHashes(pieceHashes.begin(), pieceHashes.end()); ctx->setPieceHashAlgo(MessageDigestContext::SHA1); @@ -151,9 +151,9 @@ static void extractUrlList { if(bde.isList()) { for(BDE::List::const_iterator itr = bde.listBegin(); - itr != bde.listEnd(); ++itr) { + itr != bde.listEnd(); ++itr) { if((*itr).isString()) { - uris.push_back((*itr).s()); + uris.push_back((*itr).s()); } } torrent[URL_LIST] = bde; @@ -223,32 +223,32 @@ static void extractFileEntries // multi-file mode torrent[MODE] = MULTI; for(BDE::List::const_iterator itr = filesList.listBegin(); - itr != filesList.listEnd(); ++itr) { + itr != filesList.listEnd(); ++itr) { const BDE& fileDict = *itr; if(!fileDict.isDict()) { - continue; + continue; } const BDE& fileLengthData = fileDict[C_LENGTH]; if(!fileLengthData.isInteger()) { - throw DL_ABORT_EX(StringFormat(MSG_MISSING_BT_INFO, - C_LENGTH.c_str()).str()); + throw DL_ABORT_EX(StringFormat(MSG_MISSING_BT_INFO, + C_LENGTH.c_str()).str()); } length += fileLengthData.i(); std::string pathKey; if(fileDict.containsKey(C_PATH_UTF8)) { - pathKey = C_PATH_UTF8; + pathKey = C_PATH_UTF8; } else { - pathKey = C_PATH; + pathKey = C_PATH; } const BDE& pathList = fileDict[pathKey]; if(!pathList.isList() || pathList.empty()) { - throw DL_ABORT_EX("Path is empty."); + throw DL_ABORT_EX("Path is empty."); } std::vector<std::string> pathelem(pathList.size()); std::transform(pathList.listBegin(), pathList.listEnd(), pathelem.begin(), - std::mem_fun_ref(&BDE::s)); + std::mem_fun_ref(&BDE::s)); std::string path = name; strappend(path, "/", util::joinPath(pathelem.begin(), pathelem.end())); // Split path with '/' again because each pathList element can @@ -260,9 +260,9 @@ static void extractFileEntries std::deque<std::string> uris; createUri(urlList.begin(), urlList.end(), std::back_inserter(uris), path); SharedHandle<FileEntry> fileEntry - (new FileEntry(strconcat(ctx->getDir(), "/", path), - fileLengthData.i(), - offset, uris)); + (new FileEntry(strconcat(ctx->getDir(), "/", path), + fileLengthData.i(), + offset, uris)); fileEntries.push_back(fileEntry); offset += fileEntry->getLength(); } @@ -271,8 +271,8 @@ static void extractFileEntries torrent[MODE] = SINGLE; const BDE& lengthData = infoDict[C_LENGTH]; if(!lengthData.isInteger()) { - throw DL_ABORT_EX(StringFormat(MSG_MISSING_BT_INFO, - C_LENGTH.c_str()).str()); + throw DL_ABORT_EX(StringFormat(MSG_MISSING_BT_INFO, + C_LENGTH.c_str()).str()); } uint64_t totalLength = lengthData.i(); @@ -280,17 +280,17 @@ static void extractFileEntries // concatenate name to it. Specification just says so. std::deque<std::string> uris; for(std::vector<std::string>::const_iterator i = urlList.begin(); - i != urlList.end(); ++i) { + i != urlList.end(); ++i) { if(util::endsWith(*i, "/")) { - uris.push_back((*i)+name); + uris.push_back((*i)+name); } else { - uris.push_back(*i); + uris.push_back(*i); } } SharedHandle<FileEntry> fileEntry (new FileEntry(strconcat(ctx->getDir(), "/", name),totalLength, 0, - uris)); + uris)); fileEntries.push_back(fileEntry); } ctx->setFileEntries(fileEntries.begin(), fileEntries.end()); @@ -306,12 +306,12 @@ static void extractAnnounce(BDE& torrent, const BDE& rootDict) torrent[ANNOUNCE_LIST] = announceList; BDE& tiers = torrent[ANNOUNCE_LIST]; for(BDE::List::iterator tieriter = tiers.listBegin(); - tieriter != tiers.listEnd(); ++tieriter) { + tieriter != tiers.listEnd(); ++tieriter) { for(BDE::List::iterator uriiter = (*tieriter).listBegin(); - uriiter != (*tieriter).listEnd(); ++uriiter) { - if((*uriiter).isString()) { - *uriiter = util::trim((*uriiter).s()); - } + uriiter != (*tieriter).listEnd(); ++uriiter) { + if((*uriiter).isString()) { + *uriiter = util::trim((*uriiter).s()); + } } } } else { @@ -330,21 +330,21 @@ static void extractNodes(BDE& torrent, const BDE& nodesList) BDE nodes = BDE::list(); if(nodesList.isList()) { for(BDE::List::const_iterator i = nodesList.listBegin(); - i != nodesList.listEnd(); ++i) { + i != nodesList.listEnd(); ++i) { const BDE& addrPairList = (*i); if(!addrPairList.isList() || addrPairList.size() != 2) { - continue; + continue; } const BDE& hostname = addrPairList[0]; if(!hostname.isString()) { - continue; + continue; } if(util::trim(hostname.s()).empty()) { - continue; + continue; } const BDE& port = addrPairList[1]; if(!port.isInteger() || !(0 < port.i() && port.i() < 65536)) { - continue; + continue; } BDE node = BDE::dict(); node[HOSTNAME] = hostname; @@ -368,7 +368,7 @@ static void processRootDictionary const BDE& infoDict = rootDict[C_INFO]; if(!infoDict.isDict()) { throw DL_ABORT_EX(StringFormat(MSG_MISSING_BT_INFO, - C_INFO.c_str()).str()); + C_INFO.c_str()).str()); } BDE torrent = BDE::dict(); @@ -376,9 +376,9 @@ static void processRootDictionary std::string encodedInfoDict = bencode::encode(infoDict); unsigned char infoHash[INFO_HASH_LENGTH]; MessageDigestHelper::digest(infoHash, INFO_HASH_LENGTH, - MessageDigestContext::SHA1, - encodedInfoDict.data(), - encodedInfoDict.size()); + MessageDigestContext::SHA1, + encodedInfoDict.data(), + encodedInfoDict.size()); torrent[INFO_HASH] = std::string(&infoHash[0], &infoHash[INFO_HASH_LENGTH]); torrent[METADATA] = encodedInfoDict; torrent[METADATA_SIZE] = encodedInfoDict.size(); @@ -387,7 +387,7 @@ static void processRootDictionary const BDE& piecesData = infoDict[C_PIECES]; if(!piecesData.isString()) { throw DL_ABORT_EX(StringFormat(MSG_MISSING_BT_INFO, - C_PIECES.c_str()).str()); + C_PIECES.c_str()).str()); } // Commented out To download 0 length torrent. // if(piecesData.s().empty()) { @@ -402,7 +402,7 @@ static void processRootDictionary const BDE& pieceLengthData = infoDict[C_PIECE_LENGTH]; if(!pieceLengthData.isInteger()) { throw DL_ABORT_EX(StringFormat(MSG_MISSING_BT_INFO, - C_PIECE_LENGTH.c_str()).str()); + C_PIECE_LENGTH.c_str()).str()); } size_t pieceLength = pieceLengthData.i(); ctx->setPieceLength(pieceLength); @@ -458,59 +458,59 @@ static void processRootDictionary } void load(const std::string& torrentFile, - const SharedHandle<DownloadContext>& ctx, - const std::string& overrideName) + const SharedHandle<DownloadContext>& ctx, + const std::string& overrideName) { processRootDictionary(ctx, - bencode::decodeFromFile(torrentFile), - torrentFile, - overrideName, - std::deque<std::string>()); + bencode::decodeFromFile(torrentFile), + torrentFile, + overrideName, + std::deque<std::string>()); } void load(const std::string& torrentFile, - const SharedHandle<DownloadContext>& ctx, - const std::deque<std::string>& uris, - const std::string& overrideName) + const SharedHandle<DownloadContext>& ctx, + const std::deque<std::string>& uris, + const std::string& overrideName) { processRootDictionary(ctx, - bencode::decodeFromFile(torrentFile), - torrentFile, - overrideName, - uris); + bencode::decodeFromFile(torrentFile), + torrentFile, + overrideName, + uris); } void loadFromMemory(const unsigned char* content, - size_t length, - const SharedHandle<DownloadContext>& ctx, - const std::string& defaultName, - const std::string& overrideName) + size_t length, + const SharedHandle<DownloadContext>& ctx, + const std::string& defaultName, + const std::string& overrideName) { processRootDictionary(ctx, - bencode::decode(content, length), - defaultName, - overrideName, - std::deque<std::string>()); + bencode::decode(content, length), + defaultName, + overrideName, + std::deque<std::string>()); } void loadFromMemory(const unsigned char* content, - size_t length, - const SharedHandle<DownloadContext>& ctx, - const std::deque<std::string>& uris, - const std::string& defaultName, - const std::string& overrideName) + size_t length, + const SharedHandle<DownloadContext>& ctx, + const std::deque<std::string>& uris, + const std::string& defaultName, + const std::string& overrideName) { processRootDictionary(ctx, - bencode::decode(content, length), - defaultName, - overrideName, - uris); + bencode::decode(content, length), + defaultName, + overrideName, + uris); } void loadFromMemory(const std::string& context, - const SharedHandle<DownloadContext>& ctx, - const std::string& defaultName, - const std::string& overrideName) + const SharedHandle<DownloadContext>& ctx, + const std::string& defaultName, + const std::string& overrideName) { processRootDictionary (ctx, @@ -520,10 +520,10 @@ void loadFromMemory(const std::string& context, } void loadFromMemory(const std::string& context, - const SharedHandle<DownloadContext>& ctx, - const std::deque<std::string>& uris, - const std::string& defaultName, - const std::string& overrideName) + const SharedHandle<DownloadContext>& ctx, + const std::deque<std::string>& uris, + const std::string& defaultName, + const std::string& overrideName) { processRootDictionary (ctx, @@ -573,7 +573,7 @@ void print(std::ostream& o, const SharedHandle<DownloadContext>& dctx) continue; } for(BDE::List::const_iterator i = (*tieritr).listBegin(); - i != (*tieritr).listEnd(); ++i) { + i != (*tieritr).listEnd(); ++i) { o << " " << (*i).s(); } o << "\n"; @@ -587,7 +587,7 @@ void print(std::ostream& o, const SharedHandle<DownloadContext>& dctx) const BDE& urlList = torrentAttrs[URL_LIST]; o << "URL List: " << "\n"; for(BDE::List::const_iterator i = urlList.listBegin(); - i != urlList.listEnd(); ++i) { + i != urlList.listEnd(); ++i) { o << " " << (*i).s() << "\n"; } } @@ -626,7 +626,7 @@ void computeFastSet uint32_t y = ntohl(ny); size_t index = y%numPieces; if(std::find(fastSet.begin(), fastSet.end(), index) == fastSet.end()) { - fastSet.push_back(index); + fastSet.push_back(index); } } unsigned char temp[20]; @@ -700,7 +700,7 @@ void checkIndex(size_t index, size_t pieces) { if(!(index < pieces)) { throw DL_ABORT_EX(StringFormat("Invalid index: %lu", - static_cast<unsigned long>(index)).str()); + static_cast<unsigned long>(index)).str()); } } @@ -716,13 +716,13 @@ void checkLength(size_t length) if(length > MAX_BLOCK_LENGTH) { throw DL_ABORT_EX (StringFormat("Length too long: %lu > %uKB", - static_cast<unsigned long>(length), - MAX_BLOCK_LENGTH/1024).str()); + static_cast<unsigned long>(length), + MAX_BLOCK_LENGTH/1024).str()); } if(length == 0) { throw DL_ABORT_EX (StringFormat("Invalid length: %lu", - static_cast<unsigned long>(length)).str()); + static_cast<unsigned long>(length)).str()); } } @@ -731,15 +731,15 @@ void checkRange(uint32_t begin, size_t length, size_t pieceLength) if(!(0 < length)) { throw DL_ABORT_EX (StringFormat("Invalid range: begin=%u, length=%lu", - begin, - static_cast<unsigned long>(length)).str()); + begin, + static_cast<unsigned long>(length)).str()); } uint32_t end = begin+length; if(!(end <= pieceLength)) { throw DL_ABORT_EX (StringFormat("Invalid range: begin=%u, length=%lu", - begin, - static_cast<unsigned long>(length)).str()); + begin, + static_cast<unsigned long>(length)).str()); } } @@ -749,11 +749,11 @@ void checkBitfield if(!(bitfieldLength == (pieces+7)/8)) { throw DL_ABORT_EX (StringFormat("Invalid bitfield length: %lu", - static_cast<unsigned long>(bitfieldLength)).str()); + static_cast<unsigned long>(bitfieldLength)).str()); } // Check if last byte contains garbage set bit. if(bitfield[bitfieldLength-1]&~bitfield::lastByteMask(pieces)) { - throw DL_ABORT_EX("Invalid bitfield"); + throw DL_ABORT_EX("Invalid bitfield"); } } @@ -811,8 +811,8 @@ std::pair<std::string, uint16_t> unpackcompact(const unsigned char* compact) char host[NI_MAXHOST]; int s; s = getnameinfo(reinterpret_cast<const struct sockaddr*>(&in), sizeof(in), - host, NI_MAXHOST, 0, NI_MAXSERV, - NI_NUMERICHOST); + host, NI_MAXHOST, 0, NI_MAXSERV, + NI_NUMERICHOST); if(s) { return std::pair<std::string, uint16_t>(); } @@ -838,7 +838,7 @@ void assertPayloadLengthEqual if(expected != actual) { throw DL_ABORT_EX (StringFormat(EX_INVALID_PAYLOAD_SIZE, msgName.c_str(), - actual, expected).str()); + actual, expected).str()); } } @@ -849,7 +849,7 @@ void assertID if(expected != id) { throw DL_ABORT_EX (StringFormat(EX_INVALID_BT_MESSAGE_ID, id, msgName.c_str(), - expected).str()); + expected).str()); } } @@ -894,7 +894,7 @@ BDE parseMagnet(const std::string& magnet) if(r.containsKey("tr")) { const BDE& uris = r["tr"]; for(BDE::List::const_iterator i = uris.listBegin(); i != uris.listEnd(); - ++i) { + ++i) { BDE tier = BDE::list(); tier << *i; announceList << tier; @@ -952,11 +952,11 @@ std::string torrent2Magnet(const BDE& attrs) if(attrs.containsKey(ANNOUNCE_LIST)) { const BDE& tiers = attrs[ANNOUNCE_LIST]; for(BDE::List::const_iterator tieriter = tiers.listBegin(); - tieriter != tiers.listEnd(); ++tieriter) { + tieriter != tiers.listEnd(); ++tieriter) { for(BDE::List::const_iterator uriiter = (*tieriter).listBegin(); - uriiter != (*tieriter).listEnd(); ++uriiter) { - uri += "&tr="; - uri += util::urlencode((*uriiter).s()); + uriiter != (*tieriter).listEnd(); ++uriiter) { + uri += "&tr="; + uri += util::urlencode((*uriiter).s()); } } } diff --git a/src/bittorrent_helper.h b/src/bittorrent_helper.h index a27427ae..d08962b8 100644 --- a/src/bittorrent_helper.h +++ b/src/bittorrent_helper.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -89,35 +89,35 @@ extern const std::string METADATA_SIZE; extern const std::string METADATA; void load(const std::string& torrentFile, - const SharedHandle<DownloadContext>& ctx, - const std::string& overrideName = ""); + const SharedHandle<DownloadContext>& ctx, + const std::string& overrideName = ""); void load(const std::string& torrentFile, - const SharedHandle<DownloadContext>& ctx, - const std::deque<std::string>& uris, - const std::string& overrideName = ""); + const SharedHandle<DownloadContext>& ctx, + const std::deque<std::string>& uris, + const std::string& overrideName = ""); void loadFromMemory(const unsigned char* content, size_t length, - const SharedHandle<DownloadContext>& ctx, - const std::string& defaultName, - const std::string& overrideName = ""); + const SharedHandle<DownloadContext>& ctx, + const std::string& defaultName, + const std::string& overrideName = ""); void loadFromMemory(const unsigned char* content, size_t length, - const SharedHandle<DownloadContext>& ctx, - const std::deque<std::string>& uris, - const std::string& defaultName, - const std::string& overrideName = ""); + const SharedHandle<DownloadContext>& ctx, + const std::deque<std::string>& uris, + const std::string& defaultName, + const std::string& overrideName = ""); void loadFromMemory(const std::string& context, - const SharedHandle<DownloadContext>& ctx, - const std::string& defaultName, - const std::string& overrideName = ""); + const SharedHandle<DownloadContext>& ctx, + const std::string& defaultName, + const std::string& overrideName = ""); void loadFromMemory(const std::string& context, - const SharedHandle<DownloadContext>& ctx, - const std::deque<std::string>& uris, - const std::string& defaultName, - const std::string& overrideName = ""); + const SharedHandle<DownloadContext>& ctx, + const std::deque<std::string>& uris, + const std::string& defaultName, + const std::string& overrideName = ""); // Parses BitTorrent Magnet URI and returns BDE::dict() which includes // infoHash, name and announceList. If parsing operation failed, an diff --git a/src/common.h b/src/common.h index 4096d630..46420cb5 100644 --- a/src/common.h +++ b/src/common.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -39,11 +39,11 @@ # undef SIZE_MAX # ifndef _OFF_T_ # define _OFF_T_ - typedef long long _off_t; +typedef long long _off_t; # ifndef _NO_OLDNAMES - typedef _off_t off_t; +typedef _off_t off_t; # endif // !_NO_OLDNAMES -# endif // !_OFF_T_ +# endif // !_OFF_T_ #endif // __MINGW32__ #ifdef HAVE_CONFIG_H @@ -52,10 +52,10 @@ #ifdef __MINGW32__ #ifdef malloc -# undef malloc +# undef malloc #endif #ifdef realloc -# undef realloc +# undef realloc #endif #endif // __MINGW32__ diff --git a/src/daemon.cc b/src/daemon.cc index 35a094c1..50b21e9a 100644 --- a/src/daemon.cc +++ b/src/daemon.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/daemon.h b/src/daemon.h index d3be03aa..70537816 100644 --- a/src/daemon.h +++ b/src/daemon.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/download_helper.cc b/src/download_helper.cc index ffe9448f..28a7579b 100644 --- a/src/download_helper.cc +++ b/src/download_helper.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -163,9 +163,9 @@ static void unfoldURI } static void splitURI(std::deque<std::string>& result, - std::deque<std::string>::const_iterator begin, - std::deque<std::string>::const_iterator end, - size_t numSplit) + std::deque<std::string>::const_iterator begin, + std::deque<std::string>::const_iterator end, + size_t numSplit) { size_t numURIs = std::distance(begin, end); if(numURIs >= numSplit) { @@ -200,9 +200,9 @@ static SharedHandle<RequestGroup> createRequestGroup static SharedHandle<RequestGroup> createBtRequestGroup(const std::string& torrentFilePath, - const SharedHandle<Option>& option, - const std::deque<std::string>& auxUris, - const std::string& torrentData = "") + const SharedHandle<Option>& option, + const std::deque<std::string>& auxUris, + const std::string& torrentData = "") { SharedHandle<RequestGroup> rg(new RequestGroup(option)); SharedHandle<DownloadContext> dctx(new DownloadContext()); @@ -230,13 +230,13 @@ createBtRequestGroup(const std::string& torrentFilePath, static SharedHandle<RequestGroup> createBtMagnetRequestGroup(const std::string& magnetLink, - const SharedHandle<Option>& option, - const std::deque<std::string>& auxUris) + const SharedHandle<Option>& option, + const std::deque<std::string>& auxUris) { SharedHandle<RequestGroup> rg(new RequestGroup(option)); SharedHandle<DownloadContext> dctx (new DownloadContext(METADATA_PIECE_SIZE, 0, - A2STR::NIL)); + A2STR::NIL)); dctx->setDir(A2STR::NIL); // We only know info hash. Total Length is unknown at this moment. dctx->markTotalLengthIsUnknown(); @@ -273,7 +273,7 @@ void createRequestGroupForBitTorrent splitURI(auxUris, nargs.begin(), nargs.end(), numSplit); SharedHandle<RequestGroup> rg = createBtRequestGroup(option->get(PREF_TORRENT_FILE), option, auxUris, - torrentData); + torrentData); rg->setNumConcurrentCommand(numSplit); result.push_back(rg); } @@ -288,8 +288,8 @@ void createRequestGroupForMetalink { if(metalinkData.empty()) { Metalink2RequestGroup().generate(result, - option->get(PREF_METALINK_FILE), - option); + option->get(PREF_METALINK_FILE), + option); } else { SharedHandle<ByteArrayDiskWriter> dw(new ByteArrayDiskWriter()); dw->setString(metalinkData); @@ -309,8 +309,8 @@ private: bool _ignoreLocalPath; public: AccRequestGroup(std::deque<SharedHandle<RequestGroup> >& requestGroups, - const SharedHandle<Option>& option, - bool ignoreLocalPath = false): + const SharedHandle<Option>& option, + bool ignoreLocalPath = false): _requestGroups(requestGroups), _option(option), _ignoreLocalPath(ignoreLocalPath) {} @@ -321,43 +321,43 @@ public: std::deque<std::string> streamURIs; size_t numSplit = _option->getAsInt(PREF_SPLIT); for(size_t i = 0; i < numSplit; ++i) { - streamURIs.push_back(uri); + streamURIs.push_back(uri); } SharedHandle<RequestGroup> rg = - createRequestGroup(_option, streamURIs); + createRequestGroup(_option, streamURIs); rg->setNumConcurrentCommand(numSplit); _requestGroups.push_back(rg); } #ifdef ENABLE_BITTORRENT else if(_detector.guessTorrentMagnet(uri)) { try { - SharedHandle<RequestGroup> group = - createBtMagnetRequestGroup(uri, _option, std::deque<std::string>()); - _requestGroups.push_back(group); + SharedHandle<RequestGroup> group = + createBtMagnetRequestGroup(uri, _option, std::deque<std::string>()); + _requestGroups.push_back(group); } catch(RecoverableException& e) { - // error occurred while parsing torrent file. - // We simply ignore it. - LogFactory::getInstance()->error(EX_EXCEPTION_CAUGHT, e); + // error occurred while parsing torrent file. + // We simply ignore it. + LogFactory::getInstance()->error(EX_EXCEPTION_CAUGHT, e); } } else if(!_ignoreLocalPath && _detector.guessTorrentFile(uri)) { try { - _requestGroups.push_back(createBtRequestGroup(uri, _option, - std::deque<std::string>())); + _requestGroups.push_back(createBtRequestGroup(uri, _option, + std::deque<std::string>())); } catch(RecoverableException& e) { - // error occurred while parsing torrent file. - // We simply ignore it. - LogFactory::getInstance()->error(EX_EXCEPTION_CAUGHT, e); + // error occurred while parsing torrent file. + // We simply ignore it. + LogFactory::getInstance()->error(EX_EXCEPTION_CAUGHT, e); } } #endif // ENABLE_BITTORRENT #ifdef ENABLE_METALINK else if(!_ignoreLocalPath && _detector.guessMetalinkFile(uri)) { try { - Metalink2RequestGroup().generate(_requestGroups, uri, _option); + Metalink2RequestGroup().generate(_requestGroups, uri, _option); } catch(RecoverableException& e) { - // error occurred while parsing metalink file. - // We simply ignore it. - LogFactory::getInstance()->error(EX_EXCEPTION_CAUGHT, e); + // error occurred while parsing metalink file. + // We simply ignore it. + LogFactory::getInstance()->error(EX_EXCEPTION_CAUGHT, e); } } #endif // ENABLE_METALINK @@ -391,7 +391,7 @@ void createRequestGroupForUri } if(!ignoreForceSequential && option->get(PREF_FORCE_SEQUENTIAL) == V_TRUE) { std::for_each(nargs.begin(), nargs.end(), - AccRequestGroup(result, option, ignoreLocalPath)); + AccRequestGroup(result, option, ignoreLocalPath)); } else { std::deque<std::string>::iterator strmProtoEnd = std::stable_partition(nargs.begin(), nargs.end(), StreamProtocolFilter()); @@ -400,15 +400,15 @@ void createRequestGroupForUri size_t numSplit = option->getAsInt(PREF_SPLIT); std::deque<std::string> streamURIs; splitURI(streamURIs, nargs.begin(), strmProtoEnd, - numSplit); + numSplit); SharedHandle<RequestGroup> rg = - createRequestGroup(option, streamURIs, true); + createRequestGroup(option, streamURIs, true); rg->setNumConcurrentCommand(numSplit); result.push_back(rg); } // process remaining URIs(local metalink, BitTorrent files) std::for_each(strmProtoEnd, nargs.end(), - AccRequestGroup(result, option, ignoreLocalPath)); + AccRequestGroup(result, option, ignoreLocalPath)); } } @@ -428,9 +428,9 @@ static void createRequestGroupForUriList SharedHandle<Option> requestOption(new Option(*option.get())); for(std::set<std::string>::const_iterator i = - listRequestOptions().begin(); i != listRequestOptions().end(); ++i) { + listRequestOptions().begin(); i != listRequestOptions().end(); ++i) { if(tempOption->defined(*i)) { - requestOption->put(*i, tempOption->get(*i)); + requestOption->put(*i, tempOption->get(*i)); } } @@ -447,8 +447,8 @@ void createRequestGroupForUriList } else { if(!File(option->get(PREF_INPUT_FILE)).isFile()) { throw DL_ABORT_EX - (StringFormat(EX_FILE_OPEN, option->get(PREF_INPUT_FILE).c_str(), - "No such file").str()); + (StringFormat(EX_FILE_OPEN, option->get(PREF_INPUT_FILE).c_str(), + "No such file").str()); } std::ifstream f(option->get(PREF_INPUT_FILE).c_str(), std::ios::binary); createRequestGroupForUriList(result, option, f); diff --git a/src/download_helper.h b/src/download_helper.h index 6d4cbb98..68074a4f 100644 --- a/src/download_helper.h +++ b/src/download_helper.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/gettimeofday.h b/src/gettimeofday.h index 3ce51bd9..c64f369b 100644 --- a/src/gettimeofday.h +++ b/src/gettimeofday.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -53,7 +53,7 @@ extern "C" { #ifndef HAVE_GETTIMEOFDAY int __cdecl gettimeofday(struct timeval *__restrict__ tp, - void *__restrict__ tzp __attribute__((unused))); + void *__restrict__ tzp __attribute__((unused))); #endif // HAVE_GETTIMEOFDAY diff --git a/src/help_tags.h b/src/help_tags.h index 8907c531..4d34f9c8 100644 --- a/src/help_tags.h +++ b/src/help_tags.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/inet_aton.c b/src/inet_aton.c index 3d121469..c408ee75 100644 --- a/src/inet_aton.c +++ b/src/inet_aton.c @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/inet_aton.h b/src/inet_aton.h index 68a0065f..29ac525f 100644 --- a/src/inet_aton.h +++ b/src/inet_aton.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/libgen.c b/src/libgen.c index 110cfde6..814c2d91 100644 --- a/src/libgen.c +++ b/src/libgen.c @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/libgen.h b/src/libgen.h index 7e3cd347..e2485d6e 100644 --- a/src/libgen.h +++ b/src/libgen.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/localtime_r.c b/src/localtime_r.c index dbe2dfd7..2077405f 100644 --- a/src/localtime_r.c +++ b/src/localtime_r.c @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/localtime_r.h b/src/localtime_r.h index 8b209732..af90b6d8 100644 --- a/src/localtime_r.h +++ b/src/localtime_r.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/magnet.cc b/src/magnet.cc index 954e9990..b74e4f1d 100644 --- a/src/magnet.cc +++ b/src/magnet.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -47,7 +47,7 @@ BDE parse(const std::string& magnet) } std::deque<std::string> queries; util::split(std::string(magnet.begin()+8, magnet.end()), - std::back_inserter(queries), "&"); + std::back_inserter(queries), "&"); BDE dict = BDE::dict(); for(std::deque<std::string>::const_iterator i = queries.begin(); i != queries.end(); ++i) { diff --git a/src/magnet.h b/src/magnet.h index 06468bfc..4cf5d5e2 100644 --- a/src/magnet.h +++ b/src/magnet.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/main.cc b/src/main.cc index bdae9088..d7078974 100644 --- a/src/main.cc +++ b/src/main.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -143,18 +143,18 @@ static void showFiles try { #ifdef ENABLE_BITTORRENT if(dt.guessTorrentFile(*i)) { - showTorrentFile(*i); + showTorrentFile(*i); } else #endif // ENABLE_BITTORRENT #ifdef ENABLE_METALINK - if(dt.guessMetalinkFile(*i)) { - showMetalinkFile(*i, op); - } else + if(dt.guessMetalinkFile(*i)) { + showMetalinkFile(*i, op); + } else #endif // ENABLE_METALINK - { - printf(MSG_NOT_TORRENT_METALINK); - printf("\n\n"); - } + { + printf(MSG_NOT_TORRENT_METALINK); + printf("\n\n"); + } } catch(RecoverableException& e) { std::cout << e.stackTrace() << std::endl; } @@ -163,7 +163,7 @@ static void showFiles #endif // ENABLE_BITTORRENT || ENABLE_METALINK extern void option_processing(Option& option, std::deque<std::string>& uris, - int argc, char* const argv[]); + int argc, char* const argv[]); downloadresultcode::RESULT main(int argc, char* argv[]) { @@ -232,35 +232,35 @@ downloadresultcode::RESULT main(int argc, char* argv[]) #ifdef ENABLE_BITTORRENT if(!op->blank(PREF_TORRENT_FILE)) { if(op->get(PREF_SHOW_FILES) == V_TRUE) { - showTorrentFile(op->get(PREF_TORRENT_FILE)); - return exitStatus; + showTorrentFile(op->get(PREF_TORRENT_FILE)); + return exitStatus; } else { - createRequestGroupForBitTorrent(requestGroups, op, args); + createRequestGroupForBitTorrent(requestGroups, op, args); } } else #endif // ENABLE_BITTORRENT #ifdef ENABLE_METALINK if(!op->blank(PREF_METALINK_FILE)) { - if(op->get(PREF_SHOW_FILES) == V_TRUE) { - showMetalinkFile(op->get(PREF_METALINK_FILE), op); - return exitStatus; - } else { - createRequestGroupForMetalink(requestGroups, op); - } + if(op->get(PREF_SHOW_FILES) == V_TRUE) { + showMetalinkFile(op->get(PREF_METALINK_FILE), op); + return exitStatus; + } else { + createRequestGroupForMetalink(requestGroups, op); + } } else #endif // ENABLE_METALINK - if(!op->blank(PREF_INPUT_FILE)) { - createRequestGroupForUriList(requestGroups, op); + if(!op->blank(PREF_INPUT_FILE)) { + createRequestGroupForUriList(requestGroups, op); #if defined ENABLE_BITTORRENT || defined ENABLE_METALINK - } else if(op->get(PREF_SHOW_FILES) == V_TRUE) { - showFiles(args, op); - return exitStatus; + } else if(op->get(PREF_SHOW_FILES) == V_TRUE) { + showFiles(args, op); + return exitStatus; #endif // ENABLE_METALINK || ENABLE_METALINK - } else { - createRequestGroupForUri(requestGroups, op, args); - } + } else { + createRequestGroupForUri(requestGroups, op, args); + } // Remove option values which is only valid for URIs specified in // command-line. If they are left, because op is used as a @@ -279,7 +279,7 @@ downloadresultcode::RESULT main(int argc, char* argv[]) std::cout << MSG_NO_FILES_TO_DOWNLOAD << std::endl; } else { exitStatus = MultiUrlRequestInfo(requestGroups, op, getStatCalc(op), - getSummaryOut(op)).execute(); + getSummaryOut(op)).execute(); } } catch(Exception& ex) { std::cerr << EX_EXCEPTION_CAUGHT << "\n" << ex.stackTrace() << std::endl; diff --git a/src/message.h b/src/message.h index c98cb115..930e4139 100644 --- a/src/message.h +++ b/src/message.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -89,7 +89,7 @@ #define MSG_TRACKER_REQUEST_CREATION_FAILED _("CUID#%d - Cannot create tracker request.") #define MSG_CREATING_TRACKER_REQUEST _("CUID#%d - Creating new tracker request command #%d") #define MSG_DHT_ENABLED_PEER _("CUID#%d - The peer is DHT-enabled.") -#define MSG_CONNECT_FAILED_AND_RETRY "CUID#%d - Could not to connect to %s:%u."\ +#define MSG_CONNECT_FAILED_AND_RETRY "CUID#%d - Could not to connect to %s:%u." \ " Trying another address" #define MSG_UNRECOGNIZED_URI _("Unrecognized URI or unsupported protocol: %s") @@ -141,45 +141,45 @@ #define MSG_NULL_TRACKER_RESPONSE _("Tracker returned null data.") #define MSG_WINSOCK_INIT_FAILD _("Windows socket library initialization failed") #define MSG_TIME_HAS_PASSED _("%d second(s) has passed. Stopping application.") -#define MSG_SIGNATURE_SAVED _("Saved signature as %s. Please note that aria2"\ - " doesn't verify signatures.") -#define MSG_SIGNATURE_NOT_SAVED _("Saving signature as %s failed. Maybe file"\ - " already exists.") -#define MSG_OPENING_READABLE_SERVER_STAT_FILE_FAILED \ +#define MSG_SIGNATURE_SAVED _("Saved signature as %s. Please note that aria2" \ + " doesn't verify signatures.") +#define MSG_SIGNATURE_NOT_SAVED _("Saving signature as %s failed. Maybe file" \ + " already exists.") +#define MSG_OPENING_READABLE_SERVER_STAT_FILE_FAILED \ _("Failed to open ServerStat file %s for read.") #define MSG_SERVER_STAT_LOADED _("ServerStat file %s loaded successfully.") #define MSG_READING_SERVER_STAT_FILE_FAILED _("Failed to read ServerStat from" \ - " %s.") -#define MSG_OPENING_WRITABLE_SERVER_STAT_FILE_FAILED \ + " %s.") +#define MSG_OPENING_WRITABLE_SERVER_STAT_FILE_FAILED \ _("Failed to open ServerStat file %s for write.") #define MSG_SERVER_STAT_SAVED _("ServerStat file %s saved successfully.") -#define MSG_WRITING_SERVER_STAT_FILE_FAILED _("Failed to write ServerStat to"\ - " %s.") -#define MSG_ESTABLISHING_CONNECTION_FAILED \ +#define MSG_WRITING_SERVER_STAT_FILE_FAILED _("Failed to write ServerStat to" \ + " %s.") +#define MSG_ESTABLISHING_CONNECTION_FAILED \ _("Failed to establish connection, cause: %s") #define MSG_NETWORK_PROBLEM _("Network problem has occurred. cause:%s") -#define MSG_LOADING_TRUSTED_CA_CERT_FAILED \ +#define MSG_LOADING_TRUSTED_CA_CERT_FAILED \ _("Failed to load trusted CA certificates from %s. Cause: %s") -#define MSG_CERT_VERIFICATION_FAILED \ +#define MSG_CERT_VERIFICATION_FAILED \ _("Certificate verification failed. Cause: %s") #define MSG_NO_CERT_FOUND _("No certificate found.") #define MSG_HOSTNAME_NOT_MATCH _("Hostname not match.") #define MSG_NO_FILES_TO_DOWNLOAD _("No files to download.") -#define MSG_WARN_NO_CA_CERT \ - _("You may encounter the certificate verification error with HTTPS server."\ +#define MSG_WARN_NO_CA_CERT \ + _("You may encounter the certificate verification error with HTTPS server." \ " See --ca-certificate and --check-certificate option.") #define MSG_SHOW_FILES _("Printing the contents of file '%s'...") -#define MSG_NOT_TORRENT_METALINK _("This file is neither Torrent nor Metalink"\ - " file. Skipping.") +#define MSG_NOT_TORRENT_METALINK _("This file is neither Torrent nor Metalink" \ + " file. Skipping.") #define MSG_GID_NOT_PROVIDED "GID is not provided." #define MSG_CANNOT_PARSE_XML_RPC_REQUEST "Failed to parse xml-rpc request." #define MSG_GOOD_BYE_SEEDER "Client is in seed state: Good Bye Seeder;)" #define MSG_NOT_FILE _("Is '%s' a file?") -#define MSG_INTERFACE_NOT_FOUND _("Failed to find given interface %s,"\ - " cause: %s") +#define MSG_INTERFACE_NOT_FOUND _("Failed to find given interface %s," \ + " cause: %s") #define MSG_METADATA_SAVED _("Saved metadata as %s.") -#define MSG_METADATA_NOT_SAVED _("Saving metadata as %s failed. Maybe file"\ - " already exists.") +#define MSG_METADATA_NOT_SAVED _("Saving metadata as %s failed. Maybe file" \ + " already exists.") #define EX_TIME_OUT _("Timeout.") #define EX_INVALID_CHUNK_SIZE _("Invalid chunk size.") diff --git a/src/messageDigest.cc b/src/messageDigest.cc index 06e79704..4cc86732 100644 --- a/src/messageDigest.cc +++ b/src/messageDigest.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -59,7 +59,7 @@ static MessageDigestContext::DigestAlgoMap::value_type digests[] = { MessageDigestContext::DigestAlgoMap MessageDigestContext::digestAlgos(&digests[0], - &digests[sizeof(digests)/sizeof(DigestAlgoMap::value_type)]); + &digests[sizeof(digests)/sizeof(DigestAlgoMap::value_type)]); std::string MessageDigestContext::digestFinal() { diff --git a/src/messageDigest.h b/src/messageDigest.h index a529797e..3ff6ca69 100644 --- a/src/messageDigest.h +++ b/src/messageDigest.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -108,8 +108,8 @@ public: DigestAlgoMap::const_iterator itr = digestAlgos.find(algostring); if(itr == digestAlgos.end()) { throw DL_ABORT_EX - (StringFormat("Digest algorithm %s is not supported.", - algostring.c_str()).str()); + (StringFormat("Digest algorithm %s is not supported.", + algostring.c_str()).str()); } return (*itr).second; } diff --git a/src/option_processing.cc b/src/option_processing.cc index 847b4f55..51021605 100644 --- a/src/option_processing.cc +++ b/src/option_processing.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -66,8 +66,8 @@ extern void showVersion(); extern void showUsage(const std::string& keyword, const OptionParser& oparser); static void overrideWithEnv(Option& op, const OptionParser& optionParser, - const std::string& pref, - const std::string& envName) + const std::string& pref, + const std::string& envName) { char* value = getenv(envName.c_str()); if(value) { @@ -75,15 +75,15 @@ static void overrideWithEnv(Option& op, const OptionParser& optionParser, optionParser.findByName(pref)->parse(op, value); } catch(Exception& e) { std::cerr << "Caught Error while parsing environment variable" - << " '" << envName << "'" - << "\n" - << e.stackTrace(); + << " '" << envName << "'" + << "\n" + << e.stackTrace(); } } } void option_processing(Option& op, std::deque<std::string>& uris, - int argc, char* const argv[]) + int argc, char* const argv[]) { OptionParser oparser; oparser.setOptionHandlers(OptionHandlerFactory::createOptionHandlers()); @@ -100,25 +100,25 @@ void option_processing(Option& op, std::deque<std::string>& uris, ucfname = op.get(PREF_CONF_PATH); if(op.defined("version")) { - showVersion(); - exit(downloadresultcode::FINISHED); + showVersion(); + exit(downloadresultcode::FINISHED); } if(op.defined("help")) { - std::string keyword; - if(op.get("help").empty()) { - keyword = TAG_BASIC; - } else { - keyword = op.get("help"); - if(util::startsWith(keyword, "--")) { - keyword = keyword.substr(2); - } - std::string::size_type eqpos = keyword.find("="); - if(eqpos != std::string::npos) { - keyword = keyword.substr(0, eqpos); - } - } - showUsage(keyword, oparser); - exit(downloadresultcode::FINISHED); + std::string keyword; + if(op.get("help").empty()) { + keyword = TAG_BASIC; + } else { + keyword = op.get("help"); + if(util::startsWith(keyword, "--")) { + keyword = keyword.substr(2); + } + std::string::size_type eqpos = keyword.find("="); + if(eqpos != std::string::npos) { + keyword = keyword.substr(0, eqpos); + } + } + showUsage(keyword, oparser); + exit(downloadresultcode::FINISHED); } } @@ -126,32 +126,32 @@ void option_processing(Option& op, std::deque<std::string>& uris, if(!noConf) { std::string cfname = - ucfname.empty() ? - oparser.findByName(PREF_CONF_PATH)->getDefaultValue(): - ucfname; + ucfname.empty() ? + oparser.findByName(PREF_CONF_PATH)->getDefaultValue(): + ucfname; if(File(cfname).isFile()) { - std::ifstream cfstream(cfname.c_str(), std::ios::binary); - try { - oparser.parse(op, cfstream); - } catch(OptionHandlerException& e) { - std::cerr << "Parse error in " << cfname << "\n" - << e.stackTrace() << "\n" - << "Usage:" << "\n" - << oparser.findByName(e.getOptionName())->getDescription() - << std::endl; - exit(downloadresultcode::UNKNOWN_ERROR); - } catch(Exception& e) { - std::cerr << "Parse error in " << cfname << "\n" - << e.stackTrace() << std::endl; - exit(downloadresultcode::UNKNOWN_ERROR); - } + std::ifstream cfstream(cfname.c_str(), std::ios::binary); + try { + oparser.parse(op, cfstream); + } catch(OptionHandlerException& e) { + std::cerr << "Parse error in " << cfname << "\n" + << e.stackTrace() << "\n" + << "Usage:" << "\n" + << oparser.findByName(e.getOptionName())->getDescription() + << std::endl; + exit(downloadresultcode::UNKNOWN_ERROR); + } catch(Exception& e) { + std::cerr << "Parse error in " << cfname << "\n" + << e.stackTrace() << std::endl; + exit(downloadresultcode::UNKNOWN_ERROR); + } } else if(!ucfname.empty()) { - std::cerr << StringFormat("Configuration file %s is not found.", - cfname.c_str()) - << "\n"; - showUsage(TAG_HELP, oparser); - exit(downloadresultcode::UNKNOWN_ERROR); + std::cerr << StringFormat("Configuration file %s is not found.", + cfname.c_str()) + << "\n"; + showUsage(TAG_HELP, oparser); + exit(downloadresultcode::UNKNOWN_ERROR); } } // Override configuration with environment variables. @@ -168,9 +168,9 @@ void option_processing(Option& op, std::deque<std::string>& uris, oparser.parse(op, cmdstream); } catch(OptionHandlerException& e) { std::cerr << e.stackTrace() << "\n" - << "Usage:" << "\n" - << oparser.findByName(e.getOptionName()) - << std::endl; + << "Usage:" << "\n" + << oparser.findByName(e.getOptionName()) + << std::endl; exit(downloadresultcode::UNKNOWN_ERROR); } catch(Exception& e) { std::cerr << e.stackTrace() << std::endl; diff --git a/src/prefs.cc b/src/prefs.cc index 46bf3b40..93b8c4be 100644 --- a/src/prefs.cc +++ b/src/prefs.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/prefs.h b/src/prefs.h index 6d1b4d39..27276463 100644 --- a/src/prefs.h +++ b/src/prefs.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/right.txt b/src/right.txt index a25df173..a88ed330 100644 --- a/src/right.txt +++ b/src/right.txt @@ -1,7 +1,7 @@ /* * aria2 - The high speed download utility * - * Copyright (C) 2006 Tatsuhiro Tsujikawa + * Copyright (C) 2010 Tatsuhiro Tsujikawa * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/strptime.h b/src/strptime.h index 59f39a01..a39b9e05 100644 --- a/src/strptime.h +++ b/src/strptime.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/timegm.h b/src/timegm.h index 1c0ecd35..6a78bcf4 100644 --- a/src/timegm.h +++ b/src/timegm.h @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/src/usage_text.h b/src/usage_text.h index 8babd046..8fbc5067 100644 --- a/src/usage_text.h +++ b/src/usage_text.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -33,559 +33,559 @@ */ /* copyright --> */ -#define TEXT_DIR \ -_(" -d, --dir=DIR The directory to store the downloaded file.") -#define TEXT_OUT \ -_(" -o, --out=FILE The file name of the downloaded file.") -#define TEXT_LOG \ -_(" -l, --log=LOG The file name of the log file. If '-' is\n"\ - " specified, log is written to stdout.") -#define TEXT_DAEMON \ -_(" -D, --daemon Run as daemon. The current working directory will\n"\ - " be changed to \"/\" and standard input, standard\n"\ - " output and standard error will be redirected to\n"\ - " \"/dev/null\".") -#define TEXT_SPLIT \ -_(" -s, --split=N Download a file using N connections. If more\n"\ - " than N URLs are given, first N URLs are used and\n"\ - " remaining URLs are used for backup. If less than\n"\ - " N URLs are given, those URLs are used more than\n"\ - " once so that N connections total are made\n"\ - " simultaneously. Please see -j option too.\n"\ - " Please note that in Metalink download, this\n"\ - " option has no effect and use -C option instead.") -#define TEXT_RETRY_WAIT \ -_(" --retry-wait=SEC Set the seconds to wait to retry after an error\n"\ - " has occured.") -#define TEXT_TIMEOUT \ -_(" -t, --timeout=SEC Set timeout in seconds.") -#define TEXT_MAX_TRIES \ -_(" -m, --max-tries=N Set number of tries. 0 means unlimited.") -#define TEXT_HTTP_PROXY \ -_(" --http-proxy=PROXY Use this proxy server for HTTP.\n"\ - " See also --all-proxy option.\n"\ - " This affects all URLs.") -#define TEXT_HTTPS_PROXY \ -_(" --https-proxy=PROXY Use this proxy server for HTTPS.\n"\ - " See also --all-proxy option.\n"\ - " This affects all URLs.") -#define TEXT_FTP_PROXY \ -_(" --ftp-proxy=PROXY Use this proxy server for FTP.\n"\ - " See also --all-proxy option.\n"\ - " This affects all URLs.") -#define TEXT_ALL_PROXY \ -_(" --all-proxy=PROXY Use this proxy server for all protocols.\n"\ - " You can override this setting and specify a\n"\ - " proxy server for a particular protocol using\n"\ - " --http-proxy, --https-proxy and --ftp-proxy\n"\ - " options.\n"\ - " This affects all URLs.") -#define TEXT_HTTP_USER \ -_(" --http-user=USER Set HTTP user. This affects all URLs.") -#define TEXT_HTTP_PASSWD \ -_(" --http-passwd=PASSWD Set HTTP password. This affects all URLs.") -#define TEXT_PROXY_METHOD \ -_(" --proxy-method=METHOD Set the method to use in proxy request.") -#define TEXT_REFERER \ -_(" --referer=REFERER Set Referer. This affects all URLs.") -#define TEXT_FTP_USER \ -_(" --ftp-user=USER Set FTP user. This affects all URLs.") -#define TEXT_FTP_PASSWD \ -_(" --ftp-passwd=PASSWD Set FTP password. This affects all URLs.") -#define TEXT_FTP_TYPE \ -_(" --ftp-type=TYPE Set FTP transfer type.") -#define TEXT_FTP_PASV \ -_(" -p, --ftp-pasv[=true|false] Use the passive mode in FTP. If false is given,\n"\ - " the active mode will be used.") -#define TEXT_LOWEST_SPEED_LIMIT \ -_(" --lowest-speed-limit=SPEED Close connection if download speed is lower than\n"\ - " or equal to this value(bytes per sec).\n"\ - " 0 means aria2 does not have a lowest speed limit.\n"\ - " You can append K or M(1K = 1024, 1M = 1024K).\n"\ - " This option does not affect BitTorrent downloads.") -#define TEXT_MAX_OVERALL_DOWNLOAD_LIMIT \ -_(" --max-overall-download-limit=SPEED Set max overall download speed in bytes/sec.\n"\ - " 0 means unrestricted.\n"\ - " You can append K or M(1K = 1024, 1M = 1024K).\n"\ - " To limit the download speed per download, use\n"\ - " --max-download-limit option.") -#define TEXT_MAX_DOWNLOAD_LIMIT \ -_(" --max-download-limit=SPEED Set max download speed per each download in\n"\ - " bytes/sec. 0 means unrestricted.\n"\ - " You can append K or M(1K = 1024, 1M = 1024K).\n"\ - " To limit the overall download speed, use\n"\ - " --max-overall-download-limit option.") -#define TEXT_FILE_ALLOCATION \ -_(" --file-allocation=METHOD Specify file allocation method.\n"\ - " 'none' doesn't pre-allocate file space. 'prealloc'\n"\ - " pre-allocates file space before download begins.\n"\ - " This may take some time depending on the size of\n"\ - " the file.\n"\ - " If you are using newer file systems such as ext4\n"\ - " (with extents support), btrfs or xfs, 'falloc' is\n"\ - " your best choice. It allocates large(few GiB)\n"\ - " files almost instantly. Don't use 'falloc' with\n"\ - " legacy file systems such as ext3 because it takes\n"\ - " almost same time as 'prealloc' and it blocks aria2\n"\ - " entirely until allocation finishes. 'falloc' may\n"\ - " not be available if your system doesn't have\n"\ - " posix_fallocate() function.") -#define TEXT_NO_FILE_ALLOCATION_LIMIT \ -_(" --no-file-allocation-limit=SIZE No file allocation is made for files whose\n"\ - " size is smaller than SIZE.\n"\ - " You can append K or M(1K = 1024, 1M = 1024K).") -# define TEXT_ENABLE_DIRECT_IO \ -_(" --enable-direct-io[=true|false] Enable directI/O, which lowers cpu usage while\n"\ - " allocating files.\n"\ - " Turn off if you encounter any error") -#define TEXT_ALLOW_OVERWRITE \ -_(" --allow-overwrite=true|false If false is given, and a file already exists but\n"\ - " the corresponding control file (filename.aria2)\n"\ - " doesn't exist, then aria2 will not re-download\n"\ - " the file. See also --auto-file-renaming option.") -#define TEXT_ALLOW_PIECE_LENGTH_CHANGE \ -_(" --allow-piece-length-change=true|false If false is given, aria2 aborts download\n"\ - " when a piece length is different from one in\n"\ - " a control file. If true is given, you can proceed\n"\ - " but some download progress will be lost.") -#define TEXT_FORCE_SEQUENTIAL \ -_(" -Z, --force-sequential[=true|false] Fetch URIs in the command-line sequentially\n"\ - " and download each URI in a separate session, like\n"\ - " the usual command-line download utilities.") -#define TEXT_AUTO_FILE_RENAMING \ -_(" --auto-file-renaming[=true|false] Rename file name if the same file already\n"\ - " exists. This option works only in http(s)/ftp\n"\ - " download.\n"\ - " The new file name has a dot and a number(1..9999)\n"\ - " appended.") -#define TEXT_PARAMETERIZED_URI \ -_(" -P, --parameterized-uri[=true|false] Enable parameterized URI support.\n"\ - " You can specify set of parts:\n"\ - " http://{sv1,sv2,sv3}/foo.iso\n"\ - " Also you can specify numeric sequences with step\n"\ - " counter:\n"\ - " http://host/image[000-100:2].img\n"\ - " A step counter can be omitted.\n"\ - " If all URIs do not point to the same file, such\n"\ - " as the second example above, -Z option is\n"\ - " required.") -#define TEXT_ENABLE_HTTP_KEEP_ALIVE \ -_(" --enable-http-keep-alive[=true|false] Enable HTTP/1.1 persistent connection.") -#define TEXT_ENABLE_HTTP_PIPELINING \ -_(" --enable-http-pipelining[=true|false] Enable HTTP/1.1 pipelining.") -#define TEXT_CHECK_INTEGRITY \ -_(" -V, --check-integrity[=true|false] Check file integrity by validating piece\n"\ - " hashes. This option has effect only in BitTorrent\n"\ - " and Metalink downloads with chunk checksums.\n"\ - " Use this option to re-download a damaged portion\n"\ - " of a file. See also --bt-hash-check-seed option.") -#define TEXT_BT_HASH_CHECK_SEED \ -_(" --bt-hash-check-seed[=true|false] If true is given, after hash check using\n"\ - " --check-integrity option and file is complete,\n"\ - " continue to seed file. If you want to check file\n"\ - " and download it only when it is damaged or\n"\ - " incomplete, set this option to false.\n"\ - " This option has effect only on BitTorrent\n"\ - " download.") -#define TEXT_REALTIME_CHUNK_CHECKSUM \ -_(" --realtime-chunk-checksum=true|false Validate chunk of data by calculating\n"\ - " checksum while downloading a file if chunk\n"\ - " checksums are provided.") -#define TEXT_CONTINUE \ -_(" -c, --continue Continue downloading a partially downloaded\n"\ - " file. Use this option to resume a download\n"\ - " started by a web browser or another program\n"\ - " which downloads files sequentially from the\n"\ - " beginning. Currently this option is only\n"\ - " applicable to http(s)/ftp downloads.") -#define TEXT_USER_AGENT \ -_(" -U, --user-agent=USER_AGENT Set user agent for http(s) downloads.") -#define TEXT_NO_NETRC \ -_(" -n, --no-netrc Disables netrc support.") -#define TEXT_INPUT_FILE \ -_(" -i, --input-file=FILE Downloads URIs found in FILE. You can specify\n"\ - " multiple URIs for a single entity: separate\n"\ - " URIs on a single line using the TAB character.\n"\ - " Reads input from stdin when '-' is specified.\n"\ - " The additional out and dir options can be\n"\ - " specified after each line of URIs. This optional\n"\ - " line must start with white space(s). See INPUT\n"\ - " FILE section of man page for details.") -#define TEXT_MAX_CONCURRENT_DOWNLOADS \ -_(" -j, --max-concurrent-downloads=N Set maximum number of parallel downloads for\n"\ - " every static (HTTP/FTP) URL, torrent and metalink.\n"\ - " See also -s and -C options.") -#define TEXT_LOAD_COOKIES \ -_(" --load-cookies=FILE Load Cookies from FILE using the Firefox3 format\n"\ - " and Mozilla/Firefox(1.x/2.x)/Netscape format.") -#define TEXT_SAVE_COOKIES \ -_(" --save-cookies=FILE Save Cookies to FILE in Mozilla/Firefox(1.x/2.x)/\n"\ - " Netscape format. If FILE already exists, it is\n"\ - " overwritten. Session Cookies are also saved and\n"\ - " their expiry values are treated as 0.") -#define TEXT_SHOW_FILES \ -_(" -S, --show-files Print file listing of .torrent or .metalink file\n"\ - " and exit. More detailed information will be listed\n"\ - " in case of torrent file.") -#define TEXT_SELECT_FILE \ -_(" --select-file=INDEX... Set file to download by specifying its index.\n"\ - " You can find the file index using the\n"\ - " --show-files option. Multiple indexes can be\n"\ - " specified by using ',', for example: \"3,6\".\n"\ - " You can also use '-' to specify a range: \"1-5\".\n"\ - " ',' and '-' can be used together.\n"\ - " When used with the -M option, index may vary\n"\ - " depending on the query(see --metalink-* options).") -#define TEXT_TORRENT_FILE \ -_(" -T, --torrent-file=TORRENT_FILE The path to the .torrent file.") -#define TEXT_FOLLOW_TORRENT \ -_(" --follow-torrent=true|false|mem If true or mem is specified, when a file\n"\ - " whose suffix is .torrent or content type is\n"\ - " application/x-bittorrent is downloaded, aria2\n"\ - " parses it as a torrent file and downloads files\n"\ - " mentioned in it.\n"\ - " If mem is specified, a torrent file is not\n"\ - " written to the disk, but is just kept in memory.\n"\ - " If false is specified, the action mentioned above\n"\ - " is not taken.") -#define TEXT_DIRECT_FILE_MAPPING \ -_(" --direct-file-mapping=true|false Directly read from and write to each file\n"\ - " mentioned in .torrent file.") -#define TEXT_LISTEN_PORT \ -_(" --listen-port=PORT... Set TCP port number for BitTorrent downloads.\n"\ - " Multiple ports can be specified by using ',',\n"\ - " for example: \"6881,6885\". You can also use '-'\n"\ - " to specify a range: \"6881-6999\". ',' and '-' can\n"\ - " be used together.") -#define TEXT_MAX_OVERALL_UPLOAD_LIMIT \ -_(" --max-overall-upload-limit=SPEED Set max overall upload speed in bytes/sec.\n"\ - " 0 means unrestricted.\n"\ - " You can append K or M(1K = 1024, 1M = 1024K).\n"\ - " To limit the upload speed per torrent, use\n"\ - " --max-upload-limit option.") -#define TEXT_MAX_UPLOAD_LIMIT \ -_(" -u, --max-upload-limit=SPEED Set max upload speed per each torrent in\n"\ - " bytes/sec. 0 means unrestricted.\n"\ - " You can append K or M(1K = 1024, 1M = 1024K).\n"\ - " To limit the overall upload speed, use\n"\ - " --max-overall-upload-limit option.") -#define TEXT_SEED_TIME \ -_(" --seed-time=MINUTES Specify seeding time in minutes. Also see the\n"\ - " --seed-ratio option.") -#define TEXT_SEED_RATIO \ -_(" --seed-ratio=RATIO Specify share ratio. Seed completed torrents\n"\ - " until share ratio reaches RATIO.\n"\ - " You are strongly encouraged to specify equals or\n"\ - " more than 1.0 here. Specify 0.0 if you intend to\n"\ - " do seeding regardless of share ratio.\n" \ - " If --seed-time option is specified along with\n"\ - " this option, seeding ends when at least one of\n"\ - " the conditions is satisfied.") -#define TEXT_PEER_ID_PREFIX \ -_(" --peer-id-prefix=PEER_ID_PREFIX Specify the prefix of peer ID. The peer ID in\n"\ - " BitTorrent is 20 byte length. If more than 20\n"\ - " bytes are specified, only first 20 bytes are\n"\ - " used. If less than 20 bytes are specified, random\n"\ - " byte data are added to make its length 20 bytes.") -#define TEXT_ENABLE_PEER_EXCHANGE \ -_(" --enable-peer-exchange[=true|false] Enable Peer Exchange extension.") -#define TEXT_ENABLE_DHT \ -_(" --enable-dht[=true|false] Enable DHT functionality.") -#define TEXT_DHT_LISTEN_PORT \ -_(" --dht-listen-port=PORT... Set UDP listening port for DHT.\n"\ - " Multiple ports can be specified by using ',',\n"\ - " for example: \"6881,6885\". You can also use '-'\n"\ - " to specify a range: \"6881-6999\". ',' and '-' can\n"\ - " be used together.") -#define TEXT_DHT_ENTRY_POINT \ -_(" --dht-entry-point=HOST:PORT Set host and port as an entry point to DHT\n"\ - " network.") -#define TEXT_DHT_FILE_PATH \ -_(" --dht-file-path=PATH Change the DHT routing table file to PATH.") -#define TEXT_BT_MIN_CRYPTO_LEVEL \ -_(" --bt-min-crypto-level=plain|arc4 Set minimum level of encryption method.\n"\ - " If several encryption methods are provided by a\n"\ - " peer, aria2 chooses the lowest one which satisfies\n"\ - " the given level.") -#define TEXT_BT_REQUIRE_CRYPTO \ -_(" --bt-require-crypto=true|false If true is given, aria2 doesn't accept and\n"\ - " establish connection with legacy BitTorrent\n"\ - " handshake. Thus aria2 always uses Obfuscation\n"\ - " handshake.") -#define TEXT_BT_REQUEST_PEER_SPEED_LIMIT \ -_(" --bt-request-peer-speed-limit=SPEED If the whole download speed of every\n"\ - " torrent is lower than SPEED, aria2 temporarily\n"\ - " increases the number of peers to try for more\n"\ - " download speed. Configuring this option with your\n"\ - " preferred download speed can increase your\n"\ - " download speed in some cases.\n"\ - " You can append K or M(1K = 1024, 1M = 1024K).") -#define TEXT_BT_MAX_OPEN_FILES \ -_(" --bt-max-open-files=NUM Specify maximum number of files to open in each\n"\ - " BitTorrent download.") -#define TEXT_BT_SEED_UNVERIFIED \ -_(" --bt-seed-unverified[=true|false] Seed previously downloaded files without\n"\ - " verifying piece hashes.") -#define TEXT_BT_MAX_PEERS \ -_(" --bt-max-peers=NUM Specify the maximum number of peers per torrent.\n"\ - " 0 means unlimited.\n"\ - " See also --bt-request-peer-speed-limit option.") -#define TEXT_METALINK_FILE \ -_(" -M, --metalink-file=METALINK_FILE The file path to the .metalink file. Reads\n"\ - " input from stdin when '-' is specified.") -#define TEXT_METALINK_SERVERS \ -_(" -C, --metalink-servers=NUM_SERVERS The number of servers to connect to\n"\ - " simultaneously. Some Metalinks regulate the\n"\ - " number of servers to connect. aria2 strictly\n"\ - " respects them. This means that if Metalink defines\n"\ - " the maxconnections attribute lower than\n"\ - " NUM_SERVERS, then aria2 uses the value of\n"\ - " maxconnections attribute instead of NUM_SERVERS.\n"\ - " See also -s and -j options.") -#define TEXT_METALINK_VERSION \ -_(" --metalink-version=VERSION The version of the file to download.") -#define TEXT_METALINK_LANGUAGE \ -_(" --metalink-language=LANGUAGE The language of the file to download.") -#define TEXT_METALINK_OS \ -_(" --metalink-os=OS The operating system of the file to download.") -#define TEXT_METALINK_LOCATION \ -_(" --metalink-location=LOCATION[,...] The location of the preferred server.\n"\ - " A comma-delimited list of locations is\n"\ - " acceptable.") -#define TEXT_METALINK_PREFERRED_PROTOCOL \ -_(" --metalink-preferred-protocol=PROTO Specify preferred protocol. Specify 'none'\n"\ - " if you don't have any preferred protocol.") -#define TEXT_FOLLOW_METALINK \ -_(" --follow-metalink=true|false|mem If true or mem is specified, when a file\n"\ - " whose suffix is .metalink or content type of\n"\ - " application/metalink+xml is downloaded, aria2\n"\ - " parses it as a metalink file and downloads files\n"\ - " mentioned in it.\n"\ - " If mem is specified, a metalink file is not\n"\ - " written to the disk, but is just kept in memory.\n"\ - " If false is specified, the action mentioned above\n"\ - " is not taken.") -#define TEXT_METALINK_ENABLE_UNIQUE_PROTOCOL \ -_(" --metalink-enable-unique-protocol=true|false If true is given and several\n"\ - " protocols are available for a mirror in a metalink\n"\ - " file, aria2 uses one of them.\n"\ - " Use --metalink-preferred-protocol option to\n"\ - " specify the preference of protocol.") -#define TEXT_VERSION \ -_(" -v, --version Print the version number and exit.") -#define TEXT_HELP \ -_(" -h, --help[=TAG|KEYWORD] Print usage and exit.\n"\ - " The help messages are classified with tags. A tag\n"\ - " starts with \"#\". For example, type \"--help=#http\"\n"\ - " to get the usage for the options tagged with\n"\ - " \"#http\". If non-tag word is given, print the usage\n"\ - " for the options whose name includes that word.") -#define TEXT_NO_CONF \ -_(" --no-conf Disable loading aria2.conf file.") -#define TEXT_CONF_PATH \ -_(" --conf-path=PATH Change the configuration file path to PATH.") -#define TEXT_STOP \ -_(" --stop=SEC Stop application after SEC seconds has passed.\n" \ - " If 0 is given, this feature is disabled.") -#define TEXT_HEADER \ -_(" --header=HEADER Append HEADER to HTTP request header. You can use\n"\ - " this option repeatedly to specify more than one\n"\ - " header:\n"\ - " aria2c --header=\"X-A: b78\" --header=\"X-B: 9J1\"\n"\ - " http://host/file") -#define TEXT_QUIET \ -_(" -q, --quiet[=true|false] Make aria2 quiet(no console output).") -#define TEXT_ASYNC_DNS \ -_(" --async-dns[=true|false] Enable asynchronous DNS.") -#define TEXT_FTP_REUSE_CONNECTION \ -_(" --ftp-reuse-connection[=true|false] Reuse connection in FTP.") -#define TEXT_SUMMARY_INTERVAL \ -_(" --summary-interval=SEC Set interval to output download progress summary.\n"\ - " Setting 0 suppresses the output.") -#define TEXT_LOG_LEVEL \ -_(" --log-level=LEVEL Set log level to output.") -#define TEXT_REMOTE_TIME \ -_(" -R, --remote-time[=true|false] Retrieve timestamp of the remote file from the\n"\ - " remote HTTP/FTP server and if it is available,\n"\ - " apply it to the local file.") -#define TEXT_CONNECT_TIMEOUT \ -_(" --connect-timeout=SEC Set the connect timeout in seconds to establish\n"\ - " connection to HTTP/FTP/proxy server. After the\n"\ - " connection is established, this option makes no\n"\ - " effect and --timeout option is used instead.") -#define TEXT_MAX_FILE_NOT_FOUND \ -_(" --max-file-not-found=NUM If aria2 receives `file not found' status from the\n"\ - " remote HTTP/FTP servers NUM times without getting\n"\ - " a single byte, then force the download to fail.\n"\ - " Specify 0 to disable this option.\n"\ - " This options is effective only when using\n"\ - " HTTP/FTP servers.") -#define TEXT_URI_SELECTOR \ -_(" --uri-selector=SELECTOR Specify URI selection algorithm.\n"\ - " If 'inorder' is given, URI is tried in the order\n"\ - " appeared in the URI list.\n"\ - " If 'feedback' is given, aria2 uses download speed\n"\ - " observed in the previous downloads and choose\n"\ - " fastest server in the URI list. This also\n"\ - " effectively skips dead mirrors. The observed\n"\ - " download speed is a part of performance profile\n"\ - " of servers mentioned in --server-stat-of and\n"\ - " --server-stat-if options.\n"\ - " If 'adaptive' is given, selects one of the best\n"\ - " mirrors for the first and reserved connections.\n"\ - " For supplementary ones, it returns mirrors which\n" \ - " has not been tested yet, and if each of them has\n"\ - " already been tested, returns mirrors which has to\n"\ - " be tested again. Otherwise, it doesn't select\n"\ - " anymore mirrors. Like 'feedback', it uses a\n"\ - " performance profile of servers.") -#define TEXT_SERVER_STAT_OF \ -_(" --server-stat-of=FILE Specify the filename to which performance profile\n"\ - " of the servers is saved. You can load saved data\n"\ - " using --server-stat-if option.") -#define TEXT_SERVER_STAT_IF \ -_(" --server-stat-if=FILE Specify the filename to load performance profile\n"\ - " of the servers. The loaded data will be used in\n"\ - " some URI selector such as 'feedback'.\n"\ - " See also --uri-selector option") -#define TEXT_SERVER_STAT_TIMEOUT \ -_(" --server-stat-timeout=SEC Specifies timeout in seconds to invalidate\n"\ - " performance profile of the servers since the last\n"\ - " contact to them.") -#define TEXT_AUTO_SAVE_INTERVAL \ -_(" --auto-save-interval=SEC Save a control file(*.aria2) every SEC seconds.\n"\ - " If 0 is given, a control file is not saved during\n"\ - " download. aria2 saves a control file when it stops\n"\ - " regardless of the value.") -#define TEXT_CERTIFICATE \ -_(" --certificate=FILE Use the client certificate in FILE.\n"\ - " The certificate must be in PEM format.\n"\ - " You may use --private-key option to specify the\n"\ - " private key.") -#define TEXT_PRIVATE_KEY \ -_(" --private-key=FILE Use the private key in FILE.\n"\ - " The private key must be decrypted and in PEM\n"\ - " format. See also --certificate option.") -#define TEXT_CA_CERTIFICATE \ -_(" --ca-certificate=FILE Use the certificate authorities in FILE to verify\n"\ - " the peers. The certificate file must be in PEM\n"\ - " format and can contain multiple CA certificates.\n"\ - " Use --check-certificate option to enable\n"\ - " verification.") -#define TEXT_CHECK_CERTIFICATE \ -_(" --check-certificate[=true|false] Verify the peer using certificates specified\n"\ - " in --ca-certificate option.") -#define TEXT_NO_PROXY \ -_(" --no-proxy=DOMAINS Specify comma separated hostnames or domains where\n"\ - " proxy should not be used.") -#define TEXT_USE_HEAD \ -_(" --use-head[=true|false] Use HEAD method for the first request to the HTTP\n"\ - " server.") -#define TEXT_EVENT_POLL \ -_(" --event-poll=POLL Specify the method for polling events.") -#define TEXT_XML_RPC_LISTEN_PORT \ -_(" --xml-rpc-listen-port=PORT Specify a port number for XML-RPC server to listen\n"\ - " to.") -#define TEXT_ENABLE_XML_RPC \ -_(" --enable-xml-rpc[=true|false] Enable XML-RPC server.\n"\ - " It is strongly recommended to set username and\n"\ - " password using --xml-rpc-user and --xml-rpc-passwd\n"\ - " option. See also --xml-rpc-listen-port option.") -#define TEXT_XML_RPC_MAX_REQUEST_SIZE \ -_(" --xml-rpc-max-request-size=SIZE Set max size of XML-RPC request. If aria2\n"\ - " detects the request is more than SIZE bytes, it\n"\ - " drops connection.") -#define TEXT_XML_RPC_USER \ -_(" --xml-rpc-user=USER Set XML-RPC user.") -#define TEXT_XML_RPC_PASSWD \ -_(" --xml-rpc-passwd=PASSWD Set XML-RPC password.") -#define TEXT_BT_EXTERNAL_IP \ -_(" --bt-external-ip=IPADDRESS Specify the external IP address to report to a\n"\ - " BitTorrent tracker. Although this function is\n"\ - " named 'external', it can accept any kind of IP\n"\ - " addresses.") -#define TEXT_HTTP_AUTH_CHALLENGE \ -_(" --http-auth-challenge[=true|false] Send HTTP authorization header only when it\n"\ - " is requested by the server. If false is set, then\n"\ - " authorization header is always sent to the server.\n"\ - " There is an exception: if username and password\n"\ - " are embedded in URI, authorization header is\n"\ - " always sent to the server regardless of this\n"\ - " option.") -#define TEXT_INDEX_OUT \ -_(" -O, --index-out=INDEX=PATH Set file path for file with index=INDEX. You can\n"\ - " find the file index using the --show-files option.\n"\ - " PATH is a relative path to the path specified in\n"\ - " --dir option. You can use this option multiple\n"\ - " times.") -#define TEXT_DRY_RUN \ -_(" --dry-run[=true|false] If true is given, aria2 just checks whether the\n"\ - " remote file is available and doesn't download\n"\ - " data. This option has effect on HTTP/FTP download.\n"\ - " BitTorrent downloads are canceled if true is\n"\ - " specified.") -#define TEXT_BT_TRACKER_INTERVAL \ -_(" --bt-tracker-interval=SEC Set the interval in seconds between tracker\n"\ - " requests. This completely overrides interval value\n"\ - " and aria2 just uses this value and ignores the\n"\ - " min interval and interval value in the response of\n"\ - " tracker. If 0 is set, aria2 determines interval\n"\ - " based on the response of tracker and the download\n"\ - " progress.") -#define TEXT_ON_DOWNLOAD_COMPLETE \ -_(" --on-download-complete=COMMAND Set the command to be executed when download\n"\ - " completes.\n"\ - " See --on-download-start option for the\n"\ - " requirement of COMMAND.\n"\ - " See also --on-download-stop option.") -#define TEXT_ON_DOWNLOAD_START \ -_(" --on-download-start=COMMAND Set the command to be executed when download\n"\ - " starts up. COMMAND must take just one argument and\n"\ - " GID is passed to COMMAND as a first argument.") -#define TEXT_ON_DOWNLOAD_ERROR \ -_(" --on-download-error=COMMAND Set the command to be executed when download\n"\ - " aborts due to error.\n"\ - " See --on-download-start option for the\n"\ - " requirement of COMMAND.\n"\ - " See also --on-download-stop option.") -#define TEXT_ON_DOWNLOAD_STOP \ -_(" --on-download-stop=COMMAND Set the command to be executed when download\n"\ - " stops. You can override the command to be executed\n"\ - " for particular download result using\n"\ - " --on-download-complete and --on-download-error. If\n"\ - " they are specified, command specified in this\n"\ - " option is not executed.\n"\ - " See --on-download-start option for the\n"\ - " requirement of COMMAND.") -#define TEXT_BT_STOP_TIMEOUT \ -_(" --bt-stop-timeout=SEC Stop BitTorrent download if download speed is 0 in\n"\ - " consecutive SEC seconds. If 0 is given, this\n"\ - " feature is disabled.") -#define TEXT_XML_RPC_LISTEN_ALL \ -_(" --xml-rpc-listen-all[=true|false] Listen incoming XML-RPC requests on all\n"\ - " network interfaces. If false is given, listen only\n"\ - " on local loopback interface.") -#define TEXT_BT_PRIORITIZE_PIECE \ -_(" --bt-prioritize-piece=head[=SIZE],tail[=SIZE] Try to download first and last\n"\ - " pieces of each file first. This is useful for\n"\ - " previewing files. The argument can contain 2\n"\ - " keywords:head and tail. To include both keywords,\n"\ - " they must be separated by comma. These keywords\n"\ - " can take one parameter, SIZE. For example, if\n"\ - " head=SIZE is specified, pieces in the range of\n"\ - " first SIZE bytes of each file get higher priority.\n"\ - " tail=SIZE means the range of last SIZE bytes of\n"\ - " each file. SIZE can include K or M(1K = 1024, 1M =\n"\ - " 1024K). If SIZE is omitted, SIZE=1M is used.") -#define TEXT_INTERFACE \ -_(" --interface=INTERFACE Bind sockets to given interface. You can specify\n"\ - " interface name, IP address and hostname.") -#define TEXT_DISABLE_IPV6 \ -_(" --disable-ipv6[=true|false] Disable IPv6.") -#define TEXT_BT_SAVE_METADATA \ -_(" --bt-save-metadata[=true|false] Save metadata as .torrent file. This option has\n" \ - " effect only when BitTorrent Magnet URI is used.\n" \ - " The filename is hex encoded info hash with suffix\n" \ - " .torrent. The directory to be saved is the same\n" \ - " directory where download file is saved. If the\n" \ - " same file already exists, metadata is not saved.") +#define TEXT_DIR \ + _(" -d, --dir=DIR The directory to store the downloaded file.") +#define TEXT_OUT \ + _(" -o, --out=FILE The file name of the downloaded file.") +#define TEXT_LOG \ + _(" -l, --log=LOG The file name of the log file. If '-' is\n" \ + " specified, log is written to stdout.") +#define TEXT_DAEMON \ + _(" -D, --daemon Run as daemon. The current working directory will\n" \ + " be changed to \"/\" and standard input, standard\n" \ + " output and standard error will be redirected to\n" \ + " \"/dev/null\".") +#define TEXT_SPLIT \ + _(" -s, --split=N Download a file using N connections. If more\n" \ + " than N URLs are given, first N URLs are used and\n" \ + " remaining URLs are used for backup. If less than\n" \ + " N URLs are given, those URLs are used more than\n" \ + " once so that N connections total are made\n" \ + " simultaneously. Please see -j option too.\n" \ + " Please note that in Metalink download, this\n" \ + " option has no effect and use -C option instead.") +#define TEXT_RETRY_WAIT \ + _(" --retry-wait=SEC Set the seconds to wait to retry after an error\n" \ + " has occured.") +#define TEXT_TIMEOUT \ + _(" -t, --timeout=SEC Set timeout in seconds.") +#define TEXT_MAX_TRIES \ + _(" -m, --max-tries=N Set number of tries. 0 means unlimited.") +#define TEXT_HTTP_PROXY \ + _(" --http-proxy=PROXY Use this proxy server for HTTP.\n" \ + " See also --all-proxy option.\n" \ + " This affects all URLs.") +#define TEXT_HTTPS_PROXY \ + _(" --https-proxy=PROXY Use this proxy server for HTTPS.\n" \ + " See also --all-proxy option.\n" \ + " This affects all URLs.") +#define TEXT_FTP_PROXY \ + _(" --ftp-proxy=PROXY Use this proxy server for FTP.\n" \ + " See also --all-proxy option.\n" \ + " This affects all URLs.") +#define TEXT_ALL_PROXY \ + _(" --all-proxy=PROXY Use this proxy server for all protocols.\n" \ + " You can override this setting and specify a\n" \ + " proxy server for a particular protocol using\n" \ + " --http-proxy, --https-proxy and --ftp-proxy\n" \ + " options.\n" \ + " This affects all URLs.") +#define TEXT_HTTP_USER \ + _(" --http-user=USER Set HTTP user. This affects all URLs.") +#define TEXT_HTTP_PASSWD \ + _(" --http-passwd=PASSWD Set HTTP password. This affects all URLs.") +#define TEXT_PROXY_METHOD \ + _(" --proxy-method=METHOD Set the method to use in proxy request.") +#define TEXT_REFERER \ + _(" --referer=REFERER Set Referer. This affects all URLs.") +#define TEXT_FTP_USER \ + _(" --ftp-user=USER Set FTP user. This affects all URLs.") +#define TEXT_FTP_PASSWD \ + _(" --ftp-passwd=PASSWD Set FTP password. This affects all URLs.") +#define TEXT_FTP_TYPE \ + _(" --ftp-type=TYPE Set FTP transfer type.") +#define TEXT_FTP_PASV \ + _(" -p, --ftp-pasv[=true|false] Use the passive mode in FTP. If false is given,\n" \ + " the active mode will be used.") +#define TEXT_LOWEST_SPEED_LIMIT \ + _(" --lowest-speed-limit=SPEED Close connection if download speed is lower than\n" \ + " or equal to this value(bytes per sec).\n" \ + " 0 means aria2 does not have a lowest speed limit.\n" \ + " You can append K or M(1K = 1024, 1M = 1024K).\n" \ + " This option does not affect BitTorrent downloads.") +#define TEXT_MAX_OVERALL_DOWNLOAD_LIMIT \ + _(" --max-overall-download-limit=SPEED Set max overall download speed in bytes/sec.\n" \ + " 0 means unrestricted.\n" \ + " You can append K or M(1K = 1024, 1M = 1024K).\n" \ + " To limit the download speed per download, use\n" \ + " --max-download-limit option.") +#define TEXT_MAX_DOWNLOAD_LIMIT \ + _(" --max-download-limit=SPEED Set max download speed per each download in\n" \ + " bytes/sec. 0 means unrestricted.\n" \ + " You can append K or M(1K = 1024, 1M = 1024K).\n" \ + " To limit the overall download speed, use\n" \ + " --max-overall-download-limit option.") +#define TEXT_FILE_ALLOCATION \ + _(" --file-allocation=METHOD Specify file allocation method.\n" \ + " 'none' doesn't pre-allocate file space. 'prealloc'\n" \ + " pre-allocates file space before download begins.\n" \ + " This may take some time depending on the size of\n" \ + " the file.\n" \ + " If you are using newer file systems such as ext4\n" \ + " (with extents support), btrfs or xfs, 'falloc' is\n" \ + " your best choice. It allocates large(few GiB)\n" \ + " files almost instantly. Don't use 'falloc' with\n" \ + " legacy file systems such as ext3 because it takes\n" \ + " almost same time as 'prealloc' and it blocks aria2\n" \ + " entirely until allocation finishes. 'falloc' may\n" \ + " not be available if your system doesn't have\n" \ + " posix_fallocate() function.") +#define TEXT_NO_FILE_ALLOCATION_LIMIT \ + _(" --no-file-allocation-limit=SIZE No file allocation is made for files whose\n" \ + " size is smaller than SIZE.\n" \ + " You can append K or M(1K = 1024, 1M = 1024K).") +# define TEXT_ENABLE_DIRECT_IO \ + _(" --enable-direct-io[=true|false] Enable directI/O, which lowers cpu usage while\n" \ + " allocating files.\n" \ + " Turn off if you encounter any error") +#define TEXT_ALLOW_OVERWRITE \ + _(" --allow-overwrite=true|false If false is given, and a file already exists but\n" \ + " the corresponding control file (filename.aria2)\n" \ + " doesn't exist, then aria2 will not re-download\n" \ + " the file. See also --auto-file-renaming option.") +#define TEXT_ALLOW_PIECE_LENGTH_CHANGE \ + _(" --allow-piece-length-change=true|false If false is given, aria2 aborts download\n" \ + " when a piece length is different from one in\n" \ + " a control file. If true is given, you can proceed\n" \ + " but some download progress will be lost.") +#define TEXT_FORCE_SEQUENTIAL \ + _(" -Z, --force-sequential[=true|false] Fetch URIs in the command-line sequentially\n" \ + " and download each URI in a separate session, like\n" \ + " the usual command-line download utilities.") +#define TEXT_AUTO_FILE_RENAMING \ + _(" --auto-file-renaming[=true|false] Rename file name if the same file already\n" \ + " exists. This option works only in http(s)/ftp\n" \ + " download.\n" \ + " The new file name has a dot and a number(1..9999)\n" \ + " appended.") +#define TEXT_PARAMETERIZED_URI \ + _(" -P, --parameterized-uri[=true|false] Enable parameterized URI support.\n" \ + " You can specify set of parts:\n" \ + " http://{sv1,sv2,sv3}/foo.iso\n" \ + " Also you can specify numeric sequences with step\n" \ + " counter:\n" \ + " http://host/image[000-100:2].img\n" \ + " A step counter can be omitted.\n" \ + " If all URIs do not point to the same file, such\n" \ + " as the second example above, -Z option is\n" \ + " required.") +#define TEXT_ENABLE_HTTP_KEEP_ALIVE \ + _(" --enable-http-keep-alive[=true|false] Enable HTTP/1.1 persistent connection.") +#define TEXT_ENABLE_HTTP_PIPELINING \ + _(" --enable-http-pipelining[=true|false] Enable HTTP/1.1 pipelining.") +#define TEXT_CHECK_INTEGRITY \ + _(" -V, --check-integrity[=true|false] Check file integrity by validating piece\n" \ + " hashes. This option has effect only in BitTorrent\n" \ + " and Metalink downloads with chunk checksums.\n" \ + " Use this option to re-download a damaged portion\n" \ + " of a file. See also --bt-hash-check-seed option.") +#define TEXT_BT_HASH_CHECK_SEED \ + _(" --bt-hash-check-seed[=true|false] If true is given, after hash check using\n" \ + " --check-integrity option and file is complete,\n" \ + " continue to seed file. If you want to check file\n" \ + " and download it only when it is damaged or\n" \ + " incomplete, set this option to false.\n" \ + " This option has effect only on BitTorrent\n" \ + " download.") +#define TEXT_REALTIME_CHUNK_CHECKSUM \ + _(" --realtime-chunk-checksum=true|false Validate chunk of data by calculating\n" \ + " checksum while downloading a file if chunk\n" \ + " checksums are provided.") +#define TEXT_CONTINUE \ + _(" -c, --continue Continue downloading a partially downloaded\n" \ + " file. Use this option to resume a download\n" \ + " started by a web browser or another program\n" \ + " which downloads files sequentially from the\n" \ + " beginning. Currently this option is only\n" \ + " applicable to http(s)/ftp downloads.") +#define TEXT_USER_AGENT \ + _(" -U, --user-agent=USER_AGENT Set user agent for http(s) downloads.") +#define TEXT_NO_NETRC \ + _(" -n, --no-netrc Disables netrc support.") +#define TEXT_INPUT_FILE \ + _(" -i, --input-file=FILE Downloads URIs found in FILE. You can specify\n" \ + " multiple URIs for a single entity: separate\n" \ + " URIs on a single line using the TAB character.\n" \ + " Reads input from stdin when '-' is specified.\n" \ + " The additional out and dir options can be\n" \ + " specified after each line of URIs. This optional\n" \ + " line must start with white space(s). See INPUT\n" \ + " FILE section of man page for details.") +#define TEXT_MAX_CONCURRENT_DOWNLOADS \ + _(" -j, --max-concurrent-downloads=N Set maximum number of parallel downloads for\n" \ + " every static (HTTP/FTP) URL, torrent and metalink.\n" \ + " See also -s and -C options.") +#define TEXT_LOAD_COOKIES \ + _(" --load-cookies=FILE Load Cookies from FILE using the Firefox3 format\n" \ + " and Mozilla/Firefox(1.x/2.x)/Netscape format.") +#define TEXT_SAVE_COOKIES \ + _(" --save-cookies=FILE Save Cookies to FILE in Mozilla/Firefox(1.x/2.x)/\n" \ + " Netscape format. If FILE already exists, it is\n" \ + " overwritten. Session Cookies are also saved and\n" \ + " their expiry values are treated as 0.") +#define TEXT_SHOW_FILES \ + _(" -S, --show-files Print file listing of .torrent or .metalink file\n" \ + " and exit. More detailed information will be listed\n" \ + " in case of torrent file.") +#define TEXT_SELECT_FILE \ + _(" --select-file=INDEX... Set file to download by specifying its index.\n" \ + " You can find the file index using the\n" \ + " --show-files option. Multiple indexes can be\n" \ + " specified by using ',', for example: \"3,6\".\n" \ + " You can also use '-' to specify a range: \"1-5\".\n" \ + " ',' and '-' can be used together.\n" \ + " When used with the -M option, index may vary\n" \ + " depending on the query(see --metalink-* options).") +#define TEXT_TORRENT_FILE \ + _(" -T, --torrent-file=TORRENT_FILE The path to the .torrent file.") +#define TEXT_FOLLOW_TORRENT \ + _(" --follow-torrent=true|false|mem If true or mem is specified, when a file\n" \ + " whose suffix is .torrent or content type is\n" \ + " application/x-bittorrent is downloaded, aria2\n" \ + " parses it as a torrent file and downloads files\n" \ + " mentioned in it.\n" \ + " If mem is specified, a torrent file is not\n" \ + " written to the disk, but is just kept in memory.\n" \ + " If false is specified, the action mentioned above\n" \ + " is not taken.") +#define TEXT_DIRECT_FILE_MAPPING \ + _(" --direct-file-mapping=true|false Directly read from and write to each file\n" \ + " mentioned in .torrent file.") +#define TEXT_LISTEN_PORT \ + _(" --listen-port=PORT... Set TCP port number for BitTorrent downloads.\n" \ + " Multiple ports can be specified by using ',',\n" \ + " for example: \"6881,6885\". You can also use '-'\n" \ + " to specify a range: \"6881-6999\". ',' and '-' can\n" \ + " be used together.") +#define TEXT_MAX_OVERALL_UPLOAD_LIMIT \ + _(" --max-overall-upload-limit=SPEED Set max overall upload speed in bytes/sec.\n" \ + " 0 means unrestricted.\n" \ + " You can append K or M(1K = 1024, 1M = 1024K).\n" \ + " To limit the upload speed per torrent, use\n" \ + " --max-upload-limit option.") +#define TEXT_MAX_UPLOAD_LIMIT \ + _(" -u, --max-upload-limit=SPEED Set max upload speed per each torrent in\n" \ + " bytes/sec. 0 means unrestricted.\n" \ + " You can append K or M(1K = 1024, 1M = 1024K).\n" \ + " To limit the overall upload speed, use\n" \ + " --max-overall-upload-limit option.") +#define TEXT_SEED_TIME \ + _(" --seed-time=MINUTES Specify seeding time in minutes. Also see the\n" \ + " --seed-ratio option.") +#define TEXT_SEED_RATIO \ + _(" --seed-ratio=RATIO Specify share ratio. Seed completed torrents\n" \ + " until share ratio reaches RATIO.\n" \ + " You are strongly encouraged to specify equals or\n" \ + " more than 1.0 here. Specify 0.0 if you intend to\n" \ + " do seeding regardless of share ratio.\n" \ + " If --seed-time option is specified along with\n" \ + " this option, seeding ends when at least one of\n" \ + " the conditions is satisfied.") +#define TEXT_PEER_ID_PREFIX \ + _(" --peer-id-prefix=PEER_ID_PREFIX Specify the prefix of peer ID. The peer ID in\n" \ + " BitTorrent is 20 byte length. If more than 20\n" \ + " bytes are specified, only first 20 bytes are\n" \ + " used. If less than 20 bytes are specified, random\n" \ + " byte data are added to make its length 20 bytes.") +#define TEXT_ENABLE_PEER_EXCHANGE \ + _(" --enable-peer-exchange[=true|false] Enable Peer Exchange extension.") +#define TEXT_ENABLE_DHT \ + _(" --enable-dht[=true|false] Enable DHT functionality.") +#define TEXT_DHT_LISTEN_PORT \ + _(" --dht-listen-port=PORT... Set UDP listening port for DHT.\n" \ + " Multiple ports can be specified by using ',',\n" \ + " for example: \"6881,6885\". You can also use '-'\n" \ + " to specify a range: \"6881-6999\". ',' and '-' can\n" \ + " be used together.") +#define TEXT_DHT_ENTRY_POINT \ + _(" --dht-entry-point=HOST:PORT Set host and port as an entry point to DHT\n" \ + " network.") +#define TEXT_DHT_FILE_PATH \ + _(" --dht-file-path=PATH Change the DHT routing table file to PATH.") +#define TEXT_BT_MIN_CRYPTO_LEVEL \ + _(" --bt-min-crypto-level=plain|arc4 Set minimum level of encryption method.\n" \ + " If several encryption methods are provided by a\n" \ + " peer, aria2 chooses the lowest one which satisfies\n" \ + " the given level.") +#define TEXT_BT_REQUIRE_CRYPTO \ + _(" --bt-require-crypto=true|false If true is given, aria2 doesn't accept and\n" \ + " establish connection with legacy BitTorrent\n" \ + " handshake. Thus aria2 always uses Obfuscation\n" \ + " handshake.") +#define TEXT_BT_REQUEST_PEER_SPEED_LIMIT \ + _(" --bt-request-peer-speed-limit=SPEED If the whole download speed of every\n" \ + " torrent is lower than SPEED, aria2 temporarily\n" \ + " increases the number of peers to try for more\n" \ + " download speed. Configuring this option with your\n" \ + " preferred download speed can increase your\n" \ + " download speed in some cases.\n" \ + " You can append K or M(1K = 1024, 1M = 1024K).") +#define TEXT_BT_MAX_OPEN_FILES \ + _(" --bt-max-open-files=NUM Specify maximum number of files to open in each\n" \ + " BitTorrent download.") +#define TEXT_BT_SEED_UNVERIFIED \ + _(" --bt-seed-unverified[=true|false] Seed previously downloaded files without\n" \ + " verifying piece hashes.") +#define TEXT_BT_MAX_PEERS \ + _(" --bt-max-peers=NUM Specify the maximum number of peers per torrent.\n" \ + " 0 means unlimited.\n" \ + " See also --bt-request-peer-speed-limit option.") +#define TEXT_METALINK_FILE \ + _(" -M, --metalink-file=METALINK_FILE The file path to the .metalink file. Reads\n" \ + " input from stdin when '-' is specified.") +#define TEXT_METALINK_SERVERS \ + _(" -C, --metalink-servers=NUM_SERVERS The number of servers to connect to\n" \ + " simultaneously. Some Metalinks regulate the\n" \ + " number of servers to connect. aria2 strictly\n" \ + " respects them. This means that if Metalink defines\n" \ + " the maxconnections attribute lower than\n" \ + " NUM_SERVERS, then aria2 uses the value of\n" \ + " maxconnections attribute instead of NUM_SERVERS.\n" \ + " See also -s and -j options.") +#define TEXT_METALINK_VERSION \ + _(" --metalink-version=VERSION The version of the file to download.") +#define TEXT_METALINK_LANGUAGE \ + _(" --metalink-language=LANGUAGE The language of the file to download.") +#define TEXT_METALINK_OS \ + _(" --metalink-os=OS The operating system of the file to download.") +#define TEXT_METALINK_LOCATION \ + _(" --metalink-location=LOCATION[,...] The location of the preferred server.\n" \ + " A comma-delimited list of locations is\n" \ + " acceptable.") +#define TEXT_METALINK_PREFERRED_PROTOCOL \ + _(" --metalink-preferred-protocol=PROTO Specify preferred protocol. Specify 'none'\n" \ + " if you don't have any preferred protocol.") +#define TEXT_FOLLOW_METALINK \ + _(" --follow-metalink=true|false|mem If true or mem is specified, when a file\n" \ + " whose suffix is .metalink or content type of\n" \ + " application/metalink+xml is downloaded, aria2\n" \ + " parses it as a metalink file and downloads files\n" \ + " mentioned in it.\n" \ + " If mem is specified, a metalink file is not\n" \ + " written to the disk, but is just kept in memory.\n" \ + " If false is specified, the action mentioned above\n" \ + " is not taken.") +#define TEXT_METALINK_ENABLE_UNIQUE_PROTOCOL \ + _(" --metalink-enable-unique-protocol=true|false If true is given and several\n" \ + " protocols are available for a mirror in a metalink\n" \ + " file, aria2 uses one of them.\n" \ + " Use --metalink-preferred-protocol option to\n" \ + " specify the preference of protocol.") +#define TEXT_VERSION \ + _(" -v, --version Print the version number and exit.") +#define TEXT_HELP \ + _(" -h, --help[=TAG|KEYWORD] Print usage and exit.\n" \ + " The help messages are classified with tags. A tag\n" \ + " starts with \"#\". For example, type \"--help=#http\"\n" \ + " to get the usage for the options tagged with\n" \ + " \"#http\". If non-tag word is given, print the usage\n" \ + " for the options whose name includes that word.") +#define TEXT_NO_CONF \ + _(" --no-conf Disable loading aria2.conf file.") +#define TEXT_CONF_PATH \ + _(" --conf-path=PATH Change the configuration file path to PATH.") +#define TEXT_STOP \ + _(" --stop=SEC Stop application after SEC seconds has passed.\n" \ + " If 0 is given, this feature is disabled.") +#define TEXT_HEADER \ + _(" --header=HEADER Append HEADER to HTTP request header. You can use\n" \ + " this option repeatedly to specify more than one\n" \ + " header:\n" \ + " aria2c --header=\"X-A: b78\" --header=\"X-B: 9J1\"\n" \ + " http://host/file") +#define TEXT_QUIET \ + _(" -q, --quiet[=true|false] Make aria2 quiet(no console output).") +#define TEXT_ASYNC_DNS \ + _(" --async-dns[=true|false] Enable asynchronous DNS.") +#define TEXT_FTP_REUSE_CONNECTION \ + _(" --ftp-reuse-connection[=true|false] Reuse connection in FTP.") +#define TEXT_SUMMARY_INTERVAL \ + _(" --summary-interval=SEC Set interval to output download progress summary.\n" \ + " Setting 0 suppresses the output.") +#define TEXT_LOG_LEVEL \ + _(" --log-level=LEVEL Set log level to output.") +#define TEXT_REMOTE_TIME \ + _(" -R, --remote-time[=true|false] Retrieve timestamp of the remote file from the\n" \ + " remote HTTP/FTP server and if it is available,\n" \ + " apply it to the local file.") +#define TEXT_CONNECT_TIMEOUT \ + _(" --connect-timeout=SEC Set the connect timeout in seconds to establish\n" \ + " connection to HTTP/FTP/proxy server. After the\n" \ + " connection is established, this option makes no\n" \ + " effect and --timeout option is used instead.") +#define TEXT_MAX_FILE_NOT_FOUND \ + _(" --max-file-not-found=NUM If aria2 receives `file not found' status from the\n" \ + " remote HTTP/FTP servers NUM times without getting\n" \ + " a single byte, then force the download to fail.\n" \ + " Specify 0 to disable this option.\n" \ + " This options is effective only when using\n" \ + " HTTP/FTP servers.") +#define TEXT_URI_SELECTOR \ + _(" --uri-selector=SELECTOR Specify URI selection algorithm.\n" \ + " If 'inorder' is given, URI is tried in the order\n" \ + " appeared in the URI list.\n" \ + " If 'feedback' is given, aria2 uses download speed\n" \ + " observed in the previous downloads and choose\n" \ + " fastest server in the URI list. This also\n" \ + " effectively skips dead mirrors. The observed\n" \ + " download speed is a part of performance profile\n" \ + " of servers mentioned in --server-stat-of and\n" \ + " --server-stat-if options.\n" \ + " If 'adaptive' is given, selects one of the best\n" \ + " mirrors for the first and reserved connections.\n" \ + " For supplementary ones, it returns mirrors which\n" \ + " has not been tested yet, and if each of them has\n" \ + " already been tested, returns mirrors which has to\n" \ + " be tested again. Otherwise, it doesn't select\n" \ + " anymore mirrors. Like 'feedback', it uses a\n" \ + " performance profile of servers.") +#define TEXT_SERVER_STAT_OF \ + _(" --server-stat-of=FILE Specify the filename to which performance profile\n" \ + " of the servers is saved. You can load saved data\n" \ + " using --server-stat-if option.") +#define TEXT_SERVER_STAT_IF \ + _(" --server-stat-if=FILE Specify the filename to load performance profile\n" \ + " of the servers. The loaded data will be used in\n" \ + " some URI selector such as 'feedback'.\n" \ + " See also --uri-selector option") +#define TEXT_SERVER_STAT_TIMEOUT \ + _(" --server-stat-timeout=SEC Specifies timeout in seconds to invalidate\n" \ + " performance profile of the servers since the last\n" \ + " contact to them.") +#define TEXT_AUTO_SAVE_INTERVAL \ + _(" --auto-save-interval=SEC Save a control file(*.aria2) every SEC seconds.\n" \ + " If 0 is given, a control file is not saved during\n" \ + " download. aria2 saves a control file when it stops\n" \ + " regardless of the value.") +#define TEXT_CERTIFICATE \ + _(" --certificate=FILE Use the client certificate in FILE.\n" \ + " The certificate must be in PEM format.\n" \ + " You may use --private-key option to specify the\n" \ + " private key.") +#define TEXT_PRIVATE_KEY \ + _(" --private-key=FILE Use the private key in FILE.\n" \ + " The private key must be decrypted and in PEM\n" \ + " format. See also --certificate option.") +#define TEXT_CA_CERTIFICATE \ + _(" --ca-certificate=FILE Use the certificate authorities in FILE to verify\n" \ + " the peers. The certificate file must be in PEM\n" \ + " format and can contain multiple CA certificates.\n" \ + " Use --check-certificate option to enable\n" \ + " verification.") +#define TEXT_CHECK_CERTIFICATE \ + _(" --check-certificate[=true|false] Verify the peer using certificates specified\n" \ + " in --ca-certificate option.") +#define TEXT_NO_PROXY \ + _(" --no-proxy=DOMAINS Specify comma separated hostnames or domains where\n" \ + " proxy should not be used.") +#define TEXT_USE_HEAD \ + _(" --use-head[=true|false] Use HEAD method for the first request to the HTTP\n" \ + " server.") +#define TEXT_EVENT_POLL \ + _(" --event-poll=POLL Specify the method for polling events.") +#define TEXT_XML_RPC_LISTEN_PORT \ + _(" --xml-rpc-listen-port=PORT Specify a port number for XML-RPC server to listen\n" \ + " to.") +#define TEXT_ENABLE_XML_RPC \ + _(" --enable-xml-rpc[=true|false] Enable XML-RPC server.\n" \ + " It is strongly recommended to set username and\n" \ + " password using --xml-rpc-user and --xml-rpc-passwd\n" \ + " option. See also --xml-rpc-listen-port option.") +#define TEXT_XML_RPC_MAX_REQUEST_SIZE \ + _(" --xml-rpc-max-request-size=SIZE Set max size of XML-RPC request. If aria2\n" \ + " detects the request is more than SIZE bytes, it\n" \ + " drops connection.") +#define TEXT_XML_RPC_USER \ + _(" --xml-rpc-user=USER Set XML-RPC user.") +#define TEXT_XML_RPC_PASSWD \ + _(" --xml-rpc-passwd=PASSWD Set XML-RPC password.") +#define TEXT_BT_EXTERNAL_IP \ + _(" --bt-external-ip=IPADDRESS Specify the external IP address to report to a\n" \ + " BitTorrent tracker. Although this function is\n" \ + " named 'external', it can accept any kind of IP\n" \ + " addresses.") +#define TEXT_HTTP_AUTH_CHALLENGE \ + _(" --http-auth-challenge[=true|false] Send HTTP authorization header only when it\n" \ + " is requested by the server. If false is set, then\n" \ + " authorization header is always sent to the server.\n" \ + " There is an exception: if username and password\n" \ + " are embedded in URI, authorization header is\n" \ + " always sent to the server regardless of this\n" \ + " option.") +#define TEXT_INDEX_OUT \ + _(" -O, --index-out=INDEX=PATH Set file path for file with index=INDEX. You can\n" \ + " find the file index using the --show-files option.\n" \ + " PATH is a relative path to the path specified in\n" \ + " --dir option. You can use this option multiple\n" \ + " times.") +#define TEXT_DRY_RUN \ + _(" --dry-run[=true|false] If true is given, aria2 just checks whether the\n" \ + " remote file is available and doesn't download\n" \ + " data. This option has effect on HTTP/FTP download.\n" \ + " BitTorrent downloads are canceled if true is\n" \ + " specified.") +#define TEXT_BT_TRACKER_INTERVAL \ + _(" --bt-tracker-interval=SEC Set the interval in seconds between tracker\n" \ + " requests. This completely overrides interval value\n" \ + " and aria2 just uses this value and ignores the\n" \ + " min interval and interval value in the response of\n" \ + " tracker. If 0 is set, aria2 determines interval\n" \ + " based on the response of tracker and the download\n" \ + " progress.") +#define TEXT_ON_DOWNLOAD_COMPLETE \ + _(" --on-download-complete=COMMAND Set the command to be executed when download\n" \ + " completes.\n" \ + " See --on-download-start option for the\n" \ + " requirement of COMMAND.\n" \ + " See also --on-download-stop option.") +#define TEXT_ON_DOWNLOAD_START \ + _(" --on-download-start=COMMAND Set the command to be executed when download\n" \ + " starts up. COMMAND must take just one argument and\n" \ + " GID is passed to COMMAND as a first argument.") +#define TEXT_ON_DOWNLOAD_ERROR \ + _(" --on-download-error=COMMAND Set the command to be executed when download\n" \ + " aborts due to error.\n" \ + " See --on-download-start option for the\n" \ + " requirement of COMMAND.\n" \ + " See also --on-download-stop option.") +#define TEXT_ON_DOWNLOAD_STOP \ + _(" --on-download-stop=COMMAND Set the command to be executed when download\n" \ + " stops. You can override the command to be executed\n" \ + " for particular download result using\n" \ + " --on-download-complete and --on-download-error. If\n" \ + " they are specified, command specified in this\n" \ + " option is not executed.\n" \ + " See --on-download-start option for the\n" \ + " requirement of COMMAND.") +#define TEXT_BT_STOP_TIMEOUT \ + _(" --bt-stop-timeout=SEC Stop BitTorrent download if download speed is 0 in\n" \ + " consecutive SEC seconds. If 0 is given, this\n" \ + " feature is disabled.") +#define TEXT_XML_RPC_LISTEN_ALL \ + _(" --xml-rpc-listen-all[=true|false] Listen incoming XML-RPC requests on all\n" \ + " network interfaces. If false is given, listen only\n" \ + " on local loopback interface.") +#define TEXT_BT_PRIORITIZE_PIECE \ + _(" --bt-prioritize-piece=head[=SIZE],tail[=SIZE] Try to download first and last\n" \ + " pieces of each file first. This is useful for\n" \ + " previewing files. The argument can contain 2\n" \ + " keywords:head and tail. To include both keywords,\n" \ + " they must be separated by comma. These keywords\n" \ + " can take one parameter, SIZE. For example, if\n" \ + " head=SIZE is specified, pieces in the range of\n" \ + " first SIZE bytes of each file get higher priority.\n" \ + " tail=SIZE means the range of last SIZE bytes of\n" \ + " each file. SIZE can include K or M(1K = 1024, 1M =\n" \ + " 1024K). If SIZE is omitted, SIZE=1M is used.") +#define TEXT_INTERFACE \ + _(" --interface=INTERFACE Bind sockets to given interface. You can specify\n" \ + " interface name, IP address and hostname.") +#define TEXT_DISABLE_IPV6 \ + _(" --disable-ipv6[=true|false] Disable IPv6.") +#define TEXT_BT_SAVE_METADATA \ + _(" --bt-save-metadata[=true|false] Save metadata as .torrent file. This option has\n" \ + " effect only when BitTorrent Magnet URI is used.\n" \ + " The filename is hex encoded info hash with suffix\n" \ + " .torrent. The directory to be saved is the same\n" \ + " directory where download file is saved. If the\n" \ + " same file already exists, metadata is not saved.") diff --git a/src/util.cc b/src/util.cc index 0edf1188..943353dc 100644 --- a/src/util.cc +++ b/src/util.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -142,7 +142,7 @@ int64_t difftv(struct timeval tv1, struct timeval tv2) { return 0; } return ((int64_t)(tv1.tv_sec-tv2.tv_sec)*1000000+ - tv1.tv_usec-tv2.tv_usec); + tv1.tv_usec-tv2.tv_usec); } int32_t difftvsec(struct timeval tv1, struct timeval tv2) { @@ -235,7 +235,7 @@ std::string urlencode(const unsigned char* target, size_t len) { std::string urlencode(const std::string& target) { return urlencode(reinterpret_cast<const unsigned char*>(target.c_str()), - target.size()); + target.size()); } std::string torrentUrlencode(const unsigned char* target, size_t len) { @@ -264,11 +264,11 @@ std::string urldecode(const std::string& target) { itr != target.end(); ++itr) { if(*itr == '%') { if(itr+1 != target.end() && itr+2 != target.end() && - isxdigit(*(itr+1)) && isxdigit(*(itr+2))) { - result += parseInt(std::string(itr+1, itr+3), 16); - itr += 2; + isxdigit(*(itr+1)) && isxdigit(*(itr+2))) { + result += parseInt(std::string(itr+1, itr+3), 16); + itr += 2; } else { - result += *itr; + result += *itr; } } else { result += *itr; @@ -322,13 +322,13 @@ std::string fromHex(const std::string& src) return dest; } for(size_t i = 0; i < src.size(); i += 2) { - unsigned char high = hexCharToUInt(src[i]); - unsigned char low = hexCharToUInt(src[i+1]); - if(high == 255 || low == 255) { - dest.clear(); - return dest; - } - dest += (high*16+low); + unsigned char high = hexCharToUInt(src[i]); + unsigned char low = hexCharToUInt(src[i+1]); + if(high == 255 || low == 255) { + dest.clear(); + return dest; + } + dest += (high*16+low); } return dest; } @@ -389,19 +389,19 @@ int32_t parseInt(const std::string& s, int32_t base) std::string trimed = trim(s); if(trimed.empty()) { throw DL_ABORT_EX(StringFormat(MSG_STRING_INTEGER_CONVERSION_FAILURE, - "empty string").str()); + "empty string").str()); } char* stop; errno = 0; long int v = strtol(trimed.c_str(), &stop, base); if(*stop != '\0') { throw DL_ABORT_EX(StringFormat(MSG_STRING_INTEGER_CONVERSION_FAILURE, - trimed.c_str()).str()); + trimed.c_str()).str()); } else if((((v == LONG_MIN) || (v == LONG_MAX)) && (errno == ERANGE)) || - (v > INT32_MAX) || - (v < INT32_MIN)) { + (v > INT32_MAX) || + (v < INT32_MIN)) { throw DL_ABORT_EX(StringFormat(MSG_STRING_INTEGER_CONVERSION_FAILURE, - trimed.c_str()).str()); + trimed.c_str()).str()); } return v; } @@ -411,22 +411,22 @@ uint32_t parseUInt(const std::string& s, int base) std::string trimed = trim(s); if(trimed.empty()) { throw DL_ABORT_EX(StringFormat(MSG_STRING_INTEGER_CONVERSION_FAILURE, - "empty string").str()); + "empty string").str()); } // We don't allow negative number. if(trimed[0] == '-') { throw DL_ABORT_EX(StringFormat(MSG_STRING_INTEGER_CONVERSION_FAILURE, - trimed.c_str()).str()); + trimed.c_str()).str()); } char* stop; errno = 0; unsigned long int v = strtoul(trimed.c_str(), &stop, base); if(*stop != '\0') { throw DL_ABORT_EX(StringFormat(MSG_STRING_INTEGER_CONVERSION_FAILURE, - trimed.c_str()).str()); + trimed.c_str()).str()); } else if(((v == ULONG_MAX) && (errno == ERANGE)) || (v > UINT32_MAX)) { throw DL_ABORT_EX(StringFormat(MSG_STRING_INTEGER_CONVERSION_FAILURE, - trimed.c_str()).str()); + trimed.c_str()).str()); } return v; } @@ -458,17 +458,17 @@ int64_t parseLLInt(const std::string& s, int32_t base) std::string trimed = trim(s); if(trimed.empty()) { throw DL_ABORT_EX(StringFormat(MSG_STRING_INTEGER_CONVERSION_FAILURE, - "empty string").str()); + "empty string").str()); } char* stop; errno = 0; int64_t v = strtoll(trimed.c_str(), &stop, base); if(*stop != '\0') { throw DL_ABORT_EX(StringFormat(MSG_STRING_INTEGER_CONVERSION_FAILURE, - trimed.c_str()).str()); + trimed.c_str()).str()); } else if(((v == INT64_MIN) || (v == INT64_MAX)) && (errno == ERANGE)) { throw DL_ABORT_EX(StringFormat(MSG_STRING_INTEGER_CONVERSION_FAILURE, - trimed.c_str()).str()); + trimed.c_str()).str()); } return v; } @@ -478,22 +478,22 @@ uint64_t parseULLInt(const std::string& s, int base) std::string trimed = trim(s); if(trimed.empty()) { throw DL_ABORT_EX(StringFormat(MSG_STRING_INTEGER_CONVERSION_FAILURE, - "empty string").str()); + "empty string").str()); } // We don't allow negative number. if(trimed[0] == '-') { throw DL_ABORT_EX(StringFormat(MSG_STRING_INTEGER_CONVERSION_FAILURE, - trimed.c_str()).str()); + trimed.c_str()).str()); } char* stop; errno = 0; uint64_t v = strtoull(trimed.c_str(), &stop, base); if(*stop != '\0') { throw DL_ABORT_EX(StringFormat(MSG_STRING_INTEGER_CONVERSION_FAILURE, - trimed.c_str()).str()); + trimed.c_str()).str()); } else if((v == ULLONG_MAX) && (errno == ERANGE)) { throw DL_ABORT_EX(StringFormat(MSG_STRING_INTEGER_CONVERSION_FAILURE, - trimed.c_str()).str()); + trimed.c_str()).str()); } return v; } @@ -514,8 +514,8 @@ IntSequence parseIntRange(const std::string& src) } else { std::pair<std::string, std::string> 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()); + throw DL_ABORT_EX + (StringFormat(MSG_INCOMPLETE_RANGE, p.first.c_str()).str()); } int32_t v1 = parseInt(vp.first.c_str()); int32_t v2 = parseInt(vp.second.c_str()); @@ -535,14 +535,14 @@ static void computeHeadPieces return; } for(std::vector<SharedHandle<FileEntry> >::const_iterator fi = - fileEntries.begin(); fi != fileEntries.end(); ++fi) { + fileEntries.begin(); fi != fileEntries.end(); ++fi) { if((*fi)->getLength() == 0) { continue; } size_t lastIndex = ((*fi)->getOffset()+std::min(head, (*fi)->getLength())-1)/pieceLength; for(size_t index = (*fi)->getOffset()/pieceLength; - index <= lastIndex; ++index) { + index <= lastIndex; ++index) { indexes.push_back(index); } } @@ -558,7 +558,7 @@ static void computeTailPieces return; } for(std::vector<SharedHandle<FileEntry> >::const_iterator fi = - fileEntries.begin(); fi != fileEntries.end(); ++fi) { + fileEntries.begin(); fi != fileEntries.end(); ++fi) { if((*fi)->getLength() == 0) { continue; } @@ -566,7 +566,7 @@ static void computeTailPieces size_t fromIndex = (endOffset-1-(std::min(tail, (*fi)->getLength())-1))/pieceLength; for(size_t index = fromIndex; index <= (endOffset-1)/pieceLength; - ++index) { + ++index) { indexes.push_back(index); } } @@ -587,19 +587,19 @@ void parsePrioritizePieceRange computeHeadPieces(indexes, fileEntries, pieceLength, defaultSize); } else if(util::startsWith(*i, "head=")) { std::string sizestr = std::string((*i).begin()+(*i).find("=")+1, - (*i).end()); + (*i).end()); computeHeadPieces(indexes, fileEntries, pieceLength, - std::max((int64_t)0, getRealSize(sizestr))); + std::max((int64_t)0, getRealSize(sizestr))); } else if((*i) == "tail") { computeTailPieces(indexes, fileEntries, pieceLength, defaultSize); } else if(util::startsWith(*i, "tail=")) { std::string sizestr = std::string((*i).begin()+(*i).find("=")+1, - (*i).end()); + (*i).end()); computeTailPieces(indexes, fileEntries, pieceLength, - std::max((int64_t)0, getRealSize(sizestr))); + std::max((int64_t)0, getRealSize(sizestr))); } else { throw DL_ABORT_EX - (StringFormat("Unrecognized token %s", (*i).c_str()).str()); + (StringFormat("Unrecognized token %s", (*i).c_str()).str()); } } std::sort(indexes.begin(), indexes.end()); @@ -631,7 +631,7 @@ std::string getContentDispositionFilename(const std::string& header) { static const std::string TRIMMED("\r\n '\""); std::string fn = File(trim(header.substr - (filenamesp, filenameep-filenamesp), TRIMMED)).getBasename(); + (filenamesp, filenameep-filenamesp), TRIMMED)).getBasename(); if(fn == ".." || fn == ".") { return A2STR::NIL; } else { @@ -714,7 +714,7 @@ int64_t getRealSize(const std::string& sizeWithUnit) (StringFormat("Negative value detected: %s", sizeWithUnit.c_str()).str()); } else if(INT64_MAX/mult < v) { throw DL_ABORT_EX(StringFormat(MSG_STRING_INTEGER_CONVERSION_FAILURE, - "overflow/underflow").str()); + "overflow/underflow").str()); } return v*mult; } @@ -758,33 +758,33 @@ void usleep(long microseconds) { ::usleep(microseconds); #elif defined(HAVE_WINSOCK2_H) - LARGE_INTEGER current, freq, end; + LARGE_INTEGER current, freq, end; - static enum {GET_FREQUENCY, GET_MICROSECONDS, SKIP_MICROSECONDS} state = GET_FREQUENCY; + static enum {GET_FREQUENCY, GET_MICROSECONDS, SKIP_MICROSECONDS} state = GET_FREQUENCY; - if (state == GET_FREQUENCY) { - if (QueryPerformanceFrequency(&freq)) - state = GET_MICROSECONDS; - else - state = SKIP_MICROSECONDS; - } - - long msec = microseconds / 1000; - microseconds %= 1000; + if (state == GET_FREQUENCY) { + if (QueryPerformanceFrequency(&freq)) + state = GET_MICROSECONDS; + else + state = SKIP_MICROSECONDS; + } + + long msec = microseconds / 1000; + microseconds %= 1000; - if (state == GET_MICROSECONDS && microseconds) { - QueryPerformanceCounter(&end); + if (state == GET_MICROSECONDS && microseconds) { + QueryPerformanceCounter(&end); - end.QuadPart += (freq.QuadPart * microseconds) / 1000000; + end.QuadPart += (freq.QuadPart * microseconds) / 1000000; - while (QueryPerformanceCounter(¤t) && (current.QuadPart <= end.QuadPart)) - /* noop */ ; - } + while (QueryPerformanceCounter(¤t) && (current.QuadPart <= end.QuadPart)) + /* noop */ ; + } - if (msec) - Sleep(msec); + if (msec) + Sleep(msec); #else - #error no usleep function is available (nanosleep?) +#error no usleep function is available (nanosleep?) #endif } @@ -857,11 +857,11 @@ void mkdirs(const std::string& dirpath) } else if(dir.exists()) { throw DL_ABORT_EX (StringFormat(EX_MAKE_DIR, dir.getPath().c_str(), - "File already exists.").str()); + "File already exists.").str()); } else if(!dir.mkdirs()) { throw DL_ABORT_EX (StringFormat(EX_MAKE_DIR, dir.getPath().c_str(), - strerror(errno)).str()); + strerror(errno)).str()); } } @@ -870,7 +870,7 @@ void convertBitfield(BitfieldMan* dest, const BitfieldMan* src) size_t numBlock = dest->countBlock(); for(size_t index = 0; index < numBlock; ++index) { if(src->isBitSetOffsetRange((uint64_t)index*dest->getBlockLength(), - dest->getBlockLength())) { + dest->getBlockLength())) { dest->setBit(index); } } @@ -913,10 +913,10 @@ getNumericNameInfo(const struct sockaddr* sockaddr, socklen_t len) char host[NI_MAXHOST]; char service[NI_MAXSERV]; int s = getnameinfo(sockaddr, len, host, NI_MAXHOST, service, NI_MAXSERV, - NI_NUMERICHOST|NI_NUMERICSERV); + NI_NUMERICHOST|NI_NUMERICSERV); if(s != 0) { throw DL_ABORT_EX(StringFormat("Failed to get hostname and port. cause: %s", - gai_strerror(s)).str()); + gai_strerror(s)).str()); } return std::pair<std::string, uint16_t>(host, atoi(service)); // TODO } @@ -950,7 +950,7 @@ parseIndexPath(const std::string& line) size_t index = parseUInt(p.first); if(p.second.empty()) { throw DL_ABORT_EX(StringFormat("Path with index=%u is empty.", - static_cast<unsigned int>(index)).str()); + static_cast<unsigned int>(index)).str()); } return std::map<size_t, std::string>::value_type(index, p.second); } @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -87,7 +87,7 @@ inline uint64_t hton64(uint64_t x) { return byteswap64(x); } namespace util { void split(std::pair<std::string, std::string>& hp, - const std::string& src, char delim); + const std::string& src, char delim); std::pair<std::string, std::string> split(const std::string& src, const std::string& delims); @@ -140,10 +140,10 @@ int32_t difftvsec(struct timeval tv1, struct timeval tv2); extern const std::string DEFAULT_TRIM_CHARSET; std::string trim(const std::string& src, - const std::string& trimCharset = DEFAULT_TRIM_CHARSET); + const std::string& trimCharset = DEFAULT_TRIM_CHARSET); void trimSelf(std::string& str, - const std::string& trimCharset = DEFAULT_TRIM_CHARSET); + const std::string& trimCharset = DEFAULT_TRIM_CHARSET); bool startsWith(const std::string& target, const std::string& part); @@ -216,7 +216,7 @@ void parsePrioritizePieceRange std::string getContentDispositionFilename(const std::string& header); std::string randomAlpha(size_t length, - const SharedHandle<Randomizer>& randomizer); + const SharedHandle<Randomizer>& randomizer); std::string toUpper(const std::string& src); @@ -293,7 +293,7 @@ std::string joinPath(InputIterator first, InputIterator last) for(;first != last; ++first) { if(*first == "..") { if(!elements.empty()) { - elements.pop_back(); + elements.pop_back(); } } else if(*first == ".") { // do nothing @@ -317,7 +317,7 @@ std::map<size_t, std::string> createIndexPathMap(std::istream& i); */ template<typename OutputIterator> OutputIterator split(const std::string& src, OutputIterator out, - const std::string& delims, bool doTrim = false) + const std::string& delims, bool doTrim = false) { std::string::size_type p = 0; while(1) { @@ -325,11 +325,11 @@ 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; - ++out; + *out = term; + ++out; } break; } diff --git a/src/version_usage.cc b/src/version_usage.cc index 7ea68eac..c70b1f9d 100644 --- a/src/version_usage.cc +++ b/src/version_usage.cc @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the @@ -55,36 +55,36 @@ namespace aria2 { void showVersion() { std::cout << PACKAGE << _(" version ") << PACKAGE_VERSION << "\n" - << "Copyright (C) 2006, 2009 Tatsuhiro Tsujikawa" << "\n" - << "\n" - << + << "Copyright (C) 2006, 2009 Tatsuhiro Tsujikawa" << "\n" + << "\n" + << "This program is free software; you can redistribute it and/or modify\n" "it under the terms of the GNU General Public License as published by\n" "the Free Software Foundation; either version 2 of the License, or\n" "(at your option) any later version.\n" - << "\n" - << + << "\n" + << "This program is distributed in the hope that it will be useful,\n" "but WITHOUT ANY WARRANTY; without even the implied warranty of\n" "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n" "GNU General Public License for more details.\n" - << "\n" - << "** Configuration **" << "\n" - << "Enabled Features: " - << FeatureConfig::getInstance()->featureSummary() << "\n" + << "\n" + << "** Configuration **" << "\n" + << "Enabled Features: " + << FeatureConfig::getInstance()->featureSummary() << "\n" #ifdef ENABLE_MESSAGE_DIGEST - << "Hash Algorithms: " - << MessageDigestContext::getSupportedAlgoString() << "\n" + << "Hash Algorithms: " + << MessageDigestContext::getSupportedAlgoString() << "\n" #endif // ENABLE_MESSAGE_DIGEST - << "\n" - << StringFormat(_("Report bugs to %s"), PACKAGE_BUGREPORT) << "\n" - << "Visit " << PACKAGE_URL << std::endl; + << "\n" + << StringFormat(_("Report bugs to %s"), PACKAGE_BUGREPORT) << "\n" + << "Visit " << PACKAGE_URL << std::endl; } void showUsage(const std::string& keyword, const OptionParser& oparser) { std::cout << _("Usage: aria2c [OPTIONS] [URI | MAGNET | TORRENT_FILE |" - " METALINK_FILE]...") << "\n" - << "\n"; + " METALINK_FILE]...") << "\n" + << "\n"; if(util::startsWith(keyword, "#")) { std::vector<SharedHandle<OptionHandler> > handlers = keyword == TAG_ALL ? oparser.findAll():oparser.findByTag(keyword); @@ -92,56 +92,56 @@ void showUsage(const std::string& keyword, const OptionParser& oparser) { std::cout << _("Printing all options."); } else { std::cout << StringFormat(_("Printing options tagged with '%s'."), - keyword.c_str()); + keyword.c_str()); std::cout << "\n"; SharedHandle<OptionHandler> help = oparser.findByName("help"); std::cout << StringFormat(_("See -h option to know other command-line" - " options(%s)."), - help->createPossibleValuesString().c_str()); + " options(%s)."), + help->createPossibleValuesString().c_str()); } std::cout << "\n" - << _("Options:") << "\n"; + << _("Options:") << "\n"; std::copy(handlers.begin(), handlers.end(), - std::ostream_iterator<SharedHandle<OptionHandler> > - (std::cout, "\n\n")); + std::ostream_iterator<SharedHandle<OptionHandler> > + (std::cout, "\n\n")); } else { std::vector<SharedHandle<OptionHandler> > handlers = oparser.findByNameSubstring(keyword); if(!handlers.empty()) { std::cout << StringFormat(_("Printing options whose name includes" - " '%s'."), keyword.c_str()) - << "\n" - << _("Options:") << "\n"; + " '%s'."), keyword.c_str()) + << "\n" + << _("Options:") << "\n"; std::copy(handlers.begin(), handlers.end(), - std::ostream_iterator<SharedHandle<OptionHandler> > - (std::cout, "\n\n")); + std::ostream_iterator<SharedHandle<OptionHandler> > + (std::cout, "\n\n")); } else { std::cout << StringFormat(_("No option matching with '%s'."), - keyword.c_str()) - << "\n" << oparser.findByName("help") << "\n"; + keyword.c_str()) + << "\n" << oparser.findByName("help") << "\n"; } } if(keyword == TAG_BASIC) { std::cout << "URI, MAGNET, TORRENT_FILE, METALINK_FILE:" << "\n" - << _(" You can specify multiple HTTP(S)/FTP URIs. Unless you specify -Z option, all\n" - " URIs must point to the same file or downloading will fail.") << "\n" - << _(" You can also specify arbitrary number of BitTorrent Magnet URIs, torrent/\n" - " metalink files stored in a local drive. Please note that they are always\n" - " treated as a separate download.") << "\n" + << _(" You can specify multiple HTTP(S)/FTP URIs. Unless you specify -Z option, all\n" + " URIs must point to the same file or downloading will fail.") << "\n" + << _(" You can also specify arbitrary number of BitTorrent Magnet URIs, torrent/\n" + " metalink files stored in a local drive. Please note that they are always\n" + " treated as a separate download.") << "\n" - << "\n" - << _(" You can specify both torrent file with -T option and URIs. By doing this,\n" - " download a file from both torrent swarm and HTTP/FTP server at the same time,\n" - " while the data from HTTP/FTP are uploaded to the torrent swarm. For single file\n" - " torrents, URI can be a complete URI pointing to the resource or if URI ends\n" - " with '/', 'name' in torrent file is added. For multi-file torrents, 'name' and\n" - " 'path' in torrent are added to form a URI for each file.") << "\n" - << "\n" - << _(" Make sure that URI is quoted with single(\') or double(\") quotation if it\n" - " contains \"&\" or any characters that have special meaning in shell.") << "\n" - << "\n"; + << "\n" + << _(" You can specify both torrent file with -T option and URIs. By doing this,\n" + " download a file from both torrent swarm and HTTP/FTP server at the same time,\n" + " while the data from HTTP/FTP are uploaded to the torrent swarm. For single file\n" + " torrents, URI can be a complete URI pointing to the resource or if URI ends\n" + " with '/', 'name' in torrent file is added. For multi-file torrents, 'name' and\n" + " 'path' in torrent are added to form a URI for each file.") << "\n" + << "\n" + << _(" Make sure that URI is quoted with single(\') or double(\") quotation if it\n" + " contains \"&\" or any characters that have special meaning in shell.") << "\n" + << "\n"; } std::cout << _("Refer to man page for more information.") << std::endl; } diff --git a/test/AuthConfigFactoryTest.cc b/test/AuthConfigFactoryTest.cc index 8ddb20ec..128d4b83 100644 --- a/test/AuthConfigFactoryTest.cc +++ b/test/AuthConfigFactoryTest.cc @@ -47,9 +47,9 @@ void AuthConfigFactoryTest::testCreateAuthConfig_http() SharedHandle<Netrc> netrc(new Netrc()); netrc->addAuthenticator (SharedHandle<Authenticator>(new Authenticator("localhost", - "localhostuser", - "localhostpass", - "localhostacct"))); + "localhostuser", + "localhostpass", + "localhostacct"))); netrc->addAuthenticator (SharedHandle<Authenticator>(new DefaultAuthenticator("default", "defaultpassword", "defaultaccount"))); factory.setNetrc(netrc); @@ -60,7 +60,7 @@ void AuthConfigFactoryTest::testCreateAuthConfig_http() CPPUNIT_ASSERT(factory.activateBasicCred("localhost", "/", &option)); CPPUNIT_ASSERT_EQUAL(std::string("localhostuser:localhostpass"), - factory.createAuthConfig(req, &option)->getAuthText()); + factory.createAuthConfig(req, &option)->getAuthText()); // See default token in netrc is ignored. req->setUrl("http://mirror/"); @@ -78,12 +78,12 @@ void AuthConfigFactoryTest::testCreateAuthConfig_http() CPPUNIT_ASSERT(factory.activateBasicCred("mirror", "/", &option)); CPPUNIT_ASSERT_EQUAL(std::string("userDefinedUser:userDefinedPassword"), - factory.createAuthConfig(req, &option)->getAuthText()); + factory.createAuthConfig(req, &option)->getAuthText()); // username and password in URI req->setUrl("http://aria2user:aria2password@localhost/download/aria2-1.0.0.tar.bz2"); CPPUNIT_ASSERT_EQUAL(std::string("aria2user:aria2password"), - factory.createAuthConfig(req, &option)->getAuthText()); + factory.createAuthConfig(req, &option)->getAuthText()); } void AuthConfigFactoryTest::testCreateAuthConfig_httpNoChallenge() @@ -103,16 +103,16 @@ void AuthConfigFactoryTest::testCreateAuthConfig_httpNoChallenge() SharedHandle<Netrc> netrc(new Netrc()); netrc->addAuthenticator (SharedHandle<Authenticator>(new Authenticator("localhost", - "localhostuser", - "localhostpass", - "localhostacct"))); + "localhostuser", + "localhostpass", + "localhostacct"))); netrc->addAuthenticator (SharedHandle<Authenticator>(new DefaultAuthenticator("default", "defaultpassword", "defaultaccount"))); factory.setNetrc(netrc); // not activated CPPUNIT_ASSERT_EQUAL(std::string("localhostuser:localhostpass"), - factory.createAuthConfig(req, &option)->getAuthText()); + factory.createAuthConfig(req, &option)->getAuthText()); // See default token in netrc is ignored. req->setUrl("http://mirror/"); @@ -124,12 +124,12 @@ void AuthConfigFactoryTest::testCreateAuthConfig_httpNoChallenge() option.put(PREF_HTTP_PASSWD, "userDefinedPassword"); CPPUNIT_ASSERT_EQUAL(std::string("userDefinedUser:userDefinedPassword"), - factory.createAuthConfig(req, &option)->getAuthText()); + factory.createAuthConfig(req, &option)->getAuthText()); // username and password in URI req->setUrl("http://aria2user:aria2password@localhost/download/aria2-1.0.0.tar.bz2"); CPPUNIT_ASSERT_EQUAL(std::string("aria2user:aria2password"), - factory.createAuthConfig(req, &option)->getAuthText()); + factory.createAuthConfig(req, &option)->getAuthText()); } void AuthConfigFactoryTest::testCreateAuthConfig_ftp() @@ -144,7 +144,7 @@ void AuthConfigFactoryTest::testCreateAuthConfig_ftp() // without auth info CPPUNIT_ASSERT_EQUAL(std::string("anonymous:ARIA2USER@"), - factory.createAuthConfig(req, &option)->getAuthText()); + factory.createAuthConfig(req, &option)->getAuthText()); // with Netrc SharedHandle<Netrc> netrc(new Netrc()); @@ -152,47 +152,47 @@ void AuthConfigFactoryTest::testCreateAuthConfig_ftp() (SharedHandle<Authenticator>(new DefaultAuthenticator("default", "defaultpassword", "defaultaccount"))); factory.setNetrc(netrc); CPPUNIT_ASSERT_EQUAL(std::string("default:defaultpassword"), - factory.createAuthConfig(req, &option)->getAuthText()); + factory.createAuthConfig(req, &option)->getAuthText()); // disable Netrc option.put(PREF_NO_NETRC, V_TRUE); CPPUNIT_ASSERT_EQUAL(std::string("anonymous:ARIA2USER@"), - factory.createAuthConfig(req, &option)->getAuthText()); + factory.createAuthConfig(req, &option)->getAuthText()); // with Netrc + user defined option.put(PREF_NO_NETRC, V_FALSE); option.put(PREF_FTP_USER, "userDefinedUser"); option.put(PREF_FTP_PASSWD, "userDefinedPassword"); CPPUNIT_ASSERT_EQUAL(std::string("userDefinedUser:userDefinedPassword"), - factory.createAuthConfig(req, &option)->getAuthText()); + factory.createAuthConfig(req, &option)->getAuthText()); // username and password in URI req->setUrl("ftp://aria2user:aria2password@localhost/download/aria2-1.0.0.tar.bz2"); CPPUNIT_ASSERT_EQUAL(std::string("aria2user:aria2password"), - factory.createAuthConfig(req, &option)->getAuthText()); + factory.createAuthConfig(req, &option)->getAuthText()); // username in URI, but no password. We have DefaultAuthenticator // but username is not aria2user req->setUrl("ftp://aria2user@localhost/download/aria2-1.0.0.tar.bz2"); CPPUNIT_ASSERT_EQUAL(std::string("aria2user:userDefinedPassword"), - factory.createAuthConfig(req, &option)->getAuthText()); + factory.createAuthConfig(req, &option)->getAuthText()); // Recreate netrc with entry for user aria2user netrc.reset(new Netrc()); netrc->addAuthenticator (SharedHandle<Authenticator>(new Authenticator("localhost", - "aria2user", - "netrcpass", - "netrcacct"))); + "aria2user", + "netrcpass", + "netrcacct"))); factory.setNetrc(netrc); // This time, we can find same username "aria2user" in netrc, so the // password "netrcpass" is used, instead of "userDefinedPassword" CPPUNIT_ASSERT_EQUAL(std::string("aria2user:netrcpass"), - factory.createAuthConfig(req, &option)->getAuthText()); + factory.createAuthConfig(req, &option)->getAuthText()); // No netrc entry for host mirror, so "userDefinedPassword" is used. req->setUrl("ftp://aria2user@mirror/download/aria2-1.0.0.tar.bz2"); CPPUNIT_ASSERT_EQUAL(std::string("aria2user:userDefinedPassword"), - factory.createAuthConfig(req, &option)->getAuthText()); + factory.createAuthConfig(req, &option)->getAuthText()); } void AuthConfigFactoryTest::testUpdateBasicCred() @@ -216,19 +216,19 @@ void AuthConfigFactoryTest::testUpdateBasicCred() req->setUrl("http://localhost/download/v2.6/Changelog"); CPPUNIT_ASSERT_EQUAL(std::string("price:j38jdc"), - factory.createAuthConfig(req, &option)->getAuthText()); + factory.createAuthConfig(req, &option)->getAuthText()); req->setUrl("http://localhost/documents/reference.html"); CPPUNIT_ASSERT_EQUAL(std::string("alice:ium8"), - factory.createAuthConfig(req, &option)->getAuthText()); + factory.createAuthConfig(req, &option)->getAuthText()); req->setUrl("http://localhost/documents2/manual.html"); CPPUNIT_ASSERT_EQUAL(std::string("myname:mypass"), - factory.createAuthConfig(req, &option)->getAuthText()); + factory.createAuthConfig(req, &option)->getAuthText()); req->setUrl("http://localhost/doc/readme.txt"); CPPUNIT_ASSERT_EQUAL(std::string("myname:mypass"), - factory.createAuthConfig(req, &option)->getAuthText()); + factory.createAuthConfig(req, &option)->getAuthText()); req->setUrl("http://local/"); CPPUNIT_ASSERT(factory.createAuthConfig(req, &option).isNull()); diff --git a/test/BDETest.cc b/test/BDETest.cc index b70da967..4c6b05b9 100644 --- a/test/BDETest.cc +++ b/test/BDETest.cc @@ -41,7 +41,7 @@ void BDETest::testString() unsigned char dataWithNull[] = { 0xf0, '\0', 0x0f }; BDE sWithNull(dataWithNull, sizeof(dataWithNull)); CPPUNIT_ASSERT(memcmp(dataWithNull, sWithNull.s().c_str(), - sizeof(dataWithNull)) == 0); + sizeof(dataWithNull)) == 0); BDE zero(""); CPPUNIT_ASSERT_EQUAL(std::string(""), zero.s()); @@ -49,7 +49,7 @@ 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())); + util::toHex(data.uc(), data.s().size())); } void BDETest::testInteger() diff --git a/test/BNodeTest.cc b/test/BNodeTest.cc index 0cf1d8a2..8e86a19c 100644 --- a/test/BNodeTest.cc +++ b/test/BNodeTest.cc @@ -185,8 +185,8 @@ void BNodeTest::testFindClosestKNodes() } { for(size_t i = 0; i < 6; ++i) { - bucket4->getRandomNodeID(id); - bucket4->addNode(SharedHandle<DHTNode>(new DHTNode(id))); + bucket4->getRandomNodeID(id); + bucket4->addNode(SharedHandle<DHTNode>(new DHTNode(id))); } unsigned char targetID[DHT_ID_LENGTH]; memset(targetID, 0x80, DHT_ID_LENGTH); @@ -194,7 +194,7 @@ void BNodeTest::testFindClosestKNodes() BNode::findClosestKNodes(nodes, bp4, targetID); CPPUNIT_ASSERT_EQUAL((size_t)8, nodes.size()); for(size_t i = 0; i < DHTBucket::K; ++i) { - CPPUNIT_ASSERT(bucket4->isInRange(nodes[i])); + CPPUNIT_ASSERT(bucket4->isInRange(nodes[i])); } } delete bp4; diff --git a/test/Base32Test.cc b/test/Base32Test.cc index 274facdd..8b86c4d2 100644 --- a/test/Base32Test.cc +++ b/test/Base32Test.cc @@ -29,7 +29,7 @@ void Base32Test::testEncode() CPPUNIT_ASSERT_EQUAL(std::string("GEZDGNA="), base32::encode("1234")); CPPUNIT_ASSERT_EQUAL(std::string("GEZDGNBV"), base32::encode("12345")); CPPUNIT_ASSERT_EQUAL(std::string("ESGQUHGQQKCA===="), - base32::encode(util::fromHex("248d0a1cd08284"))); + base32::encode(util::fromHex("248d0a1cd08284"))); } void Base32Test::testDecode() diff --git a/test/BencodeTest.cc b/test/BencodeTest.cc index 19a5fc03..e733498f 100644 --- a/test/BencodeTest.cc +++ b/test/BencodeTest.cc @@ -32,7 +32,7 @@ void BencodeTest::testDecode() CPPUNIT_ASSERT(dict.isDict()); CPPUNIT_ASSERT_EQUAL(std::string("aria2"), dict["name"].s()); CPPUNIT_ASSERT_EQUAL(static_cast<BDE::Integer>(12345678900LL), - dict["size"].i()); + dict["size"].i()); BDE list = dict["files"]; CPPUNIT_ASSERT(list.isList()); CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(2), list.size()); @@ -47,7 +47,7 @@ void BencodeTest::testDecode() BDE dict = list[0]; CPPUNIT_ASSERT(dict.isDict()); CPPUNIT_ASSERT_EQUAL(static_cast<BDE::Integer>(123), - dict["k"].i()); + dict["k"].i()); } { // empty key is allowed @@ -75,8 +75,8 @@ void BencodeTest::testDecode() CPPUNIT_FAIL("exception must be thrown."); } catch(RecoverableException& e) { CPPUNIT_ASSERT_EQUAL(std::string("Bencode decoding failed:" - " Delimiter 'e' not found."), - std::string(e.what())); + " Delimiter 'e' not found."), + std::string(e.what())); } } { @@ -86,9 +86,9 @@ void BencodeTest::testDecode() CPPUNIT_FAIL("exception must be thrown."); } catch(RecoverableException& e) { CPPUNIT_ASSERT_EQUAL(std::string("Bencode decoding failed:" - " Unexpected EOF in dict context." - " 'e' expected."), - std::string(e.what())); + " Unexpected EOF in dict context." + " 'e' expected."), + std::string(e.what())); } } { @@ -98,9 +98,9 @@ void BencodeTest::testDecode() CPPUNIT_FAIL("exception must be thrown."); } catch(RecoverableException& e) { CPPUNIT_ASSERT_EQUAL(std::string("Bencode decoding failed:" - " Unexpected EOF in list context." - " 'e' expected."), - std::string(e.what())); + " Unexpected EOF in list context." + " 'e' expected."), + std::string(e.what())); } } { @@ -110,9 +110,9 @@ void BencodeTest::testDecode() CPPUNIT_FAIL("exception must be thrown."); } catch(RecoverableException& e) { CPPUNIT_ASSERT_EQUAL(std::string("Bencode decoding failed:" - " Expected 3 bytes of data," - " but only 2 read."), - std::string(e.what())); + " Expected 3 bytes of data," + " but only 2 read."), + std::string(e.what())); } } { @@ -122,9 +122,9 @@ void BencodeTest::testDecode() CPPUNIT_FAIL("exception must be thrown."); } catch(RecoverableException& e) { CPPUNIT_ASSERT_EQUAL(std::string("Bencode decoding failed:" - " A positive integer expected" - " but none found."), - std::string(e.what())); + " A positive integer expected" + " but none found."), + std::string(e.what())); } } { @@ -134,9 +134,9 @@ void BencodeTest::testDecode() CPPUNIT_FAIL("exception must be thrown."); } catch(RecoverableException& e) { CPPUNIT_ASSERT_EQUAL(std::string("Bencode decoding failed:" - " A positive integer expected" - " but none found."), - std::string(e.what())); + " A positive integer expected" + " but none found."), + std::string(e.what())); } } { @@ -187,12 +187,12 @@ void BencodeTest::testEncode() dict["attrs"]["license"] = std::string("GPL"); CPPUNIT_ASSERT_EQUAL(std::string("d" - "5:attrsd7:license3:GPLe" - "5:filesl6:aria2ce" - "3:loci80000e" - "4:name5:aria2" - "e"), - bencode::encode(dict)); + "5:attrsd7:license3:GPLe" + "5:filesl6:aria2ce" + "3:loci80000e" + "4:name5:aria2" + "e"), + bencode::encode(dict)); } } diff --git a/test/BitfieldManTest.cc b/test/BitfieldManTest.cc index fc22ab4f..c0532ff5 100644 --- a/test/BitfieldManTest.cc +++ b/test/BitfieldManTest.cc @@ -498,47 +498,47 @@ void BitfieldManTest::testGetSparceMissingUnusedIndex() { memset(ignoreBitfield, 0, sizeof(ignoreBitfield)); size_t index; CPPUNIT_ASSERT(bitfield.getSparseMissingUnusedIndex(index, - ignoreBitfield, length)); + ignoreBitfield, length)); CPPUNIT_ASSERT_EQUAL((size_t)0, index); bitfield.setUseBit(0); CPPUNIT_ASSERT(bitfield.getSparseMissingUnusedIndex(index, - ignoreBitfield, length)); + ignoreBitfield, length)); CPPUNIT_ASSERT_EQUAL((size_t)5, index); bitfield.setUseBit(5); CPPUNIT_ASSERT(bitfield.getSparseMissingUnusedIndex(index, - ignoreBitfield, length)); + ignoreBitfield, length)); CPPUNIT_ASSERT_EQUAL((size_t)3, index); bitfield.setUseBit(3); CPPUNIT_ASSERT(bitfield.getSparseMissingUnusedIndex(index, - ignoreBitfield, length)); + ignoreBitfield, length)); CPPUNIT_ASSERT_EQUAL((size_t)8, index); bitfield.setUseBit(8); CPPUNIT_ASSERT(bitfield.getSparseMissingUnusedIndex(index, - ignoreBitfield, length)); + ignoreBitfield, length)); CPPUNIT_ASSERT_EQUAL((size_t)2, index); bitfield.setUseBit(2); CPPUNIT_ASSERT(bitfield.getSparseMissingUnusedIndex(index, - ignoreBitfield, length)); + ignoreBitfield, length)); CPPUNIT_ASSERT_EQUAL((size_t)7, index); bitfield.setUseBit(7); CPPUNIT_ASSERT(bitfield.getSparseMissingUnusedIndex(index, - ignoreBitfield, length)); + ignoreBitfield, length)); CPPUNIT_ASSERT_EQUAL((size_t)1, index); bitfield.setUseBit(1); CPPUNIT_ASSERT(bitfield.getSparseMissingUnusedIndex(index, - ignoreBitfield, length)); + ignoreBitfield, length)); CPPUNIT_ASSERT_EQUAL((size_t)4, index); bitfield.setUseBit(4); CPPUNIT_ASSERT(bitfield.getSparseMissingUnusedIndex(index, - ignoreBitfield, length)); + ignoreBitfield, length)); CPPUNIT_ASSERT_EQUAL((size_t)6, index); bitfield.setUseBit(6); CPPUNIT_ASSERT(bitfield.getSparseMissingUnusedIndex(index, - ignoreBitfield, length)); + ignoreBitfield, length)); CPPUNIT_ASSERT_EQUAL((size_t)9, index); bitfield.setUseBit(9); CPPUNIT_ASSERT(!bitfield.getSparseMissingUnusedIndex(index, - ignoreBitfield, length)); + ignoreBitfield, length)); } void BitfieldManTest::testGetSparceMissingUnusedIndex_setBit() { @@ -548,47 +548,47 @@ void BitfieldManTest::testGetSparceMissingUnusedIndex_setBit() { memset(ignoreBitfield, 0, sizeof(ignoreBitfield)); size_t index; CPPUNIT_ASSERT(bitfield.getSparseMissingUnusedIndex(index, - ignoreBitfield, length)); + ignoreBitfield, length)); CPPUNIT_ASSERT_EQUAL((size_t)0, index); bitfield.setBit(0); CPPUNIT_ASSERT(bitfield.getSparseMissingUnusedIndex(index, - ignoreBitfield, length)); + ignoreBitfield, length)); CPPUNIT_ASSERT_EQUAL((size_t)1, index); bitfield.setBit(1); CPPUNIT_ASSERT(bitfield.getSparseMissingUnusedIndex(index, - ignoreBitfield, length)); + ignoreBitfield, length)); CPPUNIT_ASSERT_EQUAL((size_t)2, index); bitfield.setBit(2); CPPUNIT_ASSERT(bitfield.getSparseMissingUnusedIndex(index, - ignoreBitfield, length)); + ignoreBitfield, length)); CPPUNIT_ASSERT_EQUAL((size_t)3, index); bitfield.setBit(3); CPPUNIT_ASSERT(bitfield.getSparseMissingUnusedIndex(index, - ignoreBitfield, length)); + ignoreBitfield, length)); CPPUNIT_ASSERT_EQUAL((size_t)4, index); bitfield.setBit(4); CPPUNIT_ASSERT(bitfield.getSparseMissingUnusedIndex(index, - ignoreBitfield, length)); + ignoreBitfield, length)); CPPUNIT_ASSERT_EQUAL((size_t)5, index); bitfield.setBit(5); CPPUNIT_ASSERT(bitfield.getSparseMissingUnusedIndex(index, - ignoreBitfield, length)); + ignoreBitfield, length)); CPPUNIT_ASSERT_EQUAL((size_t)6, index); bitfield.setBit(6); CPPUNIT_ASSERT(bitfield.getSparseMissingUnusedIndex(index, - ignoreBitfield, length)); + ignoreBitfield, length)); CPPUNIT_ASSERT_EQUAL((size_t)7, index); bitfield.setBit(7); CPPUNIT_ASSERT(bitfield.getSparseMissingUnusedIndex(index, - ignoreBitfield, length)); + ignoreBitfield, length)); CPPUNIT_ASSERT_EQUAL((size_t)8, index); bitfield.setBit(8); CPPUNIT_ASSERT(bitfield.getSparseMissingUnusedIndex(index, - ignoreBitfield, length)); + ignoreBitfield, length)); CPPUNIT_ASSERT_EQUAL((size_t)9, index); bitfield.setBit(9); CPPUNIT_ASSERT(!bitfield.getSparseMissingUnusedIndex(index, - ignoreBitfield, length)); + ignoreBitfield, length)); } void BitfieldManTest::testIsBitSetOffsetRange() @@ -714,8 +714,8 @@ void BitfieldManTest::testGetAllMissingIndexes() unsigned char misbitfield[8]; CPPUNIT_ASSERT(bf.getAllMissingIndexes(misbitfield, sizeof(misbitfield), - peerBf.getBitfield(), - peerBf.getBitfieldLength())); + peerBf.getBitfield(), + peerBf.getBitfieldLength())); CPPUNIT_ASSERT_EQUAL((size_t)64, bitfield::countSetBit(misbitfield, nbits)); for(size_t i = 0; i < 62; ++i) { bf.setBit(i); @@ -723,8 +723,8 @@ void BitfieldManTest::testGetAllMissingIndexes() peerBf.unsetBit(62); CPPUNIT_ASSERT(bf.getAllMissingIndexes(misbitfield, sizeof(misbitfield), - peerBf.getBitfield(), - peerBf.getBitfieldLength())); + peerBf.getBitfield(), + peerBf.getBitfieldLength())); CPPUNIT_ASSERT_EQUAL((size_t)1, bitfield::countSetBit(misbitfield, nbits)); CPPUNIT_ASSERT(bitfield::test(misbitfield, nbits, 63)); } @@ -740,9 +740,9 @@ void BitfieldManTest::testGetAllMissingUnusedIndexes() unsigned char misbitfield[8]; CPPUNIT_ASSERT(bf.getAllMissingUnusedIndexes(misbitfield, - sizeof(misbitfield), - peerBf.getBitfield(), - peerBf.getBitfieldLength())); + sizeof(misbitfield), + peerBf.getBitfield(), + peerBf.getBitfieldLength())); CPPUNIT_ASSERT_EQUAL((size_t)64, bitfield::countSetBit(misbitfield, nbits)); for(size_t i = 0; i < 61; ++i) { @@ -751,9 +751,9 @@ void BitfieldManTest::testGetAllMissingUnusedIndexes() bf.setUseBit(61); peerBf.unsetBit(62); CPPUNIT_ASSERT(bf.getAllMissingUnusedIndexes(misbitfield, - sizeof(misbitfield), - peerBf.getBitfield(), - peerBf.getBitfieldLength())); + sizeof(misbitfield), + peerBf.getBitfield(), + peerBf.getBitfieldLength())); CPPUNIT_ASSERT_EQUAL((size_t)1, bitfield::countSetBit(misbitfield, nbits)); CPPUNIT_ASSERT(bitfield::test(misbitfield, nbits, 63)); } diff --git a/test/BittorrentHelperTest.cc b/test/BittorrentHelperTest.cc index 9f8fec7c..ab1a2c97 100644 --- a/test/BittorrentHelperTest.cc +++ b/test/BittorrentHelperTest.cc @@ -145,13 +145,13 @@ void BittorrentHelperTest::testGetPieceHash() { load("test.torrent", dctx); CPPUNIT_ASSERT_EQUAL(util::toHex("AAAAAAAAAAAAAAAAAAAA", 20), - dctx->getPieceHash(0)); + dctx->getPieceHash(0)); CPPUNIT_ASSERT_EQUAL(util::toHex("BBBBBBBBBBBBBBBBBBBB", 20), - dctx->getPieceHash(1)); + dctx->getPieceHash(1)); CPPUNIT_ASSERT_EQUAL(util::toHex("CCCCCCCCCCCCCCCCCCCC", 20), - dctx->getPieceHash(2)); + dctx->getPieceHash(2)); CPPUNIT_ASSERT_EQUAL(std::string(""), - dctx->getPieceHash(3)); + dctx->getPieceHash(3)); CPPUNIT_ASSERT_EQUAL(MessageDigestContext::SHA1, dctx->getPieceHashAlgo()); } @@ -167,11 +167,11 @@ void BittorrentHelperTest::testGetFileEntries() { SharedHandle<FileEntry> fileEntry1 = *itr; CPPUNIT_ASSERT_EQUAL(std::string("./aria2-test/aria2/src/aria2c"), - fileEntry1->getPath()); + fileEntry1->getPath()); itr++; SharedHandle<FileEntry> fileEntry2 = *itr; CPPUNIT_ASSERT_EQUAL(std::string("./aria2-test/aria2-0.2.2.tar.bz2"), - fileEntry2->getPath()); + fileEntry2->getPath()); } void BittorrentHelperTest::testGetFileEntriesSingle() { @@ -185,7 +185,7 @@ void BittorrentHelperTest::testGetFileEntriesSingle() { SharedHandle<FileEntry> fileEntry1 = *itr; CPPUNIT_ASSERT_EQUAL(std::string("./aria2-0.8.2.tar.bz2"), - fileEntry1->getPath()); + fileEntry1->getPath()); } void BittorrentHelperTest::testGetTotalLength() { @@ -228,7 +228,7 @@ void BittorrentHelperTest::testGetNameSingle() { load("single.torrent", dctx); CPPUNIT_ASSERT_EQUAL(std::string("./aria2-0.8.2.tar.bz2"), - dctx->getBasePath()); + dctx->getBasePath()); CPPUNIT_ASSERT_EQUAL(std::string("aria2-0.8.2.tar.bz2"), getName(dctx)); } @@ -237,7 +237,7 @@ void BittorrentHelperTest::testOverrideName() SharedHandle<DownloadContext> dctx(new DownloadContext()); load("test.torrent", dctx, "aria2-override.name"); CPPUNIT_ASSERT_EQUAL(std::string("./aria2-override.name"), - dctx->getBasePath()); + dctx->getBasePath()); CPPUNIT_ASSERT_EQUAL(std::string("aria2-override.name"), getName(dctx)); } @@ -254,7 +254,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"), - tier[0].s()); + tier[0].s()); } @@ -292,7 +292,7 @@ void BittorrentHelperTest::testGetInfoHashAsString() { load("test.torrent", dctx); CPPUNIT_ASSERT_EQUAL(std::string("248d0a1cd08284299de78d5c1ed359bb46717d8c"), - getInfoHashString(dctx)); + getInfoHashString(dctx)); } void BittorrentHelperTest::testGetPeerId() { @@ -348,24 +348,24 @@ void BittorrentHelperTest::testGetFileEntries_multiFileUrlList() { const SharedHandle<FileEntry>& fileEntry1 = *itr; CPPUNIT_ASSERT_EQUAL(std::string("./aria2-test/aria2/src/aria2c"), - fileEntry1->getPath()); + fileEntry1->getPath()); const std::deque<std::string>& uris1 = fileEntry1->getRemainingUris(); CPPUNIT_ASSERT_EQUAL((size_t)2, uris1.size()); CPPUNIT_ASSERT_EQUAL(std::string("http://localhost/dist/aria2-test/aria2/src/aria2c"), - uris1[0]); + uris1[0]); CPPUNIT_ASSERT_EQUAL(std::string("http://mirror/dist/aria2-test/aria2/src/aria2c"), - uris1[1]); + uris1[1]); ++itr; const SharedHandle<FileEntry>& fileEntry2 = *itr; CPPUNIT_ASSERT_EQUAL(std::string("./aria2-test/aria2-0.2.2.tar.bz2"), - fileEntry2->getPath()); + fileEntry2->getPath()); const std::deque<std::string>& uris2 = fileEntry2->getRemainingUris(); CPPUNIT_ASSERT_EQUAL((size_t)2, uris2.size()); CPPUNIT_ASSERT_EQUAL(std::string("http://localhost/dist/aria2-test/aria2-0.2.2.tar.bz2"), - uris2[0]); + uris2[0]); CPPUNIT_ASSERT_EQUAL(std::string("http://mirror/dist/aria2-test/aria2-0.2.2.tar.bz2"), - uris2[1]); + uris2[1]); } void BittorrentHelperTest::testGetFileEntries_singleFileUrlList() { @@ -379,11 +379,11 @@ void BittorrentHelperTest::testGetFileEntries_singleFileUrlList() { const SharedHandle<FileEntry>& fileEntry1 = fileEntries.front(); CPPUNIT_ASSERT_EQUAL(std::string("./aria2.tar.bz2"), - fileEntry1->getPath()); + fileEntry1->getPath()); const std::deque<std::string>& uris1 = fileEntry1->getRemainingUris(); CPPUNIT_ASSERT_EQUAL((size_t)1, uris1.size()); CPPUNIT_ASSERT_EQUAL(std::string("http://localhost/dist/aria2.tar.bz2"), - uris1[0]); + uris1[0]); } void BittorrentHelperTest::testGetFileEntries_singleFileUrlListEndsWithSlash() { @@ -397,11 +397,11 @@ void BittorrentHelperTest::testGetFileEntries_singleFileUrlListEndsWithSlash() { const SharedHandle<FileEntry>& fileEntry1 = fileEntries.front(); CPPUNIT_ASSERT_EQUAL(std::string("./aria2.tar.bz2"), - fileEntry1->getPath()); + fileEntry1->getPath()); const std::deque<std::string>& uris1 = fileEntry1->getRemainingUris(); CPPUNIT_ASSERT_EQUAL((size_t)1, uris1.size()); CPPUNIT_ASSERT_EQUAL(std::string("http://localhost/dist/aria2.tar.bz2"), - uris1[0]); + uris1[0]); } void BittorrentHelperTest::testLoadFromMemory() @@ -451,7 +451,7 @@ void BittorrentHelperTest::testLoadFromMemory_joinPathMulti() // remove ".." element CPPUNIT_ASSERT_EQUAL(std::string("../name1/name2"), getName(dctx)); CPPUNIT_ASSERT_EQUAL(std::string("/tmp/name1/dir1/dir2/file.img"), - dctx->getFirstFileEntry()->getPath()); + dctx->getFirstFileEntry()->getPath()); } void BittorrentHelperTest::testLoadFromMemory_joinPathSingle() @@ -465,7 +465,7 @@ void BittorrentHelperTest::testLoadFromMemory_joinPathSingle() CPPUNIT_ASSERT_EQUAL(std::string("../name1/name2"), getName(dctx)); CPPUNIT_ASSERT_EQUAL(std::string("/tmp/name1/name2"), - dctx->getFirstFileEntry()->getPath()); + dctx->getFirstFileEntry()->getPath()); } void BittorrentHelperTest::testGetNodes() @@ -588,7 +588,7 @@ void BittorrentHelperTest::testGetBasePath() multiCtx->setDir("downloads"); load("test.torrent", multiCtx); CPPUNIT_ASSERT_EQUAL(std::string("downloads/aria2-test"), - multiCtx->getBasePath()); + multiCtx->getBasePath()); } void BittorrentHelperTest::testSetFileFilter_single() @@ -641,9 +641,9 @@ void BittorrentHelperTest::testUTF8Torrent() load("utf8.torrent", dctx); CPPUNIT_ASSERT_EQUAL(std::string("name in utf-8"), getName(dctx)); CPPUNIT_ASSERT_EQUAL(std::string("./name in utf-8/path in utf-8"), - dctx->getFirstFileEntry()->getPath()); + dctx->getFirstFileEntry()->getPath()); CPPUNIT_ASSERT_EQUAL(std::string("This is utf8 comment."), - dctx->getAttribute(BITTORRENT)[COMMENT].s()); + dctx->getAttribute(BITTORRENT)[COMMENT].s()); } void BittorrentHelperTest::testEtc() @@ -651,11 +651,11 @@ void BittorrentHelperTest::testEtc() SharedHandle<DownloadContext> dctx(new DownloadContext()); load("test.torrent", dctx); CPPUNIT_ASSERT_EQUAL(std::string("REDNOAH.COM RULES"), - dctx->getAttribute(BITTORRENT)[COMMENT].s()); + dctx->getAttribute(BITTORRENT)[COMMENT].s()); CPPUNIT_ASSERT_EQUAL(std::string("aria2"), - dctx->getAttribute(BITTORRENT)[CREATED_BY].s()); + dctx->getAttribute(BITTORRENT)[CREATED_BY].s()); CPPUNIT_ASSERT_EQUAL((int64_t)1123456789, - dctx->getAttribute(BITTORRENT)[CREATION_DATE].i()); + dctx->getAttribute(BITTORRENT)[CREATION_DATE].i()); } void BittorrentHelperTest::testCreatecompact() @@ -700,7 +700,7 @@ void BittorrentHelperTest::testMetadata() { const BDE& attrs = dctx->getAttribute(bittorrent::BITTORRENT); CPPUNIT_ASSERT(metadata == attrs[bittorrent::METADATA].s()); CPPUNIT_ASSERT_EQUAL(metadata.size(), - (size_t)attrs[bittorrent::METADATA_SIZE].i()); + (size_t)attrs[bittorrent::METADATA_SIZE].i()); } void BittorrentHelperTest::testParseMagnet() @@ -710,14 +710,14 @@ void BittorrentHelperTest::testParseMagnet() "&tr=http://tracker1&tr=http://tracker2"; BDE attrs = bittorrent::parseMagnet(magnet); CPPUNIT_ASSERT_EQUAL(std::string("248d0a1cd08284299de78d5c1ed359bb46717d8c"), - util::toHex(attrs[bittorrent::INFO_HASH].s())); + util::toHex(attrs[bittorrent::INFO_HASH].s())); CPPUNIT_ASSERT_EQUAL(std::string("[METADATA]aria2"), - attrs[bittorrent::NAME].s()); + attrs[bittorrent::NAME].s()); CPPUNIT_ASSERT_EQUAL((size_t)2, attrs[bittorrent::ANNOUNCE_LIST].size()); CPPUNIT_ASSERT_EQUAL(std::string("http://tracker1"), - attrs[bittorrent::ANNOUNCE_LIST][0][0].s()); + attrs[bittorrent::ANNOUNCE_LIST][0][0].s()); CPPUNIT_ASSERT_EQUAL(std::string("http://tracker2"), - attrs[bittorrent::ANNOUNCE_LIST][1][0].s()); + attrs[bittorrent::ANNOUNCE_LIST][1][0].s()); magnet = "magnet:?xt=urn:btih:248d0a1cd08284299de78d5c1ed359bb46717d8c"; attrs = bittorrent::parseMagnet(magnet); @@ -750,10 +750,10 @@ void BittorrentHelperTest::testMetadata2Torrent() announceList[0] << std::string("http://localhost/announce"); CPPUNIT_ASSERT_EQUAL (std::string("d" - "13:announce-list" - "ll25:http://localhost/announceee" - "4:infoMETADATA" - "e"), + "13:announce-list" + "ll25:http://localhost/announceee" + "4:infoMETADATA" + "e"), metadata2Torrent(metadata, attrs)); } @@ -764,10 +764,10 @@ void BittorrentHelperTest::testTorrent2Magnet() CPPUNIT_ASSERT_EQUAL (std::string("magnet:?xt=urn:btih:248D0A1CD08284299DE78D5C1ED359BB46717D8C" - "&dn=aria2-test" - "&tr=http%3A%2F%2Ftracker1" - "&tr=http%3A%2F%2Ftracker2" - "&tr=http%3A%2F%2Ftracker3"), + "&dn=aria2-test" + "&tr=http%3A%2F%2Ftracker1" + "&tr=http%3A%2F%2Ftracker2" + "&tr=http%3A%2F%2Ftracker3"), torrent2Magnet(dctx->getAttribute(BITTORRENT))); } diff --git a/test/BtBitfieldMessageTest.cc b/test/BtBitfieldMessageTest.cc index 5f51c6c9..8fa09e8f 100644 --- a/test/BtBitfieldMessageTest.cc +++ b/test/BtBitfieldMessageTest.cc @@ -87,10 +87,10 @@ void BtBitfieldMessageTest::testDoReceivedAction() { msg.setBitfield(bitfield, sizeof(bitfield)); CPPUNIT_ASSERT_EQUAL(std::string("0000"), util::toHex(peer->getBitfield(), - peer->getBitfieldLength())); + peer->getBitfieldLength())); msg.doReceivedAction(); CPPUNIT_ASSERT_EQUAL(std::string("ffff"), util::toHex(peer->getBitfield(), - peer->getBitfieldLength())); + peer->getBitfieldLength())); } void BtBitfieldMessageTest::testDoReceivedAction_goodByeSeeder() diff --git a/test/BtCancelMessageTest.cc b/test/BtCancelMessageTest.cc index b5127a16..07fa0dee 100644 --- a/test/BtCancelMessageTest.cc +++ b/test/BtCancelMessageTest.cc @@ -37,8 +37,8 @@ public: size_t length; public: MockBtMessageDispatcher2():index(0), - begin(0), - length(0) {} + begin(0), + length(0) {} virtual void doCancelSendingPieceAction(size_t index, uint32_t begin, size_t length) { this->index = index; diff --git a/test/BtDependencyTest.cc b/test/BtDependencyTest.cc index d1dc1f77..aa4670d9 100644 --- a/test/BtDependencyTest.cc +++ b/test/BtDependencyTest.cc @@ -94,7 +94,7 @@ void BtDependencyTest::testResolve() const SharedHandle<FileEntry>& firstFileEntry = dependant->getDownloadContext()->getFirstFileEntry(); CPPUNIT_ASSERT_EQUAL(std::string("/tmp/outfile.path"), - firstFileEntry->getPath()); + firstFileEntry->getPath()); CPPUNIT_ASSERT_EQUAL((size_t)1, firstFileEntry->getRemainingUris().size()); } @@ -139,7 +139,7 @@ void BtDependencyTest::testResolve_loadError() CPPUNIT_ASSERT (!dependant->getDownloadContext()->hasAttribute(bittorrent::BITTORRENT)); CPPUNIT_ASSERT_EQUAL(std::string("/tmp/outfile.path"), - dependant->getFirstFilePath()); + dependant->getFirstFilePath()); } void BtDependencyTest::testResolve_dependeeFailure() @@ -153,7 +153,7 @@ void BtDependencyTest::testResolve_dependeeFailure() CPPUNIT_ASSERT (!dependant->getDownloadContext()->hasAttribute(bittorrent::BITTORRENT)); CPPUNIT_ASSERT_EQUAL(std::string("/tmp/outfile.path"), - dependant->getFirstFilePath()); + dependant->getFirstFilePath()); } void BtDependencyTest::testResolve_dependeeInProgress() @@ -167,7 +167,7 @@ void BtDependencyTest::testResolve_dependeeInProgress() BtDependency dep(dependant, dependee); CPPUNIT_ASSERT(!dep.resolve()); CPPUNIT_ASSERT_EQUAL(std::string("/tmp/outfile.path"), - dependant->getFirstFilePath()); + dependant->getFirstFilePath()); } } // namespace aria2 diff --git a/test/BtExtendedMessageTest.cc b/test/BtExtendedMessageTest.cc index c1d29daf..ce32c69b 100644 --- a/test/BtExtendedMessageTest.cc +++ b/test/BtExtendedMessageTest.cc @@ -46,8 +46,8 @@ void BtExtendedMessageTest::testCreate() { msg[5] = 1; // Set dummy extended message ID 1 memcpy(msg+6, payload.c_str(), payload.size()); SharedHandle<BtExtendedMessage> pm = BtExtendedMessage::create(exmsgFactory, - peer, - &msg[4], 13); + peer, + &msg[4], 13); CPPUNIT_ASSERT_EQUAL((uint8_t)20, pm->getId()); // case: payload size is wrong diff --git a/test/BtHandshakeMessageTest.cc b/test/BtHandshakeMessageTest.cc index b49f2227..1eca38bf 100644 --- a/test/BtHandshakeMessageTest.cc +++ b/test/BtHandshakeMessageTest.cc @@ -39,18 +39,18 @@ CPPUNIT_TEST_SUITE_REGISTRATION(BtHandshakeMessageTest); void createHandshakeMessageData(unsigned char* msg) { msg[0] = 19; memcpy(&msg[1], BtHandshakeMessageTest::BTPSTR.c_str(), - BtHandshakeMessageTest::BTPSTR.size()); + BtHandshakeMessageTest::BTPSTR.size()); unsigned char reserved[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x04 }; memcpy(&msg[20], reserved, sizeof(reserved)); unsigned char infoHash[] = { 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff }; + 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff }; memcpy(&msg[28], infoHash, sizeof(infoHash)); unsigned char peerId[] = { 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, - 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, - 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, - 0xf0, 0xf0, 0xf0, 0xf0, 0xf0 }; + 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, + 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, + 0xf0, 0xf0, 0xf0, 0xf0, 0xf0 }; memcpy(&msg[48], peerId, sizeof(peerId)); } @@ -61,24 +61,24 @@ void BtHandshakeMessageTest::testCreate() { 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)); + 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() { unsigned char infoHash[] = { 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff }; + 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff }; unsigned char peerId[] = { 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, - 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, - 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, - 0xf0, 0xf0, 0xf0, 0xf0, 0xf0 }; + 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, + 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, + 0xf0, 0xf0, 0xf0, 0xf0, 0xf0 }; SharedHandle<BtHandshakeMessage> msg(new BtHandshakeMessage()); msg->setInfoHash(infoHash); @@ -87,18 +87,18 @@ 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)); + util::toHex((const unsigned char*)msg->getMessage(), 68)); } void BtHandshakeMessageTest::testToString() { unsigned char infoHash[] = { 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff }; + 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff }; unsigned char peerId[] = { 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, - 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, - 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, - 0xf0, 0xf0, 0xf0, 0xf0, 0xf0 }; + 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, + 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, + 0xf0, 0xf0, 0xf0, 0xf0, 0xf0 }; BtHandshakeMessage msg; msg.setInfoHash(infoHash); diff --git a/test/BtPieceMessageTest.cc b/test/BtPieceMessageTest.cc index 0c7c749b..9ba3958e 100644 --- a/test/BtPieceMessageTest.cc +++ b/test/BtPieceMessageTest.cc @@ -65,8 +65,8 @@ public: public: virtual SharedHandle<BtMessage> createRejectMessage(size_t index, - uint32_t begin, - size_t length) { + uint32_t begin, + size_t length) { SharedHandle<MockBtMessage2> msg(new MockBtMessage2(index, begin, length)); return msg; } @@ -83,7 +83,7 @@ public: peer.reset(new Peer("host", 6969)); peer->allocateSessionResource(_dctx->getPieceLength(), - _dctx->getTotalLength()); + _dctx->getTotalLength()); btMessageDispatcher.reset(new MockBtMessageDispatcher()); _btMessageFactory.reset(new MockBtMessageFactory2()); @@ -292,7 +292,7 @@ void BtPieceMessageTest::testCancelSendingPieceEvent_sendingInProgress() { void BtPieceMessageTest::testToString() { CPPUNIT_ASSERT_EQUAL(std::string("piece index=1, begin=1024, length=16384"), - msg->toString()); + msg->toString()); } } // namespace aria2 diff --git a/test/BtPostDownloadHandlerTest.cc b/test/BtPostDownloadHandlerTest.cc index cfcc73fb..2cc732cd 100644 --- a/test/BtPostDownloadHandlerTest.cc +++ b/test/BtPostDownloadHandlerTest.cc @@ -78,7 +78,7 @@ void BtPostDownloadHandlerTest::testGetNextRequestGroups() (std::string("248d0a1cd08284299de78d5c1ed359bb46717d8c"), bittorrent::getInfoHashString(groups.front()->getDownloadContext())); CPPUNIT_ASSERT(std::find(rg.followedBy().begin(), rg.followedBy().end(), - groups.front()->getGID()) != rg.followedBy().end()); + groups.front()->getGID()) != rg.followedBy().end()); } } // namespace aria2 diff --git a/test/BtRegistryTest.cc b/test/BtRegistryTest.cc index 79912913..7ddfd63c 100644 --- a/test/BtRegistryTest.cc +++ b/test/BtRegistryTest.cc @@ -74,7 +74,7 @@ void BtRegistryTest::testGetDownloadContext_infoHash() CPPUNIT_ASSERT(!btRegistry.getDownloadContext("hash1").isNull()); CPPUNIT_ASSERT(btRegistry.getDownloadContext("hash1").get() == - btRegistry.getDownloadContext(1).get()); + btRegistry.getDownloadContext(1).get()); CPPUNIT_ASSERT(btRegistry.getDownloadContext("not exists").isNull()); } diff --git a/test/BtRejectMessageTest.cc b/test/BtRejectMessageTest.cc index ad5f9f2b..475c58cb 100644 --- a/test/BtRejectMessageTest.cc +++ b/test/BtRejectMessageTest.cc @@ -42,20 +42,20 @@ public: } virtual RequestSlot getOutstandingRequest(size_t index, uint32_t begin, - size_t length) { + size_t length) { if(slot.getIndex() == index && slot.getBegin() == begin && - slot.getLength() == length) { - return slot; + slot.getLength() == length) { + return slot; } else { - return RequestSlot::nullSlot; + return RequestSlot::nullSlot; } } virtual void removeOutstandingRequest(const RequestSlot& slot) { if(this->slot.getIndex() == slot.getIndex() && - this->slot.getBegin() == slot.getBegin() && - this->slot.getLength() == slot.getLength()) { - this->slot = RequestSlot::nullSlot; + this->slot.getBegin() == slot.getBegin() && + this->slot.getLength() == slot.getLength()) { + this->slot = RequestSlot::nullSlot; } } }; @@ -171,7 +171,7 @@ void BtRejectMessageTest::testDoReceivedActionFastExtensionDisabled() { void BtRejectMessageTest::testToString() { CPPUNIT_ASSERT_EQUAL(std::string("reject index=1, begin=16, length=32"), - msg->toString()); + msg->toString()); } } // namespace aria2 diff --git a/test/BtRequestMessageTest.cc b/test/BtRequestMessageTest.cc index b8435675..8314b0f8 100644 --- a/test/BtRequestMessageTest.cc +++ b/test/BtRequestMessageTest.cc @@ -69,7 +69,7 @@ public: size_t length; public: MockBtMessage2(std::string type, size_t index, uint32_t begin, - size_t length) + size_t length) : type(type), index(index), begin(begin), length(length) {} }; @@ -81,14 +81,14 @@ public: virtual SharedHandle<BtMessage> createPieceMessage(size_t index, uint32_t begin, size_t length) { SharedHandle<MockBtMessage2> btMsg - (new MockBtMessage2("piece", index, begin, length)); + (new MockBtMessage2("piece", index, begin, length)); return btMsg; } virtual SharedHandle<BtMessage> createRejectMessage(size_t index, uint32_t begin, size_t length) { SharedHandle<MockBtMessage2> btMsg - (new MockBtMessage2("reject", index, begin, length)); + (new MockBtMessage2("reject", index, begin, length)); return btMsg; } }; @@ -261,7 +261,7 @@ void BtRequestMessageTest::testHandleAbortRequestEvent_sendingInProgress() { void BtRequestMessageTest::testToString() { CPPUNIT_ASSERT_EQUAL(std::string("request index=1, begin=16, length=32"), - msg->toString()); + msg->toString()); } void BtRequestMessageTest::testValidate() { @@ -285,7 +285,7 @@ void BtRequestMessageTest::testValidate_lengthTooLong() { CPPUNIT_FAIL("exception must be thrown."); } catch(DlAbortEx& e) { CPPUNIT_ASSERT_EQUAL(std::string("Length too long: 16385 > 16KB"), - std::string(e.what())); + std::string(e.what())); } } diff --git a/test/BtSuggestPieceMessageTest.cc b/test/BtSuggestPieceMessageTest.cc index 2f53fc67..cdb0b95d 100644 --- a/test/BtSuggestPieceMessageTest.cc +++ b/test/BtSuggestPieceMessageTest.cc @@ -68,7 +68,7 @@ void BtSuggestPieceMessageTest::testToString() { msg.setIndex(12345); CPPUNIT_ASSERT_EQUAL(std::string("suggest piece index=12345"), - msg.toString()); + msg.toString()); } } // namespace aria2 diff --git a/test/ChunkedDecoderTest.cc b/test/ChunkedDecoderTest.cc index dd1b1c2b..eb54fd88 100644 --- a/test/ChunkedDecoderTest.cc +++ b/test/ChunkedDecoderTest.cc @@ -34,7 +34,7 @@ void ChunkedDecoderTest::testDecode() std::basic_string<unsigned char> msg = reinterpret_cast<const unsigned char*>("a\r\n1234567890\r\n"); CPPUNIT_ASSERT_EQUAL(std::string("1234567890"), - decoder.decode(msg.c_str(), msg.size())); + decoder.decode(msg.c_str(), msg.size())); } // Feed extension; see it is ignored. { @@ -42,33 +42,33 @@ void ChunkedDecoderTest::testDecode() reinterpret_cast<const unsigned char*> ("3;extensionIgnored\r\n123\r\n"); CPPUNIT_ASSERT_EQUAL(std::string("123"), - decoder.decode(msg.c_str(), msg.size())); + decoder.decode(msg.c_str(), msg.size())); } // Not all chunk size is available { std::basic_string<unsigned char> msg = reinterpret_cast<const unsigned char*>("1"); CPPUNIT_ASSERT_EQUAL(std::string(), - decoder.decode(msg.c_str(), msg.size())); + decoder.decode(msg.c_str(), msg.size())); } { std::basic_string<unsigned char> msg = reinterpret_cast<const unsigned char*>("0\r\n1234567890123456\r\n"); CPPUNIT_ASSERT_EQUAL(std::string("1234567890123456"), - decoder.decode(msg.c_str(), msg.size())); + decoder.decode(msg.c_str(), msg.size())); } // Not all chunk data is available { std::basic_string<unsigned char> msg = reinterpret_cast<const unsigned char*>("10\r\n1234567890"); CPPUNIT_ASSERT_EQUAL(std::string("1234567890"), - decoder.decode(msg.c_str(), msg.size())); + decoder.decode(msg.c_str(), msg.size())); } { std::basic_string<unsigned char> msg = reinterpret_cast<const unsigned char*>("123456\r\n"); CPPUNIT_ASSERT_EQUAL(std::string("123456"), - decoder.decode(msg.c_str(), msg.size())); + decoder.decode(msg.c_str(), msg.size())); } // no trailing CR LF. { @@ -76,7 +76,7 @@ void ChunkedDecoderTest::testDecode() reinterpret_cast<const unsigned char*> ("10\r\n1234567890123456"); CPPUNIT_ASSERT_EQUAL(std::string("1234567890123456"), - decoder.decode(msg.c_str(), msg.size())); + decoder.decode(msg.c_str(), msg.size())); } // feed only CR { @@ -84,7 +84,7 @@ void ChunkedDecoderTest::testDecode() reinterpret_cast<const unsigned char*> ("\r"); CPPUNIT_ASSERT_EQUAL(std::string(), - decoder.decode(msg.c_str(), msg.size())); + decoder.decode(msg.c_str(), msg.size())); } // feed next LF { @@ -92,7 +92,7 @@ void ChunkedDecoderTest::testDecode() reinterpret_cast<const unsigned char*> ("\n"); CPPUNIT_ASSERT_EQUAL(std::string(), - decoder.decode(msg.c_str(), msg.size())); + decoder.decode(msg.c_str(), msg.size())); } // feed 0 CR LF. { @@ -100,7 +100,7 @@ void ChunkedDecoderTest::testDecode() reinterpret_cast<const unsigned char*> ("0\r\n"); CPPUNIT_ASSERT_EQUAL(std::string(), - decoder.decode(msg.c_str(), msg.size())); + decoder.decode(msg.c_str(), msg.size())); } // input is over CPPUNIT_ASSERT(decoder.finished()); diff --git a/test/CookieStorageTest.cc b/test/CookieStorageTest.cc index 29044a6b..fa15a3d9 100644 --- a/test/CookieStorageTest.cc +++ b/test/CookieStorageTest.cc @@ -83,13 +83,13 @@ void CookieStorageTest::testStore() CPPUNIT_ASSERT(st.store(sessionScopedGoodCookie)); CPPUNIT_ASSERT_EQUAL((size_t)3, st.size()); CPPUNIT_ASSERT(std::find(st.begin(), st.end(), - sessionScopedGoodCookie) != st.end()); + sessionScopedGoodCookie) != st.end()); Cookie sessionScopedGoodCookie2("k2", "v3", "/", "localhost", false); CPPUNIT_ASSERT(st.store(sessionScopedGoodCookie2)); CPPUNIT_ASSERT_EQUAL((size_t)4, st.size()); CPPUNIT_ASSERT(std::find(st.begin(), st.end(), - sessionScopedGoodCookie2) != st.end()); + sessionScopedGoodCookie2) != st.end()); } void CookieStorageTest::testParseAndStore() @@ -100,12 +100,12 @@ void CookieStorageTest::testParseAndStore() " expires=Fri, 2038-01-01 00:00:00 GMT; path=/; domain=localhost;"; CPPUNIT_ASSERT(st.parseAndStore(localhostCookieStr, - "localhost", "/downloads")); + "localhost", "/downloads")); CPPUNIT_ASSERT(!st.parseAndStore(localhostCookieStr, - "mirror", "/downloads")); + "mirror", "/downloads")); CPPUNIT_ASSERT(!st.parseAndStore(localhostCookieStr, - "127.0.0.1", "/downloads")); + "127.0.0.1", "/downloads")); std::string numericHostCookieStr = "k=v;" " expires=Fri, 2038-01-01 00:00:00 GMT; path=/; domain=192.168.1.1;"; @@ -119,7 +119,7 @@ void CookieStorageTest::testCriteriaFind() Cookie alpha("alpha", "ALPHA", "/", ".aria2.org", false); Cookie bravo("bravo", "BRAVO", Time().getTime()+60, "/foo", ".aria2.org", - false); + false); Cookie charlie("charlie", "CHARLIE", "/", ".aria2.org", true); Cookie delta("delta", "DELTA", "/foo/bar", ".aria2.org", false); Cookie echo("echo", "ECHO", "/", "www.aria2.org", false); @@ -135,37 +135,37 @@ void CookieStorageTest::testCriteriaFind() CPPUNIT_ASSERT(st.store(golf)); std::deque<Cookie> aria2Slash = st.criteriaFind("www.aria2.org", "/", - 0, false); + 0, false); CPPUNIT_ASSERT_EQUAL((size_t)2, aria2Slash.size()); CPPUNIT_ASSERT(std::find(aria2Slash.begin(), aria2Slash.end(), alpha) - != aria2Slash.end()); + != aria2Slash.end()); CPPUNIT_ASSERT(std::find(aria2Slash.begin(), aria2Slash.end(), echo) - != aria2Slash.end()); + != aria2Slash.end()); std::deque<Cookie> aria2SlashFoo = st.criteriaFind("www.aria2.org", "/foo", - 0, false); + 0, false); CPPUNIT_ASSERT_EQUAL((size_t)3, aria2SlashFoo.size()); CPPUNIT_ASSERT_EQUAL(std::string("bravo"), aria2SlashFoo[0].getName()); CPPUNIT_ASSERT(std::find(aria2SlashFoo.begin(), aria2SlashFoo.end(), alpha) - != aria2SlashFoo.end()); + != aria2SlashFoo.end()); CPPUNIT_ASSERT(std::find(aria2SlashFoo.begin(), aria2SlashFoo.end(), echo) - != aria2SlashFoo.end()); + != aria2SlashFoo.end()); std::deque<Cookie> aria2Expires = st.criteriaFind("www.aria2.org", "/foo", - Time().getTime()+120, - false); + Time().getTime()+120, + false); CPPUNIT_ASSERT_EQUAL((size_t)2, aria2Expires.size()); CPPUNIT_ASSERT(std::find(aria2Expires.begin(), aria2Expires.end(), alpha) - != aria2Expires.end()); + != aria2Expires.end()); CPPUNIT_ASSERT(std::find(aria2Expires.begin(), aria2Expires.end(), echo) - != aria2Expires.end()); + != aria2Expires.end()); std::deque<Cookie> dlAria2 = st.criteriaFind("dl.aria2.org", "/", 0, false); CPPUNIT_ASSERT_EQUAL((size_t)1, dlAria2.size()); CPPUNIT_ASSERT_EQUAL(std::string("alpha"), dlAria2[0].getName()); std::deque<Cookie> numericHostCookies = st.criteriaFind("192.168.1.1", "/", 0, - false); + false); CPPUNIT_ASSERT_EQUAL((size_t)1, numericHostCookies.size()); CPPUNIT_ASSERT_EQUAL(std::string("golf"), numericHostCookies[0].getName()); } diff --git a/test/DHKeyExchangeTest.cc b/test/DHKeyExchangeTest.cc index 4ec10ecf..f16cb112 100644 --- a/test/DHKeyExchangeTest.cc +++ b/test/DHKeyExchangeTest.cc @@ -49,7 +49,7 @@ void DHKeyExchangeTest::testHandshake() dhB.computeSecret(secretB, sizeof(secretB), publicKeyA, sizeof(publicKeyA)); CPPUNIT_ASSERT_EQUAL(util::toHex(secretA, sizeof(secretA)), - util::toHex(secretB, sizeof(secretB))); + util::toHex(secretB, sizeof(secretB))); } } // namespace aria2 diff --git a/test/DHTAnnouncePeerMessageTest.cc b/test/DHTAnnouncePeerMessageTest.cc index e1908154..67eab08b 100644 --- a/test/DHTAnnouncePeerMessageTest.cc +++ b/test/DHTAnnouncePeerMessageTest.cc @@ -30,7 +30,7 @@ public: class MockDHTMessageFactory2:public MockDHTMessageFactory { virtual SharedHandle<DHTMessage> createAnnouncePeerReplyMessage(const SharedHandle<DHTNode>& remoteNode, - const std::string& transactionID) + const std::string& transactionID) { return SharedHandle<DHTMessage>(new MockDHTMessage(_localNode, remoteNode, "announce_peer", transactionID)); } @@ -71,7 +71,7 @@ void DHTAnnouncePeerMessageTest::testGetBencodedMessage() dict["a"] = aDict; CPPUNIT_ASSERT_EQUAL(util::urlencode(bencode::encode(dict)), - util::urlencode(msgbody)); + util::urlencode(msgbody)); } void DHTAnnouncePeerMessageTest::testDoReceivedAction() @@ -98,7 +98,7 @@ void DHTAnnouncePeerMessageTest::testDoReceivedAction() DHTAnnouncePeerMessage msg(localNode, remoteNode, infoHash, port, token, transactionID); msg.setPeerAnnounceStorage(WeakHandle<DHTPeerAnnounceStorage> - (&peerAnnounceStorage)); + (&peerAnnounceStorage)); msg.setMessageFactory(WeakHandle<DHTMessageFactory>(&factory)); msg.setMessageDispatcher(WeakHandle<DHTMessageDispatcher>(&dispatcher)); diff --git a/test/DHTBucketTest.cc b/test/DHTBucketTest.cc index 3ee56497..5db4e879 100644 --- a/test/DHTBucketTest.cc +++ b/test/DHTBucketTest.cc @@ -48,9 +48,9 @@ CPPUNIT_TEST_SUITE_REGISTRATION(DHTBucketTest); void DHTBucketTest::testGetRandomNodeID() { unsigned char localNodeID[] = { 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00 }; + 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00 }; SharedHandle<DHTNode> localNode(new DHTNode(localNodeID)); { DHTBucket bucket(localNode); @@ -59,33 +59,33 @@ void DHTBucketTest::testGetRandomNodeID() } { unsigned char max[] = { 0x01, 0x01, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff }; + 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff }; unsigned char min[] = { 0x01, 0x01, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00 }; + 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00 }; DHTBucket bucket(16, max, min, localNode); 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)); } } void DHTBucketTest::testIsInRange() { unsigned char localNodeID[] = { 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00 }; + 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00 }; SharedHandle<DHTNode> localNode(new DHTNode(localNodeID)); { unsigned char nodeID[] = { 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00 }; + 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00 }; SharedHandle<DHTNode> node(new DHTNode(nodeID)); DHTBucket bucket(localNode); CPPUNIT_ASSERT(bucket.isInRange(node)); @@ -94,19 +94,19 @@ void DHTBucketTest::testIsInRange() } { unsigned char max[] = { 0x01, 0x01, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff }; + 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff }; unsigned char min[] = { 0x01, 0x01, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00 }; + 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00 }; { //min unsigned char nodeID[] = { 0x01, 0x01, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00 }; + 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00 }; SharedHandle<DHTNode> node(new DHTNode(nodeID)); DHTBucket bucket(16, max, min, localNode); CPPUNIT_ASSERT(bucket.isInRange(node)); @@ -114,18 +114,18 @@ void DHTBucketTest::testIsInRange() { //max unsigned char nodeID[] = { 0x01, 0x01, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff }; + 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff }; SharedHandle<DHTNode> node(new DHTNode(nodeID)); DHTBucket bucket(16, max, min, localNode); CPPUNIT_ASSERT(bucket.isInRange(node)); } { unsigned char nodeID[] = { 0x01, 0x01, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, - 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff }; + 0x00, 0x00, 0x00, 0x00, 0x00, + 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff }; SharedHandle<DHTNode> node(new DHTNode(nodeID)); DHTBucket bucket(16, max, min, localNode); CPPUNIT_ASSERT(bucket.isInRange(node)); @@ -133,9 +133,9 @@ void DHTBucketTest::testIsInRange() { // nodeID is out of range: smaller than this range unsigned char nodeID[] = { 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00 }; + 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00 }; SharedHandle<DHTNode> node(new DHTNode(nodeID)); DHTBucket bucket(16, max, min, localNode); CPPUNIT_ASSERT(!bucket.isInRange(node)); @@ -143,9 +143,9 @@ void DHTBucketTest::testIsInRange() { // nodeID is out of range: larger than this range unsigned char nodeID[] = { 0x01, 0x02, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff }; + 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff }; SharedHandle<DHTNode> node(new DHTNode(nodeID)); DHTBucket bucket(16, max, min, localNode); CPPUNIT_ASSERT(!bucket.isInRange(node)); @@ -157,36 +157,36 @@ void DHTBucketTest::testSplitAllowed() { { unsigned char localNodeID[] = { 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00 }; + 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00 }; SharedHandle<DHTNode> localNode(new DHTNode(localNodeID)); DHTBucket bucket(localNode); CPPUNIT_ASSERT(bucket.splitAllowed()); } { unsigned char max[] = { 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff }; + 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff }; unsigned char min[] = { 0xe0, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00 }; + 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00 }; { unsigned char localNodeID[] = { 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00 }; + 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00 }; SharedHandle<DHTNode> localNode(new DHTNode(localNodeID)); DHTBucket bucket(3, max, min, localNode); CPPUNIT_ASSERT(!bucket.splitAllowed()); } { unsigned char localNodeID[] = { 0xe0, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x01 }; + 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x01 }; SharedHandle<DHTNode> localNode(new DHTNode(localNodeID)); DHTBucket bucket(3, max, min, localNode); CPPUNIT_ASSERT(bucket.splitAllowed()); @@ -204,51 +204,51 @@ void DHTBucketTest::testSplit() DHTBucket bucket(localNode); SharedHandle<DHTBucket> r = bucket.split(); { - unsigned char expectedRMax[] = { 0x7f, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, - 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((size_t)1, r->getPrefixLength()); + unsigned char expectedRMax[] = { 0x7f, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, + 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((size_t)1, r->getPrefixLength()); } { - unsigned char expectedLMax[DHT_ID_LENGTH]; - memset(expectedLMax, 0xff, DHT_ID_LENGTH); - unsigned char expectedLMin[] = { 0x80, 0x00, 0x00, 0x00, 0x00, - 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((size_t)1, bucket.getPrefixLength()); + unsigned char expectedLMax[DHT_ID_LENGTH]; + memset(expectedLMax, 0xff, DHT_ID_LENGTH); + unsigned char expectedLMin[] = { 0x80, 0x00, 0x00, 0x00, 0x00, + 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((size_t)1, bucket.getPrefixLength()); } } { SharedHandle<DHTBucket> bucket(new DHTBucket(localNode)); for(int i = 0; i < 159; ++i) { - CPPUNIT_ASSERT(bucket->splitAllowed()); - SharedHandle<DHTBucket> t = bucket; - bucket = bucket->split(); - CPPUNIT_ASSERT(!t->splitAllowed()); + CPPUNIT_ASSERT(bucket->splitAllowed()); + SharedHandle<DHTBucket> t = bucket; + bucket = bucket->split(); + CPPUNIT_ASSERT(!t->splitAllowed()); } CPPUNIT_ASSERT(!bucket->splitAllowed()); unsigned char expectedMax[] = { 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x01 }; + 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, + 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)); + util::toHex(bucket->getMaxID(), DHT_ID_LENGTH)); CPPUNIT_ASSERT_EQUAL(util::toHex(expectedMin, DHT_ID_LENGTH), - util::toHex(bucket->getMinID(), DHT_ID_LENGTH)); + util::toHex(bucket->getMinID(), DHT_ID_LENGTH)); CPPUNIT_ASSERT_EQUAL((size_t)159, bucket->getPrefixLength()); } } @@ -261,28 +261,28 @@ void DHTBucketTest::testSplit() SharedHandle<DHTBucket> r = bucket.split(); { unsigned char expectedRMax[] = { 0x7f, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff }; + 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, + 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)); + util::toHex(r->getMaxID(), DHT_ID_LENGTH)); CPPUNIT_ASSERT_EQUAL(util::toHex(expectedRMin, DHT_ID_LENGTH), - util::toHex(r->getMinID(), DHT_ID_LENGTH)); + util::toHex(r->getMinID(), DHT_ID_LENGTH)); CPPUNIT_ASSERT_EQUAL((size_t)1, r->getPrefixLength()); } { unsigned char expectedLMax[DHT_ID_LENGTH]; memset(expectedLMax, 0xff, DHT_ID_LENGTH); unsigned char expectedLMin[] = { 0x80, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00 }; + 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)); + util::toHex(bucket.getMaxID(), DHT_ID_LENGTH)); CPPUNIT_ASSERT_EQUAL(util::toHex(expectedLMin, DHT_ID_LENGTH), - util::toHex(bucket.getMinID(), DHT_ID_LENGTH)); + util::toHex(bucket.getMinID(), DHT_ID_LENGTH)); CPPUNIT_ASSERT_EQUAL((size_t)1, bucket.getPrefixLength()); } } diff --git a/test/DHTConnectionImplTest.cc b/test/DHTConnectionImplTest.cc index 9bc5b03a..15a66a16 100644 --- a/test/DHTConnectionImplTest.cc +++ b/test/DHTConnectionImplTest.cc @@ -36,7 +36,7 @@ void DHTConnectionImplTest::testWriteAndReadData() std::string message1 = "hello world."; // hostname should be "localhost", not 127.0.0.1. Test failed on Mac OSX10.5 con1.sendMessage(reinterpret_cast<const unsigned char*>(message1.c_str()), - message1.size(), "localhost", con2port); + message1.size(), "localhost", con2port); unsigned char readbuffer[100]; std::string remoteHost; @@ -46,7 +46,7 @@ void DHTConnectionImplTest::testWriteAndReadData() ssize_t rlength = con2.receiveMessage(readbuffer, sizeof(readbuffer), remoteHost, remotePort); CPPUNIT_ASSERT_EQUAL((ssize_t)message1.size(), rlength); CPPUNIT_ASSERT_EQUAL(message1, - std::string(&readbuffer[0], &readbuffer[rlength])); + std::string(&readbuffer[0], &readbuffer[rlength])); } } catch(Exception& e) { CPPUNIT_FAIL(e.stackTrace()); diff --git a/test/DHTFindNodeMessageTest.cc b/test/DHTFindNodeMessageTest.cc index 8e01b2b3..f8491813 100644 --- a/test/DHTFindNodeMessageTest.cc +++ b/test/DHTFindNodeMessageTest.cc @@ -31,11 +31,11 @@ public: public: virtual SharedHandle<DHTMessage> createFindNodeReplyMessage(const SharedHandle<DHTNode>& remoteNode, - const std::deque<SharedHandle<DHTNode> >& closestKNodes, - const std::string& transactionID) + const std::deque<SharedHandle<DHTNode> >& closestKNodes, + const std::string& transactionID) { SharedHandle<MockDHTMessage> m - (new MockDHTMessage(_localNode, remoteNode, "find_node", transactionID)); + (new MockDHTMessage(_localNode, remoteNode, "find_node", transactionID)); m->_nodes = closestKNodes; return m; } diff --git a/test/DHTFindNodeReplyMessageTest.cc b/test/DHTFindNodeReplyMessageTest.cc index e5bba6b1..1998bce8 100644 --- a/test/DHTFindNodeReplyMessageTest.cc +++ b/test/DHTFindNodeReplyMessageTest.cc @@ -47,7 +47,7 @@ void DHTFindNodeReplyMessageTest::testGetBencodedMessage() unsigned char buf[6]; CPPUNIT_ASSERT(bittorrent::createcompact - (buf, nodes[i]->getIPAddress(), nodes[i]->getPort())); + (buf, nodes[i]->getIPAddress(), nodes[i]->getPort())); compactNodeInfo += std::string(&nodes[i]->getID()[0], &nodes[i]->getID()[DHT_ID_LENGTH])+ std::string(&buf[0], &buf[sizeof(buf)]); diff --git a/test/DHTGetPeersMessageTest.cc b/test/DHTGetPeersMessageTest.cc index 28c5d229..9a8ae5fc 100644 --- a/test/DHTGetPeersMessageTest.cc +++ b/test/DHTGetPeersMessageTest.cc @@ -33,12 +33,12 @@ public: public: virtual SharedHandle<DHTMessage> createGetPeersReplyMessage(const SharedHandle<DHTNode>& remoteNode, - const std::deque<SharedHandle<Peer> >& peers, - const std::string& token, - const std::string& transactionID) + const std::deque<SharedHandle<Peer> >& peers, + const std::string& token, + const std::string& transactionID) { SharedHandle<MockDHTMessage> m - (new MockDHTMessage(_localNode, remoteNode, "get_peers", transactionID)); + (new MockDHTMessage(_localNode, remoteNode, "get_peers", transactionID)); m->_peers = peers; m->_token = token; return m; @@ -46,12 +46,12 @@ public: virtual SharedHandle<DHTMessage> createGetPeersReplyMessage(const SharedHandle<DHTNode>& remoteNode, - const std::deque<SharedHandle<DHTNode> >& closestKNodes, - const std::string& token, - const std::string& transactionID) + const std::deque<SharedHandle<DHTNode> >& closestKNodes, + const std::string& token, + const std::string& transactionID) { SharedHandle<MockDHTMessage> m - (new MockDHTMessage(_localNode, remoteNode, "get_peers", transactionID)); + (new MockDHTMessage(_localNode, remoteNode, "get_peers", transactionID)); m->_nodes = closestKNodes; m->_token = token; return m; @@ -89,7 +89,7 @@ void DHTGetPeersMessageTest::testGetBencodedMessage() dict["a"] = aDict; CPPUNIT_ASSERT_EQUAL(util::urlencode(bencode::encode(dict)), - util::urlencode(msgbody)); + util::urlencode(msgbody)); } void DHTGetPeersMessageTest::testDoReceivedAction() @@ -113,11 +113,11 @@ void DHTGetPeersMessageTest::testDoReceivedAction() DHTGetPeersMessage msg(localNode, remoteNode, infoHash, transactionID); msg.setTokenTracker(WeakHandle<DHTTokenTracker> - (&tokenTracker)); + (&tokenTracker)); msg.setMessageDispatcher(WeakHandle<DHTMessageDispatcher> - (&dispatcher)); + (&dispatcher)); msg.setMessageFactory(WeakHandle<DHTMessageFactory> - (&factory)); + (&factory)); { // localhost has peer contact information for that infohash. DHTPeerAnnounceStorage peerAnnounceStorage; @@ -125,7 +125,7 @@ void DHTGetPeersMessageTest::testDoReceivedAction() peerAnnounceStorage.addPeerAnnounce(infoHash, "192.168.0.101", 6889); msg.setPeerAnnounceStorage(WeakHandle<DHTPeerAnnounceStorage> - (&peerAnnounceStorage)); + (&peerAnnounceStorage)); msg.doReceivedAction(); @@ -159,9 +159,9 @@ void DHTGetPeersMessageTest::testDoReceivedAction() routingTable.addNode(returnNode1); msg.setPeerAnnounceStorage(WeakHandle<DHTPeerAnnounceStorage> - (&peerAnnounceStorage)); + (&peerAnnounceStorage)); msg.setRoutingTable(WeakHandle<DHTRoutingTable> - (&routingTable)); + (&routingTable)); msg.doReceivedAction(); diff --git a/test/DHTGetPeersReplyMessageTest.cc b/test/DHTGetPeersReplyMessageTest.cc index b3176365..a089604f 100644 --- a/test/DHTGetPeersReplyMessageTest.cc +++ b/test/DHTGetPeersReplyMessageTest.cc @@ -58,10 +58,10 @@ void DHTGetPeersReplyMessageTest::testGetBencodedMessage() unsigned char buf[6]; CPPUNIT_ASSERT(bittorrent::createcompact - (buf, nodes[i]->getIPAddress(), nodes[i]->getPort())); + (buf, nodes[i]->getIPAddress(), nodes[i]->getPort())); compactNodeInfo += - std::string(&nodes[i]->getID()[0], &nodes[i]->getID()[DHT_ID_LENGTH])+ - std::string(&buf[0], &buf[sizeof(buf)]); + std::string(&nodes[i]->getID()[0], &nodes[i]->getID()[DHT_ID_LENGTH])+ + std::string(&buf[0], &buf[sizeof(buf)]); } msg.setClosestKNodes (std::deque<SharedHandle<DHTNode> >(&nodes[0], &nodes[DHTBucket::K])); @@ -71,7 +71,7 @@ void DHTGetPeersReplyMessageTest::testGetBencodedMessage() rDict["nodes"] = compactNodeInfo; CPPUNIT_ASSERT_EQUAL(util::urlencode(bencode::encode(dict)), - util::urlencode(msgbody)); + util::urlencode(msgbody)); } rDict.removeKey("nodes"); { @@ -81,7 +81,7 @@ void DHTGetPeersReplyMessageTest::testGetBencodedMessage() SharedHandle<Peer> 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)); + (buffer, peer->ipaddr, peer->port)); valuesList << BDE(buffer, sizeof(buffer)); peers.push_back(peer); } @@ -91,7 +91,7 @@ void DHTGetPeersReplyMessageTest::testGetBencodedMessage() std::string msgbody = msg.getBencodedMessage(); CPPUNIT_ASSERT_EQUAL(util::urlencode(bencode::encode(dict)), - util::urlencode(msgbody)); + util::urlencode(msgbody)); } } diff --git a/test/DHTMessageFactoryImplTest.cc b/test/DHTMessageFactoryImplTest.cc index de0af760..407e940a 100644 --- a/test/DHTMessageFactoryImplTest.cc +++ b/test/DHTMessageFactoryImplTest.cc @@ -97,7 +97,7 @@ 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())); + util::toHex(m->getTransactionID())); } void DHTMessageFactoryImplTest::testCreatePingReplyMessage() @@ -116,13 +116,13 @@ void DHTMessageFactoryImplTest::testCreatePingReplyMessage() SharedHandle<DHTPingReplyMessage> m (dynamic_pointer_cast<DHTPingReplyMessage> (factory->createResponseMessage("ping", dict, - remoteNode->getIPAddress(), - remoteNode->getPort()))); + remoteNode->getIPAddress(), + remoteNode->getPort()))); CPPUNIT_ASSERT(localNode == m->getLocalNode()); CPPUNIT_ASSERT(remoteNode == m->getRemoteNode()); CPPUNIT_ASSERT_EQUAL(util::toHex(transactionID, DHT_TRANSACTION_ID_LENGTH), - util::toHex(m->getTransactionID())); + util::toHex(m->getTransactionID())); } void DHTMessageFactoryImplTest::testCreateFindNodeMessage() @@ -148,9 +148,9 @@ 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())); + util::toHex(m->getTransactionID())); CPPUNIT_ASSERT_EQUAL(util::toHex(targetNodeID, DHT_ID_LENGTH), - util::toHex(m->getTargetNodeID(), DHT_ID_LENGTH)); + util::toHex(m->getTargetNodeID(), DHT_ID_LENGTH)); } void DHTMessageFactoryImplTest::testCreateFindNodeReplyMessage() @@ -170,10 +170,10 @@ void DHTMessageFactoryImplTest::testCreateFindNodeReplyMessage() unsigned char buf[6]; CPPUNIT_ASSERT(bittorrent::createcompact - (buf, nodes[i]->getIPAddress(), nodes[i]->getPort())); + (buf, nodes[i]->getIPAddress(), nodes[i]->getPort())); compactNodeInfo += - std::string(&nodes[i]->getID()[0], &nodes[i]->getID()[DHT_ID_LENGTH])+ - std::string(&buf[0], &buf[sizeof(buf)]); + std::string(&nodes[i]->getID()[0], &nodes[i]->getID()[DHT_ID_LENGTH])+ + std::string(&buf[0], &buf[sizeof(buf)]); } rDict["nodes"] = compactNodeInfo; dict["r"] = rDict; @@ -185,8 +185,8 @@ void DHTMessageFactoryImplTest::testCreateFindNodeReplyMessage() SharedHandle<DHTFindNodeReplyMessage> m (dynamic_pointer_cast<DHTFindNodeReplyMessage> (factory->createResponseMessage("find_node", dict, - remoteNode->getIPAddress(), - remoteNode->getPort()))); + remoteNode->getIPAddress(), + remoteNode->getPort()))); CPPUNIT_ASSERT(localNode == m->getLocalNode()); CPPUNIT_ASSERT(remoteNode == m->getRemoteNode()); @@ -194,7 +194,7 @@ void DHTMessageFactoryImplTest::testCreateFindNodeReplyMessage() 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())); + util::toHex(m->getTransactionID())); } catch(Exception& e) { CPPUNIT_FAIL(e.stackTrace()); } @@ -223,9 +223,9 @@ 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())); + util::toHex(m->getTransactionID())); CPPUNIT_ASSERT_EQUAL(util::toHex(infoHash, DHT_ID_LENGTH), - util::toHex(m->getInfoHash(), DHT_ID_LENGTH)); + util::toHex(m->getInfoHash(), DHT_ID_LENGTH)); } void DHTMessageFactoryImplTest::testCreateGetPeersReplyMessage_nodes() @@ -245,10 +245,10 @@ void DHTMessageFactoryImplTest::testCreateGetPeersReplyMessage_nodes() unsigned char buf[6]; CPPUNIT_ASSERT(bittorrent::createcompact - (buf, nodes[i]->getIPAddress(), nodes[i]->getPort())); + (buf, nodes[i]->getIPAddress(), nodes[i]->getPort())); compactNodeInfo += - std::string(&nodes[i]->getID()[0], &nodes[i]->getID()[DHT_ID_LENGTH])+ - std::string(&buf[0], &buf[sizeof(buf)]); + std::string(&nodes[i]->getID()[0], &nodes[i]->getID()[DHT_ID_LENGTH])+ + std::string(&buf[0], &buf[sizeof(buf)]); } rDict["nodes"] = compactNodeInfo; rDict["token"] = BDE("token"); @@ -261,8 +261,8 @@ void DHTMessageFactoryImplTest::testCreateGetPeersReplyMessage_nodes() SharedHandle<DHTGetPeersReplyMessage> m (dynamic_pointer_cast<DHTGetPeersReplyMessage> (factory->createResponseMessage("get_peers", dict, - remoteNode->getIPAddress(), - remoteNode->getPort()))); + remoteNode->getIPAddress(), + remoteNode->getPort()))); CPPUNIT_ASSERT(localNode == m->getLocalNode()); CPPUNIT_ASSERT(remoteNode == m->getRemoteNode()); @@ -271,7 +271,7 @@ void DHTMessageFactoryImplTest::testCreateGetPeersReplyMessage_nodes() 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())); + util::toHex(m->getTransactionID())); } catch(Exception& e) { CPPUNIT_FAIL(e.stackTrace()); } @@ -292,7 +292,7 @@ void DHTMessageFactoryImplTest::testCreateGetPeersReplyMessage_values() SharedHandle<Peer> 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)); + (buffer, peer->ipaddr, peer->port)); valuesList << BDE(buffer, sizeof(buffer)); peers.push_back(peer); } @@ -307,8 +307,8 @@ void DHTMessageFactoryImplTest::testCreateGetPeersReplyMessage_values() SharedHandle<DHTGetPeersReplyMessage> m (dynamic_pointer_cast<DHTGetPeersReplyMessage> (factory->createResponseMessage("get_peers", dict, - remoteNode->getIPAddress(), - remoteNode->getPort()))); + remoteNode->getIPAddress(), + remoteNode->getPort()))); CPPUNIT_ASSERT(localNode == m->getLocalNode()); CPPUNIT_ASSERT(remoteNode == m->getRemoteNode()); @@ -317,7 +317,7 @@ void DHTMessageFactoryImplTest::testCreateGetPeersReplyMessage_values() 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())); + util::toHex(m->getTransactionID())); } catch(Exception& e) { CPPUNIT_FAIL(e.stackTrace()); } @@ -352,9 +352,9 @@ void DHTMessageFactoryImplTest::testCreateAnnouncePeerMessage() 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())); + util::toHex(m->getTransactionID())); CPPUNIT_ASSERT_EQUAL(util::toHex(infoHash, DHT_ID_LENGTH), - util::toHex(m->getInfoHash(), DHT_ID_LENGTH)); + util::toHex(m->getInfoHash(), DHT_ID_LENGTH)); CPPUNIT_ASSERT_EQUAL(port, m->getTCPPort()); } catch(Exception& e) { CPPUNIT_FAIL(e.stackTrace()); @@ -377,13 +377,13 @@ void DHTMessageFactoryImplTest::testCreateAnnouncePeerReplyMessage() SharedHandle<DHTAnnouncePeerReplyMessage> m (dynamic_pointer_cast<DHTAnnouncePeerReplyMessage> (factory->createResponseMessage("announce_peer", dict, - remoteNode->getIPAddress(), - remoteNode->getPort()))); + remoteNode->getIPAddress(), + remoteNode->getPort()))); CPPUNIT_ASSERT(localNode == m->getLocalNode()); CPPUNIT_ASSERT(remoteNode == m->getRemoteNode()); CPPUNIT_ASSERT_EQUAL(util::toHex(transactionID, DHT_TRANSACTION_ID_LENGTH), - util::toHex(m->getTransactionID())); + util::toHex(m->getTransactionID())); } void DHTMessageFactoryImplTest::testReceivedErrorMessage() @@ -402,8 +402,8 @@ void DHTMessageFactoryImplTest::testReceivedErrorMessage() try { factory->createResponseMessage("announce_peer", dict, - remoteNode->getIPAddress(), - remoteNode->getPort()); + remoteNode->getIPAddress(), + remoteNode->getPort()); CPPUNIT_FAIL("exception must be thrown."); } catch(RecoverableException& e) { std::cerr << e.stackTrace() << std::endl; diff --git a/test/DHTMessageTrackerEntryTest.cc b/test/DHTMessageTrackerEntryTest.cc index 891fd4b9..bb8f7628 100644 --- a/test/DHTMessageTrackerEntryTest.cc +++ b/test/DHTMessageTrackerEntryTest.cc @@ -43,11 +43,11 @@ void DHTMessageTrackerEntryTest::testMatch() DHTMessageTrackerEntry entry(msg1, 30); CPPUNIT_ASSERT(entry.match(msg1->getTransactionID(), - msg1->getRemoteNode()->getIPAddress(), - msg1->getRemoteNode()->getPort())); + msg1->getRemoteNode()->getIPAddress(), + msg1->getRemoteNode()->getPort())); CPPUNIT_ASSERT(!entry.match(msg2->getTransactionID(), - msg2->getRemoteNode()->getIPAddress(), - msg2->getRemoteNode()->getPort())); + msg2->getRemoteNode()->getIPAddress(), + msg2->getRemoteNode()->getPort())); } catch(Exception& e) { CPPUNIT_FAIL(e.stackTrace()); } diff --git a/test/DHTMessageTrackerTest.cc b/test/DHTMessageTrackerTest.cc index 0b8e49a4..c0d4fc5c 100644 --- a/test/DHTMessageTrackerTest.cc +++ b/test/DHTMessageTrackerTest.cc @@ -53,11 +53,11 @@ void DHTMessageTrackerTest::testMessageArrived() factory->setLocalNode(localNode); SharedHandle<MockDHTMessage> m1(new MockDHTMessage(localNode, - SharedHandle<DHTNode>(new DHTNode()))); + SharedHandle<DHTNode>(new DHTNode()))); SharedHandle<MockDHTMessage> m2(new MockDHTMessage(localNode, - SharedHandle<DHTNode>(new DHTNode()))); + SharedHandle<DHTNode>(new DHTNode()))); SharedHandle<MockDHTMessage> m3(new MockDHTMessage(localNode, - SharedHandle<DHTNode>(new DHTNode()))); + SharedHandle<DHTNode>(new DHTNode()))); m1->getRemoteNode()->setIPAddress("192.168.0.1"); m1->getRemoteNode()->setPort(6881); @@ -81,7 +81,7 @@ void DHTMessageTrackerTest::testMessageArrived() std::pair<SharedHandle<DHTMessage>, SharedHandle<DHTMessageCallback> > p = tracker.messageArrived(resDict, m2->getRemoteNode()->getIPAddress(), - m2->getRemoteNode()->getPort()); + m2->getRemoteNode()->getPort()); SharedHandle<DHTMessage> reply = p.first; CPPUNIT_ASSERT(!reply.isNull()); @@ -95,7 +95,7 @@ void DHTMessageTrackerTest::testMessageArrived() std::pair<SharedHandle<DHTMessage>, SharedHandle<DHTMessageCallback> > p = tracker.messageArrived(resDict, m3->getRemoteNode()->getIPAddress(), - m3->getRemoteNode()->getPort()); + m3->getRemoteNode()->getPort()); SharedHandle<DHTMessage> reply = p.first; CPPUNIT_ASSERT(!reply.isNull()); diff --git a/test/DHTPingMessageTest.cc b/test/DHTPingMessageTest.cc index e81983e6..edac47dd 100644 --- a/test/DHTPingMessageTest.cc +++ b/test/DHTPingMessageTest.cc @@ -30,12 +30,12 @@ public: public: virtual SharedHandle<DHTMessage> createPingReplyMessage(const SharedHandle<DHTNode>& remoteNode, - const unsigned char* remoteNodeID, - const std::string& transactionID) + const unsigned char* remoteNodeID, + const std::string& transactionID) { return SharedHandle<DHTMessage> - (new MockDHTMessage(_localNode, remoteNode, "ping_reply", - transactionID)); + (new MockDHTMessage(_localNode, remoteNode, "ping_reply", + transactionID)); } }; }; diff --git a/test/DHTRoutingTableDeserializerTest.cc b/test/DHTRoutingTableDeserializerTest.cc index f5026b8e..4e4267aa 100644 --- a/test/DHTRoutingTableDeserializerTest.cc +++ b/test/DHTRoutingTableDeserializerTest.cc @@ -56,7 +56,7 @@ void DHTRoutingTableDeserializerTest::testDeserialize() d.deserialize(ss); CPPUNIT_ASSERT(memcmp(localNode->getID(), d.getLocalNode()->getID(), - DHT_ID_LENGTH) == 0); + DHT_ID_LENGTH) == 0); std::cout << d.getSerializedTime().getTime() << std::endl; diff --git a/test/DHTUnknownMessageTest.cc b/test/DHTUnknownMessageTest.cc index 7801bdd8..ea1e31de 100644 --- a/test/DHTUnknownMessageTest.cc +++ b/test/DHTUnknownMessageTest.cc @@ -31,9 +31,9 @@ void DHTUnknownMessageTest::testToString() // data.size() > 8 std::string data = "chocolate"; DHTUnknownMessage msg(localNode, - reinterpret_cast<const unsigned char*>(data.c_str()), - data.size(), - ipaddr, port); + reinterpret_cast<const unsigned char*>(data.c_str()), + data.size(), + ipaddr, port); CPPUNIT_ASSERT_EQUAL(std::string("dht unknown Remote:192.168.0.1:6881 length=9, first 8 bytes(hex)=63686f636f6c6174"), msg.toString()); } @@ -41,9 +41,9 @@ void DHTUnknownMessageTest::testToString() // data.size() == 3 std::string data = "foo"; DHTUnknownMessage msg(localNode, - reinterpret_cast<const unsigned char*>(data.c_str()), - data.size(), - ipaddr, port); + reinterpret_cast<const unsigned char*>(data.c_str()), + data.size(), + ipaddr, port); CPPUNIT_ASSERT_EQUAL(std::string("dht unknown Remote:192.168.0.1:6881 length=3, first 8 bytes(hex)=666f6f"), msg.toString()); } diff --git a/test/DefaultBtAnnounceTest.cc b/test/DefaultBtAnnounceTest.cc index 9db5b814..344bbf9b 100644 --- a/test/DefaultBtAnnounceTest.cc +++ b/test/DefaultBtAnnounceTest.cc @@ -48,10 +48,10 @@ public: int32_t pieceLength = 256*1024; static const unsigned char infoHash[] = { 0x01, 0x23, 0x45, 0x67, - 0x89, 0xab, 0xcd, 0xef, - 0x01, 0x23, 0x45, 0x67, - 0x89, 0xab, 0xcd, 0xef, - 0x01, 0x23, 0x45, 0x67 }; + 0x89, 0xab, 0xcd, 0xef, + 0x01, 0x23, 0x45, 0x67, + 0x89, 0xab, 0xcd, 0xef, + 0x01, 0x23, 0x45, 0x67 }; std::string peerId = "-aria2-ultrafastdltl"; @@ -114,7 +114,7 @@ static BDE createAnnounceTier(const std::string& uri) } static void setAnnounceList(const SharedHandle<DownloadContext>& dctx, - const BDE& announceList) + const BDE& announceList) { dctx->getAttribute(bittorrent::BITTORRENT)[bittorrent::ANNOUNCE_LIST] = announceList; @@ -215,11 +215,11 @@ void DefaultBtAnnounceTest::testGetAnnounceUrl_withQuery() CPPUNIT_ASSERT_EQUAL (std::string("http://localhost/announce?k=v&" - "info_hash=%01%23Eg%89%AB%CD%EF%01%23Eg%89%AB%CD%EF%01%23Eg&" - "peer_id=%2Daria2%2Dultrafastdltl&" - "uploaded=1572864&downloaded=1310720&left=1572864&compact=1&" - "key=fastdltl&numwant=50&no_peer_id=1&port=6989&event=started&" - "supportcrypto=1"), + "info_hash=%01%23Eg%89%AB%CD%EF%01%23Eg%89%AB%CD%EF%01%23Eg&" + "peer_id=%2Daria2%2Dultrafastdltl&" + "uploaded=1572864&downloaded=1310720&left=1572864&compact=1&" + "key=fastdltl&numwant=50&no_peer_id=1&port=6989&event=started&" + "supportcrypto=1"), btAnnounce.getAnnounceUrl()); } @@ -238,11 +238,11 @@ void DefaultBtAnnounceTest::testGetAnnounceUrl_externalIP() CPPUNIT_ASSERT_EQUAL (std::string("http://localhost/announce?" - "info_hash=%01%23Eg%89%AB%CD%EF%01%23Eg%89%AB%CD%EF%01%23Eg&" - "peer_id=%2Daria2%2Dultrafastdltl&" - "uploaded=1572864&downloaded=1310720&left=1572864&compact=1&" - "key=fastdltl&numwant=50&no_peer_id=1&port=6989&event=started&" - "supportcrypto=1&ip=192.168.1.1"), + "info_hash=%01%23Eg%89%AB%CD%EF%01%23Eg%89%AB%CD%EF%01%23Eg&" + "peer_id=%2Daria2%2Dultrafastdltl&" + "uploaded=1572864&downloaded=1310720&left=1572864&compact=1&" + "key=fastdltl&numwant=50&no_peer_id=1&port=6989&event=started&" + "supportcrypto=1&ip=192.168.1.1"), btAnnounce.getAnnounceUrl()); } @@ -279,7 +279,7 @@ void DefaultBtAnnounceTest::testIsAllAnnounceFailed() void DefaultBtAnnounceTest::testURLOrderInStoppedEvent() { const char* urls[] = { "http://localhost1/announce", - "http://localhost2/announce" }; + "http://localhost2/announce" }; BDE announceList = BDE::list(); announceList << createAnnounceTier(&urls[0], &urls[arrayLength(urls)]); @@ -309,7 +309,7 @@ void DefaultBtAnnounceTest::testURLOrderInStoppedEvent() void DefaultBtAnnounceTest::testURLOrderInCompletedEvent() { const char* urls[] = { "http://localhost1/announce", - "http://localhost2/announce" }; + "http://localhost2/announce" }; BDE announceList = BDE::list(); announceList << createAnnounceTier(&urls[0], &urls[arrayLength(urls)]); diff --git a/test/DefaultBtMessageDispatcherTest.cc b/test/DefaultBtMessageDispatcherTest.cc index c3f664b2..b80b2601 100644 --- a/test/DefaultBtMessageDispatcherTest.cc +++ b/test/DefaultBtMessageDispatcherTest.cc @@ -78,8 +78,8 @@ public: std::string type; public: MockBtMessage2():onQueuedCalled(false), - sendCalled(false), - doCancelActionCalled(false) + sendCalled(false), + doCancelActionCalled(false) {} virtual ~MockBtMessage2() {} @@ -153,7 +153,7 @@ public: _messageFactory.reset(new MockBtMessageFactory2()); _rgman.reset(new RequestGroupMan(std::deque<SharedHandle<RequestGroup> >(), - 0, _option.get())); + 0, _option.get())); btMessageDispatcher.reset(new DefaultBtMessageDispatcher()); btMessageDispatcher->setPeer(peer); @@ -175,7 +175,7 @@ void DefaultBtMessageDispatcherTest::testAddMessage() { btMessageDispatcher->addMessageToQueue(msg); CPPUNIT_ASSERT_EQUAL(true, msg->isOnQueuedCalled()); CPPUNIT_ASSERT_EQUAL((size_t)1, - btMessageDispatcher->getMessageQueue().size()); + btMessageDispatcher->getMessageQueue().size()); } void DefaultBtMessageDispatcherTest::testSendMessages() { @@ -246,7 +246,7 @@ void DefaultBtMessageDispatcherTest::testSendMessages_underUploadLimit() { // CPPUNIT_ASSERT(msg3->isSendCalled()); // CPPUNIT_ASSERT_EQUAL((size_t)2, -// btMessageDispatcher->getMessageQueue().size()); +// btMessageDispatcher->getMessageQueue().size()); // } void DefaultBtMessageDispatcherTest::testSendMessages_sendingInProgress() { @@ -271,7 +271,7 @@ void DefaultBtMessageDispatcherTest::testSendMessages_sendingInProgress() { CPPUNIT_ASSERT(!msg3->isSendCalled()); CPPUNIT_ASSERT_EQUAL((size_t)2, - btMessageDispatcher->getMessageQueue().size()); + btMessageDispatcher->getMessageQueue().size()); } void DefaultBtMessageDispatcherTest::testDoCancelSendingPieceAction() { @@ -307,9 +307,9 @@ void DefaultBtMessageDispatcherTest::testCheckRequestSlotAndDoNecessaryThing() { btMessageDispatcher->checkRequestSlotAndDoNecessaryThing(); CPPUNIT_ASSERT_EQUAL((size_t)0, - btMessageDispatcher->getMessageQueue().size()); + btMessageDispatcher->getMessageQueue().size()); CPPUNIT_ASSERT_EQUAL((size_t)1, - btMessageDispatcher->getRequestSlots().size()); + btMessageDispatcher->getRequestSlots().size()); } void DefaultBtMessageDispatcherTest::testCheckRequestSlotAndDoNecessaryThing_timeout() { @@ -332,9 +332,9 @@ void DefaultBtMessageDispatcherTest::testCheckRequestSlotAndDoNecessaryThing_tim btMessageDispatcher->checkRequestSlotAndDoNecessaryThing(); CPPUNIT_ASSERT_EQUAL((size_t)0, - btMessageDispatcher->getMessageQueue().size()); + btMessageDispatcher->getMessageQueue().size()); CPPUNIT_ASSERT_EQUAL((size_t)0, - btMessageDispatcher->getRequestSlots().size()); + btMessageDispatcher->getRequestSlots().size()); CPPUNIT_ASSERT_EQUAL(false, piece->isBlockUsed(0)); CPPUNIT_ASSERT_EQUAL(true, peer->snubbing()); } @@ -355,9 +355,9 @@ void DefaultBtMessageDispatcherTest::testCheckRequestSlotAndDoNecessaryThing_com btMessageDispatcher->checkRequestSlotAndDoNecessaryThing(); CPPUNIT_ASSERT_EQUAL((size_t)1, - btMessageDispatcher->getMessageQueue().size()); + btMessageDispatcher->getMessageQueue().size()); CPPUNIT_ASSERT_EQUAL((size_t)0, - btMessageDispatcher->getRequestSlots().size()); + btMessageDispatcher->getRequestSlots().size()); } void DefaultBtMessageDispatcherTest::testIsSendingInProgress() { @@ -374,7 +374,7 @@ void DefaultBtMessageDispatcherTest::testCountOutstandingRequest() { RequestSlot slot(0, 0, MY_PIECE_LENGTH, 0); btMessageDispatcher->addOutstandingRequest(slot); CPPUNIT_ASSERT_EQUAL((size_t)1, - btMessageDispatcher->countOutstandingRequest()); + btMessageDispatcher->countOutstandingRequest()); } void DefaultBtMessageDispatcherTest::testIsOutstandingRequest() { diff --git a/test/DefaultBtMessageFactoryTest.cc b/test/DefaultBtMessageFactoryTest.cc index 1d9a2c93..2a948f80 100644 --- a/test/DefaultBtMessageFactoryTest.cc +++ b/test/DefaultBtMessageFactoryTest.cc @@ -58,7 +58,7 @@ void DefaultBtMessageFactoryTest::testCreateBtMessage_BtExtendedMessage() std::string payload = "4:name3:foo"; char msg[17];// 6+11bytes bittorrent::createPeerMessageString((unsigned char*)msg, sizeof(msg), - 13, 20); + 13, 20); msg[5] = 1; // Set dummy extended message ID 1 memcpy(msg+6, payload.c_str(), payload.size()); @@ -84,8 +84,8 @@ void DefaultBtMessageFactoryTest::testCreatePortMessage() bittorrent::setShortIntParam(&data[5], 6881); try { SharedHandle<BtPortMessage> m - (dynamic_pointer_cast<BtPortMessage> - (_factory->createBtMessage(&data[4], sizeof(data)-4))); + (dynamic_pointer_cast<BtPortMessage> + (_factory->createBtMessage(&data[4], sizeof(data)-4))); CPPUNIT_ASSERT(!m.isNull()); CPPUNIT_ASSERT_EQUAL((uint16_t)6881, m->getPort()); } catch(Exception& e) { diff --git a/test/DefaultBtProgressInfoFileTest.cc b/test/DefaultBtProgressInfoFileTest.cc index cbdbb15b..8045f840 100644 --- a/test/DefaultBtProgressInfoFileTest.cc +++ b/test/DefaultBtProgressInfoFileTest.cc @@ -79,7 +79,7 @@ public: SharedHandle<FileEntry>(new FileEntry("/path/to/file",totalLength,0)) }; _dctx->setFileEntries(&fileEntries[0], - &fileEntries[arrayLength(fileEntries)]); + &fileEntries[arrayLength(fileEntries)]); _dctx->setPieceLength(pieceLength); _peerStorage.reset(new MockPeerStorage()); _btRuntime.reset(new BtRuntime()); @@ -135,12 +135,12 @@ void DefaultBtProgressInfoFileTest::testLoad_compat() // bitfield CPPUNIT_ASSERT_EQUAL(std::string("fffffffffffffffffffe"), - util::toHex(_bitfield->getBitfield(), - _bitfield->getBitfieldLength())); + util::toHex(_bitfield->getBitfield(), + _bitfield->getBitfieldLength())); // the number of in-flight pieces CPPUNIT_ASSERT_EQUAL((size_t)2, - _pieceStorage->countInFlightPiece()); + _pieceStorage->countInFlightPiece()); // piece index 1 std::deque<SharedHandle<Piece> > inFlightPieces; @@ -151,7 +151,7 @@ void DefaultBtProgressInfoFileTest::testLoad_compat() 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(), - piece1->getBitfieldLength())); + piece1->getBitfieldLength())); // piece index 2 SharedHandle<Piece> piece2 = inFlightPieces[1]; @@ -168,7 +168,7 @@ void DefaultBtProgressInfoFileTest::testLoad() DefaultBtProgressInfoFile infoFile(_dctx, _pieceStorage, _option.get()); CPPUNIT_ASSERT_EQUAL(std::string("load-v0001.aria2"), - infoFile.getFilename()); + infoFile.getFilename()); infoFile.setBtRuntime(_btRuntime); infoFile.setPeerStorage(_peerStorage); @@ -184,12 +184,12 @@ void DefaultBtProgressInfoFileTest::testLoad() // bitfield CPPUNIT_ASSERT_EQUAL(std::string("fffffffffffffffffffe"), - util::toHex(_bitfield->getBitfield(), - _bitfield->getBitfieldLength())); + util::toHex(_bitfield->getBitfield(), + _bitfield->getBitfieldLength())); // the number of in-flight pieces CPPUNIT_ASSERT_EQUAL((size_t)2, - _pieceStorage->countInFlightPiece()); + _pieceStorage->countInFlightPiece()); // piece index 1 std::deque<SharedHandle<Piece> > inFlightPieces; @@ -200,7 +200,7 @@ void DefaultBtProgressInfoFileTest::testLoad() 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(), - piece1->getBitfieldLength())); + piece1->getBitfieldLength())); // piece index 2 SharedHandle<Piece> piece2 = inFlightPieces[1]; @@ -232,7 +232,7 @@ void DefaultBtProgressInfoFileTest::testSave() infoFile.setPeerStorage(_peerStorage); CPPUNIT_ASSERT_EQUAL(std::string("save-temp.aria2"), - infoFile.getFilename()); + infoFile.getFilename()); infoFile.save(); @@ -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<char*>(&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; @@ -339,7 +339,7 @@ void DefaultBtProgressInfoFileTest::testLoad_nonBt_compat() DefaultBtProgressInfoFile infoFile(dctx, _pieceStorage, _option.get()); CPPUNIT_ASSERT_EQUAL(std::string("load-nonBt.aria2"), - infoFile.getFilename()); + infoFile.getFilename()); infoFile.load(); // check the contents of objects @@ -349,12 +349,12 @@ void DefaultBtProgressInfoFileTest::testLoad_nonBt_compat() // bitfield CPPUNIT_ASSERT_EQUAL(std::string("fffffffffffffffffffe"), - util::toHex(_bitfield->getBitfield(), - _bitfield->getBitfieldLength())); + util::toHex(_bitfield->getBitfield(), + _bitfield->getBitfieldLength())); // the number of in-flight pieces CPPUNIT_ASSERT_EQUAL((size_t)2, - _pieceStorage->countInFlightPiece()); + _pieceStorage->countInFlightPiece()); // piece index 1 std::deque<SharedHandle<Piece> > inFlightPieces; @@ -365,7 +365,7 @@ void DefaultBtProgressInfoFileTest::testLoad_nonBt_compat() 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(), - piece1->getBitfieldLength())); + piece1->getBitfieldLength())); // piece index 2 SharedHandle<Piece> piece2 = inFlightPieces[1]; @@ -384,7 +384,7 @@ void DefaultBtProgressInfoFileTest::testLoad_nonBt() DefaultBtProgressInfoFile infoFile(dctx, _pieceStorage, _option.get()); CPPUNIT_ASSERT_EQUAL(std::string("load-nonBt-v0001.aria2"), - infoFile.getFilename()); + infoFile.getFilename()); infoFile.load(); // check the contents of objects @@ -394,12 +394,12 @@ void DefaultBtProgressInfoFileTest::testLoad_nonBt() // bitfield CPPUNIT_ASSERT_EQUAL(std::string("fffffffffffffffffffe"), - util::toHex(_bitfield->getBitfield(), - _bitfield->getBitfieldLength())); + util::toHex(_bitfield->getBitfield(), + _bitfield->getBitfieldLength())); // the number of in-flight pieces CPPUNIT_ASSERT_EQUAL((size_t)2, - _pieceStorage->countInFlightPiece()); + _pieceStorage->countInFlightPiece()); // piece index 1 std::deque<SharedHandle<Piece> > inFlightPieces; @@ -410,7 +410,7 @@ void DefaultBtProgressInfoFileTest::testLoad_nonBt() 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(), - piece1->getBitfieldLength())); + piece1->getBitfieldLength())); // piece index 2 SharedHandle<Piece> piece2 = inFlightPieces[1]; @@ -429,19 +429,19 @@ void DefaultBtProgressInfoFileTest::testLoad_nonBt_pieceLengthShorter() DefaultBtProgressInfoFile infoFile(dctx, _pieceStorage, _option.get()); CPPUNIT_ASSERT_EQUAL(std::string("load-nonBt-v0001.aria2"), - infoFile.getFilename()); + infoFile.getFilename()); infoFile.load(); // check the contents of objects // bitfield CPPUNIT_ASSERT_EQUAL(std::string("fffffffffffffffffffffffffffffffffffffffc"), - util::toHex(_bitfield->getBitfield(), - _bitfield->getBitfieldLength())); + util::toHex(_bitfield->getBitfield(), + _bitfield->getBitfieldLength())); // the number of in-flight pieces CPPUNIT_ASSERT_EQUAL((size_t)0, - _pieceStorage->countInFlightPiece()); + _pieceStorage->countInFlightPiece()); } void DefaultBtProgressInfoFileTest::testSave_nonBt() @@ -465,7 +465,7 @@ void DefaultBtProgressInfoFileTest::testSave_nonBt() DefaultBtProgressInfoFile infoFile(dctx, _pieceStorage, _option.get()); CPPUNIT_ASSERT_EQUAL(std::string("save-temp.aria2"), - infoFile.getFilename()); + infoFile.getFilename()); infoFile.save(); @@ -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<char*>(&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/DefaultBtRequestFactoryTest.cc b/test/DefaultBtRequestFactoryTest.cc index 2f352298..23c77ca2 100644 --- a/test/DefaultBtRequestFactoryTest.cc +++ b/test/DefaultBtRequestFactoryTest.cc @@ -57,7 +57,7 @@ public: virtual SharedHandle<BtMessage> createRequestMessage(const SharedHandle<Piece>& piece, size_t blockIndex) { return SharedHandle<BtMessage> - (new MockBtRequestMessage(piece->getIndex(), blockIndex)); + (new MockBtRequestMessage(piece->getIndex(), blockIndex)); } }; @@ -71,17 +71,17 @@ public: class SortMockBtRequestMessage { public: bool operator()(const SharedHandle<MockBtRequestMessage>& a, - const SharedHandle<MockBtRequestMessage>& b) { + const SharedHandle<MockBtRequestMessage>& b) { if(a->index < b->index) { - return true; + return true; } else if(b->index < a->index) { - return false; + return false; } else if(a->blockIndex < b->blockIndex) { - return true; + return true; } else if(b->blockIndex < a->blockIndex) { - return false; + return false; } else { - return true; + return true; } } }; @@ -132,7 +132,7 @@ void DefaultBtRequestFactoryTest::testRemoveCompletedPiece() { _requestFactory->removeCompletedPiece(); CPPUNIT_ASSERT_EQUAL((size_t)1, _requestFactory->countTargetPiece()); CPPUNIT_ASSERT_EQUAL((size_t)0, - _requestFactory->getTargetPieces().front()->getIndex()); + _requestFactory->getTargetPieces().front()->getIndex()); } void DefaultBtRequestFactoryTest::testCreateRequestMessages() { @@ -211,16 +211,16 @@ void DefaultBtRequestFactoryTest::testRemoveTargetPiece() { _requestFactory->addTargetPiece(piece1); CPPUNIT_ASSERT(std::find(_requestFactory->getTargetPieces().begin(), - _requestFactory->getTargetPieces().end(), - piece1) != - _requestFactory->getTargetPieces().end()); + _requestFactory->getTargetPieces().end(), + piece1) != + _requestFactory->getTargetPieces().end()); _requestFactory->removeTargetPiece(piece1); CPPUNIT_ASSERT(std::find(_requestFactory->getTargetPieces().begin(), - _requestFactory->getTargetPieces().end(), - piece1) == - _requestFactory->getTargetPieces().end()); + _requestFactory->getTargetPieces().end(), + piece1) == + _requestFactory->getTargetPieces().end()); } void DefaultBtRequestFactoryTest::testGetTargetPieceIndexes() diff --git a/test/DefaultExtensionMessageFactoryTest.cc b/test/DefaultExtensionMessageFactoryTest.cc index 921da4f3..2a7ab725 100644 --- a/test/DefaultExtensionMessageFactoryTest.cc +++ b/test/DefaultExtensionMessageFactoryTest.cc @@ -149,7 +149,7 @@ void DefaultExtensionMessageFactoryTest::testCreateMessage_UTPex() SharedHandle<UTPexExtensionMessage> m = createMessage<UTPexExtensionMessage>(data); CPPUNIT_ASSERT_EQUAL(_registry->getExtensionMessageID("ut_pex"), - m->getExtensionMessageID()); + m->getExtensionMessageID()); } void DefaultExtensionMessageFactoryTest::testCreateMessage_UTMetadataRequest() diff --git a/test/DefaultPeerStorageTest.cc b/test/DefaultPeerStorageTest.cc index 8f910c9c..72ed8cf9 100644 --- a/test/DefaultPeerStorageTest.cc +++ b/test/DefaultPeerStorageTest.cc @@ -78,7 +78,7 @@ void DefaultPeerStorageTest::testDeleteUnusedPeer() { CPPUNIT_ASSERT_EQUAL((size_t)1, ps.countPeer()); CPPUNIT_ASSERT_EQUAL(std::string("192.168.0.3"), - ps.getPeer("192.168.0.3", 6889)->ipaddr); + ps.getPeer("192.168.0.3", 6889)->ipaddr); ps.addPeer(peer1); ps.addPeer(peer2); @@ -90,7 +90,7 @@ void DefaultPeerStorageTest::testDeleteUnusedPeer() { // peer2 has been in use, so it did't deleted. CPPUNIT_ASSERT_EQUAL((size_t)1, ps.countPeer()); CPPUNIT_ASSERT_EQUAL(std::string("192.168.0.2"), - ps.getPeer("192.168.0.2", 6889)->ipaddr); + ps.getPeer("192.168.0.2", 6889)->ipaddr); } @@ -140,7 +140,7 @@ void DefaultPeerStorageTest::testGetUnusedPeer() { ps.addPeer(peer1); CPPUNIT_ASSERT_EQUAL(std::string("192.168.0.1"), - ps.getUnusedPeer()->ipaddr); + ps.getUnusedPeer()->ipaddr); peer1->usedBy(1); @@ -223,7 +223,7 @@ void DefaultPeerStorageTest::testReturnPeer() ps.returnPeer(peer2); // peer2 removed from the container CPPUNIT_ASSERT_EQUAL((size_t)2, ps.getPeers().size()); CPPUNIT_ASSERT(std::find(ps.getPeers().begin(), ps.getPeers().end(), peer2) - == ps.getPeers().end()); + == ps.getPeers().end()); ps.returnPeer(peer1); // peer1 is removed from the container CPPUNIT_ASSERT_EQUAL((size_t)1, ps.getPeers().size()); diff --git a/test/DefaultPieceStorageTest.cc b/test/DefaultPieceStorageTest.cc index 9693ca27..508f03ea 100644 --- a/test/DefaultPieceStorageTest.cc +++ b/test/DefaultPieceStorageTest.cc @@ -52,7 +52,7 @@ public: bittorrent::load("test.torrent", _dctx); peer.reset(new Peer("192.168.0.1", 6889)); peer->allocateSessionResource(_dctx->getPieceLength(), - _dctx->getTotalLength()); + _dctx->getTotalLength()); option = new Option(); _pieceSelector.reset(new InOrderPieceSelector()); } @@ -96,13 +96,13 @@ void DefaultPieceStorageTest::testGetMissingPiece() { SharedHandle<Piece> piece = pss.getMissingPiece(peer); CPPUNIT_ASSERT_EQUAL(std::string("piece: index=0, length=128"), - piece->toString()); + piece->toString()); piece = pss.getMissingPiece(peer); CPPUNIT_ASSERT_EQUAL(std::string("piece: index=1, length=128"), - piece->toString()); + piece->toString()); piece = pss.getMissingPiece(peer); CPPUNIT_ASSERT_EQUAL(std::string("piece: index=2, length=128"), - piece->toString()); + piece->toString()); piece = pss.getMissingPiece(peer); CPPUNIT_ASSERT(piece.isNull()); } @@ -120,11 +120,11 @@ void DefaultPieceStorageTest::testGetMissingPiece_excludedIndexes() SharedHandle<Piece> piece = pss.getMissingPiece(peer, excludedIndexes); CPPUNIT_ASSERT_EQUAL(std::string("piece: index=0, length=128"), - piece->toString()); + piece->toString()); piece = pss.getMissingPiece(peer, excludedIndexes); CPPUNIT_ASSERT_EQUAL(std::string("piece: index=2, length=128"), - piece->toString()); + piece->toString()); piece = pss.getMissingPiece(peer, excludedIndexes); CPPUNIT_ASSERT(piece.isNull()); @@ -141,7 +141,7 @@ void DefaultPieceStorageTest::testGetMissingFastPiece() { SharedHandle<Piece> piece = pss.getMissingFastPiece(peer); CPPUNIT_ASSERT_EQUAL(std::string("piece: index=2, length=128"), - piece->toString()); + piece->toString()); CPPUNIT_ASSERT(pss.getMissingFastPiece(peer).isNull()); } @@ -162,7 +162,7 @@ void DefaultPieceStorageTest::testGetMissingFastPiece_excludedIndexes() SharedHandle<Piece> piece = pss.getMissingFastPiece(peer, excludedIndexes); CPPUNIT_ASSERT_EQUAL(std::string("piece: index=1, length=128"), - piece->toString()); + piece->toString()); CPPUNIT_ASSERT(pss.getMissingFastPiece(peer, excludedIndexes).isNull()); } @@ -186,7 +186,7 @@ void DefaultPieceStorageTest::testCompletePiece() { SharedHandle<Piece> piece = pss.getMissingPiece(peer); CPPUNIT_ASSERT_EQUAL(std::string("piece: index=0, length=128"), - piece->toString()); + piece->toString()); CPPUNIT_ASSERT_EQUAL((uint64_t)0ULL, pss.getCompletedLength()); diff --git a/test/DirectDiskAdaptorTest.cc b/test/DirectDiskAdaptorTest.cc index d5c642a2..885ded9c 100644 --- a/test/DirectDiskAdaptorTest.cc +++ b/test/DirectDiskAdaptorTest.cc @@ -31,7 +31,7 @@ void DirectDiskAdaptorTest::testCutTrailingGarbage() std::string dir = "/tmp"; SharedHandle<FileEntry> entry (new FileEntry(dir+"/aria2_DirectDiskAdaptorTest_testCutTrailingGarbage", - 256, 0)); + 256, 0)); createFile(entry->getPath(), entry->getLength()+100); std::vector<SharedHandle<FileEntry> > fileEntries; @@ -47,7 +47,7 @@ void DirectDiskAdaptorTest::testCutTrailingGarbage() adaptor.cutTrailingGarbage(); CPPUNIT_ASSERT_EQUAL((uint64_t)entry->getLength(), - File(entry->getPath()).size()); + File(entry->getPath()).size()); } } // namespace aria2 diff --git a/test/DownloadContextTest.cc b/test/DownloadContextTest.cc index 42c03182..a68c0f7e 100644 --- a/test/DownloadContextTest.cc +++ b/test/DownloadContextTest.cc @@ -40,14 +40,14 @@ void DownloadContextTest::testFindFileEntryByOffset() SharedHandle<FileEntry>(new FileEntry("file6",0,6000)) }; ctx.setFileEntries(&fileEntries[0], - &fileEntries[arrayLength(fileEntries)]); + &fileEntries[arrayLength(fileEntries)]); CPPUNIT_ASSERT_EQUAL(std::string("file1"), - ctx.findFileEntryByOffset(0)->getPath()); + ctx.findFileEntryByOffset(0)->getPath()); CPPUNIT_ASSERT_EQUAL(std::string("file4"), - ctx.findFileEntryByOffset(1500)->getPath()); + ctx.findFileEntryByOffset(1500)->getPath()); CPPUNIT_ASSERT_EQUAL(std::string("file5"), - ctx.findFileEntryByOffset(5999)->getPath()); + ctx.findFileEntryByOffset(5999)->getPath()); CPPUNIT_ASSERT(ctx.findFileEntryByOffset(6000).isNull()); } diff --git a/test/DownloadHelperTest.cc b/test/DownloadHelperTest.cc index f0b9d393..9b536877 100644 --- a/test/DownloadHelperTest.cc +++ b/test/DownloadHelperTest.cc @@ -144,7 +144,7 @@ void DownloadHelperTest::testCreateRequestGroupForUri() CPPUNIT_ASSERT_EQUAL(array[0], uris[0]); } CPPUNIT_ASSERT_EQUAL((unsigned int)2, - alphaGroup->getNumConcurrentCommand()); + alphaGroup->getNumConcurrentCommand()); SharedHandle<DownloadContext> alphaCtx = alphaGroup->getDownloadContext(); CPPUNIT_ASSERT_EQUAL(std::string("/tmp"), alphaCtx->getDir()); // See filename is not assigned yet @@ -217,18 +217,18 @@ void DownloadHelperTest::testCreateRequestGroupForUri_BitTorrent() SharedHandle<DownloadContext> ctx = group->getDownloadContext(); CPPUNIT_ASSERT_EQUAL(std::string("/tmp"), ctx->getDir()); CPPUNIT_ASSERT_EQUAL(std::string("/tmp/file.out"), - ctx->getBasePath()); + ctx->getBasePath()); SharedHandle<RequestGroup> torrentGroup = result[1]; std::deque<std::string> auxURIs; torrentGroup->getDownloadContext()->getFirstFileEntry()->getUris(auxURIs); CPPUNIT_ASSERT(auxURIs.empty()); CPPUNIT_ASSERT_EQUAL((unsigned int)3, - torrentGroup->getNumConcurrentCommand()); + torrentGroup->getNumConcurrentCommand()); SharedHandle<DownloadContext> btctx = torrentGroup->getDownloadContext(); CPPUNIT_ASSERT_EQUAL(std::string("/tmp"), btctx->getDir()); CPPUNIT_ASSERT_EQUAL(std::string("/tmp/aria2-test"), - btctx->getBasePath()); + btctx->getBasePath()); } } #endif // ENABLE_BITTORRENT @@ -271,20 +271,20 @@ void DownloadHelperTest::testCreateRequestGroupForUri_Metalink() SharedHandle<DownloadContext> ctx = group->getDownloadContext(); CPPUNIT_ASSERT_EQUAL(std::string("/tmp"), ctx->getDir()); CPPUNIT_ASSERT_EQUAL(std::string("/tmp/file.out"), - ctx->getBasePath()); + ctx->getBasePath()); SharedHandle<RequestGroup> aria2052Group = result[1]; CPPUNIT_ASSERT_EQUAL((unsigned int)1, // because of maxconnections attribute - aria2052Group->getNumConcurrentCommand()); + aria2052Group->getNumConcurrentCommand()); SharedHandle<DownloadContext> aria2052Ctx = aria2052Group->getDownloadContext(); CPPUNIT_ASSERT_EQUAL(std::string("/tmp"), aria2052Ctx->getDir()); CPPUNIT_ASSERT_EQUAL(std::string("/tmp/aria2-0.5.2.tar.bz2"), - aria2052Ctx->getBasePath()); + aria2052Ctx->getBasePath()); SharedHandle<RequestGroup> aria2051Group = result[2]; CPPUNIT_ASSERT_EQUAL((unsigned int)2, - aria2051Group->getNumConcurrentCommand()); + aria2051Group->getNumConcurrentCommand()); } } #endif // ENABLE_METALINK @@ -312,13 +312,13 @@ void DownloadHelperTest::testCreateRequestGroupForUriList() SharedHandle<DownloadContext> fileCtx = fileGroup->getDownloadContext(); CPPUNIT_ASSERT_EQUAL(std::string("/mydownloads"), fileCtx->getDir()); CPPUNIT_ASSERT_EQUAL(std::string("/mydownloads/myfile.out"), - fileCtx->getBasePath()); + fileCtx->getBasePath()); SharedHandle<RequestGroup> fileISOGroup = result[1]; SharedHandle<DownloadContext> fileISOCtx = fileISOGroup->getDownloadContext(); CPPUNIT_ASSERT_EQUAL(std::string("/tmp"), fileISOCtx->getDir()); CPPUNIT_ASSERT_EQUAL(std::string("/tmp/file.out"), - fileISOCtx->getBasePath()); + fileISOCtx->getBasePath()); } #ifdef ENABLE_BITTORRENT @@ -400,9 +400,9 @@ void DownloadHelperTest::testCreateRequestGroupForMetalink() std::sort(uris.begin(), uris.end()); CPPUNIT_ASSERT_EQUAL((size_t)2, uris.size()); CPPUNIT_ASSERT_EQUAL(std::string("ftp://ftphost/aria2-0.5.2.tar.bz2"), - uris[0]); + uris[0]); CPPUNIT_ASSERT_EQUAL(std::string("http://httphost/aria2-0.5.2.tar.bz2"), - uris[1]); + uris[1]); // See numConcurrentCommand is 1 because of maxconnections attribute. CPPUNIT_ASSERT_EQUAL((unsigned int)1, group->getNumConcurrentCommand()); } diff --git a/test/ExceptionTest.cc b/test/ExceptionTest.cc index 10f6ddf7..86238c4e 100644 --- a/test/ExceptionTest.cc +++ b/test/ExceptionTest.cc @@ -28,12 +28,12 @@ void ExceptionTest::testStackTrace() DownloadFailureException c1 = DOWNLOAD_FAILURE_EXCEPTION("cause1"); DownloadFailureException c2 = DOWNLOAD_FAILURE_EXCEPTION2("cause2", c1); DownloadFailureException e = DOWNLOAD_FAILURE_EXCEPTION2("exception thrown", - c2); + c2); CPPUNIT_ASSERT_EQUAL (std::string("Exception: [ExceptionTest.cc:31] exception thrown\n" - " -> [ExceptionTest.cc:29] cause2\n" - " -> [ExceptionTest.cc:28] cause1\n"), + " -> [ExceptionTest.cc:29] cause2\n" + " -> [ExceptionTest.cc:28] cause1\n"), e.stackTrace()); } diff --git a/test/FeatureConfigTest.cc b/test/FeatureConfigTest.cc index f28260a4..32debd2e 100644 --- a/test/FeatureConfigTest.cc +++ b/test/FeatureConfigTest.cc @@ -29,25 +29,25 @@ CPPUNIT_TEST_SUITE_REGISTRATION(FeatureConfigTest); void FeatureConfigTest::testGetDefaultPort() { CPPUNIT_ASSERT_EQUAL((uint16_t)80, - FeatureConfig::getInstance()->getDefaultPort("http")); + FeatureConfig::getInstance()->getDefaultPort("http")); CPPUNIT_ASSERT_EQUAL((uint16_t)443, - FeatureConfig::getInstance()->getDefaultPort("https")); + FeatureConfig::getInstance()->getDefaultPort("https")); CPPUNIT_ASSERT_EQUAL((uint16_t)21, - FeatureConfig::getInstance()->getDefaultPort("ftp")); + FeatureConfig::getInstance()->getDefaultPort("ftp")); } void FeatureConfigTest::testIsSupported() { #ifdef ENABLE_SSL CPPUNIT_ASSERT_EQUAL(true, - FeatureConfig::getInstance()->isSupported - (FeatureConfig::FEATURE_HTTPS)); + FeatureConfig::getInstance()->isSupported + (FeatureConfig::FEATURE_HTTPS)); #else CPPUNIT_ASSERT_EQUAL(false, - FeatureConfig::getInstance()->isSupported - (FeatureConfig::FEATURE_HTTPS)); + FeatureConfig::getInstance()->isSupported + (FeatureConfig::FEATURE_HTTPS)); #endif // ENABLE_SSL CPPUNIT_ASSERT_EQUAL(false, - FeatureConfig::getInstance()->isSupported("FTPS")); + FeatureConfig::getInstance()->isSupported("FTPS")); } void FeatureConfigTest::testFeatureSummary() { @@ -90,12 +90,12 @@ void FeatureConfigTest::testFeatureSummary() { std::string featuresString; const std::string delim(", "); std::for_each(&features[0], &features[arrayLength(features)], - StringAppend(featuresString, delim)); + StringAppend(featuresString, delim)); // USE util::trimSelf(featureString); featuresString = util::trim(featuresString, delim); CPPUNIT_ASSERT_EQUAL(featuresString, - FeatureConfig::getInstance()->featureSummary()); + FeatureConfig::getInstance()->featureSummary()); } } // namespace aria2 diff --git a/test/FeedbackURISelectorTest.cc b/test/FeedbackURISelectorTest.cc index 4e3c33eb..5130b4cc 100644 --- a/test/FeedbackURISelectorTest.cc +++ b/test/FeedbackURISelectorTest.cc @@ -77,11 +77,11 @@ void FeedbackURISelectorTest::testSelect() ssm->add(alphaHTTP); CPPUNIT_ASSERT_EQUAL(std::string("http://bravo/file"), - sel->select(&_fileEntry)); + sel->select(&_fileEntry)); CPPUNIT_ASSERT_EQUAL((size_t)2, _fileEntry.getRemainingUris().size()); CPPUNIT_ASSERT_EQUAL(std::string("ftp://alpha/file"), - sel->select(&_fileEntry)); + sel->select(&_fileEntry)); CPPUNIT_ASSERT_EQUAL((size_t)1, _fileEntry.getRemainingUris().size()); } @@ -97,7 +97,7 @@ void FeedbackURISelectorTest::testSelect_skipErrorHost() // See error URIs are removed from URI List. CPPUNIT_ASSERT_EQUAL(std::string("http://bravo/file"), - sel->select(&_fileEntry)); + sel->select(&_fileEntry)); CPPUNIT_ASSERT_EQUAL((size_t)0, _fileEntry.getRemainingUris().size()); } diff --git a/test/FileEntryTest.cc b/test/FileEntryTest.cc index 3963e44e..42af9ec8 100644 --- a/test/FileEntryTest.cc +++ b/test/FileEntryTest.cc @@ -33,8 +33,8 @@ CPPUNIT_TEST_SUITE_REGISTRATION( FileEntryTest ); static SharedHandle<FileEntry> createFileEntry() { const char* uris[] = { "http://localhost/aria2.zip", - "ftp://localhost/aria2.zip", - "http://mirror/aria2.zip" }; + "ftp://localhost/aria2.zip", + "http://mirror/aria2.zip" }; SharedHandle<FileEntry> fileEntry(new FileEntry()); fileEntry->setUris(std::deque<std::string>(&uris[0], &uris[3])); return fileEntry; @@ -63,7 +63,7 @@ void FileEntryTest::testRemoveURIWhoseHostnameIs() fileEntry->removeURIWhoseHostnameIs("localhost"); CPPUNIT_ASSERT_EQUAL((size_t)1, fileEntry->getRemainingUris().size()); CPPUNIT_ASSERT_EQUAL(std::string("http://mirror/aria2.zip"), - fileEntry->getRemainingUris()[0]); + fileEntry->getRemainingUris()[0]); } @@ -83,9 +83,9 @@ void FileEntryTest::testExtractURIResult() CPPUNIT_ASSERT_EQUAL((size_t)2, fileEntry.getURIResults().size()); CPPUNIT_ASSERT_EQUAL(std::string("http://finished/file"), - fileEntry.getURIResults()[0].getURI()); + fileEntry.getURIResults()[0].getURI()); CPPUNIT_ASSERT_EQUAL(std::string("http://unknownerror/file"), - fileEntry.getURIResults()[1].getURI()); + fileEntry.getURIResults()[1].getURI()); res.clear(); @@ -140,7 +140,7 @@ void FileEntryTest::testReuseUri() } CPPUNIT_ASSERT_EQUAL((size_t)0, fileEntry->getRemainingUris().size()); fileEntry->addURIResult("http://localhost/aria2.zip", - downloadresultcode::UNKNOWN_ERROR); + downloadresultcode::UNKNOWN_ERROR); fileEntry->reuseUri(3); CPPUNIT_ASSERT_EQUAL((size_t)3, fileEntry->getRemainingUris().size()); const std::deque<std::string>& uris = fileEntry->getRemainingUris(); diff --git a/test/FtpConnectionTest.cc b/test/FtpConnectionTest.cc index caad1965..b11733ab 100644 --- a/test/FtpConnectionTest.cc +++ b/test/FtpConnectionTest.cc @@ -64,9 +64,9 @@ public: _serverSocket.reset(listenSocket->acceptConnection()); _ftp.reset(new FtpConnection(1, _clientSocket, req, - _authConfigFactory->createAuthConfig - (req, _option.get()), - _option.get())); + _authConfigFactory->createAuthConfig + (req, _option.get()), + _option.get())); } void tearDown() {} @@ -105,7 +105,7 @@ void FtpConnectionTest::testReceiveResponse() CPPUNIT_ASSERT_EQUAL((unsigned int)100, _ftp->receiveResponse()); // 2 responses in the buffer _serverSocket->writeData("101 single1\r\n" - "102 single2\r\n"); + "102 single2\r\n"); waitRead(_clientSocket); CPPUNIT_ASSERT_EQUAL((unsigned int)101, _ftp->receiveResponse()); CPPUNIT_ASSERT_EQUAL((unsigned int)102, _ftp->receiveResponse()); @@ -127,9 +127,9 @@ void FtpConnectionTest::testReceiveResponse() CPPUNIT_ASSERT_EQUAL((unsigned int)103, _ftp->receiveResponse()); _serverSocket->writeData("104-multi\r\n" - "104 \r\n" - "105-multi\r\n" - "105 \r\n"); + "104 \r\n" + "105-multi\r\n" + "105 \r\n"); waitRead(_clientSocket); CPPUNIT_ASSERT_EQUAL((unsigned int)104, _ftp->receiveResponse()); CPPUNIT_ASSERT_EQUAL((unsigned int)105, _ftp->receiveResponse()); diff --git a/test/GZipDecoderTest.cc b/test/GZipDecoderTest.cc index 31aa8f2f..b2cbfc2a 100644 --- a/test/GZipDecoderTest.cc +++ b/test/GZipDecoderTest.cc @@ -51,8 +51,8 @@ void GZipDecoderTest::testDecode() #ifdef ENABLE_MESSAGE_DIGEST CPPUNIT_ASSERT_EQUAL(std::string("8b577b33c0411b2be9d4fa74c7402d54a8d21f96"), - MessageDigestHelper::digest(MessageDigestContext::SHA1, - outfile)); + MessageDigestHelper::digest(MessageDigestContext::SHA1, + outfile)); #endif // ENABLE_MESSAGE_DIGEST } diff --git a/test/HandshakeExtensionMessageTest.cc b/test/HandshakeExtensionMessageTest.cc index 1cdd897c..58614389 100644 --- a/test/HandshakeExtensionMessageTest.cc +++ b/test/HandshakeExtensionMessageTest.cc @@ -64,11 +64,11 @@ void HandshakeExtensionMessageTest::testGetBencodedData() msg.setMetadataSize(1024); CPPUNIT_ASSERT_EQUAL (std::string("d" - "1:md6:a2_dhti2e6:ut_pexi1ee" - "13:metadata_sizei1024e" - "1:pi6889e" - "1:v5:aria2" - "e"), msg.getPayload()); + "1:md6:a2_dhti2e6:ut_pexi1ee" + "13:metadata_sizei1024e" + "1:pi6889e" + "1:v5:aria2" + "e"), msg.getPayload()); msg.setMetadataSize(0); CPPUNIT_ASSERT @@ -85,7 +85,7 @@ void HandshakeExtensionMessageTest::testToString() msg.setMetadataSize(1024); CPPUNIT_ASSERT_EQUAL (std::string("handshake client=aria2, tcpPort=6889, metadataSize=1024," - " a2_dht=2, ut_pex=1"), msg.toString()); + " a2_dht=2, ut_pex=1"), msg.toString()); } void HandshakeExtensionMessageTest::testDoReceivedAction() @@ -128,7 +128,7 @@ void HandshakeExtensionMessageTest::testCreate() "0d1:pi6881e1:v5:aria21:md6:ut_pexi1ee13:metadata_sizei1024ee"; SharedHandle<HandshakeExtensionMessage> m = HandshakeExtensionMessage::create(reinterpret_cast<const unsigned char*>(in.c_str()), - in.size()); + in.size()); CPPUNIT_ASSERT_EQUAL(std::string("aria2"), m->getClientVersion()); CPPUNIT_ASSERT_EQUAL((uint16_t)6881, m->getTCPPort()); CPPUNIT_ASSERT_EQUAL((uint8_t)1, m->getExtensionMessageID("ut_pex")); @@ -137,7 +137,7 @@ void HandshakeExtensionMessageTest::testCreate() // bad payload format std::string in = "011:hello world"; HandshakeExtensionMessage::create(reinterpret_cast<const unsigned char*>(in.c_str()), - in.size()); + in.size()); CPPUNIT_FAIL("exception must be thrown."); } catch(Exception& e) { std::cerr << e.stackTrace() << std::endl; @@ -146,7 +146,7 @@ void HandshakeExtensionMessageTest::testCreate() // malformed dencoded message std::string in = "011:hello"; HandshakeExtensionMessage::create(reinterpret_cast<const unsigned char*>(in.c_str()), - in.size()); + in.size()); CPPUNIT_FAIL("exception must be thrown."); } catch(Exception& e) { std::cerr << e.stackTrace() << std::endl; @@ -155,7 +155,7 @@ void HandshakeExtensionMessageTest::testCreate() // 0 length data std::string in = ""; HandshakeExtensionMessage::create(reinterpret_cast<const unsigned char*>(in.c_str()), - in.size()); + in.size()); CPPUNIT_FAIL("exception must be thrown."); } catch(Exception& e) { std::cerr << e.stackTrace() << std::endl; @@ -168,7 +168,7 @@ void HandshakeExtensionMessageTest::testCreate_stringnum() SharedHandle<HandshakeExtensionMessage> m = HandshakeExtensionMessage::create (reinterpret_cast<const unsigned char*>(in.c_str()), - in.size()); + in.size()); CPPUNIT_ASSERT_EQUAL(std::string("aria2"), m->getClientVersion()); // port number in string is not allowed CPPUNIT_ASSERT_EQUAL((uint16_t)0, m->getTCPPort()); diff --git a/test/HttpHeaderProcessorTest.cc b/test/HttpHeaderProcessorTest.cc index 3bd06dda..b3e0ba22 100644 --- a/test/HttpHeaderProcessorTest.cc +++ b/test/HttpHeaderProcessorTest.cc @@ -110,12 +110,12 @@ void HttpHeaderProcessorTest::testGetHttpResponseHeader() CPPUNIT_ASSERT_EQUAL(std::string("200"), header->getResponseStatus()); CPPUNIT_ASSERT_EQUAL(std::string("HTTP/1.1"), header->getVersion()); CPPUNIT_ASSERT_EQUAL(std::string("Mon, 25 Jun 2007 16:04:59 GMT"), - header->getFirst("Date")); + header->getFirst("Date")); CPPUNIT_ASSERT_EQUAL(std::string("Apache/2.2.3 (Debian)"), - header->getFirst("Server")); + header->getFirst("Server")); CPPUNIT_ASSERT_EQUAL((uint64_t)9187ULL, header->getFirstAsULLInt("Content-Length")); CPPUNIT_ASSERT_EQUAL(std::string("text/html; charset=UTF-8"), - header->getFirst("Content-Type")); + header->getFirst("Content-Type")); } void HttpHeaderProcessorTest::testGetHttpResponseHeader_empty() @@ -191,15 +191,15 @@ void HttpHeaderProcessorTest::testGetHeaderString() proc.update(hd); CPPUNIT_ASSERT_EQUAL(std::string("HTTP/1.1 200 OK\r\n" - "Date: Mon, 25 Jun 2007 16:04:59 GMT\r\n" - "Server: Apache/2.2.3 (Debian)\r\n" - "Last-Modified: Tue, 12 Jun 2007 14:28:43 GMT\r\n" - "ETag: \"594065-23e3-50825cc0\"\r\n" - "Accept-Ranges: bytes\r\n" - "Content-Length: 9187\r\n" - "Connection: close\r\n" - "Content-Type: text/html; charset=UTF-8"), - proc.getHeaderString()); + "Date: Mon, 25 Jun 2007 16:04:59 GMT\r\n" + "Server: Apache/2.2.3 (Debian)\r\n" + "Last-Modified: Tue, 12 Jun 2007 14:28:43 GMT\r\n" + "ETag: \"594065-23e3-50825cc0\"\r\n" + "Accept-Ranges: bytes\r\n" + "Content-Length: 9187\r\n" + "Connection: close\r\n" + "Content-Type: text/html; charset=UTF-8"), + proc.getHeaderString()); } void HttpHeaderProcessorTest::testGetHttpRequestHeader() diff --git a/test/HttpHeaderTest.cc b/test/HttpHeaderTest.cc index a0724b5c..64381bd2 100644 --- a/test/HttpHeaderTest.cc +++ b/test/HttpHeaderTest.cc @@ -26,7 +26,7 @@ void HttpHeaderTest::testGetRange() { HttpHeader httpHeader; httpHeader.put("Content-Range", - "9223372036854775800-9223372036854775801/9223372036854775807"); + "9223372036854775800-9223372036854775801/9223372036854775807"); SharedHandle<Range> range = httpHeader.getRange(); @@ -37,7 +37,7 @@ void HttpHeaderTest::testGetRange() { HttpHeader httpHeader; httpHeader.put("Content-Range", - "9223372036854775800-9223372036854775801/9223372036854775807"); + "9223372036854775800-9223372036854775801/9223372036854775807"); SharedHandle<Range> range = httpHeader.getRange(); diff --git a/test/HttpRequestTest.cc b/test/HttpRequestTest.cc index 9c1f9cc3..1e600172 100644 --- a/test/HttpRequestTest.cc +++ b/test/HttpRequestTest.cc @@ -106,13 +106,13 @@ void HttpRequestTest::testGetEndByte() httpRequest.setFileEntry(fileEntry); CPPUNIT_ASSERT_EQUAL((off_t)(segmentLength*index+length-1), - httpRequest.getEndByte()); + httpRequest.getEndByte()); // The end byte of FileEntry are placed inside segment fileEntry->setLength(segmentLength+100); CPPUNIT_ASSERT_EQUAL((off_t)(segmentLength*index+100-1), - httpRequest.getEndByte()); + httpRequest.getEndByte()); request->setPipeliningHint(false); @@ -239,7 +239,7 @@ void HttpRequestTest::testCreateRequest() _option->put(PREF_HTTP_PASSWD, "aria2passwd"); CPPUNIT_ASSERT(_authConfigFactory->activateBasicCred - ("localhost", "/", _option.get())); + ("localhost", "/", _option.get())); expectedText = "GET /archives/aria2-1.0.0.tar.bz2 HTTP/1.1\r\n" "User-Agent: aria2\r\n" @@ -256,7 +256,7 @@ void HttpRequestTest::testCreateRequest() // enable http proxy auth SharedHandle<Request> proxyRequest(new Request()); CPPUNIT_ASSERT(proxyRequest->setUrl - ("http://aria2proxyuser:aria2proxypasswd@localhost:9000")); + ("http://aria2proxyuser:aria2proxypasswd@localhost:9000")); httpRequest.setProxyRequest(proxyRequest); expectedText = "GET http://localhost:8080/archives/aria2-1.0.0.tar.bz2 HTTP/1.1\r\n" @@ -310,15 +310,15 @@ void HttpRequestTest::testCreateRequest() void HttpRequestTest::testCreateRequest_ftp() { - _option->put(PREF_FTP_USER, "aria2user"); - _option->put(PREF_FTP_PASSWD, "aria2passwd"); + _option->put(PREF_FTP_USER, "aria2user"); + _option->put(PREF_FTP_PASSWD, "aria2passwd"); SharedHandle<Request> request(new Request()); request->setUrl("ftp://localhost:8080/archives/aria2-1.0.0.tar.bz2"); SharedHandle<Request> proxyRequest(new Request()); CPPUNIT_ASSERT(proxyRequest->setUrl - ("http://localhost:9000")); + ("http://localhost:9000")); HttpRequest httpRequest; SharedHandle<Piece> p(new Piece(0, 1024*1024)); @@ -350,7 +350,7 @@ void HttpRequestTest::testCreateRequest_ftp() // test proxy authorization CPPUNIT_ASSERT(proxyRequest->setUrl - ("http://aria2proxyuser:aria2proxypasswd@localhost:9000")); + ("http://aria2proxyuser:aria2proxypasswd@localhost:9000")); expectedText = "GET ftp://aria2user@localhost:8080/archives/aria2-1.0.0.tar.bz2" @@ -439,7 +439,7 @@ void HttpRequestTest::testCreateRequest_with_cookie() CPPUNIT_ASSERT_EQUAL(expectedText, httpRequest.createRequest()); request->setUrl("https://www.aria2.org/archives/download/" - "aria2-1.0.0.tar.bz2"); + "aria2-1.0.0.tar.bz2"); expectedText = "GET /archives/download/aria2-1.0.0.tar.bz2 HTTP/1.1\r\n" "User-Agent: aria2\r\n" @@ -545,7 +545,7 @@ void HttpRequestTest::testCreateProxyRequest() // test proxy authorization CPPUNIT_ASSERT(proxyRequest->setUrl - ("http://aria2proxyuser:aria2proxypasswd@localhost:9000")); + ("http://aria2proxyuser:aria2proxypasswd@localhost:9000")); expectedText = "CONNECT localhost:80 HTTP/1.1\r\n" "User-Agent: aria2\r\n" @@ -602,13 +602,13 @@ void HttpRequestTest::testIsRangeSatisfied() CPPUNIT_ASSERT(!httpRequest.isRangeSatisfied(range)); range.reset(new Range(segment->getPosition(), - segment->getPosition()+segment->getLength()-1, - entityLength)); + segment->getPosition()+segment->getLength()-1, + entityLength)); CPPUNIT_ASSERT(httpRequest.isRangeSatisfied(range)); range.reset(new Range(0, segment->getPosition()+segment->getLength()-1, - entityLength)); + entityLength)); CPPUNIT_ASSERT(!httpRequest.isRangeSatisfied(range)); } @@ -681,7 +681,7 @@ void HttpRequestTest::testAddHeader() void HttpRequestTest::testAddAcceptType() { std::string acceptTypes[] = { "cream/custard", - "muffin/chocolate" }; + "muffin/chocolate" }; SharedHandle<Request> request(new Request()); request->setUrl("http://localhost/archives/aria2-1.0.0.tar.bz2"); @@ -691,7 +691,7 @@ void HttpRequestTest::testAddAcceptType() httpRequest.setRequest(request); httpRequest.setAuthConfigFactory(_authConfigFactory, _option.get()); httpRequest.addAcceptType(&acceptTypes[0], - &acceptTypes[arrayLength(acceptTypes)]); + &acceptTypes[arrayLength(acceptTypes)]); std::string expectedText = "GET /archives/aria2-1.0.0.tar.bz2 HTTP/1.1\r\n" diff --git a/test/HttpResponseTest.cc b/test/HttpResponseTest.cc index 89ebfaa1..4b3d3b4b 100644 --- a/test/HttpResponseTest.cc +++ b/test/HttpResponseTest.cc @@ -128,7 +128,7 @@ void HttpResponseTest::testGetContentType() httpResponse.setHttpHeader(httpHeader); // See paramter is ignored. CPPUNIT_ASSERT_EQUAL(std::string("application/metalink+xml"), - httpResponse.getContentType()); + httpResponse.getContentType()); } void HttpResponseTest::testDeterminFilename_without_ContentDisposition() @@ -144,7 +144,7 @@ void HttpResponseTest::testDeterminFilename_without_ContentDisposition() httpResponse.setHttpRequest(httpRequest); CPPUNIT_ASSERT_EQUAL(std::string("aria2-1.0.0.tar.bz2"), - httpResponse.determinFilename()); + httpResponse.determinFilename()); } void HttpResponseTest::testDeterminFilename_with_ContentDisposition_zero_length @@ -162,7 +162,7 @@ void HttpResponseTest::testDeterminFilename_with_ContentDisposition_zero_length httpResponse.setHttpRequest(httpRequest); CPPUNIT_ASSERT_EQUAL(std::string("aria2-1.0.0.tar.bz2"), - httpResponse.determinFilename()); + httpResponse.determinFilename()); } void HttpResponseTest::testDeterminFilename_with_ContentDisposition() @@ -170,7 +170,7 @@ void HttpResponseTest::testDeterminFilename_with_ContentDisposition() HttpResponse httpResponse; SharedHandle<HttpHeader> httpHeader(new HttpHeader()); httpHeader->put("Content-Disposition", - "attachment; filename=\"aria2-current.tar.bz2\""); + "attachment; filename=\"aria2-current.tar.bz2\""); SharedHandle<HttpRequest> httpRequest(new HttpRequest()); SharedHandle<Request> request(new Request()); request->setUrl("http://localhost/archives/aria2-1.0.0.tar.bz2"); @@ -180,7 +180,7 @@ void HttpResponseTest::testDeterminFilename_with_ContentDisposition() httpResponse.setHttpRequest(httpRequest); CPPUNIT_ASSERT_EQUAL(std::string("aria2-current.tar.bz2"), - httpResponse.determinFilename()); + httpResponse.determinFilename()); } void HttpResponseTest::testGetRedirectURI_without_Location() @@ -191,7 +191,7 @@ void HttpResponseTest::testGetRedirectURI_without_Location() httpResponse.setHttpHeader(httpHeader); CPPUNIT_ASSERT_EQUAL(std::string(""), - httpResponse.getRedirectURI()); + httpResponse.getRedirectURI()); } void HttpResponseTest::testGetRedirectURI_with_Location() @@ -248,7 +248,7 @@ void HttpResponseTest::testGetTransferEncoding() httpHeader->put("Transfer-Encoding", "chunked"); CPPUNIT_ASSERT_EQUAL(std::string("chunked"), - httpResponse.getTransferEncoding()); + httpResponse.getTransferEncoding()); } void HttpResponseTest::testGetTransferEncodingDecoder() @@ -486,9 +486,9 @@ void HttpResponseTest::testRetrieveCookie() httpResponse.setHttpRequest(httpRequest); httpHeader->put("Set-Cookie", "k1=v1; expires=Sun, 10-Jun-2007 11:00:00 GMT;" - "path=/; domain=.aria2.org;"); + "path=/; domain=.aria2.org;"); httpHeader->put("Set-Cookie", "k2=v2; expires=Sun, 01-Jan-38 00:00:00 GMT;" - "path=/; domain=.aria2.org;"); + "path=/; domain=.aria2.org;"); httpHeader->put("Set-Cookie", "k3=v3;"); httpResponse.retrieveCookie(); diff --git a/test/InOrderPieceSelector.h b/test/InOrderPieceSelector.h index 396b8879..cb174af2 100644 --- a/test/InOrderPieceSelector.h +++ b/test/InOrderPieceSelector.h @@ -13,8 +13,8 @@ public: { for(size_t i = 0; i < nbits; ++i) { if(bitfield::test(bitfield, nbits, i)) { - index = i; - return true; + index = i; + return true; } } return false; diff --git a/test/InOrderURISelectorTest.cc b/test/InOrderURISelectorTest.cc index 9efc2f3c..eef93467 100644 --- a/test/InOrderURISelectorTest.cc +++ b/test/InOrderURISelectorTest.cc @@ -46,11 +46,11 @@ CPPUNIT_TEST_SUITE_REGISTRATION(InOrderURISelectorTest); void InOrderURISelectorTest::testSelect() { CPPUNIT_ASSERT_EQUAL(std::string("http://alpha/file"), - sel->select(&_fileEntry)); + sel->select(&_fileEntry)); CPPUNIT_ASSERT_EQUAL(std::string("ftp://alpha/file"), - sel->select(&_fileEntry)); + sel->select(&_fileEntry)); CPPUNIT_ASSERT_EQUAL(std::string("http://bravo/file"), - sel->select(&_fileEntry)); + sel->select(&_fileEntry)); CPPUNIT_ASSERT_EQUAL(std::string(""), sel->select(&_fileEntry)); } diff --git a/test/IteratableChunkChecksumValidatorTest.cc b/test/IteratableChunkChecksumValidatorTest.cc index 823b6e8c..127aadf2 100644 --- a/test/IteratableChunkChecksumValidatorTest.cc +++ b/test/IteratableChunkChecksumValidatorTest.cc @@ -32,8 +32,8 @@ public: CPPUNIT_TEST_SUITE_REGISTRATION( IteratableChunkChecksumValidatorTest ); const char* IteratableChunkChecksumValidatorTest::csArray[] = { "29b0e7878271645fffb7eec7db4a7473a1c00bc1", - "4df75a661cb7eb2733d9cdaa7f772eae3a4e2976", - "0a4ea2f7dd7c52ddf2099a444ab2184b4d341bdb" }; + "4df75a661cb7eb2733d9cdaa7f772eae3a4e2976", + "0a4ea2f7dd7c52ddf2099a444ab2184b4d341bdb" }; void IteratableChunkChecksumValidatorTest::testValidate() { Option option; @@ -95,9 +95,9 @@ void IteratableChunkChecksumValidatorTest::testValidate_readError() { CPPUNIT_ASSERT(ps->hasPiece(0)); CPPUNIT_ASSERT(ps->hasPiece(1)); CPPUNIT_ASSERT(!ps->hasPiece(2)); // #2 piece is not valid because - // #program expects its size is - // #100, but it reads only 50 - // #bytes and raises error. + // #program expects its size is + // #100, but it reads only 50 + // #bytes and raises error. CPPUNIT_ASSERT(!ps->hasPiece(3)); CPPUNIT_ASSERT(!ps->hasPiece(4)); } diff --git a/test/MSEHandshakeTest.cc b/test/MSEHandshakeTest.cc index 9750304f..717aa4d0 100644 --- a/test/MSEHandshakeTest.cc +++ b/test/MSEHandshakeTest.cc @@ -25,7 +25,7 @@ private: SharedHandle<DownloadContext> _dctx; void doHandshake(const SharedHandle<MSEHandshake>& initiator, - const SharedHandle<MSEHandshake>& receiver); + const SharedHandle<MSEHandshake>& receiver); public: void setUp() @@ -46,7 +46,7 @@ public: CPPUNIT_TEST_SUITE_REGISTRATION(MSEHandshakeTest); static std::pair<SharedHandle<SocketCore>, - SharedHandle<SocketCore> > createSocketPair() + SharedHandle<SocketCore> > createSocketPair() { SharedHandle<SocketCore> initiatorSock(new SocketCore()); @@ -93,7 +93,7 @@ void MSEHandshakeTest::doHandshake(const SharedHandle<MSEHandshake>& initiator, static SharedHandle<MSEHandshake> createMSEHandshake(SharedHandle<SocketCore> socket, bool initiator, - const Option* option) + const Option* option) { SharedHandle<MSEHandshake> h(new MSEHandshake(1, socket, option)); h->initEncryptionFacility(initiator); diff --git a/test/MessageDigestHelperTest.cc b/test/MessageDigestHelperTest.cc index b07bd48a..e2a89c4a 100644 --- a/test/MessageDigestHelperTest.cc +++ b/test/MessageDigestHelperTest.cc @@ -33,23 +33,23 @@ void MessageDigestHelperTest::testDigestDiskWriter() { (new DefaultDiskWriter("4096chunk.txt")); diskio->openExistingFile(); CPPUNIT_ASSERT_EQUAL(std::string("608cabc0f2fa18c260cafd974516865c772363d5"), - MessageDigestHelper::digest("sha1", diskio, 0, 4096)); + MessageDigestHelper::digest("sha1", diskio, 0, 4096)); CPPUNIT_ASSERT_EQUAL(std::string("7a4a9ae537ebbbb826b1060e704490ad0f365ead"), - MessageDigestHelper::digest("sha1", diskio, 5, 100)); + MessageDigestHelper::digest("sha1", diskio, 5, 100)); } void MessageDigestHelperTest::testDigestFilename() { CPPUNIT_ASSERT_EQUAL(std::string("608cabc0f2fa18c260cafd974516865c772363d5"), - MessageDigestHelper::digest("sha1", "4096chunk.txt")); + MessageDigestHelper::digest("sha1", "4096chunk.txt")); } void MessageDigestHelperTest::testDigestData() { std::string data = "aria2"; CPPUNIT_ASSERT_EQUAL(std::string("f36003f22b462ffa184390533c500d8989e9f681"), - MessageDigestHelper::digest("sha1", data.c_str(), data.size())); + MessageDigestHelper::digest("sha1", data.c_str(), data.size())); } } // namespace aria2 diff --git a/test/Metalink2RequestGroupTest.cc b/test/Metalink2RequestGroupTest.cc index c02ef304..defb99f8 100644 --- a/test/Metalink2RequestGroupTest.cc +++ b/test/Metalink2RequestGroupTest.cc @@ -59,7 +59,7 @@ void Metalink2RequestGroupTest::testGenerate() CPPUNIT_ASSERT_EQUAL(std::string("sha1"), dctx->getChecksumHashAlgo()); CPPUNIT_ASSERT_EQUAL (std::string("a96cf3f0266b91d87d5124cf94326422800b627d"), - dctx->getChecksum()); + dctx->getChecksum()); #endif // ENABLE_MESSAGE_DIGEST CPPUNIT_ASSERT(!dctx->getSignature().isNull()); CPPUNIT_ASSERT_EQUAL(std::string("pgp"), dctx->getSignature()->getType()); diff --git a/test/MetalinkEntryTest.cc b/test/MetalinkEntryTest.cc index 1812d739..f8b2af24 100644 --- a/test/MetalinkEntryTest.cc +++ b/test/MetalinkEntryTest.cc @@ -80,16 +80,16 @@ void MetalinkEntryTest::testDropUnsupportedResource() { std::deque<SharedHandle<MetalinkResource> >::const_iterator itr = entry->resources.begin(); CPPUNIT_ASSERT_EQUAL(MetalinkResource::TYPE_FTP, - (*itr++)->type); + (*itr++)->type); CPPUNIT_ASSERT_EQUAL(MetalinkResource::TYPE_HTTP, - (*itr++)->type); + (*itr++)->type); #ifdef ENABLE_BITTORRENT CPPUNIT_ASSERT_EQUAL(MetalinkResource::TYPE_BITTORRENT, - (*itr++)->type); + (*itr++)->type); #endif // ENABLE_BITTORRENT #ifdef ENABLE_SSL CPPUNIT_ASSERT_EQUAL(MetalinkResource::TYPE_HTTPS, - (*itr++)->type); + (*itr++)->type); #endif // ENABLE_SSL } diff --git a/test/MetalinkProcessorTest.cc b/test/MetalinkProcessorTest.cc index ecf04c36..1f4fe1ba 100644 --- a/test/MetalinkProcessorTest.cc +++ b/test/MetalinkProcessorTest.cc @@ -82,23 +82,23 @@ void MetalinkProcessorTest::testParseFile() CPPUNIT_ASSERT_EQUAL(1, entry1->maxConnections); #ifdef ENABLE_MESSAGE_DIGEST CPPUNIT_ASSERT_EQUAL(std::string("a96cf3f0266b91d87d5124cf94326422800b627d"), - entry1->checksum->getMessageDigest()); + entry1->checksum->getMessageDigest()); CPPUNIT_ASSERT_EQUAL(std::string("sha1"), entry1->checksum->getAlgo()); #endif // ENABLE_MESSAGE_DIGEST CPPUNIT_ASSERT(!entry1->getSignature().isNull()); CPPUNIT_ASSERT_EQUAL(std::string("pgp"), entry1->getSignature()->getType()); CPPUNIT_ASSERT_EQUAL(std::string("aria2-0.5.2.tar.bz2.sig"), - entry1->getSignature()->getFile()); + entry1->getSignature()->getFile()); // Note that last '\n' character is trimmed. CPPUNIT_ASSERT_EQUAL (std::string ("-----BEGIN PGP SIGNATURE-----\n" - "Version: GnuPG v1.4.9 (GNU/Linux)\n" - "\n" - "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff\n" - "ffffffffffffffffffffffff\n" - "fffff\n" - "-----END PGP SIGNATURE-----"), + "Version: GnuPG v1.4.9 (GNU/Linux)\n" + "\n" + "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff\n" + "ffffffffffffffffffffffff\n" + "fffff\n" + "-----END PGP SIGNATURE-----"), entry1->getSignature()->getBody()); std::deque<SharedHandle<MetalinkResource> >::iterator resourceItr1 = entry1->resources.begin(); @@ -107,7 +107,7 @@ void MetalinkProcessorTest::testParseFile() CPPUNIT_ASSERT_EQUAL(std::string("JP"), resource1->location); CPPUNIT_ASSERT_EQUAL(100, resource1->preference); CPPUNIT_ASSERT_EQUAL(std::string("ftp://ftphost/aria2-0.5.2.tar.bz2"), - resource1->url); + resource1->url); CPPUNIT_ASSERT_EQUAL(1, resource1->maxConnections); resourceItr1++; @@ -116,7 +116,7 @@ void MetalinkProcessorTest::testParseFile() CPPUNIT_ASSERT_EQUAL(std::string("US"), resource2->location); CPPUNIT_ASSERT_EQUAL(100, resource2->preference); CPPUNIT_ASSERT_EQUAL(std::string("http://httphost/aria2-0.5.2.tar.bz2"), - resource2->url); + resource2->url); CPPUNIT_ASSERT_EQUAL(-1, resource2->maxConnections); entryItr++; @@ -130,13 +130,13 @@ void MetalinkProcessorTest::testParseFile() CPPUNIT_ASSERT_EQUAL(-1, entry2->maxConnections); #ifdef ENABLE_MESSAGE_DIGEST CPPUNIT_ASSERT_EQUAL(std::string("4c255b0ed130f5ea880f0aa061c3da0487e251cc"), - entry2->checksum->getMessageDigest()); + entry2->checksum->getMessageDigest()); CPPUNIT_ASSERT_EQUAL((size_t)2, entry2->chunkChecksum->countChecksum()); CPPUNIT_ASSERT_EQUAL((size_t)262144, entry2->chunkChecksum->getChecksumLength()); CPPUNIT_ASSERT_EQUAL(std::string("179463a88d79cbf0b1923991708aead914f26142"), - entry2->chunkChecksum->getChecksum(0)); + entry2->chunkChecksum->getChecksum(0)); CPPUNIT_ASSERT_EQUAL(std::string("fecf8bc9a1647505fe16746f94e97a477597dbf3"), - entry2->chunkChecksum->getChecksum(1)); + entry2->chunkChecksum->getChecksum(1)); CPPUNIT_ASSERT_EQUAL(std::string("sha1"), entry2->checksum->getAlgo()); #endif // ENABLE_MESSAGE_DIGEST // See that signature is null @@ -159,11 +159,11 @@ void MetalinkProcessorTest::testParseFile() CPPUNIT_ASSERT_EQUAL(std::string("UnsupportedVerificationHashTypeIncluded"), entry4->getPath()); #ifdef ENABLE_MESSAGE_DIGEST CPPUNIT_ASSERT_EQUAL(std::string("sha1"), - entry4->checksum->getAlgo()); + entry4->checksum->getAlgo()); CPPUNIT_ASSERT_EQUAL(std::string("4c255b0ed130f5ea880f0aa061c3da0487e251cc"), - entry4->checksum->getMessageDigest()); + entry4->checksum->getMessageDigest()); CPPUNIT_ASSERT_EQUAL(std::string("sha1"), - entry4->chunkChecksum->getAlgo()); + entry4->chunkChecksum->getAlgo()); #endif // ENABLE_MESSAGE_DIGEST @@ -222,15 +222,15 @@ void MetalinkProcessorTest::testBadSize() MetalinkProcessor proc; SharedHandle<ByteArrayDiskWriter> dw(new ByteArrayDiskWriter()); dw->setString("<metalink>" - "<files>" - "<file name=\"aria2-0.5.2.tar.bz2\">" - " <size>abc</size>" - " <version>0.5.2</version>" - " <language>en-US</language>" - " <os>Linux-x86</os>" - "</file>" - "</files>" - "</metalink>"); + "<files>" + "<file name=\"aria2-0.5.2.tar.bz2\">" + " <size>abc</size>" + " <version>0.5.2</version>" + " <language>en-US</language>" + " <os>Linux-x86</os>" + "</file>" + "</files>" + "</metalink>"); try { SharedHandle<Metalinker> m = proc.parseFromBinaryStream(dw); @@ -253,16 +253,16 @@ void MetalinkProcessorTest::testBadMaxConn() MetalinkProcessor proc; SharedHandle<ByteArrayDiskWriter> dw(new ByteArrayDiskWriter()); dw->setString("<metalink>" - "<files>" - "<file name=\"aria2-0.5.2.tar.bz2\">" - " <size>43743838</size>" - " <version>0.5.2</version>" - " <language>en-US</language>" - " <os>Linux-x86</os>" - " <resources maxconnections=\"abc\"/>" - "</file>" - "</files>" - "</metalink>"); + "<files>" + "<file name=\"aria2-0.5.2.tar.bz2\">" + " <size>43743838</size>" + " <version>0.5.2</version>" + " <language>en-US</language>" + " <os>Linux-x86</os>" + " <resources maxconnections=\"abc\"/>" + "</file>" + "</files>" + "</metalink>"); try { SharedHandle<Metalinker> m = proc.parseFromBinaryStream(dw); @@ -280,21 +280,21 @@ void MetalinkProcessorTest::testNoName() MetalinkProcessor proc; SharedHandle<ByteArrayDiskWriter> dw(new ByteArrayDiskWriter()); dw->setString("<metalink>" - "<files>" - "<file>" - " <size>1024</size>" - " <version>0.0.1</version>" - " <language>GB</language>" - " <os>Linux-x64</os>" - "</file>" - "<file name=\"aria2-0.5.2.tar.bz2\">" - " <size>43743838</size>" - " <version>0.5.2</version>" - " <language>en-US</language>" - " <os>Linux-x86</os>" - "</file>" - "</files>" - "</metalink>"); + "<files>" + "<file>" + " <size>1024</size>" + " <version>0.0.1</version>" + " <language>GB</language>" + " <os>Linux-x64</os>" + "</file>" + "<file name=\"aria2-0.5.2.tar.bz2\">" + " <size>43743838</size>" + " <version>0.5.2</version>" + " <language>en-US</language>" + " <os>Linux-x86</os>" + "</file>" + "</files>" + "</metalink>"); try { SharedHandle<Metalinker> m = proc.parseFromBinaryStream(dw); @@ -312,18 +312,18 @@ void MetalinkProcessorTest::testBadURLPrefs() MetalinkProcessor proc; SharedHandle<ByteArrayDiskWriter> dw(new ByteArrayDiskWriter()); dw->setString("<metalink>" - "<files>" - "<file name=\"aria2-0.5.2.tar.bz2\">" - " <size>43743838</size>" - " <version>0.5.2</version>" - " <language>en-US</language>" - " <os>Linux-x86</os>" - " <resources>" - " <url type=\"ftp\" maxconnections=\"1\" preference=\"xyz\" location=\"JP\">ftp://mirror/</url>" - " </resources>" - "</file>" - "</files>" - "</metalink>"); + "<files>" + "<file name=\"aria2-0.5.2.tar.bz2\">" + " <size>43743838</size>" + " <version>0.5.2</version>" + " <language>en-US</language>" + " <os>Linux-x86</os>" + " <resources>" + " <url type=\"ftp\" maxconnections=\"1\" preference=\"xyz\" location=\"JP\">ftp://mirror/</url>" + " </resources>" + "</file>" + "</files>" + "</metalink>"); try { SharedHandle<Metalinker> m = proc.parseFromBinaryStream(dw); @@ -343,18 +343,18 @@ void MetalinkProcessorTest::testBadURLMaxConn() MetalinkProcessor proc; SharedHandle<ByteArrayDiskWriter> dw(new ByteArrayDiskWriter()); dw->setString("<metalink>" - "<files>" - "<file name=\"aria2-0.5.2.tar.bz2\">" - " <size>43743838</size>" - " <version>0.5.2</version>" - " <language>en-US</language>" - " <os>Linux-x86</os>" - " <resources>" - " <url maxconnections=\"xyz\" type=\"ftp\" preference=\"100\" location=\"JP\">ftp://mirror/</url>" - " </resources>" - "</file>" - "</files>" - "</metalink>"); + "<files>" + "<file name=\"aria2-0.5.2.tar.bz2\">" + " <size>43743838</size>" + " <version>0.5.2</version>" + " <language>en-US</language>" + " <os>Linux-x86</os>" + " <resources>" + " <url maxconnections=\"xyz\" type=\"ftp\" preference=\"100\" location=\"JP\">ftp://mirror/</url>" + " </resources>" + "</file>" + "</files>" + "</metalink>"); try { SharedHandle<Metalinker> m = proc.parseFromBinaryStream(dw); @@ -375,20 +375,20 @@ void MetalinkProcessorTest::testUnsupportedType() MetalinkProcessor proc; SharedHandle<ByteArrayDiskWriter> dw(new ByteArrayDiskWriter()); dw->setString("<metalink>" - "<files>" - "<file name=\"aria2-0.5.2.tar.bz2\">" - " <size>43743838</size>" - " <version>0.5.2</version>" - " <language>en-US</language>" - " <os>Linux-x86</os>" - " <resources>" - " <url type=\"ftp\">ftp://mirror/</url>" - " <url type=\"magnet\">magnet:xt=XYZ</url>" - " <url type=\"http\">http://mirror/</url>" - " </resources>" - "</file>" - "</files>" - "</metalink>"); + "<files>" + "<file name=\"aria2-0.5.2.tar.bz2\">" + " <size>43743838</size>" + " <version>0.5.2</version>" + " <language>en-US</language>" + " <os>Linux-x86</os>" + " <resources>" + " <url type=\"ftp\">ftp://mirror/</url>" + " <url type=\"magnet\">magnet:xt=XYZ</url>" + " <url type=\"http\">http://mirror/</url>" + " </resources>" + "</file>" + "</files>" + "</metalink>"); try { SharedHandle<Metalinker> m = proc.parseFromBinaryStream(dw); @@ -410,17 +410,17 @@ void MetalinkProcessorTest::testMultiplePieces() MetalinkProcessor proc; SharedHandle<ByteArrayDiskWriter> dw(new ByteArrayDiskWriter()); dw->setString("<metalink>" - "<files>" - "<file name=\"aria2.tar.bz2\">" - " <verification>" - " <pieces length=\"1024\" type=\"sha1\">" - " </pieces>" - " <pieces length=\"512\" type=\"md5\">" - " </pieces>" - " </verification>" - "</file>" - "</files>" - "</metalink>"); + "<files>" + "<file name=\"aria2.tar.bz2\">" + " <verification>" + " <pieces length=\"1024\" type=\"sha1\">" + " </pieces>" + " <pieces length=\"512\" type=\"md5\">" + " </pieces>" + " </verification>" + "</file>" + "</files>" + "</metalink>"); try { // aria2 prefers sha1 @@ -440,20 +440,20 @@ void MetalinkProcessorTest::testBadPieceNo() MetalinkProcessor proc; SharedHandle<ByteArrayDiskWriter> dw(new ByteArrayDiskWriter()); dw->setString("<metalink>" - "<files>" - "<file name=\"aria2.tar.bz2\">" - " <verification>" - " <pieces length=\"512\" type=\"sha1\">" - " <hash piece=\"0\">abc</hash>" - " <hash piece=\"xyz\">xyz</hash>" - " </pieces>" - " <pieces length=\"1024\" type=\"sha1\">" - " <hash piece=\"0\">abc</hash>" - " </pieces>" - " </verification>" - "</file>" - "</files>" - "</metalink>"); + "<files>" + "<file name=\"aria2.tar.bz2\">" + " <verification>" + " <pieces length=\"512\" type=\"sha1\">" + " <hash piece=\"0\">abc</hash>" + " <hash piece=\"xyz\">xyz</hash>" + " </pieces>" + " <pieces length=\"1024\" type=\"sha1\">" + " <hash piece=\"0\">abc</hash>" + " </pieces>" + " </verification>" + "</file>" + "</files>" + "</metalink>"); try { SharedHandle<Metalinker> m = proc.parseFromBinaryStream(dw); @@ -473,28 +473,28 @@ void MetalinkProcessorTest::testBadPieceLength() MetalinkProcessor proc; SharedHandle<ByteArrayDiskWriter> dw(new ByteArrayDiskWriter()); dw->setString("<metalink>" - "<files>" - "<file name=\"aria2.tar.bz2\">" - " <verification>" - " <pieces length=\"xyz\" type=\"sha1\">" - " <hash piece=\"0\">abc</hash>" - " </pieces>" - " <pieces length=\"1024\" type=\"sha1\">" - " <hash piece=\"0\">abc</hash>" - " </pieces>" - " </verification>" - "</file>" - "</files>" - "</metalink>"); + "<files>" + "<file name=\"aria2.tar.bz2\">" + " <verification>" + " <pieces length=\"xyz\" type=\"sha1\">" + " <hash piece=\"0\">abc</hash>" + " </pieces>" + " <pieces length=\"1024\" type=\"sha1\">" + " <hash piece=\"0\">abc</hash>" + " </pieces>" + " </verification>" + "</file>" + "</files>" + "</metalink>"); try { SharedHandle<Metalinker> m = proc.parseFromBinaryStream(dw); CPPUNIT_ASSERT_EQUAL((size_t)1, m->entries.size()); - SharedHandle<MetalinkEntry> e = m->entries[0]; - SharedHandle<ChunkChecksum> c = e->chunkChecksum; - CPPUNIT_ASSERT(!c.isNull()); - CPPUNIT_ASSERT_EQUAL((size_t)1024, c->getChecksumLength()); - CPPUNIT_ASSERT_EQUAL(std::string("sha1"), c->getAlgo()); + SharedHandle<MetalinkEntry> e = m->entries[0]; + SharedHandle<ChunkChecksum> c = e->chunkChecksum; + CPPUNIT_ASSERT(!c.isNull()); + CPPUNIT_ASSERT_EQUAL((size_t)1024, c->getChecksumLength()); + CPPUNIT_ASSERT_EQUAL(std::string("sha1"), c->getAlgo()); } catch(Exception& e) { CPPUNIT_FAIL(e.stackTrace()); } @@ -505,19 +505,19 @@ void MetalinkProcessorTest::testUnsupportedType_piece() MetalinkProcessor proc; SharedHandle<ByteArrayDiskWriter> dw(new ByteArrayDiskWriter()); dw->setString("<metalink>" - "<files>" - "<file name=\"aria2.tar.bz2\">" - " <verification>" - " <pieces length=\"512\" type=\"ARIA2\">" - " <hash piece=\"0\">abc</hash>" - " </pieces>" - " <pieces length=\"1024\" type=\"sha1\">" - " <hash piece=\"0\">abc</hash>" - " </pieces>" - " </verification>" - "</file>" - "</files>" - "</metalink>"); + "<files>" + "<file name=\"aria2.tar.bz2\">" + " <verification>" + " <pieces length=\"512\" type=\"ARIA2\">" + " <hash piece=\"0\">abc</hash>" + " </pieces>" + " <pieces length=\"1024\" type=\"sha1\">" + " <hash piece=\"0\">abc</hash>" + " </pieces>" + " </verification>" + "</file>" + "</files>" + "</metalink>"); try { SharedHandle<Metalinker> m = proc.parseFromBinaryStream(dw); @@ -538,15 +538,15 @@ void MetalinkProcessorTest::testLargeFileSize() MetalinkProcessor proc; SharedHandle<ByteArrayDiskWriter> dw(new ByteArrayDiskWriter()); dw->setString("<metalink>" - "<files>" - "<file name=\"dvd.iso\">" - " <size>9223372036854775807</size>" - " <resources>" - " <url type=\"http\">ftp://mirror/</url>" - " </resources>" - "</file>" - "</files>" - "</metalink>"); + "<files>" + "<file name=\"dvd.iso\">" + " <size>9223372036854775807</size>" + " <resources>" + " <url type=\"http\">ftp://mirror/</url>" + " </resources>" + "</file>" + "</files>" + "</metalink>"); try { SharedHandle<Metalinker> m = proc.parseFromBinaryStream(dw); diff --git a/test/MockBtAnnounce.h b/test/MockBtAnnounce.h index 790a6c6b..9d32ab70 100644 --- a/test/MockBtAnnounce.h +++ b/test/MockBtAnnounce.h @@ -43,7 +43,7 @@ public: virtual void resetAnnounce() {} virtual void processAnnounceResponse(const unsigned char* trackerResponse, - size_t trackerResponseLength) {} + size_t trackerResponseLength) {} virtual bool noMoreAnnounce() { return false; diff --git a/test/MockBtMessage.h b/test/MockBtMessage.h index 6feb8d4b..b07e6d56 100644 --- a/test/MockBtMessage.h +++ b/test/MockBtMessage.h @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the diff --git a/test/MockBtMessageFactory.h b/test/MockBtMessageFactory.h index c3a82a20..fa0a56d2 100644 --- a/test/MockBtMessageFactory.h +++ b/test/MockBtMessageFactory.h @@ -25,7 +25,7 @@ public: virtual SharedHandle<BtHandshakeMessage> createHandshakeMessage(const unsigned char* infoHash, - const unsigned char* peerId) { + const unsigned char* peerId) { return SharedHandle<BtHandshakeMessage>(); } diff --git a/test/MockDHTMessage.h b/test/MockDHTMessage.h index 3c6b0f50..4cac30e4 100644 --- a/test/MockDHTMessage.h +++ b/test/MockDHTMessage.h @@ -23,9 +23,9 @@ public: std::string _token; public: MockDHTMessage(const SharedHandle<DHTNode>& localNode, - const SharedHandle<DHTNode>& remoteNode, - const std::string& messageType = "mock", - const std::string& transactionID = ""): + const SharedHandle<DHTNode>& remoteNode, + const std::string& messageType = "mock", + const std::string& transactionID = ""): DHTMessage(localNode, remoteNode, transactionID), _isReply(false), _messageType(messageType) {} virtual ~MockDHTMessage() {} diff --git a/test/MockDHTMessageDispatcher.h b/test/MockDHTMessageDispatcher.h index 12513472..58c24090 100644 --- a/test/MockDHTMessageDispatcher.h +++ b/test/MockDHTMessageDispatcher.h @@ -17,7 +17,7 @@ public: SharedHandle<DHTMessageCallback> _callback; Entry(const SharedHandle<DHTMessage>& message, time_t timeout, - const SharedHandle<DHTMessageCallback>& callback): + const SharedHandle<DHTMessageCallback>& callback): _message(message), _timeout(timeout), _callback(callback) {} @@ -32,17 +32,17 @@ public: virtual void addMessageToQueue(const SharedHandle<DHTMessage>& message, - time_t timeout, - const SharedHandle<DHTMessageCallback>& callback = - SharedHandle<DHTMessageCallback>()) + time_t timeout, + const SharedHandle<DHTMessageCallback>& callback = + SharedHandle<DHTMessageCallback>()) { _messageQueue.push_back(Entry(message, timeout, callback)); } virtual void addMessageToQueue(const SharedHandle<DHTMessage>& message, - const SharedHandle<DHTMessageCallback>& callback = - SharedHandle<DHTMessageCallback>()) + const SharedHandle<DHTMessageCallback>& callback = + SharedHandle<DHTMessageCallback>()) { _messageQueue.push_back(Entry(message, DHT_MESSAGE_TIMEOUT, callback)); } diff --git a/test/MockDHTMessageFactory.h b/test/MockDHTMessageFactory.h index f32a5a52..07bd5cdd 100644 --- a/test/MockDHTMessageFactory.h +++ b/test/MockDHTMessageFactory.h @@ -18,15 +18,15 @@ public: virtual SharedHandle<DHTMessage> createQueryMessage(const BDE& dict, - const std::string& ipaddr, uint16_t port) + const std::string& ipaddr, uint16_t port) { return SharedHandle<DHTMessage>(); } virtual SharedHandle<DHTMessage> createResponseMessage(const std::string& messageType, - const BDE& dict, - const std::string& ipaddr, uint16_t port) + const BDE& dict, + const std::string& ipaddr, uint16_t port) { SharedHandle<DHTNode> remoteNode(new DHTNode()); // TODO At this point, removeNode's ID is random. @@ -40,48 +40,48 @@ public: virtual SharedHandle<DHTMessage> createPingMessage(const SharedHandle<DHTNode>& remoteNode, - const std::string& transactionID = "") + const std::string& transactionID = "") { return SharedHandle<DHTMessage>(); } virtual SharedHandle<DHTMessage> createPingReplyMessage(const SharedHandle<DHTNode>& remoteNode, - const unsigned char* remoteNodeID, - const std::string& transactionID) + const unsigned char* remoteNodeID, + const std::string& transactionID) { return SharedHandle<DHTMessage>(); } virtual SharedHandle<DHTMessage> createFindNodeMessage(const SharedHandle<DHTNode>& remoteNode, - const unsigned char* targetNodeID, - const std::string& transactionID = "") + const unsigned char* targetNodeID, + const std::string& transactionID = "") { return SharedHandle<DHTMessage>(); } virtual SharedHandle<DHTMessage> createFindNodeReplyMessage(const SharedHandle<DHTNode>& remoteNode, - const std::deque<SharedHandle<DHTNode> >& closestKNodes, - const std::string& transactionID) + const std::deque<SharedHandle<DHTNode> >& closestKNodes, + const std::string& transactionID) { return SharedHandle<DHTMessage>(); } virtual SharedHandle<DHTMessage> createGetPeersMessage(const SharedHandle<DHTNode>& remoteNode, - const unsigned char* infoHash, - const std::string& transactionID) + const unsigned char* infoHash, + const std::string& transactionID) { return SharedHandle<DHTMessage>(); } virtual SharedHandle<DHTMessage> createGetPeersReplyMessage(const SharedHandle<DHTNode>& remoteNode, - const std::deque<SharedHandle<DHTNode> >& closestKNodes, - const std::string& token, - const std::string& transactionID) + const std::deque<SharedHandle<DHTNode> >& closestKNodes, + const std::string& token, + const std::string& transactionID) { return SharedHandle<DHTMessage>(); } @@ -89,33 +89,33 @@ public: virtual SharedHandle<DHTMessage> createGetPeersReplyMessage(const SharedHandle<DHTNode>& remoteNode, - const std::deque<SharedHandle<Peer> >& peers, - const std::string& token, - const std::string& transactionID) + const std::deque<SharedHandle<Peer> >& peers, + const std::string& token, + const std::string& transactionID) { return SharedHandle<DHTMessage>(); } virtual SharedHandle<DHTMessage> createAnnouncePeerMessage(const SharedHandle<DHTNode>& remoteNode, - const unsigned char* infoHash, - uint16_t tcpPort, - const std::string& token, - const std::string& transactionID = "") + const unsigned char* infoHash, + uint16_t tcpPort, + const std::string& token, + const std::string& transactionID = "") { return SharedHandle<DHTMessage>(); } virtual SharedHandle<DHTMessage> createAnnouncePeerReplyMessage(const SharedHandle<DHTNode>& remoteNode, - const std::string& transactionID) + const std::string& transactionID) { return SharedHandle<DHTMessage>(); } virtual SharedHandle<DHTMessage> createUnknownMessage(const unsigned char* data, size_t length, - const std::string& ipaddr, uint16_t port) + const std::string& ipaddr, uint16_t port) { return SharedHandle<DHTMessage>(); } diff --git a/test/MockDHTTaskFactory.h b/test/MockDHTTaskFactory.h index 31228d13..c3313d4f 100644 --- a/test/MockDHTTaskFactory.h +++ b/test/MockDHTTaskFactory.h @@ -11,14 +11,14 @@ public: virtual SharedHandle<DHTTask> createPingTask(const SharedHandle<DHTNode>& remoteNode, - size_t numRetry = 0) + size_t numRetry = 0) { return SharedHandle<DHTTask>(); } virtual SharedHandle<DHTTask> createGetIDTask(const SharedHandle<DHTNode>& remoteNode, - size_t numRetry = 0) + size_t numRetry = 0) { return SharedHandle<DHTTask>(); } @@ -36,8 +36,8 @@ public: virtual SharedHandle<DHTTask> createPeerLookupTask(const SharedHandle<DownloadContext>& ctx, - const SharedHandle<BtRuntime>& btRuntime, - const SharedHandle<PeerStorage>& peerStorage) + const SharedHandle<BtRuntime>& btRuntime, + const SharedHandle<PeerStorage>& peerStorage) { return SharedHandle<DHTTask>(); } @@ -50,7 +50,7 @@ public: virtual SharedHandle<DHTTask> createReplaceNodeTask(const SharedHandle<DHTBucket>& bucket, - const SharedHandle<DHTNode>& newNode) + const SharedHandle<DHTNode>& newNode) { return SharedHandle<DHTTask>(); } diff --git a/test/MockExtensionMessage.h b/test/MockExtensionMessage.h index 3628997e..6267519f 100644 --- a/test/MockExtensionMessage.h +++ b/test/MockExtensionMessage.h @@ -13,16 +13,16 @@ public: bool _doReceivedActionCalled; public: MockExtensionMessage(const std::string& extensionName, - uint8_t extensionMessageID, - const unsigned char* data, - size_t length):_extensionName(extensionName), - _extensionMessageID(extensionMessageID), - _data(&data[0], &data[length]), - _doReceivedActionCalled(false) {} + uint8_t extensionMessageID, + const unsigned char* data, + size_t length):_extensionName(extensionName), + _extensionMessageID(extensionMessageID), + _data(&data[0], &data[length]), + _doReceivedActionCalled(false) {} MockExtensionMessage(const std::string& extensionName, - uint8_t extensionMessageID, - const std::string& data): + uint8_t extensionMessageID, + const std::string& data): _extensionName(extensionName), _extensionMessageID(extensionMessageID), _data(data), diff --git a/test/MockExtensionMessageFactory.h b/test/MockExtensionMessageFactory.h index 979ef38e..a87b7e85 100644 --- a/test/MockExtensionMessageFactory.h +++ b/test/MockExtensionMessageFactory.h @@ -11,7 +11,7 @@ public: virtual ~MockExtensionMessageFactory() {} virtual SharedHandle<ExtensionMessage> createMessage(const unsigned char* data, - size_t length) + size_t length) { return SharedHandle<ExtensionMessage> (new MockExtensionMessage("a2_mock", *data, data+1, length-1)); diff --git a/test/MockPieceStorage.h b/test/MockPieceStorage.h index bbc6d49e..baa022e1 100644 --- a/test/MockPieceStorage.h +++ b/test/MockPieceStorage.h @@ -27,14 +27,14 @@ private: bool _allDownloadFinished; public: MockPieceStorage():totalLength(0), - filteredTotalLength(0), - completedLength(0), - filteredCompletedLength(0), - bitfieldMan(0), - selectiveDownloadingMode(false), - endGame(false), - _downloadFinished(false), - _allDownloadFinished(false) {} + filteredTotalLength(0), + completedLength(0), + filteredCompletedLength(0), + bitfieldMan(0), + selectiveDownloadingMode(false), + endGame(false), + _downloadFinished(false), + _allDownloadFinished(false) {} virtual ~MockPieceStorage() {} @@ -164,7 +164,7 @@ public: } virtual void setBitfield(const unsigned char* bitfield, - size_t bitfieldLength) { + size_t bitfieldLength) { bitfieldMan->setBitfield(bitfield, bitfieldLength); } @@ -213,8 +213,8 @@ public: virtual void advertisePiece(int32_t cuid, size_t index) {} virtual void getAdvertisedPieceIndexes(std::deque<size_t>& indexes, - int32_t myCuid, - const Time& lastCheckTime) + int32_t myCuid, + const Time& lastCheckTime) {} virtual void removeAdvertisedPiece(time_t elapsed) {} @@ -239,14 +239,14 @@ public: virtual void addPieceStats(size_t index) {} virtual void addPieceStats(const unsigned char* bitfield, - size_t bitfieldLength) {} + size_t bitfieldLength) {} virtual void subtractPieceStats(const unsigned char* bitfield, - size_t bitfieldLength) {} + size_t bitfieldLength) {} virtual void updatePieceStats(const unsigned char* newBitfield, - size_t newBitfieldLength, - const unsigned char* oldBitfield) {} + size_t newBitfieldLength, + const unsigned char* oldBitfield) {} }; } // namespace aria2 diff --git a/test/MultiDiskAdaptorTest.cc b/test/MultiDiskAdaptorTest.cc index e1b6f18c..cac67471 100644 --- a/test/MultiDiskAdaptorTest.cc +++ b/test/MultiDiskAdaptorTest.cc @@ -69,7 +69,7 @@ std::vector<SharedHandle<FileEntry> > createEntries() { // |file7 // ** file8 std::vector<SharedHandle<FileEntry> > entries(&array[0], - &array[arrayLength(array)]); + &array[arrayLength(array)]); for(std::vector<SharedHandle<FileEntry> >::const_iterator i = entries.begin(); i != entries.end(); ++i) { File((*i)->getPath()).remove(); @@ -388,9 +388,9 @@ void MultiDiskAdaptorTest::testCutTrailingGarbage() adaptor.cutTrailingGarbage(); CPPUNIT_ASSERT_EQUAL((uint64_t)256, - File(entries[0]->getPath()).size()); + File(entries[0]->getPath()).size()); CPPUNIT_ASSERT_EQUAL((uint64_t)512, - File(entries[1]->getPath()).size()); + File(entries[1]->getPath()).size()); } void MultiDiskAdaptorTest::testSize() @@ -445,13 +445,13 @@ void MultiDiskAdaptorTest::testUtime() CPPUNIT_ASSERT_EQUAL((size_t)2, adaptor.utime(Time(atime), Time(mtime))); CPPUNIT_ASSERT_EQUAL((time_t)mtime, - File(entries[0]->getPath()).getModifiedTime().getTime()); + File(entries[0]->getPath()).getModifiedTime().getTime()); CPPUNIT_ASSERT_EQUAL((time_t)mtime, - File(entries[3]->getPath()).getModifiedTime().getTime()); + File(entries[3]->getPath()).getModifiedTime().getTime()); CPPUNIT_ASSERT((time_t)mtime != - File(entries[2]->getPath()).getModifiedTime().getTime()); + File(entries[2]->getPath()).getModifiedTime().getTime()); } } // namespace aria2 diff --git a/test/MultiFileAllocationIteratorTest.cc b/test/MultiFileAllocationIteratorTest.cc index 22f26517..fa5ddfbe 100644 --- a/test/MultiFileAllocationIteratorTest.cc +++ b/test/MultiFileAllocationIteratorTest.cc @@ -79,57 +79,57 @@ void MultiFileAllocationIteratorTest::testMakeDiskWriterEntries() // file1 CPPUNIT_ASSERT_EQUAL(storeDir+std::string("/file1"), - entries[0]->getFilePath()); + entries[0]->getFilePath()); CPPUNIT_ASSERT(entries[0]->needsFileAllocation()); CPPUNIT_ASSERT(!entries[0]->getDiskWriter().isNull()); // file2 CPPUNIT_ASSERT_EQUAL(storeDir+std::string("/file2"), - entries[1]->getFilePath()); + entries[1]->getFilePath()); CPPUNIT_ASSERT(entries[1]->needsFileAllocation()); CPPUNIT_ASSERT(!entries[1]->getDiskWriter().isNull()); // file3 CPPUNIT_ASSERT_EQUAL(storeDir+std::string("/file3"), - entries[2]->getFilePath()); + entries[2]->getFilePath()); CPPUNIT_ASSERT(entries[2]->needsFileAllocation()); CPPUNIT_ASSERT(!entries[2]->getDiskWriter().isNull()); // file4, diskWriter is not null, because file exists. CPPUNIT_ASSERT_EQUAL(storeDir+std::string("/file4"), - entries[3]->getFilePath()); + entries[3]->getFilePath()); CPPUNIT_ASSERT(!entries[3]->needsFileAllocation()); CPPUNIT_ASSERT(!entries[3]->getDiskWriter().isNull()); // file5 CPPUNIT_ASSERT_EQUAL(storeDir+std::string("/file5"), - entries[4]->getFilePath()); + entries[4]->getFilePath()); CPPUNIT_ASSERT(!entries[4]->needsFileAllocation()); CPPUNIT_ASSERT(entries[4]->getDiskWriter().isNull()); // file6 CPPUNIT_ASSERT_EQUAL(storeDir+std::string("/file6"), - entries[5]->getFilePath()); + entries[5]->getFilePath()); CPPUNIT_ASSERT(entries[5]->needsFileAllocation()); CPPUNIT_ASSERT(!entries[5]->getDiskWriter().isNull()); // file7 CPPUNIT_ASSERT_EQUAL(storeDir+std::string("/file7"), - entries[6]->getFilePath()); + entries[6]->getFilePath()); CPPUNIT_ASSERT(entries[6]->needsFileAllocation()); CPPUNIT_ASSERT(!entries[6]->getDiskWriter().isNull()); // file8 CPPUNIT_ASSERT_EQUAL(storeDir+std::string("/file8"), - entries[7]->getFilePath()); + entries[7]->getFilePath()); CPPUNIT_ASSERT(entries[7]->needsFileAllocation()); CPPUNIT_ASSERT(!entries[7]->getDiskWriter().isNull()); // file9 CPPUNIT_ASSERT_EQUAL(storeDir+std::string("/file9"), - entries[8]->getFilePath()); + entries[8]->getFilePath()); CPPUNIT_ASSERT(!entries[8]->needsFileAllocation()); CPPUNIT_ASSERT(!entries[8]->getDiskWriter().isNull()); // fileA CPPUNIT_ASSERT_EQUAL(storeDir+std::string("/fileA"), - entries[9]->getFilePath()); + entries[9]->getFilePath()); CPPUNIT_ASSERT(!entries[9]->needsFileAllocation()); CPPUNIT_ASSERT(entries[9]->getDiskWriter().isNull()); // fileB CPPUNIT_ASSERT_EQUAL(storeDir+std::string("/fileB"), - entries[10]->getFilePath()); + entries[10]->getFilePath()); CPPUNIT_ASSERT(entries[10]->needsFileAllocation()); CPPUNIT_ASSERT(!entries[10]->getDiskWriter().isNull()); } @@ -158,33 +158,33 @@ void MultiFileAllocationIteratorTest::testAllocate() int64_t offset = 0; SharedHandle<FileEntry> fileEntry1(new FileEntry(storeDir+"/"+fname1, - length1, - offset)); + length1, + offset)); offset += length1; SharedHandle<FileEntry> fileEntry2(new FileEntry(storeDir+"/"+fname2, - length2, - offset)); + length2, + offset)); offset += length2; SharedHandle<FileEntry> fileEntry3(new FileEntry(storeDir+"/"+fname3, - length3, - offset)); + length3, + offset)); offset += length3; SharedHandle<FileEntry> fileEntry4(new FileEntry(storeDir+"/"+fname4, - length4, - offset)); + length4, + offset)); fileEntry4->setRequested(false); offset += length4; SharedHandle<FileEntry> fileEntry5(new FileEntry(storeDir+"/"+fname5, - length5, - offset)); + length5, + offset)); offset += length5; SharedHandle<FileEntry> fileEntry6(new FileEntry(storeDir+"/"+fname6, - length6, - offset)); + length6, + offset)); fileEntry6->setRequested(false); std::vector<SharedHandle<FileEntry> > fs; @@ -197,7 +197,7 @@ void MultiFileAllocationIteratorTest::testAllocate() diskAdaptor->setFileEntries(fs.begin(), fs.end()); for(std::vector<SharedHandle<FileEntry> >::const_iterator i = fs.begin(); - i != fs.end(); ++i) { + i != fs.end(); ++i) { File((*i)->getPath()).remove(); } diff --git a/test/NetrcAuthResolverTest.cc b/test/NetrcAuthResolverTest.cc index 5458c596..399fffdf 100644 --- a/test/NetrcAuthResolverTest.cc +++ b/test/NetrcAuthResolverTest.cc @@ -80,7 +80,7 @@ void NetrcAuthResolverTest::testResolveAuthConfig_ignoreDefault() SharedHandle<AuthConfig> defAuthConfig = _resolver->resolveAuthConfig("mirror"); CPPUNIT_ASSERT_EQUAL(std::string("default:defaultpasswd"), - defAuthConfig->getAuthText()); + defAuthConfig->getAuthText()); } } // namespace aria2 diff --git a/test/OptionHandlerTest.cc b/test/OptionHandlerTest.cc index e033600a..d30292cf 100644 --- a/test/OptionHandlerTest.cc +++ b/test/OptionHandlerTest.cc @@ -74,7 +74,7 @@ void OptionHandlerTest::testBooleanOptionHandler() CPPUNIT_FAIL("exception must be thrown."); } catch(Exception& e) {} CPPUNIT_ASSERT_EQUAL(std::string("true,false"), - handler.createPossibleValuesString()); + handler.createPossibleValuesString()); } void OptionHandlerTest::testNumberOptionHandler() @@ -86,7 +86,7 @@ void OptionHandlerTest::testNumberOptionHandler() handler.parse(option, "0"); CPPUNIT_ASSERT_EQUAL(std::string("0"), option.get("foo")); CPPUNIT_ASSERT_EQUAL(std::string("*-*"), - handler.createPossibleValuesString()); + handler.createPossibleValuesString()); } void OptionHandlerTest::testNumberOptionHandler_min() @@ -100,7 +100,7 @@ void OptionHandlerTest::testNumberOptionHandler_min() CPPUNIT_FAIL("exception must be thrown."); } catch(Exception& e) {} CPPUNIT_ASSERT_EQUAL(std::string("1-*"), - handler.createPossibleValuesString()); + handler.createPossibleValuesString()); } void OptionHandlerTest::testNumberOptionHandler_max() @@ -114,7 +114,7 @@ void OptionHandlerTest::testNumberOptionHandler_max() CPPUNIT_FAIL("exception must be thrown."); } catch(Exception& e) {} CPPUNIT_ASSERT_EQUAL(std::string("*-100"), - handler.createPossibleValuesString()); + handler.createPossibleValuesString()); } void OptionHandlerTest::testNumberOptionHandler_min_max() @@ -134,7 +134,7 @@ void OptionHandlerTest::testNumberOptionHandler_min_max() CPPUNIT_FAIL("exception must be thrown."); } catch(Exception& e) {} CPPUNIT_ASSERT_EQUAL(std::string("1-100"), - handler.createPossibleValuesString()); + handler.createPossibleValuesString()); } void OptionHandlerTest::testUnitNumberOptionHandler() @@ -175,7 +175,7 @@ void OptionHandlerTest::testParameterOptionHandler_1argInit() CPPUNIT_FAIL("exception must be thrown."); } catch(Exception& e) {} CPPUNIT_ASSERT_EQUAL(std::string("value1"), - handler.createPossibleValuesString()); + handler.createPossibleValuesString()); } void OptionHandlerTest::testParameterOptionHandler_2argsInit() @@ -193,7 +193,7 @@ void OptionHandlerTest::testParameterOptionHandler_2argsInit() CPPUNIT_FAIL("exception must be thrown."); } catch(Exception& e) {} CPPUNIT_ASSERT_EQUAL(std::string("value1,value2"), - handler.createPossibleValuesString()); + handler.createPossibleValuesString()); } void OptionHandlerTest::testParameterOptionHandler_listInit() @@ -215,7 +215,7 @@ void OptionHandlerTest::testParameterOptionHandler_listInit() CPPUNIT_FAIL("exception must be thrown."); } catch(Exception& e) {} CPPUNIT_ASSERT_EQUAL(std::string("value1,value2"), - handler.createPossibleValuesString()); + handler.createPossibleValuesString()); } void OptionHandlerTest::testDefaultOptionHandler() @@ -248,7 +248,7 @@ void OptionHandlerTest::testFloatNumberOptionHandler() handler.parse(option, "1.0"); CPPUNIT_ASSERT_EQUAL(std::string("1.0"), option.get("foo")); CPPUNIT_ASSERT_EQUAL(std::string("*-*"), - handler.createPossibleValuesString()); + handler.createPossibleValuesString()); } void OptionHandlerTest::testFloatNumberOptionHandler_min() @@ -262,7 +262,7 @@ void OptionHandlerTest::testFloatNumberOptionHandler_min() CPPUNIT_FAIL("exception must be thrown."); } catch(Exception& e) {} CPPUNIT_ASSERT_EQUAL(std::string("0.0-*"), - handler.createPossibleValuesString()); + handler.createPossibleValuesString()); } void OptionHandlerTest::testFloatNumberOptionHandler_max() @@ -276,7 +276,7 @@ void OptionHandlerTest::testFloatNumberOptionHandler_max() CPPUNIT_FAIL("exception must be thrown."); } catch(Exception& e) {} CPPUNIT_ASSERT_EQUAL(std::string("*-10.0"), - handler.createPossibleValuesString()); + handler.createPossibleValuesString()); } void OptionHandlerTest::testFloatNumberOptionHandler_min_max() @@ -296,7 +296,7 @@ void OptionHandlerTest::testFloatNumberOptionHandler_min_max() CPPUNIT_FAIL("exception must be thrown."); } catch(Exception& e) {} CPPUNIT_ASSERT_EQUAL(std::string("0.0-10.0"), - handler.createPossibleValuesString()); + handler.createPossibleValuesString()); } void OptionHandlerTest::testHttpProxyOptionHandler() @@ -307,18 +307,18 @@ void OptionHandlerTest::testHttpProxyOptionHandler() Option option; handler.parse(option, "proxy:65535"); CPPUNIT_ASSERT_EQUAL(std::string("http://proxy:65535"), - option.get(PREF_HTTP_PROXY)); + option.get(PREF_HTTP_PROXY)); handler.parse(option, "http://proxy:8080"); CPPUNIT_ASSERT_EQUAL(std::string("http://proxy:8080"), - option.get(PREF_HTTP_PROXY)); + option.get(PREF_HTTP_PROXY)); try { handler.parse(option, "http://bar:65536"); CPPUNIT_FAIL("exception must be thrown."); } catch(Exception& e) {} CPPUNIT_ASSERT_EQUAL(std::string("[http://][USER:PASSWORD@]HOST[:PORT]"), - handler.createPossibleValuesString()); + handler.createPossibleValuesString()); } } // namespace aria2 diff --git a/test/OptionParserTest.cc b/test/OptionParserTest.cc index 2370c2b3..3d5f51f5 100644 --- a/test/OptionParserTest.cc +++ b/test/OptionParserTest.cc @@ -34,7 +34,7 @@ public: SharedHandle<OptionHandler> alpha (new DefaultOptionHandler("alpha", NO_DESCRIPTION, "ALPHA", "", - OptionHandler::REQ_ARG, 'A')); + OptionHandler::REQ_ARG, 'A')); alpha->addTag("apple"); _oparser->addOptionHandler(alpha); @@ -46,7 +46,7 @@ public: SharedHandle<DefaultOptionHandler> charlie (new DefaultOptionHandler("charlie", NO_DESCRIPTION, "CHARLIE", "", - OptionHandler::REQ_ARG, 'C')); + OptionHandler::REQ_ARG, 'C')); charlie->hide(); charlie->addTag("pineapple"); _oparser->addOptionHandler(charlie); @@ -158,7 +158,7 @@ void OptionParserTest::testParseArg() strncpy(nonopt2, "nonopt2", sizeof(nonopt2)); char* const argv[] = { prog, optionAlpha, argAlpha, optionBravo, argBravo, - nonopt1, nonopt2 }; + nonopt1, nonopt2 }; int argc = arrayLength(argv); std::stringstream s; @@ -167,7 +167,7 @@ void OptionParserTest::testParseArg() _oparser->parseArg(s, nonopts, argc, argv); CPPUNIT_ASSERT_EQUAL(std::string("alpha=ALPHA\n" - "bravo=BRAVO\n"), s.str()); + "bravo=BRAVO\n"), s.str()); CPPUNIT_ASSERT_EQUAL((size_t)2, nonopts.size()); CPPUNIT_ASSERT_EQUAL(std::string("nonopt1"), nonopts[0]); diff --git a/test/PeerTest.cc b/test/PeerTest.cc index d83bd690..baf9ec94 100644 --- a/test/PeerTest.cc +++ b/test/PeerTest.cc @@ -44,7 +44,7 @@ void PeerTest::testAmAllowedIndexSet() { void PeerTest::testGetId() { CPPUNIT_ASSERT_EQUAL(std::string("f05897fc14a41cb3400e283e189158656d7184da"), - peer->getID()); + peer->getID()); } void PeerTest::testOperatorEqual() diff --git a/test/PieceTest.cc b/test/PieceTest.cc index 0efaa2bc..f30b9784 100644 --- a/test/PieceTest.cc +++ b/test/PieceTest.cc @@ -70,19 +70,19 @@ void PieceTest::testUpdateHash() std::string spam("SPAM!"); CPPUNIT_ASSERT(p.updateHash - (0, reinterpret_cast<const unsigned char*>(spam.c_str()), - spam.size())); + (0, reinterpret_cast<const unsigned char*>(spam.c_str()), + spam.size())); CPPUNIT_ASSERT(!p.isHashCalculated()); std::string spamspam("SPAM!SPAM!!"); CPPUNIT_ASSERT(p.updateHash - (spam.size(), - reinterpret_cast<const unsigned char*>(spamspam.c_str()), - spamspam.size())); + (spam.size(), + reinterpret_cast<const unsigned char*>(spamspam.c_str()), + spamspam.size())); CPPUNIT_ASSERT(p.isHashCalculated()); CPPUNIT_ASSERT_EQUAL(std::string("d9189aff79e075a2e60271b9556a710dc1bc7de7"), - p.getHashString()); + p.getHashString()); } #endif // ENABLE_MESSAGE_DIGEST diff --git a/test/RarestPieceSelectorTest.cc b/test/RarestPieceSelectorTest.cc index 87cd84ef..f172b70d 100644 --- a/test/RarestPieceSelectorTest.cc +++ b/test/RarestPieceSelectorTest.cc @@ -38,13 +38,13 @@ void RarestPieceSelectorTest::testSelect() pieceStatMan->addPieceStats(0); CPPUNIT_ASSERT(selector.select(index, bf.getBitfield(), - bf.countBlock())); + bf.countBlock())); CPPUNIT_ASSERT_EQUAL((size_t)1, index); pieceStatMan->addPieceStats(1); CPPUNIT_ASSERT(selector.select(index, bf.getBitfield(), - bf.countBlock())); + bf.countBlock())); CPPUNIT_ASSERT_EQUAL((size_t)2, index); } diff --git a/test/RequestGroupManTest.cc b/test/RequestGroupManTest.cc index dcadf209..b7ab1e57 100644 --- a/test/RequestGroupManTest.cc +++ b/test/RequestGroupManTest.cc @@ -59,7 +59,7 @@ void RequestGroupManTest::testIsSameFileBeingDownloaded() rg2->setDownloadContext(dctx2); RequestGroupMan gm(std::deque<SharedHandle<RequestGroup> >(), 1, - _option.get()); + _option.get()); gm.addRequestGroup(rg1); gm.addRequestGroup(rg2); @@ -106,7 +106,7 @@ void RequestGroupManTest::testLoadServerStat() std::cerr << "testLoadServerStat" << std::endl; CPPUNIT_ASSERT(rm.loadServerStat(f.getPath())); SharedHandle<ServerStat> ss_localhost = rm.findServerStat("localhost", - "http"); + "http"); CPPUNIT_ASSERT(!ss_localhost.isNull()); CPPUNIT_ASSERT_EQUAL(std::string("localhost"), ss_localhost->getHostname()); } diff --git a/test/RequestGroupTest.cc b/test/RequestGroupTest.cc index 5dd51a09..f23a5d08 100644 --- a/test/RequestGroupTest.cc +++ b/test/RequestGroupTest.cc @@ -57,9 +57,9 @@ void RequestGroupTest::testCreateDownloadResult() SharedHandle<DownloadResult> result = group.createDownloadResult(); CPPUNIT_ASSERT_EQUAL(std::string("/tmp/myfile"), - result->fileEntries[0]->getPath()); + result->fileEntries[0]->getPath()); CPPUNIT_ASSERT_EQUAL((off_t)1024*1024, - result->fileEntries.back()->getLastOffset()); + result->fileEntries.back()->getLastOffset()); CPPUNIT_ASSERT_EQUAL((uint64_t)0, result->sessionDownloadLength); CPPUNIT_ASSERT_EQUAL((int64_t)0, result->sessionTime); // result is UNKNOWN_ERROR if download has not completed and no specific diff --git a/test/RequestTest.cc b/test/RequestTest.cc index ceda474f..ccbfd521 100644 --- a/test/RequestTest.cc +++ b/test/RequestTest.cc @@ -289,11 +289,11 @@ void RequestTest::testSetUrl17() CPPUNIT_ASSERT_EQUAL(std::string("file%20with%20space;param%25"), req.getFile()); CPPUNIT_ASSERT_EQUAL(std::string("?a=/?"), req.getQuery()); CPPUNIT_ASSERT_EQUAL(std::string("http://host:80/file%3Cwith%252%20%20space" - "/file%20with%20space;param%25?a=/?"), - req.getCurrentUrl()); + "/file%20with%20space;param%25?a=/?"), + req.getCurrentUrl()); CPPUNIT_ASSERT_EQUAL(std::string("http://host:80/file<with%2 %20space" - "/file with space;param%?a=/?"), - req.getUrl()); + "/file with space;param%?a=/?"), + req.getUrl()); } void RequestTest::testSetUrl18() { @@ -334,11 +334,11 @@ void RequestTest::testRedirectUrl() { CPPUNIT_ASSERT(req.supportsPersistentConnection()); // url must be the same CPPUNIT_ASSERT_EQUAL(std::string("http://aria.rednoah.com:8080/aria2/" - "index.html"), - req.getUrl()); + "index.html"), + req.getUrl()); // currentUrl must be updated CPPUNIT_ASSERT_EQUAL(std::string("http://aria.rednoah.co.jp/"), - req.getCurrentUrl()); + req.getCurrentUrl()); // previousUrl must be "" when redirection CPPUNIT_ASSERT_EQUAL(std::string(""), req.getPreviousUrl()); CPPUNIT_ASSERT_EQUAL(std::string("http"), req.getProtocol()); @@ -353,14 +353,14 @@ void RequestTest::testRedirectUrl() { // Give abosulute path CPPUNIT_ASSERT(req.redirectUrl("/abspath/to/file")); CPPUNIT_ASSERT_EQUAL(std::string("http://aria.rednoah.co.jp/abspath/to/file"), - req.getCurrentUrl()); + req.getCurrentUrl()); CPPUNIT_ASSERT_EQUAL((unsigned int)2, req.getRedirectCount()); // Give relative path CPPUNIT_ASSERT(req.redirectUrl("relativepath/to/file")); CPPUNIT_ASSERT_EQUAL(std::string("http://aria.rednoah.co.jp/abspath/to/" - "relativepath/to/file"), - req.getCurrentUrl()); + "relativepath/to/file"), + req.getCurrentUrl()); CPPUNIT_ASSERT_EQUAL((unsigned int)3, req.getRedirectCount()); } @@ -412,10 +412,10 @@ void RequestTest::testInnerLink() { bool v = req.setUrl("http://aria.rednoah.com/index.html#download"); CPPUNIT_ASSERT(v); CPPUNIT_ASSERT_EQUAL(std::string("http://aria.rednoah.com/index.html" - "#download"), - req.getUrl()); + "#download"), + req.getUrl()); CPPUNIT_ASSERT_EQUAL(std::string("http://aria.rednoah.com/index.html"), - req.getCurrentUrl()); + req.getCurrentUrl()); CPPUNIT_ASSERT_EQUAL(std::string("index.html"), req.getFile()); CPPUNIT_ASSERT_EQUAL(std::string(""), req.getQuery()); } @@ -424,7 +424,7 @@ void RequestTest::testInnerLinkInReferer() { Request req; req.setReferer("http://aria.rednoah.com/home.html#top"); CPPUNIT_ASSERT_EQUAL(std::string("http://aria.rednoah.com/home.html"), - req.getReferer()); + req.getReferer()); } void RequestTest::testSetUrl_zeroUsername() diff --git a/test/ServerStatManTest.cc b/test/ServerStatManTest.cc index 8aa9f627..ce6fbc7e 100644 --- a/test/ServerStatManTest.cc +++ b/test/ServerStatManTest.cc @@ -106,7 +106,7 @@ void ServerStatManTest::testSave() " last_updated=1210000002," " counter=0," " status=ERROR\n"), - out); + out); } void ServerStatManTest::testLoad() @@ -126,15 +126,15 @@ void ServerStatManTest::testLoad() CPPUNIT_ASSERT_EQUAL(std::string("localhost"), localhost_http->getHostname()); CPPUNIT_ASSERT_EQUAL(std::string("http"), localhost_http->getProtocol()); CPPUNIT_ASSERT_EQUAL(static_cast<unsigned int>(25000), - localhost_http->getDownloadSpeed()); + localhost_http->getDownloadSpeed()); CPPUNIT_ASSERT_EQUAL(static_cast<unsigned int>(101), - localhost_http->getSingleConnectionAvgSpeed()); + localhost_http->getSingleConnectionAvgSpeed()); CPPUNIT_ASSERT_EQUAL(static_cast<unsigned int>(102), - localhost_http->getMultiConnectionAvgSpeed()); + localhost_http->getMultiConnectionAvgSpeed()); CPPUNIT_ASSERT_EQUAL(static_cast<unsigned int>(6), - localhost_http->getCounter()); + localhost_http->getCounter()); CPPUNIT_ASSERT_EQUAL(static_cast<time_t>(1210000000), - localhost_http->getLastUpdated().getTime()); + localhost_http->getLastUpdated().getTime()); CPPUNIT_ASSERT_EQUAL(ServerStat::OK, localhost_http->getStatus()); SharedHandle<ServerStat> mirror = ssm.find("mirror", "http"); diff --git a/test/Sqlite3MozCookieParserTest.cc b/test/Sqlite3MozCookieParserTest.cc index ff685c64..7a229cad 100644 --- a/test/Sqlite3MozCookieParserTest.cc +++ b/test/Sqlite3MozCookieParserTest.cc @@ -55,7 +55,7 @@ void Sqlite3MozCookieParserTest::testParse() const Cookie& overflowTime = cookies[2]; CPPUNIT_ASSERT_EQUAL(std::string(".overflow_time_t.local"), - overflowTime.getDomain()); + overflowTime.getDomain()); CPPUNIT_ASSERT_EQUAL(std::string("/path/to"), overflowTime.getPath()); CPPUNIT_ASSERT_EQUAL(std::string("foo"), overflowTime.getName()); CPPUNIT_ASSERT_EQUAL(std::string("bar"), overflowTime.getValue()); @@ -72,7 +72,7 @@ void Sqlite3MozCookieParserTest::testParse_fileNotFound() } catch(RecoverableException& e) { // SUCCESS CPPUNIT_ASSERT(util::startsWith(e.what(), - "Failed to open SQLite3 database:")); + "Failed to open SQLite3 database:")); } } diff --git a/test/TestUtil.cc b/test/TestUtil.cc index 4a428c0c..cb550c17 100644 --- a/test/TestUtil.cc +++ b/test/TestUtil.cc @@ -21,11 +21,11 @@ void createFile(const std::string& path, size_t length) int fd = creat(path.c_str(), OPEN_MODE); if(fd == -1) { throw FATAL_EXCEPTION(StringFormat("Could not create file=%s. cause:%s", - path.c_str(), strerror(errno)).str()); + path.c_str(), strerror(errno)).str()); } if(-1 == ftruncate(fd, length)) { throw FATAL_EXCEPTION(StringFormat("ftruncate failed. cause:%s", - strerror(errno)).str()); + strerror(errno)).str()); } close(fd); } diff --git a/test/TimeTest.cc b/test/TimeTest.cc index b6a0d5c4..bc8fd86f 100644 --- a/test/TimeTest.cc +++ b/test/TimeTest.cc @@ -56,16 +56,16 @@ void TimeTest::testParseRFC850Ext() void TimeTest::testParseHTTPDate() { CPPUNIT_ASSERT_EQUAL((time_t)1220714793, - Time::parseHTTPDate - ("Sat, 06 Sep 2008 15:26:33 GMT").getTime()); + Time::parseHTTPDate + ("Sat, 06 Sep 2008 15:26:33 GMT").getTime()); CPPUNIT_ASSERT_EQUAL((time_t)1220714793, - Time::parseHTTPDate - ("Sat, 06-Sep-2008 15:26:33 GMT").getTime()); + Time::parseHTTPDate + ("Sat, 06-Sep-2008 15:26:33 GMT").getTime()); CPPUNIT_ASSERT_EQUAL((time_t)1220714793, - Time::parseHTTPDate - ("Sat, 06-Sep-08 15:26:33 GMT").getTime()); + Time::parseHTTPDate + ("Sat, 06-Sep-08 15:26:33 GMT").getTime()); CPPUNIT_ASSERT(Time::parseHTTPDate - ("Sat, 2008-09-06 15:26:33 GMT").bad()); + ("Sat, 2008-09-06 15:26:33 GMT").bad()); } void TimeTest::testOperatorLess() diff --git a/test/UTMetadataDataExtensionMessageTest.cc b/test/UTMetadataDataExtensionMessageTest.cc index 7f1c45d0..4e8ac012 100644 --- a/test/UTMetadataDataExtensionMessageTest.cc +++ b/test/UTMetadataDataExtensionMessageTest.cc @@ -60,7 +60,7 @@ void UTMetadataDataExtensionMessageTest::testToString() UTMetadataDataExtensionMessage msg(1); msg.setIndex(100); CPPUNIT_ASSERT_EQUAL(std::string("ut_metadata data piece=100"), - msg.toString()); + msg.toString()); } void UTMetadataDataExtensionMessageTest::testDoReceivedAction() @@ -81,8 +81,8 @@ void UTMetadataDataExtensionMessageTest::testDoReceivedAction() unsigned char infoHash[INFO_HASH_LENGTH]; MessageDigestHelper::digest(infoHash, INFO_HASH_LENGTH, - MessageDigestContext::SHA1, - metadata.data(), metadata.size()); + MessageDigestContext::SHA1, + metadata.data(), metadata.size()); attrs[bittorrent::INFO_HASH] = std::string(&infoHash[0], &infoHash[20]); dctx->setAttribute(bittorrent::BITTORRENT, attrs); diff --git a/test/UTMetadataPostDownloadHandlerTest.cc b/test/UTMetadataPostDownloadHandlerTest.cc index 86280801..9c6974d8 100644 --- a/test/UTMetadataPostDownloadHandlerTest.cc +++ b/test/UTMetadataPostDownloadHandlerTest.cc @@ -99,17 +99,17 @@ void UTMetadataPostDownloadHandlerTest::testGetNextRequestGroups() SharedHandle<DownloadContext> newDctx = newRg->getDownloadContext(); const BDE& newAttrs = newDctx->getAttribute(bittorrent::BITTORRENT); CPPUNIT_ASSERT_EQUAL(util::toHex(attrs[bittorrent::INFO_HASH].s()), - util::toHex(newAttrs[bittorrent::INFO_HASH].s())); + util::toHex(newAttrs[bittorrent::INFO_HASH].s())); CPPUNIT_ASSERT(newAttrs.containsKey(bittorrent::ANNOUNCE_LIST)); CPPUNIT_ASSERT_EQUAL((size_t)1, newAttrs[bittorrent::ANNOUNCE_LIST].size()); CPPUNIT_ASSERT_EQUAL(std::string("http://tracker"), - newAttrs[bittorrent::ANNOUNCE_LIST][0][0].s()); + newAttrs[bittorrent::ANNOUNCE_LIST][0][0].s()); CPPUNIT_ASSERT_EQUAL(_option->get("Hello"), - newRg->getOption()->get("Hello")); + newRg->getOption()->get("Hello")); CPPUNIT_ASSERT (std::find(_requestGroup->followedBy().begin(), - _requestGroup->followedBy().end(), - newRg->getGID()) != _requestGroup->followedBy().end()); + _requestGroup->followedBy().end(), + newRg->getGID()) != _requestGroup->followedBy().end()); CPPUNIT_ASSERT(!trfile.exists()); results.clear(); diff --git a/test/UTMetadataRejectExtensionMessageTest.cc b/test/UTMetadataRejectExtensionMessageTest.cc index 578c097b..d77ae298 100644 --- a/test/UTMetadataRejectExtensionMessageTest.cc +++ b/test/UTMetadataRejectExtensionMessageTest.cc @@ -46,7 +46,7 @@ void UTMetadataRejectExtensionMessageTest::testToString() UTMetadataRejectExtensionMessage msg(1); msg.setIndex(100); CPPUNIT_ASSERT_EQUAL(std::string("ut_metadata reject piece=100"), - msg.toString()); + msg.toString()); } void UTMetadataRejectExtensionMessageTest::testDoReceivedAction() diff --git a/test/UTMetadataRequestExtensionMessageTest.cc b/test/UTMetadataRequestExtensionMessageTest.cc index 6e2f3c36..be476229 100644 --- a/test/UTMetadataRequestExtensionMessageTest.cc +++ b/test/UTMetadataRequestExtensionMessageTest.cc @@ -93,7 +93,7 @@ void UTMetadataRequestExtensionMessageTest::testToString() UTMetadataRequestExtensionMessage msg(1); msg.setIndex(100); CPPUNIT_ASSERT_EQUAL(std::string("ut_metadata request piece=100"), - msg.toString()); + msg.toString()); } void UTMetadataRequestExtensionMessageTest::testDoReceivedAction_reject() diff --git a/test/UTMetadataRequestFactoryTest.cc b/test/UTMetadataRequestFactoryTest.cc index 3245e20a..561db2a1 100644 --- a/test/UTMetadataRequestFactoryTest.cc +++ b/test/UTMetadataRequestFactoryTest.cc @@ -31,9 +31,9 @@ public: virtual SharedHandle<Piece> getMissingPiece(size_t index) { if(missingIndexes.find(index) != missingIndexes.end()) { - return SharedHandle<Piece>(new Piece(index, 0)); + return SharedHandle<Piece>(new Piece(index, 0)); } else { - return SharedHandle<Piece>(); + return SharedHandle<Piece>(); } } }; diff --git a/test/UTPexExtensionMessageTest.cc b/test/UTPexExtensionMessageTest.cc index 879123a3..1af6b3b6 100644 --- a/test/UTPexExtensionMessageTest.cc +++ b/test/UTPexExtensionMessageTest.cc @@ -95,7 +95,7 @@ void UTPexExtensionMessageTest::testGetBencodedData() "e"; std::string bd = msg.getPayload(); CPPUNIT_ASSERT_EQUAL(util::urlencode(expected), - util::urlencode(bd)); + util::urlencode(bd)); } void UTPexExtensionMessageTest::testToString() @@ -174,19 +174,19 @@ void UTPexExtensionMessageTest::testCreate() CPPUNIT_ASSERT_EQUAL((uint8_t)1, msg->getExtensionMessageID()); CPPUNIT_ASSERT_EQUAL((size_t)2, msg->getFreshPeers().size()); CPPUNIT_ASSERT_EQUAL(std::string("192.168.0.1"), - msg->getFreshPeers()[0]->ipaddr); + msg->getFreshPeers()[0]->ipaddr); CPPUNIT_ASSERT_EQUAL((uint16_t)6881, msg->getFreshPeers()[0]->port); CPPUNIT_ASSERT_EQUAL(std::string("10.1.1.2"), - msg->getFreshPeers()[1]->ipaddr); + msg->getFreshPeers()[1]->ipaddr); CPPUNIT_ASSERT_EQUAL((uint16_t)9999, msg->getFreshPeers()[1]->port); CPPUNIT_ASSERT_EQUAL((size_t)2, msg->getDroppedPeers().size()); CPPUNIT_ASSERT_EQUAL(std::string("192.168.0.2"), - msg->getDroppedPeers()[0]->ipaddr); + msg->getDroppedPeers()[0]->ipaddr); CPPUNIT_ASSERT_EQUAL((uint16_t)6882, msg->getDroppedPeers()[0]->port); CPPUNIT_ASSERT_EQUAL(std::string("10.1.1.3"), - msg->getDroppedPeers()[1]->ipaddr); + msg->getDroppedPeers()[1]->ipaddr); CPPUNIT_ASSERT_EQUAL((uint16_t)10000, - msg->getDroppedPeers()[1]->port); + msg->getDroppedPeers()[1]->port); try { // 0 length data std::string in = ""; diff --git a/test/UriListParserTest.cc b/test/UriListParserTest.cc index d996172b..643ce749 100644 --- a/test/UriListParserTest.cc +++ b/test/UriListParserTest.cc @@ -62,7 +62,7 @@ void UriListParserTest::testHasNext() flp.parseNext(uris, reqOp); CPPUNIT_ASSERT_EQUAL(std::string("ftp://localhost/aria2.tar.bz2"), - list2String(uris)); + list2String(uris)); CPPUNIT_ASSERT_EQUAL(std::string("/tmp"), reqOp.get(PREF_DIR)); CPPUNIT_ASSERT_EQUAL(std::string("chunky_chocolate"), reqOp.get(PREF_OUT)); diff --git a/test/UtilTest.cc b/test/UtilTest.cc index f189f0f1..d8170ce6 100644 --- a/test/UtilTest.cc +++ b/test/UtilTest.cc @@ -150,7 +150,7 @@ void UtilTest::testSplit() { void UtilTest::testSplit_many() { std::deque<std::string> v1; util::split("name1=value1; name2=value2; name3=value3",std::back_inserter(v1), - ";", true); + ";", true); CPPUNIT_ASSERT_EQUAL(3, (int)v1.size()); std::deque<std::string>::iterator itr = v1.begin(); CPPUNIT_ASSERT_EQUAL(std::string("name1=value1"), *itr++); @@ -160,7 +160,7 @@ void UtilTest::testSplit_many() { v1.clear(); util::split("name1=value1; name2=value2; name3=value3",std::back_inserter(v1), - ";", false); + ";", false); CPPUNIT_ASSERT_EQUAL(3, (int)v1.size()); itr = v1.begin(); CPPUNIT_ASSERT_EQUAL(std::string("name1=value1"), *itr++); @@ -280,15 +280,15 @@ void UtilTest::testGetContentDispositionFilename() { 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 { @@ -322,7 +322,7 @@ void UtilTest::testToLower() { 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)); @@ -397,16 +397,16 @@ void UtilTest::testToStream() entries.push_back(f2); util::toStream(entries.begin(), entries.end(), os); CPPUNIT_ASSERT_EQUAL( - std::string("Files:\n" - "idx|path/length\n" - "===+===========================================================================\n" - " 1|aria2.tar.bz2\n" - " |12.0KiB (12,300)\n" - "---+---------------------------------------------------------------------------\n" - " 2|aria2.txt\n" - " |556B (556)\n" - "---+---------------------------------------------------------------------------\n"), - os.str()); + std::string("Files:\n" + "idx|path/length\n" + "===+===========================================================================\n" + " 1|aria2.tar.bz2\n" + " |12.0KiB (12,300)\n" + "---+---------------------------------------------------------------------------\n" + " 2|aria2.txt\n" + " |556B (556)\n" + "---+---------------------------------------------------------------------------\n"), + os.str()); } void UtilTest::testIsNumber() @@ -480,8 +480,8 @@ void UtilTest::testConvertBitfield() util::convertBitfield(&destBitfield, &srcBitfield); CPPUNIT_ASSERT_EQUAL(std::string("9fffffffffffffffffffffffffffffff80"), - util::toHex(destBitfield.getBitfield(), - destBitfield.getBitfieldLength())); + util::toHex(destBitfield.getBitfield(), + destBitfield.getBitfieldLength())); } void UtilTest::testParseIntRange() @@ -593,7 +593,7 @@ void UtilTest::testParseLLInt() { 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"); CPPUNIT_FAIL("exception must be thrown."); @@ -623,7 +623,7 @@ void UtilTest::testParseLLInt() void UtilTest::testParseULLInt() { CPPUNIT_ASSERT_EQUAL((uint64_t)18446744073709551615ULL, - util::parseULLInt("18446744073709551615")); + util::parseULLInt("18446744073709551615")); try { util::parseUInt("-1"); CPPUNIT_FAIL("exception must be thrown."); @@ -726,7 +726,7 @@ void UtilTest::testUrlencode() void UtilTest::testHtmlEscape() { CPPUNIT_ASSERT_EQUAL(std::string("aria2<>"'util"), - util::htmlEscape("aria2<>\"'util")); + util::htmlEscape("aria2<>\"'util")); } void UtilTest::testJoinPath() @@ -735,32 +735,32 @@ void UtilTest::testJoinPath() CPPUNIT_ASSERT_EQUAL (std::string("dir1/dir2/file"), util::joinPath(&dir1dir2file[0], - &dir1dir2file[arrayLength(dir1dir2file)])); + &dir1dir2file[arrayLength(dir1dir2file)])); const std::string dirparentfile[] = { "dir", "..", "file" }; CPPUNIT_ASSERT_EQUAL (std::string("file"), util::joinPath(&dirparentfile[0], - &dirparentfile[arrayLength(dirparentfile)])); + &dirparentfile[arrayLength(dirparentfile)])); const std::string dirparentparentfile[] = { "dir", "..", "..", "file" }; CPPUNIT_ASSERT_EQUAL (std::string("file"), util::joinPath(&dirparentparentfile[0], - &dirparentparentfile[arrayLength(dirparentparentfile)])); + &dirparentparentfile[arrayLength(dirparentparentfile)])); const std::string dirdotfile[] = { "dir", ".", "file" }; CPPUNIT_ASSERT_EQUAL(std::string("dir/file"), - util::joinPath(&dirdotfile[0], - &dirdotfile[arrayLength(dirdotfile)])); + util::joinPath(&dirdotfile[0], + &dirdotfile[arrayLength(dirdotfile)])); const std::string empty[] = {}; CPPUNIT_ASSERT_EQUAL(std::string(""), util::joinPath(&empty[0], &empty[0])); const std::string parentdot[] = { "..", "." }; CPPUNIT_ASSERT_EQUAL(std::string(""), - util::joinPath(&parentdot[0], - &parentdot[arrayLength(parentdot)])); + util::joinPath(&parentdot[0], + &parentdot[arrayLength(parentdot)])); } void UtilTest::testParseIndexPath() @@ -890,7 +890,7 @@ void UtilTest::testParsePrioritizePieceRange() CPPUNIT_ASSERT_EQUAL((size_t)6, result[3]); result.clear(); util::parsePrioritizePieceRange(result, "head=300M,tail=300M", - entries, pieceLength); + entries, pieceLength); CPPUNIT_ASSERT_EQUAL((size_t)7, result.size()); for(size_t i = 0; i < 7; ++i) { CPPUNIT_ASSERT_EQUAL(i, result[i]); diff --git a/test/XmlRpcMethodTest.cc b/test/XmlRpcMethodTest.cc index 6497c3c3..3d3b2e31 100644 --- a/test/XmlRpcMethodTest.cc +++ b/test/XmlRpcMethodTest.cc @@ -86,7 +86,7 @@ public: _e->option = _option.get(); _e->_requestGroupMan.reset (new RequestGroupMan(std::deque<SharedHandle<RequestGroup> >(), - 1, _option.get())); + 1, _option.get())); } void tearDown() {} @@ -145,7 +145,7 @@ void XmlRpcMethodTest::testAddUri() _e->_requestGroupMan->getReservedGroups(); CPPUNIT_ASSERT_EQUAL((size_t)1, rgs.size()); CPPUNIT_ASSERT_EQUAL(std::string("http://localhost/"), - rgs.front()->getDownloadContext()->getFirstFileEntry()->getRemainingUris().front()); + rgs.front()->getDownloadContext()->getFirstFileEntry()->getRemainingUris().front()); } // with options BDE opt = BDE::dict(); @@ -155,8 +155,8 @@ void XmlRpcMethodTest::testAddUri() XmlRpcResponse res = m.execute(req, _e.get()); CPPUNIT_ASSERT_EQUAL(0, res._code); CPPUNIT_ASSERT_EQUAL(std::string("/sink"), - _e->_requestGroupMan->findReservedGroup(2)-> - getDownloadContext()->getDir()); + _e->_requestGroupMan->findReservedGroup(2)-> + getDownloadContext()->getDir()); } } @@ -242,10 +242,10 @@ void XmlRpcMethodTest::testAddTorrent() SharedHandle<RequestGroup> group = _e->_requestGroupMan->findReservedGroup(1); CPPUNIT_ASSERT(!group.isNull()); CPPUNIT_ASSERT_EQUAL(std::string("/tmp/aria2-0.8.2.tar.bz2"), - group->getFirstFilePath()); + group->getFirstFilePath()); CPPUNIT_ASSERT_EQUAL((size_t)1, group->getDownloadContext()->getFirstFileEntry()->getRemainingUris().size()); CPPUNIT_ASSERT_EQUAL(std::string("http://localhost/aria2-0.8.2.tar.bz2"), - group->getDownloadContext()->getFirstFileEntry()->getRemainingUris()[0]); + group->getDownloadContext()->getFirstFileEntry()->getRemainingUris()[0]); } // with options BDE opt = BDE::dict(); @@ -255,7 +255,7 @@ void XmlRpcMethodTest::testAddTorrent() XmlRpcResponse res = m.execute(req, _e.get()); CPPUNIT_ASSERT_EQUAL(0, res._code); CPPUNIT_ASSERT_EQUAL(std::string("/sink/aria2-0.8.2.tar.bz2"), - _e->_requestGroupMan->findReservedGroup(2)->getFirstFilePath()); + _e->_requestGroupMan->findReservedGroup(2)->getFirstFilePath()); } } @@ -294,8 +294,8 @@ void XmlRpcMethodTest::testAddTorrent_withPosition() m.execute(req2, _e.get()); CPPUNIT_ASSERT_EQUAL((size_t)1, - _e->_requestGroupMan->getReservedGroups()[0]-> - getDownloadContext()->getFileEntries().size()); + _e->_requestGroupMan->getReservedGroups()[0]-> + getDownloadContext()->getFileEntries().size()); } #endif // ENABLE_BITTORRENT @@ -316,11 +316,11 @@ void XmlRpcMethodTest::testAddMetalink() SharedHandle<RequestGroup> tar = _e->_requestGroupMan->findReservedGroup(1); CPPUNIT_ASSERT(!tar.isNull()); CPPUNIT_ASSERT_EQUAL(std::string("/tmp/aria2-5.0.0.tar.bz2"), - tar->getFirstFilePath()); + tar->getFirstFilePath()); SharedHandle<RequestGroup> deb = _e->_requestGroupMan->findReservedGroup(2); CPPUNIT_ASSERT(!deb.isNull()); CPPUNIT_ASSERT_EQUAL(std::string("/tmp/aria2-5.0.0.deb"), - deb->getFirstFilePath()); + deb->getFirstFilePath()); } // with options BDE opt = BDE::dict(); @@ -330,7 +330,7 @@ void XmlRpcMethodTest::testAddMetalink() XmlRpcResponse res = m.execute(req, _e.get()); CPPUNIT_ASSERT_EQUAL(0, res._code); CPPUNIT_ASSERT_EQUAL(std::string("/sink/aria2-5.0.0.tar.bz2"), - _e->_requestGroupMan->findReservedGroup(3)->getFirstFilePath()); + _e->_requestGroupMan->findReservedGroup(3)->getFirstFilePath()); } } @@ -369,8 +369,8 @@ void XmlRpcMethodTest::testAddMetalink_withPosition() CPPUNIT_ASSERT_EQUAL(0, res2._code); CPPUNIT_ASSERT_EQUAL(std::string("/tmp/aria2-5.0.0.tar.bz2"), - _e->_requestGroupMan->getReservedGroups()[0]-> - getFirstFilePath()); + _e->_requestGroupMan->getReservedGroups()[0]-> + getFirstFilePath()); } #endif // ENABLE_METALINK @@ -401,20 +401,20 @@ void XmlRpcMethodTest::testChangeOption() CPPUNIT_ASSERT_EQUAL(0, res._code); CPPUNIT_ASSERT_EQUAL((unsigned int)100*1024, - group->getMaxDownloadSpeedLimit()); + group->getMaxDownloadSpeedLimit()); CPPUNIT_ASSERT_EQUAL(std::string("102400"), - option->get(PREF_MAX_DOWNLOAD_LIMIT)); + option->get(PREF_MAX_DOWNLOAD_LIMIT)); #ifdef ENABLE_BITTORRENT CPPUNIT_ASSERT_EQUAL(std::string("307200"), - option->get(PREF_BT_REQUEST_PEER_SPEED_LIMIT)); + option->get(PREF_BT_REQUEST_PEER_SPEED_LIMIT)); CPPUNIT_ASSERT_EQUAL(std::string("100"), option->get(PREF_BT_MAX_PEERS)); CPPUNIT_ASSERT_EQUAL((unsigned int)100, btObject._btRuntime->getMaxPeers()); CPPUNIT_ASSERT_EQUAL((unsigned int)50*1024, - group->getMaxUploadSpeedLimit()); + group->getMaxUploadSpeedLimit()); CPPUNIT_ASSERT_EQUAL(std::string("51200"), - option->get(PREF_MAX_UPLOAD_LIMIT)); + option->get(PREF_MAX_UPLOAD_LIMIT)); #endif // ENABLE_BITTORRENT } @@ -470,14 +470,14 @@ void XmlRpcMethodTest::testChangeGlobalOption() CPPUNIT_ASSERT_EQUAL(0, res._code); CPPUNIT_ASSERT_EQUAL((unsigned int)100*1024, - _e->_requestGroupMan->getMaxOverallDownloadSpeedLimit()); + _e->_requestGroupMan->getMaxOverallDownloadSpeedLimit()); CPPUNIT_ASSERT_EQUAL(std::string("102400"), - _e->option->get(PREF_MAX_OVERALL_DOWNLOAD_LIMIT)); + _e->option->get(PREF_MAX_OVERALL_DOWNLOAD_LIMIT)); #ifdef ENABLE_BITTORRENT CPPUNIT_ASSERT_EQUAL((unsigned int)50*1024, - _e->_requestGroupMan->getMaxOverallUploadSpeedLimit()); + _e->_requestGroupMan->getMaxOverallUploadSpeedLimit()); CPPUNIT_ASSERT_EQUAL(std::string("51200"), - _e->option->get(PREF_MAX_OVERALL_UPLOAD_LIMIT)); + _e->option->get(PREF_MAX_OVERALL_UPLOAD_LIMIT)); #endif // ENABLE_BITTORRENT } @@ -510,26 +510,26 @@ void XmlRpcMethodTest::testNoSuchMethod() XmlRpcResponse res = m.execute(req, 0); CPPUNIT_ASSERT_EQUAL(1, res._code); CPPUNIT_ASSERT_EQUAL(std::string("No such method: make.hamburger"), - res._param["faultString"].s()); + res._param["faultString"].s()); CPPUNIT_ASSERT_EQUAL (std::string("<?xml version=\"1.0\"?>" - "<methodResponse>" - "<fault>" - "<value>" - "<struct>" - "<member>" - "<name>faultCode</name><value><int>1</int></value>" - "</member>" - "<member>" - "<name>faultString</name>" - "<value>" - "<string>No such method: make.hamburger</string>" - "</value>" - "</member>" - "</struct>" - "</value>" - "</fault>" - "</methodResponse>"), + "<methodResponse>" + "<fault>" + "<value>" + "<struct>" + "<member>" + "<name>faultCode</name><value><int>1</int></value>" + "</member>" + "<member>" + "<name>faultString</name>" + "<value>" + "<string>No such method: make.hamburger</string>" + "</value>" + "</member>" + "</struct>" + "</value>" + "</fault>" + "</methodResponse>"), res.toXml()); } @@ -542,7 +542,7 @@ void XmlRpcMethodTest::testTellStatus_withoutGid() } static void addUri(const std::string& uri, - const SharedHandle<DownloadEngine>& e) + const SharedHandle<DownloadEngine>& e) { AddUriXmlRpcMethod m; XmlRpcRequest req(AddUriXmlRpcMethod::getMethodName(), BDE::list()); @@ -634,7 +634,7 @@ void XmlRpcMethodTest::testGetVersion() } CPPUNIT_ASSERT_EQUAL(FeatureConfig::getInstance()->featureSummary()+", ", - features); + features); } void XmlRpcMethodTest::testGatherStoppedDownload() @@ -645,13 +645,13 @@ void XmlRpcMethodTest::testGatherStoppedDownload() followedBy.push_back(4); SharedHandle<DownloadResult> d (new DownloadResult(1, - fileEntries, - false, - UINT64_MAX, - 1000, - downloadresultcode::FINISHED, - followedBy, - 2)); + fileEntries, + false, + UINT64_MAX, + 1000, + downloadresultcode::FINISHED, + followedBy, + 2)); BDE entry = BDE::dict(); gatherStoppedDownload(entry, d); @@ -678,9 +678,9 @@ void XmlRpcMethodTest::testGatherProgressCommon() gatherProgressCommon(entry, group); CPPUNIT_ASSERT_EQUAL(util::itos(followedBy[0]->getGID()), - entry["followedBy"][0].s()); + entry["followedBy"][0].s()); CPPUNIT_ASSERT_EQUAL(util::itos(followedBy[1]->getGID()), - entry["followedBy"][1].s()); + entry["followedBy"][1].s()); CPPUNIT_ASSERT_EQUAL(std::string("2"), entry["belongsTo"].s()); } diff --git a/test/XmlRpcRequestParserControllerTest.cc b/test/XmlRpcRequestParserControllerTest.cc index a317007b..6595bd25 100644 --- a/test/XmlRpcRequestParserControllerTest.cc +++ b/test/XmlRpcRequestParserControllerTest.cc @@ -43,7 +43,7 @@ void XmlRpcRequestParserControllerTest::testPopStructFrame() const BDE& structValue = controller.getCurrentFrameValue(); CPPUNIT_ASSERT_EQUAL((size_t)1, structValue.size()); CPPUNIT_ASSERT_EQUAL(std::string("Hello, aria2"), - structValue["greeting"].s()); + structValue["greeting"].s()); } void XmlRpcRequestParserControllerTest::testPopStructFrame_noName() @@ -147,7 +147,7 @@ void XmlRpcRequestParserControllerTest::testPopArrayFrame_compound() const BDE& result = controller.getCurrentFrameValue(); CPPUNIT_ASSERT_EQUAL(std::string("http://aria2.sf.net/"), - result[0]["uris"][1].s()); + result[0]["uris"][1].s()); CPPUNIT_ASSERT_EQUAL((BDE::Integer)120, result[0]["options"]["timeout"].i()); CPPUNIT_ASSERT_EQUAL(std::string("jp"), result[1][0].s()); } diff --git a/test/XmlRpcRequestProcessorTest.cc b/test/XmlRpcRequestProcessorTest.cc index 792eacad..0ed827f0 100644 --- a/test/XmlRpcRequestProcessorTest.cc +++ b/test/XmlRpcRequestProcessorTest.cc @@ -31,38 +31,38 @@ void XmlRpcRequestProcessorTest::testParseMemory() XmlRpcRequestProcessor proc; XmlRpcRequest req = proc.parseMemory("<?xml version=\"1.0\"?>" - "<methodCall>" - " <methodName>aria2.addURI</methodName>" - " <params>" - " <param>" - " <value><i4>100</i4></value>" - " </param>" - " <param>" - " <value>" - " <struct>" - " <member>" - " <name>max-count</name>" - " <value><i4>65535</i4></value>" - " </member>" - " <member>" - " <name>seed-ratio</name>" - " <value><double>0.99</double></value>" - " </member>" - " </struct>" - " </value>" - " </param>" - " <param>" - " <value>" - " <array>" - " <data>" - " <value><string>pudding</string></value>" - " <value><base64>aGVsbG8gd29ybGQ=</base64></value>" - " </data>" - " </array>" - " </value>" - " </param>" - " </params>" - "</methodCall>"); + "<methodCall>" + " <methodName>aria2.addURI</methodName>" + " <params>" + " <param>" + " <value><i4>100</i4></value>" + " </param>" + " <param>" + " <value>" + " <struct>" + " <member>" + " <name>max-count</name>" + " <value><i4>65535</i4></value>" + " </member>" + " <member>" + " <name>seed-ratio</name>" + " <value><double>0.99</double></value>" + " </member>" + " </struct>" + " </value>" + " </param>" + " <param>" + " <value>" + " <array>" + " <data>" + " <value><string>pudding</string></value>" + " <value><base64>aGVsbG8gd29ybGQ=</base64></value>" + " </data>" + " </array>" + " </value>" + " </param>" + " </params>" + "</methodCall>"); CPPUNIT_ASSERT_EQUAL(std::string("aria2.addURI"), req._methodName); CPPUNIT_ASSERT_EQUAL((size_t)3, req._params.size()); @@ -79,11 +79,11 @@ void XmlRpcRequestProcessorTest::testParseMemory_shouldFail() XmlRpcRequestProcessor proc; try { proc.parseMemory("<methodCall>" - " <methodName>aria2.addURI</methodName>" - " <params>" - " <param>" - " <value><i4>100</i4></value>" - " </param>"); + " <methodName>aria2.addURI</methodName>" + " <params>" + " <param>" + " <value><i4>100</i4></value>" + " </param>"); CPPUNIT_FAIL("exception must be thrown."); } catch(RecoverableException& e) { // success diff --git a/test/a2functionalTest.cc b/test/a2functionalTest.cc index 0129d4af..fd811d0b 100644 --- a/test/a2functionalTest.cc +++ b/test/a2functionalTest.cc @@ -68,7 +68,7 @@ void a2functionalTest::testAdopt2nd() GreetingHandle greeting(new JapaneseGreeting()); CPPUNIT_ASSERT_EQUAL(std::string("A Japanese said:HAROO WAARUDO"), - adopt2nd(std::plus<std::string>(), mem_fun_sh(&Greeting::sayGreeting))("A Japanese said:", greeting)); + adopt2nd(std::plus<std::string>(), mem_fun_sh(&Greeting::sayGreeting))("A Japanese said:", greeting)); } void a2functionalTest::testStrjoin() @@ -85,7 +85,7 @@ void a2functionalTest::testStrjoin() v.push_back("lonely"); CPPUNIT_ASSERT_EQUAL(std::string("A hero is lonely"), - strjoin(v.begin(), v.end(), " ")); + strjoin(v.begin(), v.end(), " ")); } void a2functionalTest::testStrconcat() diff --git a/test/bitfieldTest.cc b/test/bitfieldTest.cc index 4dc7901c..7eb55a30 100644 --- a/test/bitfieldTest.cc +++ b/test/bitfieldTest.cc @@ -41,7 +41,7 @@ void bitfieldTest::testCountBit32() void bitfieldTest::testCountSetBit() { unsigned char bitfield[] = { 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xf9 }; + 0xff, 0xff, 0xff, 0xf9 }; // (nbits+7)/8 == 0 && nbits%32 == 0 CPPUNIT_ASSERT_EQUAL((size_t)62, bitfield::countSetBit(bitfield, 64)); // (nbits+7)/8 != 0 && nbits%32 != 0 && len%4 == 0 @@ -57,11 +57,11 @@ void bitfieldTest::testCountSetBit() void bitfieldTest::testLastByteMask() { CPPUNIT_ASSERT_EQUAL((unsigned int)128, - (unsigned int)bitfield::lastByteMask(9)); + (unsigned int)bitfield::lastByteMask(9)); CPPUNIT_ASSERT_EQUAL((unsigned int)240, - (unsigned int)bitfield::lastByteMask(12)); + (unsigned int)bitfield::lastByteMask(12)); CPPUNIT_ASSERT_EQUAL((unsigned int)255, - (unsigned int)bitfield::lastByteMask(16)); + (unsigned int)bitfield::lastByteMask(16)); } } // namespace aria2 |
