1
0
mirror of https://github.com/unrealircd/unrealircd.git synced 2026-06-12 19:14:46 +02:00

Get rid of stricmp/strnicmp (use strcasecmp/strncasecmp)

This commit is contained in:
Bram Matthys
2019-09-09 16:13:32 +02:00
parent 9636f83a2b
commit 7d4b7c2fed
26 changed files with 76 additions and 83 deletions
+1 -8
View File
@@ -285,16 +285,9 @@
#define LOGFILE LPATH
#else
#define Debug(x) ;
#if VMS
#define LOGFILE "NLA0:"
#else
#define LOGFILE "/dev/null"
#endif
#define LOGFILE "/dev/null"
#endif
// FIXME: get rid of this
# define stricmp strcasecmp
# define strnicmp strncasecmp
#if defined(DEFAULT_RECVQ)
# if (DEFAULT_RECVQ < 512)
error DEFAULT_RECVQ needs redefining.
+2 -2
View File
@@ -42,8 +42,8 @@
#define LIST_SHOW_MODES
#ifndef mode_t
#define GOT_STRCASECMP
#define strcasecmp _stricmp
#define strncasecmp _strnicmp
#define strcasecmp _strcasecmp
#define strncasecmp _strncasecmp
#define HAVE_EXPLICIT_BZERO
#define explicit_bzero(a,b) SecureZeroMemory(a,b)
#define HAVE_INET_PTON
+2 -2
View File
@@ -41,7 +41,7 @@ ClientCapability *ClientCapabilityFindReal(const char *token)
for (clicap = clicaps; clicap; clicap = clicap->next)
{
if (!stricmp(token, clicap->name))
if (!strcasecmp(token, clicap->name))
return clicap;
}
@@ -61,7 +61,7 @@ ClientCapability *ClientCapabilityFind(const char *token, aClient *sptr)
for (clicap = clicaps; clicap; clicap = clicap->next)
{
if (!stricmp(token, clicap->name))
if (!strcasecmp(token, clicap->name))
{
if (clicap->visible && !clicap->visible(sptr))
return NULL; /* hidden */
+1 -1
View File
@@ -25,7 +25,7 @@ int CommandExists(char *name)
for (p = CommandHash[toupper(*name)]; p; p = p->next)
{
if (!stricmp(p->cmd, name))
if (!strcasecmp(p->cmd, name))
return 1;
}
+1 -1
View File
@@ -41,7 +41,7 @@ HistoryBackend *HistoryBackendFind(const char *name)
for (m = historybackends; m; m = m->next)
{
if (!stricmp(name, m->name))
if (!strcasecmp(name, m->name))
return m;
}
return NULL;
+1 -1
View File
@@ -160,7 +160,7 @@ Isupport *IsupportFind(const char *token)
for (isupport = Isupports; isupport; isupport = isupport->next)
{
if (!stricmp(token, isupport->token))
if (!strcasecmp(token, isupport->token))
return isupport;
}
return NULL;
+1 -1
View File
@@ -41,7 +41,7 @@ MessageTagHandler *MessageTagHandlerFind(const char *token)
for (m = mtaghandlers; m; m = m->next)
{
if (!stricmp(token, m->name))
if (!strcasecmp(token, m->name))
return m;
}
return NULL;
+24 -24
View File
@@ -2002,7 +2002,7 @@ int load_conf(char *filename, const char *original_path)
continue;
}
#ifdef _WIN32
if (!stricmp(filename, inc->file))
if (!strcasecmp(filename, inc->file))
{
counter ++;
continue;
@@ -2750,7 +2750,7 @@ ConfigItem_alias *Find_alias(char *name)
for (e = conf_alias; e; e = e->next)
{
if (!stricmp(e->alias, name))
if (!strcasecmp(e->alias, name))
return e;
}
return NULL;
@@ -2865,7 +2865,7 @@ ConfigItem_ulines *Find_uline(char *host)
for(ulines = conf_ulines; ulines; ulines = ulines->next)
{
if (!stricmp(host, ulines->servername))
if (!strcasecmp(host, ulines->servername))
return ulines;
}
return NULL;
@@ -6740,15 +6740,15 @@ void test_tlsblock(ConfigFile *conf, ConfigEntry *cep, int *totalerrors)
name++;
}
if (!stricmp(name, "All"))
if (!strcasecmp(name, "All"))
option = TLS_PROTOCOL_ALL;
else if (!stricmp(name, "TLSv1"))
else if (!strcasecmp(name, "TLSv1"))
option = TLS_PROTOCOL_TLSV1;
else if (!stricmp(name, "TLSv1.1"))
else if (!strcasecmp(name, "TLSv1.1"))
option = TLS_PROTOCOL_TLSV1_1;
else if (!stricmp(name, "TLSv1.2"))
else if (!strcasecmp(name, "TLSv1.2"))
option = TLS_PROTOCOL_TLSV1_2;
else if (!stricmp(name, "TLSv1.3"))
else if (!strcasecmp(name, "TLSv1.3"))
option = TLS_PROTOCOL_TLSV1_3;
else
{
@@ -6947,15 +6947,15 @@ void conf_tlsblock(ConfigFile *conf, ConfigEntry *cep, TLSOptions *tlsoptions)
name++;
}
if (!stricmp(name, "All"))
if (!strcasecmp(name, "All"))
option = TLS_PROTOCOL_ALL;
else if (!stricmp(name, "TLSv1"))
else if (!strcasecmp(name, "TLSv1"))
option = TLS_PROTOCOL_TLSV1;
else if (!stricmp(name, "TLSv1.1"))
else if (!strcasecmp(name, "TLSv1.1"))
option = TLS_PROTOCOL_TLSV1_1;
else if (!stricmp(name, "TLSv1.2"))
else if (!strcasecmp(name, "TLSv1.2"))
option = TLS_PROTOCOL_TLSV1_2;
else if (!stricmp(name, "TLSv1.3"))
else if (!strcasecmp(name, "TLSv1.3"))
option = TLS_PROTOCOL_TLSV1_3;
if (option)
@@ -7090,11 +7090,11 @@ int _conf_set(ConfigFile *conf, ConfigEntry *ce)
tempiConf.uhnames = config_checkval(cep->ce_vardata, CFG_YESNO);
}
else if (!strcmp(cep->ce_varname, "allow-userhost-change")) {
if (!stricmp(cep->ce_vardata, "always"))
if (!strcasecmp(cep->ce_vardata, "always"))
tempiConf.userhost_allowed = UHALLOW_ALWAYS;
else if (!stricmp(cep->ce_vardata, "never"))
else if (!strcasecmp(cep->ce_vardata, "never"))
tempiConf.userhost_allowed = UHALLOW_NEVER;
else if (!stricmp(cep->ce_vardata, "not-on-channels"))
else if (!strcasecmp(cep->ce_vardata, "not-on-channels"))
tempiConf.userhost_allowed = UHALLOW_NOCHANS;
else
tempiConf.userhost_allowed = UHALLOW_REJOIN;
@@ -7743,10 +7743,10 @@ int _test_set(ConfigFile *conf, ConfigEntry *ce)
else if (!strcmp(cep->ce_varname, "allow-userhost-change")) {
CheckNull(cep);
CheckDuplicate(cep, allow_userhost_change, "allow-userhost-change");
if (stricmp(cep->ce_vardata, "always") &&
stricmp(cep->ce_vardata, "never") &&
stricmp(cep->ce_vardata, "not-on-channels") &&
stricmp(cep->ce_vardata, "force-rejoin"))
if (strcasecmp(cep->ce_vardata, "always") &&
strcasecmp(cep->ce_vardata, "never") &&
strcasecmp(cep->ce_vardata, "not-on-channels") &&
strcasecmp(cep->ce_vardata, "force-rejoin"))
{
config_error("%s:%i: set::allow-userhost-change is invalid",
cep->ce_fileptr->cf_filename,
@@ -8809,7 +8809,7 @@ int is_blacklisted_module(char *name)
ConfigItem_blacklist_module *m;
for (m = conf_blacklist_module; m; m = m->next)
if (!stricmp(m->name, name) || !stricmp(m->name, path))
if (!strcasecmp(m->name, name) || !strcasecmp(m->name, path))
return 1;
return 0;
@@ -9765,7 +9765,7 @@ static void conf_download_complete(const char *url, const char *file, const char
continue;
if (inc->flag.type & INCLUDE_NOTLOADED)
continue;
if (stricmp(url, inc->url))
if (strcasecmp(url, inc->url))
continue;
inc->flag.type &= ~INCLUDE_DLQUEUED;
@@ -9961,7 +9961,7 @@ char *find_remote_include(char *url, char **errorbuf)
continue;
if (!(inc->flag.type & INCLUDE_REMOTE))
continue;
if (!stricmp(url, inc->url))
if (!strcasecmp(url, inc->url))
{
*errorbuf = inc->errorbuf;
return inc->file;
@@ -9980,7 +9980,7 @@ char *find_loaded_remote_include(char *url)
continue;
if (!(inc->flag.type & INCLUDE_REMOTE))
continue;
if (!stricmp(url, inc->url))
if (!strcasecmp(url, inc->url))
return inc->file;
}
+1 -1
View File
@@ -266,7 +266,7 @@ void ircd_log(int flags, FORMAT_STRING(const char *format), ...)
for (logs = conf_log; logs; logs = logs->next) {
#ifdef HAVE_SYSLOG
if (!stricmp(logs->file, "syslog") && logs->flags & flags) {
if (!strcasecmp(logs->file, "syslog") && logs->flags & flags) {
syslog(LOG_INFO, "%s", buf);
written++;
continue;
+1 -1
View File
@@ -846,7 +846,7 @@ CMD_FUNC(m_module)
Hooktype *HooktypeFind(char *string) {
Hooktype *hooktype;
for (hooktype = Hooktypes; hooktype->string ;hooktype++) {
if (!stricmp(hooktype->string, string))
if (!strcasecmp(hooktype->string, string))
return hooktype;
}
return NULL;
+1 -1
View File
@@ -82,7 +82,7 @@ int extban_account_is_banned(aClient *sptr, aChannel *chptr, char *banin, int ty
{
char *ban = banin+3;
if (!stricmp(ban, sptr->user->svid))
if (!strcasecmp(ban, sptr->user->svid))
return 1;
return 0;
+1 -1
View File
@@ -74,7 +74,7 @@ ConfigItem_help *Find_Help(char *command)
{
if (help->command == NULL)
continue;
else if (!stricmp(command,help->command))
else if (!strcasecmp(command,help->command))
return help;
}
return NULL;
+2 -2
View File
@@ -365,7 +365,7 @@ CMD_FUNC(m_uid)
** client, just reject it. -Lefler
** Allow opers to use Q-lined nicknames. -Russell
*/
if (!stricmp("ircd", nick) || !stricmp("irc", nick))
if (!strcasecmp("ircd", nick) || !strcasecmp("irc", nick))
{
sendnumeric(sptr, ERR_ERRONEUSNICKNAME, nick,
"Reserved for internal IRCd purposes");
@@ -706,7 +706,7 @@ CMD_FUNC(m_nick)
** client, just reject it. -Lefler
** Allow opers to use Q-lined nicknames. -Russell
*/
if (!stricmp("ircd", nick) || !stricmp("irc", nick))
if (!strcasecmp("ircd", nick) || !strcasecmp("irc", nick))
{
sendnumeric(sptr, ERR_ERRONEUSNICKNAME, nick,
"Reserved for internal IRCd purposes");
+1 -1
View File
@@ -125,7 +125,7 @@ RestrictedCmd *find_restrictions_bycmd(char *cmd) {
RestrictedCmd *rcmd;
for (rcmd = RestrictedCmdList; rcmd; rcmd = rcmd->next)
{
if (!stricmp(rcmd->cmd, cmd))
if (!strcasecmp(rcmd->cmd, cmd))
return rcmd;
}
return NULL;
+2 -2
View File
@@ -128,9 +128,9 @@ static TKLType *find_TKLType_by_flag(char flag)
}
void rmtkl_check_options(char *param, int *skipperm, int *silent) {
if (!stricmp("-skipperm", param))
if (!strcasecmp("-skipperm", param))
*skipperm = 1;
if (!stricmp("-silent", param))
if (!strcasecmp("-silent", param))
*silent = 1;
}
+4 -4
View File
@@ -90,7 +90,7 @@ static aClient *decode_puid(char *puid)
cookie = atoi(it2);
}
if (stricmp(me.name, puid))
if (strcasecmp(me.name, puid))
return NULL;
list_for_each_entry(cptr, &unknown_list, lclient_node)
@@ -133,7 +133,7 @@ CMD_FUNC(m_svslogin)
if (!SASL_SERVER || MyClient(sptr) || (parc < 3) || !parv[3])
return 0;
if (!stricmp(parv[1], me.name))
if (!strcasecmp(parv[1], me.name))
{
aClient *target_p;
@@ -180,7 +180,7 @@ CMD_FUNC(m_sasl)
if (!SASL_SERVER || MyClient(sptr) || (parc < 4) || !parv[4])
return 0;
if (!stricmp(parv[1], me.name))
if (!strcasecmp(parv[1], me.name))
{
aClient *target_p;
@@ -196,7 +196,7 @@ CMD_FUNC(m_sasl)
make_user(target_p);
/* reject if another SASL agent is answering */
if (*target_p->local->sasl_agent && stricmp(sptr->name, target_p->local->sasl_agent))
if (*target_p->local->sasl_agent && strcasecmp(sptr->name, target_p->local->sasl_agent))
return 0;
else
strlcpy(target_p->local->sasl_agent, sptr->name, sizeof(target_p->local->sasl_agent));
+1 -1
View File
@@ -276,7 +276,7 @@ static inline int stats_operonly_long(char *s)
OperStat *os;
for (os = iConf.oper_only_stats_ext; os; os = os->next)
{
if (!stricmp(os->flag, s))
if (!strcasecmp(os->flag, s))
return 1;
}
return 0;
+1 -1
View File
@@ -130,7 +130,7 @@ CMD_FUNC(m_svsnline)
continue;
if (bconf->flag.type2 != CONF_BAN_TYPE_AKILL)
continue;
if (!stricmp(bconf->mask, parv[2]))
if (!strcasecmp(bconf->mask, parv[2]))
break;
}
if (bconf)
+5 -5
View File
@@ -3374,8 +3374,8 @@ aTKline *_find_tkl_serverban(int type, char *usermask, char *hostmask, int softb
{
if (tkl->type == type)
{
if (!stricmp(tkl->ptr.serverban->hostmask, hostmask) &&
!stricmp(tkl->ptr.serverban->usermask, usermask))
if (!strcasecmp(tkl->ptr.serverban->hostmask, hostmask) &&
!strcasecmp(tkl->ptr.serverban->usermask, usermask))
{
/* And an extra check for soft/hard ban mismatches.. */
if ((tkl->ptr.serverban->subtype & TKL_SUBTYPE_SOFT) == softban)
@@ -3400,8 +3400,8 @@ aTKline *_find_tkl_banexception(int type, char *usermask, char *hostmask, int so
{
if (tkl->type == type)
{
if (!stricmp(tkl->ptr.banexception->hostmask, hostmask) &&
!stricmp(tkl->ptr.banexception->usermask, usermask))
if (!strcasecmp(tkl->ptr.banexception->hostmask, hostmask) &&
!strcasecmp(tkl->ptr.banexception->usermask, usermask))
{
/* And an extra check for soft/hard ban mismatches.. */
if ((tkl->ptr.banexception->subtype & TKL_SUBTYPE_SOFT) == softban)
@@ -3423,7 +3423,7 @@ aTKline *_find_tkl_nameban(int type, char *name, int hold)
for (tkl = tklines[tkl_hash(tpe)]; tkl; tkl = tkl->next)
{
if ((tkl->type == type) && !stricmp(tkl->ptr.nameban->name, name))
if ((tkl->type == type) && !strcasecmp(tkl->ptr.nameban->name, name))
return tkl;
}
return NULL; /* Not found */
+2 -2
View File
@@ -56,13 +56,13 @@ CMD_FUNC(m_tsctl)
return 0;
}
if (MyClient(sptr) && (!parv[1] || stricmp(parv[1], "alltime")))
if (MyClient(sptr) && (!parv[1] || strcasecmp(parv[1], "alltime")))
{
sendnotice(sptr, "/TSCTL now shows the time on all servers. You can now longer MODIFY the time.");
parv[1] = "alltime";
}
if (parv[1] && !stricmp(parv[1], "alltime"))
if (parv[1] && !strcasecmp(parv[1], "alltime"))
{
sendnotice(sptr, "*** Server=%s TStime=%lld",
me.name, (long long)TStime());
+1 -1
View File
@@ -364,7 +364,7 @@ int websocket_handle_handshake(aClient *sptr, char *readbuf, int *length)
r;
r = websocket_handshake_helper(NULL, 0, &key, &value, &lastloc, &end_of_request))
{
if (!stricmp(key, "Sec-WebSocket-Key"))
if (!strcasecmp(key, "Sec-WebSocket-Key"))
{
if (strchr(value, ':'))
{
+2 -2
View File
@@ -441,8 +441,8 @@ char has_common_chan = 0;
/* if they only want people with a certain server */
if (wfl.want_server != WHO_DONTCARE)
{
if (((wfl.want_server == WHO_WANT) && stricmp(wfl.server, acptr->user->server)) ||
((wfl.want_server == WHO_DONTWANT) && !stricmp(wfl.server, acptr->user->server)))
if (((wfl.want_server == WHO_WANT) && strcasecmp(wfl.server, acptr->user->server)) ||
((wfl.want_server == WHO_DONTWANT) && !strcasecmp(wfl.server, acptr->user->server)))
{
return WHO_CANTSEE;
}
+2 -2
View File
@@ -118,7 +118,7 @@ static inline aCommand *find_Cmd(char *cmd, int flags)
continue;
if ((flags & M_ALIAS) && !(p->flags & M_ALIAS))
continue;
if (!stricmp(p->cmd, cmd))
if (!strcasecmp(p->cmd, cmd))
return p;
}
return NULL;
@@ -138,7 +138,7 @@ aCommand *find_Command_simple(char *cmd)
aCommand *p;
for (p = CommandHash[toupper(*cmd)]; p; p = p->next) {
if (!stricmp(p->cmd, cmd))
if (!strcasecmp(p->cmd, cmd))
return (p);
}
+1 -1
View File
@@ -284,7 +284,7 @@ int parse2(aClient *cptr, aClient **fromptr, MessageTag *mtags, char *ch)
** This error should indeed not be sent in case
** of notices -- Syzop.
*/
if (!IsRegistered(cptr) && stricmp(ch, "NOTICE")) {
if (!IsRegistered(cptr) && strcasecmp(ch, "NOTICE")) {
sendnumericfmt(from, ERR_NOTREGISTERED, "You have not registered");
parse_addlag(cptr, bytes);
return -1;
+5 -5
View File
@@ -678,7 +678,7 @@ CMD_FUNC(m_rehash)
}
}
if (!BadPtr(parv[1]) && stricmp(parv[1], "-all"))
if (!BadPtr(parv[1]) && strcasecmp(parv[1], "-all"))
{
if (!ValidatePermissionsForPath("server:rehash",sptr,NULL,NULL,NULL))
@@ -689,13 +689,13 @@ CMD_FUNC(m_rehash)
if (*parv[1] == '-')
{
if (!strnicmp("-gar", parv[1], 4))
if (!strncasecmp("-gar", parv[1], 4))
{
loop.do_garbage_collect = 1;
RunHook3(HOOKTYPE_REHASHFLAG, cptr, sptr, parv[1]);
return 0;
}
if (!strnicmp("-dns", parv[1], 4))
if (!strncasecmp("-dns", parv[1], 4))
{
reinit_resolver(sptr);
return 0;
@@ -725,8 +725,8 @@ CMD_FUNC(m_rehash)
RunHook3(HOOKTYPE_REHASHFLAG, cptr, sptr, parv[1]);
return 0;
}
if (!strnicmp("-motd", parv[1], 5)
|| !strnicmp("-rules", parv[1], 6))
if (!strncasecmp("-motd", parv[1], 5)
|| !strncasecmp("-rules", parv[1], 6))
{
if (cptr != sptr)
sendto_umode_global(UMODE_OPER, "Remotely rehasing all MOTDs and RULES on request of %s", sptr->name);
+10 -10
View File
@@ -48,7 +48,7 @@ int main(int argc, char *argv[]) {
}
hAdvapi = LoadLibrary("advapi32.dll");
uChangeServiceConfig2 = (UCHANGESERVICECONFIG2)GetProcAddress(hAdvapi, "ChangeServiceConfig2A");
if (!stricmp(argv[1], "install")) {
if (!strcasecmp(argv[1], "install")) {
SC_HANDLE hService, hSCManager;
char path[MAX_PATH+1];
char binpath[MAX_PATH+1];
@@ -79,7 +79,7 @@ int main(int argc, char *argv[]) {
CloseServiceHandle(hSCManager);
return 0;
}
else if (!stricmp(argv[1], "uninstall")) {
else if (!strcasecmp(argv[1], "uninstall")) {
SC_HANDLE hSCManager = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS);
SC_HANDLE hService = OpenService(hSCManager, "UnrealIRCd", DELETE);
if (DeleteService(hService))
@@ -90,7 +90,7 @@ int main(int argc, char *argv[]) {
CloseServiceHandle(hSCManager);
return 0;
}
else if (!stricmp(argv[1], "start")) {
else if (!strcasecmp(argv[1], "start")) {
SC_HANDLE hSCManager = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS);
SC_HANDLE hService = OpenService(hSCManager, "UnrealIRCd", SERVICE_START);
if (StartService(hService, 0, NULL))
@@ -101,7 +101,7 @@ int main(int argc, char *argv[]) {
CloseServiceHandle(hSCManager);
return 0;
}
else if (!stricmp(argv[1], "stop")) {
else if (!strcasecmp(argv[1], "stop")) {
SERVICE_STATUS status;
SC_HANDLE hSCManager = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS);
SC_HANDLE hService = OpenService(hSCManager, "UnrealIRCd", SERVICE_STOP);
@@ -111,7 +111,7 @@ int main(int argc, char *argv[]) {
CloseServiceHandle(hSCManager);
return 0;
}
else if (!stricmp(argv[1], "restart")) {
else if (!strcasecmp(argv[1], "restart")) {
SERVICE_STATUS status;
SC_HANDLE hSCManager = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS);
SC_HANDLE hService = OpenService(hSCManager, "UnrealIRCd", SERVICE_STOP|SERVICE_START);
@@ -122,14 +122,14 @@ int main(int argc, char *argv[]) {
CloseServiceHandle(hSCManager);
return 0;
}
else if (!stricmp(argv[1], "rehash")) {
else if (!strcasecmp(argv[1], "rehash")) {
SERVICE_STATUS status;
SC_HANDLE hSCManager = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS);
SC_HANDLE hService = OpenService(hSCManager, "UnrealIRCd", SERVICE_USER_DEFINED_CONTROL);
ControlService(hService, IRCD_SERVICE_CONTROL_REHASH, &status);
printf("UnrealIRCd NT Service successfully rehashed");
}
else if (!stricmp(argv[1], "config")) {
else if (!strcasecmp(argv[1], "config")) {
SERVICE_STATUS status;
SC_HANDLE hSCManager = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS);
SC_HANDLE hService = OpenService(hSCManager, "UnrealIRCd",
@@ -138,16 +138,16 @@ int main(int argc, char *argv[]) {
show_usage();
return -1;
}
if (!stricmp(argv[2], "startup")) {
if (!strcasecmp(argv[2], "startup")) {
if (ChangeServiceConfig(hService, SERVICE_NO_CHANGE,
!stricmp(argv[3], "auto") ? SERVICE_AUTO_START
!strcasecmp(argv[3], "auto") ? SERVICE_AUTO_START
: SERVICE_DEMAND_START, SERVICE_NO_CHANGE,
NULL, NULL, NULL, NULL, NULL, NULL, NULL))
printf("UnrealIRCd NT Service configuration changed");
else
printf("UnrealIRCd NT Service configuration change failed - %s", show_error(GetLastError()));
}
else if (!stricmp(argv[2], "crashrestart")) {
else if (!strcasecmp(argv[2], "crashrestart")) {
SERVICE_FAILURE_ACTIONS hFailActions;
SC_ACTION hAction;
memset(&hFailActions, 0, sizeof(hFailActions));