1
0
mirror of https://github.com/irssi/irssi.git synced 2024-12-04 14:46:39 -05:00

Use g_ascii_str{,n}casecmp for case insensitive comparison with

ascii only strings.


git-svn-id: http://svn.irssi.org/repos/irssi/trunk@4739 dbcabf3a-b0e7-0310-adc4-f8d773084564
This commit is contained in:
Emanuele Giaquinta 2008-03-09 12:17:55 +00:00 committed by exg
parent 7df46597e1
commit 72930e0be3
12 changed files with 35 additions and 35 deletions

View File

@ -836,24 +836,24 @@ int parse_time_interval(const char *time, int *msecs)
return TRUE; return TRUE;
} }
if (g_strncasecmp(desc, "days", len) == 0) { if (g_ascii_strncasecmp(desc, "days", len) == 0) {
if (number > 24) { if (number > 24) {
/* would overflow */ /* would overflow */
return FALSE; return FALSE;
} }
*msecs += number * 1000*3600*24; *msecs += number * 1000*3600*24;
} else if (g_strncasecmp(desc, "hours", len) == 0) } else if (g_ascii_strncasecmp(desc, "hours", len) == 0)
*msecs += number * 1000*3600; *msecs += number * 1000*3600;
else if (g_strncasecmp(desc, "minutes", len) == 0 || else if (g_ascii_strncasecmp(desc, "minutes", len) == 0 ||
g_strncasecmp(desc, "mins", len) == 0) g_ascii_strncasecmp(desc, "mins", len) == 0)
*msecs += number * 1000*60; *msecs += number * 1000*60;
else if (g_strncasecmp(desc, "seconds", len) == 0 || else if (g_ascii_strncasecmp(desc, "seconds", len) == 0 ||
g_strncasecmp(desc, "secs", len) == 0) g_ascii_strncasecmp(desc, "secs", len) == 0)
*msecs += number * 1000; *msecs += number * 1000;
else if (g_strncasecmp(desc, "milliseconds", len) == 0 || else if (g_ascii_strncasecmp(desc, "milliseconds", len) == 0 ||
g_strncasecmp(desc, "millisecs", len) == 0 || g_ascii_strncasecmp(desc, "millisecs", len) == 0 ||
g_strncasecmp(desc, "mseconds", len) == 0 || g_ascii_strncasecmp(desc, "mseconds", len) == 0 ||
g_strncasecmp(desc, "msecs", len) == 0) g_ascii_strncasecmp(desc, "msecs", len) == 0)
*msecs += number; *msecs += number;
else { else {
ret = FALSE; ret = FALSE;
@ -907,13 +907,13 @@ int parse_size(const char *size, int *bytes)
return FALSE; return FALSE;
} }
if (g_strncasecmp(desc, "gbytes", len) == 0) if (g_ascii_strncasecmp(desc, "gbytes", len) == 0)
*bytes += number * 1024*1024*1024; *bytes += number * 1024*1024*1024;
if (g_strncasecmp(desc, "mbytes", len) == 0) if (g_ascii_strncasecmp(desc, "mbytes", len) == 0)
*bytes += number * 1024*1024; *bytes += number * 1024*1024;
if (g_strncasecmp(desc, "kbytes", len) == 0) if (g_ascii_strncasecmp(desc, "kbytes", len) == 0)
*bytes += number * 1024; *bytes += number * 1024;
if (g_strncasecmp(desc, "bytes", len) == 0) if (g_ascii_strncasecmp(desc, "bytes", len) == 0)
*bytes += number; *bytes += number;
/* skip punctuation */ /* skip punctuation */

View File

@ -415,7 +415,7 @@ static void cmd_reconnect(const char *data, SERVER_REC *server)
cmd_param_error(CMDERR_NOT_CONNECTED); cmd_param_error(CMDERR_NOT_CONNECTED);
rec = reconnects->data; rec = reconnects->data;
} else { } else {
if (g_strncasecmp(data, "RECON-", 6) == 0) if (g_ascii_strncasecmp(data, "RECON-", 6) == 0)
data += 6; data += 6;
tagnum = atoi(tag); tagnum = atoi(tag);
@ -439,7 +439,7 @@ static void cmd_disconnect(const char *data, SERVER_REC *server)
{ {
RECONNECT_REC *rec; RECONNECT_REC *rec;
if (g_strncasecmp(data, "RECON-", 6) != 0) if (g_ascii_strncasecmp(data, "RECON-", 6) != 0)
return; /* handle only reconnection removing */ return; /* handle only reconnection removing */
rec = reconnect_find_tag(atoi(data+6)); rec = reconnect_find_tag(atoi(data+6));

View File

@ -77,8 +77,8 @@ static char *server_create_address_tag(const char *address)
/* try to generate a reasonable server tag */ /* try to generate a reasonable server tag */
if (strchr(address, '.') == NULL) { if (strchr(address, '.') == NULL) {
start = end = NULL; start = end = NULL;
} else if (g_strncasecmp(address, "irc", 3) == 0 || } else if (g_ascii_strncasecmp(address, "irc", 3) == 0 ||
g_strncasecmp(address, "chat", 4) == 0) { g_ascii_strncasecmp(address, "chat", 4) == 0) {
/* irc-2.cs.hut.fi -> hut, chat.bt.net -> bt */ /* irc-2.cs.hut.fi -> hut, chat.bt.net -> bt */
end = strrchr(address, '.'); end = strrchr(address, '.');
start = end-1; start = end-1;

View File

@ -269,7 +269,7 @@ static void event_wallops(IRC_SERVER_REC *server, const char *data, const char *
if (ignore_check(SERVER(server), nick, addr, NULL, data, MSGLEVEL_WALLOPS)) if (ignore_check(SERVER(server), nick, addr, NULL, data, MSGLEVEL_WALLOPS))
return; return;
if (g_strncasecmp(data, "\001ACTION ", 8) != 0) if (g_ascii_strncasecmp(data, "\001ACTION ", 8) != 0)
printformat(server, NULL, MSGLEVEL_WALLOPS, IRCTXT_WALLOPS, nick, data); printformat(server, NULL, MSGLEVEL_WALLOPS, IRCTXT_WALLOPS, nick, data);
else { else {
/* Action in WALLOP */ /* Action in WALLOP */

View File

@ -177,7 +177,7 @@ static void cmd_notify(const char *data)
signal_stop(); signal_stop();
} }
if (g_strncasecmp(data, "-list", 4) == 0) { if (g_ascii_strncasecmp(data, "-list", 4) == 0) {
cmd_notifylist_show(); cmd_notifylist_show();
signal_stop(); signal_stop();
} }

View File

@ -974,7 +974,7 @@ static void cmd_window_stick(const char *data)
while (*data == ' ') data++; while (*data == ' ') data++;
} }
if (g_strncasecmp(data, "OF", 2) == 0 || i_toupper(*data) == 'N') { if (g_ascii_strncasecmp(data, "OF", 2) == 0 || i_toupper(*data) == 'N') {
/* unset sticky */ /* unset sticky */
if (!WINDOW_GUI(win)->sticky) { if (!WINDOW_GUI(win)->sticky) {
printformat_window(win, MSGLEVEL_CLIENTERROR, printformat_window(win, MSGLEVEL_CLIENTERROR,

View File

@ -224,7 +224,7 @@ static void ctcp_msg(IRC_SERVER_REC *server, const char *data,
{ {
char *args, *str; char *args, *str;
if (g_strncasecmp(data, "ACTION ", 7) == 0) { if (g_ascii_strncasecmp(data, "ACTION ", 7) == 0) {
/* special treatment for actions */ /* special treatment for actions */
signal_emit("ctcp action", 5, server, data+7, signal_emit("ctcp action", 5, server, data+7,
nick, addr, target); nick, addr, target);

View File

@ -257,7 +257,7 @@ void irc_server_purge_output(IRC_SERVER_REC *server, const char *target)
redirect = tmp->next->data; redirect = tmp->next->data;
if ((target == NULL || command_has_target(cmd, target)) && if ((target == NULL || command_has_target(cmd, target)) &&
g_strncasecmp(cmd, "PONG ", 5) != 0) { g_ascii_strncasecmp(cmd, "PONG ", 5) != 0) {
/* remove the redirection */ /* remove the redirection */
link = tmp->next; link = tmp->next;
server->cmdqueue = server->cmdqueue =

View File

@ -539,7 +539,7 @@ static void cmd_mircdcc(const char *data, SERVER_REC *server,
if (dcc == NULL) return; if (dcc == NULL) return;
dcc->mirc_ctcp = i_toupper(*data) != 'N' && dcc->mirc_ctcp = i_toupper(*data) != 'N' &&
g_strncasecmp(data, "OF", 2) != 0; g_ascii_strncasecmp(data, "OF", 2) != 0;
} }
/* DCC CLOSE CHAT <nick> - check only from chat_ids in open DCC chats, /* DCC CLOSE CHAT <nick> - check only from chat_ids in open DCC chats,
@ -553,7 +553,7 @@ static void cmd_dcc_close(char *data, SERVER_REC *server)
g_return_if_fail(data != NULL); g_return_if_fail(data != NULL);
if (g_strncasecmp(data, "CHAT ", 5) != 0 || if (g_ascii_strncasecmp(data, "CHAT ", 5) != 0 ||
!cmd_get_params(data, &free_arg, 2, NULL, &nick)) !cmd_get_params(data, &free_arg, 2, NULL, &nick))
return; return;
@ -694,11 +694,11 @@ static void dcc_chat_msg(CHAT_DCC_REC *dcc, const char *msg)
g_return_if_fail(msg != NULL); g_return_if_fail(msg != NULL);
reply = FALSE; reply = FALSE;
if (g_strncasecmp(msg, "CTCP_MESSAGE ", 13) == 0) { if (g_ascii_strncasecmp(msg, "CTCP_MESSAGE ", 13) == 0) {
/* bitchx (and ircii?) sends this */ /* bitchx (and ircii?) sends this */
msg += 13; msg += 13;
dcc->mirc_ctcp = FALSE; dcc->mirc_ctcp = FALSE;
} else if (g_strncasecmp(msg, "CTCP_REPLY ", 11) == 0) { } else if (g_ascii_strncasecmp(msg, "CTCP_REPLY ", 11) == 0) {
/* bitchx (and ircii?) sends this */ /* bitchx (and ircii?) sends this */
msg += 11; msg += 11;
reply = TRUE; reply = TRUE;
@ -761,7 +761,7 @@ static void ctcp_reply_dcc_reject(IRC_SERVER_REC *server, const char *data,
/* default REJECT handler checks args too - /* default REJECT handler checks args too -
we don't care about it in DCC chats. */ we don't care about it in DCC chats. */
if (g_strncasecmp(data, "CHAT", 4) == 0 && if (g_ascii_strncasecmp(data, "CHAT", 4) == 0 &&
(data[4] == '\0' || data[4] == ' ')) { (data[4] == '\0' || data[4] == ' ')) {
dcc = dcc_find_request(DCC_CHAT_TYPE, nick, NULL); dcc = dcc_find_request(DCC_CHAT_TYPE, nick, NULL);
if (dcc != NULL) dcc_close(dcc); if (dcc != NULL) dcc_close(dcc);

View File

@ -199,7 +199,7 @@ static void dcc_server_msg(SERVER_DCC_REC *dcc, const char *msg)
g_return_if_fail(msg != NULL); g_return_if_fail(msg != NULL);
/* Check for CHAT protocol */ /* Check for CHAT protocol */
if (g_strncasecmp(msg, "100 ", 4) == 0) { if (g_ascii_strncasecmp(msg, "100 ", 4) == 0) {
msg += 4; msg += 4;
/* Check if this server is accepting chat requests.*/ /* Check if this server is accepting chat requests.*/
if (dcc->accept_chat) { if (dcc->accept_chat) {
@ -227,7 +227,7 @@ static void dcc_server_msg(SERVER_DCC_REC *dcc, const char *msg)
} }
/* Check for FSERVE protocol */ /* Check for FSERVE protocol */
if (g_strncasecmp(msg, "110 ", 4) == 0) { if (g_ascii_strncasecmp(msg, "110 ", 4) == 0) {
msg += 4; msg += 4;
/* Check if this server is accepting fserve requests.*/ /* Check if this server is accepting fserve requests.*/
if (dcc->accept_fserve) { if (dcc->accept_fserve) {
@ -236,7 +236,7 @@ static void dcc_server_msg(SERVER_DCC_REC *dcc, const char *msg)
} }
/* Check for SEND protocol */ /* Check for SEND protocol */
if (g_strncasecmp(msg, "120 ", 4) == 0) { if (g_ascii_strncasecmp(msg, "120 ", 4) == 0) {
msg += 4; msg += 4;
/* Check if this server is accepting send requests.*/ /* Check if this server is accepting send requests.*/
if (dcc->accept_send) { if (dcc->accept_send) {
@ -368,7 +368,7 @@ static void cmd_dcc_close(char *data, SERVER_REC *server)
g_return_if_fail(data != NULL); g_return_if_fail(data != NULL);
if (g_strncasecmp(data, "SERVER ", 7) != 0 || if (g_ascii_strncasecmp(data, "SERVER ", 7) != 0 ||
!cmd_get_params(data, &free_arg, 2, NULL, &port_str)) { !cmd_get_params(data, &free_arg, 2, NULL, &port_str)) {
return; return;
} }

View File

@ -332,7 +332,7 @@ static void sig_server_nick_changed(IRC_SERVER_REC *server)
static void ctcp_msg(IRC_SERVER_REC *server, const char *data, static void ctcp_msg(IRC_SERVER_REC *server, const char *data,
const char *nick, const char *addr, const char *target) const char *nick, const char *addr, const char *target)
{ {
if (g_strncasecmp(data, "dcc ", 4) != 0) if (g_ascii_strncasecmp(data, "dcc ", 4) != 0)
return; return;
data += 4; data += 4;
@ -345,7 +345,7 @@ static void ctcp_msg(IRC_SERVER_REC *server, const char *data,
static void ctcp_reply(IRC_SERVER_REC *server, const char *data, static void ctcp_reply(IRC_SERVER_REC *server, const char *data,
const char *nick, const char *addr, const char *target) const char *nick, const char *addr, const char *target)
{ {
if (g_strncasecmp(data, "dcc ", 4) != 0) if (g_ascii_strncasecmp(data, "dcc ", 4) != 0)
return; return;
data += 4; data += 4;

View File

@ -274,7 +274,7 @@ static void flood_ctcp(IRC_SERVER_REC *server, const char *data,
if (addr == NULL || g_strcasecmp(nick, server->nick) == 0) if (addr == NULL || g_strcasecmp(nick, server->nick) == 0)
return; return;
level = g_strncasecmp(data, "ACTION ", 7) != 0 ? MSGLEVEL_CTCPS : level = g_ascii_strncasecmp(data, "ACTION ", 7) != 0 ? MSGLEVEL_CTCPS :
(ischannel(*target) ? MSGLEVEL_PUBLIC : MSGLEVEL_MSGS); (ischannel(*target) ? MSGLEVEL_PUBLIC : MSGLEVEL_MSGS);
if (!ignore_check(SERVER(server), nick, addr, target, data, level)) if (!ignore_check(SERVER(server), nick, addr, target, data, level))
flood_newmsg(server, level, nick, addr, target); flood_newmsg(server, level, nick, addr, target);