I am using libcurl to download binary files, but i want to read the header of these binary files, which are the first couple of bytes. If the headers byte match a condition I want to continue the download, else I don't want to cancel the download.
size_t writeData(void *contents, size_t size,
size_t nmemb, FILE *stream) {
const unsigned char * cPtr;
cPtr = (const unsigned char*)contents;
bool isByte = checkByte(cPtr, nmemb);
if (isByte){
// Continue Download, and write to disk.
size_t written = fwrite(contents, size, nmemb, stream);
return written;
}
else
// Kill Download.
}