replace switch_stristr implementation with one that shouldn't segfault.
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@6080 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
parent
990ea4a855
commit
04c1158b52
|
@ -199,24 +199,46 @@ SWITCH_DECLARE(switch_bool_t) switch_simple_email(char *to, char *from, char *he
|
||||||
|
|
||||||
SWITCH_DECLARE(const char *) switch_stristr(const char *str, const char *instr)
|
SWITCH_DECLARE(const char *) switch_stristr(const char *str, const char *instr)
|
||||||
{
|
{
|
||||||
switch_size_t score = strlen(str), x = 0;
|
/*
|
||||||
const char *a = str, *b = instr, *p = NULL;
|
** Rev History: 16/07/97 Greg Thayer Optimized
|
||||||
while(*a && *b) {
|
** 07/04/95 Bob Stout ANSI-fy
|
||||||
if (tolower(*b) == tolower(*a)) {
|
** 02/03/94 Fred Cole Original
|
||||||
if (++x == score) {
|
** 09/01/03 Bob Stout Bug fix (lines 40-41) per Fred Bulback
|
||||||
return b - x + 1;
|
**
|
||||||
}
|
** Hereby donated to public domain.
|
||||||
a++;
|
*/
|
||||||
} else {
|
|
||||||
a = str;
|
const char *pptr, *sptr, *start;
|
||||||
p = b+1;
|
|
||||||
x = 0;
|
if (!str || !instr)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
for (start = str; *start; start++) {
|
||||||
|
/* find start of pattern in string */
|
||||||
|
for ( ; ((*start) && (toupper(*start) != toupper(*instr))); start++);
|
||||||
|
|
||||||
|
if (!*start)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
pptr = instr;
|
||||||
|
sptr = start;
|
||||||
|
|
||||||
|
while (toupper(*sptr) == toupper(*pptr)) {
|
||||||
|
sptr++;
|
||||||
|
pptr++;
|
||||||
|
|
||||||
|
/* if end of pattern then pattern was found */
|
||||||
|
if (!*pptr)
|
||||||
|
return (start);
|
||||||
|
|
||||||
|
if (!*sptr)
|
||||||
|
return NULL;
|
||||||
}
|
}
|
||||||
b++;
|
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
SWITCH_DECLARE(switch_status_t) switch_find_local_ip(char *buf, int len, int family)
|
SWITCH_DECLARE(switch_status_t) switch_find_local_ip(char *buf, int len, int family)
|
||||||
{
|
{
|
||||||
switch_status_t status = SWITCH_STATUS_FALSE;
|
switch_status_t status = SWITCH_STATUS_FALSE;
|
||||||
|
|
Loading…
Reference in New Issue