~ubuntu-branches/ubuntu/trusty/rhash/trusty

« back to all changes in this revision

Viewing changes to librhash/torrent.h

  • Committer: Bazaar Package Importer
  • Author(s): Alexey S Kravchenko
  • Date: 2011-06-15 01:03:34 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20110615010334-ochayini7ut2djvs
Tags: 1.2.6-1
* New upstream release version 1.2.6
 - ABI changed - now librhash0.0 is librhash0
 - OpenSSL support for faster hash calculation if libssl is installed
   (fully optional) for both rhash and librhash0

Show diffs side-by-side

added added

removed removed

Lines of Context:
13
13
 
14
14
typedef struct torrent_ctx
15
15
{
16
 
  unsigned char btih[20]; /* resulting BTIH hash sum */
17
 
  unsigned flags;
18
 
  sha1_ctx sha1_context;
 
16
        unsigned char btih[20]; /* resulting BTIH hash sum */
 
17
        unsigned flags;
 
18
        sha1_ctx sha1_context;
19
19
#ifdef USE_OPENSSL
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;
22
22
#endif
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 */
30
30
} torrent_ctx;
31
31
 
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);
36
36
 
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);
39
39
 
40
40
/* possible options */
41
41
#define BT_OPT_PRIVATE 1
42
42
#define BT_OPT_INFOHASH_ONLY 2
43
43
 
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);
50
50
 
51
51
#ifdef __cplusplus
52
52
} /* extern "C" */