Use rb_* versions of nonportable string functions

This commit is contained in:
Elizabeth Myers 2016-04-05 05:39:59 -05:00
parent 508e25a85b
commit f956cb0f1f
22 changed files with 44 additions and 66 deletions

View file

@ -208,7 +208,7 @@ main(int argc, char *argv[])
rb_set_time();
setup_signals();
authd_option_handlers = rb_dictionary_create("authd options handlers", strcasecmp);
authd_option_handlers = rb_dictionary_create("authd options handlers", rb_strcasecmp);
init_resolver();
init_providers();

View file

@ -599,7 +599,7 @@ static int check_question(struct reslist *request, HEADER * header, char *buf, c
sizeof(hostbuf));
if (n <= 0)
return 0;
if (strcasecmp(hostbuf, request->queryname))
if (rb_strcasecmp(hostbuf, request->queryname))
return 0;
return 1;
}

View file

@ -243,9 +243,9 @@ parse_resvconf(void)
if ((p = strpbrk(arg, " \t")) != NULL)
*p = '\0'; /* take the first word */
if (strcasecmp(opt, "domain") == 0)
if (rb_strcasecmp(opt, "domain") == 0)
rb_strlcpy(irc_domain, arg, sizeof(irc_domain));
else if (strcasecmp(opt, "nameserver") == 0)
else if (rb_strcasecmp(opt, "nameserver") == 0)
add_nameserver(arg);
}

View file

@ -576,7 +576,7 @@ hurt_find_exact(const char *ip)
{
hurt = (hurt_t *) ptr->data;
if (!strcasecmp(ip, hurt->ip))
if (!rb_strcasecmp(ip, hurt->ip))
return hurt;
}

View file

@ -46,7 +46,7 @@ umode_noctcp_process(hook_data_privmsg_user *data) {
return;
}
if (data->target_p->umodes & user_modes['C'] && *data->text == '\001' && strncasecmp(data->text + 1, "ACTION", 6)) {
if (data->target_p->umodes & user_modes['C'] && *data->text == '\001' && rb_strncasecmp(data->text + 1, "ACTION", 6)) {
sendto_one_numeric(data->source_p, ERR_CANNOTSENDTOUSER, form_str(ERR_CANNOTSENDTOUSER), data->target_p->name, "+C set");
data->approved = ERR_CANNOTSENDTOUSER;
return;

View file

@ -117,7 +117,7 @@ start_authd(void)
cid_clients = rb_dictionary_create("authd cid to uid mapping", rb_uint32cmp);
if(bl_stats == NULL)
bl_stats = rb_dictionary_create("blacklist statistics", strcasecmp);
bl_stats = rb_dictionary_create("blacklist statistics", rb_strcasecmp);
if(timeout_ev == NULL)
timeout_ev = rb_event_addish("timeout_dead_authd_clients", timeout_dead_authd_clients, NULL, 1);

View file

@ -68,8 +68,8 @@ init_cache(void)
oper_motd = cache_file(ircd_paths[IRCD_PATH_IRCD_OMOTD], "opers.motd", 0);
memset(&links_cache_list, 0, sizeof(links_cache_list));
help_dict_oper = rb_dictionary_create("oper help", strcasecmp);
help_dict_user = rb_dictionary_create("user help", strcasecmp);
help_dict_oper = rb_dictionary_create("oper help", rb_strcasecmp);
help_dict_user = rb_dictionary_create("user help", rb_strcasecmp);
}
/*

View file

@ -143,7 +143,7 @@ capability_index_create(const char *name)
idx = rb_malloc(sizeof(struct CapabilityIndex));
idx->name = name;
idx->cap_dict = rb_dictionary_create(name, strcasecmp);
idx->cap_dict = rb_dictionary_create(name, rb_strcasecmp);
idx->highest_bit = 1;
rb_dlinkAdd(idx, &idx->node, &capability_indexes);

View file

@ -251,6 +251,6 @@ void hashcomment(void)
if (strlen(yytext) < sizeof(INCLUDE) - 1)
return;
if (!strncasecmp(yytext, INCLUDE, sizeof(INCLUDE) - 1))
if (!rb_strncasecmp(yytext, INCLUDE, sizeof(INCLUDE) - 1))
yyerror("You probably meant '.include', skipping");
}

View file

@ -58,8 +58,8 @@ time_t conf_find_time(char *name)
for (i = 0; ircd_times[i].name; i++)
{
if (strcasecmp(ircd_times[i].name, name) == 0 ||
(ircd_times[i].plural && strcasecmp(ircd_times[i].plural, name) == 0))
if (rb_strcasecmp(ircd_times[i].name, name) == 0 ||
(ircd_times[i].plural && rb_strcasecmp(ircd_times[i].plural, name) == 0))
return ircd_times[i].val;
}
@ -86,7 +86,7 @@ static int conf_get_yesno_value(char *str)
for (i = 0; yesno[i].word; i++)
{
if (strcasecmp(str, yesno[i].word) == 0)
if (rb_strcasecmp(str, yesno[i].word) == 0)
{
return yesno[i].yesno;
}

View file

@ -255,7 +255,7 @@ load_all_modules(bool warn)
size_t len = strlen(ldirent->d_name);
if(len > module_ext_len &&
strncasecmp(ldirent->d_name + (len - module_ext_len), LT_MODULE_EXT, module_ext_len) == 0)
rb_strncasecmp(ldirent->d_name + (len - module_ext_len), LT_MODULE_EXT, module_ext_len) == 0)
{
(void) snprintf(module_fq_name, sizeof(module_fq_name), "%s%c%s",
ircd_paths[IRCD_PATH_AUTOLOAD_MODULES], RB_PATH_SEPARATOR, ldirent->d_name);

View file

@ -114,7 +114,7 @@ find_top_conf(const char *name)
RB_DLINK_FOREACH(d, conf_items.head)
{
tc = d->data;
if(strcasecmp(tc->tc_name, name) == 0)
if(rb_strcasecmp(tc->tc_name, name) == 0)
return tc;
}
@ -136,7 +136,7 @@ find_conf_item(const struct TopConf *top, const char *name)
{
cf = &top->tc_entries[i];
if(!strcasecmp(cf->cf_name, name))
if(!rb_strcasecmp(cf->cf_name, name))
return cf;
}
}
@ -144,7 +144,7 @@ find_conf_item(const struct TopConf *top, const char *name)
RB_DLINK_FOREACH(d, top->tc_items.head)
{
cf = d->data;
if(strcasecmp(cf->cf_name, name) == 0)
if(rb_strcasecmp(cf->cf_name, name) == 0)
return cf;
}
@ -1395,10 +1395,10 @@ conf_set_connect_aftype(void *data)
{
char *aft = data;
if(strcasecmp(aft, "ipv4") == 0)
if(rb_strcasecmp(aft, "ipv4") == 0)
yy_server->aftype = AF_INET;
#ifdef RB_IPV6
else if(strcasecmp(aft, "ipv6") == 0)
else if(rb_strcasecmp(aft, "ipv6") == 0)
yy_server->aftype = AF_INET6;
#endif
else
@ -1549,11 +1549,11 @@ conf_set_general_hide_error_messages(void *data)
{
char *val = data;
if(strcasecmp(val, "yes") == 0)
if(rb_strcasecmp(val, "yes") == 0)
ConfigFileEntry.hide_error_messages = 2;
else if(strcasecmp(val, "opers") == 0)
else if(rb_strcasecmp(val, "opers") == 0)
ConfigFileEntry.hide_error_messages = 1;
else if(strcasecmp(val, "no") == 0)
else if(rb_strcasecmp(val, "no") == 0)
ConfigFileEntry.hide_error_messages = 0;
else
conf_report_error("Invalid setting '%s' for general::hide_error_messages.", val);
@ -1573,11 +1573,11 @@ conf_set_general_stats_k_oper_only(void *data)
{
char *val = data;
if(strcasecmp(val, "yes") == 0)
if(rb_strcasecmp(val, "yes") == 0)
ConfigFileEntry.stats_k_oper_only = 2;
else if(strcasecmp(val, "masked") == 0)
else if(rb_strcasecmp(val, "masked") == 0)
ConfigFileEntry.stats_k_oper_only = 1;
else if(strcasecmp(val, "no") == 0)
else if(rb_strcasecmp(val, "no") == 0)
ConfigFileEntry.stats_k_oper_only = 0;
else
conf_report_error("Invalid setting '%s' for general::stats_k_oper_only.", val);
@ -1588,11 +1588,11 @@ conf_set_general_stats_i_oper_only(void *data)
{
char *val = data;
if(strcasecmp(val, "yes") == 0)
if(rb_strcasecmp(val, "yes") == 0)
ConfigFileEntry.stats_i_oper_only = 2;
else if(strcasecmp(val, "masked") == 0)
else if(rb_strcasecmp(val, "masked") == 0)
ConfigFileEntry.stats_i_oper_only = 1;
else if(strcasecmp(val, "no") == 0)
else if(rb_strcasecmp(val, "no") == 0)
ConfigFileEntry.stats_i_oper_only = 0;
else
conf_report_error("Invalid setting '%s' for general::stats_i_oper_only.", val);
@ -1667,11 +1667,11 @@ conf_set_general_certfp_method(void *data)
{
char *method = data;
if (!strcasecmp(method, "sha1"))
if (!rb_strcasecmp(method, "sha1"))
ConfigFileEntry.certfp_method = RB_SSL_CERTFP_METH_SHA1;
else if (!strcasecmp(method, "sha256"))
else if (!rb_strcasecmp(method, "sha256"))
ConfigFileEntry.certfp_method = RB_SSL_CERTFP_METH_SHA256;
else if (!strcasecmp(method, "sha512"))
else if (!rb_strcasecmp(method, "sha512"))
ConfigFileEntry.certfp_method = RB_SSL_CERTFP_METH_SHA512;
else
{
@ -1884,9 +1884,9 @@ conf_set_blacklist_type(void *data)
for (; args; args = args->next)
{
if (!strcasecmp(args->v.string, "ipv4"))
if (!rb_strcasecmp(args->v.string, "ipv4"))
yy_blacklist_iptype |= IPTYPE_IPV4;
else if (!strcasecmp(args->v.string, "ipv6"))
else if (!rb_strcasecmp(args->v.string, "ipv6"))
yy_blacklist_iptype |= IPTYPE_IPV6;
else
conf_report_error("blacklist::type has unknown address family %s",

View file

@ -295,7 +295,7 @@ handle_encap(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *so
void
clear_hash_parse()
{
cmd_dict = rb_dictionary_create("command", strcasecmp);
cmd_dict = rb_dictionary_create("command", rb_strcasecmp);
}
/* mod_add_cmd

View file

@ -51,7 +51,7 @@ privilegeset_get_any(const char *name)
{
struct PrivilegeSet *set = (struct PrivilegeSet *) iter->data;
if (!strcasecmp(set->name, name))
if (!rb_strcasecmp(set->name, name))
return set;
}

View file

@ -814,7 +814,7 @@ set_default_conf(void)
ConfigFileEntry.hide_opers_in_whois = 0;
if (!alias_dict)
alias_dict = rb_dictionary_create("alias", strcasecmp);
alias_dict = rb_dictionary_create("alias", rb_strcasecmp);
}
/*

View file

@ -397,7 +397,7 @@ check_server(const char *name, struct Client *client_p)
if(tmp_p->certfp)
{
if(!client_p->certfp || strcasecmp(tmp_p->certfp, client_p->certfp) != 0)
if(!client_p->certfp || rb_strcasecmp(tmp_p->certfp, client_p->certfp) != 0)
continue;
}

View file

@ -135,7 +135,7 @@ char *substitution_parse(const char *fmt, rb_dlink_list *varlist)
{
struct substitution_variable *val = (struct substitution_variable *) nptr->data;
if (!strcasecmp(varname, val->name))
if (!rb_strcasecmp(varname, val->name))
{
rb_strlcpy(bptr, val->value, BUFSIZE - (bptr - buf));
bptr += strlen(val->value);

View file

@ -53,7 +53,7 @@ chm_noctcp_process(hook_data_privmsg_channel *data)
if (data->approved || data->msgtype == MESSAGE_TYPE_NOTICE)
return;
if (*data->text == '\001' && strncasecmp(data->text + 1, "ACTION ", 7) && data->chptr->mode.mode & mode_noctcp)
if (*data->text == '\001' && rb_strncasecmp(data->text + 1, "ACTION ", 7) && data->chptr->mode.mode & mode_noctcp)
{
sendto_one_numeric(data->source_p, ERR_CANNOTSENDTOCHAN, form_str(ERR_CANNOTSENDTOCHAN), data->chptr->chname);
data->approved = ERR_CANNOTSENDTOCHAN;

View file

@ -67,7 +67,7 @@ is_safe_error(const char *message)
if (!strncmp(message, "Terminated by ", 14))
return true;
if (!strncasecmp(message, "Closing Link", 12))
if (!rb_strncasecmp(message, "Closing Link", 12))
return false;
if (strchr(message, '['))
return false;

View file

@ -240,7 +240,7 @@ m_challenge(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *sou
if (oper_p->certfp != NULL)
{
if (source_p->certfp == NULL || strcasecmp(source_p->certfp, oper_p->certfp))
if (source_p->certfp == NULL || rb_strcasecmp(source_p->certfp, oper_p->certfp))
{
sendto_one_numeric(source_p, ERR_NOOPERHOST, form_str(ERR_NOOPERHOST));
ilog(L_FOPER, "FAILED OPER (%s) by (%s!%s@%s) (%s) -- client certificate fingerprint mismatch",

View file

@ -117,7 +117,7 @@ m_oper(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p
if (oper_p->certfp != NULL)
{
if (source_p->certfp == NULL || strcasecmp(source_p->certfp, oper_p->certfp))
if (source_p->certfp == NULL || rb_strcasecmp(source_p->certfp, oper_p->certfp))
{
sendto_one_numeric(source_p, ERR_NOOPERHOST, form_str(ERR_NOOPERHOST));
ilog(L_FOPER, "FAILED OPER (%s) by (%s!%s@%s) (%s) -- client certificate fingerprint mismatch",

View file

@ -156,28 +156,6 @@ ws_frame_set_fin(ws_frame_hdr_t *header, int fin)
header->opcode_rsv_fin |= (fin << 7) & (0x1 << 7);
}
#ifdef _WIN32
char *
strcasestr(const char *s, const char *find)
{
char c, sc;
size_t len;
if ((c = *find++) != 0) {
c = tolower((unsigned char)c);
len = strlen(find);
do {
do {
if ((sc = *s++) == 0)
return (NULL);
} while ((char)tolower((unsigned char)sc) != c);
} while (strnicmp(s, find, len) != 0);
s--;
}
return ((char *)s);
}
#endif
static void close_conn(conn_t * conn, int wait_plain, const char *fmt, ...);
static void conn_mod_read_cb(rb_fde_t *fd, void *data);
static void conn_plain_read_cb(rb_fde_t *fd, void *data);
@ -682,7 +660,7 @@ conn_mod_handshake_process(conn_t *conn)
if (!dolen)
break;
if ((p = strcasestr(inbuf, "Sec-WebSocket-Key:")) != NULL)
if ((p = rb_strcasestr(inbuf, "Sec-WebSocket-Key:")) != NULL)
{
char *start, *end;