diff options
Diffstat (limited to 'src/libstrongswan/utils/utils.c')
-rw-r--r-- | src/libstrongswan/utils/utils.c | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/src/libstrongswan/utils/utils.c b/src/libstrongswan/utils/utils.c index 406c5c811..fe80edb82 100644 --- a/src/libstrongswan/utils/utils.c +++ b/src/libstrongswan/utils/utils.c @@ -103,7 +103,7 @@ void memwipe_noinline(void *ptr, size_t n) */ void *memstr(const void *haystack, const char *needle, size_t n) { - unsigned const char *pos = haystack; + const u_char *pos = haystack; size_t l; if (!haystack || !needle || (l = strlen(needle)) == 0) @@ -123,6 +123,28 @@ void *memstr(const void *haystack, const char *needle, size_t n) /** * Described in header. */ +void *utils_memrchr(const void *s, int c, size_t n) +{ + const u_char *pos; + + if (!s || !n) + { + return NULL; + } + + for (pos = s + n - 1; pos >= (u_char*)s; pos--) + { + if (*pos == (u_char)c) + { + return (void*)pos; + } + } + return NULL; +} + +/** + * Described in header. + */ char* translate(char *str, const char *from, const char *to) { char *pos = str; |