Add MG_MK_STR_N() and mg_str_starts_with()

CL: Add MG_MK_STR_N() and mg_str_starts_with()

PUBLISHED_FROM=f01003efc6aa6ff45fa99c7ad6e5319f5002f22d
This commit is contained in:
Deomid Ryabkov authored and Cesanta Bot committed 2018-10-29 15:50:31 +00:00
1 parent 220231e647
commit 91b57aa9a8
2 files changed
+12

No files matched your search

+7
View File
@@ -1770,6 +1770,13 @@ struct mg_str mg_strstrip(struct mg_str s) {
}
return s;
}
int mg_str_starts_with(struct mg_str s, struct mg_str prefix) WEAK;
int mg_str_starts_with(struct mg_str s, struct mg_str prefix) {
const struct mg_str sp = MG_MK_STR_N(s.p, prefix.len);
if (s.len < prefix.len) return 0;
return (mg_strcmp(sp, prefix) == 0);
}
#ifdef MG_MODULE_LINES
#line 1 "common/str_util.c"
#endif