summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFelix Fietkau <nbd@openwrt.org>2013-01-01 20:08:13 +0100
committerFelix Fietkau <nbd@openwrt.org>2013-01-01 20:08:13 +0100
commit46cf4c79368daa556ed6936999ab05408f61da00 (patch)
tree2417b260af84dd734436f47dd89280223e3a8854
parent47627fab8f23cd3f9171fabe1f1bfdef547ccc97 (diff)
add uh_path_match()
-rw-r--r--utils.c10
-rw-r--r--utils.h2
2 files changed, 12 insertions, 0 deletions
diff --git a/utils.c b/utils.c
index 847ff34..477296f 100644
--- a/utils.c
+++ b/utils.c
@@ -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;
+}
diff --git a/utils.h b/utils.h
index 4f74f5c..07db0cf 100644
--- a/utils.h
+++ b/utils.h
@@ -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