common CHANGE new ly_strncmp()
compare NULL-terminated reference string with a number of bytes from
other string.
diff --git a/src/common.c b/src/common.c
index 5139826..0abfcd6 100644
--- a/src/common.c
+++ b/src/common.c
@@ -171,6 +171,17 @@
return (char *)s;
}
+int
+ly_strncmp(const char *refstr, const char *str, size_t str_len)
+{
+ int rc = strncmp(refstr, str, str_len);
+ if (!rc && refstr[str_len] == '\0') {
+ return 0;
+ } else {
+ return rc ? rc : 1;
+ }
+}
+
LY_ERR
ly_getutf8(const char **input, unsigned int *utf8_char, size_t *bytes_read)
{