#include <stdlib.h>
#include <string.h>
-#include <stdint.h>
#include "CollectionReader.h"
#include "GlobalSettings.h"
GlobalSettings::isVerbose() && fprintf(stderr, "[%s:%d] readInput EOF reached.\n", __FILE__, __LINE__);
return NULL;
}
- firstLink = false;
}
if (isTextCollection) {
while (!readerInput->isEOF() && !isLineBreakPresent()) {
ED2KLink* ed2kLink = ED2KLink::parseED2KLink(line);
free(line);
return ed2kLink;
- } else {
+ }
+ if (firstLink) {
/* read header */
if (!ensureBufferCapacity(4)) {
return NULL;
GlobalSettings::isVerbose() && fprintf(stderr, "[%s:%d] unknown tag type: %02x.\n", __FILE__, __LINE__, tagType);
}
}
+ fileCollectionCount = 0;
+ if (!ensureBufferCapacity(4)) {
+ return NULL;
+ }
+ growingBuffer.read(&fileCollectionCount, 4);
+ GlobalSettings::isVerbose() && fprintf(stderr, "[%s:%d] will read %d file tags.\n", __FILE__, __LINE__, fileCollectionCount);
+ collectionFileIndex = 0;
+ firstLink = false;
+ }
+ if (collectionFileIndex < fileCollectionCount) {
+ } else {
+ GlobalSettings::isVerbose() && fprintf(stderr, "[%s:%d] reached end of collection.\n", __FILE__, __LINE__);
}
return NULL;
}
}
void CollectionReader::identifyCollectionType() {
- int version;
size_t readBytes;
readBytes = readerInput->read(&version, 4);
} else if (!strncmp("ed2k", (char*) &version, 4)) {
isTextCollection = true;
growingBuffer.write(&version, 4);
+ version = 0;
GlobalSettings::isVerbose() && fprintf(stderr, "[%s:%d] identified text collection\n", __FILE__, __LINE__);
} else {
GlobalSettings::isVerbose() && fprintf(stderr, "[%s:%d] could not identify collection!\n", __FILE__, __LINE__);