diff options
| author | Richard Nyberg <rnyberg@murmeldjur.se> | 2006-09-12 15:12:34 +0000 |
|---|---|---|
| committer | Richard Nyberg <rnyberg@murmeldjur.se> | 2006-09-12 15:12:34 +0000 |
| commit | cd0eb82f20b4b0186207b8f5653b83dde83ca03c (patch) | |
| tree | 6bca76b9777c7e2dbd3018d4397e468bce72c0ff /misc/metainfo.h | |
| parent | fc20273a800fa62dfd801018761c30716ced920c (diff) | |
| download | btpd-cd0eb82f20b4b0186207b8f5653b83dde83ca03c.tar.gz btpd-cd0eb82f20b4b0186207b8f5653b83dde83ca03c.zip | |
The metainfo code provided a load -> test -> struct metainfo interface.
The metainfo struct has been replaced by functions for qeurying specific items from the torrent. In addition, the tests of the torrent data has been improved.
Diffstat (limited to 'misc/metainfo.h')
| -rw-r--r-- | misc/metainfo.h | 43 |
1 files changed, 26 insertions, 17 deletions
diff --git a/misc/metainfo.h b/misc/metainfo.h index 242bab3..ab5b0cf 100644 --- a/misc/metainfo.h +++ b/misc/metainfo.h @@ -1,28 +1,37 @@ #ifndef BTPD_METAINFO_H #define BTPD_METAINFO_H -struct fileinfo { +struct mi_file { char *path; off_t length; }; -struct metainfo { - char *name; - char *announce; - uint8_t info_hash[20]; - uint8_t (*piece_hash)[20]; - unsigned pieces_off; - uint32_t npieces; - off_t piece_length; - off_t total_length; - unsigned nfiles; - struct fileinfo *files; +struct mi_tier { + int nurls; + char **urls; }; -int fill_fileinfo(const char *fdct, struct fileinfo *fip); -int fill_metainfo(const char *base, struct metainfo *mip, int mem_hashes); -void clear_metainfo(struct metainfo *mip); -void print_metainfo(struct metainfo *mip); -int load_metainfo(const char *path, off_t size, int mem_hashes, struct metainfo **res); +struct mi_announce { + int ntiers; + struct mi_tier *tiers; +}; + +char *mi_name(const char *p); +uint8_t *mi_info_hash(const char *p, uint8_t *hash); +uint8_t *mi_hashes(const char *p); +int mi_simple(const char *p); +size_t mi_npieces(const char *p); +off_t mi_total_length(const char *p); +off_t mi_piece_length(const char *p); + +struct mi_announce *mi_announce(const char *p); +void mi_free_announce(struct mi_announce *ann); + +size_t mi_nfiles(const char *p); +struct mi_file *mi_files(const char *p); +void mi_free_files(unsigned nfiles, struct mi_file *files); + +int mi_test(const char *p, size_t size); +char *mi_load(const char *path, size_t *size); #endif |