#include "ED2KLink.h"
#include "GrowingBuffer.h"
#include "GlobalSettings.h"
-#include "GlobalSettings.h"
static int getDigits(size_t number) {
int digits = 0;
memcpy(this->hash, hash, 16);
this->size = size;
- this->link = (char*) calloc(13 + (strlen(filename) + 1) + 1 + getDigits(size) + 1 + 32 + 2, 1);
- sprintf(this->link, "ed2k://|file|%s|%u|", filename, size);
+ link = (char*) calloc(13 + (strlen(filename) + 1) + 1 + getDigits(size) + 1 + 32 + 2, 1);
+ sprintf(link, "ed2k://|file|%s|%u|", filename, size);
for (int i = 0; i < 16; i++) {
- sprintf(this->link + strlen(this->link), "%02x", *((int*) this->hash + i));
+ sprintf(link + strlen(link), "%02x", *((int*) this->hash + i));
}
- sprintf(this->link + strlen(this->link), "|/");
+ sprintf(link + strlen(link), "|/");
+ GlobalSettings::isVerbose() && fprintf(stderr, "[%s:%d] created ed2kLink: %s\n", __FILE__, __LINE__, link);
}
ED2KLink::~ED2KLink() {
}
ED2KLink* ED2KLink::parseED2KLink(const char* buffer) {
- ED2KLink* ed2kLink;
const char* tempBuffer = buffer;
char* filename;
char* sizeString;
sscanf(tempBuffer, "%hhx", hash + hashIndex);
}
- ed2kLink = new ED2KLink(filename, size, hash);
- return ed2kLink;
+ return new ED2KLink(filename, size, hash);
}
const char* ED2KLink::getLink() {