Commit 7105802e authored by deuce's avatar deuce
Browse files

Use the FreeBSD strcasestr() implementation.

parent d30d95b8
......@@ -74,6 +74,31 @@ uifcapi_t uifc; /* User Interface (UIFC) Library API */
char YesStr[]="Yes";
char NoStr[]="No";
/*
* Find the first occurrence of find in s, ignore case.
* From FreeBSD src/lib/libc/string/strcasestr.c
*/
char *
strcasestr(s, find)
const char *s, *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 (strncasecmp(s, find, len) != 0);
s--;
}
return ((char *)s);
}
int lprintf(char *fmt, ...)
{
va_list argptr;
......@@ -1658,13 +1683,9 @@ int finduser(scfg_t *cfg, user_t *user)
for(i=1; i<=last; i++) {
user->number=i;
getuserdat(cfg,user);
#ifdef BSD
/* Only FreeBSD has strcasestr */
if(strcasestr(user->alias, str)!=NULL || strcasestr(user->name, str)!=NULL || strcasestr(user->handle, str)!=NULL
|| user->number==un) {
#else
if(strstr(user->alias, str)!=NULL || strstr(user->name, str)!=NULL || strstr(user->handle, str)!=NULL
|| user->number==un) {
#endif
if((opt[j]=(struct user_list *)malloc(sizeof(struct user_list)))==NULL)
allocfail(sizeof(struct user_list));
sprintf(opt[j]->info,"%1.1s%1.1s %-25.25s %-25.25s",user->misc&DELETED?"*":" ",user->misc&INACTIVE?"*":" ",user->name,user->alias);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment