From 21f742f888d3c7696362900c6dba5d11d5d72e16 Mon Sep 17 00:00:00 2001 From: Tristan Le Guern Date: Wed, 29 Jul 2015 16:10:23 +0200 Subject: [PATCH] Implement xmpp_stanza_del_attribute() --- src/stanza.c | 21 +++++++++++++++++++++ strophe.h | 3 +++ 2 files changed, 24 insertions(+) diff --git a/src/stanza.c b/src/stanza.c index df4c7a0..63c894a 100644 --- a/src/stanza.c +++ b/src/stanza.c @@ -1042,3 +1042,24 @@ char *xmpp_stanza_get_attribute(xmpp_stanza_t * const stanza, return hash_get(stanza->attributes, name); } + +/** Delete an attribute from a stanza. + * + * @param stanza a Strophe stanza object + * @param name a string containing attribute name + * + * @return XMPP_EOK (0) on success or a number less than 0 on failure + * + * @ingroup Stanza + */ +int xmpp_stanza_del_attribute(xmpp_stanza_t * const stanza, + const char * const name) +{ + if (stanza->type != XMPP_STANZA_TAG) + return -1; + + if (!stanza->attributes) + return -1; + + return hash_drop(stanza->attributes, name); +} diff --git a/strophe.h b/strophe.h index 7f2f80e..6c094a1 100644 --- a/strophe.h +++ b/strophe.h @@ -342,6 +342,9 @@ int xmpp_stanza_set_text_with_size(xmpp_stanza_t *stanza, const char * const text, const size_t size); +int xmpp_stanza_del_attribute(xmpp_stanza_t * const stanza, + const char * const name); + /* common stanza helpers */ char *xmpp_stanza_get_type(xmpp_stanza_t * const stanza); char *xmpp_stanza_get_id(xmpp_stanza_t * const stanza);