Skip to content

Commit 21f742f

Browse files
tleguernpasis
authored andcommitted
Implement xmpp_stanza_del_attribute()
1 parent 0d4bcc0 commit 21f742f

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

src/stanza.c

+21
Original file line numberDiff line numberDiff line change
@@ -1042,3 +1042,24 @@ char *xmpp_stanza_get_attribute(xmpp_stanza_t * const stanza,
10421042

10431043
return hash_get(stanza->attributes, name);
10441044
}
1045+
1046+
/** Delete an attribute from a stanza.
1047+
*
1048+
* @param stanza a Strophe stanza object
1049+
* @param name a string containing attribute name
1050+
*
1051+
* @return XMPP_EOK (0) on success or a number less than 0 on failure
1052+
*
1053+
* @ingroup Stanza
1054+
*/
1055+
int xmpp_stanza_del_attribute(xmpp_stanza_t * const stanza,
1056+
const char * const name)
1057+
{
1058+
if (stanza->type != XMPP_STANZA_TAG)
1059+
return -1;
1060+
1061+
if (!stanza->attributes)
1062+
return -1;
1063+
1064+
return hash_drop(stanza->attributes, name);
1065+
}

strophe.h

+3
Original file line numberDiff line numberDiff line change
@@ -342,6 +342,9 @@ int xmpp_stanza_set_text_with_size(xmpp_stanza_t *stanza,
342342
const char * const text,
343343
const size_t size);
344344

345+
int xmpp_stanza_del_attribute(xmpp_stanza_t * const stanza,
346+
const char * const name);
347+
345348
/* common stanza helpers */
346349
char *xmpp_stanza_get_type(xmpp_stanza_t * const stanza);
347350
char *xmpp_stanza_get_id(xmpp_stanza_t * const stanza);

0 commit comments

Comments
 (0)