14
14
typedef struct torrent_ctx
16
unsigned char btih[20]; /* resulting BTIH hash sum */
18
sha1_ctx sha1_context;
16
unsigned char btih[20]; /* resulting BTIH hash sum */
18
sha1_ctx sha1_context;
20
unsigned long reserved; /* need more space for openssl sha1 context */
21
void *sha_init, *sha_update, *sha_final;
20
unsigned long reserved; /* need more space for openssl sha1 context */
21
void *sha_init, *sha_update, *sha_final;
23
blocks_vector_t blocks_hashes; /* the list of sha1 hashes of pieces */
24
size_t index; /* byte index in the current piece */
25
size_t piece_length; /* length of a torrent file piece */
26
vector_t files; /* names of files in the torrent batch */
27
strbuf_t* torrent; /* content of generated torrent file */
28
char* program_name; /* the name of the program */
29
char* announce; /* announce url */
23
blocks_vector_t blocks_hashes; /* the list of sha1 hashes of pieces */
24
size_t index; /* byte index in the current piece */
25
size_t piece_length; /* length of a torrent file piece */
26
vector_t files; /* names of files in the torrent batch */
27
strbuf_t* torrent; /* content of generated torrent file */
28
char* program_name; /* the name of the program */
29
char* announce; /* announce url */
32
void torrent_init(torrent_ctx *ctx);
33
void torrent_update(torrent_ctx *ctx, const void* msg, size_t size);
34
void torrent_final(torrent_ctx *ctx, unsigned char result[20]);
35
void torrent_cleanup(torrent_ctx *ctx);
32
void rhash_torrent_init(torrent_ctx *ctx);
33
void rhash_torrent_update(torrent_ctx *ctx, const void* msg, size_t size);
34
void rhash_torrent_final(torrent_ctx *ctx, unsigned char result[20]);
35
void rhash_torrent_cleanup(torrent_ctx *ctx);
37
size_t torrent_get_text(torrent_ctx *ctx, char** pstr);
38
unsigned char* torrent_get_btih(torrent_ctx *ctx);
37
size_t rhash_torrent_get_text(torrent_ctx *ctx, char** pstr);
38
unsigned char* rhash_torrent_get_btih(torrent_ctx *ctx);
40
40
/* possible options */
41
41
#define BT_OPT_PRIVATE 1
42
42
#define BT_OPT_INFOHASH_ONLY 2
44
void torrent_set_options(torrent_ctx *ctx, unsigned flags);
45
void torrent_add_file(torrent_ctx *ctx, const char* path, uint64_t filesize);
46
void torrent_set_announce(torrent_ctx *ctx, const char* announce_url);
47
void torrent_set_program_name(torrent_ctx *ctx, const char* name);
48
void torrent_set_piece_length(torrent_ctx *ctx, size_t piece_length);
49
size_t torrent_default_piece_length(uint64_t total_size);
44
void rhash_torrent_set_options(torrent_ctx *ctx, unsigned flags);
45
void rhash_torrent_add_file(torrent_ctx *ctx, const char* path, uint64_t filesize);
46
void rhash_torrent_set_announce(torrent_ctx *ctx, const char* announce_url);
47
void rhash_torrent_set_program_name(torrent_ctx *ctx, const char* name);
48
void rhash_torrent_set_piece_length(torrent_ctx *ctx, size_t piece_length);
49
size_t rhash_torrent_default_piece_length(uint64_t total_size);