mirror of https://github.com/aria2/aria2
2008-03-15 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
Fixed compilation error with g++-4.3pull/1/head
parent
8dacfe45b8
commit
538a8fcfe7
|
@ -1,3 +1,7 @@
|
||||||
|
2008-03-15 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
|
||||||
|
|
||||||
|
Fixed compilation error with g++-4.3
|
||||||
|
|
||||||
2008-03-13 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
|
2008-03-13 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
|
||||||
|
|
||||||
Added missing include files for MinGW
|
Added missing include files for MinGW
|
||||||
|
|
|
@ -110,12 +110,12 @@ bool AbstractCommand::execute() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(checkSocketIsReadable && readCheckTarget->isReadable(0) ||
|
if((checkSocketIsReadable && readCheckTarget->isReadable(0)) ||
|
||||||
checkSocketIsWritable && writeCheckTarget->isWritable(0) ||
|
(checkSocketIsWritable && writeCheckTarget->isWritable(0)) ||
|
||||||
#ifdef ENABLE_ASYNC_DNS
|
#ifdef ENABLE_ASYNC_DNS
|
||||||
nameResolverCheck && nameResolveFinished() ||
|
(nameResolverCheck && nameResolveFinished()) ||
|
||||||
#endif // ENABLE_ASYNC_DNS
|
#endif // ENABLE_ASYNC_DNS
|
||||||
!checkSocketIsReadable && !checkSocketIsWritable && !nameResolverCheck) {
|
(!checkSocketIsReadable && !checkSocketIsWritable && !nameResolverCheck)) {
|
||||||
checkPoint.reset();
|
checkPoint.reset();
|
||||||
if(!_requestGroup->getPieceStorage().isNull()) {
|
if(!_requestGroup->getPieceStorage().isNull()) {
|
||||||
_segments = _requestGroup->getSegmentMan()->getInFlightSegment(cuid);
|
_segments = _requestGroup->getSegmentMan()->getInFlightSegment(cuid);
|
||||||
|
|
|
@ -41,6 +41,7 @@
|
||||||
#include "DlAbortEx.h"
|
#include "DlAbortEx.h"
|
||||||
#include "a2io.h"
|
#include "a2io.h"
|
||||||
#include <cerrno>
|
#include <cerrno>
|
||||||
|
#include <cstring>
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
|
|
||||||
namespace aria2 {
|
namespace aria2 {
|
||||||
|
|
|
@ -37,6 +37,7 @@
|
||||||
|
|
||||||
#include "NumberDecorator.h"
|
#include "NumberDecorator.h"
|
||||||
#include "DlAbortEx.h"
|
#include "DlAbortEx.h"
|
||||||
|
#include <algorithm>
|
||||||
|
|
||||||
namespace aria2 {
|
namespace aria2 {
|
||||||
|
|
||||||
|
|
|
@ -37,6 +37,7 @@
|
||||||
|
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
#include "SharedHandle.h"
|
#include "SharedHandle.h"
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
namespace aria2 {
|
namespace aria2 {
|
||||||
|
|
||||||
|
|
|
@ -37,6 +37,7 @@
|
||||||
|
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
#include <map>
|
#include <map>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
typedef std::map<std::string, uint8_t> Extensions;
|
typedef std::map<std::string, uint8_t> Extensions;
|
||||||
|
|
||||||
|
|
|
@ -33,6 +33,7 @@
|
||||||
*/
|
*/
|
||||||
/* copyright --> */
|
/* copyright --> */
|
||||||
#include "BtKeepAliveMessage.h"
|
#include "BtKeepAliveMessage.h"
|
||||||
|
#include <cstring>
|
||||||
|
|
||||||
namespace aria2 {
|
namespace aria2 {
|
||||||
|
|
||||||
|
|
|
@ -65,7 +65,7 @@ BtRequestMessageHandle BtRequestMessage::create(const unsigned char* data, size_
|
||||||
void BtRequestMessage::doReceivedAction() {
|
void BtRequestMessage::doReceivedAction() {
|
||||||
if(pieceStorage->hasPiece(index) &&
|
if(pieceStorage->hasPiece(index) &&
|
||||||
(!peer->amChoking() ||
|
(!peer->amChoking() ||
|
||||||
peer->amChoking() && peer->isInAmAllowedIndexSet(index))) {
|
(peer->amChoking() && peer->isInAmAllowedIndexSet(index)))) {
|
||||||
BtMessageHandle msg = messageFactory->createPieceMessage(index,
|
BtMessageHandle msg = messageFactory->createPieceMessage(index,
|
||||||
begin,
|
begin,
|
||||||
length);
|
length);
|
||||||
|
|
|
@ -36,6 +36,7 @@
|
||||||
#define _D_COMMAND_H_
|
#define _D_COMMAND_H_
|
||||||
|
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
|
#include <stdint.h>
|
||||||
#include <deque>
|
#include <deque>
|
||||||
|
|
||||||
namespace aria2 {
|
namespace aria2 {
|
||||||
|
|
|
@ -86,10 +86,10 @@ bool Cookie::good() const
|
||||||
|
|
||||||
bool Cookie::match(const std::string& host, const std::string& dir, time_t date, bool secure) const
|
bool Cookie::match(const std::string& host, const std::string& dir, time_t date, bool secure) const
|
||||||
{
|
{
|
||||||
if((secure || !this->secure && !secure) &&
|
if((secure || (!this->secure && !secure)) &&
|
||||||
Util::endsWith("."+host, this->domain) &&
|
Util::endsWith("."+host, this->domain) &&
|
||||||
Util::startsWith(dir, this->path) &&
|
Util::startsWith(dir, this->path) &&
|
||||||
(this->onetime || date < this->expires)) {
|
(this->onetime || (date < this->expires))) {
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -34,6 +34,7 @@
|
||||||
/* copyright --> */
|
/* copyright --> */
|
||||||
#include "CookieParser.h"
|
#include "CookieParser.h"
|
||||||
#include "Util.h"
|
#include "Util.h"
|
||||||
|
#include <strings.h>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
#include <istream>
|
#include <istream>
|
||||||
|
|
||||||
|
|
|
@ -48,6 +48,7 @@
|
||||||
#include "Logger.h"
|
#include "Logger.h"
|
||||||
#include <cerrno>
|
#include <cerrno>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
|
#include <cstring>
|
||||||
|
|
||||||
namespace aria2 {
|
namespace aria2 {
|
||||||
|
|
||||||
|
|
|
@ -72,7 +72,7 @@ bool DHTGetPeersCommand::execute()
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if(_task.isNull() &&
|
if(_task.isNull() &&
|
||||||
(_numRetry > 0 && _lastGetPeerTime.elapsed(RETRY_INTERVAL) ||
|
((_numRetry > 0 && _lastGetPeerTime.elapsed(RETRY_INTERVAL)) ||
|
||||||
_lastGetPeerTime.elapsed(GET_PEER_INTERVAL))) {
|
_lastGetPeerTime.elapsed(GET_PEER_INTERVAL))) {
|
||||||
logger->debug("Issuing PeerLookup for infoHash=%s",
|
logger->debug("Issuing PeerLookup for infoHash=%s",
|
||||||
btContext->getInfoHashAsString().c_str());
|
btContext->getInfoHashAsString().c_str());
|
||||||
|
|
|
@ -116,4 +116,9 @@ std::string DHTNode::toString() const
|
||||||
", RTT="+Util::uitos(_rtt);
|
", RTT="+Util::uitos(_rtt);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DHTNode::setID(const unsigned char* id)
|
||||||
|
{
|
||||||
|
memcpy(_id, id, DHT_ID_LENGTH);
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace aria2
|
} // namespace aria2
|
||||||
|
|
|
@ -87,10 +87,7 @@ public:
|
||||||
_ipaddr = ipaddr;
|
_ipaddr = ipaddr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setID(const unsigned char* id)
|
void setID(const unsigned char* id);
|
||||||
{
|
|
||||||
memcpy(_id, id, DHT_ID_LENGTH);
|
|
||||||
}
|
|
||||||
|
|
||||||
uint16_t getPort() const
|
uint16_t getPort() const
|
||||||
{
|
{
|
||||||
|
|
|
@ -35,6 +35,7 @@
|
||||||
#include "Data.h"
|
#include "Data.h"
|
||||||
#include "MetaEntryVisitor.h"
|
#include "MetaEntryVisitor.h"
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
#include <cstdlib> // <-- TODO remove this if strtoll is replaced with Util::parseLLInt()
|
||||||
|
|
||||||
namespace aria2 {
|
namespace aria2 {
|
||||||
|
|
||||||
|
|
|
@ -456,4 +456,9 @@ DefaultBtContext::getNodes()
|
||||||
return _nodes;
|
return _nodes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DefaultBtContext::setInfoHash(const unsigned char* infoHash)
|
||||||
|
{
|
||||||
|
memcpy(this->infoHash, infoHash, sizeof(this->infoHash));
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace aria2
|
} // namespace aria2
|
||||||
|
|
|
@ -160,10 +160,7 @@ private:
|
||||||
}
|
}
|
||||||
|
|
||||||
// for unit test
|
// for unit test
|
||||||
void setInfoHash(const unsigned char* infoHash)
|
void setInfoHash(const unsigned char* infoHash);
|
||||||
{
|
|
||||||
memcpy(this->infoHash, infoHash, sizeof(this->infoHash));
|
|
||||||
}
|
|
||||||
|
|
||||||
void setNumPieces(size_t numPieces)
|
void setNumPieces(size_t numPieces)
|
||||||
{
|
{
|
||||||
|
|
|
@ -53,6 +53,7 @@
|
||||||
#include "DownloadFailureException.h"
|
#include "DownloadFailureException.h"
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <cerrno>
|
#include <cerrno>
|
||||||
|
#include <cstring>
|
||||||
|
|
||||||
namespace aria2 {
|
namespace aria2 {
|
||||||
|
|
||||||
|
@ -182,7 +183,7 @@ void DefaultBtProgressInfoFile::load()
|
||||||
|
|
||||||
uint32_t infoHashLength;
|
uint32_t infoHashLength;
|
||||||
in.read(reinterpret_cast<char*>(&infoHashLength), sizeof(infoHashLength));
|
in.read(reinterpret_cast<char*>(&infoHashLength), sizeof(infoHashLength));
|
||||||
if(infoHashLength < 0 || infoHashLength == 0 && infoHashCheckEnabled) {
|
if((infoHashLength < 0) || ((infoHashLength == 0) && infoHashCheckEnabled)) {
|
||||||
throw new DlAbortEx("Invalid info hash length: %d", infoHashLength);
|
throw new DlAbortEx("Invalid info hash length: %d", infoHashLength);
|
||||||
}
|
}
|
||||||
if(infoHashLength > 0) {
|
if(infoHashLength > 0) {
|
||||||
|
|
|
@ -66,8 +66,8 @@ public:
|
||||||
FindIdenticalPeer(const PeerHandle& peer):_peer(peer) {}
|
FindIdenticalPeer(const PeerHandle& peer):_peer(peer) {}
|
||||||
|
|
||||||
bool operator()(const PeerHandle& peer) const {
|
bool operator()(const PeerHandle& peer) const {
|
||||||
return _peer == peer ||
|
return (_peer == peer) ||
|
||||||
_peer->ipaddr == peer->ipaddr && _peer->port == peer->port;
|
((_peer->ipaddr == peer->ipaddr) && (_peer->port == peer->port));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -34,6 +34,7 @@
|
||||||
/* copyright --> */
|
/* copyright --> */
|
||||||
#include "Dictionary.h"
|
#include "Dictionary.h"
|
||||||
#include "MetaEntryVisitor.h"
|
#include "MetaEntryVisitor.h"
|
||||||
|
#include <algorithm>
|
||||||
|
|
||||||
namespace aria2 {
|
namespace aria2 {
|
||||||
|
|
||||||
|
|
|
@ -142,8 +142,8 @@ bool DownloadCommand::executeInternal() {
|
||||||
if(_requestGroup->getTotalLength() != 0 && bufSize == 0) {
|
if(_requestGroup->getTotalLength() != 0 && bufSize == 0) {
|
||||||
throw new DlRetryEx(EX_GOT_EOF);
|
throw new DlRetryEx(EX_GOT_EOF);
|
||||||
}
|
}
|
||||||
if(!transferDecoder.isNull() && transferDecoder->finished()
|
if((!transferDecoder.isNull() && transferDecoder->finished())
|
||||||
|| transferDecoder.isNull() && segment->complete()
|
|| (transferDecoder.isNull() && segment->complete())
|
||||||
|| bufSize == 0) {
|
|| bufSize == 0) {
|
||||||
if(!transferDecoder.isNull()) transferDecoder->end();
|
if(!transferDecoder.isNull()) transferDecoder->end();
|
||||||
logger->info(MSG_SEGMENT_DOWNLOAD_COMPLETED, cuid);
|
logger->info(MSG_SEGMENT_DOWNLOAD_COMPLETED, cuid);
|
||||||
|
|
|
@ -34,10 +34,12 @@
|
||||||
/* copyright --> */
|
/* copyright --> */
|
||||||
#include "File.h"
|
#include "File.h"
|
||||||
#include "Util.h"
|
#include "Util.h"
|
||||||
|
#define basename posix_basename
|
||||||
#include <libgen.h>
|
#include <libgen.h>
|
||||||
// use GNU version basename
|
// use GNU version basename
|
||||||
#undef basename
|
#undef basename
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
#include <stdlib.h>
|
||||||
#include <deque>
|
#include <deque>
|
||||||
|
|
||||||
namespace aria2 {
|
namespace aria2 {
|
||||||
|
|
|
@ -37,6 +37,7 @@
|
||||||
|
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
#include "SharedHandle.h"
|
#include "SharedHandle.h"
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
namespace aria2 {
|
namespace aria2 {
|
||||||
|
|
||||||
|
|
|
@ -73,7 +73,7 @@ uint64_t HttpHeader::getFirstAsULLInt(const std::string& name) const {
|
||||||
if(value == "") {
|
if(value == "") {
|
||||||
return 0;
|
return 0;
|
||||||
} else {
|
} else {
|
||||||
return strtoull(value.c_str(), 0, 10);
|
return Util::parseULLInt(value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -85,7 +85,7 @@ RangeHandle HttpHeader::getRange() const
|
||||||
if(contentLengthStr == "") {
|
if(contentLengthStr == "") {
|
||||||
return new Range(0, 0, 0);
|
return new Range(0, 0, 0);
|
||||||
} else {
|
} else {
|
||||||
uint64_t contentLength = strtoull(contentLengthStr.c_str(), 0, 10);
|
uint64_t contentLength = Util::parseULLInt(contentLengthStr);
|
||||||
if(contentLength == 0) {
|
if(contentLength == 0) {
|
||||||
return new Range(0, 0, 0);
|
return new Range(0, 0, 0);
|
||||||
} else {
|
} else {
|
||||||
|
@ -102,9 +102,9 @@ RangeHandle HttpHeader::getRange() const
|
||||||
std::pair<std::string, std::string> startEndBytePair;
|
std::pair<std::string, std::string> startEndBytePair;
|
||||||
Util::split(startEndBytePair, rangePair.first, '-');
|
Util::split(startEndBytePair, rangePair.first, '-');
|
||||||
|
|
||||||
uint64_t startByte = STRTOULL(startEndBytePair.first.c_str());
|
off_t startByte = Util::parseLLInt(startEndBytePair.first);
|
||||||
uint64_t endByte = STRTOULL(startEndBytePair.second.c_str());
|
off_t endByte = Util::parseLLInt(startEndBytePair.second);
|
||||||
uint64_t entityLength = STRTOULL(rangePair.second.c_str());
|
uint64_t entityLength = Util::parseULLInt(rangePair.second);
|
||||||
|
|
||||||
return new Range(startByte, endByte, entityLength);
|
return new Range(startByte, endByte, entityLength);
|
||||||
}
|
}
|
||||||
|
|
|
@ -115,11 +115,11 @@ bool HttpRequest::isRangeSatisfied(const RangeHandle& range) const
|
||||||
if(segment.isNull()) {
|
if(segment.isNull()) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if(getStartByte() == range->getStartByte() &&
|
if((getStartByte() == range->getStartByte()) &&
|
||||||
(getEndByte() == 0 ||
|
((getEndByte() == 0) ||
|
||||||
getEndByte() > 0 && getEndByte() == range->getEndByte()) &&
|
((getEndByte() > 0) && (getEndByte() == range->getEndByte()))) &&
|
||||||
(entityLength == 0 ||
|
((entityLength == 0) ||
|
||||||
entityLength > 0 && entityLength == range->getEntityLength())) {
|
((entityLength > 0) && (entityLength == range->getEntityLength())))) {
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -37,6 +37,7 @@
|
||||||
|
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
#include "SharedHandle.h"
|
#include "SharedHandle.h"
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
namespace aria2 {
|
namespace aria2 {
|
||||||
|
|
||||||
|
|
|
@ -40,6 +40,7 @@
|
||||||
#include "DlAbortEx.h"
|
#include "DlAbortEx.h"
|
||||||
#include "message.h"
|
#include "message.h"
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
#include <cstdlib> // <-- TODO remove this if strtoul is replaced with Util::parseUInt()
|
||||||
|
|
||||||
namespace aria2 {
|
namespace aria2 {
|
||||||
|
|
||||||
|
|
|
@ -37,6 +37,7 @@
|
||||||
|
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
#include <map>
|
#include <map>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
namespace aria2 {
|
namespace aria2 {
|
||||||
|
|
||||||
|
|
|
@ -37,6 +37,7 @@
|
||||||
|
|
||||||
#include "OptionHandler.h"
|
#include "OptionHandler.h"
|
||||||
#include "DlAbortEx.h"
|
#include "DlAbortEx.h"
|
||||||
|
#include <strings.h>
|
||||||
|
|
||||||
namespace aria2 {
|
namespace aria2 {
|
||||||
|
|
||||||
|
|
|
@ -83,8 +83,8 @@ bool PeerAbstractCommand::execute() {
|
||||||
uploadLimitCheck && (uploadLimit == 0 ||
|
uploadLimitCheck && (uploadLimit == 0 ||
|
||||||
e->getUploadSpeed() <= uploadLimit*1024) ||
|
e->getUploadSpeed() <= uploadLimit*1024) ||
|
||||||
*/
|
*/
|
||||||
checkSocketIsReadable && readCheckTarget->isReadable(0) ||
|
(checkSocketIsReadable && readCheckTarget->isReadable(0)) ||
|
||||||
checkSocketIsWritable && writeCheckTarget->isWritable(0)) {
|
(checkSocketIsWritable && writeCheckTarget->isWritable(0))) {
|
||||||
checkPoint.reset();
|
checkPoint.reset();
|
||||||
}
|
}
|
||||||
if(checkPoint.elapsed(timeout)) {
|
if(checkPoint.elapsed(timeout)) {
|
||||||
|
|
|
@ -37,6 +37,7 @@
|
||||||
|
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
#include "SharedHandle.h"
|
#include "SharedHandle.h"
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
namespace aria2 {
|
namespace aria2 {
|
||||||
|
|
||||||
|
|
|
@ -218,8 +218,8 @@ bool PeerInteractionCommand::executeInternal() {
|
||||||
if(btInteractive->countReceivedMessageInIteration() > 0) {
|
if(btInteractive->countReceivedMessageInIteration() > 0) {
|
||||||
updateKeepAlive();
|
updateKeepAlive();
|
||||||
}
|
}
|
||||||
if(peer->amInterested() && !peer->peerChoking() && peer->getLatency() < 1500 ||
|
if((peer->amInterested() && !peer->peerChoking() && (peer->getLatency() < 1500)) ||
|
||||||
peer->peerInterested() && !peer->amChoking()) {
|
(peer->peerInterested() && !peer->amChoking())) {
|
||||||
if(maxDownloadSpeedLimit > 0) {
|
if(maxDownloadSpeedLimit > 0) {
|
||||||
TransferStat stat = peerStorage->calculateStat();
|
TransferStat stat = peerStorage->calculateStat();
|
||||||
if(maxDownloadSpeedLimit < stat.downloadSpeed) {
|
if(maxDownloadSpeedLimit < stat.downloadSpeed) {
|
||||||
|
|
|
@ -38,6 +38,7 @@
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
#include "SharedHandle.h"
|
#include "SharedHandle.h"
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
namespace aria2 {
|
namespace aria2 {
|
||||||
|
|
||||||
|
|
|
@ -154,7 +154,7 @@ bool Request::parseUrl(const std::string& url) {
|
||||||
|
|
||||||
bool Request::isHexNumber(const char c) const
|
bool Request::isHexNumber(const char c) const
|
||||||
{
|
{
|
||||||
return '0' <= c && c <= '9' || 'A' <= c && c <= 'F' || 'a' <= c && c <= 'f';
|
return ('0' <= c && c <= '9') || ('A' <= c && c <= 'F') || ('a' <= c && c <= 'f');
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string Request::urlencode(const std::string& src) const
|
std::string Request::urlencode(const std::string& src) const
|
||||||
|
|
|
@ -321,9 +321,9 @@ bool RequestGroup::downloadFinishedByFileLength()
|
||||||
{
|
{
|
||||||
// assuming that a control file doesn't exist.
|
// assuming that a control file doesn't exist.
|
||||||
if(!isPreLocalFileCheckEnabled() ||
|
if(!isPreLocalFileCheckEnabled() ||
|
||||||
_option->get(PREF_ALLOW_OVERWRITE) == V_TRUE ||
|
(_option->get(PREF_ALLOW_OVERWRITE) == V_TRUE) ||
|
||||||
_option->get(PREF_CHECK_INTEGRITY) == V_TRUE &&
|
((_option->get(PREF_CHECK_INTEGRITY) == V_TRUE) &&
|
||||||
!_downloadContext->getPieceHashes().empty()) {
|
!_downloadContext->getPieceHashes().empty())) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// TODO consider the case when the getFilePath() returns dir path.
|
// TODO consider the case when the getFilePath() returns dir path.
|
||||||
|
@ -882,8 +882,8 @@ void RequestGroup::removeURIWhoseHostnameIs(const std::string& hostname)
|
||||||
std::deque<std::string> newURIs;
|
std::deque<std::string> newURIs;
|
||||||
Request req;
|
Request req;
|
||||||
for(std::deque<std::string>::const_iterator itr = _uris.begin(); itr != _uris.end(); ++itr) {
|
for(std::deque<std::string>::const_iterator itr = _uris.begin(); itr != _uris.end(); ++itr) {
|
||||||
if((*itr).find(hostname) == std::string::npos ||
|
if(((*itr).find(hostname) == std::string::npos) ||
|
||||||
req.setUrl(*itr) && req.getHost() != hostname) {
|
(req.setUrl(*itr) && (req.getHost() != hostname))) {
|
||||||
newURIs.push_back(*itr);
|
newURIs.push_back(*itr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,6 +37,7 @@
|
||||||
|
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
#include "SharedHandle.h"
|
#include "SharedHandle.h"
|
||||||
|
#include <unistd.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <deque>
|
#include <deque>
|
||||||
|
|
||||||
|
|
|
@ -45,6 +45,7 @@
|
||||||
#include "Option.h"
|
#include "Option.h"
|
||||||
#include "DownloadContext.h"
|
#include "DownloadContext.h"
|
||||||
#include "Piece.h"
|
#include "Piece.h"
|
||||||
|
#include <algorithm>
|
||||||
|
|
||||||
namespace aria2 {
|
namespace aria2 {
|
||||||
|
|
||||||
|
|
|
@ -40,6 +40,7 @@
|
||||||
#include "a2time.h"
|
#include "a2time.h"
|
||||||
#include <cstdarg>
|
#include <cstdarg>
|
||||||
#include <cerrno>
|
#include <cerrno>
|
||||||
|
#include <cstring>
|
||||||
|
|
||||||
namespace aria2 {
|
namespace aria2 {
|
||||||
|
|
||||||
|
|
|
@ -36,6 +36,7 @@
|
||||||
#include "BinaryStream.h"
|
#include "BinaryStream.h"
|
||||||
#include "Util.h"
|
#include "Util.h"
|
||||||
#include "a2io.h"
|
#include "a2io.h"
|
||||||
|
#include <cstring>
|
||||||
|
|
||||||
namespace aria2 {
|
namespace aria2 {
|
||||||
|
|
||||||
|
|
|
@ -38,6 +38,7 @@
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
#include "a2netcompat.h"
|
#include "a2netcompat.h"
|
||||||
#include "a2time.h"
|
#include "a2time.h"
|
||||||
|
#include <cstdlib>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
|
|
|
@ -40,6 +40,7 @@
|
||||||
#include "DownloadContext.h"
|
#include "DownloadContext.h"
|
||||||
#include "Piece.h"
|
#include "Piece.h"
|
||||||
#include "FileEntry.h"
|
#include "FileEntry.h"
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
namespace aria2 {
|
namespace aria2 {
|
||||||
|
|
||||||
|
@ -70,6 +71,21 @@ void UnknownLengthPieceStorage::initStorage()
|
||||||
_diskAdaptor->setFileEntries(_downloadContext->getFileEntries());
|
_diskAdaptor->setFileEntries(_downloadContext->getFileEntries());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool UnknownLengthPieceStorage::hasMissingPiece(const SharedHandle<Peer>& peer)
|
||||||
|
{
|
||||||
|
abort();
|
||||||
|
}
|
||||||
|
|
||||||
|
SharedHandle<Piece> UnknownLengthPieceStorage::getMissingPiece(const SharedHandle<Peer>& peer)
|
||||||
|
{
|
||||||
|
abort();
|
||||||
|
}
|
||||||
|
|
||||||
|
SharedHandle<Piece> UnknownLengthPieceStorage::getMissingFastPiece(const SharedHandle<Peer>& peer)
|
||||||
|
{
|
||||||
|
abort();
|
||||||
|
}
|
||||||
|
|
||||||
PieceHandle UnknownLengthPieceStorage::getMissingPiece()
|
PieceHandle UnknownLengthPieceStorage::getMissingPiece()
|
||||||
{
|
{
|
||||||
if(_downloadFinished) {
|
if(_downloadFinished) {
|
||||||
|
@ -163,6 +179,18 @@ void UnknownLengthPieceStorage::markAllPiecesDone()
|
||||||
_downloadFinished = true;
|
_downloadFinished = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void UnknownLengthPieceStorage::markPiecesDone(uint64_t length)
|
||||||
|
{
|
||||||
|
// TODO not implemented yet
|
||||||
|
abort();
|
||||||
|
}
|
||||||
|
|
||||||
|
void UnknownLengthPieceStorage::markPieceMissing(size_t index)
|
||||||
|
{
|
||||||
|
// TODO not implemented yet
|
||||||
|
abort();
|
||||||
|
}
|
||||||
|
|
||||||
Pieces UnknownLengthPieceStorage::getInFlightPieces()
|
Pieces UnknownLengthPieceStorage::getInFlightPieces()
|
||||||
{
|
{
|
||||||
return Pieces();
|
return Pieces();
|
||||||
|
|
|
@ -69,10 +69,7 @@ public:
|
||||||
* Returns true if the peer has a piece that localhost doesn't have.
|
* Returns true if the peer has a piece that localhost doesn't have.
|
||||||
* Otherwise returns false.
|
* Otherwise returns false.
|
||||||
*/
|
*/
|
||||||
virtual bool hasMissingPiece(const SharedHandle<Peer>& peer)
|
virtual bool hasMissingPiece(const SharedHandle<Peer>& peer);
|
||||||
{
|
|
||||||
abort();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a piece that the peer has but localhost doesn't.
|
* Returns a piece that the peer has but localhost doesn't.
|
||||||
|
@ -80,10 +77,8 @@ public:
|
||||||
* from get the same piece. But in end game mode, same piece may be returned
|
* from get the same piece. But in end game mode, same piece may be returned
|
||||||
* to several commands.
|
* to several commands.
|
||||||
*/
|
*/
|
||||||
virtual SharedHandle<Piece> getMissingPiece(const SharedHandle<Peer>& peer)
|
virtual SharedHandle<Piece> getMissingPiece(const SharedHandle<Peer>& peer);
|
||||||
{
|
|
||||||
abort();
|
|
||||||
}
|
|
||||||
/**
|
/**
|
||||||
* Returns a piece that the peer has but localhost doesn't.
|
* Returns a piece that the peer has but localhost doesn't.
|
||||||
* Only pieces that declared as "fast" are returned.
|
* Only pieces that declared as "fast" are returned.
|
||||||
|
@ -91,10 +86,8 @@ public:
|
||||||
* from get the same piece. But in end game mode, same piece may be returned
|
* from get the same piece. But in end game mode, same piece may be returned
|
||||||
* to several commands.
|
* to several commands.
|
||||||
*/
|
*/
|
||||||
virtual SharedHandle<Piece> getMissingFastPiece(const SharedHandle<Peer>& peer)
|
virtual SharedHandle<Piece> getMissingFastPiece(const SharedHandle<Peer>& peer);
|
||||||
{
|
|
||||||
abort();
|
|
||||||
}
|
|
||||||
/**
|
/**
|
||||||
* Returns a missing piece if available. Otherwise returns 0;
|
* Returns a missing piece if available. Otherwise returns 0;
|
||||||
*/
|
*/
|
||||||
|
@ -240,17 +233,9 @@ public:
|
||||||
*/
|
*/
|
||||||
virtual void markAllPiecesDone();
|
virtual void markAllPiecesDone();
|
||||||
|
|
||||||
virtual void markPiecesDone(uint64_t length)
|
virtual void markPiecesDone(uint64_t length);
|
||||||
{
|
|
||||||
// TODO not implemented yet
|
|
||||||
abort();
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual void markPieceMissing(size_t index)
|
virtual void markPieceMissing(size_t index);
|
||||||
{
|
|
||||||
// TODO not implemented yet
|
|
||||||
abort();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Do nothing because loading in-flight piece is not supported for this
|
* Do nothing because loading in-flight piece is not supported for this
|
||||||
|
|
48
src/Util.cc
48
src/Util.cc
|
@ -100,7 +100,8 @@ std::pair<std::string, std::string> Util::split(const std::string& src, const st
|
||||||
}
|
}
|
||||||
|
|
||||||
int64_t Util::difftv(struct timeval tv1, struct timeval tv2) {
|
int64_t Util::difftv(struct timeval tv1, struct timeval tv2) {
|
||||||
if(tv1.tv_sec < tv2.tv_sec || tv1.tv_sec == tv2.tv_sec && tv1.tv_usec < tv2.tv_usec) {
|
if((tv1.tv_sec < tv2.tv_sec) ||
|
||||||
|
((tv1.tv_sec == tv2.tv_sec) && (tv1.tv_usec < tv2.tv_usec))) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
return ((int64_t)(tv1.tv_sec-tv2.tv_sec)*1000000+
|
return ((int64_t)(tv1.tv_sec-tv2.tv_sec)*1000000+
|
||||||
|
@ -187,9 +188,9 @@ std::string Util::replace(const std::string& target, const std::string& oldstr,
|
||||||
bool Util::shouldUrlencode(const char c)
|
bool Util::shouldUrlencode(const char c)
|
||||||
{
|
{
|
||||||
return !(// ALPHA
|
return !(// ALPHA
|
||||||
'A' <= c && c <= 'Z' || 'a' <= c && c <= 'z' ||
|
('A' <= c && c <= 'Z') || ('a' <= c && c <= 'z') ||
|
||||||
// DIGIT
|
// DIGIT
|
||||||
'0' <= c && c <= '9' ||
|
('0' <= c && c <= '9') ||
|
||||||
// safe
|
// safe
|
||||||
'$' == c || '-' == c || '_' == c || '.' == c ||
|
'$' == c || '-' == c || '_' == c || '.' == c ||
|
||||||
// extra
|
// extra
|
||||||
|
@ -218,9 +219,9 @@ std::string Util::urlencode(const unsigned char* target, size_t len) {
|
||||||
std::string Util::torrentUrlencode(const unsigned char* target, size_t len) {
|
std::string Util::torrentUrlencode(const unsigned char* target, size_t len) {
|
||||||
std::string dest;
|
std::string dest;
|
||||||
for(size_t i = 0; i < len; i++) {
|
for(size_t i = 0; i < len; i++) {
|
||||||
if('0' <= target[i] && target[i] <= '9' ||
|
if(('0' <= target[i] && target[i] <= '9') ||
|
||||||
'A' <= target[i] && target[i] <= 'Z' ||
|
('A' <= target[i] && target[i] <= 'Z') ||
|
||||||
'a' <= target[i] && target[i] <= 'z') {
|
('a' <= target[i] && target[i] <= 'z')) {
|
||||||
dest += target[i];
|
dest += target[i];
|
||||||
} else {
|
} else {
|
||||||
char temp[4];
|
char temp[4];
|
||||||
|
@ -409,7 +410,9 @@ int32_t Util::parseInt(const std::string& s, int32_t base)
|
||||||
if(*stop != '\0') {
|
if(*stop != '\0') {
|
||||||
throw new DlAbortEx(MSG_STRING_INTEGER_CONVERSION_FAILURE,
|
throw new DlAbortEx(MSG_STRING_INTEGER_CONVERSION_FAILURE,
|
||||||
trimed.c_str());
|
trimed.c_str());
|
||||||
} else if((v == LONG_MIN || v == LONG_MAX) && errno == ERANGE || v > INT32_MAX || v < INT32_MIN) {
|
} else if((((v == LONG_MIN) || (v == LONG_MAX)) && (errno == ERANGE)) ||
|
||||||
|
(v > INT32_MAX) ||
|
||||||
|
(v < INT32_MIN)) {
|
||||||
throw new DlAbortEx(MSG_STRING_INTEGER_CONVERSION_FAILURE,
|
throw new DlAbortEx(MSG_STRING_INTEGER_CONVERSION_FAILURE,
|
||||||
trimed.c_str());
|
trimed.c_str());
|
||||||
}
|
}
|
||||||
|
@ -434,7 +437,7 @@ uint32_t Util::parseUInt(const std::string& s, int base)
|
||||||
if(*stop != '\0') {
|
if(*stop != '\0') {
|
||||||
throw new DlAbortEx(MSG_STRING_INTEGER_CONVERSION_FAILURE,
|
throw new DlAbortEx(MSG_STRING_INTEGER_CONVERSION_FAILURE,
|
||||||
trimed.c_str());
|
trimed.c_str());
|
||||||
} else if((v == ULONG_MAX) && errno == ERANGE || v > UINT32_MAX) {
|
} else if(((v == ULONG_MAX) && (errno == ERANGE)) || (v > UINT32_MAX)) {
|
||||||
throw new DlAbortEx(MSG_STRING_INTEGER_CONVERSION_FAILURE,
|
throw new DlAbortEx(MSG_STRING_INTEGER_CONVERSION_FAILURE,
|
||||||
trimed.c_str());
|
trimed.c_str());
|
||||||
}
|
}
|
||||||
|
@ -454,7 +457,32 @@ int64_t Util::parseLLInt(const std::string& s, int32_t base)
|
||||||
if(*stop != '\0') {
|
if(*stop != '\0') {
|
||||||
throw new DlAbortEx(MSG_STRING_INTEGER_CONVERSION_FAILURE,
|
throw new DlAbortEx(MSG_STRING_INTEGER_CONVERSION_FAILURE,
|
||||||
trimed.c_str());
|
trimed.c_str());
|
||||||
} else if((v == INT64_MIN || v == INT64_MAX) && errno == ERANGE) {
|
} else if(((v == INT64_MIN) || (v == INT64_MAX)) && (errno == ERANGE)) {
|
||||||
|
throw new DlAbortEx(MSG_STRING_INTEGER_CONVERSION_FAILURE,
|
||||||
|
trimed.c_str());
|
||||||
|
}
|
||||||
|
return v;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint64_t Util::parseULLInt(const std::string& s, int base)
|
||||||
|
{
|
||||||
|
std::string trimed = Util::trim(s);
|
||||||
|
if(trimed.empty()) {
|
||||||
|
throw new DlAbortEx(MSG_STRING_INTEGER_CONVERSION_FAILURE,
|
||||||
|
"empty string");
|
||||||
|
}
|
||||||
|
// We don't allow negative number.
|
||||||
|
if(trimed[0] == '-') {
|
||||||
|
throw new DlAbortEx(MSG_STRING_INTEGER_CONVERSION_FAILURE,
|
||||||
|
trimed.c_str());
|
||||||
|
}
|
||||||
|
char* stop;
|
||||||
|
errno = 0;
|
||||||
|
uint64_t v = strtoull(trimed.c_str(), &stop, base);
|
||||||
|
if(*stop != '\0') {
|
||||||
|
throw new DlAbortEx(MSG_STRING_INTEGER_CONVERSION_FAILURE,
|
||||||
|
trimed.c_str());
|
||||||
|
} else if((v == ULLONG_MAX) && (errno == ERANGE)) {
|
||||||
throw new DlAbortEx(MSG_STRING_INTEGER_CONVERSION_FAILURE,
|
throw new DlAbortEx(MSG_STRING_INTEGER_CONVERSION_FAILURE,
|
||||||
trimed.c_str());
|
trimed.c_str());
|
||||||
}
|
}
|
||||||
|
@ -621,7 +649,7 @@ int64_t Util::getRealSize(const std::string& sizeWithUnit)
|
||||||
|
|
||||||
if(v < 0) {
|
if(v < 0) {
|
||||||
throw new DlAbortEx("Negative value detected: %s", sizeWithUnit.c_str());
|
throw new DlAbortEx("Negative value detected: %s", sizeWithUnit.c_str());
|
||||||
} else if(v*mult < 0) {
|
} else if(INT64_MAX/mult < v) {
|
||||||
throw new DlAbortEx(MSG_STRING_INTEGER_CONVERSION_FAILURE,
|
throw new DlAbortEx(MSG_STRING_INTEGER_CONVERSION_FAILURE,
|
||||||
"overflow/underflow");
|
"overflow/underflow");
|
||||||
}
|
}
|
||||||
|
|
|
@ -168,10 +168,12 @@ public:
|
||||||
|
|
||||||
static int32_t parseInt(const std::string& s, int32_t base = 10);
|
static int32_t parseInt(const std::string& s, int32_t base = 10);
|
||||||
|
|
||||||
static unsigned int parseUInt(const std::string& s, int base = 10);
|
static uint32_t parseUInt(const std::string& s, int base = 10);
|
||||||
|
|
||||||
static int64_t parseLLInt(const std::string& s, int32_t base = 10);
|
static int64_t parseLLInt(const std::string& s, int32_t base = 10);
|
||||||
|
|
||||||
|
static uint64_t parseULLInt(const std::string& s, int base = 10);
|
||||||
|
|
||||||
static IntSequence parseIntRange(const std::string& src);
|
static IntSequence parseIntRange(const std::string& src);
|
||||||
|
|
||||||
// this function temporarily put here
|
// this function temporarily put here
|
||||||
|
|
|
@ -35,6 +35,7 @@
|
||||||
#ifndef _D_ARRAY_FUN_H_
|
#ifndef _D_ARRAY_FUN_H_
|
||||||
#define _D_ARRAY_FUN_H_
|
#define _D_ARRAY_FUN_H_
|
||||||
|
|
||||||
|
#include <cstdlib>
|
||||||
#include <functional>
|
#include <functional>
|
||||||
|
|
||||||
namespace aria2 {
|
namespace aria2 {
|
||||||
|
@ -62,7 +63,7 @@ class array_function_base {
|
||||||
public:
|
public:
|
||||||
virtual ~array_function_base() {}
|
virtual ~array_function_base() {}
|
||||||
|
|
||||||
virtual R operator[](std::size_t index) const = 0;
|
virtual R operator[](size_t index) const = 0;
|
||||||
|
|
||||||
virtual array_function_base* clone() const = 0;
|
virtual array_function_base* clone() const = 0;
|
||||||
};
|
};
|
||||||
|
@ -75,7 +76,7 @@ private:
|
||||||
public:
|
public:
|
||||||
array_unary_function(A a, F f):_a(a), _f(f) {}
|
array_unary_function(A a, F f):_a(a), _f(f) {}
|
||||||
|
|
||||||
virtual typename F::result_type operator[](std::size_t index) const
|
virtual typename F::result_type operator[](size_t index) const
|
||||||
{
|
{
|
||||||
return _f(_a[index]);
|
return _f(_a[index]);
|
||||||
}
|
}
|
||||||
|
@ -95,7 +96,7 @@ private:
|
||||||
public:
|
public:
|
||||||
array_binary_function(A a, B b, F f):_a(a), _b(b), _f(f) {}
|
array_binary_function(A a, B b, F f):_a(a), _b(b), _f(f) {}
|
||||||
|
|
||||||
virtual typename F::result_type operator[](std::size_t index) const
|
virtual typename F::result_type operator[](size_t index) const
|
||||||
{
|
{
|
||||||
return _f(_a[index], _b[index]);
|
return _f(_a[index], _b[index]);
|
||||||
}
|
}
|
||||||
|
@ -133,7 +134,7 @@ public:
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
R operator[](std::size_t index) const
|
R operator[](size_t index) const
|
||||||
{
|
{
|
||||||
return (*_p)[index];
|
return (*_p)[index];
|
||||||
}
|
}
|
||||||
|
@ -199,19 +200,17 @@ array_and(A a, B b)
|
||||||
|
|
||||||
// calculate length of array
|
// calculate length of array
|
||||||
|
|
||||||
template<typename T, std::size_t N>
|
template<typename T, size_t N>
|
||||||
char (&char_array_ref(T (&)[N]))[N];
|
char (&char_array_ref(T (&)[N]))[N];
|
||||||
|
|
||||||
template<typename T, std::size_t N>
|
template<typename T, size_t N>
|
||||||
std::size_t
|
size_t arrayLength(T (&a)[N])
|
||||||
arrayLength(T (&a)[N])
|
|
||||||
{
|
{
|
||||||
return sizeof(char_array_ref(a));
|
return sizeof(char_array_ref(a));
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
std::size_t
|
size_t arrayLength(T (&a)[0u])
|
||||||
arrayLength(T (&a)[0u])
|
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,6 +44,7 @@
|
||||||
#include "a2io.h"
|
#include "a2io.h"
|
||||||
#include "help_tags.h"
|
#include "help_tags.h"
|
||||||
#include "File.h"
|
#include "File.h"
|
||||||
|
#include <cstdlib>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
#include "DHTUtil.h"
|
#include "DHTUtil.h"
|
||||||
#include "Exception.h"
|
#include "Exception.h"
|
||||||
#include "Util.h"
|
#include "Util.h"
|
||||||
|
#include <cstring>
|
||||||
#include <cppunit/extensions/HelperMacros.h>
|
#include <cppunit/extensions/HelperMacros.h>
|
||||||
|
|
||||||
namespace aria2 {
|
namespace aria2 {
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
#include "BitfieldMan.h"
|
#include "BitfieldMan.h"
|
||||||
#include "FixedNumberRandomizer.h"
|
#include "FixedNumberRandomizer.h"
|
||||||
|
#include <cstring>
|
||||||
#include <cppunit/extensions/HelperMacros.h>
|
#include <cppunit/extensions/HelperMacros.h>
|
||||||
|
|
||||||
namespace aria2 {
|
namespace aria2 {
|
||||||
|
|
|
@ -2,6 +2,8 @@
|
||||||
#include "DHTNode.h"
|
#include "DHTNode.h"
|
||||||
#include "Exception.h"
|
#include "Exception.h"
|
||||||
#include "Util.h"
|
#include "Util.h"
|
||||||
|
#include <cstring>
|
||||||
|
#include <algorithm>
|
||||||
#include <cppunit/extensions/HelperMacros.h>
|
#include <cppunit/extensions/HelperMacros.h>
|
||||||
|
|
||||||
namespace aria2 {
|
namespace aria2 {
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
#include "DHTIDCloser.h"
|
#include "DHTIDCloser.h"
|
||||||
#include "Exception.h"
|
#include "Exception.h"
|
||||||
#include "Util.h"
|
#include "Util.h"
|
||||||
|
#include <cstring>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <cppunit/extensions/HelperMacros.h>
|
#include <cppunit/extensions/HelperMacros.h>
|
||||||
|
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
#include "DHTGetPeersReplyMessage.h"
|
#include "DHTGetPeersReplyMessage.h"
|
||||||
#include "DHTAnnouncePeerMessage.h"
|
#include "DHTAnnouncePeerMessage.h"
|
||||||
#include "DHTAnnouncePeerReplyMessage.h"
|
#include "DHTAnnouncePeerReplyMessage.h"
|
||||||
|
#include <cstring>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <cppunit/extensions/HelperMacros.h>
|
#include <cppunit/extensions/HelperMacros.h>
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
#include "DHTUtil.h"
|
#include "DHTUtil.h"
|
||||||
#include "Exception.h"
|
#include "Exception.h"
|
||||||
#include "Util.h"
|
#include "Util.h"
|
||||||
|
#include <cstring>
|
||||||
#include <cppunit/extensions/HelperMacros.h>
|
#include <cppunit/extensions/HelperMacros.h>
|
||||||
|
|
||||||
namespace aria2 {
|
namespace aria2 {
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
#include "AnnounceTier.h"
|
#include "AnnounceTier.h"
|
||||||
#include "FixedNumberRandomizer.h"
|
#include "FixedNumberRandomizer.h"
|
||||||
#include "FileEntry.h"
|
#include "FileEntry.h"
|
||||||
|
#include <cstring>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <cppunit/extensions/HelperMacros.h>
|
#include <cppunit/extensions/HelperMacros.h>
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
#define _D_FIXED_NUMBER_RANDOMIZER_H_
|
#define _D_FIXED_NUMBER_RANDOMIZER_H_
|
||||||
|
|
||||||
#include "Randomizer.h"
|
#include "Randomizer.h"
|
||||||
|
#include <cstdlib>
|
||||||
|
|
||||||
namespace aria2 {
|
namespace aria2 {
|
||||||
|
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
#include "BtContext.h"
|
#include "BtContext.h"
|
||||||
#include "Util.h"
|
#include "Util.h"
|
||||||
#include "AnnounceTier.h"
|
#include "AnnounceTier.h"
|
||||||
|
#include <cstring>
|
||||||
|
|
||||||
namespace aria2 {
|
namespace aria2 {
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,8 @@
|
||||||
#include "FileEntry.h"
|
#include "FileEntry.h"
|
||||||
#include "Exception.h"
|
#include "Exception.h"
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <cerrno>
|
||||||
|
#include <cstring>
|
||||||
#include <cppunit/extensions/HelperMacros.h>
|
#include <cppunit/extensions/HelperMacros.h>
|
||||||
|
|
||||||
namespace aria2 {
|
namespace aria2 {
|
||||||
|
@ -48,12 +50,12 @@ std::deque<SharedHandle<FileEntry> > createEntries() {
|
||||||
void readFile(const std::string& filename, char* buf, int bufLength) {
|
void readFile(const std::string& filename, char* buf, int bufLength) {
|
||||||
FILE* f = fopen(filename.c_str(), "r");
|
FILE* f = fopen(filename.c_str(), "r");
|
||||||
if(f == NULL) {
|
if(f == NULL) {
|
||||||
abort();
|
CPPUNIT_FAIL(strerror(errno));
|
||||||
}
|
}
|
||||||
int retval = fread(buf, bufLength, 1, f);
|
int retval = fread(buf, bufLength, 1, f);
|
||||||
fclose(f);
|
fclose(f);
|
||||||
if(retval != 1) {
|
if(retval != 1) {
|
||||||
abort();
|
CPPUNIT_FAIL("return value is not 1");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -41,6 +41,7 @@ class UtilTest:public CppUnit::TestFixture {
|
||||||
CPPUNIT_TEST(testParseInt);
|
CPPUNIT_TEST(testParseInt);
|
||||||
CPPUNIT_TEST(testParseUInt);
|
CPPUNIT_TEST(testParseUInt);
|
||||||
CPPUNIT_TEST(testParseLLInt);
|
CPPUNIT_TEST(testParseLLInt);
|
||||||
|
CPPUNIT_TEST(testParseULLInt);
|
||||||
CPPUNIT_TEST(testToString_binaryStream);
|
CPPUNIT_TEST(testToString_binaryStream);
|
||||||
CPPUNIT_TEST(testItos);
|
CPPUNIT_TEST(testItos);
|
||||||
CPPUNIT_TEST(testUitos);
|
CPPUNIT_TEST(testUitos);
|
||||||
|
@ -78,6 +79,7 @@ public:
|
||||||
void testParseInt();
|
void testParseInt();
|
||||||
void testParseUInt();
|
void testParseUInt();
|
||||||
void testParseLLInt();
|
void testParseLLInt();
|
||||||
|
void testParseULLInt();
|
||||||
void testToString_binaryStream();
|
void testToString_binaryStream();
|
||||||
void testItos();
|
void testItos();
|
||||||
void testUitos();
|
void testUitos();
|
||||||
|
@ -612,6 +614,26 @@ void UtilTest::testParseLLInt()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void UtilTest::testParseULLInt()
|
||||||
|
{
|
||||||
|
CPPUNIT_ASSERT_EQUAL(18446744073709551615ULL,
|
||||||
|
Util::parseULLInt("18446744073709551615"));
|
||||||
|
try {
|
||||||
|
Util::parseUInt("-1");
|
||||||
|
CPPUNIT_FAIL("exception must be thrown.");
|
||||||
|
} catch(Exception* e) {
|
||||||
|
std::cerr << *e;
|
||||||
|
delete e;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
Util::parseLLInt("18446744073709551616");
|
||||||
|
CPPUNIT_FAIL("exception must be thrown.");
|
||||||
|
} catch(Exception* e) {
|
||||||
|
std::cerr << *e;
|
||||||
|
delete e;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void UtilTest::testToString_binaryStream()
|
void UtilTest::testToString_binaryStream()
|
||||||
{
|
{
|
||||||
SharedHandle<DiskWriter> dw = new ByteArrayDiskWriter();
|
SharedHandle<DiskWriter> dw = new ByteArrayDiskWriter();
|
||||||
|
|
Loading…
Reference in New Issue