[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[Libevent-users] [PATCH] http: Allow wildcards in request callback paths



this allows you to register callbacks with paths like "/artist*".

based on the patch here:
http://www.mail-archive.com/libevent-users@xxxxxxxxxx/msg00985.html

Signed-off-by: Bobby Powers <bobbypowers@xxxxxxxxx>
---
 http.c |   10 ++++++++--
 1 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/http.c b/http.c
index 19d4f91..1f5b402 100644
--- a/http.c
+++ b/http.c
@@ -2467,8 +2467,14 @@ evhttp_dispatch_callback(struct httpcbq *callbacks, struct evhttp_request *req)
 
 	TAILQ_FOREACH(cb, callbacks, next) {
 		int res = 0;
-		res = ((strncmp(cb->what, translated, offset) == 0) &&
-		    (cb->what[offset] == '\0'));
+		char *multi = strchr(cb->what, '*');
+		if (multi != NULL) {
+			int len = strlen(cb->what) - 1;
+			res =  strncmp(cb->what, translated, len) == 0;
+		} else {
+			res = ((strncmp(cb->what, translated, offset) == 0) &&
+			       (cb->what[offset] == '\0'));
+		}
 
 		if (res) {
 			mm_free(translated);
-- 
1.7.1.251.g92a7.dirty

***********************************************************************
To unsubscribe, send an e-mail to majordomo@xxxxxxxxxxxxx with
unsubscribe libevent-users    in the body.