mirror of
https://git.savannah.nongnu.org/git/lwip.git
synced 2025-08-04 21:44:38 +08:00
DEF: added lwip_strnistr() for case insensitive matching
This commit is contained in:
parent
dcb29c591f
commit
75f33081c2
@ -118,6 +118,29 @@ lwip_strnstr(const char *buffer, const char *token, size_t n)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef lwip_strnistr
|
||||||
|
/**
|
||||||
|
* @ingroup sys_nonstandard
|
||||||
|
* lwIP default implementation for strnistr() non-standard function.
|
||||||
|
* This can be \#defined to strnistr() depending on your platform port.
|
||||||
|
*/
|
||||||
|
char *
|
||||||
|
lwip_strnistr(const char *buffer, const char *token, size_t n)
|
||||||
|
{
|
||||||
|
const char *p;
|
||||||
|
size_t tokenlen = strlen(token);
|
||||||
|
if (tokenlen == 0) {
|
||||||
|
return LWIP_CONST_CAST(char *, buffer);
|
||||||
|
}
|
||||||
|
for (p = buffer; *p && (p + tokenlen <= buffer + n); p++) {
|
||||||
|
if (lwip_strnicmp(p, token, tokenlen) == 0) {
|
||||||
|
return LWIP_CONST_CAST(char *, p);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifndef lwip_stricmp
|
#ifndef lwip_stricmp
|
||||||
/**
|
/**
|
||||||
* @ingroup sys_nonstandard
|
* @ingroup sys_nonstandard
|
||||||
|
@ -144,6 +144,10 @@ int lwip_stricmp(const char* str1, const char* str2);
|
|||||||
/* This can be #defined to strnstr() depending on your platform */
|
/* This can be #defined to strnstr() depending on your platform */
|
||||||
char* lwip_strnstr(const char* buffer, const char* token, size_t n);
|
char* lwip_strnstr(const char* buffer, const char* token, size_t n);
|
||||||
#endif
|
#endif
|
||||||
|
#ifndef lwip_strnistr
|
||||||
|
/* This can be #defined to strnistr() depending on your platform */
|
||||||
|
char* lwip_strnistr(const char* buffer, const char* token, size_t n);
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user