aboutsummaryrefslogtreecommitdiffstats
path: root/lib/xmltree.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/xmltree.c')
-rw-r--r--lib/xmltree.c21
1 files changed, 13 insertions, 8 deletions
diff --git a/lib/xmltree.c b/lib/xmltree.c
index 3906029c..0726d387 100644
--- a/lib/xmltree.c
+++ b/lib/xmltree.c
@@ -3,7 +3,7 @@
* BitlBee - An IRC to IM gateway *
* Simple XML (stream) parse tree handling code (Jabber/XMPP, mainly) *
* *
-* Copyright 2006 Wilmer van der Gaast <wilmer@gaast.net> *
+* Copyright 2006-2012 Wilmer van der Gaast <wilmer@gaast.net> *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Lesser General Public *
@@ -162,9 +162,8 @@ int xt_handle( struct xt_parser *xt, struct xt_node *node, int depth )
xt_status st;
int i;
- /* Just in case someone likes infinite loops... */
if( xt->root == NULL )
- return 0;
+ return 1;
if( node == NULL )
return xt_handle( xt, xt->root, depth );
@@ -262,15 +261,21 @@ void xt_cleanup( struct xt_parser *xt, struct xt_node *node, int depth )
}
}
-struct xt_node *xt_from_string( const char *in )
+struct xt_node *xt_from_string( const char *in, int len )
{
struct xt_parser *parser;
- struct xt_node *ret;
+ struct xt_node *ret = NULL;
+
+ if( len == 0 )
+ len = strlen( in );
parser = xt_new( NULL, NULL );
- xt_feed( parser, in, strlen( in ) );
- ret = parser->root;
- parser->root = NULL;
+ xt_feed( parser, in, len );
+ if( parser->cur == NULL )
+ {
+ ret = parser->root;
+ parser->root = NULL;
+ }
xt_free( parser );
return ret;