Commit 6fe9cae6 authored by Dmitry Frank's avatar Dmitry Frank Committed by Cesanta Bot

Add mg_next_comma_list_entry_n()

And mgos_conf_check_access_n()

PUBLISHED_FROM=c7de937b4f5463ca463d604183a4ee831617bd6d
parent 38e984a0
......@@ -1926,19 +1926,30 @@ const char *mg_next_comma_list_entry(const char *, struct mg_str *,
struct mg_str *) WEAK;
const char *mg_next_comma_list_entry(const char *list, struct mg_str *val,
struct mg_str *eq_val) {
if (list == NULL || *list == '\0') {
struct mg_str ret = mg_next_comma_list_entry_n(mg_mk_str(list), val, eq_val);
return ret.p;
}
struct mg_str mg_next_comma_list_entry_n(struct mg_str list, struct mg_str *val,
struct mg_str *eq_val) WEAK;
struct mg_str mg_next_comma_list_entry_n(struct mg_str list, struct mg_str *val,
struct mg_str *eq_val) {
if (list.len == 0) {
/* End of the list */
list = NULL;
list = mg_mk_str(NULL);
} else {
val->p = list;
if ((list = strchr(val->p, ',')) != NULL) {
const char *chr = NULL;
*val = list;
if ((chr = mg_strchr(*val, ',')) != NULL) {
/* Comma found. Store length and shift the list ptr */
val->len = list - val->p;
list++;
val->len = chr - val->p;
chr++;
list.len -= (chr - list.p);
list.p = chr;
} else {
/* This value is the last one */
list = val->p + strlen(val->p);
val->len = list - val->p;
list = mg_mk_str_n(list.p + list.len, 0);
}
if (eq_val != NULL) {
......
......@@ -2104,6 +2104,8 @@ int mg_avprintf(char **buf, size_t size, const char *fmt, va_list ap);
*/
const char *mg_next_comma_list_entry(const char *list, struct mg_str *val,
struct mg_str *eq_val);
struct mg_str mg_next_comma_list_entry_n(struct mg_str list, struct mg_str *val,
struct mg_str *eq_val);
/*
* Matches 0-terminated string (mg_match_prefix) or string with given length
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment