aboutsummaryrefslogtreecommitdiffstats
path: root/src/libstrongswan/utils.c
diff options
context:
space:
mode:
authorTobias Brunner <tobias@strongswan.org>2008-12-03 09:45:58 +0000
committerTobias Brunner <tobias@strongswan.org>2008-12-03 09:45:58 +0000
commit81736d7d243036220621a438e4d92528798fdc09 (patch)
tree74083f9cd5c2af13cfccca6848990148fb063873 /src/libstrongswan/utils.c
parent0948edbbff1b7afe8d0a8040e2357f2ae227e642 (diff)
downloadstrongswan-81736d7d243036220621a438e4d92528798fdc09.tar.bz2
strongswan-81736d7d243036220621a438e4d92528798fdc09.tar.xz
added memstr and extract_token_str helper functions
Diffstat (limited to 'src/libstrongswan/utils.c')
-rw-r--r--src/libstrongswan/utils.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/libstrongswan/utils.c b/src/libstrongswan/utils.c
index aa50b86b4..b1974cf97 100644
--- a/src/libstrongswan/utils.c
+++ b/src/libstrongswan/utils.c
@@ -79,6 +79,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.
+ */
bool mkdir_p(const char *path, mode_t mode)
{
size_t len;