Synchronet now requires the libarchive development package (e.g. libarchive-dev on Debian-based Linux distros, libarchive.org for more info) to build successfully.

Commit f4ae099c authored by rswindell's avatar rswindell

New function (fcrc32) to calculate CRC32 of byte range from file stream.

parent 0c80d4c1
......@@ -89,5 +89,18 @@ unsigned long crc32(char *buf, unsigned long len)
return(~crc);
}
unsigned long fcrc32(FILE* fp, unsigned long len)
{
int ch;
unsigned long l,crc=0xffffffff;
rewind(fp);
for(l=0;(len==0 || l<len) && !feof(fp);l++) {
if((ch=fgetc(fp))==EOF)
break;
crc=ucrc32(ch,crc);
}
return(~crc);
}
......@@ -38,6 +38,8 @@
#ifndef _CRC32_H_
#define _CRC32_H_
#include <stdio.h> /* FILE */
#ifdef __cplusplus
extern "C" {
#endif
......@@ -45,6 +47,7 @@ extern "C" {
extern long crc32tbl[];
unsigned long crc32(char* buf, unsigned long len);
unsigned long fcrc32(FILE* fp, unsigned long len);
#ifdef __cplusplus
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment