author | psykose <alice@ayaya.dev> |
Thu, 21 Apr 2022 20:23:32 +0200 | |
changeset 744 | 4ebe32453682 |
parent 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 |
static void message_node_free (LmMessageNode *node); |
|
32 |
static LmMessageNode * message_node_last_child (LmMessageNode *node); |
|
33 |
||
34 |
static void |
|
35 |
message_node_free (LmMessageNode *node) |
|
36 |
{ |
|
710
ea3137a59c2b
LmMessageNode: Expose attributes member
Mykhailo Danylenko <risbea@gmail.com>
parents:
690
diff
changeset
|
37 |
LmMessageNode *l; |
ea3137a59c2b
LmMessageNode: Expose attributes member
Mykhailo Danylenko <risbea@gmail.com>
parents:
690
diff
changeset
|
38 |
LmMessageNodeAttribute *a; |
607 | 39 |
|
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
|
40 |
g_return_if_fail (node != NULL); |
1 | 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 |
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
|
43 |
LmMessageNode *next = l->next; |
1 | 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 |
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
|
46 |
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
|
47 |
} |
1 | 48 |
|
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
|
49 |
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
|
50 |
g_free (node->value); |
607 | 51 |
|
710
ea3137a59c2b
LmMessageNode: Expose attributes member
Mykhailo Danylenko <risbea@gmail.com>
parents:
690
diff
changeset
|
52 |
for (a = node->attributes; a;) { |
ea3137a59c2b
LmMessageNode: Expose attributes member
Mykhailo Danylenko <risbea@gmail.com>
parents:
690
diff
changeset
|
53 |
LmMessageNodeAttribute *next_a = a->next; |
607 | 54 |
|
710
ea3137a59c2b
LmMessageNode: Expose attributes member
Mykhailo Danylenko <risbea@gmail.com>
parents:
690
diff
changeset
|
55 |
g_free (a->name); |
ea3137a59c2b
LmMessageNode: Expose attributes member
Mykhailo Danylenko <risbea@gmail.com>
parents:
690
diff
changeset
|
56 |
g_free (a->value); |
ea3137a59c2b
LmMessageNode: Expose attributes member
Mykhailo Danylenko <risbea@gmail.com>
parents:
690
diff
changeset
|
57 |
g_free (a); |
ea3137a59c2b
LmMessageNode: Expose attributes member
Mykhailo Danylenko <risbea@gmail.com>
parents:
690
diff
changeset
|
58 |
|
ea3137a59c2b
LmMessageNode: Expose attributes member
Mykhailo Danylenko <risbea@gmail.com>
parents:
690
diff
changeset
|
59 |
a = next_a; |
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 |
} |
607 | 61 |
|
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
|
62 |
g_free (node); |
1 | 63 |
} |
64 |
||
65 |
static LmMessageNode * |
|
66 |
message_node_last_child (LmMessageNode *node) |
|
67 |
{ |
|
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
|
68 |
LmMessageNode *l; |
607 | 69 |
|
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
|
70 |
g_return_val_if_fail (node != NULL, NULL); |
1 | 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 |
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
|
73 |
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
|
74 |
} |
607 | 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 |
l = node->children; |
1 | 77 |
|
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
|
78 |
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
|
79 |
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
|
80 |
} |
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 |
return l; |
1 | 83 |
} |
84 |
||
85 |
LmMessageNode * |
|
86 |
_lm_message_node_new (const gchar *name) |
|
87 |
{ |
|
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
|
88 |
LmMessageNode *node; |
1 | 89 |
|
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
|
90 |
node = g_new0 (LmMessageNode, 1); |
607 | 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 |
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
|
93 |
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
|
94 |
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
|
95 |
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
|
96 |
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
|
97 |
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
|
98 |
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
|
99 |
node->children = NULL; |
1 | 100 |
|
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
|
101 |
node->ref_count = 1; |
1 | 102 |
|
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
|
103 |
return node; |
1 | 104 |
} |
105 |
void |
|
106 |
_lm_message_node_add_child_node (LmMessageNode *node, LmMessageNode *child) |
|
107 |
{ |
|
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
|
108 |
LmMessageNode *prev; |
607 | 109 |
|
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
|
110 |
g_return_if_fail (node != NULL); |
1 | 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 |
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
|
113 |
lm_message_node_ref (child); |
1 | 114 |
|
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
|
115 |
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
|
116 |
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
|
117 |
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
|
118 |
} 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
|
119 |
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
|
120 |
} |
607 | 121 |
|
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
|
122 |
child->parent = node; |
1 | 123 |
} |
124 |
||
125 |
/** |
|
126 |
* lm_message_node_get_value: |
|
127 |
* @node: an #LmMessageNode |
|
607 | 128 |
* |
1 | 129 |
* Retrieves the value of @node. |
607 | 130 |
* |
131 |
* Return value: |
|
1 | 132 |
**/ |
133 |
const gchar * |
|
134 |
lm_message_node_get_value (LmMessageNode *node) |
|
135 |
{ |
|
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
|
136 |
g_return_val_if_fail (node != NULL, NULL); |
607 | 137 |
|
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
|
138 |
return node->value; |
1 | 139 |
} |
140 |
||
141 |
/** |
|
142 |
* lm_message_node_set_value: |
|
143 |
* @node: an #LmMessageNode |
|
144 |
* @value: the new value. |
|
607 | 145 |
* |
1 | 146 |
* Sets the value of @node. If a previous value is set it will be freed. |
147 |
**/ |
|
148 |
void |
|
149 |
lm_message_node_set_value (LmMessageNode *node, const gchar *value) |
|
150 |
{ |
|
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
|
151 |
g_return_if_fail (node != NULL); |
607 | 152 |
|
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
|
153 |
g_free (node->value); |
607 | 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 |
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
|
156 |
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
|
157 |
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
|
158 |
} |
1 | 159 |
|
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
|
160 |
node->value = g_strdup (value); |
1 | 161 |
} |
162 |
||
163 |
/** |
|
164 |
* lm_message_node_add_child: |
|
165 |
* @node: an #LmMessageNode |
|
166 |
* @name: the name of the new child |
|
167 |
* @value: value of the new child |
|
607 | 168 |
* |
169 |
* Add a child node with @name and value set to @value. |
|
170 |
* |
|
1 | 171 |
* Return value: the newly created child |
172 |
**/ |
|
173 |
LmMessageNode * |
|
607 | 174 |
lm_message_node_add_child (LmMessageNode *node, |
175 |
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
|
176 |
const gchar *value) |
1 | 177 |
{ |
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
|
178 |
LmMessageNode *child; |
607 | 179 |
|
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 |
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
|
181 |
g_return_val_if_fail (name != NULL, NULL); |
168
ac1affcd5d22
2006-09-01 Mikael Hallendal <micke@imendio.com>
hallski <hallski>
parents:
166
diff
changeset
|
182 |
|
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
|
183 |
child = _lm_message_node_new (name); |
1 | 184 |
|
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
|
185 |
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
|
186 |
_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
|
187 |
lm_message_node_unref (child); |
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 |
return child; |
1 | 190 |
} |
191 |
||
192 |
/** |
|
193 |
* lm_message_node_set_attributes: |
|
194 |
* @node: an #LmMessageNode |
|
195 |
* @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
|
196 |
* @Varargs: The rest of the name/value pairs |
607 | 197 |
* |
198 |
* Sets a list of attributes. The arguments should be names and corresponding |
|
1 | 199 |
* value and needs to be ended with %NULL. |
200 |
**/ |
|
201 |
void |
|
202 |
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
|
203 |
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
|
204 |
...) |
1 | 205 |
{ |
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
|
206 |
va_list args; |
607 | 207 |
|
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
|
208 |
g_return_if_fail (node != NULL); |
1 | 209 |
|
607 | 210 |
for (va_start (args, name); |
211 |
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
|
212 |
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
|
213 |
const gchar *value; |
1 | 214 |
|
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
|
215 |
value = (const gchar *) va_arg (args, gpointer); |
1 | 216 |
|
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
|
217 |
lm_message_node_set_attribute (node, name, 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
|
218 |
} |
1 | 219 |
|
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
|
220 |
va_end (args); |
1 | 221 |
} |
222 |
||
223 |
/** |
|
224 |
* lm_message_node_set_attribute: |
|
225 |
* @node: an #LmMessageNode |
|
226 |
* @name: name of attribute |
|
227 |
* @value: value of attribute. |
|
607 | 228 |
* |
1 | 229 |
* Sets the attribute @name to @value. |
230 |
**/ |
|
231 |
void |
|
232 |
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
|
233 |
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
|
234 |
const gchar *value) |
1 | 235 |
{ |
710
ea3137a59c2b
LmMessageNode: Expose attributes member
Mykhailo Danylenko <risbea@gmail.com>
parents:
690
diff
changeset
|
236 |
gboolean found = FALSE; |
ea3137a59c2b
LmMessageNode: Expose attributes member
Mykhailo Danylenko <risbea@gmail.com>
parents:
690
diff
changeset
|
237 |
LmMessageNodeAttribute *a; |
1 | 238 |
|
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
|
239 |
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
|
240 |
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
|
241 |
g_return_if_fail (value != NULL); |
168
ac1affcd5d22
2006-09-01 Mikael Hallendal <micke@imendio.com>
hallski <hallski>
parents:
166
diff
changeset
|
242 |
|
710
ea3137a59c2b
LmMessageNode: Expose attributes member
Mykhailo Danylenko <risbea@gmail.com>
parents:
690
diff
changeset
|
243 |
for (a = node->attributes; a; a = a->next) { |
ea3137a59c2b
LmMessageNode: Expose attributes member
Mykhailo Danylenko <risbea@gmail.com>
parents:
690
diff
changeset
|
244 |
if (strcmp (a->name, name) == 0) { |
ea3137a59c2b
LmMessageNode: Expose attributes member
Mykhailo Danylenko <risbea@gmail.com>
parents:
690
diff
changeset
|
245 |
g_free (a->value); |
ea3137a59c2b
LmMessageNode: Expose attributes member
Mykhailo Danylenko <risbea@gmail.com>
parents:
690
diff
changeset
|
246 |
a->value = g_strdup (value); |
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
|
247 |
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
|
248 |
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
|
249 |
} |
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
|
250 |
} |
607 | 251 |
|
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
|
252 |
if (!found) { |
710
ea3137a59c2b
LmMessageNode: Expose attributes member
Mykhailo Danylenko <risbea@gmail.com>
parents:
690
diff
changeset
|
253 |
a = g_new0 (LmMessageNodeAttribute, 1); |
ea3137a59c2b
LmMessageNode: Expose attributes member
Mykhailo Danylenko <risbea@gmail.com>
parents:
690
diff
changeset
|
254 |
a->name = g_strdup (name); |
ea3137a59c2b
LmMessageNode: Expose attributes member
Mykhailo Danylenko <risbea@gmail.com>
parents:
690
diff
changeset
|
255 |
a->value = g_strdup (value); |
607 | 256 |
|
710
ea3137a59c2b
LmMessageNode: Expose attributes member
Mykhailo Danylenko <risbea@gmail.com>
parents:
690
diff
changeset
|
257 |
a->next = node->attributes; |
ea3137a59c2b
LmMessageNode: Expose attributes member
Mykhailo Danylenko <risbea@gmail.com>
parents:
690
diff
changeset
|
258 |
node->attributes = a; |
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 |
} |
1 | 260 |
} |
261 |
||
262 |
/** |
|
263 |
* lm_message_node_get_attribute: |
|
264 |
* @node: an #LmMessageNode |
|
265 |
* @name: the attribute name |
|
607 | 266 |
* |
1 | 267 |
* Fetches the attribute @name from @node. |
607 | 268 |
* |
1 | 269 |
* Return value: the attribute value or %NULL if not set |
270 |
**/ |
|
271 |
const gchar * |
|
272 |
lm_message_node_get_attribute (LmMessageNode *node, const gchar *name) |
|
273 |
{ |
|
710
ea3137a59c2b
LmMessageNode: Expose attributes member
Mykhailo Danylenko <risbea@gmail.com>
parents:
690
diff
changeset
|
274 |
LmMessageNodeAttribute *a; |
ea3137a59c2b
LmMessageNode: Expose attributes member
Mykhailo Danylenko <risbea@gmail.com>
parents:
690
diff
changeset
|
275 |
const gchar *ret_val = NULL; |
1 | 276 |
|
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
|
277 |
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
|
278 |
g_return_val_if_fail (name != NULL, NULL); |
1 | 279 |
|
710
ea3137a59c2b
LmMessageNode: Expose attributes member
Mykhailo Danylenko <risbea@gmail.com>
parents:
690
diff
changeset
|
280 |
for (a = node->attributes; a; a = a->next) { |
ea3137a59c2b
LmMessageNode: Expose attributes member
Mykhailo Danylenko <risbea@gmail.com>
parents:
690
diff
changeset
|
281 |
if (strcmp (a->name, name) == 0) { |
ea3137a59c2b
LmMessageNode: Expose attributes member
Mykhailo Danylenko <risbea@gmail.com>
parents:
690
diff
changeset
|
282 |
ret_val = a->value; |
ea3137a59c2b
LmMessageNode: Expose attributes member
Mykhailo Danylenko <risbea@gmail.com>
parents:
690
diff
changeset
|
283 |
break; |
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 |
} |
607 | 286 |
|
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
|
287 |
return ret_val; |
1 | 288 |
} |
289 |
||
290 |
/** |
|
291 |
* lm_message_node_get_child: |
|
292 |
* @node: an #LmMessageNode |
|
293 |
* @child_name: the childs name |
|
607 | 294 |
* |
295 |
* Fetches the child @child_name from @node. If child is not found as an |
|
1 | 296 |
* immediate child of @node %NULL is returned. |
607 | 297 |
* |
1 | 298 |
* Return value: the child node or %NULL if not found |
299 |
**/ |
|
300 |
LmMessageNode * |
|
301 |
lm_message_node_get_child (LmMessageNode *node, const gchar *child_name) |
|
302 |
{ |
|
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
|
303 |
LmMessageNode *l; |
168
ac1affcd5d22
2006-09-01 Mikael Hallendal <micke@imendio.com>
hallski <hallski>
parents:
166
diff
changeset
|
304 |
|
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
|
305 |
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
|
306 |
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
|
307 |
|
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
|
308 |
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
|
309 |
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
|
310 |
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
|
311 |
} |
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 |
} |
1 | 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 |
return NULL; |
1 | 315 |
} |
316 |
||
317 |
/** |
|
318 |
* lm_message_node_find_child: |
|
56
3bf928955fc5
2003-11-20 Ross Burton <ross@burtonini.com>
hallski <hallski>
parents:
7
diff
changeset
|
319 |
* @node: A #LmMessageNode |
3bf928955fc5
2003-11-20 Ross Burton <ross@burtonini.com>
hallski <hallski>
parents:
7
diff
changeset
|
320 |
* @child_name: The name of the child to find |
607 | 321 |
* |
322 |
* Locates a child among all children of @node. The entire tree will be search |
|
323 |
* until a child with name @child_name is located. |
|
324 |
* |
|
1 | 325 |
* Return value: the located child or %NULL if not found |
326 |
**/ |
|
607 | 327 |
LmMessageNode * |
1 | 328 |
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
|
329 |
const gchar *child_name) |
1 | 330 |
{ |
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
|
331 |
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
|
332 |
LmMessageNode *ret_val = NULL; |
1 | 333 |
|
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
|
334 |
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
|
335 |
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
|
336 |
|
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
|
337 |
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
|
338 |
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
|
339 |
return l; |
1 | 340 |
} |
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
|
341 |
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
|
342 |
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
|
343 |
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
|
344 |
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
|
345 |
} |
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 |
} |
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 |
} |
1 | 348 |
|
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
|
349 |
return NULL; |
1 | 350 |
} |
351 |
||
352 |
/** |
|
6
78fdf5d9eb1b
2003-06-11 Mikael Hallendal <micke@codefactory.se>
hallski <hallski>
parents:
4
diff
changeset
|
353 |
* lm_message_node_get_raw_mode: |
78fdf5d9eb1b
2003-06-11 Mikael Hallendal <micke@codefactory.se>
hallski <hallski>
parents:
4
diff
changeset
|
354 |
* @node: an #LmMessageNode |
607 | 355 |
* |
356 |
* 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
|
357 |
* |
78fdf5d9eb1b
2003-06-11 Mikael Hallendal <micke@codefactory.se>
hallski <hallski>
parents:
4
diff
changeset
|
358 |
* 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
|
359 |
**/ |
78fdf5d9eb1b
2003-06-11 Mikael Hallendal <micke@codefactory.se>
hallski <hallski>
parents:
4
diff
changeset
|
360 |
gboolean |
78fdf5d9eb1b
2003-06-11 Mikael Hallendal <micke@codefactory.se>
hallski <hallski>
parents:
4
diff
changeset
|
361 |
lm_message_node_get_raw_mode (LmMessageNode *node) |
78fdf5d9eb1b
2003-06-11 Mikael Hallendal <micke@codefactory.se>
hallski <hallski>
parents:
4
diff
changeset
|
362 |
{ |
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
|
363 |
g_return_val_if_fail (node != NULL, FALSE); |
6
78fdf5d9eb1b
2003-06-11 Mikael Hallendal <micke@codefactory.se>
hallski <hallski>
parents:
4
diff
changeset
|
364 |
|
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
|
365 |
return node->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 |
|
607 | 368 |
/** |
6
78fdf5d9eb1b
2003-06-11 Mikael Hallendal <micke@codefactory.se>
hallski <hallski>
parents:
4
diff
changeset
|
369 |
* lm_message_node_set_raw_mode: |
78fdf5d9eb1b
2003-06-11 Mikael Hallendal <micke@codefactory.se>
hallski <hallski>
parents:
4
diff
changeset
|
370 |
* @node: an #LmMessageNode |
78fdf5d9eb1b
2003-06-11 Mikael Hallendal <micke@codefactory.se>
hallski <hallski>
parents:
4
diff
changeset
|
371 |
* @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
|
372 |
* |
78fdf5d9eb1b
2003-06-11 Mikael Hallendal <micke@codefactory.se>
hallski <hallski>
parents:
4
diff
changeset
|
373 |
* 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
|
374 |
**/ |
78fdf5d9eb1b
2003-06-11 Mikael Hallendal <micke@codefactory.se>
hallski <hallski>
parents:
4
diff
changeset
|
375 |
void |
78fdf5d9eb1b
2003-06-11 Mikael Hallendal <micke@codefactory.se>
hallski <hallski>
parents:
4
diff
changeset
|
376 |
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
|
377 |
{ |
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
|
378 |
g_return_if_fail (node != NULL); |
6
78fdf5d9eb1b
2003-06-11 Mikael Hallendal <micke@codefactory.se>
hallski <hallski>
parents:
4
diff
changeset
|
379 |
|
607 | 380 |
node->raw_mode = raw_mode; |
6
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 |
|
78fdf5d9eb1b
2003-06-11 Mikael Hallendal <micke@codefactory.se>
hallski <hallski>
parents:
4
diff
changeset
|
383 |
/** |
1 | 384 |
* lm_message_node_ref: |
385 |
* @node: an #LmMessageNode |
|
607 | 386 |
* |
1 | 387 |
* Adds a reference to @node. |
607 | 388 |
* |
1 | 389 |
* Return value: the node |
390 |
**/ |
|
391 |
LmMessageNode * |
|
392 |
lm_message_node_ref (LmMessageNode *node) |
|
393 |
{ |
|
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
|
394 |
g_return_val_if_fail (node != NULL, NULL); |
607 | 395 |
|
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
|
396 |
node->ref_count++; |
607 | 397 |
|
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
|
398 |
return node; |
1 | 399 |
} |
400 |
||
401 |
/** |
|
402 |
* lm_message_node_unref: |
|
403 |
* @node: an #LmMessageNode |
|
607 | 404 |
* |
1 | 405 |
* Removes a reference from @node. When no more references are present the |
406 |
* node is freed. When freed lm_message_node_unref() will be called on all |
|
607 | 407 |
* children. If caller needs to keep references to the children a call to |
408 |
* lm_message_node_ref() needs to be done before the call to |
|
1 | 409 |
*lm_message_unref(). |
410 |
**/ |
|
411 |
void |
|
412 |
lm_message_node_unref (LmMessageNode *node) |
|
413 |
{ |
|
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
|
414 |
g_return_if_fail (node != NULL); |
607 | 415 |
|
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
|
416 |
node->ref_count--; |
607 | 417 |
|
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
|
418 |
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
|
419 |
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
|
420 |
} |
1 | 421 |
} |
422 |
||
423 |
/** |
|
424 |
* lm_message_node_to_string: |
|
425 |
* @node: an #LmMessageNode |
|
607 | 426 |
* |
1 | 427 |
* Returns an XML string representing the node. This is what is sent over the |
607 | 428 |
* wire. This is used internally Loudmouth and is external for debugging |
1 | 429 |
* purposes. |
607 | 430 |
* |
1 | 431 |
* Return value: an XML string representation of @node |
432 |
**/ |
|
433 |
gchar * |
|
434 |
lm_message_node_to_string (LmMessageNode *node) |
|
435 |
{ |
|
710
ea3137a59c2b
LmMessageNode: Expose attributes member
Mykhailo Danylenko <risbea@gmail.com>
parents:
690
diff
changeset
|
436 |
GString *ret; |
ea3137a59c2b
LmMessageNode: Expose attributes member
Mykhailo Danylenko <risbea@gmail.com>
parents:
690
diff
changeset
|
437 |
LmMessageNodeAttribute *a; |
ea3137a59c2b
LmMessageNode: Expose attributes member
Mykhailo Danylenko <risbea@gmail.com>
parents:
690
diff
changeset
|
438 |
LmMessageNode *child; |
166
2e6fae54b2fb
2006-08-22 Mikael Hallendal <micke@imendio.com>
hallski <hallski>
parents:
99
diff
changeset
|
439 |
|
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
|
440 |
g_return_val_if_fail (node != NULL, NULL); |
607 | 441 |
|
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
|
442 |
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
|
443 |
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
|
444 |
} |
607 | 445 |
|
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
|
446 |
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
|
447 |
g_string_append (ret, node->name); |
607 | 448 |
|
710
ea3137a59c2b
LmMessageNode: Expose attributes member
Mykhailo Danylenko <risbea@gmail.com>
parents:
690
diff
changeset
|
449 |
for (a = node->attributes; a; a = a->next) { |
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
|
450 |
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
|
451 |
gchar *escaped; |
184
4e16d32b2410
2006-10-16 Mikael Hallendal <micke@imendio.com>
hallski <hallski>
parents:
168
diff
changeset
|
452 |
|
710
ea3137a59c2b
LmMessageNode: Expose attributes member
Mykhailo Danylenko <risbea@gmail.com>
parents:
690
diff
changeset
|
453 |
escaped = g_markup_escape_text (a->value, -1); |
607 | 454 |
g_string_append_printf (ret, " %s=\"%s\"", |
710
ea3137a59c2b
LmMessageNode: Expose attributes member
Mykhailo Danylenko <risbea@gmail.com>
parents:
690
diff
changeset
|
455 |
a->name, escaped); |
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
|
456 |
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
|
457 |
} else { |
607 | 458 |
g_string_append_printf (ret, " %s=\"%s\"", |
710
ea3137a59c2b
LmMessageNode: Expose attributes member
Mykhailo Danylenko <risbea@gmail.com>
parents:
690
diff
changeset
|
459 |
a->name, a->value); |
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
|
460 |
} |
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 |
} |
607 | 462 |
|
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
|
463 |
g_string_append_c (ret, '>'); |
607 | 464 |
|
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
|
465 |
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
|
466 |
gchar *tmp; |
1 | 467 |
|
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
|
468 |
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
|
469 |
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
|
470 |
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
|
471 |
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
|
472 |
} 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
|
473 |
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
|
474 |
} |
607 | 475 |
} |
1 | 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 |
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
|
478 |
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
|
479 |
/* 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
|
480 |
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
|
481 |
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
|
482 |
} |
1 | 483 |
|
576
18caa29fe013
Removed some whitespace insertions that were altering the structure of the
Kirk Haines <wyhaines@gmail.com>
parents:
518
diff
changeset
|
484 |
/* 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
|
485 |
g_string_append_printf (ret, "</%s>", node->name); |
607 | 486 |
|
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
|
487 |
return g_string_free (ret, FALSE); |
1 | 488 |
} |