diff options
author | Hiltjo Posthuma <hiltjo@codemadness.org> | 2021-11-26 12:15:12 +0100 |
---|---|---|
committer | Hiltjo Posthuma <hiltjo@codemadness.org> | 2021-11-26 12:15:12 +0100 |
commit | f2edcbb9d9f06dd7bf172efaa7a68d99ac0f24ea (patch) | |
tree | 7b543aee2d6f6090df0b803b17e72e9524eafa9b /util.c | |
parent | ac1ae80f3d1998d3ce3c7fa1ca933e2cda5d20fd (diff) |
sfeed_curses: reuse some functions in util
Diffstat (limited to 'util.c')
-rw-r--r-- | util.c | 20 |
1 files changed, 20 insertions, 0 deletions
@@ -46,6 +46,26 @@ errx(int exitstatus, const char *fmt, ...) exit(exitstatus); } +/* strcasestr() included for portability */ +char * +strcasestr(const char *h, const char *n) +{ + size_t i; + + if (!n[0]) + return (char *)h; + + for (; *h; ++h) { + for (i = 0; n[i] && tolower((unsigned char)n[i]) == + tolower((unsigned char)h[i]); ++i) + ; + if (n[i] == '\0') + return (char *)h; + } + + return NULL; +} + /* check if string has a non-empty scheme / protocol part */ int uri_hasscheme(const char *s) |