diff options
author | Felix Fietkau <nbd@openwrt.org> | 2013-01-01 20:08:13 +0100 |
---|---|---|
committer | Felix Fietkau <nbd@openwrt.org> | 2013-01-01 20:08:13 +0100 |
commit | 46cf4c79368daa556ed6936999ab05408f61da00 (patch) | |
tree | 2417b260af84dd734436f47dd89280223e3a8854 | |
parent | 47627fab8f23cd3f9171fabe1f1bfdef547ccc97 (diff) |
add uh_path_match()
-rw-r--r-- | utils.c | 10 | ||||
-rw-r--r-- | utils.h | 2 |
2 files changed, 12 insertions, 0 deletions
@@ -189,3 +189,13 @@ int uh_b64decode(char *buf, int blen, const unsigned char *src, int slen) buf[len++] = 0; return len; } + +bool uh_path_match(const char *prefix, const char *url) +{ + int len = strlen(prefix); + + if (strncmp(url, prefix, len) != 0) + return false; + + return url[len] == '/' || url[len] == 0; +} @@ -55,4 +55,6 @@ static inline void clearenv(void) int uh_urldecode(char *buf, int blen, const char *src, int slen); int uh_urlencode(char *buf, int blen, const char *src, int slen); int uh_b64decode(char *buf, int blen, const unsigned char *src, int slen); +bool uh_path_match(const char *prefix, const char *url); + #endif |