46 |
#define PREFIX_ERROR "=!=" |
#define PREFIX_ERROR "=!=" |
47 |
#define PREFIX_PLUGIN "-P-" |
#define PREFIX_PLUGIN "-P-" |
48 |
|
|
49 |
#define CHANNEL_PREFIX "#&+!" |
#define DEFAULT_IRC_PORT 6667 |
50 |
|
|
51 |
/* channel modes */ |
/* nick types */ |
52 |
|
|
53 |
#define NUM_CHANNEL_MODES 7 |
#define NICK_CHANOWNER 1 |
54 |
#define CHANNEL_MODE_INVITE 0 |
#define NICK_CHANADMIN 2 |
55 |
#define CHANNEL_MODE_KEY 1 |
#define NICK_OP 4 |
56 |
#define CHANNEL_MODE_LIMIT 2 |
#define NICK_HALFOP 8 |
57 |
#define CHANNEL_MODE_MODERATED 3 |
#define NICK_VOICE 16 |
58 |
#define CHANNEL_MODE_NO_MSG_OUT 4 |
#define NICK_AWAY 32 |
59 |
#define CHANNEL_MODE_SECRET 5 |
#define NICK_SET_FLAG(nick, set, flag) \ |
|
#define CHANNEL_MODE_TOPIC 6 |
|
|
#define SET_CHANNEL_MODE(channel, set, mode) \ |
|
60 |
if (set) \ |
if (set) \ |
61 |
channel->modes[mode] = channel_modes[mode]; \ |
nick->flags |= flag; \ |
62 |
else \ |
else \ |
63 |
channel->modes[mode] = ' '; |
nick->flags &= 0xFFFF - flag; |
|
|
|
|
#define DEFAULT_IRC_PORT 6667 |
|
|
|
|
|
/* DCC types & status */ |
|
|
|
|
|
#define DCC_CHAT_RECV 0 /* receiving DCC chat */ |
|
|
#define DCC_CHAT_SEND 1 /* sending DCC chat */ |
|
|
#define DCC_FILE_RECV 2 /* incoming DCC file */ |
|
|
#define DCC_FILE_SEND 3 /* sending DCC file */ |
|
|
|
|
|
#define DCC_WAITING 0 /* waiting for host answer */ |
|
|
#define DCC_CONNECTING 1 /* connecting to host */ |
|
|
#define DCC_ACTIVE 2 /* sending/receiving data */ |
|
|
#define DCC_DONE 3 /* transfer done */ |
|
|
#define DCC_FAILED 4 /* DCC failed */ |
|
|
#define DCC_ABORTED 5 /* DCC aborted by user */ |
|
|
|
|
|
#define DCC_IS_CHAT(type) ((type == DCC_CHAT_RECV) || (type == DCC_CHAT_SEND)) |
|
|
#define DCC_IS_FILE(type) ((type == DCC_FILE_RECV) || (type == DCC_FILE_SEND)) |
|
|
#define DCC_IS_RECV(type) ((type == DCC_CHAT_RECV) || (type == DCC_FILE_RECV)) |
|
|
#define DCC_IS_SEND(type) ((type == DCC_CHAT_SEND) || (type == DCC_FILE_SEND)) |
|
|
|
|
|
#define DCC_ENDED(status) ((status == DCC_DONE) || (status == DCC_FAILED) || \ |
|
|
(status == DCC_ABORTED)) |
|
|
|
|
|
/* nick types */ |
|
64 |
|
|
65 |
typedef struct t_irc_nick t_irc_nick; |
typedef struct t_irc_nick t_irc_nick; |
66 |
|
|
67 |
struct t_irc_nick |
struct t_irc_nick |
68 |
{ |
{ |
69 |
char *nick; /* nickname */ |
char *nick; /* nickname */ |
70 |
int is_chanowner; /* chan owner? (specific to unrealircd) */ |
int flags; /* chanowner/chanadmin (unrealircd), */ |
71 |
int is_chanadmin; /* chan admin? (specific to unrealircd) */ |
/* op, halfop, voice, away */ |
|
int is_op; /* operator privileges? */ |
|
|
int is_halfop; /* half operator privileges? */ |
|
|
int has_voice; /* nick has voice? */ |
|
|
int is_away; /* = 1 if nick is away, otherwise 0 */ |
|
72 |
int color; /* color for nickname in chat window */ |
int color; /* color for nickname in chat window */ |
73 |
t_irc_nick *prev_nick; /* link to previous nick on the channel */ |
t_irc_nick *prev_nick; /* link to previous nick on the channel */ |
74 |
t_irc_nick *next_nick; /* link to next nick on the channel */ |
t_irc_nick *next_nick; /* link to next nick on the channel */ |
76 |
|
|
77 |
/* channel types */ |
/* channel types */ |
78 |
|
|
79 |
typedef struct t_irc_channel t_irc_channel; |
#define CHANNEL_PREFIX "#&+!" |
80 |
|
|
81 |
#define CHAT_UNKNOWN -1 |
#define CHANNEL_TYPE_UNKNOWN -1 |
82 |
#define CHAT_CHANNEL 0 |
#define CHANNEL_TYPE_CHANNEL 0 |
83 |
#define CHAT_PRIVATE 1 |
#define CHANNEL_TYPE_PRIVATE 1 |
84 |
|
|
85 |
|
#define NUM_CHANNEL_MODES 7 |
86 |
|
#define CHANNEL_MODE_INVITE 0 |
87 |
|
#define CHANNEL_MODE_KEY 1 |
88 |
|
#define CHANNEL_MODE_LIMIT 2 |
89 |
|
#define CHANNEL_MODE_MODERATED 3 |
90 |
|
#define CHANNEL_MODE_NO_MSG_OUT 4 |
91 |
|
#define CHANNEL_MODE_SECRET 5 |
92 |
|
#define CHANNEL_MODE_TOPIC 6 |
93 |
|
#define CHANNEL_SET_MODE(channel, set, mode) \ |
94 |
|
if (set) \ |
95 |
|
channel->modes[mode] = channel_modes[mode]; \ |
96 |
|
else \ |
97 |
|
channel->modes[mode] = ' '; |
98 |
|
|
99 |
|
typedef struct t_irc_channel t_irc_channel; |
100 |
|
|
101 |
struct t_irc_channel |
struct t_irc_channel |
102 |
{ |
{ |
104 |
void *dcc_chat; /* DCC CHAT pointer (NULL if not DCC) */ |
void *dcc_chat; /* DCC CHAT pointer (NULL if not DCC) */ |
105 |
char *name; /* name of channel (exemple: "#abc") */ |
char *name; /* name of channel (exemple: "#abc") */ |
106 |
char *topic; /* topic of channel (host for private) */ |
char *topic; /* topic of channel (host for private) */ |
107 |
char modes[NUM_CHANNEL_MODES+1];/* channel modes */ |
char *modes; /* channel modes */ |
108 |
int limit; /* user limit (0 is limit not set) */ |
int limit; /* user limit (0 is limit not set) */ |
109 |
char *key; /* channel key (NULL if no key is set) */ |
char *key; /* channel key (NULL if no key is set) */ |
110 |
int nicks_count; /* # nicks on channel (0 if dcc/pv) */ |
int nicks_count; /* # nicks on channel (0 if dcc/pv) */ |
150 |
int child_write; /* to write into child pipe */ |
int child_write; /* to write into child pipe */ |
151 |
int sock; /* socket for server (IPv4 or IPv6) */ |
int sock; /* socket for server (IPv4 or IPv6) */ |
152 |
int is_connected; /* 1 if WeeChat is connected to server */ |
int is_connected; /* 1 if WeeChat is connected to server */ |
|
#ifdef HAVE_GNUTLS |
|
153 |
int ssl_connected; /* = 1 if connected with SSL */ |
int ssl_connected; /* = 1 if connected with SSL */ |
154 |
|
#ifdef HAVE_GNUTLS |
155 |
gnutls_session gnutls_sess; /* gnutls session (only if SSL is used) */ |
gnutls_session gnutls_sess; /* gnutls session (only if SSL is used) */ |
156 |
#endif |
#endif |
|
|
|
157 |
char *unterminated_message; /* beginning of a message in input buf */ |
char *unterminated_message; /* beginning of a message in input buf */ |
158 |
char *nick; /* current nickname */ |
char *nick; /* current nickname */ |
159 |
time_t reconnect_start; /* this time + delay = reconnect time */ |
time_t reconnect_start; /* this time + delay = reconnect time */ |
204 |
|
|
205 |
/* DCC types */ |
/* DCC types */ |
206 |
|
|
207 |
|
#define DCC_CHAT_RECV 0 /* receiving DCC chat */ |
208 |
|
#define DCC_CHAT_SEND 1 /* sending DCC chat */ |
209 |
|
#define DCC_FILE_RECV 2 /* incoming DCC file */ |
210 |
|
#define DCC_FILE_SEND 3 /* sending DCC file */ |
211 |
|
|
212 |
|
#define DCC_WAITING 0 /* waiting for host answer */ |
213 |
|
#define DCC_CONNECTING 1 /* connecting to host */ |
214 |
|
#define DCC_ACTIVE 2 /* sending/receiving data */ |
215 |
|
#define DCC_DONE 3 /* transfer done */ |
216 |
|
#define DCC_FAILED 4 /* DCC failed */ |
217 |
|
#define DCC_ABORTED 5 /* DCC aborted by user */ |
218 |
|
|
219 |
|
#define DCC_IS_CHAT(type) ((type == DCC_CHAT_RECV) || (type == DCC_CHAT_SEND)) |
220 |
|
#define DCC_IS_FILE(type) ((type == DCC_FILE_RECV) || (type == DCC_FILE_SEND)) |
221 |
|
#define DCC_IS_RECV(type) ((type == DCC_CHAT_RECV) || (type == DCC_FILE_RECV)) |
222 |
|
#define DCC_IS_SEND(type) ((type == DCC_CHAT_SEND) || (type == DCC_FILE_SEND)) |
223 |
|
|
224 |
|
#define DCC_ENDED(status) ((status == DCC_DONE) || (status == DCC_FAILED) || \ |
225 |
|
(status == DCC_ABORTED)) |
226 |
|
|
227 |
typedef struct t_irc_dcc t_irc_dcc; |
typedef struct t_irc_dcc t_irc_dcc; |
228 |
|
|
229 |
struct t_irc_dcc |
struct t_irc_dcc |
249 |
unsigned long start_resume; /* start of resume (in bytes) */ |
unsigned long start_resume; /* start of resume (in bytes) */ |
250 |
time_t last_check_time; /* last time we looked at bytes sent/rcv*/ |
time_t last_check_time; /* last time we looked at bytes sent/rcv*/ |
251 |
unsigned long last_check_pos; /* bytes sent/recv at last check */ |
unsigned long last_check_pos; /* bytes sent/recv at last check */ |
|
unsigned long bytes_per_sec; /* bytes per second */ |
|
252 |
time_t last_activity; /* time of last byte received/sent */ |
time_t last_activity; /* time of last byte received/sent */ |
253 |
|
unsigned long bytes_per_sec; /* bytes per second */ |
254 |
|
unsigned long eta; /* estimated time of arrival */ |
255 |
t_irc_dcc *prev_dcc; /* link to previous dcc file/chat */ |
t_irc_dcc *prev_dcc; /* link to previous dcc file/chat */ |
256 |
t_irc_dcc *next_dcc; /* link to next dcc file/chat */ |
t_irc_dcc *next_dcc; /* link to next dcc file/chat */ |
257 |
}; |
}; |
331 |
|
|
332 |
/* channel functions (irc-channel.c) */ |
/* channel functions (irc-channel.c) */ |
333 |
|
|
334 |
extern t_irc_channel *channel_new (t_irc_server *, int, char *, int); |
extern t_irc_channel *channel_new (t_irc_server *, int, char *); |
335 |
extern void channel_free (t_irc_server *, t_irc_channel *); |
extern void channel_free (t_irc_server *, t_irc_channel *); |
336 |
extern void channel_free_all (t_irc_server *); |
extern void channel_free_all (t_irc_server *); |
337 |
extern t_irc_channel *channel_search (t_irc_server *, char *); |
extern t_irc_channel *channel_search (t_irc_server *, char *); |
349 |
/* nick functions (irc-nick.c) */ |
/* nick functions (irc-nick.c) */ |
350 |
|
|
351 |
extern int nick_find_color (t_irc_nick *); |
extern int nick_find_color (t_irc_nick *); |
352 |
extern t_irc_nick *nick_new (t_irc_channel *, char *, int, int, int, int, int); |
extern t_irc_nick *nick_new (t_irc_server *, t_irc_channel *, char *, |
353 |
|
int, int, int, int, int); |
354 |
extern void nick_resort (t_irc_channel *, t_irc_nick *); |
extern void nick_resort (t_irc_channel *, t_irc_nick *); |
355 |
extern void nick_change (t_irc_channel *, t_irc_nick *, char *); |
extern void nick_change (t_irc_channel *, t_irc_nick *, char *); |
356 |
extern void nick_free (t_irc_channel *, t_irc_nick *); |
extern void nick_free (t_irc_channel *, t_irc_nick *); |
369 |
extern void dcc_accept (t_irc_dcc *); |
extern void dcc_accept (t_irc_dcc *); |
370 |
extern void dcc_accept_resume (t_irc_server *, char *, int, unsigned long); |
extern void dcc_accept_resume (t_irc_server *, char *, int, unsigned long); |
371 |
extern void dcc_start_resume (t_irc_server *, char *, int, unsigned long); |
extern void dcc_start_resume (t_irc_server *, char *, int, unsigned long); |
372 |
|
extern t_irc_dcc *dcc_alloc (); |
373 |
extern t_irc_dcc *dcc_add (t_irc_server *, int, unsigned long, int, char *, int, |
extern t_irc_dcc *dcc_add (t_irc_server *, int, unsigned long, int, char *, int, |
374 |
char *, char *, unsigned long); |
char *, char *, unsigned long); |
375 |
extern void dcc_send_request (t_irc_server *, int, char *, char *); |
extern void dcc_send_request (t_irc_server *, int, char *, char *); |
376 |
extern void dcc_chat_sendf (t_irc_dcc *, char *, ...); |
extern void dcc_chat_sendf (t_irc_dcc *, char *, ...); |
377 |
extern void dcc_handle (); |
extern void dcc_handle (); |
378 |
extern void dcc_end (); |
extern void dcc_end (); |
379 |
|
extern void dcc_print_log (t_irc_dcc *); |
380 |
|
|
381 |
/* IRC display (irc-diplay.c) */ |
/* IRC display (irc-diplay.c) */ |
382 |
|
|