aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorWilmer van der Gaast <wilmer@gaast.net>2014-10-17 23:37:41 +0100
committerWilmer van der Gaast <wilmer@gaast.net>2014-10-17 23:37:41 +0100
commit9ead105e86e6ae332ebdcbc2f1582775b6ef6d38 (patch)
tree9495539922feee5c5e695d445676877ec154281e /lib
parent4f7255d4bed610a77cefd9786fe13c1d673b11bb (diff)
parent46511b3c928bea3072c8c1012b92a3057fa77517 (diff)
Bunch of merges from dx.
Diffstat (limited to 'lib')
-rw-r--r--lib/xmltree.c16
-rw-r--r--lib/xmltree.h1
2 files changed, 17 insertions, 0 deletions
diff --git a/lib/xmltree.c b/lib/xmltree.c
index 3d9eb735..6253d760 100644
--- a/lib/xmltree.c
+++ b/lib/xmltree.c
@@ -523,6 +523,22 @@ char *xt_find_attr( struct xt_node *node, const char *key )
return node->attr[i].value;
}
+struct xt_node *xt_find_node_by_attr( struct xt_node *xt, const char *tag, const char *key, const char *value )
+{
+ struct xt_node *c;
+ char *s;
+
+ for( c = xt; ( c = xt_find_node( c, tag ) ); c = c->next )
+ {
+ if( ( s = xt_find_attr( c, key ) ) && strcmp( s, value ) == 0 )
+ {
+ return c;
+ }
+ }
+ return NULL;
+}
+
+
/* Strip a few non-printable characters that aren't allowed in XML streams
(and upset some XMPP servers for example). */
void xt_strip_text( char *in )
diff --git a/lib/xmltree.h b/lib/xmltree.h
index c1451dad..af13b859 100644
--- a/lib/xmltree.h
+++ b/lib/xmltree.h
@@ -91,6 +91,7 @@ void xt_free( struct xt_parser *xt );
struct xt_node *xt_find_node( struct xt_node *node, const char *name );
struct xt_node *xt_find_path( struct xt_node *node, const char *name );
char *xt_find_attr( struct xt_node *node, const char *key );
+struct xt_node *xt_find_node_by_attr( struct xt_node *xt, const char *tag, const char *key, const char *value );
struct xt_node *xt_new_node( char *name, const char *text, struct xt_node *children );
void xt_add_child( struct xt_node *parent, struct xt_node *child );