about summary refs log tree commit diff
path: root/cli/btpd_if.h
blob: 8c35cc7871c1c3bd40a00509689f2f4bf12da9ec (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
38
39
40
41
42
43
44
#ifndef BTPD_IF_H
#define BTPD_IF_H

struct ipc;

enum torrent_state { //XXX: Same as in btpd/torrent.h
    T_STARTING,
    T_ACTIVE,
    T_STOPPING
};

enum ipc_code {
    IPC_OK,
    IPC_FAIL,
    IPC_ERROR,
    IPC_COMMERR
};

struct btstat {
    unsigned ntorrents;
    struct tpstat {
        char *name;
        enum torrent_state state;

        unsigned errors;
        unsigned npeers;
        uint32_t npieces, nseen;
        off_t have, total;
        long long downloaded, uploaded;
        unsigned long rate_up, rate_down;
    } torrents[];
};

int ipc_open(const char *dir, struct ipc **out);
int ipc_close(struct ipc *ipc);

enum ipc_code btpd_add(struct ipc *ipc, const uint8_t *hash,
    const char *torrent, const char *content);
enum ipc_code btpd_del(struct ipc *ipc, const uint8_t *hash);
enum ipc_code btpd_die(struct ipc *ipc, int seconds);
enum ipc_code btpd_stat(struct ipc *ipc, struct btstat **out);
void free_btstat(struct btstat *stat);

#endif