From e4f9c67cc94df1e370846b19ddedd4365df7b638 Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Sun, 6 Jul 2008 12:59:19 +0200 Subject: [PATCH] add method to read hash tag --- CollectionReader.cpp | 15 +++++++++++++++ CollectionReader.h | 6 ++++-- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/CollectionReader.cpp b/CollectionReader.cpp index ffbb89c..00427ff 100644 --- a/CollectionReader.cpp +++ b/CollectionReader.cpp @@ -83,6 +83,21 @@ BlobTag* CollectionReader::readBlobTag(bool header) { return blobTag; } +HashTag* CollectionReader::readHashTag() { + if (!ensureBufferCapacity(1)) { + return NULL; + } + uint8_t tagId = 0; + growingBuffer.read(&tagId, 1); + GlobalSettings::isVerbose() && fprintf(stderr, "[%s:%d] read tag id %d.\n", __FILE__, __LINE__, tagId); + if (!ensureBufferCapacity(16)) { + return NULL; + } + char hash[16]; + growingBuffer.read(hash, 16); + return new HashTag(tagId, hash); +} + ED2KLink* CollectionReader::getNextLink() { if (readerInput->isEOF() && !growingBuffer.getRemaining()) { GlobalSettings::isVerbose() && fprintf(stderr, "[%s:%d] readInput EOF reached.\n", __FILE__, __LINE__); diff --git a/CollectionReader.h b/CollectionReader.h index 770c2a8..023b226 100644 --- a/CollectionReader.h +++ b/CollectionReader.h @@ -10,6 +10,7 @@ #include "GrowingBuffer.h" #include "StringTag.h" #include "BlobTag.h" +#include "HashTag.h" class CollectionReader { @@ -25,8 +26,9 @@ private: bool ensureBufferCapacity(size_t byteCount); void readMoreBytes(); - BlobTag* readBlobTag(bool hader); - StringTag* readStringTag(bool header); + BlobTag* readBlobTag(bool header = false); + StringTag* readStringTag(bool header = false); + HashTag* readHashTag(); private: ReaderInput* readerInput; -- 2.7.4