diff options
| author | Tatsuhiro Tsujikawa <tatsuhiro.t@gmail.com> | 2006-07-03 14:19:23 +0000 |
|---|---|---|
| committer | Tatsuhiro Tsujikawa <tatsuhiro.t@gmail.com> | 2006-07-03 14:19:23 +0000 |
| commit | 78eff232546a5fa6f48c151dc2343915ed94fa8c (patch) | |
| tree | 6d30c01c1586f0513ab152de48473dad2746fe5d /src/Metalinker.cc | |
| parent | 003a47435758a976a57c483c37859989105e204e (diff) | |
2006-07-03 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
To add Metalink support(http/ftp only):
* src/AbstractCommand.h
(tryReserved): New function.
* src/AbstractCommand.cc
(execute): Call tryReserved().
(tryReserved): New function.
* src/Request.h
(Requests): New type definition.
* src/SegmentMan.h
(reserved): New variable.
* src/Util.h
(fileChecksum): New function.
(toUpper): New function.
(toLower): New function.
* src/Util.cc
(messageDigest.h): Included.
(trim): Trim \r\n\t.
(fileChecksum): New function.
(toUpper): New function.
(toLower): New function.
* src/main.cc
(normalDownload): New function.
(main): Added 2 command-line options: metalink-file,
metalink-connection. Their usage has not been written yet.
* src/MetalinkProcessor.h: New class.
* src/Xml2MetalinkProcessor.h: New class.
* src/Xml2MetalinkProcessor.cc: New class.
* src/MetalinkEntry.h: New class.
* src/MetalinkEntry.cc: New class.
* src/MetalinkResource.h: New class.
* src/MetalinkResource.cc: New class.
To add md5 message digest checking:
* src/messageDigest.h: Rewritten.
* src/MultiDiskWriter.cc: Updated according to the changes in
messageDigest.h.
* src/ShaVisitor.cc: Updated according to the changes in
messageDigest.h.
* src/Util.cc: Updated according to the changes in
messageDigest.h.
* src/AbstractDiskWriter.cc: Updated according to the changes in
messageDigest.h.
To fix a bug that causes segfault when the payload length in
peer
message is less than 0:
* src/PeerConnection.cc:
(receiveMessage): Fixed the bug.
* src/PeerMessageUtil.cc
(checkLength): Throw an exception if length is less than or
equals to
0.
To add new interfaces to Base64 encoding/decoding:
* src/Base64.h
(part_encode): Changed the method signature.
(encode): New function(overload).
(decode): New function(overload).
* src/Base64.cc
(part_encode): Rewritten.
(encode): Rewritten.
(encode): New function(overload).
To prevent a peer to download same piece if there is an error in
checksum:
* src/PieceMessage.cc
(receivedAction): Call peerInteraction->abortPiece().
Diffstat (limited to 'src/Metalinker.cc')
| -rw-r--r-- | src/Metalinker.cc | 74 |
1 files changed, 74 insertions, 0 deletions
diff --git a/src/Metalinker.cc b/src/Metalinker.cc new file mode 100644 index 00000000..303ce97b --- /dev/null +++ b/src/Metalinker.cc @@ -0,0 +1,74 @@ +/* <!-- copyright */ +/* + * aria2 - a simple utility for downloading files faster + * + * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +/* copyright --> */ +#include "Metalinker.h" +#include <algorithm> + +Metalinker::Metalinker() { +} + +Metalinker::~Metalinker() { + for_each(entries.begin(), entries.end(), Deleter()); +} + +class EntryQuery { +private: + string version; + string language; + string os; +public: + EntryQuery(const string& version, + const string& language, + const string& os):version(version), + language(language), + os(os) {} + bool operator()(const MetalinkEntry* entry) { + if(!version.empty()) { + if(version != entry->version) { + return false; + } + } + if(!language.empty()) { + if(language != entry->language) { + return false; + } + } + if(!os.empty()) { + if(os != entry->os) { + return false; + } + } + return true; + } +}; + +MetalinkEntry* Metalinker::queryEntry(const string& version, + const string& language, + const string& os) const { + MetalinkEntries::const_iterator itr = + find_if(entries.begin(), entries.end(), + EntryQuery(version, language, os)); + if(itr == entries.end()) { + return NULL; + } else { + return *itr; + } +} |
