author | Frank Zschockelt <lm@freakysoft.de> |
Thu, 04 Feb 2016 19:18:03 +0100 | |
changeset 690 | 7ccf2113ec5f |
parent 607 | e2bd14357c9a |
child 710 | ea3137a59c2b |
permissions | -rw-r--r-- |
516
4dd3aa6b83e5
Change the tab width to 4 steps in the emacs headers
Mikael Hallendal <micke@imendio.com>
parents:
515
diff
changeset
|
1 |
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
1 | 2 |
/* |
99
81e9d035de02
2004-10-05 Mikael Hallendal <micke@imendio.com>
hallski <hallski>
parents:
84
diff
changeset
|
3 |
* Copyright (C) 2003 Imendio AB |
1 | 4 |
* |
5 |
* This program is free software; you can redistribute it and/or |
|
6 |
* modify it under the terms of the GNU Lesser General Public License as |
|
7 |
* published by the Free Software Foundation; either version 2 of the |
|
8 |
* License, or (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 GNU |
|
13 |
* Lesser General Public License for more details. |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU Lesser General Public |
|
690
7ccf2113ec5f
Update the postal address of the FSF
Frank Zschockelt <lm@freakysoft.de>
parents:
607
diff
changeset
|
16 |
* License along with this program; if not, see <https://www.gnu.org/licenses> |
1 | 17 |
*/ |
18 |
||
417
364c17252e5f
Added inlined documentation from generated through the Gtk-doc migration script.
Mikael Hallendal <micke@imendio.com>
parents:
185
diff
changeset
|
19 |
/** |
420
f40434cca022
Fixed the SECTION parts of the inlined docs so that gtk-doc finds them.
Mikael Hallendal <micke@imendio.com>
parents:
417
diff
changeset
|
20 |
* SECTION:lm-message-node |
421
2a91651d22de
Added Title to the inlined documentation
Mikael Hallendal <micke@imendio.com>
parents:
420
diff
changeset
|
21 |
* @Title: LmMessageNode |
417
364c17252e5f
Added inlined documentation from generated through the Gtk-doc migration script.
Mikael Hallendal <micke@imendio.com>
parents:
185
diff
changeset
|
22 |
* @Short_description: A node in the message tree |
364c17252e5f
Added inlined documentation from generated through the Gtk-doc migration script.
Mikael Hallendal <micke@imendio.com>
parents:
185
diff
changeset
|
23 |
*/ |
364c17252e5f
Added inlined documentation from generated through the Gtk-doc migration script.
Mikael Hallendal <micke@imendio.com>
parents:
185
diff
changeset
|
24 |
|
1 | 25 |
#include <config.h> |
26 |
#include <string.h> |
|
27 |
||
28 |
#include "lm-internals.h" |
|
29 |
#include "lm-message-node.h" |
|
30 |
||
31 |
typedef struct { |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
32 |
gchar *key; |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
33 |
gchar *value; |
1 | 34 |
} KeyValuePair; |
35 |
||
36 |
static void message_node_free (LmMessageNode *node); |
|
37 |
static LmMessageNode * message_node_last_child (LmMessageNode *node); |
|
38 |
||
39 |
static void |
|
40 |
message_node_free (LmMessageNode *node) |
|
41 |
{ |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
42 |
LmMessageNode *l; |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
43 |
GSList *list; |
607 | 44 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
45 |
g_return_if_fail (node != NULL); |
1 | 46 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
47 |
for (l = node->children; l;) { |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
48 |
LmMessageNode *next = l->next; |
1 | 49 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
50 |
lm_message_node_unref (l); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
51 |
l = next; |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
52 |
} |
1 | 53 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
54 |
g_free (node->name); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
55 |
g_free (node->value); |
607 | 56 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
57 |
for (list = node->attributes; list; list = list->next) { |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
58 |
KeyValuePair *kvp = (KeyValuePair *) list->data; |
607 | 59 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
60 |
g_free (kvp->key); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
61 |
g_free (kvp->value); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
62 |
g_free (kvp); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
63 |
} |
607 | 64 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
65 |
g_slist_free (node->attributes); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
66 |
g_free (node); |
1 | 67 |
} |
68 |
||
69 |
static LmMessageNode * |
|
70 |
message_node_last_child (LmMessageNode *node) |
|
71 |
{ |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
72 |
LmMessageNode *l; |
607 | 73 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
74 |
g_return_val_if_fail (node != NULL, NULL); |
1 | 75 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
76 |
if (!node->children) { |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
77 |
return NULL; |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
78 |
} |
607 | 79 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
80 |
l = node->children; |
1 | 81 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
82 |
while (l->next) { |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
83 |
l = l->next; |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
84 |
} |
1 | 85 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
86 |
return l; |
1 | 87 |
} |
88 |
||
89 |
LmMessageNode * |
|
90 |
_lm_message_node_new (const gchar *name) |
|
91 |
{ |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
92 |
LmMessageNode *node; |
1 | 93 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
94 |
node = g_new0 (LmMessageNode, 1); |
607 | 95 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
96 |
node->name = g_strdup (name); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
97 |
node->value = NULL; |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
98 |
node->raw_mode = FALSE; |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
99 |
node->attributes = NULL; |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
100 |
node->next = NULL; |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
101 |
node->prev = NULL; |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
102 |
node->parent = NULL; |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
103 |
node->children = NULL; |
1 | 104 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
105 |
node->ref_count = 1; |
1 | 106 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
107 |
return node; |
1 | 108 |
} |
109 |
void |
|
110 |
_lm_message_node_add_child_node (LmMessageNode *node, LmMessageNode *child) |
|
111 |
{ |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
112 |
LmMessageNode *prev; |
607 | 113 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
114 |
g_return_if_fail (node != NULL); |
1 | 115 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
116 |
prev = message_node_last_child (node); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
117 |
lm_message_node_ref (child); |
1 | 118 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
119 |
if (prev) { |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
120 |
prev->next = child; |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
121 |
child->prev = prev; |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
122 |
} else { |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
123 |
node->children = child; |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
124 |
} |
607 | 125 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
126 |
child->parent = node; |
1 | 127 |
} |
128 |
||
129 |
/** |
|
130 |
* lm_message_node_get_value: |
|
131 |
* @node: an #LmMessageNode |
|
607 | 132 |
* |
1 | 133 |
* Retrieves the value of @node. |
607 | 134 |
* |
135 |
* Return value: |
|
1 | 136 |
**/ |
137 |
const gchar * |
|
138 |
lm_message_node_get_value (LmMessageNode *node) |
|
139 |
{ |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
140 |
g_return_val_if_fail (node != NULL, NULL); |
607 | 141 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
142 |
return node->value; |
1 | 143 |
} |
144 |
||
145 |
/** |
|
146 |
* lm_message_node_set_value: |
|
147 |
* @node: an #LmMessageNode |
|
148 |
* @value: the new value. |
|
607 | 149 |
* |
1 | 150 |
* Sets the value of @node. If a previous value is set it will be freed. |
151 |
**/ |
|
152 |
void |
|
153 |
lm_message_node_set_value (LmMessageNode *node, const gchar *value) |
|
154 |
{ |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
155 |
g_return_if_fail (node != NULL); |
607 | 156 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
157 |
g_free (node->value); |
607 | 158 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
159 |
if (!value) { |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
160 |
node->value = NULL; |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
161 |
return; |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
162 |
} |
1 | 163 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
164 |
node->value = g_strdup (value); |
1 | 165 |
} |
166 |
||
167 |
/** |
|
168 |
* lm_message_node_add_child: |
|
169 |
* @node: an #LmMessageNode |
|
170 |
* @name: the name of the new child |
|
171 |
* @value: value of the new child |
|
607 | 172 |
* |
173 |
* Add a child node with @name and value set to @value. |
|
174 |
* |
|
1 | 175 |
* Return value: the newly created child |
176 |
**/ |
|
177 |
LmMessageNode * |
|
607 | 178 |
lm_message_node_add_child (LmMessageNode *node, |
179 |
const gchar *name, |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
180 |
const gchar *value) |
1 | 181 |
{ |
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
182 |
LmMessageNode *child; |
607 | 183 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
184 |
g_return_val_if_fail (node != NULL, NULL); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
185 |
g_return_val_if_fail (name != NULL, NULL); |
168
ac1affcd5d22
2006-09-01 Mikael Hallendal <micke@imendio.com>
hallski <hallski>
parents:
166
diff
changeset
|
186 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
187 |
child = _lm_message_node_new (name); |
1 | 188 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
189 |
lm_message_node_set_value (child, value); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
190 |
_lm_message_node_add_child_node (node, child); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
191 |
lm_message_node_unref (child); |
1 | 192 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
193 |
return child; |
1 | 194 |
} |
195 |
||
196 |
/** |
|
197 |
* lm_message_node_set_attributes: |
|
198 |
* @node: an #LmMessageNode |
|
199 |
* @name: the first attribute, should be followed by a string with the value |
|
56
3bf928955fc5
2003-11-20 Ross Burton <ross@burtonini.com>
hallski <hallski>
parents:
7
diff
changeset
|
200 |
* @Varargs: The rest of the name/value pairs |
607 | 201 |
* |
202 |
* Sets a list of attributes. The arguments should be names and corresponding |
|
1 | 203 |
* value and needs to be ended with %NULL. |
204 |
**/ |
|
205 |
void |
|
206 |
lm_message_node_set_attributes (LmMessageNode *node, |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
207 |
const gchar *name, |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
208 |
...) |
1 | 209 |
{ |
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
210 |
va_list args; |
607 | 211 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
212 |
g_return_if_fail (node != NULL); |
1 | 213 |
|
607 | 214 |
for (va_start (args, name); |
215 |
name; |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
216 |
name = (const gchar *) va_arg (args, gpointer)) { |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
217 |
const gchar *value; |
1 | 218 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
219 |
value = (const gchar *) va_arg (args, gpointer); |
1 | 220 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
221 |
lm_message_node_set_attribute (node, name, value); |
607 | 222 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
223 |
} |
1 | 224 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
225 |
va_end (args); |
1 | 226 |
} |
227 |
||
228 |
/** |
|
229 |
* lm_message_node_set_attribute: |
|
230 |
* @node: an #LmMessageNode |
|
231 |
* @name: name of attribute |
|
232 |
* @value: value of attribute. |
|
607 | 233 |
* |
1 | 234 |
* Sets the attribute @name to @value. |
235 |
**/ |
|
236 |
void |
|
237 |
lm_message_node_set_attribute (LmMessageNode *node, |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
238 |
const gchar *name, |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
239 |
const gchar *value) |
1 | 240 |
{ |
607 | 241 |
gboolean found = FALSE; |
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
242 |
GSList *l; |
1 | 243 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
244 |
g_return_if_fail (node != NULL); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
245 |
g_return_if_fail (name != NULL); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
246 |
g_return_if_fail (value != NULL); |
168
ac1affcd5d22
2006-09-01 Mikael Hallendal <micke@imendio.com>
hallski <hallski>
parents:
166
diff
changeset
|
247 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
248 |
for (l = node->attributes; l; l = l->next) { |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
249 |
KeyValuePair *kvp = (KeyValuePair *) l->data; |
607 | 250 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
251 |
if (strcmp (kvp->key, name) == 0) { |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
252 |
g_free (kvp->value); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
253 |
kvp->value = g_strdup (value); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
254 |
found = TRUE; |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
255 |
break; |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
256 |
} |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
257 |
} |
607 | 258 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
259 |
if (!found) { |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
260 |
KeyValuePair *kvp; |
607 | 261 |
|
262 |
kvp = g_new0 (KeyValuePair, 1); |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
263 |
kvp->key = g_strdup (name); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
264 |
kvp->value = g_strdup (value); |
607 | 265 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
266 |
node->attributes = g_slist_prepend (node->attributes, kvp); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
267 |
} |
1 | 268 |
} |
269 |
||
270 |
/** |
|
271 |
* lm_message_node_get_attribute: |
|
272 |
* @node: an #LmMessageNode |
|
273 |
* @name: the attribute name |
|
607 | 274 |
* |
1 | 275 |
* Fetches the attribute @name from @node. |
607 | 276 |
* |
1 | 277 |
* Return value: the attribute value or %NULL if not set |
278 |
**/ |
|
279 |
const gchar * |
|
280 |
lm_message_node_get_attribute (LmMessageNode *node, const gchar *name) |
|
281 |
{ |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
282 |
GSList *l; |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
283 |
const gchar *ret_val = NULL; |
1 | 284 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
285 |
g_return_val_if_fail (node != NULL, NULL); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
286 |
g_return_val_if_fail (name != NULL, NULL); |
1 | 287 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
288 |
for (l = node->attributes; l; l = l->next) { |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
289 |
KeyValuePair *kvp = (KeyValuePair *) l->data; |
607 | 290 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
291 |
if (strcmp (kvp->key, name) == 0) { |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
292 |
ret_val = kvp->value; |
1 | 293 |
} |
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
294 |
} |
607 | 295 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
296 |
return ret_val; |
1 | 297 |
} |
298 |
||
299 |
/** |
|
300 |
* lm_message_node_get_child: |
|
301 |
* @node: an #LmMessageNode |
|
302 |
* @child_name: the childs name |
|
607 | 303 |
* |
304 |
* Fetches the child @child_name from @node. If child is not found as an |
|
1 | 305 |
* immediate child of @node %NULL is returned. |
607 | 306 |
* |
1 | 307 |
* Return value: the child node or %NULL if not found |
308 |
**/ |
|
309 |
LmMessageNode * |
|
310 |
lm_message_node_get_child (LmMessageNode *node, const gchar *child_name) |
|
311 |
{ |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
312 |
LmMessageNode *l; |
168
ac1affcd5d22
2006-09-01 Mikael Hallendal <micke@imendio.com>
hallski <hallski>
parents:
166
diff
changeset
|
313 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
314 |
g_return_val_if_fail (node != NULL, NULL); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
315 |
g_return_val_if_fail (child_name != NULL, NULL); |
168
ac1affcd5d22
2006-09-01 Mikael Hallendal <micke@imendio.com>
hallski <hallski>
parents:
166
diff
changeset
|
316 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
317 |
for (l = node->children; l; l = l->next) { |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
318 |
if (strcmp (l->name, child_name) == 0) { |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
319 |
return l; |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
320 |
} |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
321 |
} |
1 | 322 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
323 |
return NULL; |
1 | 324 |
} |
325 |
||
326 |
/** |
|
327 |
* lm_message_node_find_child: |
|
56
3bf928955fc5
2003-11-20 Ross Burton <ross@burtonini.com>
hallski <hallski>
parents:
7
diff
changeset
|
328 |
* @node: A #LmMessageNode |
3bf928955fc5
2003-11-20 Ross Burton <ross@burtonini.com>
hallski <hallski>
parents:
7
diff
changeset
|
329 |
* @child_name: The name of the child to find |
607 | 330 |
* |
331 |
* Locates a child among all children of @node. The entire tree will be search |
|
332 |
* until a child with name @child_name is located. |
|
333 |
* |
|
1 | 334 |
* Return value: the located child or %NULL if not found |
335 |
**/ |
|
607 | 336 |
LmMessageNode * |
1 | 337 |
lm_message_node_find_child (LmMessageNode *node, |
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
338 |
const gchar *child_name) |
1 | 339 |
{ |
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
340 |
LmMessageNode *l; |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
341 |
LmMessageNode *ret_val = NULL; |
1 | 342 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
343 |
g_return_val_if_fail (node != NULL, NULL); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
344 |
g_return_val_if_fail (child_name != NULL, NULL); |
168
ac1affcd5d22
2006-09-01 Mikael Hallendal <micke@imendio.com>
hallski <hallski>
parents:
166
diff
changeset
|
345 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
346 |
for (l = node->children; l; l = l->next) { |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
347 |
if (strcmp (l->name, child_name) == 0) { |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
348 |
return l; |
1 | 349 |
} |
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
350 |
if (l->children) { |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
351 |
ret_val = lm_message_node_find_child (l, child_name); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
352 |
if (ret_val) { |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
353 |
return ret_val; |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
354 |
} |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
355 |
} |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
356 |
} |
1 | 357 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
358 |
return NULL; |
1 | 359 |
} |
360 |
||
361 |
/** |
|
6
78fdf5d9eb1b
2003-06-11 Mikael Hallendal <micke@codefactory.se>
hallski <hallski>
parents:
4
diff
changeset
|
362 |
* lm_message_node_get_raw_mode: |
78fdf5d9eb1b
2003-06-11 Mikael Hallendal <micke@codefactory.se>
hallski <hallski>
parents:
4
diff
changeset
|
363 |
* @node: an #LmMessageNode |
607 | 364 |
* |
365 |
* Checks if the nodes value should be sent as raw mode. |
|
6
78fdf5d9eb1b
2003-06-11 Mikael Hallendal <micke@codefactory.se>
hallski <hallski>
parents:
4
diff
changeset
|
366 |
* |
78fdf5d9eb1b
2003-06-11 Mikael Hallendal <micke@codefactory.se>
hallski <hallski>
parents:
4
diff
changeset
|
367 |
* Return value: %TRUE if nodes value should be sent as is and %FALSE if the value will be escaped before sending. |
78fdf5d9eb1b
2003-06-11 Mikael Hallendal <micke@codefactory.se>
hallski <hallski>
parents:
4
diff
changeset
|
368 |
**/ |
78fdf5d9eb1b
2003-06-11 Mikael Hallendal <micke@codefactory.se>
hallski <hallski>
parents:
4
diff
changeset
|
369 |
gboolean |
78fdf5d9eb1b
2003-06-11 Mikael Hallendal <micke@codefactory.se>
hallski <hallski>
parents:
4
diff
changeset
|
370 |
lm_message_node_get_raw_mode (LmMessageNode *node) |
78fdf5d9eb1b
2003-06-11 Mikael Hallendal <micke@codefactory.se>
hallski <hallski>
parents:
4
diff
changeset
|
371 |
{ |
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
372 |
g_return_val_if_fail (node != NULL, FALSE); |
6
78fdf5d9eb1b
2003-06-11 Mikael Hallendal <micke@codefactory.se>
hallski <hallski>
parents:
4
diff
changeset
|
373 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
374 |
return node->raw_mode; |
6
78fdf5d9eb1b
2003-06-11 Mikael Hallendal <micke@codefactory.se>
hallski <hallski>
parents:
4
diff
changeset
|
375 |
} |
78fdf5d9eb1b
2003-06-11 Mikael Hallendal <micke@codefactory.se>
hallski <hallski>
parents:
4
diff
changeset
|
376 |
|
607 | 377 |
/** |
6
78fdf5d9eb1b
2003-06-11 Mikael Hallendal <micke@codefactory.se>
hallski <hallski>
parents:
4
diff
changeset
|
378 |
* lm_message_node_set_raw_mode: |
78fdf5d9eb1b
2003-06-11 Mikael Hallendal <micke@codefactory.se>
hallski <hallski>
parents:
4
diff
changeset
|
379 |
* @node: an #LmMessageNode |
78fdf5d9eb1b
2003-06-11 Mikael Hallendal <micke@codefactory.se>
hallski <hallski>
parents:
4
diff
changeset
|
380 |
* @raw_mode: boolean specifying if node value should be escaped or not. |
78fdf5d9eb1b
2003-06-11 Mikael Hallendal <micke@codefactory.se>
hallski <hallski>
parents:
4
diff
changeset
|
381 |
* |
78fdf5d9eb1b
2003-06-11 Mikael Hallendal <micke@codefactory.se>
hallski <hallski>
parents:
4
diff
changeset
|
382 |
* Set @raw_mode to %TRUE if you don't want to escape the value. You need to make sure the value is valid XML yourself. |
78fdf5d9eb1b
2003-06-11 Mikael Hallendal <micke@codefactory.se>
hallski <hallski>
parents:
4
diff
changeset
|
383 |
**/ |
78fdf5d9eb1b
2003-06-11 Mikael Hallendal <micke@codefactory.se>
hallski <hallski>
parents:
4
diff
changeset
|
384 |
void |
78fdf5d9eb1b
2003-06-11 Mikael Hallendal <micke@codefactory.se>
hallski <hallski>
parents:
4
diff
changeset
|
385 |
lm_message_node_set_raw_mode (LmMessageNode *node, gboolean raw_mode) |
78fdf5d9eb1b
2003-06-11 Mikael Hallendal <micke@codefactory.se>
hallski <hallski>
parents:
4
diff
changeset
|
386 |
{ |
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
387 |
g_return_if_fail (node != NULL); |
6
78fdf5d9eb1b
2003-06-11 Mikael Hallendal <micke@codefactory.se>
hallski <hallski>
parents:
4
diff
changeset
|
388 |
|
607 | 389 |
node->raw_mode = raw_mode; |
6
78fdf5d9eb1b
2003-06-11 Mikael Hallendal <micke@codefactory.se>
hallski <hallski>
parents:
4
diff
changeset
|
390 |
} |
78fdf5d9eb1b
2003-06-11 Mikael Hallendal <micke@codefactory.se>
hallski <hallski>
parents:
4
diff
changeset
|
391 |
|
78fdf5d9eb1b
2003-06-11 Mikael Hallendal <micke@codefactory.se>
hallski <hallski>
parents:
4
diff
changeset
|
392 |
/** |
1 | 393 |
* lm_message_node_ref: |
394 |
* @node: an #LmMessageNode |
|
607 | 395 |
* |
1 | 396 |
* Adds a reference to @node. |
607 | 397 |
* |
1 | 398 |
* Return value: the node |
399 |
**/ |
|
400 |
LmMessageNode * |
|
401 |
lm_message_node_ref (LmMessageNode *node) |
|
402 |
{ |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
403 |
g_return_val_if_fail (node != NULL, NULL); |
607 | 404 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
405 |
node->ref_count++; |
607 | 406 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
407 |
return node; |
1 | 408 |
} |
409 |
||
410 |
/** |
|
411 |
* lm_message_node_unref: |
|
412 |
* @node: an #LmMessageNode |
|
607 | 413 |
* |
1 | 414 |
* Removes a reference from @node. When no more references are present the |
415 |
* node is freed. When freed lm_message_node_unref() will be called on all |
|
607 | 416 |
* children. If caller needs to keep references to the children a call to |
417 |
* lm_message_node_ref() needs to be done before the call to |
|
1 | 418 |
*lm_message_unref(). |
419 |
**/ |
|
420 |
void |
|
421 |
lm_message_node_unref (LmMessageNode *node) |
|
422 |
{ |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
423 |
g_return_if_fail (node != NULL); |
607 | 424 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
425 |
node->ref_count--; |
607 | 426 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
427 |
if (node->ref_count == 0) { |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
428 |
message_node_free (node); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
429 |
} |
1 | 430 |
} |
431 |
||
432 |
/** |
|
433 |
* lm_message_node_to_string: |
|
434 |
* @node: an #LmMessageNode |
|
607 | 435 |
* |
1 | 436 |
* Returns an XML string representing the node. This is what is sent over the |
607 | 437 |
* wire. This is used internally Loudmouth and is external for debugging |
1 | 438 |
* purposes. |
607 | 439 |
* |
1 | 440 |
* Return value: an XML string representation of @node |
441 |
**/ |
|
442 |
gchar * |
|
443 |
lm_message_node_to_string (LmMessageNode *node) |
|
444 |
{ |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
445 |
GString *ret; |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
446 |
GSList *l; |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
447 |
LmMessageNode *child; |
166
2e6fae54b2fb
2006-08-22 Mikael Hallendal <micke@imendio.com>
hallski <hallski>
parents:
99
diff
changeset
|
448 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
449 |
g_return_val_if_fail (node != NULL, NULL); |
607 | 450 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
451 |
if (node->name == NULL) { |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
452 |
return g_strdup (""); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
453 |
} |
607 | 454 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
455 |
ret = g_string_new ("<"); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
456 |
g_string_append (ret, node->name); |
607 | 457 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
458 |
for (l = node->attributes; l; l = l->next) { |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
459 |
KeyValuePair *kvp = (KeyValuePair *) l->data; |
184
4e16d32b2410
2006-10-16 Mikael Hallendal <micke@imendio.com>
hallski <hallski>
parents:
168
diff
changeset
|
460 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
461 |
if (node->raw_mode == FALSE) { |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
462 |
gchar *escaped; |
184
4e16d32b2410
2006-10-16 Mikael Hallendal <micke@imendio.com>
hallski <hallski>
parents:
168
diff
changeset
|
463 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
464 |
escaped = g_markup_escape_text (kvp->value, -1); |
607 | 465 |
g_string_append_printf (ret, " %s=\"%s\"", |
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
466 |
kvp->key, escaped); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
467 |
g_free (escaped); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
468 |
} else { |
607 | 469 |
g_string_append_printf (ret, " %s=\"%s\"", |
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
470 |
kvp->key, kvp->value); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
471 |
} |
607 | 472 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
473 |
} |
607 | 474 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
475 |
g_string_append_c (ret, '>'); |
607 | 476 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
477 |
if (node->value) { |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
478 |
gchar *tmp; |
1 | 479 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
480 |
if (node->raw_mode == FALSE) { |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
481 |
tmp = g_markup_escape_text (node->value, -1); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
482 |
g_string_append (ret, tmp); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
483 |
g_free (tmp); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
484 |
} else { |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
485 |
g_string_append (ret, node->value); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
486 |
} |
607 | 487 |
} |
1 | 488 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
489 |
for (child = node->children; child; child = child->next) { |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
490 |
gchar *child_str = lm_message_node_to_string (child); |
576
18caa29fe013
Removed some whitespace insertions that were altering the structure of the
Kirk Haines <wyhaines@gmail.com>
parents:
518
diff
changeset
|
491 |
/* g_string_append_c (ret, ' '); */ |
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
492 |
g_string_append (ret, child_str); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
493 |
g_free (child_str); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
494 |
} |
1 | 495 |
|
576
18caa29fe013
Removed some whitespace insertions that were altering the structure of the
Kirk Haines <wyhaines@gmail.com>
parents:
518
diff
changeset
|
496 |
/* g_string_append_printf (ret, "</%s>\n", node->name); */ |
18caa29fe013
Removed some whitespace insertions that were altering the structure of the
Kirk Haines <wyhaines@gmail.com>
parents:
518
diff
changeset
|
497 |
g_string_append_printf (ret, "</%s>", node->name); |
607 | 498 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
499 |
return g_string_free (ret, FALSE); |
1 | 500 |
} |