1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
|
typedef struct ParsedItem ParsedItem;
struct XmlItem
{
gboolean is_element;
union
{
struct
{
const char *name;
guint sibling_index;
} element;
char text[1];
} u;
};
struct XmlStore
{
GHashTable *names;
GArray *items;
GList *stack;
guint last_index;
};
static guint
add_item (GArray *array,
const XmlItem *item)
{
}
XmlStore *
xml_store_new (void)
{
XmlStore *store = g_new (XmlStore, 1);
store->names = g_hash_table_new (g_str_hash, g_str_equal);
store->stack = NULL;
store->items = g_array_new (TRUE, TRUE, sizeof (XmlItem));
}
void
xml_store_append_begin (XmlStore *store,
const char *element)
{
XmlItem item;
item.is_element = TRUE;
item.element.name = canonical_name (store, element);
item.element.sibling = NULL;
if (store->last)
store->last->u.element.sibling = &result;
}
typedef enum
{
BEGIN,
TEXT,
END
} XmlItemType;
struct XmlItem
{
XmlItemType type;
char [1] data;
};
struct XmlStore
{
XmlItem * items;
GHashTable *user_data_map;
};
struct ParsedItem
{
XmlItemType type;
union
{
struct
{
char * element;
int n_attrs;
char **attr;
} begin_item;
struct
{
char *text;
} text_item;
struct
{
char *element;
} end_item;
} u;
};
static void
parse_begin_item (XmlItem *item,
ParsedItem *parsed_item)
{
}
static void
parse_end_item (XmlItem *item,
ParsedItem *parsed_item)
{
}
static void
parse_text_item (XmlItem *item,
ParsedItem *parsed_item)
{
}
static ParsedItem *
parsed_item_new (XmlItem *item)
{
ParsedItem *parsed_item = g_new0 (ParsedItem, 0);
switch (item->type)
{
case BEGIN:
parsed_item->type = BEGIN;
parse_begin_item (item, parsed_item);
break;
case END:
parsed_item->type = END;
parse_end_item (item, parsed_item);
break;
case TEXT:
parsed_item->type = TEXT;
parse_text_item (item, parsed_item);
break;
}
return parsed_item;
}
static void
parsed_item_free (ParsedItem *item)
{
}
|