1 #ifndef __DCC_H
2 #define __DCC_H
3 
4 #include "modules.h"
5 #include "network.h"
6 
7 #define DCC(dcc) ((DCC_REC *) (dcc))
8 
9 typedef struct CHAT_DCC_REC CHAT_DCC_REC;
10 
11 typedef struct {
12 #include "dcc-rec.h"
13 } DCC_REC;
14 
15 /* fully connected? */
16 #define dcc_is_connected(dcc) \
17         ((dcc)->starttime != 0)
18 
19 /* not connected, we're waiting for other side to connect */
20 #define dcc_is_listening(dcc) \
21         ((dcc)->handle != NULL && (dcc)->starttime == 0)
22 
23 /* not connected, waiting for user to accept it */
24 #define dcc_is_waiting_user(dcc) \
25         ((dcc)->handle == NULL)
26 
27 /* passive DCC */
28 #define dcc_is_passive(dcc) \
29 	((dcc)->pasv_id >= 0)
30 
31 extern GSList *dcc_conns;
32 
33 void dcc_register_type(const char *type);
34 void dcc_unregister_type(const char *type);
35 
36 int dcc_str2type(const char *str);
37 #define dcc_type2str(type) (module_find_id_str("DCC", type))
38 
39 /* Initialize DCC record */
40 void dcc_init_rec(DCC_REC *dcc, IRC_SERVER_REC *server, CHAT_DCC_REC *chat,
41 		  const char *nick, const char *arg);
42 void dcc_destroy(DCC_REC *dcc);
43 
44 /* Find waiting DCC requests (non-connected) */
45 DCC_REC *dcc_find_request_latest(int type);
46 DCC_REC *dcc_find_request(int type, const char *nick, const char *arg);
47 
48 /* IP <-> string for DCC CTCP messages.
49    `str' must be at least MAX_IP_LEN bytes.
50    If /SET dcc_own_ip is set, dcc_ip2str() always returns it. */
51 void dcc_ip2str(IPADDR *ip, char *str);
52 void dcc_str2ip(const char *str, IPADDR *ip);
53 
54 /* Start listening for incoming connections */
55 GIOChannel *dcc_listen(GIOChannel *iface, IPADDR *ip, int *port);
56 /* Connect to specified IP address using the correct own_ip. */
57 GIOChannel *dcc_connect_ip(IPADDR *ip, int port);
58 
59 /* Close DCC - sends "dcc closed" signal and calls dcc_destroy() */
60 void dcc_close(DCC_REC *dcc);
61 /* Reject a DCC request */
62 void dcc_reject(DCC_REC *dcc, IRC_SERVER_REC *server);
63 
64 void dcc_init(void);
65 void dcc_deinit(void);
66 
67 #endif
68