Lines 24-33
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
Link Here
|
24 |
#include <stdio.h> /* printf() etc. */ |
24 |
#include <stdio.h> /* printf() etc. */ |
25 |
#include <fcntl.h> /* open() */ |
25 |
#include <fcntl.h> /* open() */ |
26 |
#include <unistd.h> /* access(), read(), close() */ |
26 |
#include <unistd.h> /* access(), read(), close() */ |
|
|
27 |
#include <inttypes.h> /* PRId64 etc. */ |
28 |
|
27 |
#ifdef USE_OPENSSL |
29 |
#ifdef USE_OPENSSL |
28 |
#include <openssl/sha.h> /* SHA1() */ |
30 |
#include <openssl/sha.h> /* SHA1() */ |
29 |
#else |
31 |
#else |
30 |
#include <inttypes.h> |
|
|
31 |
#include "sha1.h" |
32 |
#include "sha1.h" |
32 |
#endif |
33 |
#endif |
33 |
#include <pthread.h> /* pthread functions and data structures */ |
34 |
#include <pthread.h> /* pthread functions and data structures */ |
Lines 212-222
static void read_files(metafile_t *m, queue_t *q, unsigned char *pos)
Link Here
|
212 |
{ |
213 |
{ |
213 |
int fd; /* file descriptor */ |
214 |
int fd; /* file descriptor */ |
214 |
flist_t *f; /* pointer to a place in the file list */ |
215 |
flist_t *f; /* pointer to a place in the file list */ |
215 |
ssize_t r = 0; /* number of bytes read from file(s) |
216 |
size_t r = 0; /* number of bytes read from file(s) |
216 |
into the read buffer */ |
217 |
into the read buffer */ |
217 |
#ifndef NO_HASH_CHECK |
218 |
#ifndef NO_HASH_CHECK |
218 |
off_t counter = 0; /* number of bytes hashed |
219 |
int64_t counter = 0; /* number of bytes hashed |
219 |
should match size when done */ |
220 |
should match size when done */ |
220 |
#endif |
221 |
#endif |
221 |
piece_t *p = get_free(q, m->piece_length); |
222 |
piece_t *p = get_free(q, m->piece_length); |
222 |
|
223 |
|
Lines 276-283
static void read_files(metafile_t *m, queue_t *q, unsigned char *pos)
Link Here
|
276 |
#ifndef NO_HASH_CHECK |
277 |
#ifndef NO_HASH_CHECK |
277 |
counter += r; |
278 |
counter += r; |
278 |
if (counter != m->size) { |
279 |
if (counter != m->size) { |
279 |
fprintf(stderr, "Counted %" PRIoff " bytes, " |
280 |
fprintf(stderr, "Counted %" PRId64 " bytes, " |
280 |
"but hashed %" PRIoff " bytes. " |
281 |
"but hashed %" PRId64 " bytes. " |
281 |
"Something is wrong...\n", m->size, counter); |
282 |
"Something is wrong...\n", m->size, counter); |
282 |
exit(EXIT_FAILURE); |
283 |
exit(EXIT_FAILURE); |
283 |
} |
284 |
} |
Lines 297-303
EXPORT unsigned char *make_hash(metafile_t *m)
Link Here
|
297 |
pthread_t print_progress_thread; /* progress printer thread */ |
298 |
pthread_t print_progress_thread; /* progress printer thread */ |
298 |
pthread_t *workers; |
299 |
pthread_t *workers; |
299 |
unsigned char *hash_string; /* the hash string */ |
300 |
unsigned char *hash_string; /* the hash string */ |
300 |
unsigned int i; |
301 |
int i; |
301 |
int err; |
302 |
int err; |
302 |
|
303 |
|
303 |
workers = malloc(m->threads * sizeof(pthread_t)); |
304 |
workers = malloc(m->threads * sizeof(pthread_t)); |