diff --git a/include/str.h b/include/str.h index f73c621..ea03ee3 100644 --- a/include/str.h +++ b/include/str.h @@ -64,4 +64,30 @@ translate_slashes(CHAR8 *out, const char *str) return out; } +static inline UNUSED CHAR8 * +strchrnula(const CHAR8 *s, int c) +{ + unsigned int i; + + if (s == NULL) + return NULL; + + for (i = 0; s[i] != '\000' && s[i] != c; i++) + ; + + return (CHAR8 *)&s[i]; +} + +static inline UNUSED CHAR8 * +strchra(const CHAR8 *s, int c) +{ + const CHAR8 *s1; + + s1 = strchrnula(s, c); + if (!s1 || s1[0] == '\000') + return NULL; + + return (CHAR8 *)s1; +} + #endif /* SHIM_STR_H */