Commit | Line | Data |
---|---|---|
d3372da9 | 1 | #ifndef _CONDUIT_H |
2 | #define _CONDUIT_H | |
3 | ||
4 | #include <sys/types.h> | |
e03797e4 | 5 | #include <stdint.h> |
d3372da9 | 6 | |
7 | #define CNDS_IDLE 0 | |
8 | #define CNDS_SYN 1 | |
9 | #define CNDS_EST 2 | |
10 | ||
11 | struct transfer | |
12 | { | |
13 | struct transfer *next, *prev; | |
14 | struct conduit *conduit; | |
15 | char *tag; /* UTF8 */ | |
e03797e4 | 16 | intmax_t pos, size; |
d3372da9 | 17 | time_t cmptime, ckptime; |
e03797e4 | 18 | intmax_t cmpsize, ckpsize; |
d3372da9 | 19 | int timeout; |
20 | }; | |
21 | ||
22 | struct conduit | |
23 | { | |
24 | struct transfer *transfers; | |
25 | struct conduitiface *iface; | |
26 | void *cdata, *udata; | |
27 | int state; | |
28 | }; | |
29 | ||
30 | struct conduitiface | |
31 | { | |
32 | int (*init)(struct conduit *conduit); | |
33 | int (*connect)(struct conduit *conduit); | |
34 | void (*destroy)(struct conduit *conduit); | |
6431aca0 | 35 | int (*cancel)(struct conduit *conduit, struct transfer *transfer); |
d3372da9 | 36 | }; |
37 | ||
38 | struct transfer *findtransferbytag(struct conduit *conduit, char *tag); | |
e03797e4 FT |
39 | void transfersetsize(struct transfer *transfer, intmax_t size); |
40 | void transfersetpos(struct transfer *transfer, intmax_t pos); | |
e45d1d8a | 41 | struct transfer *newtransfer(struct conduit *conduit, char *tag, intmax_t size, intmax_t pos); |
d3372da9 | 42 | void freetransfer(struct transfer *transfer); |
43 | struct conduit *newconduit(struct conduitiface *iface, void *udata); | |
44 | void freeconduit(struct conduit *conduit); | |
45 | int condtryconn(struct conduit *conduit); | |
46 | void conddisconn(struct conduit *conduit); | |
47 | void condconnected(struct conduit *conduit); | |
48 | ||
49 | extern void (*cb_condstate)(struct conduit *conduit, void *data); | |
50 | extern void (*cb_trsize)(struct transfer *transfer, void *data); | |
51 | extern void (*cb_trpos)(struct transfer *transfer, void *data); | |
52 | extern void (*cb_trnew)(struct transfer *transfer, void *data); | |
53 | extern void (*cb_trfree)(struct transfer *transfer, void *data); | |
54 | extern struct conduitiface *conduit_pipe; | |
55 | extern struct conduitiface *conduit_dclib; | |
56 | ||
57 | #endif |