From 0a0852b5764baba1156afaa3695ded2c48e0c5dd Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=D0=91=D0=BE=D0=B1=D0=B1=D0=B8?= <lsm@cesanta.com>
Date: Thu, 23 Nov 2017 11:09:47 +0000
Subject: [PATCH] Document mg_match_prefix

PUBLISHED_FROM=b85fe1ee1e7bae4528c1240d8531c410728d0709
---
 mongoose.h | 18 ++++++++++++++++--
 1 file changed, 16 insertions(+), 2 deletions(-)

diff --git a/mongoose.h b/mongoose.h
index 6b8b80262..399f7f863 100644
--- a/mongoose.h
+++ b/mongoose.h
@@ -2171,10 +2171,24 @@ struct mg_str mg_next_comma_list_entry_n(struct mg_str list, struct mg_str *val,
 
 /*
  * Matches 0-terminated string (mg_match_prefix) or string with given length
- * mg_match_prefix_n against a glob pattern.
- *
+ * mg_match_prefix_n against a glob pattern. Glob syntax:
+ * ```
+ * - * matches zero or more characters until a slash character /
+ * - ** matches zero or more characters
+ * - ? Matches exactly one character which is not a slash /
+ * - | or ,  divides alternative patterns
+ * - any other character matches itself
+ * ```
  * Match is case-insensitive. Returns number of bytes matched, or -1 if no
  * match.
+ * Examples:
+ * ```
+ * mg_match_prefix("a*f", len, "abcdefgh") == 6
+ * mg_match_prefix("a*f", len, "abcdexgh") == -1
+ * mg_match_prefix("a*f|de*,xy", len, "defgh") == 5
+ * mg_match_prefix("?*", len, "abc") == 3
+ * mg_match_prefix("?*", len, "") == -1
+ * ```
  */
 int mg_match_prefix(const char *pattern, int pattern_len, const char *str);
 int mg_match_prefix_n(const struct mg_str pattern, const struct mg_str str);
-- 
GitLab