summary refs log tree commit diff
path: root/cli/btpd_if.h
blob: 64cdb4b8c16ff1e1f1b0a92813cf4908bef42e91 (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

#include <sys/types.h>
#include <sys/socket.h>
#include <sys/un.h>

struct ipc;

enum ipc_code {
    IPC_OK,
    IPC_FAIL,
    IPC_COMMERR
};

struct btstat {
    unsigned ntorrents;
    struct tpstat {
        char *name;
        unsigned num;
        char 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_die(struct ipc *ipc, int seconds);
enum ipc_code btpd_stat(struct ipc *ipc, struct btstat **out);

enum ipc_code btpd_del_num(struct ipc *ipc, unsigned num);
enum ipc_code btpd_start_num(struct ipc *ipc, unsigned num);
enum ipc_code btpd_stop_num(struct ipc *ipc, unsigned num);

void free_btstat(struct btstat *stat);

#endif