Handle #1459 - deprecate mg_globmatch, introduce mg_match()

This commit is contained in:
Sergey Lyubka committed 2022-01-29 11:03:54 +00:00
1 parent 768f67ae0a
commit 63b880e624
10 files changed
+184 -102

No files matched your search

+2 -3
View File
@@ -59,7 +59,7 @@ static void fn(struct mg_connection *c, int ev, void *ev_data, void *fn_data) {
LIST_ADD_HEAD(struct sub, &s_subs, sub);
LOG(LL_INFO,
("SUB %p [%.*s]", c->fd, (int) sub->topic.len, sub->topic.ptr));
// Change '+' to '*' for topic matching using mg_globmatch
// Change '+' to '*' for topic matching using mg_match
for (size_t i = 0; i < sub->topic.len; i++) {
if (sub->topic.ptr[i] == '+') ((char *) sub->topic.ptr)[i] = '*';
}
@@ -76,8 +76,7 @@ static void fn(struct mg_connection *c, int ev, void *ev_data, void *fn_data) {
LOG(LL_INFO, ("PUB %p [%.*s] -> [%.*s]", c->fd, (int) mm->data.len,
mm->data.ptr, (int) mm->topic.len, mm->topic.ptr));
for (struct sub *sub = s_subs; sub != NULL; sub = sub->next) {
if (mg_globmatch(sub->topic.ptr, sub->topic.len, mm->topic.ptr,
mm->topic.len)) {
if (mg_match(mm->topic, sub->topic, NULL)) {
mg_mqtt_pub(sub->c, mm->topic, mm->data, 1, false);
}
}