Merge branch 'master' into irssiproxy

Conflicts:
	src/irc/proxy/listen.c
This commit is contained in:
dequis 2015-06-14 10:42:41 -03:00
commit 29fb0d9802
95 changed files with 542 additions and 496 deletions

View file

@ -188,7 +188,7 @@ static void command_set_ban(const char *data, IRC_SERVER_REC *server,
item, &channel, &nicks)) return;
if (!ischannel(*channel)) cmd_param_error(CMDERR_NOT_JOINED);
if (*nicks == '\0') {
if (strcmp(data, "*") != 0)
if (g_strcmp0(data, "*") != 0)
cmd_param_error(CMDERR_NOT_ENOUGH_PARAMS);
/* /BAN * or /UNBAN * - ban/unban everyone */
nicks = (char *) data;
@ -318,7 +318,7 @@ static void cmd_unban(const char *data, IRC_SERVER_REC *server, void *item)
static void read_settings(void)
{
if (default_ban_type_str != NULL &&
strcmp(default_ban_type_str, settings_get_str("ban_type")) == 0)
g_strcmp0(default_ban_type_str, settings_get_str("ban_type")) == 0)
return;
g_free_not_null(default_ban_type_str);

View file

@ -270,7 +270,7 @@ static void event_join(IRC_SERVER_REC *server, const char *data, const char *nic
}
chanrec->joined = TRUE;
if (strcmp(chanrec->name, channel) != 0) {
if (g_strcmp0(chanrec->name, channel) != 0) {
g_free(chanrec->name);
chanrec->name = g_strdup(channel);
}

View file

@ -72,7 +72,7 @@ static void cmd_notice(const char *data, IRC_SERVER_REC *server,
if (!cmd_get_params(data, &free_arg, 2 | PARAM_FLAG_GETREST,
&target, &msg))
return;
if (strcmp(target, "*") == 0)
if (g_strcmp0(target, "*") == 0)
target = item == NULL ? NULL : window_item_get_target(item);
if (target == NULL || *target == '\0' || *msg == '\0')
cmd_param_error(CMDERR_NOT_ENOUGH_PARAMS);
@ -99,7 +99,7 @@ static void cmd_ctcp(const char *data, IRC_SERVER_REC *server,
if (!cmd_get_params(data, &free_arg, 3 | PARAM_FLAG_GETREST,
&target, &ctcpcmd, &ctcpdata))
return;
if (strcmp(target, "*") == 0)
if (g_strcmp0(target, "*") == 0)
target = item == NULL ? NULL : window_item_get_target(item);
if (target == NULL || *target == '\0' || *ctcpcmd == '\0')
cmd_param_error(CMDERR_NOT_ENOUGH_PARAMS);
@ -133,7 +133,7 @@ static void cmd_nctcp(const char *data, IRC_SERVER_REC *server,
if (!cmd_get_params(data, &free_arg, 3 | PARAM_FLAG_GETREST,
&target, &ctcpcmd, &ctcpdata))
return;
if (strcmp(target, "*") == 0)
if (g_strcmp0(target, "*") == 0)
target = item == NULL ? NULL : window_item_get_target(item);
if (target == NULL || *target == '\0' || *ctcpcmd == '\0')
cmd_param_error(CMDERR_NOT_ENOUGH_PARAMS);
@ -238,7 +238,7 @@ static void cmd_invite(const char *data, IRC_SERVER_REC *server, WI_ITEM_REC *it
return;
if (*nick == '\0') cmd_param_error(CMDERR_NOT_ENOUGH_PARAMS);
if (*channame == '\0' || strcmp(channame, "*") == 0) {
if (*channame == '\0' || g_strcmp0(channame, "*") == 0) {
if (!IS_IRC_CHANNEL(item))
cmd_param_error(CMDERR_NOT_JOINED);
@ -284,13 +284,13 @@ static void cmd_who(const char *data, IRC_SERVER_REC *server,
if (!cmd_get_params(data, &free_arg, 2 | PARAM_FLAG_GETREST, &channel, &rest))
return;
if (strcmp(channel, "*") == 0 || *channel == '\0') {
if (g_strcmp0(channel, "*") == 0 || *channel == '\0') {
if (!IS_IRC_CHANNEL(item))
cmd_param_error(CMDERR_NOT_JOINED);
channel = IRC_CHANNEL(item)->name;
}
if (strcmp(channel, "**") == 0) {
if (g_strcmp0(channel, "**") == 0) {
/* ** displays all nicks.. */
*channel = '\0';
}
@ -313,14 +313,14 @@ static void cmd_names(const char *data, IRC_SERVER_REC *server,
PARAM_FLAG_GETREST, "names", &optlist, &channel))
return;
if (strcmp(channel, "*") == 0 || *channel == '\0') {
if (g_strcmp0(channel, "*") == 0 || *channel == '\0') {
if (!IS_IRC_CHANNEL(item))
cmd_param_error(CMDERR_NOT_JOINED);
channel = IRC_CHANNEL(item)->name;
}
if (strcmp(channel, "**") == 0) {
if (g_strcmp0(channel, "**") == 0) {
/* ** displays all nicks.. */
irc_send_cmd(server, "NAMES");
} else {
@ -409,7 +409,7 @@ static void cmd_whois(const char *data, IRC_SERVER_REC *server,
query = qserver = queryitem->name;
}
if (strcmp(query, "*") == 0 &&
if (g_strcmp0(query, "*") == 0 &&
g_hash_table_lookup(optlist, "yes") == NULL)
cmd_param_error(CMDERR_NOT_GOOD_IDEA);
@ -810,7 +810,7 @@ static void cmd_knockout(const char *data, IRC_SERVER_REC *server,
for (ptr = server->knockoutlist; ptr != NULL; ptr = ptr->next) {
rec = ptr->data;
if (channel == rec->channel &&
!strcmp(rec->ban, banmasks))
!g_strcmp0(rec->ban, banmasks))
break;
}
if (ptr == NULL) {

View file

@ -67,13 +67,13 @@ static void check_query_changes(IRC_SERVER_REC *server, const char *nick,
if (query == NULL)
return;
if (strcmp(query->name, nick) != 0) {
if (g_strcmp0(query->name, nick) != 0) {
/* upper/lowercase chars in nick changed */
query_change_nick(query, nick);
}
if (address != NULL && (query->address == NULL ||
strcmp(query->address, address) != 0)) {
g_strcmp0(query->address, address) != 0)) {
/* host changed */
query_change_address(query, address);
}
@ -109,7 +109,7 @@ static void event_nick(SERVER_REC *server, const char *data,
query = query_find(server, orignick);
if (query != NULL) {
params = event_get_params(data, 1, &nick);
if (strcmp(query->name, nick) != 0)
if (g_strcmp0(query->name, nick) != 0)
query_change_nick(query, nick);
g_free(params);
}

View file

@ -314,6 +314,8 @@ SERVER_REC *irc_server_init_connect(SERVER_CONNECT_REC *conn)
void irc_server_connect(SERVER_REC *server)
{
g_return_if_fail(server != NULL);
if (!server_start_connect(server)) {
server_connect_unref(server->connrec);
g_free(server);
@ -638,7 +640,7 @@ static void event_connected(IRC_SERVER_REC *server, const char *data, const char
params = event_get_params(data, 1, &nick);
if (strcmp(server->nick, nick) != 0) {
if (g_strcmp0(server->nick, nick) != 0) {
/* nick changed unexpectedly .. connected via proxy, etc. */
g_free(server->nick);
server->nick = g_strdup(nick);

View file

@ -66,7 +66,7 @@ static void sig_session_save_server(IRC_SERVER_REC *server, CONFIG_REC *config,
config_node_set_bool(config, node, "emode_known", server->emode_known);
config_node_set_bool(config, node, "isupport_sent", server->isupport_sent);
isupport = config_node_section(node, "isupport", NODE_TYPE_BLOCK);
isupport = config_node_section(config, node, "isupport", NODE_TYPE_BLOCK);
isupport_data.config = config;
isupport_data.node = isupport;
@ -95,7 +95,7 @@ static void sig_session_restore_server(IRC_SERVER_REC *server,
(GCompareFunc) g_istr_equal);
}
node = config_node_section(node, "isupport", -1);
node = config_node_section(NULL, node, "isupport", -1);
tmp = node == NULL ? NULL : config_node_first(node->value);
for (; tmp != NULL; tmp = config_node_next(tmp)) {

View file

@ -398,7 +398,7 @@ void parse_channel_modes(IRC_CHANNEL_REC *channel, const char *setby,
old_key = NULL;
}
if (strcmp(newmode->str, channel->mode) != 0) {
if (g_strcmp0(newmode->str, channel->mode) != 0) {
g_free(channel->mode);
channel->mode = g_strdup(newmode->str);
@ -842,7 +842,7 @@ static void cmd_mode(const char *data, IRC_SERVER_REC *server,
return;
}
if (strcmp(target, "*") == 0) {
if (g_strcmp0(target, "*") == 0) {
if (!IS_IRC_CHANNEL(channel))
cmd_param_error(CMDERR_NOT_JOINED);

View file

@ -339,7 +339,7 @@ static GSList *redirect_cmd_list_find(GSList *list, const char *event)
while (list != NULL) {
const char *str = list->data;
if (strcmp(str, event) == 0)
if (g_strcmp0(str, event) == 0)
break;
list = list->next->next;
}
@ -365,7 +365,7 @@ static const char *redirect_match(REDIRECT_REC *redirect, const char *event,
use the default signal */
signal = NULL;
for (tmp = redirect->signals; tmp != NULL; tmp = tmp->next->next) {
if (strcmp(tmp->data, event) == 0) {
if (g_strcmp0(tmp->data, event) == 0) {
signal = tmp->next->data;
break;
}
@ -527,7 +527,7 @@ server_redirect_get(IRC_SERVER_REC *server, const char *prefix,
next = ptr->next;
r = ptr->data;
if (prefix != NULL && r->prefix != NULL &&
strcmp(prefix, r->prefix)) {
g_strcmp0(prefix, r->prefix)) {
/* not from this server */
continue;
}

View file

@ -57,7 +57,7 @@ static void sig_dcc_request(GET_DCC_REC *dcc, const char *nickaddr)
/* don't autoget files beginning with a dot, if download dir is
our home dir (stupid kludge for stupid people) */
if (*dcc->arg == '.' &&
strcmp(settings_get_str("dcc_download_path"), "~") == 0)
g_strcmp0(settings_get_str("dcc_download_path"), "~") == 0)
return;
/* check file size limit, NOTE: it's still possible to send a

View file

@ -191,7 +191,7 @@ static void cmd_msg(const char *data, SERVER_REC *server, WI_ITEM_REC *item)
return;
/* handle only DCC messages */
if (strcmp(target, "*") == 0)
if (g_strcmp0(target, "*") == 0)
dcc = item_get_dcc(item);
else if (*target == '=')
dcc = dcc_chat_find_id(target+1);
@ -625,7 +625,7 @@ static void ctcp_msg_dcc_chat(IRC_SERVER_REC *server, const char *data,
g_strfreev(params);
return;
}
passive = paramcount == 4 && strcmp(params[2], "0") == 0;
passive = paramcount == 4 && g_strcmp0(params[2], "0") == 0;
dcc = DCC_CHAT(dcc_find_request(DCC_CHAT_TYPE, nick, NULL));
if (dcc != NULL) {

View file

@ -554,7 +554,7 @@ void cmd_dcc_receive(const char *data, DCC_GET_FUNC accept_func,
next = tmp->next;
if (IS_DCC_GET(dcc) && g_ascii_strcasecmp(dcc->nick, nick) == 0 &&
(dcc_is_waiting_user(dcc) || dcc->from_dccserver) &&
(*fname == '\0' || strcmp(dcc->arg, fname) == 0)) {
(*fname == '\0' || g_strcmp0(dcc->arg, fname) == 0)) {
found = TRUE;
if (!dcc_is_passive(dcc))
accept_func(dcc);

View file

@ -149,7 +149,7 @@ DCC_REC *dcc_find_request(int type, const char *nick, const char *arg)
if (dcc->type == type && !dcc_is_connected(dcc) &&
g_ascii_strcasecmp(dcc->nick, nick) == 0 &&
(arg == NULL || strcmp(dcc->arg, arg) == 0))
(arg == NULL || g_strcmp0(dcc->arg, arg) == 0))
return dcc;
}
@ -516,7 +516,7 @@ static void cmd_dcc_close(char *data, IRC_SERVER_REC *server)
next = tmp->next;
if (dcc->type == type && g_ascii_strcasecmp(dcc->nick, nick) == 0 &&
(*arg == '\0' || strcmp(dcc->arg, arg) == 0)) {
(*arg == '\0' || g_strcmp0(dcc->arg, arg) == 0)) {
dcc_reject(dcc, server);
found = TRUE;
}

View file

@ -30,7 +30,7 @@ void notifylist_add_config(NOTIFYLIST_REC *rec)
CONFIG_NODE *node;
node = iconfig_node_traverse("notifies", TRUE);
node = config_node_section(node, rec->mask, NODE_TYPE_BLOCK);
node = iconfig_node_section(node, rec->mask, NODE_TYPE_BLOCK);
if (rec->away_check)
iconfig_node_set_bool(node, "away_check", TRUE);
@ -39,7 +39,7 @@ void notifylist_add_config(NOTIFYLIST_REC *rec)
iconfig_node_set_str(node, "ircnets", NULL);
if (rec->ircnets != NULL && *rec->ircnets != NULL) {
node = config_node_section(node, "ircnets", NODE_TYPE_LIST);
node = iconfig_node_section(node, "ircnets", NODE_TYPE_LIST);
iconfig_node_add_list(node, rec->ircnets);
}
}
@ -73,7 +73,7 @@ void notifylist_read_config(void)
rec->mask = g_strdup(node->key);
rec->away_check = config_node_get_bool(node, "away_check", FALSE);
node = config_node_section(node, "ircnets", -1);
node = iconfig_node_section(node, "ircnets", -1);
if (node != NULL) rec->ircnets = config_node_get_list(node);
}
}

View file

@ -91,7 +91,7 @@ int notifylist_ircnets_match(NOTIFYLIST_REC *rec, const char *ircnet)
if (rec->ircnets == NULL) return TRUE;
if (ircnet == NULL) return FALSE;
if (strcmp(ircnet, "*") == 0) return TRUE;
if (g_strcmp0(ircnet, "*") == 0) return TRUE;
for (tmp = rec->ircnets; *tmp != NULL; tmp++) {
if (g_ascii_strcasecmp(*tmp, ircnet) == 0)

View file

@ -209,7 +209,7 @@ static void dump_join(IRC_CHANNEL_REC *channel, CLIENT_REC *client)
void proxy_client_reset_nick(CLIENT_REC *client)
{
if (client->server == NULL ||
strcmp(client->nick, client->server->nick) == 0)
g_strcmp0(client->nick, client->server->nick) == 0)
return;
proxy_outdata(client, ":%s!proxy NICK :%s\n",

View file

@ -84,7 +84,7 @@ static void grab_who(CLIENT_REC *client, const char *channel)
arg = g_string_new(channel);
for (tmp = list, count = 0; *tmp != NULL; tmp++, count++) {
if (strcmp(*tmp, "0") == 0) {
if (g_strcmp0(*tmp, "0") == 0) {
/* /who 0 displays everyone */
**tmp = '*';
}
@ -108,18 +108,18 @@ static void handle_client_connect_cmd(CLIENT_REC *client,
password = settings_get_str("irssiproxy_password");
if (password != NULL && strcmp(cmd, "PASS") == 0) {
if (strcmp(password, args) == 0)
if (password != NULL && g_strcmp0(cmd, "PASS") == 0) {
if (g_strcmp0(password, args) == 0)
client->pass_sent = TRUE;
else {
/* wrong password! */
remove_client(client);
return;
}
} else if (strcmp(cmd, "NICK") == 0) {
} else if (g_strcmp0(cmd, "NICK") == 0) {
g_free_not_null(client->nick);
client->nick = g_strdup(args);
} else if (strcmp(cmd, "USER") == 0) {
} else if (g_strcmp0(cmd, "USER") == 0) {
client->user_sent = TRUE;
}
@ -147,12 +147,12 @@ static void handle_client_cmd(CLIENT_REC *client, char *cmd, char *args,
return;
}
if (strcmp(cmd, "QUIT") == 0) {
if (g_strcmp0(cmd, "QUIT") == 0) {
remove_client(client);
return;
}
if (strcmp(cmd, "PING") == 0) {
if (g_strcmp0(cmd, "PING") == 0) {
/* Reply to PING, if the target parameter is either
proxy_adress, our own nick or empty. */
char *params, *origin, *target;
@ -170,7 +170,7 @@ static void handle_client_cmd(CLIENT_REC *client, char *cmd, char *args,
g_free(params);
}
if (strcmp(cmd, "PROXY") == 0) {
if (g_strcmp0(cmd, "PROXY") == 0) {
if (g_ascii_strcasecmp(args, "CTCP ON") == 0) {
/* client wants all ctcps */
client->want_ctcp = 1;
@ -206,11 +206,11 @@ static void handle_client_cmd(CLIENT_REC *client, char *cmd, char *args,
}
/* check if the command could be redirected */
if (strcmp(cmd, "WHO") == 0)
if (g_strcmp0(cmd, "WHO") == 0)
grab_who(client, args);
else if (strcmp(cmd, "WHOWAS") == 0)
else if (g_strcmp0(cmd, "WHOWAS") == 0)
proxy_redirect_event(client, "whowas", 1, args, -1);
else if (strcmp(cmd, "WHOIS") == 0) {
else if (g_strcmp0(cmd, "WHOIS") == 0) {
char *p;
/* convert dots to spaces */
@ -218,11 +218,11 @@ static void handle_client_cmd(CLIENT_REC *client, char *cmd, char *args,
if (*p == ',') *p = ' ';
proxy_redirect_event(client, "whois", 1, args, TRUE);
} else if (strcmp(cmd, "ISON") == 0)
} else if (g_strcmp0(cmd, "ISON") == 0)
proxy_redirect_event(client, "ison", 1, args, -1);
else if (strcmp(cmd, "USERHOST") == 0)
else if (g_strcmp0(cmd, "USERHOST") == 0)
proxy_redirect_event(client, "userhost", 1, args, -1);
else if (strcmp(cmd, "MODE") == 0) {
else if (g_strcmp0(cmd, "MODE") == 0) {
/* convert dots to spaces */
char *slist, *str, mode, *p;
int argc;
@ -258,7 +258,7 @@ static void handle_client_cmd(CLIENT_REC *client, char *cmd, char *args,
}
g_free(str);
g_free(slist);
} else if (strcmp(cmd, "PRIVMSG") == 0) {
} else if (g_strcmp0(cmd, "PRIVMSG") == 0) {
/* send the message to other clients as well */
char *params, *target, *msg;
@ -289,9 +289,9 @@ static void handle_client_cmd(CLIENT_REC *client, char *cmd, char *args,
}
ignore_next = FALSE;
g_free(params);
} else if (strcmp(cmd, "PING") == 0) {
} else if (g_strcmp0(cmd, "PING") == 0) {
proxy_redirect_event(client, "ping", 1, NULL, TRUE);
} else if (strcmp(cmd, "AWAY") == 0) {
} else if (g_strcmp0(cmd, "AWAY") == 0) {
/* set the away reason */
if (args != NULL) {
g_free(client->server->away_reason);
@ -354,7 +354,7 @@ static void sig_listen(LISTEN_REC *listen)
rec->handle = sendbuf;
rec->host = g_strdup(host);
rec->port = port;
if (strcmp(listen->ircnet, "*") == 0) {
if (g_strcmp0(listen->ircnet, "*") == 0) {
rec->proxy_address = g_strdup("irc.proxy");
rec->server = servers == NULL ? NULL : IRC_SERVER(servers->data);
} else {
@ -423,7 +423,7 @@ static void sig_server_event(IRC_SERVER_REC *server, const char *line,
}
}
if (strcmp(event, "event privmsg") == 0 &&
if (g_strcmp0(event, "event privmsg") == 0 &&
strstr(args, " :\001") != NULL &&
strstr(args, " :\001ACTION") == NULL) {
/* CTCP - either answer ourself or forward it to one client */
@ -443,8 +443,8 @@ static void sig_server_event(IRC_SERVER_REC *server, const char *line,
return;
}
if (strcmp(event, "event ping") == 0 ||
strcmp(event, "event pong") == 0) {
if (g_strcmp0(event, "event ping") == 0 ||
g_strcmp0(event, "event pong") == 0) {
/* We want to answer ourself to PINGs and CTCPs.
Also hide PONGs from clients. */
g_free(event);
@ -470,7 +470,7 @@ static void event_connected(IRC_SERVER_REC *server)
CLIENT_REC *rec = tmp->data;
if (rec->connected && rec->server == NULL &&
(strcmp(rec->listen->ircnet, "*") == 0 ||
(g_strcmp0(rec->listen->ircnet, "*") == 0 ||
(chatnet != NULL &&
g_ascii_strcasecmp(chatnet, rec->listen->ircnet) == 0))) {
proxy_outdata(rec, ":%s NOTICE %s :Connected to server\n",