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