Implement xmpp_stanza_del_attribute()

This commit is contained in:
Tristan Le Guern
2015-07-29 16:10:23 +02:00
committed by Dmitry Podgorny
parent 0d4bcc0228
commit 21f742f888
2 changed files with 24 additions and 0 deletions

View File

@@ -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);
}

View File

@@ -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);