Statistics
| Revision:

root / src / xml.h @ 1

History | View | Annotate | Download (2.5 KB)

1
/*
2
 * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
3
 * Copyright (C) 1999-2004 Hiroyuki Yamamoto
4
 *
5
 * This program is free software; you can redistribute it and/or modify
6
 * it under the terms of the GNU General Public License as published by
7
 * the Free Software Foundation; either version 2 of the License, or
8
 * (at your option) any later version.
9
 *
10
 * This program is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 * GNU General Public License for more details.
14
 *
15
 * You should have received a copy of the GNU General Public License
16
 * along with this program; if not, write to the Free Software
17
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18
 */
19

    
20
#ifndef __XML_H__
21
#define __XML_H__
22

    
23
#include <glib.h>
24
#include <stdio.h>
25

    
26
#define XMLBUFSIZE        8192
27

    
28
typedef struct _XMLAttr                XMLAttr;
29
typedef struct _XMLTag                XMLTag;
30
typedef struct _XMLNode                XMLNode;
31
typedef struct _XMLFile                XMLFile;
32

    
33
struct _XMLAttr
34
{
35
        gchar *name;
36
        gchar *value;
37
};
38

    
39
struct _XMLTag
40
{
41
        gchar *tag;
42
        GList *attr;
43
};
44

    
45
struct _XMLNode
46
{
47
        XMLTag *tag;
48
        gchar *element;
49
};
50

    
51
struct _XMLFile
52
{
53
        FILE *fp;
54

    
55
        GString *buf;
56
        gchar *bufp;
57

    
58
        gchar *dtd;
59
        GList *tag_stack;
60
        guint level;
61

    
62
        gboolean is_empty_element;
63
};
64

    
65
XMLFile *xml_open_file                (const gchar        *path);
66
void     xml_close_file                (XMLFile        *file);
67
GNode   *xml_parse_file                (const gchar        *path);
68

    
69
gint xml_get_dtd                (XMLFile        *file);
70
gint xml_parse_next_tag                (XMLFile        *file);
71
void xml_push_tag                (XMLFile        *file,
72
                                 XMLTag                *tag);
73
void xml_pop_tag                (XMLFile        *file);
74

    
75
XMLTag *xml_get_current_tag        (XMLFile        *file);
76
GList  *xml_get_current_tag_attr(XMLFile        *file);
77
gchar  *xml_get_element                (XMLFile        *file);
78

    
79
gint xml_read_line                (XMLFile        *file);
80
void xml_truncate_buf                (XMLFile        *file);
81
gboolean  xml_compare_tag        (XMLFile        *file,
82
                                 const gchar        *name);
83

    
84
XMLNode *xml_node_new                (XMLTag                *tag,
85
                                 const gchar        *text);
86
XMLTag *xml_tag_new                (const gchar        *tag);
87
XMLAttr *xml_attr_new                (const gchar        *name,
88
                                 const gchar        *value);
89
void xml_tag_add_attr                (XMLTag                *tag,
90
                                 XMLAttr        *attr);
91

    
92
XMLTag  *xml_copy_tag                (XMLTag                *tag);
93
XMLAttr *xml_copy_attr                (XMLAttr        *attr);
94

    
95
gint xml_unescape_str                (gchar                *str);
96
gint xml_file_put_escape_str        (FILE                *fp,
97
                                 const gchar        *str);
98

    
99
gint xml_file_put_xml_decl        (FILE                *fp);
100
gint xml_file_put_node                (FILE                *fp,
101
                                 XMLNode        *node);
102

    
103
void xml_free_node                (XMLNode        *node);
104
void xml_free_tree                (GNode                *node);
105

    
106
#endif /* __XML_H__ */