|
|
@@ -69,4 +69,28 @@ static size_t string_begins_with (const char *str, const char *needle)
|
|
|
return data_begins_with(str, strlen(str), needle);
|
|
|
}
|
|
|
|
|
|
+static size_t data_begins_with_bin (const char *str, size_t str_len, const char *needle, size_t needle_len)
|
|
|
+{
|
|
|
+ ASSERT(needle_len > 0)
|
|
|
+
|
|
|
+ size_t len = 0;
|
|
|
+
|
|
|
+ while (str_len > 0 && needle_len > 0) {
|
|
|
+ if (*str != *needle) {
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+ str++;
|
|
|
+ str_len--;
|
|
|
+ needle++;
|
|
|
+ needle_len--;
|
|
|
+ len++;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (needle_len > 0) {
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+
|
|
|
+ return len;
|
|
|
+}
|
|
|
+
|
|
|
#endif
|