aboutsummaryrefslogtreecommitdiffstats
path: root/protocols/jabber/xmltree.c
diff options
context:
space:
mode:
authorWilmer van der Gaast <wilmer@gaast.net>2006-10-12 19:48:58 +0200
committerWilmer van der Gaast <wilmer@gaast.net>2006-10-12 19:48:58 +0200
commit259edd40f5e332791a44f7547346bf799f1f7327 (patch)
tree498572c9e849bab47b6c67a059f791d8dd0998c3 /protocols/jabber/xmltree.c
parentb56b220e4280a75577f79b9dbcaf6eb2d7336873 (diff)
Special message when the XMPP session is ended because of a concurrent
login, and now sending proper error responses to IQ packets we can't handle.
Diffstat (limited to 'protocols/jabber/xmltree.c')
-rw-r--r--protocols/jabber/xmltree.c36
1 files changed, 36 insertions, 0 deletions
diff --git a/protocols/jabber/xmltree.c b/protocols/jabber/xmltree.c
index af0c5832..7a165a1e 100644
--- a/protocols/jabber/xmltree.c
+++ b/protocols/jabber/xmltree.c
@@ -549,3 +549,39 @@ void xt_add_attr( struct xt_node *node, char *key, char *value )
node->attr[i].value = g_strdup( value );
}
+
+int xt_remove_attr( struct xt_node *node, char *key )
+{
+ int i, last;
+
+ for( i = 0; node->attr[i].key; i ++ )
+ if( strcmp( node->attr[i].key, key ) == 0 )
+ break;
+
+ /* If we didn't find the attribute... */
+ if( node->attr[i].key == NULL )
+ return 0;
+
+ g_free( node->attr[i].key );
+ g_free( node->attr[i].value );
+
+ /* If it's the last, this is easy: */
+ if( node->attr[i+1].key == NULL )
+ {
+ node->attr[i].key = node->attr[i].value = NULL;
+ }
+ else /* It's also pretty easy, actually. */
+ {
+ /* Find the last item. */
+ for( last = i + 1; node->attr[last+1].key; last ++ );
+
+ node->attr[i] = node->attr[last];
+ node->attr[last].key = NULL;
+ node->attr[last].value = NULL;
+ }
+
+ /* Let's not bother with reallocating memory here. It takes time and
+ most packets don't stay in memory for long anyway. */
+
+ return 1;
+}