diff options
author | David Timber <mieabby@gmail.com> | 2020-09-19 03:15:28 +0930 |
---|---|---|
committer | David Timber <mieabby@gmail.com> | 2020-09-19 03:15:28 +0930 |
commit | 66a17c4bf5c38579e460209c2028d3275f366121 (patch) | |
tree | e169276fb0b1686abb01c0c5e794e96aaa253e13 /src/util_rt.c | |
parent | 54166c46f32555532dc3c0e922fe6a591cb74128 (diff) |
Impl bne
Diffstat (limited to 'src/util_rt.c')
-rw-r--r-- | src/util_rt.c | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/util_rt.c b/src/util_rt.c index df12015..d3aa132 100644 --- a/src/util_rt.c +++ b/src/util_rt.c @@ -221,6 +221,27 @@ void prne_transstr (char *str, int(*trans_f)(int)) { } } +char *prne_strnstr ( + const char *haystack, + size_t hs_len, + const char *const needle, + const size_t n_len) +{ + if (n_len == 0) { + return NULL; + } + + while (hs_len >= n_len) { + if (*haystack == *needle && memcmp(haystack, needle, n_len) == 0) { + return (char*)haystack; + } + haystack += 1; + hs_len -= 1; + } + + return NULL; +} + bool prne_hex_fromstr (const char *str, uint_fast8_t *out) { static const uint_fast8_t shift[2] = { 4, 0 }; size_t i; |