| 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 | int (*cancel)(struct conduit *conduit, struct transfer *transfer); |
| 35 | }; |
| 36 | |
| 37 | struct transfer *findtransferbytag(struct conduit *conduit, char *tag); |
| 38 | void transfersetsize(struct transfer *transfer, int size); |
| 39 | void transfersetpos(struct transfer *transfer, int pos); |
| 40 | struct transfer *newtransfer(struct conduit *conduit, char *tag, int size, int pos); |
| 41 | void freetransfer(struct transfer *transfer); |
| 42 | struct conduit *newconduit(struct conduitiface *iface, void *udata); |
| 43 | void freeconduit(struct conduit *conduit); |
| 44 | int condtryconn(struct conduit *conduit); |
| 45 | void conddisconn(struct conduit *conduit); |
| 46 | void condconnected(struct conduit *conduit); |
| 47 | |
| 48 | extern void (*cb_condstate)(struct conduit *conduit, void *data); |
| 49 | extern void (*cb_trsize)(struct transfer *transfer, void *data); |
| 50 | extern void (*cb_trpos)(struct transfer *transfer, void *data); |
| 51 | extern void (*cb_trnew)(struct transfer *transfer, void *data); |
| 52 | extern void (*cb_trfree)(struct transfer *transfer, void *data); |
| 53 | extern struct conduitiface *conduit_pipe; |
| 54 | extern struct conduitiface *conduit_dclib; |
| 55 | |
| 56 | #endif |