mirror of
https://github.com/irssi/irssi.git
synced 2024-12-04 14:46:39 -05:00
irc/core/irc-commands.c: fix indentation
This commit is contained in:
parent
be6d7629e3
commit
cf90b2122e
@ -61,16 +61,16 @@ static int knockout_tag;
|
|||||||
|
|
||||||
/* SYNTAX: NOTICE <targets> <message> */
|
/* SYNTAX: NOTICE <targets> <message> */
|
||||||
static void cmd_notice(const char *data, IRC_SERVER_REC *server,
|
static void cmd_notice(const char *data, IRC_SERVER_REC *server,
|
||||||
WI_ITEM_REC *item)
|
WI_ITEM_REC *item)
|
||||||
{
|
{
|
||||||
const char *target, *msg;
|
const char *target, *msg;
|
||||||
char *recoded;
|
char *recoded;
|
||||||
void *free_arg;
|
void *free_arg;
|
||||||
|
|
||||||
CMD_IRC_SERVER(server);
|
CMD_IRC_SERVER(server);
|
||||||
|
|
||||||
if (!cmd_get_params(data, &free_arg, 2 | PARAM_FLAG_GETREST,
|
if (!cmd_get_params(data, &free_arg, 2 | PARAM_FLAG_GETREST,
|
||||||
&target, &msg))
|
&target, &msg))
|
||||||
return;
|
return;
|
||||||
if (g_strcmp0(target, "*") == 0)
|
if (g_strcmp0(target, "*") == 0)
|
||||||
target = item == NULL ? NULL : window_item_get_target(item);
|
target = item == NULL ? NULL : window_item_get_target(item);
|
||||||
@ -88,16 +88,16 @@ static void cmd_notice(const char *data, IRC_SERVER_REC *server,
|
|||||||
|
|
||||||
/* SYNTAX: CTCP <targets> <ctcp command> [<ctcp data>] */
|
/* SYNTAX: CTCP <targets> <ctcp command> [<ctcp data>] */
|
||||||
static void cmd_ctcp(const char *data, IRC_SERVER_REC *server,
|
static void cmd_ctcp(const char *data, IRC_SERVER_REC *server,
|
||||||
WI_ITEM_REC *item)
|
WI_ITEM_REC *item)
|
||||||
{
|
{
|
||||||
const char *target;
|
const char *target;
|
||||||
char *ctcpcmd, *ctcpdata;
|
char *ctcpcmd, *ctcpdata;
|
||||||
void *free_arg;
|
void *free_arg;
|
||||||
|
|
||||||
CMD_IRC_SERVER(server);
|
CMD_IRC_SERVER(server);
|
||||||
|
|
||||||
if (!cmd_get_params(data, &free_arg, 3 | PARAM_FLAG_GETREST,
|
if (!cmd_get_params(data, &free_arg, 3 | PARAM_FLAG_GETREST,
|
||||||
&target, &ctcpcmd, &ctcpdata))
|
&target, &ctcpcmd, &ctcpdata))
|
||||||
return;
|
return;
|
||||||
if (g_strcmp0(target, "*") == 0)
|
if (g_strcmp0(target, "*") == 0)
|
||||||
target = item == NULL ? NULL : window_item_get_target(item);
|
target = item == NULL ? NULL : window_item_get_target(item);
|
||||||
@ -122,16 +122,16 @@ static void cmd_ctcp(const char *data, IRC_SERVER_REC *server,
|
|||||||
|
|
||||||
/* SYNTAX: NCTCP <targets> <ctcp command> [<ctcp data>] */
|
/* SYNTAX: NCTCP <targets> <ctcp command> [<ctcp data>] */
|
||||||
static void cmd_nctcp(const char *data, IRC_SERVER_REC *server,
|
static void cmd_nctcp(const char *data, IRC_SERVER_REC *server,
|
||||||
WI_ITEM_REC *item)
|
WI_ITEM_REC *item)
|
||||||
{
|
{
|
||||||
const char *target;
|
const char *target;
|
||||||
char *ctcpcmd, *ctcpdata, *recoded;
|
char *ctcpcmd, *ctcpdata, *recoded;
|
||||||
void *free_arg;
|
void *free_arg;
|
||||||
|
|
||||||
CMD_IRC_SERVER(server);
|
CMD_IRC_SERVER(server);
|
||||||
|
|
||||||
if (!cmd_get_params(data, &free_arg, 3 | PARAM_FLAG_GETREST,
|
if (!cmd_get_params(data, &free_arg, 3 | PARAM_FLAG_GETREST,
|
||||||
&target, &ctcpcmd, &ctcpdata))
|
&target, &ctcpcmd, &ctcpdata))
|
||||||
return;
|
return;
|
||||||
if (g_strcmp0(target, "*") == 0)
|
if (g_strcmp0(target, "*") == 0)
|
||||||
target = item == NULL ? NULL : window_item_get_target(item);
|
target = item == NULL ? NULL : window_item_get_target(item);
|
||||||
@ -150,22 +150,22 @@ static void cmd_nctcp(const char *data, IRC_SERVER_REC *server,
|
|||||||
|
|
||||||
/* SYNTAX: PART [<channels>] [<message>] */
|
/* SYNTAX: PART [<channels>] [<message>] */
|
||||||
static void cmd_part(const char *data, IRC_SERVER_REC *server,
|
static void cmd_part(const char *data, IRC_SERVER_REC *server,
|
||||||
WI_ITEM_REC *item)
|
WI_ITEM_REC *item)
|
||||||
{
|
{
|
||||||
char *channame, *msg;
|
char *channame, *msg;
|
||||||
char *recoded = NULL;
|
char *recoded = NULL;
|
||||||
void *free_arg;
|
void *free_arg;
|
||||||
|
|
||||||
CMD_IRC_SERVER(server);
|
CMD_IRC_SERVER(server);
|
||||||
|
|
||||||
if (!cmd_get_params(data, &free_arg, 2 | PARAM_FLAG_GETREST |
|
if (!cmd_get_params(data, &free_arg, 2 | PARAM_FLAG_GETREST |
|
||||||
PARAM_FLAG_OPTCHAN, item, &channame, &msg))
|
PARAM_FLAG_OPTCHAN, item, &channame, &msg))
|
||||||
return;
|
return;
|
||||||
if (*channame == '\0') cmd_param_error(CMDERR_NOT_ENOUGH_PARAMS);
|
if (*channame == '\0') cmd_param_error(CMDERR_NOT_ENOUGH_PARAMS);
|
||||||
|
|
||||||
if (*msg == '\0') msg = (char *) settings_get_str("part_message");
|
if (*msg == '\0') msg = (char *) settings_get_str("part_message");
|
||||||
|
|
||||||
if (server->cmdcount > MAX_COMMANDS_ON_PART_UNTIL_PURGE)
|
if (server->cmdcount > MAX_COMMANDS_ON_PART_UNTIL_PURGE)
|
||||||
irc_server_purge_output(server, channame);
|
irc_server_purge_output(server, channame);
|
||||||
|
|
||||||
if (*msg != '\0')
|
if (*msg != '\0')
|
||||||
@ -186,11 +186,11 @@ static void cmd_kick(const char *data, IRC_SERVER_REC *server, WI_ITEM_REC *item
|
|||||||
char *channame, *nicks, *reason, *recoded;
|
char *channame, *nicks, *reason, *recoded;
|
||||||
void *free_arg;
|
void *free_arg;
|
||||||
|
|
||||||
CMD_IRC_SERVER(server);
|
CMD_IRC_SERVER(server);
|
||||||
|
|
||||||
if (!cmd_get_params(data, &free_arg, 3 | PARAM_FLAG_GETREST |
|
if (!cmd_get_params(data, &free_arg, 3 | PARAM_FLAG_GETREST |
|
||||||
PARAM_FLAG_OPTCHAN, item,
|
PARAM_FLAG_OPTCHAN, item,
|
||||||
&channame, &nicks, &reason))
|
&channame, &nicks, &reason))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (*channame == '\0' || *nicks == '\0') cmd_param_error(CMDERR_NOT_ENOUGH_PARAMS);
|
if (*channame == '\0' || *nicks == '\0') cmd_param_error(CMDERR_NOT_ENOUGH_PARAMS);
|
||||||
@ -213,11 +213,11 @@ static void cmd_topic(const char *data, IRC_SERVER_REC *server, WI_ITEM_REC *ite
|
|||||||
char *recoded = NULL;
|
char *recoded = NULL;
|
||||||
void *free_arg;
|
void *free_arg;
|
||||||
|
|
||||||
CMD_IRC_SERVER(server);
|
CMD_IRC_SERVER(server);
|
||||||
|
|
||||||
if (!cmd_get_params(data, &free_arg, 2 | PARAM_FLAG_OPTCHAN |
|
if (!cmd_get_params(data, &free_arg, 2 | PARAM_FLAG_OPTCHAN |
|
||||||
PARAM_FLAG_OPTIONS | PARAM_FLAG_GETREST,
|
PARAM_FLAG_OPTIONS | PARAM_FLAG_GETREST,
|
||||||
item, "topic", &optlist, &channame, &topic))
|
item, "topic", &optlist, &channame, &topic))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (*topic != '\0' || g_hash_table_lookup(optlist, "delete") != NULL)
|
if (*topic != '\0' || g_hash_table_lookup(optlist, "delete") != NULL)
|
||||||
@ -239,7 +239,7 @@ static void cmd_invite(const char *data, IRC_SERVER_REC *server, WI_ITEM_REC *it
|
|||||||
char *nick, *channame;
|
char *nick, *channame;
|
||||||
void *free_arg;
|
void *free_arg;
|
||||||
|
|
||||||
CMD_IRC_SERVER(server);
|
CMD_IRC_SERVER(server);
|
||||||
|
|
||||||
if (!cmd_get_params(data, &free_arg, 2, &nick, &channame))
|
if (!cmd_get_params(data, &free_arg, 2, &nick, &channame))
|
||||||
return;
|
return;
|
||||||
@ -258,17 +258,17 @@ static void cmd_invite(const char *data, IRC_SERVER_REC *server, WI_ITEM_REC *it
|
|||||||
|
|
||||||
/* SYNTAX: LIST [-yes] [<channel>] */
|
/* SYNTAX: LIST [-yes] [<channel>] */
|
||||||
static void cmd_list(const char *data, IRC_SERVER_REC *server,
|
static void cmd_list(const char *data, IRC_SERVER_REC *server,
|
||||||
WI_ITEM_REC *item)
|
WI_ITEM_REC *item)
|
||||||
{
|
{
|
||||||
GHashTable *optlist;
|
GHashTable *optlist;
|
||||||
char *str;
|
char *str;
|
||||||
void *free_arg;
|
void *free_arg;
|
||||||
|
|
||||||
CMD_IRC_SERVER(server);
|
CMD_IRC_SERVER(server);
|
||||||
|
|
||||||
if (!cmd_get_params(data, &free_arg, 1 | PARAM_FLAG_OPTIONS |
|
if (!cmd_get_params(data, &free_arg, 1 | PARAM_FLAG_OPTIONS |
|
||||||
PARAM_FLAG_GETREST | PARAM_FLAG_STRIP_TRAILING_WS,
|
PARAM_FLAG_GETREST | PARAM_FLAG_STRIP_TRAILING_WS,
|
||||||
"list", &optlist, &str))
|
"list", &optlist, &str))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (*str == '\0' && g_hash_table_lookup(optlist, "yes") == NULL &&
|
if (*str == '\0' && g_hash_table_lookup(optlist, "yes") == NULL &&
|
||||||
@ -282,7 +282,7 @@ static void cmd_list(const char *data, IRC_SERVER_REC *server,
|
|||||||
|
|
||||||
/* SYNTAX: WHO [<nicks> | <channels> | **] */
|
/* SYNTAX: WHO [<nicks> | <channels> | **] */
|
||||||
static void cmd_who(const char *data, IRC_SERVER_REC *server,
|
static void cmd_who(const char *data, IRC_SERVER_REC *server,
|
||||||
WI_ITEM_REC *item)
|
WI_ITEM_REC *item)
|
||||||
{
|
{
|
||||||
char *channel, *rest;
|
char *channel, *rest;
|
||||||
void *free_arg;
|
void *free_arg;
|
||||||
@ -290,7 +290,7 @@ static void cmd_who(const char *data, IRC_SERVER_REC *server,
|
|||||||
CMD_IRC_SERVER(server);
|
CMD_IRC_SERVER(server);
|
||||||
|
|
||||||
if (!cmd_get_params(data, &free_arg, 2 | PARAM_FLAG_GETREST |
|
if (!cmd_get_params(data, &free_arg, 2 | PARAM_FLAG_GETREST |
|
||||||
PARAM_FLAG_STRIP_TRAILING_WS, &channel, &rest))
|
PARAM_FLAG_STRIP_TRAILING_WS, &channel, &rest))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (g_strcmp0(channel, "*") == 0 || *channel == '\0') {
|
if (g_strcmp0(channel, "*") == 0 || *channel == '\0') {
|
||||||
@ -313,29 +313,29 @@ static void cmd_who(const char *data, IRC_SERVER_REC *server,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void cmd_names(const char *data, IRC_SERVER_REC *server,
|
static void cmd_names(const char *data, IRC_SERVER_REC *server,
|
||||||
WI_ITEM_REC *item)
|
WI_ITEM_REC *item)
|
||||||
{
|
{
|
||||||
GHashTable *optlist;
|
GHashTable *optlist;
|
||||||
char *channel;
|
char *channel;
|
||||||
void *free_arg;
|
void *free_arg;
|
||||||
|
|
||||||
CMD_IRC_SERVER(server);
|
CMD_IRC_SERVER(server);
|
||||||
|
|
||||||
if (!cmd_get_params(data, &free_arg, 1 | PARAM_FLAG_OPTIONS |
|
if (!cmd_get_params(data, &free_arg, 1 | PARAM_FLAG_OPTIONS |
|
||||||
PARAM_FLAG_GETREST | PARAM_FLAG_STRIP_TRAILING_WS,
|
PARAM_FLAG_GETREST | PARAM_FLAG_STRIP_TRAILING_WS,
|
||||||
"names", &optlist, &channel))
|
"names", &optlist, &channel))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (g_strcmp0(channel, "*") == 0 || *channel == '\0') {
|
if (g_strcmp0(channel, "*") == 0 || *channel == '\0') {
|
||||||
if (!IS_IRC_CHANNEL(item))
|
if (!IS_IRC_CHANNEL(item))
|
||||||
cmd_param_error(CMDERR_NOT_JOINED);
|
cmd_param_error(CMDERR_NOT_JOINED);
|
||||||
|
|
||||||
channel = IRC_CHANNEL(item)->name;
|
channel = IRC_CHANNEL(item)->name;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (g_strcmp0(channel, "**") == 0) {
|
if (g_strcmp0(channel, "**") == 0) {
|
||||||
/* ** displays all nicks.. */
|
/* ** displays all nicks.. */
|
||||||
irc_send_cmd(server, "NAMES");
|
irc_send_cmd(server, "NAMES");
|
||||||
} else {
|
} else {
|
||||||
irc_send_cmdv(server, "NAMES %s", channel);
|
irc_send_cmdv(server, "NAMES %s", channel);
|
||||||
}
|
}
|
||||||
@ -346,12 +346,12 @@ static void cmd_names(const char *data, IRC_SERVER_REC *server,
|
|||||||
/* SYNTAX: NICK <new nick> */
|
/* SYNTAX: NICK <new nick> */
|
||||||
static void cmd_nick(const char *data, IRC_SERVER_REC *server, WI_ITEM_REC *item)
|
static void cmd_nick(const char *data, IRC_SERVER_REC *server, WI_ITEM_REC *item)
|
||||||
{
|
{
|
||||||
char *nick;
|
char *nick;
|
||||||
void *free_arg;
|
void *free_arg;
|
||||||
|
|
||||||
g_return_if_fail(data != NULL);
|
g_return_if_fail(data != NULL);
|
||||||
|
|
||||||
CMD_IRC_SERVER(server);
|
CMD_IRC_SERVER(server);
|
||||||
|
|
||||||
if (!cmd_get_params(data, &free_arg, 1, &nick))
|
if (!cmd_get_params(data, &free_arg, 1, &nick))
|
||||||
return;
|
return;
|
||||||
@ -388,23 +388,23 @@ static char *get_redirect_nicklist(const char *nicks, int *free)
|
|||||||
|
|
||||||
/* SYNTAX: WHOIS [-<server tag>] [<server>] [<nicks>] */
|
/* SYNTAX: WHOIS [-<server tag>] [<server>] [<nicks>] */
|
||||||
static void cmd_whois(const char *data, IRC_SERVER_REC *server,
|
static void cmd_whois(const char *data, IRC_SERVER_REC *server,
|
||||||
WI_ITEM_REC *item)
|
WI_ITEM_REC *item)
|
||||||
{
|
{
|
||||||
GHashTable *optlist;
|
GHashTable *optlist;
|
||||||
char *qserver, *query, *event_402, *str;
|
char *qserver, *query, *event_402, *str;
|
||||||
void *free_arg;
|
void *free_arg;
|
||||||
int free_nick;
|
int free_nick;
|
||||||
|
|
||||||
CMD_IRC_SERVER(server);
|
CMD_IRC_SERVER(server);
|
||||||
|
|
||||||
if (!cmd_get_params(data, &free_arg, 2 | PARAM_FLAG_OPTIONS |
|
if (!cmd_get_params(data, &free_arg, 2 | PARAM_FLAG_OPTIONS |
|
||||||
PARAM_FLAG_UNKNOWN_OPTIONS,
|
PARAM_FLAG_UNKNOWN_OPTIONS,
|
||||||
"whois", &optlist, &qserver, &query))
|
"whois", &optlist, &qserver, &query))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
/* -<server tag> */
|
/* -<server tag> */
|
||||||
server = IRC_SERVER(cmd_options_get_server("whois", optlist,
|
server = IRC_SERVER(cmd_options_get_server("whois", optlist,
|
||||||
SERVER(server)));
|
SERVER(server)));
|
||||||
if (server == NULL) {
|
if (server == NULL) {
|
||||||
cmd_params_free(free_arg);
|
cmd_params_free(free_arg);
|
||||||
return;
|
return;
|
||||||
@ -439,15 +439,15 @@ static void cmd_whois(const char *data, IRC_SERVER_REC *server,
|
|||||||
|
|
||||||
str = g_strconcat(qserver, " ", query, NULL);
|
str = g_strconcat(qserver, " ", query, NULL);
|
||||||
server_redirect_event(server, "whois", 1, str, TRUE,
|
server_redirect_event(server, "whois", 1, str, TRUE,
|
||||||
NULL,
|
NULL,
|
||||||
"event 318", "whois end",
|
"event 318", "whois end",
|
||||||
"event 402", event_402,
|
"event 402", event_402,
|
||||||
"event 301", "whois away", /* 301 can come as a reply to /MSG, /WHOIS or /WHOWAS */
|
"event 301", "whois away", /* 301 can come as a reply to /MSG, /WHOIS or /WHOWAS */
|
||||||
"event 313", "whois oper",
|
"event 313", "whois oper",
|
||||||
"event 401", (settings_get_bool("auto_whowas") ? "whois try whowas" : "whois event not found"),
|
"event 401", (settings_get_bool("auto_whowas") ? "whois try whowas" : "whois event not found"),
|
||||||
"event 311", "whois event",
|
"event 311", "whois event",
|
||||||
"", "whois default event", NULL);
|
"", "whois default event", NULL);
|
||||||
g_free(str);
|
g_free(str);
|
||||||
|
|
||||||
server->whois_found = FALSE;
|
server->whois_found = FALSE;
|
||||||
irc_send_cmd_split(server, tmpstr->str, 2, server->max_whois_in_cmd);
|
irc_send_cmd_split(server, tmpstr->str, 2, server->max_whois_in_cmd);
|
||||||
@ -457,7 +457,7 @@ static void cmd_whois(const char *data, IRC_SERVER_REC *server,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void event_whois(IRC_SERVER_REC *server, const char *data,
|
static void event_whois(IRC_SERVER_REC *server, const char *data,
|
||||||
const char *nick, const char *addr)
|
const char *nick, const char *addr)
|
||||||
{
|
{
|
||||||
server->whois_found = TRUE;
|
server->whois_found = TRUE;
|
||||||
signal_emit("event 311", 4, server, data, nick, addr);
|
signal_emit("event 311", 4, server, data, nick, addr);
|
||||||
@ -473,23 +473,23 @@ static void sig_whois_try_whowas(IRC_SERVER_REC *server, const char *data)
|
|||||||
|
|
||||||
server->whowas_found = FALSE;
|
server->whowas_found = FALSE;
|
||||||
server_redirect_event(server, "whowas", 1, nick, -1, NULL,
|
server_redirect_event(server, "whowas", 1, nick, -1, NULL,
|
||||||
"event 314", "whowas event",
|
"event 314", "whowas event",
|
||||||
"event 369", "whowas event end",
|
"event 369", "whowas event end",
|
||||||
"event 406", "event empty", NULL);
|
"event 406", "event empty", NULL);
|
||||||
irc_send_cmdv(server, "WHOWAS %s 1", nick);
|
irc_send_cmdv(server, "WHOWAS %s 1", nick);
|
||||||
|
|
||||||
g_free(params);
|
g_free(params);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void event_end_of_whois(IRC_SERVER_REC *server, const char *data,
|
static void event_end_of_whois(IRC_SERVER_REC *server, const char *data,
|
||||||
const char *nick, const char *addr)
|
const char *nick, const char *addr)
|
||||||
{
|
{
|
||||||
signal_emit("event 318", 4, server, data, nick, addr);
|
signal_emit("event 318", 4, server, data, nick, addr);
|
||||||
server->whois_found = FALSE;
|
server->whois_found = FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void event_whowas(IRC_SERVER_REC *server, const char *data,
|
static void event_whowas(IRC_SERVER_REC *server, const char *data,
|
||||||
const char *nick, const char *addr)
|
const char *nick, const char *addr)
|
||||||
{
|
{
|
||||||
server->whowas_found = TRUE;
|
server->whowas_found = TRUE;
|
||||||
signal_emit("event 314", 4, server, data, nick, addr);
|
signal_emit("event 314", 4, server, data, nick, addr);
|
||||||
@ -502,17 +502,17 @@ static void cmd_whowas(const char *data, IRC_SERVER_REC *server)
|
|||||||
void *free_arg;
|
void *free_arg;
|
||||||
int free_nick;
|
int free_nick;
|
||||||
|
|
||||||
CMD_IRC_SERVER(server);
|
CMD_IRC_SERVER(server);
|
||||||
|
|
||||||
if (!cmd_get_params(data, &free_arg, 2 | PARAM_FLAG_GETREST | PARAM_FLAG_STRIP_TRAILING_WS,
|
if (!cmd_get_params(data, &free_arg, 2 | PARAM_FLAG_GETREST | PARAM_FLAG_STRIP_TRAILING_WS,
|
||||||
&nicks, &rest))
|
&nicks, &rest))
|
||||||
return;
|
return;
|
||||||
if (*nicks == '\0') nicks = server->nick;
|
if (*nicks == '\0') nicks = server->nick;
|
||||||
|
|
||||||
nicks_redir = get_redirect_nicklist(nicks, &free_nick);
|
nicks_redir = get_redirect_nicklist(nicks, &free_nick);
|
||||||
server_redirect_event(server, "whowas", 1, nicks_redir, -1, NULL,
|
server_redirect_event(server, "whowas", 1, nicks_redir, -1, NULL,
|
||||||
"event 301", "whowas away", /* 301 can come as a reply to /MSG, /WHOIS or /WHOWAS */
|
"event 301", "whowas away", /* 301 can come as a reply to /MSG, /WHOIS or /WHOWAS */
|
||||||
"event 314", "whowas event", NULL);
|
"event 314", "whowas event", NULL);
|
||||||
if (free_nick) g_free(nicks_redir);
|
if (free_nick) g_free(nicks_redir);
|
||||||
|
|
||||||
server->whowas_found = FALSE;
|
server->whowas_found = FALSE;
|
||||||
@ -529,9 +529,9 @@ static void cmd_whowas(const char *data, IRC_SERVER_REC *server)
|
|||||||
static void cmd_ping(const char *data, IRC_SERVER_REC *server, WI_ITEM_REC *item)
|
static void cmd_ping(const char *data, IRC_SERVER_REC *server, WI_ITEM_REC *item)
|
||||||
{
|
{
|
||||||
GTimeVal tv;
|
GTimeVal tv;
|
||||||
char *str;
|
char *str;
|
||||||
|
|
||||||
CMD_IRC_SERVER(server);
|
CMD_IRC_SERVER(server);
|
||||||
|
|
||||||
if (*data == '\0') {
|
if (*data == '\0') {
|
||||||
if (!IS_QUERY(item))
|
if (!IS_QUERY(item))
|
||||||
@ -554,7 +554,7 @@ static void cmd_away(const char *data, IRC_SERVER_REC *server)
|
|||||||
void *free_arg;
|
void *free_arg;
|
||||||
|
|
||||||
if (!cmd_get_params(data, &free_arg, 1 | PARAM_FLAG_OPTIONS |
|
if (!cmd_get_params(data, &free_arg, 1 | PARAM_FLAG_OPTIONS |
|
||||||
PARAM_FLAG_GETREST, "away", &optlist, &reason)) return;
|
PARAM_FLAG_GETREST, "away", &optlist, &reason)) return;
|
||||||
|
|
||||||
if (g_hash_table_lookup(optlist, "one") != NULL)
|
if (g_hash_table_lookup(optlist, "one") != NULL)
|
||||||
irc_server_send_away(server, reason);
|
irc_server_send_away(server, reason);
|
||||||
@ -567,7 +567,7 @@ static void cmd_away(const char *data, IRC_SERVER_REC *server)
|
|||||||
/* SYNTAX: SCONNECT <new server> [[<port>] <existing server>] */
|
/* SYNTAX: SCONNECT <new server> [[<port>] <existing server>] */
|
||||||
static void cmd_sconnect(const char *data, IRC_SERVER_REC *server)
|
static void cmd_sconnect(const char *data, IRC_SERVER_REC *server)
|
||||||
{
|
{
|
||||||
CMD_IRC_SERVER(server);
|
CMD_IRC_SERVER(server);
|
||||||
if (*data == '\0') cmd_return_error(CMDERR_NOT_ENOUGH_PARAMS);
|
if (*data == '\0') cmd_return_error(CMDERR_NOT_ENOUGH_PARAMS);
|
||||||
|
|
||||||
irc_send_cmdv(server, "CONNECT %s", data);
|
irc_send_cmdv(server, "CONNECT %s", data);
|
||||||
@ -600,11 +600,11 @@ static void cmd_wait(const char *data, IRC_SERVER_REC *server)
|
|||||||
void *free_arg;
|
void *free_arg;
|
||||||
int n;
|
int n;
|
||||||
|
|
||||||
CMD_IRC_SERVER(server);
|
CMD_IRC_SERVER(server);
|
||||||
|
|
||||||
if (!cmd_get_params(data, &free_arg, 1 | PARAM_FLAG_OPTIONS |
|
if (!cmd_get_params(data, &free_arg, 1 | PARAM_FLAG_OPTIONS |
|
||||||
PARAM_FLAG_UNKNOWN_OPTIONS | PARAM_FLAG_GETREST,
|
PARAM_FLAG_UNKNOWN_OPTIONS | PARAM_FLAG_GETREST,
|
||||||
NULL, &optlist, &msecs))
|
NULL, &optlist, &msecs))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (*msecs == '\0')
|
if (*msecs == '\0')
|
||||||
@ -612,7 +612,7 @@ static void cmd_wait(const char *data, IRC_SERVER_REC *server)
|
|||||||
|
|
||||||
/* -<server tag> */
|
/* -<server tag> */
|
||||||
server = IRC_SERVER(cmd_options_get_server(NULL, optlist,
|
server = IRC_SERVER(cmd_options_get_server(NULL, optlist,
|
||||||
SERVER(server)));
|
SERVER(server)));
|
||||||
|
|
||||||
n = atoi(msecs);
|
n = atoi(msecs);
|
||||||
if (server != NULL && n > 0) {
|
if (server != NULL && n > 0) {
|
||||||
@ -635,10 +635,10 @@ static void cmd_wall(const char *data, IRC_SERVER_REC *server, WI_ITEM_REC *item
|
|||||||
IRC_CHANNEL_REC *chanrec;
|
IRC_CHANNEL_REC *chanrec;
|
||||||
GSList *tmp, *nicks;
|
GSList *tmp, *nicks;
|
||||||
|
|
||||||
CMD_IRC_SERVER(server);
|
CMD_IRC_SERVER(server);
|
||||||
|
|
||||||
if (!cmd_get_params(data, &free_arg, 2 | PARAM_FLAG_OPTCHAN |
|
if (!cmd_get_params(data, &free_arg, 2 | PARAM_FLAG_OPTCHAN |
|
||||||
PARAM_FLAG_GETREST, item, &channame, &msg))
|
PARAM_FLAG_GETREST, item, &channame, &msg))
|
||||||
return;
|
return;
|
||||||
if (*msg == '\0') cmd_param_error(CMDERR_NOT_ENOUGH_PARAMS);
|
if (*msg == '\0') cmd_param_error(CMDERR_NOT_ENOUGH_PARAMS);
|
||||||
|
|
||||||
@ -654,11 +654,11 @@ static void cmd_wall(const char *data, IRC_SERVER_REC *server, WI_ITEM_REC *item
|
|||||||
/* Fall back to manually noticing each op */
|
/* Fall back to manually noticing each op */
|
||||||
nicks = NULL;
|
nicks = NULL;
|
||||||
g_hash_table_foreach(chanrec->nicks,
|
g_hash_table_foreach(chanrec->nicks,
|
||||||
(GHFunc) cmd_wall_hash, &nicks);
|
(GHFunc) cmd_wall_hash, &nicks);
|
||||||
|
|
||||||
args = g_strconcat(chanrec->name, " ", recoded, NULL);
|
args = g_strconcat(chanrec->name, " ", recoded, NULL);
|
||||||
msg = parse_special_string(settings_get_str("wall_format"),
|
msg = parse_special_string(settings_get_str("wall_format"),
|
||||||
SERVER(server), item, args, NULL, 0);
|
SERVER(server), item, args, NULL, 0);
|
||||||
g_free(args);
|
g_free(args);
|
||||||
|
|
||||||
for (tmp = nicks; tmp != NULL; tmp = tmp->next) {
|
for (tmp = nicks; tmp != NULL; tmp = tmp->next) {
|
||||||
@ -666,7 +666,7 @@ static void cmd_wall(const char *data, IRC_SERVER_REC *server, WI_ITEM_REC *item
|
|||||||
|
|
||||||
if (rec != chanrec->ownnick) {
|
if (rec != chanrec->ownnick) {
|
||||||
irc_send_cmdv(server, "NOTICE %s :%s",
|
irc_send_cmdv(server, "NOTICE %s :%s",
|
||||||
rec->nick, msg);
|
rec->nick, msg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -680,17 +680,17 @@ static void cmd_wall(const char *data, IRC_SERVER_REC *server, WI_ITEM_REC *item
|
|||||||
|
|
||||||
/* SYNTAX: KICKBAN [<channel>] <nicks> <reason> */
|
/* SYNTAX: KICKBAN [<channel>] <nicks> <reason> */
|
||||||
static void cmd_kickban(const char *data, IRC_SERVER_REC *server,
|
static void cmd_kickban(const char *data, IRC_SERVER_REC *server,
|
||||||
WI_ITEM_REC *item)
|
WI_ITEM_REC *item)
|
||||||
{
|
{
|
||||||
IRC_CHANNEL_REC *chanrec;
|
IRC_CHANNEL_REC *chanrec;
|
||||||
char *channel, *nicks, *reason, *kickcmd, *bancmd, *recoded;
|
char *channel, *nicks, *reason, *kickcmd, *bancmd, *recoded;
|
||||||
char **nicklist, *spacenicks;
|
char **nicklist, *spacenicks;
|
||||||
void *free_arg;
|
void *free_arg;
|
||||||
|
|
||||||
CMD_IRC_SERVER(server);
|
CMD_IRC_SERVER(server);
|
||||||
|
|
||||||
if (!cmd_get_params(data, &free_arg, 3 | PARAM_FLAG_OPTCHAN | PARAM_FLAG_GETREST,
|
if (!cmd_get_params(data, &free_arg, 3 | PARAM_FLAG_OPTCHAN | PARAM_FLAG_GETREST,
|
||||||
item, &channel, &nicks, &reason))
|
item, &channel, &nicks, &reason))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (*channel == '\0' || *nicks == '\0')
|
if (*channel == '\0' || *nicks == '\0')
|
||||||
@ -701,7 +701,7 @@ static void cmd_kickban(const char *data, IRC_SERVER_REC *server,
|
|||||||
cmd_param_error(CMDERR_CHAN_NOT_FOUND);
|
cmd_param_error(CMDERR_CHAN_NOT_FOUND);
|
||||||
|
|
||||||
nicklist = g_strsplit(nicks, ",", -1);
|
nicklist = g_strsplit(nicks, ",", -1);
|
||||||
spacenicks = g_strjoinv(" ", nicklist);
|
spacenicks = g_strjoinv(" ", nicklist);
|
||||||
g_strfreev(nicklist);
|
g_strfreev(nicklist);
|
||||||
|
|
||||||
recoded = recode_out(SERVER(server), reason, channel);
|
recoded = recode_out(SERVER(server), reason, channel);
|
||||||
@ -709,9 +709,9 @@ static void cmd_kickban(const char *data, IRC_SERVER_REC *server,
|
|||||||
g_free(recoded);
|
g_free(recoded);
|
||||||
|
|
||||||
bancmd = g_strdup_printf("%s %s", chanrec->name, spacenicks);
|
bancmd = g_strdup_printf("%s %s", chanrec->name, spacenicks);
|
||||||
g_free(spacenicks);
|
g_free(spacenicks);
|
||||||
|
|
||||||
if (settings_get_bool("kick_first_on_kickban")) {
|
if (settings_get_bool("kick_first_on_kickban")) {
|
||||||
signal_emit("command kick", 3, kickcmd, server, chanrec);
|
signal_emit("command kick", 3, kickcmd, server, chanrec);
|
||||||
signal_emit("command ban", 3, bancmd, server, chanrec);
|
signal_emit("command ban", 3, bancmd, server, chanrec);
|
||||||
} else {
|
} else {
|
||||||
@ -742,7 +742,7 @@ static void knockout_timeout_server(IRC_SERVER_REC *server)
|
|||||||
if (!IS_IRC_SERVER(server))
|
if (!IS_IRC_SERVER(server))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
now = time(NULL);
|
now = time(NULL);
|
||||||
for (tmp = server->knockoutlist; tmp != NULL; tmp = next) {
|
for (tmp = server->knockoutlist; tmp != NULL; tmp = next) {
|
||||||
KNOCKOUT_REC *rec = tmp->data;
|
KNOCKOUT_REC *rec = tmp->data;
|
||||||
|
|
||||||
@ -763,16 +763,16 @@ static int knockout_timeout(void)
|
|||||||
|
|
||||||
/* SYNTAX: KNOCKOUT [<time>] <nicks> <reason> */
|
/* SYNTAX: KNOCKOUT [<time>] <nicks> <reason> */
|
||||||
static void cmd_knockout(const char *data, IRC_SERVER_REC *server,
|
static void cmd_knockout(const char *data, IRC_SERVER_REC *server,
|
||||||
IRC_CHANNEL_REC *channel)
|
IRC_CHANNEL_REC *channel)
|
||||||
{
|
{
|
||||||
KNOCKOUT_REC *rec;
|
KNOCKOUT_REC *rec;
|
||||||
char *nicks, *reason, *timeoutstr, *kickcmd, *bancmd, *recoded;
|
char *nicks, *reason, *timeoutstr, *kickcmd, *bancmd, *recoded;
|
||||||
char **nicklist, *spacenicks, *banmasks;
|
char **nicklist, *spacenicks, *banmasks;
|
||||||
void *free_arg;
|
void *free_arg;
|
||||||
int timeleft;
|
int timeleft;
|
||||||
GSList *ptr;
|
GSList *ptr;
|
||||||
|
|
||||||
CMD_IRC_SERVER(server);
|
CMD_IRC_SERVER(server);
|
||||||
|
|
||||||
if (!IS_IRC_CHANNEL(channel))
|
if (!IS_IRC_CHANNEL(channel))
|
||||||
cmd_return_error(CMDERR_NOT_JOINED);
|
cmd_return_error(CMDERR_NOT_JOINED);
|
||||||
@ -780,14 +780,14 @@ static void cmd_knockout(const char *data, IRC_SERVER_REC *server,
|
|||||||
if (i_isdigit(*data)) {
|
if (i_isdigit(*data)) {
|
||||||
/* first argument is the timeout */
|
/* first argument is the timeout */
|
||||||
if (!cmd_get_params(data, &free_arg, 3 | PARAM_FLAG_GETREST,
|
if (!cmd_get_params(data, &free_arg, 3 | PARAM_FLAG_GETREST,
|
||||||
&timeoutstr, &nicks, &reason))
|
&timeoutstr, &nicks, &reason))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (!parse_time_interval(timeoutstr, &timeleft))
|
if (!parse_time_interval(timeoutstr, &timeleft))
|
||||||
cmd_param_error(CMDERR_INVALID_TIME);
|
cmd_param_error(CMDERR_INVALID_TIME);
|
||||||
} else {
|
} else {
|
||||||
if (!cmd_get_params(data, &free_arg, 2 | PARAM_FLAG_GETREST,
|
if (!cmd_get_params(data, &free_arg, 2 | PARAM_FLAG_GETREST,
|
||||||
&nicks, &reason))
|
&nicks, &reason))
|
||||||
return;
|
return;
|
||||||
timeleft = settings_get_time("knockout_time");
|
timeleft = settings_get_time("knockout_time");
|
||||||
}
|
}
|
||||||
@ -795,7 +795,7 @@ static void cmd_knockout(const char *data, IRC_SERVER_REC *server,
|
|||||||
if (*nicks == '\0') cmd_param_error(CMDERR_NOT_ENOUGH_PARAMS);
|
if (*nicks == '\0') cmd_param_error(CMDERR_NOT_ENOUGH_PARAMS);
|
||||||
|
|
||||||
nicklist = g_strsplit(nicks, ",", -1);
|
nicklist = g_strsplit(nicks, ",", -1);
|
||||||
spacenicks = g_strjoinv(" ", nicklist);
|
spacenicks = g_strjoinv(" ", nicklist);
|
||||||
g_strfreev(nicklist);
|
g_strfreev(nicklist);
|
||||||
|
|
||||||
banmasks = ban_get_masks(channel, spacenicks, 0);
|
banmasks = ban_get_masks(channel, spacenicks, 0);
|
||||||
@ -808,7 +808,7 @@ static void cmd_knockout(const char *data, IRC_SERVER_REC *server,
|
|||||||
bancmd = *banmasks == '\0'? NULL :
|
bancmd = *banmasks == '\0'? NULL :
|
||||||
g_strdup_printf("%s %s", channel->name, banmasks);
|
g_strdup_printf("%s %s", channel->name, banmasks);
|
||||||
|
|
||||||
if (settings_get_bool("kick_first_on_kickban")) {
|
if (settings_get_bool("kick_first_on_kickban")) {
|
||||||
signal_emit("command kick", 3, kickcmd, server, channel);
|
signal_emit("command kick", 3, kickcmd, server, channel);
|
||||||
if (bancmd != NULL)
|
if (bancmd != NULL)
|
||||||
signal_emit("command ban", 3, bancmd, server, channel);
|
signal_emit("command ban", 3, bancmd, server, channel);
|
||||||
@ -827,7 +827,7 @@ static void cmd_knockout(const char *data, IRC_SERVER_REC *server,
|
|||||||
for (ptr = server->knockoutlist; ptr != NULL; ptr = ptr->next) {
|
for (ptr = server->knockoutlist; ptr != NULL; ptr = ptr->next) {
|
||||||
rec = ptr->data;
|
rec = ptr->data;
|
||||||
if (channel == rec->channel &&
|
if (channel == rec->channel &&
|
||||||
!g_strcmp0(rec->ban, banmasks))
|
!g_strcmp0(rec->ban, banmasks))
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (ptr == NULL) {
|
if (ptr == NULL) {
|
||||||
@ -845,10 +845,10 @@ static void cmd_knockout(const char *data, IRC_SERVER_REC *server,
|
|||||||
/* SYNTAX: SERVER PURGE [<target>] */
|
/* SYNTAX: SERVER PURGE [<target>] */
|
||||||
static void cmd_server_purge(const char *data, IRC_SERVER_REC *server)
|
static void cmd_server_purge(const char *data, IRC_SERVER_REC *server)
|
||||||
{
|
{
|
||||||
char *target;
|
char *target;
|
||||||
void *free_arg;
|
void *free_arg;
|
||||||
|
|
||||||
CMD_IRC_SERVER(server);
|
CMD_IRC_SERVER(server);
|
||||||
|
|
||||||
if (!cmd_get_params(data, &free_arg, 1, &target))
|
if (!cmd_get_params(data, &free_arg, 1, &target))
|
||||||
return;
|
return;
|
||||||
@ -895,12 +895,12 @@ static void cmd_oper(const char *data, IRC_SERVER_REC *server)
|
|||||||
char *nick, *password;
|
char *nick, *password;
|
||||||
void *free_arg;
|
void *free_arg;
|
||||||
|
|
||||||
CMD_IRC_SERVER(server);
|
CMD_IRC_SERVER(server);
|
||||||
|
|
||||||
/* asking for password is handled by fe-common */
|
/* asking for password is handled by fe-common */
|
||||||
if (!cmd_get_params(data, &free_arg, 2, &nick, &password))
|
if (!cmd_get_params(data, &free_arg, 2, &nick, &password))
|
||||||
return;
|
return;
|
||||||
if (*password == '\0') cmd_param_error(CMDERR_NOT_ENOUGH_PARAMS);
|
if (*password == '\0') cmd_param_error(CMDERR_NOT_ENOUGH_PARAMS);
|
||||||
|
|
||||||
irc_send_cmdv(server, "OPER %s %s", nick, password);
|
irc_send_cmdv(server, "OPER %s %s", nick, password);
|
||||||
cmd_params_free(free_arg);
|
cmd_params_free(free_arg);
|
||||||
@ -909,7 +909,7 @@ static void cmd_oper(const char *data, IRC_SERVER_REC *server)
|
|||||||
/* SYNTAX: ACCEPT [[-]nick,...] */
|
/* SYNTAX: ACCEPT [[-]nick,...] */
|
||||||
static void cmd_accept(const char *data, IRC_SERVER_REC *server)
|
static void cmd_accept(const char *data, IRC_SERVER_REC *server)
|
||||||
{
|
{
|
||||||
CMD_IRC_SERVER(server);
|
CMD_IRC_SERVER(server);
|
||||||
|
|
||||||
if (*data == '\0')
|
if (*data == '\0')
|
||||||
irc_send_cmd(server, "ACCEPT *");
|
irc_send_cmd(server, "ACCEPT *");
|
||||||
@ -920,7 +920,7 @@ static void cmd_accept(const char *data, IRC_SERVER_REC *server)
|
|||||||
/* SYNTAX: UNSILENCE <nick!user@host> */
|
/* SYNTAX: UNSILENCE <nick!user@host> */
|
||||||
static void cmd_unsilence(const char *data, IRC_SERVER_REC *server)
|
static void cmd_unsilence(const char *data, IRC_SERVER_REC *server)
|
||||||
{
|
{
|
||||||
CMD_IRC_SERVER(server);
|
CMD_IRC_SERVER(server);
|
||||||
|
|
||||||
if (*data == '\0')
|
if (*data == '\0')
|
||||||
cmd_return_error(CMDERR_NOT_ENOUGH_PARAMS);
|
cmd_return_error(CMDERR_NOT_ENOUGH_PARAMS);
|
||||||
@ -953,7 +953,7 @@ static void command_2self(const char *data, IRC_SERVER_REC *server)
|
|||||||
char *target, *text;
|
char *target, *text;
|
||||||
void *free_arg;
|
void *free_arg;
|
||||||
|
|
||||||
CMD_IRC_SERVER(server);
|
CMD_IRC_SERVER(server);
|
||||||
|
|
||||||
if (!cmd_get_params(data, &free_arg, 2 | PARAM_FLAG_GETREST, &target, &text))
|
if (!cmd_get_params(data, &free_arg, 2 | PARAM_FLAG_GETREST, &target, &text))
|
||||||
return;
|
return;
|
||||||
@ -998,8 +998,8 @@ void irc_commands_init(void)
|
|||||||
command_bind_irc("admin", NULL, (SIGNAL_FUNC) command_self);
|
command_bind_irc("admin", NULL, (SIGNAL_FUNC) command_self);
|
||||||
/* SYNTAX: INFO [<server>] */
|
/* SYNTAX: INFO [<server>] */
|
||||||
command_bind_irc("info", NULL, (SIGNAL_FUNC) command_self);
|
command_bind_irc("info", NULL, (SIGNAL_FUNC) command_self);
|
||||||
/* SYNTAX: KNOCK <channel> */
|
/* SYNTAX: KNOCK <channel> */
|
||||||
command_bind_irc("knock", NULL, (SIGNAL_FUNC) command_self);
|
command_bind_irc("knock", NULL, (SIGNAL_FUNC) command_self);
|
||||||
/* SYNTAX: LINKS [[<server>] <mask>] */
|
/* SYNTAX: LINKS [[<server>] <mask>] */
|
||||||
command_bind_irc("links", NULL, (SIGNAL_FUNC) command_self);
|
command_bind_irc("links", NULL, (SIGNAL_FUNC) command_self);
|
||||||
/* SYNTAX: LUSERS [<server mask> [<remote server>]] */
|
/* SYNTAX: LUSERS [<server mask> [<remote server>]] */
|
||||||
@ -1081,7 +1081,7 @@ void irc_commands_deinit(void)
|
|||||||
command_unbind("accept", (SIGNAL_FUNC) cmd_accept);
|
command_unbind("accept", (SIGNAL_FUNC) cmd_accept);
|
||||||
command_unbind("admin", (SIGNAL_FUNC) command_self);
|
command_unbind("admin", (SIGNAL_FUNC) command_self);
|
||||||
command_unbind("info", (SIGNAL_FUNC) command_self);
|
command_unbind("info", (SIGNAL_FUNC) command_self);
|
||||||
command_unbind("knock", (SIGNAL_FUNC) command_self);
|
command_unbind("knock", (SIGNAL_FUNC) command_self);
|
||||||
command_unbind("links", (SIGNAL_FUNC) command_self);
|
command_unbind("links", (SIGNAL_FUNC) command_self);
|
||||||
command_unbind("lusers", (SIGNAL_FUNC) command_self);
|
command_unbind("lusers", (SIGNAL_FUNC) command_self);
|
||||||
command_unbind("map", (SIGNAL_FUNC) command_self);
|
command_unbind("map", (SIGNAL_FUNC) command_self);
|
||||||
|
Loading…
Reference in New Issue
Block a user