Bug Summary

File:irc/core/irc-commands.c
Location:line 77, column 6
Description:Dereference of null pointer.

Annotated Source Code

1/*
2 irc-commands.c : irssi
3
4 Copyright (C) 1999 Timo Sirainen
5
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License along
17 with this program; if not, write to the Free Software Foundation, Inc.,
18 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19*/
20
21#include "module.h"
22#include "misc.h"
23#include "recode.h"
24#include "special-vars.h"
25#include "settings.h"
26#include "window-item-def.h"
27
28#include "servers-reconnect.h"
29#include "servers-redirect.h"
30#include "servers-setup.h"
31#include "nicklist.h"
32
33#include "bans.h"
34#include "irc-commands.h"
35#include "irc-servers.h"
36#include "irc-channels.h"
37#include "irc-queries.h"
38
39/* How often to check if there's anyone to be unbanned in knockout list */
40#define KNOCKOUT_TIMECHECK10000 10000
41
42/* /LIST: Max. number of channels in IRC network before -yes option
43 is required */
44#define LIST_MAX_CHANNELS_PASS1000 1000
45
46/* When /PARTing a channel, if there's more messages in output queue
47 than this, purge the output for channel. The idea behind this is that
48 if you accidentally pasted some large text and /PART the channel, the
49 text won't be fully pasted. Note that this counter is the whole size
50 of the output queue, not channel specific.. */
51#define MAX_COMMANDS_ON_PART_UNTIL_PURGE10 10
52
53typedef struct {
54 IRC_CHANNEL_REC *channel;
55 char *ban;
56 time_t unban_time;
57} KNOCKOUT_REC;
58
59static GString *tmpstr;
60static int knockout_tag;
61
62/* SYNTAX: NOTICE <targets> <message> */
63static void cmd_notice(const char *data, IRC_SERVER_REC *server,
64 WI_ITEM_REC *item)
65{
66 const char *target, *msg;
67 char *recoded;
68 void *free_arg;
69
70 CMD_IRC_SERVER(server)do { if (server != ((void *)0) && !(((IRC_SERVER_REC *
) chat_protocol_check_cast(((SERVER_REC *) module_check_cast(
server, __builtin_offsetof(SERVER_REC, type), "SERVER")), __builtin_offsetof
(IRC_SERVER_REC, chat_type), "IRC")) ? (!(0)) : (0))) return;
if (server == ((void *)0) || !(server)->connected) do { signal_emit
("error command", 1, ((gpointer) (CMDERR_NOT_CONNECTED))); signal_stop
(); return; } while (0); } while (0)
;
[1] '?' condition evaluates to true
[2] Taking false branch
[3] Taking false branch
[4] Loop condition is false. Exiting loop
71
72 if (!cmd_get_params(data, &free_arg, 2 | PARAM_FLAG_GETREST0x00002000,
[5] Taking false branch
73 &target, &msg))
74 return;
75 if (strcmp(target, "*") == 0)
[6] Taking true branch
76 target = item == NULL((void *)0) ? NULL((void *)0) : window_item_get_target(item)((item)->get_target(item));
[7] '?' condition evaluates to true
77 if (*target == '\0' || *msg == '\0')
[8] Dereference of null pointer
78 cmd_param_error(CMDERR_NOT_ENOUGH_PARAMS)do { cmd_params_free(free_arg); do { signal_emit("error command"
, 1, ((gpointer) (CMDERR_NOT_ENOUGH_PARAMS))); signal_stop();
return; } while (0); } while (0)
;
79
80 recoded = recode_out(SERVER(server)((SERVER_REC *) module_check_cast(server, __builtin_offsetof(
SERVER_REC, type), "SERVER"))
, msg, target);
81 g_string_printf(tmpstr, "NOTICE %s :%s", target, recoded);
82 g_free(recoded);
83
84 irc_send_cmd_split(server, tmpstr->str, 2, server->max_msgs_in_cmd);
85
86 cmd_params_free(free_arg);
87}
88
89/* SYNTAX: CTCP <targets> <ctcp command> [<ctcp data>] */
90static void cmd_ctcp(const char *data, IRC_SERVER_REC *server,
91 WI_ITEM_REC *item)
92{
93 const char *target;
94 char *ctcpcmd, *ctcpdata;
95 void *free_arg;
96
97 CMD_IRC_SERVER(server)do { if (server != ((void *)0) && !(((IRC_SERVER_REC *
) chat_protocol_check_cast(((SERVER_REC *) module_check_cast(
server, __builtin_offsetof(SERVER_REC, type), "SERVER")), __builtin_offsetof
(IRC_SERVER_REC, chat_type), "IRC")) ? (!(0)) : (0))) return;
if (server == ((void *)0) || !(server)->connected) do { signal_emit
("error command", 1, ((gpointer) (CMDERR_NOT_CONNECTED))); signal_stop
(); return; } while (0); } while (0)
;
98
99 if (!cmd_get_params(data, &free_arg, 3 | PARAM_FLAG_GETREST0x00002000,
100 &target, &ctcpcmd, &ctcpdata))
101 return;
102 if (strcmp(target, "*") == 0)
103 target = item == NULL((void *)0) ? NULL((void *)0) : window_item_get_target(item)((item)->get_target(item));
104 if (*target == '\0' || *ctcpcmd == '\0')
105 cmd_param_error(CMDERR_NOT_ENOUGH_PARAMS)do { cmd_params_free(free_arg); do { signal_emit("error command"
, 1, ((gpointer) (CMDERR_NOT_ENOUGH_PARAMS))); signal_stop();
return; } while (0); } while (0)
;
106
107 g_strup(ctcpcmd);
108 if (*ctcpdata == '\0')
109 g_string_printf(tmpstr, "PRIVMSG %s :\001%s\001", target, ctcpcmd);
110 else {
111 char *recoded;
112
113 recoded = recode_out(SERVER(server)((SERVER_REC *) module_check_cast(server, __builtin_offsetof(
SERVER_REC, type), "SERVER"))
, ctcpdata, target);
114 g_string_printf(tmpstr, "PRIVMSG %s :\001%s %s\001", target, ctcpcmd, recoded);
115 g_free(recoded);
116 }
117
118 irc_send_cmd_split(server, tmpstr->str, 2, server->max_msgs_in_cmd);
119
120 cmd_params_free(free_arg);
121}
122
123/* SYNTAX: NCTCP <targets> <ctcp command> [<ctcp data>] */
124static void cmd_nctcp(const char *data, IRC_SERVER_REC *server,
125 WI_ITEM_REC *item)
126{
127 const char *target;
128 char *ctcpcmd, *ctcpdata, *recoded;
129 void *free_arg;
130
131 CMD_IRC_SERVER(server)do { if (server != ((void *)0) && !(((IRC_SERVER_REC *
) chat_protocol_check_cast(((SERVER_REC *) module_check_cast(
server, __builtin_offsetof(SERVER_REC, type), "SERVER")), __builtin_offsetof
(IRC_SERVER_REC, chat_type), "IRC")) ? (!(0)) : (0))) return;
if (server == ((void *)0) || !(server)->connected) do { signal_emit
("error command", 1, ((gpointer) (CMDERR_NOT_CONNECTED))); signal_stop
(); return; } while (0); } while (0)
;
132
133 if (!cmd_get_params(data, &free_arg, 3 | PARAM_FLAG_GETREST0x00002000,
134 &target, &ctcpcmd, &ctcpdata))
135 return;
136 if (strcmp(target, "*") == 0)
137 target = item == NULL((void *)0) ? NULL((void *)0) : window_item_get_target(item)((item)->get_target(item));
138 if (*target == '\0' || *ctcpcmd == '\0')
139 cmd_param_error(CMDERR_NOT_ENOUGH_PARAMS)do { cmd_params_free(free_arg); do { signal_emit("error command"
, 1, ((gpointer) (CMDERR_NOT_ENOUGH_PARAMS))); signal_stop();
return; } while (0); } while (0)
;
140
141 g_strup(ctcpcmd);
142 recoded = recode_out(SERVER(server)((SERVER_REC *) module_check_cast(server, __builtin_offsetof(
SERVER_REC, type), "SERVER"))
, ctcpdata, target);
143 g_string_printf(tmpstr, "NOTICE %s :\001%s %s\001", target, ctcpcmd, recoded);
144 g_free(recoded);
145
146 irc_send_cmd_split(server, tmpstr->str, 2, server->max_msgs_in_cmd);
147
148 cmd_params_free(free_arg);
149}
150
151/* SYNTAX: PART [<channels>] [<message>] */
152static void cmd_part(const char *data, IRC_SERVER_REC *server,
153 WI_ITEM_REC *item)
154{
155 char *channame, *msg;
156 char *recoded = NULL((void *)0);
157 void *free_arg;
158
159 CMD_IRC_SERVER(server)do { if (server != ((void *)0) && !(((IRC_SERVER_REC *
) chat_protocol_check_cast(((SERVER_REC *) module_check_cast(
server, __builtin_offsetof(SERVER_REC, type), "SERVER")), __builtin_offsetof
(IRC_SERVER_REC, chat_type), "IRC")) ? (!(0)) : (0))) return;
if (server == ((void *)0) || !(server)->connected) do { signal_emit
("error command", 1, ((gpointer) (CMDERR_NOT_CONNECTED))); signal_stop
(); return; } while (0); } while (0)
;
160
161 if (!cmd_get_params(data, &free_arg, 2 | PARAM_FLAG_GETREST0x00002000 |
162 PARAM_FLAG_OPTCHAN0x00010000, item, &channame, &msg))
163 return;
164 if (*channame == '\0') cmd_param_error(CMDERR_NOT_ENOUGH_PARAMS)do { cmd_params_free(free_arg); do { signal_emit("error command"
, 1, ((gpointer) (CMDERR_NOT_ENOUGH_PARAMS))); signal_stop();
return; } while (0); } while (0)
;
165
166 if (*msg == '\0') msg = (char *) settings_get_str("part_message");
167
168 if (server->cmdcount > MAX_COMMANDS_ON_PART_UNTIL_PURGE10)
169 irc_server_purge_output(server, channame);
170
171 if (*msg != '\0')
172 recoded = recode_out(SERVER(server)((SERVER_REC *) module_check_cast(server, __builtin_offsetof(
SERVER_REC, type), "SERVER"))
, msg, channame);
173 irc_send_cmdv(server, ! recoded ? "PART %s" : "PART %s :%s",
174 channame, recoded);
175
176 g_free(recoded);
177 cmd_params_free(free_arg);
178}
179
180/* SYNTAX: KICK [<channel>] <nicks> [<reason>] */
181static void cmd_kick(const char *data, IRC_SERVER_REC *server, WI_ITEM_REC *item)
182{
183 char *channame, *nicks, *reason, *recoded;
184 void *free_arg;
185
186 CMD_IRC_SERVER(server)do { if (server != ((void *)0) && !(((IRC_SERVER_REC *
) chat_protocol_check_cast(((SERVER_REC *) module_check_cast(
server, __builtin_offsetof(SERVER_REC, type), "SERVER")), __builtin_offsetof
(IRC_SERVER_REC, chat_type), "IRC")) ? (!(0)) : (0))) return;
if (server == ((void *)0) || !(server)->connected) do { signal_emit
("error command", 1, ((gpointer) (CMDERR_NOT_CONNECTED))); signal_stop
(); return; } while (0); } while (0)
;
187
188 if (!cmd_get_params(data, &free_arg, 3 | PARAM_FLAG_GETREST0x00002000 |
189 PARAM_FLAG_OPTCHAN0x00010000, item,
190 &channame, &nicks, &reason))
191 return;
192
193 if (*channame == '\0' || *nicks == '\0') cmd_param_error(CMDERR_NOT_ENOUGH_PARAMS)do { cmd_params_free(free_arg); do { signal_emit("error command"
, 1, ((gpointer) (CMDERR_NOT_ENOUGH_PARAMS))); signal_stop();
return; } while (0); } while (0)
;
194 if (!ischannel(*channame)((*channame) == '#' || (*channame) == '&' || (*channame) ==
'!' || (*channame) == '+')
) cmd_param_error(CMDERR_NOT_JOINED)do { cmd_params_free(free_arg); do { signal_emit("error command"
, 1, ((gpointer) (CMDERR_NOT_JOINED))); signal_stop(); return
; } while (0); } while (0)
;
195
196 recoded = recode_out(SERVER(server)((SERVER_REC *) module_check_cast(server, __builtin_offsetof(
SERVER_REC, type), "SERVER"))
, reason, channame);
197 g_string_printf(tmpstr, "KICK %s %s :%s", channame, nicks, recoded);
198 g_free(recoded);
199
200 irc_send_cmd_split(server, tmpstr->str, 3, server->max_kicks_in_cmd);
201
202 cmd_params_free(free_arg);
203}
204
205/* SYNTAX: TOPIC [-delete] [<channel>] [<topic>] */
206static void cmd_topic(const char *data, IRC_SERVER_REC *server, WI_ITEM_REC *item)
207{
208 GHashTable *optlist;
209 char *channame, *topic;
210 char *recoded = NULL((void *)0);
211 void *free_arg;
212
213 CMD_IRC_SERVER(server)do { if (server != ((void *)0) && !(((IRC_SERVER_REC *
) chat_protocol_check_cast(((SERVER_REC *) module_check_cast(
server, __builtin_offsetof(SERVER_REC, type), "SERVER")), __builtin_offsetof
(IRC_SERVER_REC, chat_type), "IRC")) ? (!(0)) : (0))) return;
if (server == ((void *)0) || !(server)->connected) do { signal_emit
("error command", 1, ((gpointer) (CMDERR_NOT_CONNECTED))); signal_stop
(); return; } while (0); } while (0)
;
214
215 if (!cmd_get_params(data, &free_arg, 2 | PARAM_FLAG_OPTCHAN0x00010000 |
216 PARAM_FLAG_OPTIONS0x00004000 | PARAM_FLAG_GETREST0x00002000,
217 item, "topic", &optlist, &channame, &topic))
218 return;
219
220 if (*topic != '\0' || g_hash_table_lookup(optlist, "delete") != NULL((void *)0))
221 recoded = recode_out(SERVER(server)((SERVER_REC *) module_check_cast(server, __builtin_offsetof(
SERVER_REC, type), "SERVER"))
, topic, channame);
222 irc_send_cmdv(server, recoded == NULL((void *)0) ? "TOPIC %s" : "TOPIC %s :%s",
223 channame, recoded);
224 g_free(recoded);
225
226 cmd_params_free(free_arg);
227}
228
229/* SYNTAX: INVITE <nick> [<channel>] */
230static void cmd_invite(const char *data, IRC_SERVER_REC *server, WI_ITEM_REC *item)
231{
232 char *nick, *channame;
233 void *free_arg;
234
235 CMD_IRC_SERVER(server)do { if (server != ((void *)0) && !(((IRC_SERVER_REC *
) chat_protocol_check_cast(((SERVER_REC *) module_check_cast(
server, __builtin_offsetof(SERVER_REC, type), "SERVER")), __builtin_offsetof
(IRC_SERVER_REC, chat_type), "IRC")) ? (!(0)) : (0))) return;
if (server == ((void *)0) || !(server)->connected) do { signal_emit
("error command", 1, ((gpointer) (CMDERR_NOT_CONNECTED))); signal_stop
(); return; } while (0); } while (0)
;
236
237 if (!cmd_get_params(data, &free_arg, 2, &nick, &channame))
238 return;
239
240 if (*nick == '\0') cmd_param_error(CMDERR_NOT_ENOUGH_PARAMS)do { cmd_params_free(free_arg); do { signal_emit("error command"
, 1, ((gpointer) (CMDERR_NOT_ENOUGH_PARAMS))); signal_stop();
return; } while (0); } while (0)
;
241 if (*channame == '\0' || strcmp(channame, "*") == 0) {
242 if (!IS_IRC_CHANNEL(item)(((IRC_CHANNEL_REC *) chat_protocol_check_cast(((CHANNEL_REC *
) module_check_cast_module(item, __builtin_offsetof(CHANNEL_REC
, type), "WINDOW ITEM TYPE", "CHANNEL")), __builtin_offsetof(
IRC_CHANNEL_REC, chat_type), "IRC")) ? (!(0)) : (0))
)
243 cmd_param_error(CMDERR_NOT_JOINED)do { cmd_params_free(free_arg); do { signal_emit("error command"
, 1, ((gpointer) (CMDERR_NOT_JOINED))); signal_stop(); return
; } while (0); } while (0)
;
244
245 channame = IRC_CHANNEL(item)((IRC_CHANNEL_REC *) chat_protocol_check_cast(((CHANNEL_REC *
) module_check_cast_module(item, __builtin_offsetof(CHANNEL_REC
, type), "WINDOW ITEM TYPE", "CHANNEL")), __builtin_offsetof(
IRC_CHANNEL_REC, chat_type), "IRC"))
->name;
246 }
247
248 irc_send_cmdv(server, "INVITE %s %s", nick, channame);
249 cmd_params_free(free_arg);
250}
251
252/* SYNTAX: LIST [-yes] [<channel>] */
253static void cmd_list(const char *data, IRC_SERVER_REC *server,
254 WI_ITEM_REC *item)
255{
256 GHashTable *optlist;
257 char *str;
258 void *free_arg;
259
260 CMD_IRC_SERVER(server)do { if (server != ((void *)0) && !(((IRC_SERVER_REC *
) chat_protocol_check_cast(((SERVER_REC *) module_check_cast(
server, __builtin_offsetof(SERVER_REC, type), "SERVER")), __builtin_offsetof
(IRC_SERVER_REC, chat_type), "IRC")) ? (!(0)) : (0))) return;
if (server == ((void *)0) || !(server)->connected) do { signal_emit
("error command", 1, ((gpointer) (CMDERR_NOT_CONNECTED))); signal_stop
(); return; } while (0); } while (0)
;
261
262 if (!cmd_get_params(data, &free_arg, 1 | PARAM_FLAG_OPTIONS0x00004000 |
263 PARAM_FLAG_GETREST0x00002000, "list", &optlist, &str))
264 return;
265
266 if (*str == '\0' && g_hash_table_lookup(optlist, "yes") == NULL((void *)0) &&
267 (server->channels_formed <= 0 ||
268 server->channels_formed > LIST_MAX_CHANNELS_PASS1000))
269 cmd_param_error(CMDERR_NOT_GOOD_IDEA)do { cmd_params_free(free_arg); do { signal_emit("error command"
, 1, ((gpointer) (CMDERR_NOT_GOOD_IDEA))); signal_stop(); return
; } while (0); } while (0)
;
270
271 irc_send_cmdv(server, "LIST %s", str);
272 cmd_params_free(free_arg);
273}
274
275/* SYNTAX: WHO [<nicks> | <channels> | **] */
276static void cmd_who(const char *data, IRC_SERVER_REC *server,
277 WI_ITEM_REC *item)
278{
279 char *channel, *rest;
280 void *free_arg;
281
282 CMD_IRC_SERVER(server)do { if (server != ((void *)0) && !(((IRC_SERVER_REC *
) chat_protocol_check_cast(((SERVER_REC *) module_check_cast(
server, __builtin_offsetof(SERVER_REC, type), "SERVER")), __builtin_offsetof
(IRC_SERVER_REC, chat_type), "IRC")) ? (!(0)) : (0))) return;
if (server == ((void *)0) || !(server)->connected) do { signal_emit
("error command", 1, ((gpointer) (CMDERR_NOT_CONNECTED))); signal_stop
(); return; } while (0); } while (0)
;
283
284 if (!cmd_get_params(data, &free_arg, 2 | PARAM_FLAG_GETREST0x00002000, &channel, &rest))
285 return;
286
287 if (strcmp(channel, "*") == 0 || *channel == '\0') {
288 if (!IS_IRC_CHANNEL(item)(((IRC_CHANNEL_REC *) chat_protocol_check_cast(((CHANNEL_REC *
) module_check_cast_module(item, __builtin_offsetof(CHANNEL_REC
, type), "WINDOW ITEM TYPE", "CHANNEL")), __builtin_offsetof(
IRC_CHANNEL_REC, chat_type), "IRC")) ? (!(0)) : (0))
)
289 cmd_param_error(CMDERR_NOT_JOINED)do { cmd_params_free(free_arg); do { signal_emit("error command"
, 1, ((gpointer) (CMDERR_NOT_JOINED))); signal_stop(); return
; } while (0); } while (0)
;
290
291 channel = IRC_CHANNEL(item)((IRC_CHANNEL_REC *) chat_protocol_check_cast(((CHANNEL_REC *
) module_check_cast_module(item, __builtin_offsetof(CHANNEL_REC
, type), "WINDOW ITEM TYPE", "CHANNEL")), __builtin_offsetof(
IRC_CHANNEL_REC, chat_type), "IRC"))
->name;
292 }
293 if (strcmp(channel, "**") == 0) {
294 /* ** displays all nicks.. */
295 *channel = '\0';
296 }
297
298 irc_send_cmdv(server, *rest == '\0' ? "WHO %s" : "WHO %s %s",
299 channel, rest);
300 cmd_params_free(free_arg);
301}
302
303static void cmd_names(const char *data, IRC_SERVER_REC *server,
304 WI_ITEM_REC *item)
305{
306 GHashTable *optlist;
307 char *channel;
308 void *free_arg;
309
310 CMD_IRC_SERVER(server)do { if (server != ((void *)0) && !(((IRC_SERVER_REC *
) chat_protocol_check_cast(((SERVER_REC *) module_check_cast(
server, __builtin_offsetof(SERVER_REC, type), "SERVER")), __builtin_offsetof
(IRC_SERVER_REC, chat_type), "IRC")) ? (!(0)) : (0))) return;
if (server == ((void *)0) || !(server)->connected) do { signal_emit
("error command", 1, ((gpointer) (CMDERR_NOT_CONNECTED))); signal_stop
(); return; } while (0); } while (0)
;
311
312 if (!cmd_get_params(data, &free_arg, 1 | PARAM_FLAG_OPTIONS0x00004000 |
313 PARAM_FLAG_GETREST0x00002000, "names", &optlist, &channel))
314 return;
315
316 if (strcmp(channel, "*") == 0 || *channel == '\0') {
317 if (!IS_IRC_CHANNEL(item)(((IRC_CHANNEL_REC *) chat_protocol_check_cast(((CHANNEL_REC *
) module_check_cast_module(item, __builtin_offsetof(CHANNEL_REC
, type), "WINDOW ITEM TYPE", "CHANNEL")), __builtin_offsetof(
IRC_CHANNEL_REC, chat_type), "IRC")) ? (!(0)) : (0))
)
318 cmd_param_error(CMDERR_NOT_JOINED)do { cmd_params_free(free_arg); do { signal_emit("error command"
, 1, ((gpointer) (CMDERR_NOT_JOINED))); signal_stop(); return
; } while (0); } while (0)
;
319
320 channel = IRC_CHANNEL(item)((IRC_CHANNEL_REC *) chat_protocol_check_cast(((CHANNEL_REC *
) module_check_cast_module(item, __builtin_offsetof(CHANNEL_REC
, type), "WINDOW ITEM TYPE", "CHANNEL")), __builtin_offsetof(
IRC_CHANNEL_REC, chat_type), "IRC"))
->name;
321 }
322
323 if (strcmp(channel, "**") == 0) {
324 /* ** displays all nicks.. */
325 irc_send_cmd(server, "NAMES");
326 } else {
327 irc_send_cmdv(server, "NAMES %s", channel);
328 }
329
330 cmd_params_free(free_arg);
331}
332
333/* SYNTAX: NICK <new nick> */
334static void cmd_nick(const char *data, IRC_SERVER_REC *server, WI_ITEM_REC *item)
335{
336 char *nick;
337 void *free_arg;
338
339 g_return_if_fail(data != NULL)do{ if (data != ((void *)0)) { } else { g_return_if_fail_warning
(((gchar*) 0), __PRETTY_FUNCTION__, "data != NULL"); return;
}; }while (0)
;
340
341 CMD_IRC_SERVER(server)do { if (server != ((void *)0) && !(((IRC_SERVER_REC *
) chat_protocol_check_cast(((SERVER_REC *) module_check_cast(
server, __builtin_offsetof(SERVER_REC, type), "SERVER")), __builtin_offsetof
(IRC_SERVER_REC, chat_type), "IRC")) ? (!(0)) : (0))) return;
if (server == ((void *)0) || !(server)->connected) do { signal_emit
("error command", 1, ((gpointer) (CMDERR_NOT_CONNECTED))); signal_stop
(); return; } while (0); } while (0)
;
342
343 if (!cmd_get_params(data, &free_arg, 1, &nick))
344 return;
345
346 g_free(server->last_nick);
347 server->last_nick = g_strdup(nick);
348
349 irc_send_cmdv(server, "NICK %s", nick);
350 cmd_params_free(free_arg);
351}
352
353static char *get_redirect_nicklist(const char *nicks, int *free)
354{
355 char *str, *ret;
356
357 if (*nicks != '!' && strchr(nicks, ',') == NULL((void *)0)) {
358 *free = FALSE(0);
359 return (char *) nicks;
360 }
361
362 *free = TRUE(!(0));
363
364 /* ratbox-style operspy whois takes !nick, echoes that
365 * in RPL_ENDOFWHOIS as normal but gives output about the
366 * plain nick
367 */
368 str = g_strdup(*nicks == '!' ? nicks + 1 : nicks);
369 g_strdelimit(str, ",", ' ');
370 ret = g_strconcat(str, " ", nicks, NULL((void *)0));
371 g_free(str);
372
373 return ret;
374}
375
376/* SYNTAX: WHOIS [-<server tag>] [<server>] [<nicks>] */
377static void cmd_whois(const char *data, IRC_SERVER_REC *server,
378 WI_ITEM_REC *item)
379{
380 GHashTable *optlist;
381 char *qserver, *query, *event_402, *str;
382 void *free_arg;
383 int free_nick;
384
385 CMD_IRC_SERVER(server)do { if (server != ((void *)0) && !(((IRC_SERVER_REC *
) chat_protocol_check_cast(((SERVER_REC *) module_check_cast(
server, __builtin_offsetof(SERVER_REC, type), "SERVER")), __builtin_offsetof
(IRC_SERVER_REC, chat_type), "IRC")) ? (!(0)) : (0))) return;
if (server == ((void *)0) || !(server)->connected) do { signal_emit
("error command", 1, ((gpointer) (CMDERR_NOT_CONNECTED))); signal_stop
(); return; } while (0); } while (0)
;
386
387 if (!cmd_get_params(data, &free_arg, 2 | PARAM_FLAG_OPTIONS0x00004000 |
388 PARAM_FLAG_UNKNOWN_OPTIONS0x00008000,
389 "whois", &optlist, &qserver, &query))
390 return;
391
392 /* -<server tag> */
393 server = IRC_SERVER(cmd_options_get_server("whois", optlist,((IRC_SERVER_REC *) chat_protocol_check_cast(((SERVER_REC *) module_check_cast
(cmd_options_get_server("whois", optlist, ((SERVER_REC *) module_check_cast
(server, __builtin_offsetof(SERVER_REC, type), "SERVER"))), __builtin_offsetof
(SERVER_REC, type), "SERVER")), __builtin_offsetof(IRC_SERVER_REC
, chat_type), "IRC"))
394 SERVER(server)))((IRC_SERVER_REC *) chat_protocol_check_cast(((SERVER_REC *) module_check_cast
(cmd_options_get_server("whois", optlist, ((SERVER_REC *) module_check_cast
(server, __builtin_offsetof(SERVER_REC, type), "SERVER"))), __builtin_offsetof
(SERVER_REC, type), "SERVER")), __builtin_offsetof(IRC_SERVER_REC
, chat_type), "IRC"))
;
395 if (server == NULL((void *)0)) {
396 cmd_params_free(free_arg);
397 return;
398 }
399
400 if (*query == '\0') {
401 query = qserver;
402 qserver = "";
403 }
404 if (*query == '\0') {
405 QUERY_REC *queryitem = QUERY(item)((QUERY_REC *) module_check_cast_module(item, __builtin_offsetof
(QUERY_REC, type), "WINDOW ITEM TYPE", "QUERY"))
;
406 if (queryitem == NULL((void *)0))
407 query = server->nick;
408 else
409 query = qserver = queryitem->name;
410 }
411
412 if (strcmp(query, "*") == 0 &&
413 g_hash_table_lookup(optlist, "yes") == NULL((void *)0))
414 cmd_param_error(CMDERR_NOT_GOOD_IDEA)do { cmd_params_free(free_arg); do { signal_emit("error command"
, 1, ((gpointer) (CMDERR_NOT_GOOD_IDEA))); signal_stop(); return
; } while (0); } while (0)
;
415
416 event_402 = "event 402";
417 if (*qserver == '\0')
418 g_string_printf(tmpstr, "WHOIS %s", query);
419 else {
420 g_string_printf(tmpstr, "WHOIS %s %s", qserver, query);
421 if (g_strcasecmp(qserver, query) == 0)
422 event_402 = "whois event not found";
423 }
424
425 query = get_redirect_nicklist(query, &free_nick);
426
427 str = g_strconcat(qserver, " ", query, NULL((void *)0));
428 server_redirect_event(server, "whois", 1, str, TRUE(!(0)),
429 NULL((void *)0),
430 "event 318", "whois end",
431 "event 402", event_402,
432 "event 301", "whois away", /* 301 can come as a reply to /MSG, /WHOIS or /WHOWAS */
433 "event 313", "whois oper",
434 "event 401", (settings_get_bool("auto_whowas") ? "whois try whowas" : "whois event not found"),
435 "event 311", "whois event",
436 "", "whois default event", NULL((void *)0));
437 g_free(str);
438
439 server->whois_found = FALSE(0);
440 irc_send_cmd_split(server, tmpstr->str, 2, server->max_whois_in_cmd);
441
442 if (free_nick) g_free(query);
443 cmd_params_free(free_arg);
444}
445
446static void event_whois(IRC_SERVER_REC *server, const char *data,
447 const char *nick, const char *addr)
448{
449 server->whois_found = TRUE(!(0));
450 signal_emit("event 311", 4, server, data, nick, addr);
451}
452
453static void sig_whois_try_whowas(IRC_SERVER_REC *server, const char *data)
454{
455 char *params, *nick;
456
457 g_return_if_fail(data != NULL)do{ if (data != ((void *)0)) { } else { g_return_if_fail_warning
(((gchar*) 0), __PRETTY_FUNCTION__, "data != NULL"); return;
}; }while (0)
;
458
459 params = event_get_params(data, 2, NULL((void *)0), &nick);
460
461 server->whowas_found = FALSE(0);
462 server_redirect_event(server, "whowas", 1, nick, -1, NULL((void *)0),
463 "event 314", "whowas event",
464 "event 369", "whowas event end",
465 "event 406", "event empty", NULL((void *)0));
466 irc_send_cmdv(server, "WHOWAS %s 1", nick);
467
468 g_free(params);
469}
470
471static void event_end_of_whois(IRC_SERVER_REC *server, const char *data,
472 const char *nick, const char *addr)
473{
474 signal_emit("event 318", 4, server, data, nick, addr);
475 server->whois_found = FALSE(0);
476}
477
478static void event_whowas(IRC_SERVER_REC *server, const char *data,
479 const char *nick, const char *addr)
480{
481 server->whowas_found = TRUE(!(0));
482 signal_emit("event 314", 4, server, data, nick, addr);
483}
484
485/* SYNTAX: WHOWAS [<nicks> [<count> [server]]] */
486static void cmd_whowas(const char *data, IRC_SERVER_REC *server)
487{
488 char *nicks, *rest, *nicks_redir;
489 void *free_arg;
490 int free_nick;
491
492 CMD_IRC_SERVER(server)do { if (server != ((void *)0) && !(((IRC_SERVER_REC *
) chat_protocol_check_cast(((SERVER_REC *) module_check_cast(
server, __builtin_offsetof(SERVER_REC, type), "SERVER")), __builtin_offsetof
(IRC_SERVER_REC, chat_type), "IRC")) ? (!(0)) : (0))) return;
if (server == ((void *)0) || !(server)->connected) do { signal_emit
("error command", 1, ((gpointer) (CMDERR_NOT_CONNECTED))); signal_stop
(); return; } while (0); } while (0)
;
493
494 if (!cmd_get_params(data, &free_arg, 2 | PARAM_FLAG_GETREST0x00002000, &nicks, &rest))
495 return;
496 if (*nicks == '\0') nicks = server->nick;
497
498 nicks_redir = get_redirect_nicklist(nicks, &free_nick);
499 server_redirect_event(server, "whowas", 1, nicks_redir, -1, NULL((void *)0),
500 "event 301", "whowas away", /* 301 can come as a reply to /MSG, /WHOIS or /WHOWAS */
501 "event 314", "whowas event", NULL((void *)0));
502 if (free_nick) g_free(nicks_redir);
503
504 server->whowas_found = FALSE(0);
505 irc_send_cmdv(server, *rest == '\0' ? "WHOWAS %s" :
506 "WHOWAS %s %s", nicks, rest);
507
508 cmd_params_free(free_arg);
509}
510
511/* SYNTAX: PING [<nick> | <channel> | *] */
512static void cmd_ping(const char *data, IRC_SERVER_REC *server, WI_ITEM_REC *item)
513{
514 GTimeVal tv;
515 char *str;
516
517 CMD_IRC_SERVER(server)do { if (server != ((void *)0) && !(((IRC_SERVER_REC *
) chat_protocol_check_cast(((SERVER_REC *) module_check_cast(
server, __builtin_offsetof(SERVER_REC, type), "SERVER")), __builtin_offsetof
(IRC_SERVER_REC, chat_type), "IRC")) ? (!(0)) : (0))) return;
if (server == ((void *)0) || !(server)->connected) do { signal_emit
("error command", 1, ((gpointer) (CMDERR_NOT_CONNECTED))); signal_stop
(); return; } while (0); } while (0)
;
518
519 if (*data == '\0') {
520 if (!IS_QUERY(item)(((QUERY_REC *) module_check_cast_module(item, __builtin_offsetof
(QUERY_REC, type), "WINDOW ITEM TYPE", "QUERY")) ? (!(0)) : (
0))
)
521 cmd_return_error(CMDERR_NOT_ENOUGH_PARAMS)do { signal_emit("error command", 1, ((gpointer) (CMDERR_NOT_ENOUGH_PARAMS
))); signal_stop(); return; } while (0)
;
522 data = window_item_get_target(item)((item)->get_target(item));
523 }
524
525 g_get_current_time(&tv);
526
527 str = g_strdup_printf("%s PING %ld %ld", data, tv.tv_sec, tv.tv_usec);
528 signal_emit("command ctcp", 3, str, server, item);
529 g_free(str);
530}
531
532/* SYNTAX: AWAY [-one | -all] [<reason>] */
533static void cmd_away(const char *data, IRC_SERVER_REC *server)
534{
535 GHashTable *optlist;
536 char *reason;
537 void *free_arg;
538
539 if (!cmd_get_params(data, &free_arg, 1 | PARAM_FLAG_OPTIONS0x00004000 |
540 PARAM_FLAG_GETREST0x00002000, "away", &optlist, &reason)) return;
541
542 if (g_hash_table_lookup(optlist, "one") != NULL((void *)0))
543 irc_server_send_away(server, reason);
544 else
545 g_slist_foreach(servers, (GFunc) irc_server_send_away, reason);
546
547 cmd_params_free(free_arg);
548}
549
550/* SYNTAX: SCONNECT <new server> [[<port>] <existing server>] */
551static void cmd_sconnect(const char *data, IRC_SERVER_REC *server)
552{
553 CMD_IRC_SERVER(server)do { if (server != ((void *)0) && !(((IRC_SERVER_REC *
) chat_protocol_check_cast(((SERVER_REC *) module_check_cast(
server, __builtin_offsetof(SERVER_REC, type), "SERVER")), __builtin_offsetof
(IRC_SERVER_REC, chat_type), "IRC")) ? (!(0)) : (0))) return;
if (server == ((void *)0) || !(server)->connected) do { signal_emit
("error command", 1, ((gpointer) (CMDERR_NOT_CONNECTED))); signal_stop
(); return; } while (0); } while (0)
;
554 if (*data == '\0') cmd_return_error(CMDERR_NOT_ENOUGH_PARAMS)do { signal_emit("error command", 1, ((gpointer) (CMDERR_NOT_ENOUGH_PARAMS
))); signal_stop(); return; } while (0)
;
555
556 irc_send_cmdv(server, "CONNECT %s", data);
557}
558
559/* SYNTAX: QUOTE <data> */
560static void cmd_quote(const char *data, IRC_SERVER_REC *server)
561{
562 if (server != NULL((void *)0) && !IS_IRC_SERVER(server)(((IRC_SERVER_REC *) chat_protocol_check_cast(((SERVER_REC *)
module_check_cast(server, __builtin_offsetof(SERVER_REC, type
), "SERVER")), __builtin_offsetof(IRC_SERVER_REC, chat_type),
"IRC")) ? (!(0)) : (0))
)
563 return;
564 if (server == NULL((void *)0) || server->connect_time == 0)
565 cmd_return_error(CMDERR_NOT_CONNECTED)do { signal_emit("error command", 1, ((gpointer) (CMDERR_NOT_CONNECTED
))); signal_stop(); return; } while (0)
;
566
567 if (!server->connected)
568 irc_send_cmd_now(server, data);
569 else
570 irc_send_cmd(server, data);
571}
572
573static void cmd_wall_hash(gpointer key, NICK_REC *nick, GSList **nicks)
574{
575 if (nick->op) *nicks = g_slist_append(*nicks, nick);
576}
577
578/* SYNTAX: WAIT [-<server tag>] <milliseconds> */
579static void cmd_wait(const char *data, IRC_SERVER_REC *server)
580{
581 GHashTable *optlist;
582 char *msecs;
583 void *free_arg;
584 int n;
585
586 CMD_IRC_SERVER(server)do { if (server != ((void *)0) && !(((IRC_SERVER_REC *
) chat_protocol_check_cast(((SERVER_REC *) module_check_cast(
server, __builtin_offsetof(SERVER_REC, type), "SERVER")), __builtin_offsetof
(IRC_SERVER_REC, chat_type), "IRC")) ? (!(0)) : (0))) return;
if (server == ((void *)0) || !(server)->connected) do { signal_emit
("error command", 1, ((gpointer) (CMDERR_NOT_CONNECTED))); signal_stop
(); return; } while (0); } while (0)
;
587
588 if (!cmd_get_params(data, &free_arg, 1 | PARAM_FLAG_OPTIONS0x00004000 |
589 PARAM_FLAG_UNKNOWN_OPTIONS0x00008000 | PARAM_FLAG_GETREST0x00002000,
590 NULL((void *)0), &optlist, &msecs))
591 return;
592
593 if (*msecs == '\0')
594 cmd_param_error(CMDERR_NOT_ENOUGH_PARAMS)do { cmd_params_free(free_arg); do { signal_emit("error command"
, 1, ((gpointer) (CMDERR_NOT_ENOUGH_PARAMS))); signal_stop();
return; } while (0); } while (0)
;
595
596 /* -<server tag> */
597 server = IRC_SERVER(cmd_options_get_server(NULL, optlist,((IRC_SERVER_REC *) chat_protocol_check_cast(((SERVER_REC *) module_check_cast
(cmd_options_get_server(((void *)0), optlist, ((SERVER_REC *)
module_check_cast(server, __builtin_offsetof(SERVER_REC, type
), "SERVER"))), __builtin_offsetof(SERVER_REC, type), "SERVER"
)), __builtin_offsetof(IRC_SERVER_REC, chat_type), "IRC"))
598 SERVER(server)))((IRC_SERVER_REC *) chat_protocol_check_cast(((SERVER_REC *) module_check_cast
(cmd_options_get_server(((void *)0), optlist, ((SERVER_REC *)
module_check_cast(server, __builtin_offsetof(SERVER_REC, type
), "SERVER"))), __builtin_offsetof(SERVER_REC, type), "SERVER"
)), __builtin_offsetof(IRC_SERVER_REC, chat_type), "IRC"))
;
599
600 n = atoi(msecs);
601 if (server != NULL((void *)0) && n > 0) {
602 g_get_current_time(&server->wait_cmd);
603 server->wait_cmd.tv_sec += n/1000;
604 server->wait_cmd.tv_usec += n%1000;
605 if (server->wait_cmd.tv_usec >= 1000) {
606 server->wait_cmd.tv_sec++;
607 server->wait_cmd.tv_usec -= 1000;
608 }
609 }
610 cmd_params_free(free_arg);
611}
612
613/* SYNTAX: WALL [<channel>] <message> */
614static void cmd_wall(const char *data, IRC_SERVER_REC *server, WI_ITEM_REC *item)
615{
616 char *channame, *msg, *args, *recoded;
617 void *free_arg;
618 IRC_CHANNEL_REC *chanrec;
619 GSList *tmp, *nicks;
620
621 CMD_IRC_SERVER(server)do { if (server != ((void *)0) && !(((IRC_SERVER_REC *
) chat_protocol_check_cast(((SERVER_REC *) module_check_cast(
server, __builtin_offsetof(SERVER_REC, type), "SERVER")), __builtin_offsetof
(IRC_SERVER_REC, chat_type), "IRC")) ? (!(0)) : (0))) return;
if (server == ((void *)0) || !(server)->connected) do { signal_emit
("error command", 1, ((gpointer) (CMDERR_NOT_CONNECTED))); signal_stop
(); return; } while (0); } while (0)
;
622
623 if (!cmd_get_params(data, &free_arg, 2 | PARAM_FLAG_OPTCHAN0x00010000 |
624 PARAM_FLAG_GETREST0x00002000, item, &channame, &msg))
625 return;
626 if (*msg == '\0') cmd_param_error(CMDERR_NOT_ENOUGH_PARAMS)do { cmd_params_free(free_arg); do { signal_emit("error command"
, 1, ((gpointer) (CMDERR_NOT_ENOUGH_PARAMS))); signal_stop();
return; } while (0); } while (0)
;
627
628 chanrec = irc_channel_find(server, channame)((IRC_CHANNEL_REC *) chat_protocol_check_cast(((CHANNEL_REC *
) module_check_cast_module(channel_find(((SERVER_REC *) module_check_cast
(server, __builtin_offsetof(SERVER_REC, type), "SERVER")), channame
), __builtin_offsetof(CHANNEL_REC, type), "WINDOW ITEM TYPE",
"CHANNEL")), __builtin_offsetof(IRC_CHANNEL_REC, chat_type),
"IRC"))
;
629 if (chanrec == NULL((void *)0)) cmd_param_error(CMDERR_CHAN_NOT_FOUND)do { cmd_params_free(free_arg); do { signal_emit("error command"
, 1, ((gpointer) (CMDERR_CHAN_NOT_FOUND))); signal_stop(); return
; } while (0); } while (0)
;
630
631 recoded = recode_out(SERVER(server)((SERVER_REC *) module_check_cast(server, __builtin_offsetof(
SERVER_REC, type), "SERVER"))
, msg, channame);
632 /* See if the server has advertised support of wallchops */
633 if (g_hash_table_lookup(chanrec->server->isupport, "statusmsg") ||
634 g_hash_table_lookup(chanrec->server->isupport, "wallchops"))
635 irc_send_cmdv(server, "NOTICE @%s :%s", chanrec->name, recoded);
636 else {
637 /* Fall back to manually noticing each op */
638 nicks = NULL((void *)0);
639 g_hash_table_foreach(chanrec->nicks,
640 (GHFunc) cmd_wall_hash, &nicks);
641
642 args = g_strconcat(chanrec->name, " ", recoded, NULL((void *)0));
643 msg = parse_special_string(settings_get_str("wall_format"),
644 SERVER(server)((SERVER_REC *) module_check_cast(server, __builtin_offsetof(
SERVER_REC, type), "SERVER"))
, item, args, NULL((void *)0), 0);
645 g_free(args);
646
647 for (tmp = nicks; tmp != NULL((void *)0); tmp = tmp->next) {
648 NICK_REC *rec = tmp->data;
649
650 if (rec != chanrec->ownnick) {
651 irc_send_cmdv(server, "NOTICE %s :%s",
652 rec->nick, msg);
653 }
654 }
655
656 g_free(msg);
657 g_slist_free(nicks);
658 }
659
660 g_free(recoded);
661 cmd_params_free(free_arg);
662}
663
664/* SYNTAX: KICKBAN [<channel>] <nicks> <reason> */
665static void cmd_kickban(const char *data, IRC_SERVER_REC *server,
666 WI_ITEM_REC *item)
667{
668 IRC_CHANNEL_REC *chanrec;
669 char *channel, *nicks, *reason, *kickcmd, *bancmd, *recoded;
670 char **nicklist, *spacenicks;
671 void *free_arg;
672
673 CMD_IRC_SERVER(server)do { if (server != ((void *)0) && !(((IRC_SERVER_REC *
) chat_protocol_check_cast(((SERVER_REC *) module_check_cast(
server, __builtin_offsetof(SERVER_REC, type), "SERVER")), __builtin_offsetof
(IRC_SERVER_REC, chat_type), "IRC")) ? (!(0)) : (0))) return;
if (server == ((void *)0) || !(server)->connected) do { signal_emit
("error command", 1, ((gpointer) (CMDERR_NOT_CONNECTED))); signal_stop
(); return; } while (0); } while (0)
;
674
675 if (!cmd_get_params(data, &free_arg, 3 | PARAM_FLAG_OPTCHAN0x00010000 | PARAM_FLAG_GETREST0x00002000,
676 item, &channel, &nicks, &reason))
677 return;
678
679 if (*channel == '\0' || *nicks == '\0')
680 cmd_param_error(CMDERR_NOT_ENOUGH_PARAMS)do { cmd_params_free(free_arg); do { signal_emit("error command"
, 1, ((gpointer) (CMDERR_NOT_ENOUGH_PARAMS))); signal_stop();
return; } while (0); } while (0)
;
681
682 chanrec = irc_channel_find(server, channel)((IRC_CHANNEL_REC *) chat_protocol_check_cast(((CHANNEL_REC *
) module_check_cast_module(channel_find(((SERVER_REC *) module_check_cast
(server, __builtin_offsetof(SERVER_REC, type), "SERVER")), channel
), __builtin_offsetof(CHANNEL_REC, type), "WINDOW ITEM TYPE",
"CHANNEL")), __builtin_offsetof(IRC_CHANNEL_REC, chat_type),
"IRC"))
;
683 if (chanrec == NULL((void *)0))
684 cmd_param_error(CMDERR_CHAN_NOT_FOUND)do { cmd_params_free(free_arg); do { signal_emit("error command"
, 1, ((gpointer) (CMDERR_CHAN_NOT_FOUND))); signal_stop(); return
; } while (0); } while (0)
;
685
686 nicklist = g_strsplit(nicks, ",", -1);
687 spacenicks = g_strjoinv(" ", nicklist);
688 g_strfreev(nicklist);
689
690 recoded = recode_out(SERVER(server)((SERVER_REC *) module_check_cast(server, __builtin_offsetof(
SERVER_REC, type), "SERVER"))
, reason, channel);
691 kickcmd = g_strdup_printf("%s %s %s", chanrec->name, nicks, recoded);
692 g_free(recoded);
693
694 bancmd = g_strdup_printf("%s %s", chanrec->name, spacenicks);
695 g_free(spacenicks);
696
697 if (settings_get_bool("kick_first_on_kickban")) {
698 signal_emit("command kick", 3, kickcmd, server, chanrec);
699 signal_emit("command ban", 3, bancmd, server, chanrec);
700 } else {
701 signal_emit("command ban", 3, bancmd, server, chanrec);
702 signal_emit("command kick", 3, kickcmd, server, chanrec);
703 }
704 g_free(kickcmd);
705 g_free(bancmd);
706
707 cmd_params_free(free_arg);
708}
709
710static void knockout_destroy(IRC_SERVER_REC *server, KNOCKOUT_REC *rec)
711{
712 server->knockoutlist = g_slist_remove(server->knockoutlist, rec);
713 g_free(rec->ban);
714 g_free(rec);
715}
716
717/* timeout function: knockout */
718static void knockout_timeout_server(IRC_SERVER_REC *server)
719{
720 GSList *tmp, *next;
721 time_t now;
722
723 g_return_if_fail(server != NULL)do{ if (server != ((void *)0)) { } else { g_return_if_fail_warning
(((gchar*) 0), __PRETTY_FUNCTION__, "server != NULL"); return
; }; }while (0)
;
724
725 if (!IS_IRC_SERVER(server)(((IRC_SERVER_REC *) chat_protocol_check_cast(((SERVER_REC *)
module_check_cast(server, __builtin_offsetof(SERVER_REC, type
), "SERVER")), __builtin_offsetof(IRC_SERVER_REC, chat_type),
"IRC")) ? (!(0)) : (0))
)
726 return;
727
728 now = time(NULL((void *)0));
729 for (tmp = server->knockoutlist; tmp != NULL((void *)0); tmp = next) {
730 KNOCKOUT_REC *rec = tmp->data;
731
732 next = tmp->next;
733 if (rec->unban_time <= now) {
734 /* timeout, unban. */
735 ban_remove(rec->channel, rec->ban);
736 knockout_destroy(server, rec);
737 }
738 }
739}
740
741static int knockout_timeout(void)
742{
743 g_slist_foreach(servers, (GFunc) knockout_timeout_server, NULL((void *)0));
744 return 1;
745}
746
747/* SYNTAX: KNOCKOUT [<time>] <nicks> <reason> */
748static void cmd_knockout(const char *data, IRC_SERVER_REC *server,
749 IRC_CHANNEL_REC *channel)
750{
751 KNOCKOUT_REC *rec;
752 char *nicks, *reason, *timeoutstr, *kickcmd, *bancmd, *recoded;
753 char **nicklist, *spacenicks, *banmasks;
754 void *free_arg;
755 int timeleft;
756 GSList *ptr;
757
758 CMD_IRC_SERVER(server)do { if (server != ((void *)0) && !(((IRC_SERVER_REC *
) chat_protocol_check_cast(((SERVER_REC *) module_check_cast(
server, __builtin_offsetof(SERVER_REC, type), "SERVER")), __builtin_offsetof
(IRC_SERVER_REC, chat_type), "IRC")) ? (!(0)) : (0))) return;
if (server == ((void *)0) || !(server)->connected) do { signal_emit
("error command", 1, ((gpointer) (CMDERR_NOT_CONNECTED))); signal_stop
(); return; } while (0); } while (0)
;
759
760 if (!IS_IRC_CHANNEL(channel)(((IRC_CHANNEL_REC *) chat_protocol_check_cast(((CHANNEL_REC *
) module_check_cast_module(channel, __builtin_offsetof(CHANNEL_REC
, type), "WINDOW ITEM TYPE", "CHANNEL")), __builtin_offsetof(
IRC_CHANNEL_REC, chat_type), "IRC")) ? (!(0)) : (0))
)
761 cmd_return_error(CMDERR_NOT_JOINED)do { signal_emit("error command", 1, ((gpointer) (CMDERR_NOT_JOINED
))); signal_stop(); return; } while (0)
;
762
763 if (i_isdigit(*data)__isctype(((int) (unsigned char) (*data)), 0x00000400L)) {
764 /* first argument is the timeout */
765 if (!cmd_get_params(data, &free_arg, 3 | PARAM_FLAG_GETREST0x00002000,
766 &timeoutstr, &nicks, &reason))
767 return;
768
769 if (!parse_time_interval(timeoutstr, &timeleft))
770 cmd_param_error(CMDERR_INVALID_TIME)do { cmd_params_free(free_arg); do { signal_emit("error command"
, 1, ((gpointer) (CMDERR_INVALID_TIME))); signal_stop(); return
; } while (0); } while (0)
;
771 } else {
772 if (!cmd_get_params(data, &free_arg, 2 | PARAM_FLAG_GETREST0x00002000,
773 &nicks, &reason))
774 return;
775 timeleft = settings_get_time("knockout_time");
776 }
777
778 if (*nicks == '\0') cmd_param_error(CMDERR_NOT_ENOUGH_PARAMS)do { cmd_params_free(free_arg); do { signal_emit("error command"
, 1, ((gpointer) (CMDERR_NOT_ENOUGH_PARAMS))); signal_stop();
return; } while (0); } while (0)
;
779
780 nicklist = g_strsplit(nicks, ",", -1);
781 spacenicks = g_strjoinv(" ", nicklist);
782 g_strfreev(nicklist);
783
784 banmasks = ban_get_masks(channel, spacenicks, 0);
785 g_free(spacenicks);
786
787 recoded = recode_out(SERVER(server)((SERVER_REC *) module_check_cast(server, __builtin_offsetof(
SERVER_REC, type), "SERVER"))
, reason, channel->name);
788 kickcmd = g_strdup_printf("%s %s %s", channel->name, nicks, recoded);
789 g_free(recoded);
790
791 bancmd = *banmasks == '\0'? NULL((void *)0) :
792 g_strdup_printf("%s %s", channel->name, banmasks);
793
794 if (settings_get_bool("kick_first_on_kickban")) {
795 signal_emit("command kick", 3, kickcmd, server, channel);
796 if (bancmd != NULL((void *)0))
797 signal_emit("command ban", 3, bancmd, server, channel);
798 } else {
799 if (bancmd != NULL((void *)0))
800 signal_emit("command ban", 3, bancmd, server, channel);
801 signal_emit("command kick", 3, kickcmd, server, channel);
802 }
803 g_free(kickcmd);
804 g_free_not_null(bancmd)g_free(bancmd);
805
806 if (*banmasks == '\0')
807 g_free(banmasks);
808 else {
809 /* check if we already have this knockout */
810 for (ptr = server->knockoutlist; ptr != NULL((void *)0); ptr = ptr->next) {
811 rec = ptr->data;
812 if (channel == rec->channel &&
813 !strcmp(rec->ban, banmasks))
814 break;
815 }
816 if (ptr == NULL((void *)0)) {
817 rec = g_new(KNOCKOUT_REC, 1)((KNOCKOUT_REC *) g_malloc (((gsize) sizeof (KNOCKOUT_REC)) *
((gsize) (1))))
;
818 rec->channel = channel;
819 rec->ban = banmasks;
820 server->knockoutlist = g_slist_append(server->knockoutlist, rec);
821 }
822 rec->unban_time = time(NULL((void *)0))+timeleft/1000;
823 }
824
825 cmd_params_free(free_arg);
826}
827
828/* SYNTAX: SERVER PURGE [<target>] */
829static void cmd_server_purge(const char *data, IRC_SERVER_REC *server)
830{
831 char *target;
832 void *free_arg;
833
834 CMD_IRC_SERVER(server)do { if (server != ((void *)0) && !(((IRC_SERVER_REC *
) chat_protocol_check_cast(((SERVER_REC *) module_check_cast(
server, __builtin_offsetof(SERVER_REC, type), "SERVER")), __builtin_offsetof
(IRC_SERVER_REC, chat_type), "IRC")) ? (!(0)) : (0))) return;
if (server == ((void *)0) || !(server)->connected) do { signal_emit
("error command", 1, ((gpointer) (CMDERR_NOT_CONNECTED))); signal_stop
(); return; } while (0); } while (0)
;
835
836 if (!cmd_get_params(data, &free_arg, 1, &target))
837 return;
838
839 irc_server_purge_output(server, *target == '\0' ? NULL((void *)0) : target);
840
841 cmd_params_free(free_arg);
842}
843
844/* destroy all knockouts in server */
845static void sig_server_disconnected(IRC_SERVER_REC *server)
846{
847 g_return_if_fail(server != NULL)do{ if (server != ((void *)0)) { } else { g_return_if_fail_warning
(((gchar*) 0), __PRETTY_FUNCTION__, "server != NULL"); return
; }; }while (0)
;
848
849 if (!IS_IRC_SERVER(server)(((IRC_SERVER_REC *) chat_protocol_check_cast(((SERVER_REC *)
module_check_cast(server, __builtin_offsetof(SERVER_REC, type
), "SERVER")), __builtin_offsetof(IRC_SERVER_REC, chat_type),
"IRC")) ? (!(0)) : (0))
)
850 return;
851
852 g_free(server->last_nick);
853
854 while (server->knockoutlist != NULL((void *)0))
855 knockout_destroy(server, server->knockoutlist->data);
856}
857
858/* destroy all knockouts in channel */
859static void sig_channel_destroyed(IRC_CHANNEL_REC *channel)
860{
861 GSList *tmp, *next;
862
863 if (!IS_IRC_CHANNEL(channel)(((IRC_CHANNEL_REC *) chat_protocol_check_cast(((CHANNEL_REC *
) module_check_cast_module(channel, __builtin_offsetof(CHANNEL_REC
, type), "WINDOW ITEM TYPE", "CHANNEL")), __builtin_offsetof(
IRC_CHANNEL_REC, chat_type), "IRC")) ? (!(0)) : (0))
|| !IS_IRC_SERVER(channel->server)(((IRC_SERVER_REC *) chat_protocol_check_cast(((SERVER_REC *)
module_check_cast(channel->server, __builtin_offsetof(SERVER_REC
, type), "SERVER")), __builtin_offsetof(IRC_SERVER_REC, chat_type
), "IRC")) ? (!(0)) : (0))
)
864 return;
865
866 for (tmp = channel->server->knockoutlist; tmp != NULL((void *)0); tmp = next) {
867 KNOCKOUT_REC *rec = tmp->data;
868
869 next = tmp->next;
870 if (rec->channel == channel)
871 knockout_destroy(channel->server, rec);
872 }
873}
874
875/* SYNTAX: OPER [<nick> [<password>]] */
876static void cmd_oper(const char *data, IRC_SERVER_REC *server)
877{
878 char *nick, *password;
879 void *free_arg;
880
881 CMD_IRC_SERVER(server)do { if (server != ((void *)0) && !(((IRC_SERVER_REC *
) chat_protocol_check_cast(((SERVER_REC *) module_check_cast(
server, __builtin_offsetof(SERVER_REC, type), "SERVER")), __builtin_offsetof
(IRC_SERVER_REC, chat_type), "IRC")) ? (!(0)) : (0))) return;
if (server == ((void *)0) || !(server)->connected) do { signal_emit
("error command", 1, ((gpointer) (CMDERR_NOT_CONNECTED))); signal_stop
(); return; } while (0); } while (0)
;
882
883 /* asking for password is handled by fe-common */
884 if (!cmd_get_params(data, &free_arg, 2, &nick, &password))
885 return;
886 if (*password == '\0') cmd_param_error(CMDERR_NOT_ENOUGH_PARAMS)do { cmd_params_free(free_arg); do { signal_emit("error command"
, 1, ((gpointer) (CMDERR_NOT_ENOUGH_PARAMS))); signal_stop();
return; } while (0); } while (0)
;
887
888 irc_send_cmdv(server, "OPER %s %s", nick, password);
889 cmd_params_free(free_arg);
890}
891
892/* SYNTAX: ACCEPT [[-]nick,...] */
893static void cmd_accept(const char *data, IRC_SERVER_REC *server)
894{
895 CMD_IRC_SERVER(server)do { if (server != ((void *)0) && !(((IRC_SERVER_REC *
) chat_protocol_check_cast(((SERVER_REC *) module_check_cast(
server, __builtin_offsetof(SERVER_REC, type), "SERVER")), __builtin_offsetof
(IRC_SERVER_REC, chat_type), "IRC")) ? (!(0)) : (0))) return;
if (server == ((void *)0) || !(server)->connected) do { signal_emit
("error command", 1, ((gpointer) (CMDERR_NOT_CONNECTED))); signal_stop
(); return; } while (0); } while (0)
;
896
897 if (*data == '\0')
898 irc_send_cmd(server, "ACCEPT *");
899 else
900 irc_send_cmdv(server, "ACCEPT %s", data);
901}
902
903/* SYNTAX: UNSILENCE <nick!user@host> */
904static void cmd_unsilence(const char *data, IRC_SERVER_REC *server)
905{
906 CMD_IRC_SERVER(server)do { if (server != ((void *)0) && !(((IRC_SERVER_REC *
) chat_protocol_check_cast(((SERVER_REC *) module_check_cast(
server, __builtin_offsetof(SERVER_REC, type), "SERVER")), __builtin_offsetof
(IRC_SERVER_REC, chat_type), "IRC")) ? (!(0)) : (0))) return;
if (server == ((void *)0) || !(server)->connected) do { signal_emit
("error command", 1, ((gpointer) (CMDERR_NOT_CONNECTED))); signal_stop
(); return; } while (0); } while (0)
;
907
908 if (*data == '\0')
909 cmd_return_error(CMDERR_NOT_ENOUGH_PARAMS)do { signal_emit("error command", 1, ((gpointer) (CMDERR_NOT_ENOUGH_PARAMS
))); signal_stop(); return; } while (0)
;
910
911 irc_send_cmdv(server, "SILENCE -%s", data);
912}
913
914static void command_self(const char *data, IRC_SERVER_REC *server)
915{
916 CMD_IRC_SERVER(server)do { if (server != ((void *)0) && !(((IRC_SERVER_REC *
) chat_protocol_check_cast(((SERVER_REC *) module_check_cast(
server, __builtin_offsetof(SERVER_REC, type), "SERVER")), __builtin_offsetof
(IRC_SERVER_REC, chat_type), "IRC")) ? (!(0)) : (0))) return;
if (server == ((void *)0) || !(server)->connected) do { signal_emit
("error command", 1, ((gpointer) (CMDERR_NOT_CONNECTED))); signal_stop
(); return; } while (0); } while (0)
;
917
918 irc_send_cmdv(server, *data == '\0' ? "%s" : "%s %s", current_command, data);
919}
920
921static void command_1self(const char *data, IRC_SERVER_REC *server)
922{
923 g_return_if_fail(data != NULL)do{ if (data != ((void *)0)) { } else { g_return_if_fail_warning
(((gchar*) 0), __PRETTY_FUNCTION__, "data != NULL"); return;
}; }while (0)
;
924 if (!IS_IRC_SERVER(server)(((IRC_SERVER_REC *) chat_protocol_check_cast(((SERVER_REC *)
module_check_cast(server, __builtin_offsetof(SERVER_REC, type
), "SERVER")), __builtin_offsetof(IRC_SERVER_REC, chat_type),
"IRC")) ? (!(0)) : (0))
|| !server->connected)
925 cmd_return_error(CMDERR_NOT_CONNECTED)do { signal_emit("error command", 1, ((gpointer) (CMDERR_NOT_CONNECTED
))); signal_stop(); return; } while (0)
;
926 if (*data == '\0') cmd_return_error(CMDERR_NOT_ENOUGH_PARAMS)do { signal_emit("error command", 1, ((gpointer) (CMDERR_NOT_ENOUGH_PARAMS
))); signal_stop(); return; } while (0)
;
927
928 irc_send_cmdv(server, "%s :%s", current_command, data);
929}
930
931static void command_2self(const char *data, IRC_SERVER_REC *server)
932{
933 char *target, *text;
934 void *free_arg;
935
936 CMD_IRC_SERVER(server)do { if (server != ((void *)0) && !(((IRC_SERVER_REC *
) chat_protocol_check_cast(((SERVER_REC *) module_check_cast(
server, __builtin_offsetof(SERVER_REC, type), "SERVER")), __builtin_offsetof
(IRC_SERVER_REC, chat_type), "IRC")) ? (!(0)) : (0))) return;
if (server == ((void *)0) || !(server)->connected) do { signal_emit
("error command", 1, ((gpointer) (CMDERR_NOT_CONNECTED))); signal_stop
(); return; } while (0); } while (0)
;
937
938 if (!cmd_get_params(data, &free_arg, 2 | PARAM_FLAG_GETREST0x00002000, &target, &text))
939 return;
940 if (*target == '\0') cmd_param_error(CMDERR_NOT_ENOUGH_PARAMS)do { cmd_params_free(free_arg); do { signal_emit("error command"
, 1, ((gpointer) (CMDERR_NOT_ENOUGH_PARAMS))); signal_stop();
return; } while (0); } while (0)
;
941 irc_send_cmdv(server, "%s %s :%s", current_command, target, text);
942 cmd_params_free(free_arg);
943}
944
945void irc_commands_init(void)
946{
947 tmpstr = g_string_new(NULL((void *)0));
948
949 settings_add_str("misc", "part_message", "")settings_add_str_module("irc/core", "misc", "part_message", ""
)
;
950 settings_add_time("misc", "knockout_time", "5min")settings_add_time_module("irc/core", "misc", "knockout_time",
"5min")
;
951 settings_add_str("misc", "wall_format", "[Wall/$0] $1-")settings_add_str_module("irc/core", "misc", "wall_format", "[Wall/$0] $1-"
)
;
952 settings_add_bool("misc", "kick_first_on_kickban", FALSE)settings_add_bool_module("irc/core", "misc", "kick_first_on_kickban"
, (0))
;
953 settings_add_bool("misc", "auto_whowas", TRUE)settings_add_bool_module("irc/core", "misc", "auto_whowas", (
!(0)))
;
954
955 knockout_tag = g_timeout_add(KNOCKOUT_TIMECHECK10000, (GSourceFunc) knockout_timeout, NULL((void *)0));
956
957 command_bind_irc("notice", NULL, (SIGNAL_FUNC) cmd_notice)command_bind_full("irc/core", 0, "notice", (chat_protocol_lookup
("IRC")), ((void *)0), (SIGNAL_FUNC) cmd_notice, ((void *)0))
;
958 command_bind_irc("ctcp", NULL, (SIGNAL_FUNC) cmd_ctcp)command_bind_full("irc/core", 0, "ctcp", (chat_protocol_lookup
("IRC")), ((void *)0), (SIGNAL_FUNC) cmd_ctcp, ((void *)0))
;
959 command_bind_irc("nctcp", NULL, (SIGNAL_FUNC) cmd_nctcp)command_bind_full("irc/core", 0, "nctcp", (chat_protocol_lookup
("IRC")), ((void *)0), (SIGNAL_FUNC) cmd_nctcp, ((void *)0))
;
960 command_bind_irc("part", NULL, (SIGNAL_FUNC) cmd_part)command_bind_full("irc/core", 0, "part", (chat_protocol_lookup
("IRC")), ((void *)0), (SIGNAL_FUNC) cmd_part, ((void *)0))
;
961 command_bind_irc("kick", NULL, (SIGNAL_FUNC) cmd_kick)command_bind_full("irc/core", 0, "kick", (chat_protocol_lookup
("IRC")), ((void *)0), (SIGNAL_FUNC) cmd_kick, ((void *)0))
;
962 command_bind_irc("topic", NULL, (SIGNAL_FUNC) cmd_topic)command_bind_full("irc/core", 0, "topic", (chat_protocol_lookup
("IRC")), ((void *)0), (SIGNAL_FUNC) cmd_topic, ((void *)0))
;
963 command_bind_irc("invite", NULL, (SIGNAL_FUNC) cmd_invite)command_bind_full("irc/core", 0, "invite", (chat_protocol_lookup
("IRC")), ((void *)0), (SIGNAL_FUNC) cmd_invite, ((void *)0))
;
964 command_bind_irc("list", NULL, (SIGNAL_FUNC) cmd_list)command_bind_full("irc/core", 0, "list", (chat_protocol_lookup
("IRC")), ((void *)0), (SIGNAL_FUNC) cmd_list, ((void *)0))
;
965 command_bind_irc("who", NULL, (SIGNAL_FUNC) cmd_who)command_bind_full("irc/core", 0, "who", (chat_protocol_lookup
("IRC")), ((void *)0), (SIGNAL_FUNC) cmd_who, ((void *)0))
;
966 command_bind_irc("names", NULL, (SIGNAL_FUNC) cmd_names)command_bind_full("irc/core", 0, "names", (chat_protocol_lookup
("IRC")), ((void *)0), (SIGNAL_FUNC) cmd_names, ((void *)0))
;
967 command_bind_irc("nick", NULL, (SIGNAL_FUNC) cmd_nick)command_bind_full("irc/core", 0, "nick", (chat_protocol_lookup
("IRC")), ((void *)0), (SIGNAL_FUNC) cmd_nick, ((void *)0))
;
968 /* SYNTAX: NOTE <command> [&<password>] [+|-<flags>] [<arguments>] */
969 command_bind_irc("note", NULL, (SIGNAL_FUNC) command_self)command_bind_full("irc/core", 0, "note", (chat_protocol_lookup
("IRC")), ((void *)0), (SIGNAL_FUNC) command_self, ((void *)0
))
;
970 command_bind_irc("whois", NULL, (SIGNAL_FUNC) cmd_whois)command_bind_full("irc/core", 0, "whois", (chat_protocol_lookup
("IRC")), ((void *)0), (SIGNAL_FUNC) cmd_whois, ((void *)0))
;
971 command_bind_irc("whowas", NULL, (SIGNAL_FUNC) cmd_whowas)command_bind_full("irc/core", 0, "whowas", (chat_protocol_lookup
("IRC")), ((void *)0), (SIGNAL_FUNC) cmd_whowas, ((void *)0))
;
972 command_bind_irc("ping", NULL, (SIGNAL_FUNC) cmd_ping)command_bind_full("irc/core", 0, "ping", (chat_protocol_lookup
("IRC")), ((void *)0), (SIGNAL_FUNC) cmd_ping, ((void *)0))
;
973 /* SYNTAX: KILL <nick> <reason> */
974 command_bind_irc("kill", NULL, (SIGNAL_FUNC) command_2self)command_bind_full("irc/core", 0, "kill", (chat_protocol_lookup
("IRC")), ((void *)0), (SIGNAL_FUNC) command_2self, ((void *)
0))
;
975 command_bind_irc("away", NULL, (SIGNAL_FUNC) cmd_away)command_bind_full("irc/core", 0, "away", (chat_protocol_lookup
("IRC")), ((void *)0), (SIGNAL_FUNC) cmd_away, ((void *)0))
;
976 /* SYNTAX: ISON <nicks> */
977 command_bind_irc("ison", NULL, (SIGNAL_FUNC) command_1self)command_bind_full("irc/core", 0, "ison", (chat_protocol_lookup
("IRC")), ((void *)0), (SIGNAL_FUNC) command_1self, ((void *)
0))
;
978 command_bind_irc("accept", NULL, (SIGNAL_FUNC) cmd_accept)command_bind_full("irc/core", 0, "accept", (chat_protocol_lookup
("IRC")), ((void *)0), (SIGNAL_FUNC) cmd_accept, ((void *)0))
;
979 /* SYNTAX: ADMIN [<server>|<nickname>] */
980 command_bind_irc("admin", NULL, (SIGNAL_FUNC) command_self)command_bind_full("irc/core", 0, "admin", (chat_protocol_lookup
("IRC")), ((void *)0), (SIGNAL_FUNC) command_self, ((void *)0
))
;
981 /* SYNTAX: INFO [<server>] */
982 command_bind_irc("info", NULL, (SIGNAL_FUNC) command_self)command_bind_full("irc/core", 0, "info", (chat_protocol_lookup
("IRC")), ((void *)0), (SIGNAL_FUNC) command_self, ((void *)0
))
;
983 /* SYNTAX: KNOCK <channel> */
984 command_bind_irc("knock", NULL, (SIGNAL_FUNC) command_self)command_bind_full("irc/core", 0, "knock", (chat_protocol_lookup
("IRC")), ((void *)0), (SIGNAL_FUNC) command_self, ((void *)0
))
;
985 /* SYNTAX: LINKS [[<server>] <mask>] */
986 command_bind_irc("links", NULL, (SIGNAL_FUNC) command_self)command_bind_full("irc/core", 0, "links", (chat_protocol_lookup
("IRC")), ((void *)0), (SIGNAL_FUNC) command_self, ((void *)0
))
;
987 /* SYNTAX: LUSERS [<server mask> [<remote server>]] */
988 command_bind_irc("lusers", NULL, (SIGNAL_FUNC) command_self)command_bind_full("irc/core", 0, "lusers", (chat_protocol_lookup
("IRC")), ((void *)0), (SIGNAL_FUNC) command_self, ((void *)0
))
;
989 /* SYNTAX: MAP */
990 command_bind_irc("map", NULL, (SIGNAL_FUNC) command_self)command_bind_full("irc/core", 0, "map", (chat_protocol_lookup
("IRC")), ((void *)0), (SIGNAL_FUNC) command_self, ((void *)0
))
;
991 /* SYNTAX: MOTD [<server>|<nick>] */
992 command_bind_irc("motd", NULL, (SIGNAL_FUNC) command_self)command_bind_full("irc/core", 0, "motd", (chat_protocol_lookup
("IRC")), ((void *)0), (SIGNAL_FUNC) command_self, ((void *)0
))
;
993 /* SYNTAX: REHASH [<option>] */
994 command_bind_irc("rehash", NULL, (SIGNAL_FUNC) command_self)command_bind_full("irc/core", 0, "rehash", (chat_protocol_lookup
("IRC")), ((void *)0), (SIGNAL_FUNC) command_self, ((void *)0
))
;
995 /* SYNTAX: STATS <type> [<server>] */
996 command_bind_irc("stats", NULL, (SIGNAL_FUNC) command_self)command_bind_full("irc/core", 0, "stats", (chat_protocol_lookup
("IRC")), ((void *)0), (SIGNAL_FUNC) command_self, ((void *)0
))
;
997 /* SYNTAX: TIME [<server>|<nick>] */
998 command_bind_irc("time", NULL, (SIGNAL_FUNC) command_self)command_bind_full("irc/core", 0, "time", (chat_protocol_lookup
("IRC")), ((void *)0), (SIGNAL_FUNC) command_self, ((void *)0
))
;
999 /* SYNTAX: TRACE [<server>|<nick>] */
1000 command_bind_irc("trace", NULL, (SIGNAL_FUNC) command_self)command_bind_full("irc/core", 0, "trace", (chat_protocol_lookup
("IRC")), ((void *)0), (SIGNAL_FUNC) command_self, ((void *)0
))
;
1001 /* SYNTAX: VERSION [<server>|<nick>] */
1002 command_bind_irc("version", NULL, (SIGNAL_FUNC) command_self)command_bind_full("irc/core", 0, "version", (chat_protocol_lookup
("IRC")), ((void *)0), (SIGNAL_FUNC) command_self, ((void *)0
))
;
1003 /* SYNTAX: SERVLIST [<server mask>] */
1004 command_bind_irc("servlist", NULL, (SIGNAL_FUNC) command_self)command_bind_full("irc/core", 0, "servlist", (chat_protocol_lookup
("IRC")), ((void *)0), (SIGNAL_FUNC) command_self, ((void *)0
))
;
1005 /* SYNTAX: SILENCE [[+|-]<nick!user@host>]
1006 SILENCE [<nick>] */
1007 command_bind_irc("silence", NULL, (SIGNAL_FUNC) command_self)command_bind_full("irc/core", 0, "silence", (chat_protocol_lookup
("IRC")), ((void *)0), (SIGNAL_FUNC) command_self, ((void *)0
))
;
1008 command_bind_irc("unsilence", NULL, (SIGNAL_FUNC) cmd_unsilence)command_bind_full("irc/core", 0, "unsilence", (chat_protocol_lookup
("IRC")), ((void *)0), (SIGNAL_FUNC) cmd_unsilence, ((void *)
0))
;
1009 command_bind_irc("sconnect", NULL, (SIGNAL_FUNC) cmd_sconnect)command_bind_full("irc/core", 0, "sconnect", (chat_protocol_lookup
("IRC")), ((void *)0), (SIGNAL_FUNC) cmd_sconnect, ((void *)0
))
;
1010 /* SYNTAX: SQUERY <service> [<commands>] */
1011 command_bind_irc("squery", NULL, (SIGNAL_FUNC) command_2self)command_bind_full("irc/core", 0, "squery", (chat_protocol_lookup
("IRC")), ((void *)0), (SIGNAL_FUNC) command_2self, ((void *)
0))
;
1012 /* SYNTAX: DIE */
1013 command_bind_irc("die", NULL, (SIGNAL_FUNC) command_self)command_bind_full("irc/core", 0, "die", (chat_protocol_lookup
("IRC")), ((void *)0), (SIGNAL_FUNC) command_self, ((void *)0
))
;
1014 /* SYNTAX: HASH */
1015 command_bind_irc("hash", NULL, (SIGNAL_FUNC) command_self)command_bind_full("irc/core", 0, "hash", (chat_protocol_lookup
("IRC")), ((void *)0), (SIGNAL_FUNC) command_self, ((void *)0
))
;
1016 command_bind_irc("oper", NULL, (SIGNAL_FUNC) cmd_oper)command_bind_full("irc/core", 0, "oper", (chat_protocol_lookup
("IRC")), ((void *)0), (SIGNAL_FUNC) cmd_oper, ((void *)0))
;
1017 /* SYNTAX: RESTART */
1018 command_bind_irc("restart", NULL, (SIGNAL_FUNC) command_self)command_bind_full("irc/core", 0, "restart", (chat_protocol_lookup
("IRC")), ((void *)0), (SIGNAL_FUNC) command_self, ((void *)0
))
;
1019 /* SYNTAX: RPING <server> */
1020 command_bind_irc("rping", NULL, (SIGNAL_FUNC) command_self)command_bind_full("irc/core", 0, "rping", (chat_protocol_lookup
("IRC")), ((void *)0), (SIGNAL_FUNC) command_self, ((void *)0
))
;
1021 /* SYNTAX: SQUIT <server>|<mask> <reason> */
1022 command_bind_irc("squit", NULL, (SIGNAL_FUNC) command_2self)command_bind_full("irc/core", 0, "squit", (chat_protocol_lookup
("IRC")), ((void *)0), (SIGNAL_FUNC) command_2self, ((void *)
0))
;
1023 /* SYNTAX: UPING <server> */
1024 command_bind_irc("uping", NULL, (SIGNAL_FUNC) command_self)command_bind_full("irc/core", 0, "uping", (chat_protocol_lookup
("IRC")), ((void *)0), (SIGNAL_FUNC) command_self, ((void *)0
))
;
1025 /* SYNTAX: USERHOST <nicks> */
1026 command_bind_irc("userhost", NULL, (SIGNAL_FUNC) command_self)command_bind_full("irc/core", 0, "userhost", (chat_protocol_lookup
("IRC")), ((void *)0), (SIGNAL_FUNC) command_self, ((void *)0
))
;
1027 command_bind_irc("quote", NULL, (SIGNAL_FUNC) cmd_quote)command_bind_full("irc/core", 0, "quote", (chat_protocol_lookup
("IRC")), ((void *)0), (SIGNAL_FUNC) cmd_quote, ((void *)0))
;
1028 command_bind_irc("wall", NULL, (SIGNAL_FUNC) cmd_wall)command_bind_full("irc/core", 0, "wall", (chat_protocol_lookup
("IRC")), ((void *)0), (SIGNAL_FUNC) cmd_wall, ((void *)0))
;
1029 command_bind_irc("wait", NULL, (SIGNAL_FUNC) cmd_wait)command_bind_full("irc/core", 0, "wait", (chat_protocol_lookup
("IRC")), ((void *)0), (SIGNAL_FUNC) cmd_wait, ((void *)0))
;
1030 /* SYNTAX: WALLOPS <message> */
1031 command_bind_irc("wallops", NULL, (SIGNAL_FUNC) command_1self)command_bind_full("irc/core", 0, "wallops", (chat_protocol_lookup
("IRC")), ((void *)0), (SIGNAL_FUNC) command_1self, ((void *)
0))
;
1032 command_bind_irc("kickban", NULL, (SIGNAL_FUNC) cmd_kickban)command_bind_full("irc/core", 0, "kickban", (chat_protocol_lookup
("IRC")), ((void *)0), (SIGNAL_FUNC) cmd_kickban, ((void *)0)
)
;
1033 command_bind_irc("knockout", NULL, (SIGNAL_FUNC) cmd_knockout)command_bind_full("irc/core", 0, "knockout", (chat_protocol_lookup
("IRC")), ((void *)0), (SIGNAL_FUNC) cmd_knockout, ((void *)0
))
;
1034 command_bind_irc("server purge", NULL, (SIGNAL_FUNC) cmd_server_purge)command_bind_full("irc/core", 0, "server purge", (chat_protocol_lookup
("IRC")), ((void *)0), (SIGNAL_FUNC) cmd_server_purge, ((void
*)0))
;
1035
1036 signal_add("channel destroyed", (SIGNAL_FUNC) sig_channel_destroyed)signal_add_full("irc/core", 0, ("channel destroyed"), (SIGNAL_FUNC
) ((SIGNAL_FUNC) sig_channel_destroyed), ((void *)0))
;
1037 signal_add("server disconnected", (SIGNAL_FUNC) sig_server_disconnected)signal_add_full("irc/core", 0, ("server disconnected"), (SIGNAL_FUNC
) ((SIGNAL_FUNC) sig_server_disconnected), ((void *)0))
;
1038 signal_add("whois try whowas", (SIGNAL_FUNC) sig_whois_try_whowas)signal_add_full("irc/core", 0, ("whois try whowas"), (SIGNAL_FUNC
) ((SIGNAL_FUNC) sig_whois_try_whowas), ((void *)0))
;
1039 signal_add("whois event", (SIGNAL_FUNC) event_whois)signal_add_full("irc/core", 0, ("whois event"), (SIGNAL_FUNC)
((SIGNAL_FUNC) event_whois), ((void *)0))
;
1040 signal_add("whois end", (SIGNAL_FUNC) event_end_of_whois)signal_add_full("irc/core", 0, ("whois end"), (SIGNAL_FUNC) (
(SIGNAL_FUNC) event_end_of_whois), ((void *)0))
;
1041 signal_add("whowas event", (SIGNAL_FUNC) event_whowas)signal_add_full("irc/core", 0, ("whowas event"), (SIGNAL_FUNC
) ((SIGNAL_FUNC) event_whowas), ((void *)0))
;
1042
1043 command_set_options("connect", "+ircnet")command_set_options_module("irc/core", "connect", "+ircnet");
1044 command_set_options("topic", "delete")command_set_options_module("irc/core", "topic", "delete");
1045 command_set_options("list", "yes")command_set_options_module("irc/core", "list", "yes");
1046 command_set_options("away", "one all")command_set_options_module("irc/core", "away", "one all");
1047 command_set_options("whois", "yes")command_set_options_module("irc/core", "whois", "yes");
1048}
1049
1050void irc_commands_deinit(void)
1051{
1052 g_source_remove(knockout_tag);
1053
1054 command_unbind("notice", (SIGNAL_FUNC) cmd_notice)command_unbind_full("notice", (SIGNAL_FUNC) cmd_notice, ((void
*)0))
;
1055 command_unbind("ctcp", (SIGNAL_FUNC) cmd_ctcp)command_unbind_full("ctcp", (SIGNAL_FUNC) cmd_ctcp, ((void *)
0))
;
1056 command_unbind("nctcp", (SIGNAL_FUNC) cmd_nctcp)command_unbind_full("nctcp", (SIGNAL_FUNC) cmd_nctcp, ((void *
)0))
;
1057 command_unbind("part", (SIGNAL_FUNC) cmd_part)command_unbind_full("part", (SIGNAL_FUNC) cmd_part, ((void *)
0))
;
1058 command_unbind("kick", (SIGNAL_FUNC) cmd_kick)command_unbind_full("kick", (SIGNAL_FUNC) cmd_kick, ((void *)
0))
;
1059 command_unbind("topic", (SIGNAL_FUNC) cmd_topic)command_unbind_full("topic", (SIGNAL_FUNC) cmd_topic, ((void *
)0))
;
1060 command_unbind("invite", (SIGNAL_FUNC) cmd_invite)command_unbind_full("invite", (SIGNAL_FUNC) cmd_invite, ((void
*)0))
;
1061 command_unbind("list", (SIGNAL_FUNC) cmd_list)command_unbind_full("list", (SIGNAL_FUNC) cmd_list, ((void *)
0))
;
1062 command_unbind("who", (SIGNAL_FUNC) cmd_who)command_unbind_full("who", (SIGNAL_FUNC) cmd_who, ((void *)0)
)
;
1063 command_unbind("names", (SIGNAL_FUNC) cmd_names)command_unbind_full("names", (SIGNAL_FUNC) cmd_names, ((void *
)0))
;
1064 command_unbind("nick", (SIGNAL_FUNC) cmd_nick)command_unbind_full("nick", (SIGNAL_FUNC) cmd_nick, ((void *)
0))
;
1065 command_unbind("note", (SIGNAL_FUNC) command_self)command_unbind_full("note", (SIGNAL_FUNC) command_self, ((void
*)0))
;
1066 command_unbind("whois", (SIGNAL_FUNC) cmd_whois)command_unbind_full("whois", (SIGNAL_FUNC) cmd_whois, ((void *
)0))
;
1067 command_unbind("whowas", (SIGNAL_FUNC) cmd_whowas)command_unbind_full("whowas", (SIGNAL_FUNC) cmd_whowas, ((void
*)0))
;
1068 command_unbind("ping", (SIGNAL_FUNC) cmd_ping)command_unbind_full("ping", (SIGNAL_FUNC) cmd_ping, ((void *)
0))
;
1069 command_unbind("kill", (SIGNAL_FUNC) command_2self)command_unbind_full("kill", (SIGNAL_FUNC) command_2self, ((void
*)0))
;
1070 command_unbind("away", (SIGNAL_FUNC) cmd_away)command_unbind_full("away", (SIGNAL_FUNC) cmd_away, ((void *)
0))
;
1071 command_unbind("ison", (SIGNAL_FUNC) command_1self)command_unbind_full("ison", (SIGNAL_FUNC) command_1self, ((void
*)0))
;
1072 command_unbind("accept", (SIGNAL_FUNC) cmd_accept)command_unbind_full("accept", (SIGNAL_FUNC) cmd_accept, ((void
*)0))
;
1073 command_unbind("admin", (SIGNAL_FUNC) command_self)command_unbind_full("admin", (SIGNAL_FUNC) command_self, ((void
*)0))
;
1074 command_unbind("info", (SIGNAL_FUNC) command_self)command_unbind_full("info", (SIGNAL_FUNC) command_self, ((void
*)0))
;
1075 command_unbind("knock", (SIGNAL_FUNC) command_self)command_unbind_full("knock", (SIGNAL_FUNC) command_self, ((void
*)0))
;
1076 command_unbind("links", (SIGNAL_FUNC) command_self)command_unbind_full("links", (SIGNAL_FUNC) command_self, ((void
*)0))
;
1077 command_unbind("lusers", (SIGNAL_FUNC) command_self)command_unbind_full("lusers", (SIGNAL_FUNC) command_self, ((void
*)0))
;
1078 command_unbind("map", (SIGNAL_FUNC) command_self)command_unbind_full("map", (SIGNAL_FUNC) command_self, ((void
*)0))
;
1079 command_unbind("motd", (SIGNAL_FUNC) command_self)command_unbind_full("motd", (SIGNAL_FUNC) command_self, ((void
*)0))
;
1080 command_unbind("rehash", (SIGNAL_FUNC) command_self)command_unbind_full("rehash", (SIGNAL_FUNC) command_self, ((void
*)0))
;
1081 command_unbind("stats", (SIGNAL_FUNC) command_self)command_unbind_full("stats", (SIGNAL_FUNC) command_self, ((void
*)0))
;
1082 command_unbind("time", (SIGNAL_FUNC) command_self)command_unbind_full("time", (SIGNAL_FUNC) command_self, ((void
*)0))
;
1083 command_unbind("trace", (SIGNAL_FUNC) command_self)command_unbind_full("trace", (SIGNAL_FUNC) command_self, ((void
*)0))
;
1084 command_unbind("version", (SIGNAL_FUNC) command_self)command_unbind_full("version", (SIGNAL_FUNC) command_self, ((
void *)0))
;
1085 command_unbind("servlist", (SIGNAL_FUNC) command_self)command_unbind_full("servlist", (SIGNAL_FUNC) command_self, (
(void *)0))
;
1086 command_unbind("silence", (SIGNAL_FUNC) command_self)command_unbind_full("silence", (SIGNAL_FUNC) command_self, ((
void *)0))
;
1087 command_unbind("unsilence", (SIGNAL_FUNC) cmd_unsilence)command_unbind_full("unsilence", (SIGNAL_FUNC) cmd_unsilence,
((void *)0))
;
1088 command_unbind("sconnect", (SIGNAL_FUNC) cmd_sconnect)command_unbind_full("sconnect", (SIGNAL_FUNC) cmd_sconnect, (
(void *)0))
;
1089 command_unbind("squery", (SIGNAL_FUNC) command_2self)command_unbind_full("squery", (SIGNAL_FUNC) command_2self, ((
void *)0))
;
1090 command_unbind("die", (SIGNAL_FUNC) command_self)command_unbind_full("die", (SIGNAL_FUNC) command_self, ((void
*)0))
;
1091 command_unbind("hash", (SIGNAL_FUNC) command_self)command_unbind_full("hash", (SIGNAL_FUNC) command_self, ((void
*)0))
;
1092 command_unbind("oper", (SIGNAL_FUNC) cmd_oper)command_unbind_full("oper", (SIGNAL_FUNC) cmd_oper, ((void *)
0))
;
1093 command_unbind("restart", (SIGNAL_FUNC) command_self)command_unbind_full("restart", (SIGNAL_FUNC) command_self, ((
void *)0))
;
1094 command_unbind("rping", (SIGNAL_FUNC) command_self)command_unbind_full("rping", (SIGNAL_FUNC) command_self, ((void
*)0))
;
1095 command_unbind("squit", (SIGNAL_FUNC) command_2self)command_unbind_full("squit", (SIGNAL_FUNC) command_2self, ((void
*)0))
;
1096 command_unbind("uping", (SIGNAL_FUNC) command_self)command_unbind_full("uping", (SIGNAL_FUNC) command_self, ((void
*)0))
;
1097 command_unbind("userhost", (SIGNAL_FUNC) command_self)command_unbind_full("userhost", (SIGNAL_FUNC) command_self, (
(void *)0))
;
1098 command_unbind("quote", (SIGNAL_FUNC) cmd_quote)command_unbind_full("quote", (SIGNAL_FUNC) cmd_quote, ((void *
)0))
;
1099 command_unbind("wall", (SIGNAL_FUNC) cmd_wall)command_unbind_full("wall", (SIGNAL_FUNC) cmd_wall, ((void *)
0))
;
1100 command_unbind("wait", (SIGNAL_FUNC) cmd_wait)command_unbind_full("wait", (SIGNAL_FUNC) cmd_wait, ((void *)
0))
;
1101 command_unbind("wallops", (SIGNAL_FUNC) command_1self)command_unbind_full("wallops", (SIGNAL_FUNC) command_1self, (
(void *)0))
;
1102 command_unbind("kickban", (SIGNAL_FUNC) cmd_kickban)command_unbind_full("kickban", (SIGNAL_FUNC) cmd_kickban, ((void
*)0))
;
1103 command_unbind("knockout", (SIGNAL_FUNC) cmd_knockout)command_unbind_full("knockout", (SIGNAL_FUNC) cmd_knockout, (
(void *)0))
;
1104 command_unbind("server purge", (SIGNAL_FUNC) cmd_server_purge)command_unbind_full("server purge", (SIGNAL_FUNC) cmd_server_purge
, ((void *)0))
;
1105
1106 signal_remove("channel destroyed", (SIGNAL_FUNC) sig_channel_destroyed)signal_remove_full(("channel destroyed"), (SIGNAL_FUNC) ((SIGNAL_FUNC
) sig_channel_destroyed), ((void *)0))
;
1107 signal_remove("server disconnected", (SIGNAL_FUNC) sig_server_disconnected)signal_remove_full(("server disconnected"), (SIGNAL_FUNC) ((SIGNAL_FUNC
) sig_server_disconnected), ((void *)0))
;
1108 signal_remove("whois try whowas", (SIGNAL_FUNC) sig_whois_try_whowas)signal_remove_full(("whois try whowas"), (SIGNAL_FUNC) ((SIGNAL_FUNC
) sig_whois_try_whowas), ((void *)0))
;
1109 signal_remove("whois event", (SIGNAL_FUNC) event_whois)signal_remove_full(("whois event"), (SIGNAL_FUNC) ((SIGNAL_FUNC
) event_whois), ((void *)0))
;
1110 signal_remove("whois end", (SIGNAL_FUNC) event_end_of_whois)signal_remove_full(("whois end"), (SIGNAL_FUNC) ((SIGNAL_FUNC
) event_end_of_whois), ((void *)0))
;
1111 signal_remove("whowas event", (SIGNAL_FUNC) event_whowas)signal_remove_full(("whowas event"), (SIGNAL_FUNC) ((SIGNAL_FUNC
) event_whowas), ((void *)0))
;
1112
1113 g_string_free(tmpstr, TRUE(!(0)));
1114}