added memstr and extract_token_str helper functions

This commit is contained in:
Tobias Brunner
2008-12-03 09:45:58 +00:00
parent 0948edbbff
commit 81736d7d24
4 changed files with 57 additions and 2 deletions
+17
View File
@@ -76,6 +76,23 @@ void memxor(u_int8_t dest[], u_int8_t src[], size_t n)
}
}
/**
* Described in header.
*/
void *memstr(const void *haystack, const char *needle, size_t n)
{
unsigned const char *pos = haystack;
size_t l = strlen(needle);
for (; n >= l; ++pos, --n)
{
if (memeq(pos, needle, l))
{
return (void*)pos;
}
}
return NULL;
}
/**
* Described in header.
*/