source: protocols/jabber/xmltree.h @ 8f243ad

Last change on this file since 8f243ad was 8f243ad, checked in by Wilmer van der Gaast <wilmer@…>, at 2006-09-20T09:36:53Z

Removed old Jabber module, started to fill in the new stuff. (xmltree
developed outside this tree)

  • Property mode set to 100644
File size: 3.3 KB
Line 
1/***************************************************************************\
2*                                                                           *
3*  BitlBee - An IRC to IM gateway                                           *
4*  Simple XML (stream) parse tree handling code (Jabber/XMPP, mainly)       *
5*                                                                           *
6*  Copyright 2006 Wilmer van der Gaast <wilmer@gaast.net>                   *
7*                                                                           *
8*  This library is free software; you can redistribute it and/or            *
9*  modify it under the terms of the GNU Lesser General Public               *
10*  License as published by the Free Software Foundation, version            *
11*  2.1.                                                                     *
12*                                                                           *
13*  This library is distributed in the hope that it will be useful,          *
14*  but WITHOUT ANY WARRANTY; without even the implied warranty of           *
15*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU        *
16*  Lesser General Public License for more details.                          *
17*                                                                           *
18*  You should have received a copy of the GNU Lesser General Public License *
19*  along with this library; if not, write to the Free Software Foundation,  *
20*  Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA           *
21*                                                                           *
22****************************************************************************/
23
24typedef enum
25{
26        XT_COMPLETE     = 1,    /* </tag> reached */
27        XT_SEEN         = 2,    /* Handler called (or not defined) */
28} xt_flags;
29
30typedef enum
31{
32        XT_ABORT,               /* Abort, don't handle the rest anymore */
33        XT_HANDLED,             /* Handled this tag properly, go to the next one */
34        XT_NEXT                 /* Try if there's another matching handler */
35} xt_status;
36
37struct xt_attr
38{
39        char *key, *value;
40};
41
42struct xt_node
43{
44        struct xt_node *parent;
45        struct xt_node *children;
46       
47        char *name;
48        struct xt_attr *attr;
49        char *text;
50        int text_len;
51       
52        struct xt_node *next;
53        xt_flags flags;
54};
55
56typedef xt_status (*xt_handler_func) ( struct xt_node *node, gpointer data );
57
58struct xt_handler_entry
59{
60        char *name, *parent;
61        xt_handler_func func;
62};
63
64struct xt_parser
65{
66        GMarkupParseContext *parser;
67        struct xt_node *root;
68        struct xt_node *cur;
69       
70        struct xt_handler_entry *handlers;
71        gpointer data;
72       
73        GError *gerr;
74};
75
76struct xt_parser *xt_new( gpointer data );
77void xt_reset( struct xt_parser *xt );
78int xt_feed( struct xt_parser *xt, char *text, int text_len );
79int xt_handle( struct xt_parser *xt, struct xt_node *node );
80void xt_cleanup( struct xt_parser *xt, struct xt_node *node );
81char *xt_to_string( struct xt_node *node );
82void xt_print( struct xt_node *node );
83void xt_free_node( struct xt_node *node );
84void xt_free( struct xt_parser *xt );
85struct xt_node *xt_find_node( struct xt_node *node, char *name );
86char *xt_find_attr( struct xt_node *node, char *key );
87
88struct xt_node *xt_new_node( char *name, char *text, struct xt_node *children );
89void xt_add_child( struct xt_node *parent, struct xt_node *child );
90void xt_add_attr( struct xt_node *node, char *key, char *value );
Note: See TracBrowser for help on using the repository browser.