Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 650340
Collapse All | Expand All

(-)a/hash.c (-5 / +5 lines)
Lines 24-34 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>       /* read(), close() */
26
#include <unistd.h>       /* read(), close() */
27
#include <inttypes.h>     /* PRId64 etc. */
27
28
28
#ifdef USE_OPENSSL
29
#ifdef USE_OPENSSL
29
#include <openssl/sha.h>  /* SHA1() */
30
#include <openssl/sha.h>  /* SHA1() */
30
#else
31
#else
31
#include <inttypes.h>
32
#include "sha1.h"
32
#include "sha1.h"
33
#endif
33
#endif
34
34
Lines 60-70 EXPORT unsigned char *make_hash(metafile_t *m) Link Here
60
	unsigned char *pos;             /* position in the hash string */
60
	unsigned char *pos;             /* position in the hash string */
61
	unsigned char *read_buf;        /* read buffer */
61
	unsigned char *read_buf;        /* read buffer */
62
	int fd;                         /* file descriptor */
62
	int fd;                         /* file descriptor */
63
	ssize_t r;                      /* number of bytes read from file(s) into
63
	size_t r;                       /* number of bytes read from file(s) into
64
	                                   the read buffer */
64
	                                   the read buffer */
65
	SHA_CTX c;                      /* SHA1 hashing context */
65
	SHA_CTX c;                      /* SHA1 hashing context */
66
#ifndef NO_HASH_CHECK
66
#ifndef NO_HASH_CHECK
67
	off_t counter = 0;              /* number of bytes hashed
67
	int64_t counter = 0;            /* number of bytes hashed
68
	                                   should match size when done */
68
	                                   should match size when done */
69
#endif
69
#endif
70
70
Lines 144-151 EXPORT unsigned char *make_hash(metafile_t *m) Link Here
144
#ifndef NO_HASH_CHECK
144
#ifndef NO_HASH_CHECK
145
	counter += r;
145
	counter += r;
146
	if (counter != m->size) {
146
	if (counter != m->size) {
147
		fprintf(stderr, "Counted %" PRIoff " bytes, "
147
		fprintf(stderr, "Counted %" PRId64 " bytes, "
148
				"but hashed %" PRIoff " bytes. "
148
				"but hashed %" PRId64 " bytes. "
149
				"Something is wrong...\n", m->size, counter);
149
				"Something is wrong...\n", m->size, counter);
150
		exit(EXIT_FAILURE);
150
		exit(EXIT_FAILURE);
151
	}
151
	}
(-)a/hash_pthreads.c (-7 / +8 lines)
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));
(-)a/init.c (-1 / +3 lines)
Lines 21-30 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA Link Here
21
#include <sys/types.h>    /* off_t */
21
#include <sys/types.h>    /* off_t */
22
#include <errno.h>        /* errno */
22
#include <errno.h>        /* errno */
23
#include <string.h>       /* strerror() */
23
#include <string.h>       /* strerror() */
24
#include <stdio.h>        /* printf() etc. */
24
#include <stdio.h>        /* perror(), printf() etc. */
25
#include <sys/stat.h>     /* the stat structure */
25
#include <sys/stat.h>     /* the stat structure */
26
#include <unistd.h>       /* getopt(), getcwd(), sysconf() */
26
#include <unistd.h>       /* getopt(), getcwd(), sysconf() */
27
#include <string.h>       /* strcmp(), strlen(), strncpy() */
27
#include <string.h>       /* strcmp(), strlen(), strncpy() */
28
#include <strings.h>      /* strcasecmp() */
29
#include <inttypes.h>     /* PRId64 etc. */
28
#ifdef USE_LONG_OPTIONS
30
#ifdef USE_LONG_OPTIONS
29
#include <getopt.h>       /* getopt_long() */
31
#include <getopt.h>       /* getopt_long() */
30
#endif
32
#endif
(-)a/main.c (+3 lines)
Lines 28-33 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA Link Here
28
#ifdef ALLINONE
28
#ifdef ALLINONE
29
#include <sys/stat.h>
29
#include <sys/stat.h>
30
#include <unistd.h>      /* access(), read(), close(), getcwd(), sysconf() */
30
#include <unistd.h>      /* access(), read(), close(), getcwd(), sysconf() */
31
#include <strings.h>     /* strcasecmp() */
32
#include <inttypes.h>    /* PRId64 etc. */
33
#include <ctype.h>       /* isdigit */
31
#ifdef USE_LONG_OPTIONS
34
#ifdef USE_LONG_OPTIONS
32
#include <getopt.h>      /* getopt_long() */
35
#include <getopt.h>      /* getopt_long() */
33
#endif
36
#endif
(-)a/mktorrent.h (-2 / +2 lines)
Lines 30-36 struct flist_s; Link Here
30
typedef struct flist_s flist_t;
30
typedef struct flist_s flist_t;
31
struct flist_s {
31
struct flist_s {
32
	char *path;
32
	char *path;
33
	off_t size;
33
	int64_t size;
34
	flist_t *next;
34
	flist_t *next;
35
};
35
};
36
36
Lines 52-58 typedef struct { Link Here
52
#endif
52
#endif
53
53
54
	/* information calculated by read_dir() */
54
	/* information calculated by read_dir() */
55
	off_t size;                /* combined size of all files */
55
	int64_t size;                /* combined size of all files */
56
	flist_t *file_list;        /* list of files and their sizes */
56
	flist_t *file_list;        /* list of files and their sizes */
57
	unsigned int pieces;       /* number of pieces */
57
	unsigned int pieces;       /* number of pieces */
58
} metafile_t;
58
} metafile_t;
(-)a/prefix.c (-7 / +19 lines)
Lines 20-31 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA Link Here
20
#include <stdlib.h>
20
#include <stdlib.h>
21
#include <sys/types.h>
21
#include <sys/types.h>
22
#include <stdio.h>
22
#include <stdio.h>
23
#include <inttypes.h>
23
24
24
#ifndef TYPE
25
#ifndef TYPE
25
#define TYPE off_t
26
#define TYPE off_t
26
#endif
27
#endif
27
28
28
int main(int argc, char *argv[])
29
#if __WORDSIZE == 32 && _FILE_OFFSET_BITS == 64
30
#  define PRIdOFF_T PRId64
31
#else
32
#  define PRIdOFF_T PRIdPTR
33
#endif
34
35
int main()
29
{
36
{
30
	unsigned int i;
37
	unsigned int i;
31
	char *prefix[9];
38
	char *prefix[9];
Lines 45-60 int main(int argc, char *argv[]) Link Here
45
#define str(s) #s
52
#define str(s) #s
46
53
47
#ifdef _LARGEFILE_SOURCE
54
#ifdef _LARGEFILE_SOURCE
48
	printf("_LARGEFILE_SOURCE is set\n");
55
	fprintf(stderr, "_LARGEFILE_SOURCE is set\n");
49
#endif
56
#endif
50
57
51
#ifdef _FILE_OFFSET_BITS
58
#ifdef _FILE_OFFSET_BITS
52
	printf("_FILE_OFFSET_BITS = %lu\n", _FILE_OFFSET_BITS);
59
	fprintf(stderr, "_FILE_OFFSET_BITS = %u\n", _FILE_OFFSET_BITS);
53
#endif
60
#endif
54
61
55
	printf("sizeof(" xstr(TYPE) ") = %lu, %lu bits\n",
62
	fprintf(stderr, "__WORDSIZE is %d\n", __WORDSIZE);
56
			sizeof(TYPE), 8*sizeof(TYPE));
63
	fprintf(stderr, "PRIdOFF_T is " PRIdOFF_T "\n");
57
#endif /* DEBUG */
64
	fprintf(stderr, "sizeof(int) = %u, %u bits\n",
65
		(u_int) sizeof(int), 8 * (u_int) sizeof(int));
66
	fprintf(stderr, "sizeof(long int) = %u, %u bits\n",
67
		(u_int) sizeof(long int), 8 * (u_int) sizeof(long int));
68
	fprintf(stderr, "sizeof(" xstr(TYPE) ") = %u, %u bits\n",
69
		(u_int) sizeof(TYPE), 8 * (u_int) sizeof(TYPE));
70
#endif				/* DEBUG */
58
71
59
	printf("%s\n", prefix[sizeof(TYPE)]);
72
	printf("%s\n", prefix[sizeof(TYPE)]);
60
73
61
- 

Return to bug 650340