summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorNils Maier <maierman@web.de>2014-04-17 01:36:19 +0200
committerNils Maier <maierman@web.de>2014-04-17 18:02:42 +0200
commit010131161ebdea22e5b6eb4fd0740e8e6da3df67 (patch)
tree3a768bbd2796056c65de9630a6ab6946d4eda43f /src
parentbefd799d177c2860ea4e9c6cf8c744342c394427 (diff)
Remove ENABLE_MESSAGE_DIGEST, since we got the internal md, always
Diffstat (limited to 'src')
-rw-r--r--src/AbstractCommand.cc4
-rw-r--r--src/ConsoleStatCalc.cc2
-rw-r--r--src/Context.cc4
-rw-r--r--src/DefaultBtProgressInfoFile.cc5
-rw-r--r--src/DefaultPieceStorage.cc8
-rw-r--r--src/DownloadCommand.cc19
-rw-r--r--src/DownloadCommand.h4
-rw-r--r--src/DownloadEngineFactory.cc8
-rw-r--r--src/FeatureConfig.cc4
-rw-r--r--src/FtpNegotiationCommand.cc12
-rw-r--r--src/GrowSegment.cc4
-rw-r--r--src/GrowSegment.h4
-rw-r--r--src/HttpResponse.cc4
-rw-r--r--src/HttpResponse.h2
-rw-r--r--src/HttpResponseCommand.cc20
-rw-r--r--src/HttpResponseCommand.h4
-rw-r--r--src/HttpServerCommand.cc6
-rw-r--r--src/Makefile.am27
-rw-r--r--src/Metalink2RequestGroup.cc12
-rw-r--r--src/MetalinkEntry.cc6
-rw-r--r--src/MetalinkEntry.h5
-rw-r--r--src/MetalinkParserController.cc50
-rw-r--r--src/MetalinkParserController.h6
-rw-r--r--src/MetalinkParserStateV3Impl.cc2
-rw-r--r--src/MetalinkParserStateV4Impl.cc2
-rw-r--r--src/OptionHandlerFactory.cc8
-rw-r--r--src/OptionHandlerImpl.cc6
-rw-r--r--src/OptionHandlerImpl.h2
-rw-r--r--src/Piece.cc14
-rw-r--r--src/Piece.h15
-rw-r--r--src/PieceHashCheckIntegrityEntry.cc2
-rw-r--r--src/PiecedSegment.cc8
-rw-r--r--src/PiecedSegment.h4
-rw-r--r--src/RequestGroup.cc18
-rw-r--r--src/RpcMethodImpl.cc12
-rw-r--r--src/Segment.h4
-rw-r--r--src/SinkStreamFilter.cc2
-rw-r--r--src/download_helper.cc2
-rw-r--r--src/util.cc10
-rw-r--r--src/version_usage.cc6
40 files changed, 45 insertions, 292 deletions
diff --git a/src/AbstractCommand.cc b/src/AbstractCommand.cc
index 5dad881a..313155ba 100644
--- a/src/AbstractCommand.cc
+++ b/src/AbstractCommand.cc
@@ -66,13 +66,11 @@
#include "FileEntry.h"
#include "error_code.h"
#include "SocketRecvBuffer.h"
+#include "ChecksumCheckIntegrityEntry.h"
#ifdef ENABLE_ASYNC_DNS
#include "AsyncNameResolver.h"
#include "AsyncNameResolverMan.h"
#endif // ENABLE_ASYNC_DNS
-#ifdef ENABLE_MESSAGE_DIGEST
-# include "ChecksumCheckIntegrityEntry.h"
-#endif // ENABLE_MESSAGE_DIGEST
namespace aria2 {
diff --git a/src/ConsoleStatCalc.cc b/src/ConsoleStatCalc.cc
index f57b1dbb..64ae3e30 100644
--- a/src/ConsoleStatCalc.cc
+++ b/src/ConsoleStatCalc.cc
@@ -359,7 +359,6 @@ ConsoleStatCalc::calculateStat(const DownloadEngine* e)
}
}
}
-#ifdef ENABLE_MESSAGE_DIGEST
{
auto& entry = e->getCheckIntegrityMan()->getPickedEntry();
if(entry) {
@@ -378,7 +377,6 @@ ConsoleStatCalc::calculateStat(const DownloadEngine* e)
}
}
}
-#endif // ENABLE_MESSAGE_DIGEST
if(isTTY_) {
if (truncate_) {
auto str = o.str(color, cols);
diff --git a/src/Context.cc b/src/Context.cc
index 080c0c88..25182c47 100644
--- a/src/Context.cc
+++ b/src/Context.cc
@@ -66,6 +66,7 @@
#include "fmt.h"
#include "console.h"
#include "UriListParser.h"
+#include "message_digest_helper.h"
#ifdef ENABLE_BITTORRENT
# include "bittorrent_helper.h"
#endif // ENABLE_BITTORRENT
@@ -73,9 +74,6 @@
# include "metalink_helper.h"
# include "MetalinkEntry.h"
#endif // ENABLE_METALINK
-#ifdef ENABLE_MESSAGE_DIGEST
-# include "message_digest_helper.h"
-#endif // ENABLE_MESSAGE_DIGEST
extern char* optarg;
extern int optind, opterr, optopt;
diff --git a/src/DefaultBtProgressInfoFile.cc b/src/DefaultBtProgressInfoFile.cc
index ed5fd8f8..b1e4fd14 100644
--- a/src/DefaultBtProgressInfoFile.cc
+++ b/src/DefaultBtProgressInfoFile.cc
@@ -347,13 +347,8 @@ void DefaultBtProgressInfoFile::load()
((size_t)bitfieldLength);
READ_CHECK(fp, pieceBitfield.get(), bitfieldLength);
piece->setBitfield(pieceBitfield.get(), bitfieldLength);
-
-#ifdef ENABLE_MESSAGE_DIGEST
-
piece->setHashType(dctx_->getPieceHashType());
-#endif // ENABLE_MESSAGE_DIGEST
-
inFlightPieces.push_back(piece);
}
pieceStorage_->addInFlightPiece(inFlightPieces);
diff --git a/src/DefaultPieceStorage.cc b/src/DefaultPieceStorage.cc
index 68dc63b7..c7fd7aa9 100644
--- a/src/DefaultPieceStorage.cc
+++ b/src/DefaultPieceStorage.cc
@@ -113,12 +113,8 @@ std::shared_ptr<Piece> DefaultPieceStorage::checkOutPiece
std::shared_ptr<Piece> piece = findUsedPiece(index);
if(!piece) {
piece.reset(new Piece(index, bitfieldMan_->getBlockLength(index)));
-#ifdef ENABLE_MESSAGE_DIGEST
-
piece->setHashType(downloadContext_->getPieceHashType());
-#endif // ENABLE_MESSAGE_DIGEST
-
addUsedPiece(piece);
}
piece->addUser(cuid);
@@ -780,12 +776,8 @@ void DefaultPieceStorage::markPiecesDone(int64_t length)
p->completeBlock(i);
}
-#ifdef ENABLE_MESSAGE_DIGEST
-
p->setHashType(downloadContext_->getPieceHashType());
-#endif // ENABLE_MESSAGE_DIGEST
-
addUsedPiece(p);
}
}
diff --git a/src/DownloadCommand.cc b/src/DownloadCommand.cc
index 0e5104d1..e42339bc 100644
--- a/src/DownloadCommand.cc
+++ b/src/DownloadCommand.cc
@@ -65,10 +65,8 @@
#include "Piece.h"
#include "WrDiskCacheEntry.h"
#include "DownloadFailureException.h"
-#ifdef ENABLE_MESSAGE_DIGEST
-# include "MessageDigest.h"
-# include "message_digest_helper.h"
-#endif // ENABLE_MESSAGE_DIGEST
+#include "MessageDigest.h"
+#include "message_digest_helper.h"
#ifdef ENABLE_BITTORRENT
# include "bittorrent_helper.h"
#endif // ENABLE_BITTORRENT
@@ -86,7 +84,6 @@ DownloadCommand::DownloadCommand(cuid_t cuid,
lowestDownloadSpeedLimit_(0),
pieceHashValidationEnabled_(false)
{
-#ifdef ENABLE_MESSAGE_DIGEST
{
if(getOption()->getAsBool(PREF_REALTIME_CHUNK_CHECKSUM)) {
const std::string& algo = getDownloadContext()->getPieceHashType();
@@ -96,7 +93,6 @@ DownloadCommand::DownloadCommand(cuid_t cuid,
}
}
}
-#endif // ENABLE_MESSAGE_DIGEST
peerStat_ = req->initPeerStat();
peerStat_->downloadStart();
@@ -236,8 +232,6 @@ bool DownloadCommand::executeInternal() {
A2_LOG_INFO(fmt(MSG_SEGMENT_DOWNLOAD_COMPLETED,
getCuid()));
-#ifdef ENABLE_MESSAGE_DIGEST
-
{
const std::string& expectedPieceHash =
getDownloadContext()->getPieceHash(segment->getIndex());
@@ -270,9 +264,6 @@ bool DownloadCommand::executeInternal() {
}
}
-#else // !ENABLE_MESSAGE_DIGEST
- completeSegment(getCuid(), segment);
-#endif // !ENABLE_MESSAGE_DIGEST
} else {
// If segment is not canceled here, in the next pipelining
// request, aria2 requests bad range
@@ -319,7 +310,6 @@ bool DownloadCommand::prepareForNextSegment() {
getFileEntry()->setLength(getPieceStorage()->getCompletedLength());
}
}
-#ifdef ENABLE_MESSAGE_DIGEST
if(getDownloadContext()->getPieceHashType().empty()) {
auto entry = make_unique<ChecksumCheckIntegrityEntry>(getRequestGroup());
if(entry->isValidationReady()) {
@@ -329,7 +319,6 @@ bool DownloadCommand::prepareForNextSegment() {
(std::move(entry));
}
}
-#endif // ENABLE_MESSAGE_DIGEST
// Following 2lines are needed for DownloadEngine to detect
// completed RequestGroups without 1sec delay.
getDownloadEngine()->setNoWait(true);
@@ -370,8 +359,6 @@ bool DownloadCommand::prepareForNextSegment() {
}
}
-#ifdef ENABLE_MESSAGE_DIGEST
-
void DownloadCommand::validatePieceHash(const std::shared_ptr<Segment>& segment,
const std::string& expectedHash,
const std::string& actualHash)
@@ -393,8 +380,6 @@ void DownloadCommand::validatePieceHash(const std::shared_ptr<Segment>& segment,
}
}
-#endif // ENABLE_MESSAGE_DIGEST
-
void DownloadCommand::completeSegment(cuid_t cuid,
const std::shared_ptr<Segment>& segment)
{
diff --git a/src/DownloadCommand.h b/src/DownloadCommand.h
index ddb87da1..3efaf5a0 100644
--- a/src/DownloadCommand.h
+++ b/src/DownloadCommand.h
@@ -43,9 +43,7 @@ namespace aria2 {
class PeerStat;
class StreamFilter;
-#ifdef ENABLE_MESSAGE_DIGEST
class MessageDigest;
-#endif // ENABLE_MESSAGE_DIGEST
class DownloadCommand : public AbstractCommand {
private:
@@ -53,9 +51,7 @@ private:
std::unique_ptr<StreamFilter> streamFilter_;
-#ifdef ENABLE_MESSAGE_DIGEST
std::unique_ptr<MessageDigest> messageDigest_;
-#endif // ENABLE_MESSAGE_DIGEST
time_t startupIdleTime_;
diff --git a/src/DownloadEngineFactory.cc b/src/DownloadEngineFactory.cc
index 39b04f98..fa350589 100644
--- a/src/DownloadEngineFactory.cc
+++ b/src/DownloadEngineFactory.cc
@@ -43,9 +43,7 @@
#include "FileAllocationMan.h"
#include "CheckIntegrityMan.h"
#include "CheckIntegrityEntry.h"
-#ifdef ENABLE_MESSAGE_DIGEST
-# include "CheckIntegrityDispatcherCommand.h"
-#endif // ENABLE_MESSAGE_DIGEST
+#include "CheckIntegrityDispatcherCommand.h"
#include "prefs.h"
#include "FillRequestGroupCommand.h"
#include "FileAllocationDispatcherCommand.h"
@@ -157,19 +155,15 @@ DownloadEngineFactory::newDownloadEngine
e->setRequestGroupMan(std::move(requestGroupMan));
}
e->setFileAllocationMan(make_unique<FileAllocationMan>());
-#ifdef ENABLE_MESSAGE_DIGEST
e->setCheckIntegrityMan(make_unique<CheckIntegrityMan>());
-#endif // ENABLE_MESSAGE_DIGEST
e->addRoutineCommand(make_unique<FillRequestGroupCommand>
(e->newCUID(), e.get()));
e->addRoutineCommand(make_unique<FileAllocationDispatcherCommand>
(e->newCUID(), e->getFileAllocationMan().get(),
e.get()));
-#ifdef ENABLE_MESSAGE_DIGEST
e->addRoutineCommand(make_unique<CheckIntegrityDispatcherCommand>
(e->newCUID(), e->getCheckIntegrityMan().get(),
e.get()));
-#endif // ENABLE_MESSAGE_DIGEST
if(op->getAsInt(PREF_AUTO_SAVE_INTERVAL) > 0) {
e->addRoutineCommand
diff --git a/src/FeatureConfig.cc b/src/FeatureConfig.cc
index d1063a2a..74dafd2b 100644
--- a/src/FeatureConfig.cc
+++ b/src/FeatureConfig.cc
@@ -141,11 +141,7 @@ const char* strSupportedFeature(int feature)
break;
case(FEATURE_MESSAGE_DIGEST):
-#ifdef ENABLE_MESSAGE_DIGEST
return "Message Digest";
-#else // !ENABLE_MESSAGE_DIGEST
- return 0;
-#endif // !ENABLE_MESSAGE_DIGEST
break;
case(FEATURE_METALINK):
diff --git a/src/FtpNegotiationCommand.cc b/src/FtpNegotiationCommand.cc
index fd369370..16237fe0 100644
--- a/src/FtpNegotiationCommand.cc
+++ b/src/FtpNegotiationCommand.cc
@@ -75,9 +75,7 @@
#include "error_code.h"
#include "SocketRecvBuffer.h"
#include "NullProgressInfoFile.h"
-#ifdef ENABLE_MESSAGE_DIGEST
-# include "ChecksumCheckIntegrityEntry.h"
-#endif // ENABLE_MESSAGE_DIGEST
+#include "ChecksumCheckIntegrityEntry.h"
namespace aria2 {
@@ -386,7 +384,6 @@ bool FtpNegotiationCommand::onFileSizeDetermined(int64_t totalLength)
if(getDownloadContext()->knowsTotalLength() &&
getRequestGroup()->downloadFinishedByFileLength()) {
-#ifdef ENABLE_MESSAGE_DIGEST
// TODO Known issue: if .aria2 file exists, it will not be
// deleted on successful verification, because .aria2 file is
// not loaded. See also
@@ -401,9 +398,8 @@ bool FtpNegotiationCommand::onFileSizeDetermined(int64_t totalLength)
getDownloadEngine()->getCheckIntegrityMan()->pushEntry
(std::move(entry));
sequence_ = SEQ_EXIT;
- } else
-#endif // ENABLE_MESSAGE_DIGEST
- {
+ }
+ else {
getPieceStorage()->markAllPiecesDone();
getDownloadContext()->setChecksumVerified(true);
sequence_ = SEQ_DOWNLOAD_ALREADY_COMPLETED;
@@ -423,7 +419,6 @@ bool FtpNegotiationCommand::onFileSizeDetermined(int64_t totalLength)
if(getDownloadContext()->knowsTotalLength()) {
A2_LOG_DEBUG("File length becomes zero and it means download completed.");
-#ifdef ENABLE_MESSAGE_DIGEST
// TODO Known issue: if .aria2 file exists, it will not be
// deleted on successful verification, because .aria2 file is
// not loaded. See also
@@ -437,7 +432,6 @@ bool FtpNegotiationCommand::onFileSizeDetermined(int64_t totalLength)
(std::move(entry));
sequence_ = SEQ_EXIT;
} else
-#endif // ENABLE_MESSAGE_DIGEST
{
sequence_ = SEQ_DOWNLOAD_ALREADY_COMPLETED;
getPieceStorage()->markAllPiecesDone();
diff --git a/src/GrowSegment.cc b/src/GrowSegment.cc
index bb5d1e54..433813df 100644
--- a/src/GrowSegment.cc
+++ b/src/GrowSegment.cc
@@ -50,15 +50,11 @@ void GrowSegment::updateWrittenLength(int32_t bytes)
piece_->setAllBlock();
}
-#ifdef ENABLE_MESSAGE_DIGEST
-
std::string GrowSegment::getDigest()
{
return A2STR::NIL;
}
-#endif // ENABLE_MESSAGE_DIGEST
-
void GrowSegment::clear(WrDiskCache* diskCache)
{
writtenLength_ = 0;
diff --git a/src/GrowSegment.h b/src/GrowSegment.h
index 8ca96af7..70aed4c0 100644
--- a/src/GrowSegment.h
+++ b/src/GrowSegment.h
@@ -85,8 +85,6 @@ public:
virtual void updateWrittenLength(int32_t bytes) CXX11_OVERRIDE;
-#ifdef ENABLE_MESSAGE_DIGEST
-
virtual bool updateHash
(int32_t begin,
const unsigned char* data,
@@ -102,8 +100,6 @@ public:
virtual std::string getDigest() CXX11_OVERRIDE;
-#endif // ENABLE_MESSAGE_DIGEST
-
virtual void clear(WrDiskCache* diskCache) CXX11_OVERRIDE;
virtual std::shared_ptr<Piece> getPiece() const CXX11_OVERRIDE;
diff --git a/src/HttpResponse.cc b/src/HttpResponse.cc
index dae61dc3..c4168b3e 100644
--- a/src/HttpResponse.cc
+++ b/src/HttpResponse.cc
@@ -59,9 +59,7 @@
#include "MetalinkHttpEntry.h"
#include "base64.h"
#include "array_fun.h"
-#ifdef ENABLE_MESSAGE_DIGEST
#include "MessageDigest.h"
-#endif // ENABLE_MESSAGE_DIGEST
#ifdef HAVE_ZLIB
# include "GZipDecodingStreamFilter.h"
#endif // HAVE_ZLIB
@@ -395,7 +393,6 @@ void HttpResponse::getMetalinKHttpEntries(
std::sort(result.begin(), result.end());
}
-#ifdef ENABLE_MESSAGE_DIGEST
// Digest header field is defined by
// http://tools.ietf.org/html/rfc3230.
void HttpResponse::getDigest(std::vector<Checksum>& result) const
@@ -445,6 +442,5 @@ void HttpResponse::getDigest(std::vector<Checksum>& result) const
}
std::swap(temp, result);
}
-#endif // ENABLE_MESSAGE_DIGEST
} // namespace aria2
diff --git a/src/HttpResponse.h b/src/HttpResponse.h
index fabb6f7d..2e7b964a 100644
--- a/src/HttpResponse.h
+++ b/src/HttpResponse.h
@@ -125,13 +125,11 @@ public:
void getMetalinKHttpEntries(std::vector<MetalinkHttpEntry>& result,
const std::shared_ptr<Option>& option) const;
-#ifdef ENABLE_MESSAGE_DIGEST
// Returns all digests specified in Digest header field. Sort
// strong algorithm first. Strength is defined in MessageDigest. If
// several same digest algorithms are available, but they have
// different value, they are all ignored.
void getDigest(std::vector<Checksum>& result) const;
-#endif // ENABLE_MESSAGE_DIGEST
};
diff --git a/src/HttpResponseCommand.cc b/src/HttpResponseCommand.cc
index d6dbd7a9..7c44991a 100644
--- a/src/HttpResponseCommand.cc
+++ b/src/HttpResponseCommand.cc
@@ -75,10 +75,8 @@
#include "SocketRecvBuffer.h"
#include "MetalinkHttpEntry.h"
#include "NullProgressInfoFile.h"
-#ifdef ENABLE_MESSAGE_DIGEST
-# include "Checksum.h"
-# include "ChecksumCheckIntegrityEntry.h"
-#endif // ENABLE_MESSAGE_DIGEST
+#include "Checksum.h"
+#include "ChecksumCheckIntegrityEntry.h"
#ifdef HAVE_ZLIB
# include "GZipDecodingStreamFilter.h"
#endif // HAVE_ZLIB
@@ -210,7 +208,6 @@ bool HttpResponseCommand::executeInternal()
}
}
-#ifdef ENABLE_MESSAGE_DIGEST
if (httpHeader->defined(HttpHeader::DIGEST)) {
std::vector<Checksum> checksums;
httpResponse->getDigest(checksums);
@@ -228,7 +225,6 @@ bool HttpResponseCommand::executeInternal()
}
}
}
-#endif // ENABLE_MESSAGE_DIGEST
}
if(statusCode >= 300) {
@@ -280,7 +276,6 @@ bool HttpResponseCommand::executeInternal()
return handleDefaultEncoding(std::move(httpResponse));
}
-#ifdef ENABLE_MESSAGE_DIGEST
if (!ctx->getHashType().empty() && httpHeader->defined(HttpHeader::DIGEST)) {
std::vector<Checksum> checksums;
httpResponse->getDigest(checksums);
@@ -290,7 +285,6 @@ bool HttpResponseCommand::executeInternal()
}
}
}
-#endif // ENABLE_MESSAGE_DIGEST
// validate totalsize
grp->validateTotalLength(fe->getLength(), httpResponse->getEntityLength());
@@ -424,7 +418,6 @@ bool HttpResponseCommand::handleOtherEncoding(
getRequestGroup()->downloadFinishedByFileLength()) {
getRequestGroup()->initPieceStorage();
-#ifdef ENABLE_MESSAGE_DIGEST
// TODO Known issue: if .aria2 file exists, it will not be deleted
// on successful verification, because .aria2 file is not loaded.
// See also FtpNegotiationCommand::onFileSizeDetermined()
@@ -434,9 +427,8 @@ bool HttpResponseCommand::handleOtherEncoding(
entry->initValidator();
getPieceStorage()->getDiskAdaptor()->openExistingFile();
getDownloadEngine()->getCheckIntegrityMan()->pushEntry(std::move(entry));
- } else
-#endif // ENABLE_MESSAGE_DIGEST
- {
+ }
+ else {
getPieceStorage()->markAllPiecesDone();
getDownloadContext()->setChecksumVerified(true);
A2_LOG_NOTICE(fmt(MSG_DOWNLOAD_ALREADY_COMPLETED,
@@ -459,14 +451,12 @@ bool HttpResponseCommand::handleOtherEncoding(
// TODO Known issue: if .aria2 file exists, it will not be deleted
// on successful verification, because .aria2 file is not loaded.
// See also FtpNegotiationCommand::onFileSizeDetermined()
-#ifdef ENABLE_MESSAGE_DIGEST
if (getDownloadContext()->isChecksumVerificationNeeded()) {
A2_LOG_DEBUG("Verify checksum for zero-length file");
auto entry = make_unique<ChecksumCheckIntegrityEntry>(getRequestGroup());
entry->initValidator();
getDownloadEngine()->getCheckIntegrityMan()->pushEntry(std::move(entry));
} else
-#endif // ENABLE_MESSAGE_DIGEST
{
getRequestGroup()->getPieceStorage()->markAllPiecesDone();
}
@@ -572,7 +562,6 @@ void HttpResponseCommand::onDryRunFileFound()
poolConnection();
}
-#ifdef ENABLE_MESSAGE_DIGEST
bool HttpResponseCommand::checkChecksum(
const std::shared_ptr<DownloadContext>& dctx, const Checksum& checksum)
{
@@ -586,6 +575,5 @@ bool HttpResponseCommand::checkChecksum(
return false;
}
-#endif // ENABLE_MESSAGE_DIGEST
} // namespace aria2
diff --git a/src/HttpResponseCommand.h b/src/HttpResponseCommand.h
index bd66eae1..7cb367e1 100644
--- a/src/HttpResponseCommand.h
+++ b/src/HttpResponseCommand.h
@@ -45,9 +45,7 @@ class HttpDownloadCommand;
class HttpResponse;
class SocketCore;
class StreamFilter;
-#ifdef ENABLE_MESSAGE_DIGEST
class Checksum;
-#endif // ENABLE_MESSAGE_DIGEST
// HttpResponseCommand receives HTTP response header from remote
// server. Because network I/O is non-blocking, execute() returns
@@ -76,13 +74,11 @@ private:
void poolConnection();
void onDryRunFileFound();
-#ifdef ENABLE_MESSAGE_DIGEST
// Returns true if dctx and checksum has same hash type and hash
// value. If they have same hash type but different hash value,
// throws exception. Otherwise returns false.
bool checkChecksum(const std::shared_ptr<DownloadContext>& dctx,
const Checksum& checksum);
-#endif // ENABLE_MESSAGE_DIGEST
protected:
bool executeInternal() CXX11_OVERRIDE;
diff --git a/src/HttpServerCommand.cc b/src/HttpServerCommand.cc
index 096b3d1f..4a4d6d61 100644
--- a/src/HttpServerCommand.cc
+++ b/src/HttpServerCommand.cc
@@ -51,10 +51,8 @@
#include "fmt.h"
#include "SocketRecvBuffer.h"
#include "base64.h"
-#ifdef ENABLE_MESSAGE_DIGEST
-# include "MessageDigest.h"
-# include "message_digest_helper.h"
-#endif // ENABLE_MESSAGE_DIGEST
+#include "MessageDigest.h"
+#include "message_digest_helper.h"
#ifdef ENABLE_WEBSOCKET
# include "WebSocketResponseCommand.h"
#endif // ENABLE_WEBSOCKET
diff --git a/src/Makefile.am b/src/Makefile.am
index 0daa5c01..4046715a 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -251,7 +251,18 @@ SRCS = option_processing.cc\
HttpProxyRequestConnectChain.h\
FtpNegotiationConnectChain.h\
FtpTunnelRequestConnectChain.h\
- Lock.h
+ Lock.h \
+ IteratableChunkChecksumValidator.cc IteratableChunkChecksumValidator.h\
+ IteratableChecksumValidator.cc IteratableChecksumValidator.h\
+ CheckIntegrityDispatcherCommand.cc CheckIntegrityDispatcherCommand.h\
+ CheckIntegrityCommand.cc CheckIntegrityCommand.h\
+ ChecksumCheckIntegrityEntry.cc ChecksumCheckIntegrityEntry.h\
+ message_digest_helper.cc message_digest_helper.h\
+ Checksum.cc Checksum.h\
+ ChunkChecksum.cc ChunkChecksum.h\
+ MessageDigest.cc MessageDigest.h\
+ MessageDigestImpl.h\
+ HashFuncEntry.h
if ANDROID
SRCS += android/android.c
@@ -403,20 +414,6 @@ SRCS += AsyncNameResolver.cc AsyncNameResolver.h\
AsyncNameResolverMan.cc AsyncNameResolverMan.h
endif # ENABLE_ASYNC_DNS
-if ENABLE_MESSAGE_DIGEST
-SRCS += IteratableChunkChecksumValidator.cc IteratableChunkChecksumValidator.h\
- IteratableChecksumValidator.cc IteratableChecksumValidator.h\
- CheckIntegrityDispatcherCommand.cc CheckIntegrityDispatcherCommand.h\
- CheckIntegrityCommand.cc CheckIntegrityCommand.h\
- ChecksumCheckIntegrityEntry.cc ChecksumCheckIntegrityEntry.h\
- message_digest_helper.cc message_digest_helper.h\
- Checksum.cc Checksum.h\
- ChunkChecksum.cc ChunkChecksum.h\
- MessageDigest.cc MessageDigest.h\
- MessageDigestImpl.h\
- HashFuncEntry.h
-endif # ENABLE_MESSAGE_DIGEST
-
if ENABLE_BITTORRENT
SRCS += PeerAbstractCommand.cc PeerAbstractCommand.h\
PeerInitiateConnectionCommand.cc PeerInitiateConnectionCommand.h\
diff --git a/src/Metalink2RequestGroup.cc b/src/Metalink2RequestGroup.cc
index 5daa6bdc..6463aae6 100644
--- a/src/Metalink2RequestGroup.cc
+++ b/src/Metalink2RequestGroup.cc
@@ -64,10 +64,8 @@
# include "BtDependency.h"
# include "download_helper.h"
#endif // ENABLE_BITTORRENT
-#ifdef ENABLE_MESSAGE_DIGEST
-# include "Checksum.h"
-# include "ChunkChecksum.h"
-#endif // ENABLE_MESSAGE_DIGEST
+#include "Checksum.h"
+#include "ChunkChecksum.h"
namespace aria2 {
@@ -255,15 +253,11 @@ Metalink2RequestGroup::createRequestGroup
// If piece hash is specified in the metalink,
// make segment size equal to piece hash size.
int32_t pieceLength;
-#ifdef ENABLE_MESSAGE_DIGEST
if(!entry->chunkChecksum) {
pieceLength = option->getAsInt(PREF_PIECE_LENGTH);
} else {
pieceLength = entry->chunkChecksum->getPieceLength();
}
-#else
- pieceLength = option->getAsInt(PREF_PIECE_LENGTH);
-#endif // ENABLE_MESSAGE_DIGEST
dctx = std::make_shared<DownloadContext>
(pieceLength,
entry->getLength(),
@@ -274,7 +268,6 @@ Metalink2RequestGroup::createRequestGroup
if(option->getAsBool(PREF_METALINK_ENABLE_UNIQUE_PROTOCOL)) {
dctx->getFirstFileEntry()->setUniqueProtocol(true);
}
-#ifdef ENABLE_MESSAGE_DIGEST
if(entry->checksum) {
dctx->setDigest(entry->checksum->getHashType(),
entry->checksum->getDigest());
@@ -285,7 +278,6 @@ Metalink2RequestGroup::createRequestGroup
std::begin(entry->chunkChecksum->getPieceHashes()),
std::end(entry->chunkChecksum->getPieceHashes()));
}
-#endif // ENABLE_MESSAGE_DIGEST
dctx->setSignature(entry->popSignature());
rg->setNumConcurrentCommand
(entry->maxConnections < 0 ?
diff --git a/src/MetalinkEntry.cc b/src/MetalinkEntry.cc
index 8decf8c2..6961a910 100644
--- a/src/MetalinkEntry.cc
+++ b/src/MetalinkEntry.cc
@@ -41,10 +41,8 @@
#include "FileEntry.h"
#include "util.h"
#include "a2functional.h"
-#ifdef ENABLE_MESSAGE_DIGEST
-# include "Checksum.h"
-# include "ChunkChecksum.h"
-#endif // ENABLE_MESSAGE_DIGEST
+#include "Checksum.h"
+#include "ChunkChecksum.h"
#include "Signature.h"
#include "SimpleRandomizer.h"
diff --git a/src/MetalinkEntry.h b/src/MetalinkEntry.h
index 8884ee7f..699dda88 100644
--- a/src/MetalinkEntry.h
+++ b/src/MetalinkEntry.h
@@ -46,10 +46,8 @@ namespace aria2 {
class MetalinkResource;
class MetalinkMetaurl;
class FileEntry;
-#ifdef ENABLE_MESSAGE_DIGEST
class Checksum;
class ChunkChecksum;
-#endif // ENABLE_MESSAGE_DIGEST
class Signature;
class MetalinkEntry {
@@ -63,10 +61,9 @@ public:
std::vector<std::unique_ptr<MetalinkResource>> resources;
std::vector<std::unique_ptr<MetalinkMetaurl>> metaurls;
int maxConnections; // Metalink3Spec
-#ifdef ENABLE_MESSAGE_DIGEST
std::unique_ptr<Checksum> checksum;
std::unique_ptr<ChunkChecksum> chunkChecksum;
-#endif // ENABLE_MESSAGE_DIGEST
+
private:
std::unique_ptr<Signature> signature_;
public:
diff --git a/src/MetalinkParserController.cc b/src/MetalinkParserController.cc
index e3fbd598..91ce7053 100644
--- a/src/MetalinkParserController.cc
+++ b/src/MetalinkParserController.cc
@@ -46,11 +46,9 @@
#include "uri.h"
#include "Signature.h"
#include "util.h"
-#ifdef ENABLE_MESSAGE_DIGEST
-# include "Checksum.h"
-# include "ChunkChecksum.h"
-# include "MessageDigest.h"
-#endif // ENABLE_MESSAGE_DIGEST
+#include "Checksum.h"
+#include "ChunkChecksum.h"
+#include "MessageDigest.h"
#ifdef ENABLE_BITTORRENT
# include "magnet.h"
#endif // ENABLE_BITTORRENT
@@ -78,11 +76,9 @@ void MetalinkParserController::newEntryTransaction()
tEntry_ = make_unique<MetalinkEntry>();
tResource_.reset();
tMetaurl_.reset();
-#ifdef ENABLE_MESSAGE_DIGEST
tChecksum_.reset();
tChunkChecksumV4_.reset();
tChunkChecksum_.reset();
-#endif // ENABLE_MESSAGE_DIGEST
}
void MetalinkParserController::setFileNameOfEntry(std::string filename)
@@ -263,17 +259,14 @@ void MetalinkParserController::cancelResourceTransaction()
void MetalinkParserController::newChecksumTransaction()
{
-#ifdef ENABLE_MESSAGE_DIGEST
if(!tEntry_) {
return;
}
tChecksum_ = make_unique<Checksum>();
-#endif // ENABLE_MESSAGE_DIGEST
}
void MetalinkParserController::setTypeOfChecksum(std::string type)
{
-#ifdef ENABLE_MESSAGE_DIGEST
if(!tChecksum_) {
return;
}
@@ -283,12 +276,10 @@ void MetalinkParserController::setTypeOfChecksum(std::string type)
} else {
cancelChecksumTransaction();
}
-#endif // ENABLE_MESSAGE_DIGEST
}
void MetalinkParserController::setHashOfChecksum(std::string md)
{
-#ifdef ENABLE_MESSAGE_DIGEST
if(!tChecksum_) {
return;
}
@@ -297,12 +288,10 @@ void MetalinkParserController::setHashOfChecksum(std::string md)
} else {
cancelChecksumTransaction();
}
-#endif // ENABLE_MESSAGE_DIGEST
}
void MetalinkParserController::commitChecksumTransaction()
{
-#ifdef ENABLE_MESSAGE_DIGEST
if(!tChecksum_) {
return;
}
@@ -312,30 +301,24 @@ void MetalinkParserController::commitChecksumTransaction()
tEntry_->checksum = std::move(tChecksum_);
}
tChecksum_.reset();
-#endif // ENABLE_MESSAGE_DIGEST
}
void MetalinkParserController::cancelChecksumTransaction()
{
-#ifdef ENABLE_MESSAGE_DIGEST
tChecksum_.reset();
-#endif // ENABLE_MESSAGE_DIGEST
}
void MetalinkParserController::newChunkChecksumTransactionV4()
{
-#ifdef ENABLE_MESSAGE_DIGEST
if(!tEntry_) {
return;
}
tChunkChecksumV4_ = make_unique<ChunkChecksum>();
tempChunkChecksumsV4_.clear();
-#endif // ENABLE_MESSAGE_DIGEST
}
void MetalinkParserController::setTypeOfChunkChecksumV4(std::string type)
{
-#ifdef ENABLE_MESSAGE_DIGEST
if(!tChunkChecksumV4_) {
return;
}
@@ -345,12 +328,10 @@ void MetalinkParserController::setTypeOfChunkChecksumV4(std::string type)
} else {
cancelChunkChecksumTransactionV4();
}
-#endif // ENABLE_MESSAGE_DIGEST
}
void MetalinkParserController::setLengthOfChunkChecksumV4(size_t length)
{
-#ifdef ENABLE_MESSAGE_DIGEST
if(!tChunkChecksumV4_) {
return;
}
@@ -359,12 +340,10 @@ void MetalinkParserController::setLengthOfChunkChecksumV4(size_t length)
} else {
cancelChunkChecksumTransactionV4();
}
-#endif // ENABLE_MESSAGE_DIGEST
}
void MetalinkParserController::addHashOfChunkChecksumV4(std::string md)
{
-#ifdef ENABLE_MESSAGE_DIGEST
if(!tChunkChecksumV4_) {
return;
}
@@ -373,12 +352,10 @@ void MetalinkParserController::addHashOfChunkChecksumV4(std::string md)
} else {
cancelChunkChecksumTransactionV4();
}
-#endif // ENABLE_MESSAGE_DIGEST
}
void MetalinkParserController::commitChunkChecksumTransactionV4()
{
-#ifdef ENABLE_MESSAGE_DIGEST
if(!tChunkChecksumV4_) {
return;
}
@@ -389,30 +366,24 @@ void MetalinkParserController::commitChunkChecksumTransactionV4()
tEntry_->chunkChecksum = std::move(tChunkChecksumV4_);
}
tChunkChecksumV4_.reset();
-#endif // ENABLE_MESSAGE_DIGEST
}
void MetalinkParserController::cancelChunkChecksumTransactionV4()
{
-#ifdef ENABLE_MESSAGE_DIGEST
tChunkChecksumV4_.reset();
-#endif // ENABLE_MESSAGE_DIGEST
}
void MetalinkParserController::newChunkChecksumTransaction()
{
-#ifdef ENABLE_MESSAGE_DIGEST
if(!tEntry_) {
return;
}
tChunkChecksum_ = make_unique<ChunkChecksum>();
tempChunkChecksums_.clear();
-#endif // ENABLE_MESSAGE_DIGEST
}
void MetalinkParserController::setTypeOfChunkChecksum(std::string type)
{
-#ifdef ENABLE_MESSAGE_DIGEST
if(!tChunkChecksum_) {
return;
}
@@ -422,12 +393,10 @@ void MetalinkParserController::setTypeOfChunkChecksum(std::string type)
} else {
cancelChunkChecksumTransaction();
}
-#endif // ENABLE_MESSAGE_DIGEST
}
void MetalinkParserController::setLengthOfChunkChecksum(size_t length)
{
-#ifdef ENABLE_MESSAGE_DIGEST
if(!tChunkChecksum_) {
return;
}
@@ -436,13 +405,11 @@ void MetalinkParserController::setLengthOfChunkChecksum(size_t length)
} else {
cancelChunkChecksumTransaction();
}
-#endif // ENABLE_MESSAGE_DIGEST
}
void MetalinkParserController::addHashOfChunkChecksum(size_t order,
std::string md)
{
-#ifdef ENABLE_MESSAGE_DIGEST
if(!tChunkChecksum_) {
return;
}
@@ -451,22 +418,18 @@ void MetalinkParserController::addHashOfChunkChecksum(size_t order,
} else {
cancelChunkChecksumTransaction();
}
-#endif // ENABLE_MESSAGE_DIGEST
}
void MetalinkParserController::createNewHashOfChunkChecksum(size_t order)
{
-#ifdef ENABLE_MESSAGE_DIGEST
if(!tChunkChecksum_) {
return;
}
tempHashPair_.first = order;
-#endif // ENABLE_MESSAGE_DIGEST
}
void MetalinkParserController::setMessageDigestOfChunkChecksum(std::string md)
{
-#ifdef ENABLE_MESSAGE_DIGEST
if(!tChunkChecksum_) {
return;
}
@@ -475,22 +438,18 @@ void MetalinkParserController::setMessageDigestOfChunkChecksum(std::string md)
} else {
cancelChunkChecksumTransaction();
}
-#endif // ENABLE_MESSAGE_DIGEST
}
void MetalinkParserController::addHashOfChunkChecksum()
{
-#ifdef ENABLE_MESSAGE_DIGEST
if(!tChunkChecksum_) {
return;
}
tempChunkChecksums_.push_back(tempHashPair_);
-#endif // ENABLE_MESSAGE_DIGEST
}
void MetalinkParserController::commitChunkChecksumTransaction()
{
-#ifdef ENABLE_MESSAGE_DIGEST
if(!tChunkChecksum_) {
return;
}
@@ -508,14 +467,11 @@ void MetalinkParserController::commitChunkChecksumTransaction()
tEntry_->chunkChecksum = std::move(tChunkChecksum_);
}
tChunkChecksum_.reset();
-#endif // ENABLE_MESSAGE_DIGEST
}
void MetalinkParserController::cancelChunkChecksumTransaction()
{
-#ifdef ENABLE_MESSAGE_DIGEST
tChunkChecksum_.reset();
-#endif // ENABLE_MESSAGE_DIGEST
}
void MetalinkParserController::newSignatureTransaction()
diff --git a/src/MetalinkParserController.h b/src/MetalinkParserController.h
index 4ff11fff..61e204b4 100644
--- a/src/MetalinkParserController.h
+++ b/src/MetalinkParserController.h
@@ -50,10 +50,8 @@ class MetalinkResource;
class MetalinkMetaurl;
class Signature;
-#ifdef ENABLE_MESSAGE_DIGEST
class Checksum;
class ChunkChecksum;
-#endif // ENABLE_MESSAGE_DIGEST
class MetalinkParserController {
private:
@@ -64,7 +62,7 @@ private:
std::unique_ptr<MetalinkResource> tResource_;
std::unique_ptr<MetalinkMetaurl> tMetaurl_;
-#ifdef ENABLE_MESSAGE_DIGEST
+
std::unique_ptr<Checksum> tChecksum_;
std::unique_ptr<ChunkChecksum> tChunkChecksumV4_; // Metalink4Spec
@@ -77,8 +75,6 @@ private:
std::pair<size_t, std::string> tempHashPair_; // Metalink3Spec
-#endif // ENABLE_MESSAGE_DIGEST
-
std::unique_ptr<Signature> tSignature_;
std::string baseUri_;
public:
diff --git a/src/MetalinkParserStateV3Impl.cc b/src/MetalinkParserStateV3Impl.cc
index 5b658999..056fe579 100644
--- a/src/MetalinkParserStateV3Impl.cc
+++ b/src/MetalinkParserStateV3Impl.cc
@@ -194,7 +194,6 @@ void VerificationMetalinkParserState::beginElement
if(!checkNsUri(nsUri)) {
psm->setSkipTagState();
} else
-#ifdef ENABLE_MESSAGE_DIGEST
if(strcmp(localname, "hash") == 0) {
psm->setHashState();
auto itr = findAttr(attrs, "type", METALINK3_NAMESPACE_URI);
@@ -231,7 +230,6 @@ void VerificationMetalinkParserState::beginElement
psm->setLengthOfChunkChecksum(length);
psm->setTypeOfChunkChecksum(type);
} else
-#endif // ENABLE_MESSAGE_DIGEST
if(strcmp(localname, "signature") == 0) {
psm->setSignatureState();
auto itr = findAttr(attrs, "type", METALINK3_NAMESPACE_URI);
diff --git a/src/MetalinkParserStateV4Impl.cc b/src/MetalinkParserStateV4Impl.cc
index a10e5d88..ee9edf88 100644
--- a/src/MetalinkParserStateV4Impl.cc
+++ b/src/MetalinkParserStateV4Impl.cc
@@ -166,7 +166,6 @@ void FileMetalinkParserStateV4::beginElement
psm->setLocationOfResource(location);
psm->setPriorityOfResource(priority);
}
-#ifdef ENABLE_MESSAGE_DIGEST
else if(strcmp(localname, "hash") == 0) {
psm->setHashStateV4();
auto itr = findAttr(attrs, "type", METALINK4_NAMESPACE_URI);
@@ -203,7 +202,6 @@ void FileMetalinkParserStateV4::beginElement
psm->setLengthOfChunkChecksumV4(length);
psm->setTypeOfChunkChecksumV4(type);
}
-#endif // ENABLE_MESSAGE_DIGEST
else if(strcmp(localname, "signature") == 0) {
psm->setSignatureStateV4();
auto itr = findAttr(attrs, "mediatype", METALINK4_NAMESPACE_URI);
diff --git a/src/OptionHandlerFactory.cc b/src/OptionHandlerFactory.cc
index 9d24a243..7ef8a325 100644
--- a/src/OptionHandlerFactory.cc
+++ b/src/OptionHandlerFactory.cc
@@ -140,7 +140,6 @@ std::vector<OptionHandler*> OptionHandlerFactory::createOptionHandlers()
op->addTag(TAG_ADVANCED);
handlers.push_back(op);
}
-#ifdef ENABLE_MESSAGE_DIGEST
{
OptionHandler* op(new BooleanOptionHandler
(PREF_CHECK_INTEGRITY,
@@ -158,7 +157,6 @@ std::vector<OptionHandler*> OptionHandlerFactory::createOptionHandlers()
op->setChangeOptionForReserved(true);
handlers.push_back(op);
}
-#endif // ENABLE_MESSAGE_DIGEST
{
OptionHandler* op(new BooleanOptionHandler
(PREF_CONDITIONAL_GET,
@@ -426,7 +424,6 @@ std::vector<OptionHandler*> OptionHandlerFactory::createOptionHandlers()
op->setInitialOption(true);
handlers.push_back(op);
}
-#ifdef ENABLE_MESSAGE_DIGEST
{
OptionHandler* op(new BooleanOptionHandler
(PREF_HASH_CHECK_ONLY,
@@ -443,7 +440,6 @@ std::vector<OptionHandler*> OptionHandlerFactory::createOptionHandlers()
op->setChangeOptionForReserved(true);
handlers.push_back(op);
}
-#endif // ENABLE_MESSAGE_DIGEST
{
OptionHandler* op(new BooleanOptionHandler
(PREF_HUMAN_READABLE,
@@ -693,7 +689,6 @@ std::vector<OptionHandler*> OptionHandlerFactory::createOptionHandlers()
op->addTag(TAG_ADVANCED);
handlers.push_back(op);
}
-#ifdef ENABLE_MESSAGE_DIGEST
{
OptionHandler* op(new BooleanOptionHandler
(PREF_REALTIME_CHUNK_CHECKSUM,
@@ -707,7 +702,6 @@ std::vector<OptionHandler*> OptionHandlerFactory::createOptionHandlers()
op->setChangeOptionForReserved(true);
handlers.push_back(op);
}
-#endif // ENABLE_MESSAGE_DIGEST
{
OptionHandler* op(new BooleanOptionHandler
(PREF_REMOVE_CONTROL_FILE,
@@ -914,7 +908,6 @@ std::vector<OptionHandler*> OptionHandlerFactory::createOptionHandlers()
handlers.push_back(op);
}
// HTTP/FTP options
-#ifdef ENABLE_MESSAGE_DIGEST
{
OptionHandler* op(new ChecksumOptionHandler
(PREF_CHECKSUM,
@@ -926,7 +919,6 @@ std::vector<OptionHandler*> OptionHandlerFactory::createOptionHandlers()
op->setChangeOptionForReserved(true);
handlers.push_back(op);
}
-#endif // ENABLE_MESSAGE_DIGEST
{
OptionHandler* op(new NumberOptionHandler
(PREF_CONNECT_TIMEOUT,
diff --git a/src/OptionHandlerImpl.cc b/src/OptionHandlerImpl.cc
index 970ebfe4..0fb39758 100644
--- a/src/OptionHandlerImpl.cc
+++ b/src/OptionHandlerImpl.cc
@@ -61,9 +61,7 @@
#include "SegList.h"
#include "array_fun.h"
#include "help_tags.h"
-#ifdef ENABLE_MESSAGE_DIGEST
-# include "MessageDigest.h"
-#endif // ENABLE_MESSAGE_DIGEST
+#include "MessageDigest.h"
namespace aria2 {
@@ -368,7 +366,6 @@ std::string IndexOutOptionHandler::createPossibleValuesString() const
return "INDEX=PATH";
}
-#ifdef ENABLE_MESSAGE_DIGEST
ChecksumOptionHandler::ChecksumOptionHandler
(PrefPtr pref,
const char* description,
@@ -397,7 +394,6 @@ std::string ChecksumOptionHandler::createPossibleValuesString() const
{
return "HASH_TYPE=HEX_DIGEST";
}
-#endif // ENABLE_MESSAGE_DIGEST
ParameterOptionHandler::ParameterOptionHandler
(PrefPtr pref,
diff --git a/src/OptionHandlerImpl.h b/src/OptionHandlerImpl.h
index a4ef2a71..7753a96b 100644
--- a/src/OptionHandlerImpl.h
+++ b/src/OptionHandlerImpl.h
@@ -172,7 +172,6 @@ public:
virtual std::string createPossibleValuesString() const CXX11_OVERRIDE;
};
-#ifdef ENABLE_MESSAGE_DIGEST
class ChecksumOptionHandler : public AbstractOptionHandler {
public:
ChecksumOptionHandler(PrefPtr pref,
@@ -183,7 +182,6 @@ public:
CXX11_OVERRIDE;
virtual std::string createPossibleValuesString() const CXX11_OVERRIDE;
};
-#endif // ENABLE_MESSAGE_DIGEST
class ParameterOptionHandler : public AbstractOptionHandler {
private:
diff --git a/src/Piece.cc b/src/Piece.cc
index 668e2131..55b5a64b 100644
--- a/src/Piece.cc
+++ b/src/Piece.cc
@@ -46,9 +46,7 @@
#include "LogFactory.h"
#include "fmt.h"
#include "DiskAdaptor.h"
-#ifdef ENABLE_MESSAGE_DIGEST
-# include "MessageDigest.h"
-#endif // ENABLE_MESSAGE_DIGEST
+#include "MessageDigest.h"
namespace aria2 {
@@ -58,9 +56,7 @@ Piece::Piece()
index_(0),
length_(0),
blockLength_(BLOCK_LENGTH),
-#ifdef ENABLE_MESSAGE_DIGEST
nextBegin_(0),
-#endif // ENABLE_MESSAGE_DIGEST
usedBySegment_(false)
{}
@@ -70,9 +66,7 @@ Piece::Piece(size_t index, int32_t length, int32_t blockLength)
index_(index),
length_(length),
blockLength_(blockLength),
-#ifdef ENABLE_MESSAGE_DIGEST
- nextBegin_(0),
-#endif // ENABLE_MESSAGE_DIGEST
+ nextBegin_(0),
usedBySegment_(false)
{}
@@ -208,8 +202,6 @@ int32_t Piece::getCompletedLength()
return bitfield_->getCompletedLength();
}
-#ifdef ENABLE_MESSAGE_DIGEST
-
void Piece::setHashType(const std::string& hashType)
{
hashType_ = hashType;
@@ -304,8 +296,6 @@ void Piece::destroyHashContext()
nextBegin_ = 0;
}
-#endif // ENABLE_MESSAGE_DIGEST
-
bool Piece::usedBy(cuid_t cuid) const
{
return std::find(users_.begin(), users_.end(), cuid) != users_.end();
diff --git a/src/Piece.h b/src/Piece.h
index 40c62693..2389c3ac 100644
--- a/src/Piece.h
+++ b/src/Piece.h
@@ -50,32 +50,21 @@ class BitfieldMan;
class WrDiskCache;
class WrDiskCacheEntry;
class DiskAdaptor;
-
-#ifdef ENABLE_MESSAGE_DIGEST
-
class MessageDigest;
-#endif // ENABLE_MESSAGE_DIGEST
-
class Piece {
private:
BitfieldMan* bitfield_;
WrDiskCacheEntry* wrCache_;
-#ifdef ENABLE_MESSAGE_DIGEST
std::unique_ptr<MessageDigest> mdctx_;
-#endif // ENABLE_MESSAGE_DIGEST
std::vector<cuid_t> users_;
-#ifdef ENABLE_MESSAGE_DIGEST
std::string hashType_;
-#endif // ENABLE_MESSAGE_DIGEST
size_t index_;
int32_t length_;
int32_t blockLength_;
-#ifdef ENABLE_MESSAGE_DIGEST
int32_t nextBegin_;
-#endif // ENABLE_MESSAGE_DIGEST
bool usedBySegment_;
@@ -158,8 +147,6 @@ public:
// Calculates completed length
int32_t getCompletedLength();
-#ifdef ENABLE_MESSAGE_DIGEST
-
void setHashType(const std::string& hashType);
// Updates hash value. This function compares begin and private variable
@@ -181,8 +168,6 @@ public:
// cached data and data on disk.
std::string getDigestWithWrCache(size_t pieceLength,
const std::shared_ptr<DiskAdaptor>& adaptor);
-#endif // ENABLE_MESSAGE_DIGEST
-
/**
* Loses current bitfield state.
*/
diff --git a/src/PieceHashCheckIntegrityEntry.cc b/src/PieceHashCheckIntegrityEntry.cc
index 1356fc11..2935876e 100644
--- a/src/PieceHashCheckIntegrityEntry.cc
+++ b/src/PieceHashCheckIntegrityEntry.cc
@@ -58,13 +58,11 @@ bool PieceHashCheckIntegrityEntry::isValidationReady()
void PieceHashCheckIntegrityEntry::initValidator()
{
-#ifdef ENABLE_MESSAGE_DIGEST
auto validator = make_unique<IteratableChunkChecksumValidator>
(getRequestGroup()->getDownloadContext(),
getRequestGroup()->getPieceStorage());
validator->init();
setValidator(std::move(validator));
-#endif // ENABLE_MESSAGE_DIGEST
}
} // namespace aria2
diff --git a/src/PiecedSegment.cc b/src/PiecedSegment.cc
index e1ebcdde..819e8d70 100644
--- a/src/PiecedSegment.cc
+++ b/src/PiecedSegment.cc
@@ -90,8 +90,6 @@ void PiecedSegment::updateWrittenLength(int32_t bytes)
writtenLength_ = newWrittenLength;
}
-#ifdef ENABLE_MESSAGE_DIGEST
-
bool PiecedSegment::updateHash
(int32_t begin,
const unsigned char* data,
@@ -110,18 +108,12 @@ std::string PiecedSegment::getDigest()
return piece_->getDigest();
}
-#endif // ENABLE_MESSAGE_DIGEST
-
void PiecedSegment::clear(WrDiskCache* diskCache)
{
writtenLength_ = 0;
piece_->clearAllBlock(diskCache);
-#ifdef ENABLE_MESSAGE_DIGEST
-
piece_->destroyHashContext();
-
-#endif // ENABLE_MESSAGE_DIGEST
}
std::shared_ptr<Piece> PiecedSegment::getPiece() const
diff --git a/src/PiecedSegment.h b/src/PiecedSegment.h
index 375ef3a0..30270f7b 100644
--- a/src/PiecedSegment.h
+++ b/src/PiecedSegment.h
@@ -76,8 +76,6 @@ public:
virtual void updateWrittenLength(int32_t bytes) CXX11_OVERRIDE;
-#ifdef ENABLE_MESSAGE_DIGEST
-
// `begin' is a offset inside this segment.
virtual bool updateHash
(int32_t begin,
@@ -88,8 +86,6 @@ public:
virtual std::string getDigest() CXX11_OVERRIDE;
-#endif // ENABLE_MESSAGE_DIGEST
-
virtual void clear(WrDiskCache* diskCache) CXX11_OVERRIDE;
virtual std::shared_ptr<Piece> getPiece() const CXX11_OVERRIDE;
diff --git a/src/RequestGroup.cc b/src/RequestGroup.cc
index 2b3e1410..d0035212 100644
--- a/src/RequestGroup.cc
+++ b/src/RequestGroup.cc
@@ -79,10 +79,8 @@
#include "Segment.h"
#include "SocketRecvBuffer.h"
#include "RequestGroupCriteria.h"
-#ifdef ENABLE_MESSAGE_DIGEST
-# include "CheckIntegrityCommand.h"
-# include "ChecksumCheckIntegrityEntry.h"
-#endif // ENABLE_MESSAGE_DIGEST
+#include "CheckIntegrityCommand.h"
+#include "ChecksumCheckIntegrityEntry.h"
#ifdef ENABLE_BITTORRENT
# include "bittorrent_helper.h"
# include "BtRegistry.h"
@@ -240,14 +238,12 @@ std::unique_ptr<CheckIntegrityEntry> RequestGroup::createCheckIntegrityEntry()
// issue checksum verification and download fails without it.
loadAndOpenFile(infoFile);
if(downloadFinished()) {
-#ifdef ENABLE_MESSAGE_DIGEST
if(downloadContext_->isChecksumVerificationNeeded()) {
A2_LOG_INFO(MSG_HASH_CHECK_NOT_DONE);
auto tempEntry = make_unique<ChecksumCheckIntegrityEntry>(this);
tempEntry->setRedownload(true);
return std::move(tempEntry);
}
-#endif // ENABLE_MESSAGE_DIGEST
downloadContext_->setChecksumVerified(true);
A2_LOG_NOTICE(fmt(MSG_DOWNLOAD_ALREADY_COMPLETED,
gid_->toHex().c_str(),
@@ -257,7 +253,6 @@ std::unique_ptr<CheckIntegrityEntry> RequestGroup::createCheckIntegrityEntry()
return make_unique<StreamCheckIntegrityEntry>(this);
}
-#ifdef ENABLE_MESSAGE_DIGEST
if (downloadFinishedByFileLength() &&
downloadContext_->isChecksumVerificationAvailable()) {
pieceStorage_->markAllPiecesDone();
@@ -266,7 +261,6 @@ std::unique_ptr<CheckIntegrityEntry> RequestGroup::createCheckIntegrityEntry()
tempEntry->setRedownload(true);
return std::move(tempEntry);
}
-#endif // ENABLE_MESSAGE_DIGEST
loadAndOpenFile(infoFile);
return make_unique<StreamCheckIntegrityEntry>(this);
@@ -520,7 +514,6 @@ void RequestGroup::processCheckIntegrityEntry(
if(actualFileSize > downloadContext_->getTotalLength()) {
entry->cutTrailingGarbage();
}
-#ifdef ENABLE_MESSAGE_DIGEST
if((option_->getAsBool(PREF_CHECK_INTEGRITY) ||
downloadContext_->isChecksumVerificationNeeded()) &&
entry->isValidationReady()) {
@@ -535,7 +528,6 @@ void RequestGroup::processCheckIntegrityEntry(
e->getCheckIntegrityMan()->pushEntry(std::move(entry));
return;
}
-#endif // ENABLE_MESSAGE_DIGEST
entry->onDownloadIncomplete(commands, e);
}
@@ -664,16 +656,12 @@ void RequestGroup::adjustFilename(
outfile.size() <= downloadContext_->getTotalLength()) {
// File exists but user decided to resume it.
}
-#ifdef ENABLE_MESSAGE_DIGEST
else if(outfile.exists() && isCheckIntegrityReady()) {
// check-integrity existing file
}
-#endif // ENABLE_MESSAGE_DIGEST
else {
shouldCancelDownloadForSafety();
-#ifdef ENABLE_MESSAGE_DIGEST
}
-#endif // ENABLE_MESSAGE_DIGEST
}
void RequestGroup::removeDefunctControlFile(
@@ -709,11 +697,9 @@ void RequestGroup::loadAndOpenFile(
pieceStorage_->getDiskAdaptor()->openExistingFile();
pieceStorage_->markPiecesDone(outfile.size());
}
-#ifdef ENABLE_MESSAGE_DIGEST
else if (outfile.exists() && isCheckIntegrityReady()) {
pieceStorage_->getDiskAdaptor()->openExistingFile();
}
-#endif // ENABLE_MESSAGE_DIGEST
else {
pieceStorage_->getDiskAdaptor()->initAndOpenFile();
}
diff --git a/src/RpcMethodImpl.cc b/src/RpcMethodImpl.cc
index c920a4aa..0ecf9f3e 100644
--- a/src/RpcMethodImpl.cc
+++ b/src/RpcMethodImpl.cc
@@ -66,10 +66,8 @@
#include "base64.h"
#include "BitfieldMan.h"
#include "SessionSerializer.h"
-#ifdef ENABLE_MESSAGE_DIGEST
-# include "MessageDigest.h"
-# include "message_digest_helper.h"
-#endif // ENABLE_MESSAGE_DIGEST
+#include "MessageDigest.h"
+#include "message_digest_helper.h"
#ifdef ENABLE_BITTORRENT
# include "bittorrent_helper.h"
# include "BtRegistry.h"
@@ -254,7 +252,6 @@ std::unique_ptr<ValueBase> AddUriRpcMethod::process
}
}
-#ifdef ENABLE_MESSAGE_DIGEST
namespace {
std::string getHexSha1(const std::string& s)
{
@@ -264,7 +261,6 @@ std::string getHexSha1(const std::string& s)
return util::toHex(hash, sizeof(hash));
}
} // namespace
-#endif // ENABLE_MESSAGE_DIGEST
#ifdef ENABLE_BITTORRENT
std::unique_ptr<ValueBase> AddTorrentRpcMethod::process
@@ -341,7 +337,6 @@ std::unique_ptr<ValueBase> AddMetalinkRpcMethod::process
size_t pos = posGiven ? posParam->i() : 0;
std::vector<std::shared_ptr<RequestGroup>> result;
-#ifdef ENABLE_MESSAGE_DIGEST
std::string filename;
if(requestOption->getAsBool(PREF_RPC_SAVE_UPLOAD_METADATA)) {
// TODO RFC5854 Metalink has the extension .meta4 and Metalink
@@ -365,9 +360,6 @@ std::unique_ptr<ValueBase> AddMetalinkRpcMethod::process
} else {
createRequestGroupForMetalink(result, requestOption, metalinkParam->s());
}
-#else // !ENABLE_MESSAGE_DIGEST
- createRequestGroupForMetalink(result, requestOption, metalinkParam->s());
-#endif // !ENABLE_MESSAGE_DIGEST
auto gids = List::g();
if(!result.empty()) {
if(posGiven) {
diff --git a/src/Segment.h b/src/Segment.h
index dd17826c..ad9355ea 100644
--- a/src/Segment.h
+++ b/src/Segment.h
@@ -66,8 +66,6 @@ public:
virtual void updateWrittenLength(int32_t bytes) = 0;
-#ifdef ENABLE_MESSAGE_DIGEST
-
// `begin' is a offset inside this segment.
virtual bool updateHash
(int32_t begin,
@@ -78,8 +76,6 @@ public:
virtual std::string getDigest() = 0;
-#endif // ENABLE_MESSAGE_DIGEST
-
virtual void clear(WrDiskCache* diskCache) = 0;
virtual std::shared_ptr<Piece> getPiece() const = 0;
diff --git a/src/SinkStreamFilter.cc b/src/SinkStreamFilter.cc
index 88420cfc..28ea7fe0 100644
--- a/src/SinkStreamFilter.cc
+++ b/src/SinkStreamFilter.cc
@@ -88,11 +88,9 @@ ssize_t SinkStreamFilter::transform
} else {
out->writeData(inbuf, wlen, segment->getPositionToWrite());
}
-#ifdef ENABLE_MESSAGE_DIGEST
if(hashUpdate_) {
segment->updateHash(segment->getWrittenLength(), inbuf, wlen);
}
-#endif // ENABLE_MESSAGE_DIGEST
segment->updateWrittenLength(wlen);
} else {
wlen = 0;
diff --git a/src/download_helper.cc b/src/download_helper.cc
index fc23682f..931ab505 100644
--- a/src/download_helper.cc
+++ b/src/download_helper.cc
@@ -143,7 +143,6 @@ std::shared_ptr<RequestGroup> createRequestGroup
dctx->getFirstFileEntry()->setUris(uris);
dctx->getFirstFileEntry()->setMaxConnectionPerServer
(option->getAsInt(PREF_MAX_CONNECTION_PER_SERVER));
-#ifdef ENABLE_MESSAGE_DIGEST
const std::string& checksum = option->get(PREF_CHECKSUM);
if(!checksum.empty()) {
auto p = util::divide(std::begin(checksum), std::end(checksum), '=');
@@ -153,7 +152,6 @@ std::shared_ptr<RequestGroup> createRequestGroup
dctx->setDigest(hashType,
util::fromHex(std::begin(hexDigest), std::end(hexDigest)));
}
-#endif // ENABLE_MESSAGE_DIGEST
rg->setDownloadContext(dctx);
rg->setPauseRequested(option->getAsBool(PREF_PAUSE));
removeOneshotOption(option);
diff --git a/src/util.cc b/src/util.cc
index 3d9e8548..7e7932ab 100644
--- a/src/util.cc
+++ b/src/util.cc
@@ -85,10 +85,8 @@
#include "SocketCore.h"
#include "Lock.h"
-#ifdef ENABLE_MESSAGE_DIGEST
-# include "MessageDigest.h"
-# include "message_digest_helper.h"
-#endif // ENABLE_MESSAGE_DIGEST
+#include "MessageDigest.h"
+#include "message_digest_helper.h"
// For libc6 which doesn't define ULLONG_MAX properly because of broken limits.h
#ifndef ULLONG_MAX
@@ -1641,14 +1639,10 @@ std::string fixTaintedBasename(const std::string& src)
void generateRandomKey(unsigned char* key)
{
-#ifdef ENABLE_MESSAGE_DIGEST
unsigned char bytes[40];
generateRandomData(bytes, sizeof(bytes));
message_digest::digest(key, 20, MessageDigest::sha1().get(), bytes,
sizeof(bytes));
-#else // !ENABLE_MESSAGE_DIGEST
- generateRandomData(key, 20);
-#endif // !ENABLE_MESSAGE_DIGEST
}
// Returns true is given numeric ipv4addr is in Private Address Space.
diff --git a/src/version_usage.cc b/src/version_usage.cc
index 49f55658..6d9fc3f7 100644
--- a/src/version_usage.cc
+++ b/src/version_usage.cc
@@ -40,9 +40,7 @@
#include "a2io.h"
#include "FeatureConfig.h"
-#ifdef ENABLE_MESSAGE_DIGEST
-# include "MessageDigest.h"
-#endif // ENABLE_MESSAGE_DIGEST
+#include "MessageDigest.h"
#include "help_tags.h"
#include "prefs.h"
#include "fmt.h"
@@ -70,10 +68,8 @@ void showVersion() {
<< _("** Configuration **") << "\n"
<< _("Enabled Features") << ": "
<< featureSummary() << "\n"
-#ifdef ENABLE_MESSAGE_DIGEST
<< _("Hash Algorithms") << ": "
<< MessageDigest::getSupportedHashTypeString() << "\n"
-#endif // ENABLE_MESSAGE_DIGEST
<< _("Libraries") << ": "
<< usedLibs() << "\n"
<< "\n"