Statistics
| Revision:

root / src / xml.h @ 133

History | View | Annotate | Download (2.5 kB)

1 1 hiro
/*
2 1 hiro
 * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
3 1 hiro
 * Copyright (C) 1999-2004 Hiroyuki Yamamoto
4 1 hiro
 *
5 1 hiro
 * This program is free software; you can redistribute it and/or modify
6 1 hiro
 * it under the terms of the GNU General Public License as published by
7 1 hiro
 * the Free Software Foundation; either version 2 of the License, or
8 1 hiro
 * (at your option) any later version.
9 1 hiro
 *
10 1 hiro
 * This program is distributed in the hope that it will be useful,
11 1 hiro
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 1 hiro
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 1 hiro
 * GNU General Public License for more details.
14 1 hiro
 *
15 1 hiro
 * You should have received a copy of the GNU General Public License
16 1 hiro
 * along with this program; if not, write to the Free Software
17 1 hiro
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 1 hiro
 */
19 1 hiro
20 1 hiro
#ifndef __XML_H__
21 1 hiro
#define __XML_H__
22 1 hiro
23 1 hiro
#include <glib.h>
24 1 hiro
#include <stdio.h>
25 1 hiro
26 1 hiro
#define XMLBUFSIZE        8192
27 1 hiro
28 1 hiro
typedef struct _XMLAttr                XMLAttr;
29 1 hiro
typedef struct _XMLTag                XMLTag;
30 1 hiro
typedef struct _XMLNode                XMLNode;
31 1 hiro
typedef struct _XMLFile                XMLFile;
32 1 hiro
33 1 hiro
struct _XMLAttr
34 1 hiro
{
35 1 hiro
        gchar *name;
36 1 hiro
        gchar *value;
37 1 hiro
};
38 1 hiro
39 1 hiro
struct _XMLTag
40 1 hiro
{
41 1 hiro
        gchar *tag;
42 1 hiro
        GList *attr;
43 1 hiro
};
44 1 hiro
45 1 hiro
struct _XMLNode
46 1 hiro
{
47 1 hiro
        XMLTag *tag;
48 1 hiro
        gchar *element;
49 1 hiro
};
50 1 hiro
51 1 hiro
struct _XMLFile
52 1 hiro
{
53 1 hiro
        FILE *fp;
54 1 hiro
55 1 hiro
        GString *buf;
56 1 hiro
        gchar *bufp;
57 1 hiro
58 1 hiro
        gchar *dtd;
59 12 hiro
        gchar *encoding;
60 12 hiro
61 1 hiro
        GList *tag_stack;
62 1 hiro
        guint level;
63 1 hiro
64 1 hiro
        gboolean is_empty_element;
65 1 hiro
};
66 1 hiro
67 1 hiro
XMLFile *xml_open_file                (const gchar        *path);
68 1 hiro
void     xml_close_file                (XMLFile        *file);
69 1 hiro
GNode   *xml_parse_file                (const gchar        *path);
70 1 hiro
71 1 hiro
gint xml_get_dtd                (XMLFile        *file);
72 1 hiro
gint xml_parse_next_tag                (XMLFile        *file);
73 1 hiro
void xml_push_tag                (XMLFile        *file,
74 1 hiro
                                 XMLTag                *tag);
75 1 hiro
void xml_pop_tag                (XMLFile        *file);
76 1 hiro
77 1 hiro
XMLTag *xml_get_current_tag        (XMLFile        *file);
78 1 hiro
GList  *xml_get_current_tag_attr(XMLFile        *file);
79 1 hiro
gchar  *xml_get_element                (XMLFile        *file);
80 1 hiro
81 1 hiro
gint xml_read_line                (XMLFile        *file);
82 1 hiro
void xml_truncate_buf                (XMLFile        *file);
83 1 hiro
gboolean  xml_compare_tag        (XMLFile        *file,
84 1 hiro
                                 const gchar        *name);
85 1 hiro
86 1 hiro
XMLNode *xml_node_new                (XMLTag                *tag,
87 1 hiro
                                 const gchar        *text);
88 1 hiro
XMLTag *xml_tag_new                (const gchar        *tag);
89 1 hiro
XMLAttr *xml_attr_new                (const gchar        *name,
90 1 hiro
                                 const gchar        *value);
91 1 hiro
void xml_tag_add_attr                (XMLTag                *tag,
92 1 hiro
                                 XMLAttr        *attr);
93 1 hiro
94 1 hiro
XMLTag  *xml_copy_tag                (XMLTag                *tag);
95 1 hiro
XMLAttr *xml_copy_attr                (XMLAttr        *attr);
96 1 hiro
97 1 hiro
gint xml_unescape_str                (gchar                *str);
98 1 hiro
gint xml_file_put_escape_str        (FILE                *fp,
99 1 hiro
                                 const gchar        *str);
100 1 hiro
101 1 hiro
gint xml_file_put_xml_decl        (FILE                *fp);
102 1 hiro
gint xml_file_put_node                (FILE                *fp,
103 1 hiro
                                 XMLNode        *node);
104 1 hiro
105 1 hiro
void xml_free_node                (XMLNode        *node);
106 1 hiro
void xml_free_tree                (GNode                *node);
107 1 hiro
108 1 hiro
#endif /* __XML_H__ */