From 31843a423bb8bb8196bbd4cd6a709c05d204bb7a Mon Sep 17 00:00:00 2001 From: Jack Moffitt Date: Thu, 3 Jul 2008 02:26:27 +0000 Subject: [PATCH] Implement namespace matching for immediate children. This makes the C library consistent with the JavaScript one. --- src/handler.c | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/src/handler.c b/src/handler.c index d923a48..98704b0 100644 --- a/src/handler.c +++ b/src/handler.c @@ -36,7 +36,27 @@ static int _match_children(xmpp_stanza_t * const stanza, const char * const ns) { - return 0; + xmpp_stanza_t *child; + int matched = 0; + char *childns; + + child = xmpp_stanza_get_children(stanza); + while (child) { + childns = xmpp_stanza_get_ns(child); + if (!childns) { + child = xmpp_stanza_get_next(child); + continue; + } + + if (strcmp(ns, childns) == 0) { + matched = 1; + break; + } + + child = xmpp_stanza_get_next(child); + } + + return matched; } /** Fire off all stanza handlers that match.