summary refs log tree commit diff
path: root/misc/metainfo.h
blob: ab5b0cf9cb23d7c2cb973aedfaf067b401fe3185 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#ifndef BTPD_METAINFO_H
#define BTPD_METAINFO_H

struct mi_file {
    char *path;
    off_t length;
};

struct mi_tier {
    int nurls;
    char **urls;
};

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