From 2befeee9e596ee5042d1ebf7229ff890645b4930 Mon Sep 17 00:00:00 2001 From: Jack Moffitt Date: Tue, 26 Aug 2008 04:39:19 +0000 Subject: [PATCH] Added two new api functions, xmpp_stanza_is_text() and xmpp_stanza_is_tag() to determine the type of stanza. --- src/stanza.c | 26 ++++++++++++++++++++++++++ strophe.h | 4 ++++ 2 files changed, 30 insertions(+) diff --git a/src/stanza.c b/src/stanza.c index a93d7de..375bc0f 100644 --- a/src/stanza.c +++ b/src/stanza.c @@ -187,6 +187,32 @@ int xmpp_stanza_release(xmpp_stanza_t * const stanza) return released; } +/** Determine if a stanza is a text node. + * + * @param stanza a Strophe stanza object + * + * @return TRUE if the stanza is a text node, FALSE otherwise + * + * @ingroup Stanza + */ +int xmpp_stanza_is_text(xmpp_stanza_t * const stanza) +{ + return (stanza && stanza->type == XMPP_STANZA_TEXT); +} + +/** Determine if a stanza is a tag node. + * + * @param stanza a Strophe stanza object + * + * @return TRUE if the stanza is a tag node, FALSE otherwise + * + * @ingroup Stanza + */ +int xmpp_stanza_is_tag(xmpp_stanza_t * const stanza) +{ + return (stanza && stanza->type == XMPP_STANZA_TAG); +} + /* small helper function */ static inline void _render_update(int *written, const int length, const int lastwrite, diff --git a/strophe.h b/strophe.h index abc1039..cc210c1 100644 --- a/strophe.h +++ b/strophe.h @@ -285,6 +285,9 @@ xmpp_stanza_t * xmpp_stanza_copy(const xmpp_stanza_t * const stanza); /** free a stanza object and it's contents */ int xmpp_stanza_release(xmpp_stanza_t * const stanza); +int xmpp_stanza_is_text(xmpp_stanza_t * const stanza); +int xmpp_stanza_is_tag(xmpp_stanza_t * const stanza); + /** marshall a stanza into text for transmission or display **/ int xmpp_stanza_to_text(xmpp_stanza_t *stanza, char ** const buf, size_t * const buflen); @@ -300,6 +303,7 @@ char *xmpp_stanza_get_attribute(xmpp_stanza_t * const stanza, char * xmpp_stanza_get_ns(xmpp_stanza_t * const stanza); /* concatenate all child text nodes. this function * returns a string that must be freed by the caller */ + char *xmpp_stanza_get_text(xmpp_stanza_t * const stanza); char *xmpp_stanza_get_text_ptr(xmpp_stanza_t * const stanza); char *xmpp_stanza_get_name(xmpp_stanza_t * const stanza);