summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>2007-07-08 03:22:37 +0000
committerTatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>2007-07-08 03:22:37 +0000
commit444bf5495d80244c7185c25e619a904d74426208 (patch)
tree38cd17c3cbce983771e19eed3d17368f3fb7dd1d /src
parent823056f0dd16c03c097a2a44bb6b950b28ef43fb (diff)
2007-07-08 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
* src/main.cc (showUsage): Added 3 usage examples for metalink download. Replace MetalinkChunkChecksum with ChunkChecksum. * src/MetalinkChunkChecksum.h: Removed. * src/MetalinkEntry.h: MetalinkChunkChecksum -> ChunkChecksum. * src/Xml2MetalinkProcessor.h: MetalinkChunkChecksum -> ChunkChecksum. * src/Xml2MetalinkProcessor.cc (getPieceHash): Use ChunkChecksum instead of MetalinkChunkChecksum. * src/MetalinkRequestInfo.cc (execute)
Diffstat (limited to 'src')
-rw-r--r--src/Makefile.am1
-rw-r--r--src/Makefile.in1
-rw-r--r--src/MetalinkChunkChecksum.h56
-rw-r--r--src/MetalinkEntry.h6
-rw-r--r--src/MetalinkRequestInfo.cc6
-rw-r--r--src/Xml2MetalinkProcessor.cc29
-rw-r--r--src/Xml2MetalinkProcessor.h4
7 files changed, 21 insertions, 82 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index 77246d84..f1a5c3fe 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -224,7 +224,6 @@ SRCS += Metalinker.cc Metalinker.h\
MetalinkProcessor.h\
Xml2MetalinkProcessor.cc Xml2MetalinkProcessor.h\
MetalinkRequestInfo.cc MetalinkRequestInfo.h
-# MetalinkChunkChecksum.h
endif # ENABLE_METALINK
noinst_LIBRARIES = libaria2c.a
diff --git a/src/Makefile.in b/src/Makefile.in
index 4775683b..b9190ff3 100644
--- a/src/Makefile.in
+++ b/src/Makefile.in
@@ -670,7 +670,6 @@ SRCS = Socket.h SocketCore.cc SocketCore.h Command.cc Command.h \
CookieBoxFactory.h HttpHeaderProcessor.cc \
HttpHeaderProcessor.h FileEntry.cc FileEntry.h $(am__append_1) \
$(am__append_2) $(am__append_3)
-# MetalinkChunkChecksum.h
noinst_LIBRARIES = libaria2c.a
libaria2c_a_SOURCES = $(SRCS)
aria2c_LDADD = libaria2c.a @LIBINTL@ @ALLOCA@ @LIBGNUTLS_LIBS@\
diff --git a/src/MetalinkChunkChecksum.h b/src/MetalinkChunkChecksum.h
deleted file mode 100644
index 547ec164..00000000
--- a/src/MetalinkChunkChecksum.h
+++ /dev/null
@@ -1,56 +0,0 @@
-/* <!-- copyright */
-/*
- * aria2 - The high speed download utility
- *
- * Copyright (C) 2006 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
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- *
- * In addition, as a special exception, the copyright holders give
- * permission to link the code of portions of this program with the
- * OpenSSL library under certain conditions as described in each
- * individual source file, and distribute linked combinations
- * including the two.
- * You must obey the GNU General Public License in all respects
- * for all of the code used other than OpenSSL. If you modify
- * file(s) with this exception, you may extend this exception to your
- * version of the file(s), but you are not obligated to do so. If you
- * do not wish to do so, delete this exception statement from your
- * version. If you delete this exception statement from all source
- * files in the program, then also delete it here.
- */
-/* copyright --> */
-#ifndef _D_METALINK_CHUNK_CHECKSUM_H_
-#define _D_METALINK_CHUNK_CHECKSUM_H_
-
-#include "common.h"
-#ifdef ENABLE_MESSAGE_DIGEST
-#include "messageDigest.h"
-#endif // ENABLE_MESSAGE_DIGEST
-
-class MetalinkChunkChecksum {
-#ifdef ENABLE_MESSAGE_DIGEST
-public:
- MessageDigestContext::DigestAlgo digestAlgo;
- int32_t pieceLength;
- Strings pieceHashes;
-public:
- MetalinkChunkChecksum():pieceLength(0) {}
-#endif // ENABLE_MESSAGE_DIGEST
-};
-
-typedef SharedHandle<MetalinkChunkChecksum> MetalinkChunkChecksumHandle;
-
-#endif // _D_METALINK_CHUNK_CHECKSUM_H_
diff --git a/src/MetalinkEntry.h b/src/MetalinkEntry.h
index 37b966f7..dd68720b 100644
--- a/src/MetalinkEntry.h
+++ b/src/MetalinkEntry.h
@@ -38,8 +38,10 @@
#include "common.h"
#include "MetalinkResource.h"
#include "Checksum.h"
-#include "MetalinkChunkChecksum.h"
#include "FileEntry.h"
+#ifdef ENABLE_MESSAGE_DIGEST
+#include "ChunkChecksum.h"
+#endif // ENABLE_MESSAGE_DIGEST
#include <deque>
class MetalinkEntry;
@@ -57,7 +59,7 @@ public:
public:
MetalinkResources resources;
#ifdef ENABLE_MESSAGE_DIGEST
- MetalinkChunkChecksumHandle chunkChecksum;
+ ChunkChecksumHandle chunkChecksum;
#endif // ENABLE_MESSAGE_DIGEST
public:
MetalinkEntry();
diff --git a/src/MetalinkRequestInfo.cc b/src/MetalinkRequestInfo.cc
index 3081fb27..740d4e03 100644
--- a/src/MetalinkRequestInfo.cc
+++ b/src/MetalinkRequestInfo.cc
@@ -152,11 +152,7 @@ RequestInfos MetalinkRequestInfo::execute() {
if(entry->chunkChecksum.isNull()) {
rg->setChecksum(checksum);
} else {
- ChunkChecksumHandle cc =
- new ChunkChecksum(entry->chunkChecksum->digestAlgo,
- entry->chunkChecksum->pieceHashes,
- entry->chunkChecksum->pieceLength);
- rg->setChunkChecksum(cc);
+ rg->setChunkChecksum(entry->chunkChecksum);
}
#endif // ENABLE_MESSAGE_DIGEST
groups.push_front(rg);
diff --git a/src/Xml2MetalinkProcessor.cc b/src/Xml2MetalinkProcessor.cc
index 7c754056..793d8656 100644
--- a/src/Xml2MetalinkProcessor.cc
+++ b/src/Xml2MetalinkProcessor.cc
@@ -146,40 +146,39 @@ MetalinkEntryHandle Xml2MetalinkProcessor::getEntry(const string& xpath) {
}
#ifdef ENABLE_MESSAGE_DIGEST
-MetalinkChunkChecksumHandle Xml2MetalinkProcessor::getPieceHash(const string& xpath,
+ChunkChecksumHandle Xml2MetalinkProcessor::getPieceHash(const string& xpath,
int64_t totalSize)
{
- MetalinkChunkChecksumHandle chunkChecksum = new MetalinkChunkChecksum();
-
xmlXPathObjectPtr result = xpathEvaluation(xpath);
if(!result) {
return 0;
}
xmlNodeSetPtr nodeSet = result->nodesetval;
xmlNodePtr node = nodeSet->nodeTab[0];
- chunkChecksum->pieceLength = STRTOLL(Util::trim(xmlAttribute(node, "length")).c_str());
- string algo = Util::trim(xmlAttribute(node, "type"));
+
+ int64_t checksumLength = STRTOLL(Util::trim(xmlAttribute(node, "length")).c_str());
+ string algoString = Util::trim(xmlAttribute(node, "type"));
xmlXPathFreeObject(result);
- if(algo == "sha1") {
- chunkChecksum->digestAlgo = DIGEST_ALGO_SHA1;
- } else if(algo == "md5") {
- chunkChecksum->digestAlgo = DIGEST_ALGO_MD5;
+ MessageDigestContext::DigestAlgo algo;
+ if(algoString == "sha1") {
+ algo = DIGEST_ALGO_SHA1;
+ } else if(algoString == "md5") {
+ algo = DIGEST_ALGO_MD5;
} else {
// unknown checksum type
- chunkChecksum->pieceLength = 0;
- return chunkChecksum;
+ return 0;
}
- int64_t numPiece =
- (totalSize+chunkChecksum->pieceLength-1)/chunkChecksum->pieceLength;
+ Strings checksums;
+ int64_t numPiece = (totalSize+checksumLength-1)/checksumLength;
for(int64_t i = 0; i < numPiece; ++i) {
string pieceHash = Util::trim(xpathContent(xpath+"/m:hash[@piece=\""+Util::ullitos(i)+"\"]"));
if(pieceHash == "") {
throw new DlAbortEx("Piece hash missing. index=%d", i);
}
- chunkChecksum->pieceHashes.push_back(pieceHash);
+ checksums.push_back(pieceHash);
}
- return chunkChecksum;
+ return new ChunkChecksum(algo, checksums, checksumLength);
}
#endif // ENABLE_MESSAGE_DIGEST
diff --git a/src/Xml2MetalinkProcessor.h b/src/Xml2MetalinkProcessor.h
index aa855a7f..2d1c9b28 100644
--- a/src/Xml2MetalinkProcessor.h
+++ b/src/Xml2MetalinkProcessor.h
@@ -48,8 +48,8 @@ private:
MetalinkResourceHandle getResource(const string& xpath);
#ifdef ENABLE_MESSAGE_DIGEST
- MetalinkChunkChecksumHandle getPieceHash(const string& xpath,
- int64_t totalSize);
+ ChunkChecksumHandle getPieceHash(const string& xpath,
+ int64_t totalSize);
#endif // ENABLE_MESSAGE_DIGEST
xmlXPathObjectPtr xpathEvaluation(const string& xpath);