author | Jayson Vantuyl <jvantuyl@engineyard.com> |
Wed, 25 Mar 2009 11:28:18 -0700 | |
changeset 596 | 9096d2549372 |
parent 576 | 18caa29fe013 |
child 607 | e2bd14357c9a |
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 |
|
16 |
* License along with this program; if not, write to the |
|
17 |
* Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
|
18 |
* Boston, MA 02111-1307, USA. |
|
19 |
*/ |
|
20 |
||
417
364c17252e5f
Added inlined documentation from generated through the Gtk-doc migration script.
Mikael Hallendal <micke@imendio.com>
parents:
185
diff
changeset
|
21 |
/** |
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
|
22 |
* SECTION:lm-message-node |
421
2a91651d22de
Added Title to the inlined documentation
Mikael Hallendal <micke@imendio.com>
parents:
420
diff
changeset
|
23 |
* @Title: LmMessageNode |
417
364c17252e5f
Added inlined documentation from generated through the Gtk-doc migration script.
Mikael Hallendal <micke@imendio.com>
parents:
185
diff
changeset
|
24 |
* @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
|
25 |
*/ |
364c17252e5f
Added inlined documentation from generated through the Gtk-doc migration script.
Mikael Hallendal <micke@imendio.com>
parents:
185
diff
changeset
|
26 |
|
1 | 27 |
#include <config.h> |
28 |
#include <string.h> |
|
29 |
||
30 |
#include "lm-internals.h" |
|
31 |
#include "lm-message-node.h" |
|
32 |
||
33 |
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
|
34 |
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
|
35 |
gchar *value; |
1 | 36 |
} KeyValuePair; |
37 |
||
38 |
static void message_node_free (LmMessageNode *node); |
|
39 |
static LmMessageNode * message_node_last_child (LmMessageNode *node); |
|
40 |
||
41 |
static void |
|
42 |
message_node_free (LmMessageNode *node) |
|
43 |
{ |
|
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
|
44 |
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
|
45 |
GSList *list; |
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 |
g_return_if_fail (node != NULL); |
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 |
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
|
50 |
LmMessageNode *next = l->next; |
1 | 51 |
|
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
|
52 |
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
|
53 |
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
|
54 |
} |
1 | 55 |
|
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
|
56 |
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
|
57 |
g_free (node->value); |
1 | 58 |
|
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
|
59 |
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
|
60 |
KeyValuePair *kvp = (KeyValuePair *) list->data; |
1 | 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 (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
|
63 |
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
|
64 |
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
|
65 |
} |
1 | 66 |
|
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
|
67 |
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
|
68 |
g_free (node); |
1 | 69 |
} |
70 |
||
71 |
static LmMessageNode * |
|
72 |
message_node_last_child (LmMessageNode *node) |
|
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 |
LmMessageNode *l; |
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 |
g_return_val_if_fail (node != NULL, NULL); |
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 |
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
|
79 |
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
|
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 |
l = node->children; |
1 | 83 |
|
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
|
84 |
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
|
85 |
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
|
86 |
} |
1 | 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 |
return l; |
1 | 89 |
} |
90 |
||
91 |
LmMessageNode * |
|
92 |
_lm_message_node_new (const gchar *name) |
|
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 |
LmMessageNode *node; |
1 | 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 = g_new0 (LmMessageNode, 1); |
1 | 97 |
|
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
|
98 |
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
|
99 |
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
|
100 |
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
|
101 |
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
|
102 |
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
|
103 |
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
|
104 |
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
|
105 |
node->children = NULL; |
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 |
node->ref_count = 1; |
1 | 108 |
|
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
|
109 |
return node; |
1 | 110 |
} |
111 |
void |
|
112 |
_lm_message_node_add_child_node (LmMessageNode *node, LmMessageNode *child) |
|
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 |
LmMessageNode *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
|
115 |
|
cdd6a0c5b439
Went 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 |
g_return_if_fail (node != NULL); |
1 | 117 |
|
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
|
118 |
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
|
119 |
lm_message_node_ref (child); |
1 | 120 |
|
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
|
121 |
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
|
122 |
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
|
123 |
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
|
124 |
} 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
|
125 |
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
|
126 |
} |
1 | 127 |
|
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
|
128 |
child->parent = node; |
1 | 129 |
} |
130 |
||
131 |
/** |
|
132 |
* lm_message_node_get_value: |
|
133 |
* @node: an #LmMessageNode |
|
134 |
* |
|
135 |
* Retrieves the value of @node. |
|
136 |
* |
|
137 |
* Return value: |
|
138 |
**/ |
|
139 |
const gchar * |
|
140 |
lm_message_node_get_value (LmMessageNode *node) |
|
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 |
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
|
143 |
|
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
144 |
return node->value; |
1 | 145 |
} |
146 |
||
147 |
/** |
|
148 |
* lm_message_node_set_value: |
|
149 |
* @node: an #LmMessageNode |
|
150 |
* @value: the new value. |
|
151 |
* |
|
152 |
* Sets the value of @node. If a previous value is set it will be freed. |
|
153 |
**/ |
|
154 |
void |
|
155 |
lm_message_node_set_value (LmMessageNode *node, const gchar *value) |
|
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_return_if_fail (node != NULL); |
1 | 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 |
g_free (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
|
160 |
|
cdd6a0c5b439
Went 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 |
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
|
162 |
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
|
163 |
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
|
164 |
} |
1 | 165 |
|
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
|
166 |
node->value = g_strdup (value); |
1 | 167 |
} |
168 |
||
169 |
/** |
|
170 |
* lm_message_node_add_child: |
|
171 |
* @node: an #LmMessageNode |
|
172 |
* @name: the name of the new child |
|
173 |
* @value: value of the new child |
|
174 |
* |
|
175 |
* Add a child node with @name and value set to @value. |
|
176 |
* |
|
177 |
* Return value: the newly created child |
|
178 |
**/ |
|
179 |
LmMessageNode * |
|
180 |
lm_message_node_add_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
|
181 |
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
|
182 |
const gchar *value) |
1 | 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 |
LmMessageNode *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
|
185 |
|
cdd6a0c5b439
Went 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 |
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
|
187 |
g_return_val_if_fail (name != NULL, NULL); |
168
ac1affcd5d22
2006-09-01 Mikael Hallendal <micke@imendio.com>
hallski <hallski>
parents:
166
diff
changeset
|
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 |
child = _lm_message_node_new (name); |
1 | 190 |
|
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
|
191 |
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
|
192 |
_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
|
193 |
lm_message_node_unref (child); |
1 | 194 |
|
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
|
195 |
return child; |
1 | 196 |
} |
197 |
||
198 |
/** |
|
199 |
* lm_message_node_set_attributes: |
|
200 |
* @node: an #LmMessageNode |
|
201 |
* @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
|
202 |
* @Varargs: The rest of the name/value pairs |
1 | 203 |
* |
204 |
* Sets a list of attributes. The arguments should be names and corresponding |
|
205 |
* value and needs to be ended with %NULL. |
|
206 |
**/ |
|
207 |
void |
|
208 |
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
|
209 |
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
|
210 |
...) |
1 | 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 |
va_list args; |
cdd6a0c5b439
Went 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 |
|
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
214 |
g_return_if_fail (node != NULL); |
1 | 215 |
|
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 |
for (va_start (args, 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
|
217 |
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
|
218 |
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
|
219 |
const gchar *value; |
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 |
value = (const gchar *) va_arg (args, gpointer); |
1 | 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 |
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
|
224 |
|
cdd6a0c5b439
Went 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 |
} |
1 | 226 |
|
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
|
227 |
va_end (args); |
1 | 228 |
} |
229 |
||
230 |
/** |
|
231 |
* lm_message_node_set_attribute: |
|
232 |
* @node: an #LmMessageNode |
|
233 |
* @name: name of attribute |
|
234 |
* @value: value of attribute. |
|
235 |
* |
|
236 |
* Sets the attribute @name to @value. |
|
237 |
**/ |
|
238 |
void |
|
239 |
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
|
240 |
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
|
241 |
const gchar *value) |
1 | 242 |
{ |
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
|
243 |
gboolean found = 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
|
244 |
GSList *l; |
1 | 245 |
|
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
|
246 |
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
|
247 |
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
|
248 |
g_return_if_fail (value != NULL); |
168
ac1affcd5d22
2006-09-01 Mikael Hallendal <micke@imendio.com>
hallski <hallski>
parents:
166
diff
changeset
|
249 |
|
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
|
250 |
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
|
251 |
KeyValuePair *kvp = (KeyValuePair *) l->data; |
1 | 252 |
|
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
|
253 |
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
|
254 |
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
|
255 |
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
|
256 |
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
|
257 |
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
|
258 |
} |
cdd6a0c5b439
Went 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 |
} |
cdd6a0c5b439
Went 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 |
|
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
261 |
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
|
262 |
KeyValuePair *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
|
263 |
|
cdd6a0c5b439
Went 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 = g_new0 (KeyValuePair, 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
|
265 |
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
|
266 |
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
|
267 |
|
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
268 |
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
|
269 |
} |
1 | 270 |
} |
271 |
||
272 |
/** |
|
273 |
* lm_message_node_get_attribute: |
|
274 |
* @node: an #LmMessageNode |
|
275 |
* @name: the attribute name |
|
276 |
* |
|
277 |
* Fetches the attribute @name from @node. |
|
278 |
* |
|
279 |
* Return value: the attribute value or %NULL if not set |
|
280 |
**/ |
|
281 |
const gchar * |
|
282 |
lm_message_node_get_attribute (LmMessageNode *node, const gchar *name) |
|
283 |
{ |
|
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
|
284 |
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
|
285 |
const gchar *ret_val = NULL; |
1 | 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 |
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
|
288 |
g_return_val_if_fail (name != NULL, NULL); |
1 | 289 |
|
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
|
290 |
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
|
291 |
KeyValuePair *kvp = (KeyValuePair *) l->data; |
1 | 292 |
|
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
|
293 |
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
|
294 |
ret_val = kvp->value; |
1 | 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 |
} |
1 | 297 |
|
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
|
298 |
return ret_val; |
1 | 299 |
} |
300 |
||
301 |
/** |
|
302 |
* lm_message_node_get_child: |
|
303 |
* @node: an #LmMessageNode |
|
304 |
* @child_name: the childs name |
|
305 |
* |
|
306 |
* Fetches the child @child_name from @node. If child is not found as an |
|
307 |
* immediate child of @node %NULL is returned. |
|
308 |
* |
|
309 |
* Return value: the child node or %NULL if not found |
|
310 |
**/ |
|
311 |
LmMessageNode * |
|
312 |
lm_message_node_get_child (LmMessageNode *node, const gchar *child_name) |
|
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 |
LmMessageNode *l; |
168
ac1affcd5d22
2006-09-01 Mikael Hallendal <micke@imendio.com>
hallski <hallski>
parents:
166
diff
changeset
|
315 |
|
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
|
316 |
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
|
317 |
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
|
318 |
|
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
|
319 |
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
|
320 |
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
|
321 |
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
|
322 |
} |
cdd6a0c5b439
Went 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 |
} |
1 | 324 |
|
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
|
325 |
return NULL; |
1 | 326 |
} |
327 |
||
328 |
/** |
|
329 |
* lm_message_node_find_child: |
|
56
3bf928955fc5
2003-11-20 Ross Burton <ross@burtonini.com>
hallski <hallski>
parents:
7
diff
changeset
|
330 |
* @node: A #LmMessageNode |
3bf928955fc5
2003-11-20 Ross Burton <ross@burtonini.com>
hallski <hallski>
parents:
7
diff
changeset
|
331 |
* @child_name: The name of the child to find |
1 | 332 |
* |
333 |
* Locates a child among all children of @node. The entire tree will be search |
|
334 |
* until a child with name @child_name is located. |
|
335 |
* |
|
336 |
* Return value: the located child or %NULL if not found |
|
337 |
**/ |
|
338 |
LmMessageNode * |
|
339 |
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
|
340 |
const gchar *child_name) |
1 | 341 |
{ |
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
|
342 |
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
|
343 |
LmMessageNode *ret_val = NULL; |
1 | 344 |
|
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
|
345 |
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
|
346 |
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
|
347 |
|
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
|
348 |
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
|
349 |
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
|
350 |
return l; |
1 | 351 |
} |
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
|
352 |
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
|
353 |
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
|
354 |
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
|
355 |
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
|
356 |
} |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
357 |
} |
cdd6a0c5b439
Went 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 |
} |
1 | 359 |
|
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
|
360 |
return NULL; |
1 | 361 |
} |
362 |
||
363 |
/** |
|
6
78fdf5d9eb1b
2003-06-11 Mikael Hallendal <micke@codefactory.se>
hallski <hallski>
parents:
4
diff
changeset
|
364 |
* lm_message_node_get_raw_mode: |
78fdf5d9eb1b
2003-06-11 Mikael Hallendal <micke@codefactory.se>
hallski <hallski>
parents:
4
diff
changeset
|
365 |
* @node: an #LmMessageNode |
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 |
* Checks if the nodes value should be sent as raw mode. |
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 |
* 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
|
370 |
**/ |
78fdf5d9eb1b
2003-06-11 Mikael Hallendal <micke@codefactory.se>
hallski <hallski>
parents:
4
diff
changeset
|
371 |
gboolean |
78fdf5d9eb1b
2003-06-11 Mikael Hallendal <micke@codefactory.se>
hallski <hallski>
parents:
4
diff
changeset
|
372 |
lm_message_node_get_raw_mode (LmMessageNode *node) |
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 |
g_return_val_if_fail (node != NULL, FALSE); |
6
78fdf5d9eb1b
2003-06-11 Mikael Hallendal <micke@codefactory.se>
hallski <hallski>
parents:
4
diff
changeset
|
375 |
|
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
|
376 |
return node->raw_mode; |
6
78fdf5d9eb1b
2003-06-11 Mikael Hallendal <micke@codefactory.se>
hallski <hallski>
parents:
4
diff
changeset
|
377 |
} |
78fdf5d9eb1b
2003-06-11 Mikael Hallendal <micke@codefactory.se>
hallski <hallski>
parents:
4
diff
changeset
|
378 |
|
78fdf5d9eb1b
2003-06-11 Mikael Hallendal <micke@codefactory.se>
hallski <hallski>
parents:
4
diff
changeset
|
379 |
/** |
78fdf5d9eb1b
2003-06-11 Mikael Hallendal <micke@codefactory.se>
hallski <hallski>
parents:
4
diff
changeset
|
380 |
* lm_message_node_set_raw_mode: |
78fdf5d9eb1b
2003-06-11 Mikael Hallendal <micke@codefactory.se>
hallski <hallski>
parents:
4
diff
changeset
|
381 |
* @node: an #LmMessageNode |
78fdf5d9eb1b
2003-06-11 Mikael Hallendal <micke@codefactory.se>
hallski <hallski>
parents:
4
diff
changeset
|
382 |
* @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
|
383 |
* |
78fdf5d9eb1b
2003-06-11 Mikael Hallendal <micke@codefactory.se>
hallski <hallski>
parents:
4
diff
changeset
|
384 |
* 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
|
385 |
**/ |
78fdf5d9eb1b
2003-06-11 Mikael Hallendal <micke@codefactory.se>
hallski <hallski>
parents:
4
diff
changeset
|
386 |
void |
78fdf5d9eb1b
2003-06-11 Mikael Hallendal <micke@codefactory.se>
hallski <hallski>
parents:
4
diff
changeset
|
387 |
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
|
388 |
{ |
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
|
389 |
g_return_if_fail (node != NULL); |
6
78fdf5d9eb1b
2003-06-11 Mikael Hallendal <micke@codefactory.se>
hallski <hallski>
parents:
4
diff
changeset
|
390 |
|
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
|
391 |
node->raw_mode = raw_mode; |
6
78fdf5d9eb1b
2003-06-11 Mikael Hallendal <micke@codefactory.se>
hallski <hallski>
parents:
4
diff
changeset
|
392 |
} |
78fdf5d9eb1b
2003-06-11 Mikael Hallendal <micke@codefactory.se>
hallski <hallski>
parents:
4
diff
changeset
|
393 |
|
78fdf5d9eb1b
2003-06-11 Mikael Hallendal <micke@codefactory.se>
hallski <hallski>
parents:
4
diff
changeset
|
394 |
/** |
1 | 395 |
* lm_message_node_ref: |
396 |
* @node: an #LmMessageNode |
|
397 |
* |
|
398 |
* Adds a reference to @node. |
|
399 |
* |
|
400 |
* Return value: the node |
|
401 |
**/ |
|
402 |
LmMessageNode * |
|
403 |
lm_message_node_ref (LmMessageNode *node) |
|
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 |
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
|
406 |
|
cdd6a0c5b439
Went 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 |
node->ref_count++; |
1 | 408 |
|
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
|
409 |
return node; |
1 | 410 |
} |
411 |
||
412 |
/** |
|
413 |
* lm_message_node_unref: |
|
414 |
* @node: an #LmMessageNode |
|
415 |
* |
|
416 |
* Removes a reference from @node. When no more references are present the |
|
417 |
* node is freed. When freed lm_message_node_unref() will be called on all |
|
418 |
* children. If caller needs to keep references to the children a call to |
|
419 |
* lm_message_node_ref() needs to be done before the call to |
|
420 |
*lm_message_unref(). |
|
421 |
**/ |
|
422 |
void |
|
423 |
lm_message_node_unref (LmMessageNode *node) |
|
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 |
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
|
426 |
|
cdd6a0c5b439
Went 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 |
node->ref_count--; |
cdd6a0c5b439
Went 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 |
|
cdd6a0c5b439
Went 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 |
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
|
430 |
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
|
431 |
} |
1 | 432 |
} |
433 |
||
434 |
/** |
|
435 |
* lm_message_node_to_string: |
|
436 |
* @node: an #LmMessageNode |
|
437 |
* |
|
438 |
* Returns an XML string representing the node. This is what is sent over the |
|
439 |
* wire. This is used internally Loudmouth and is external for debugging |
|
440 |
* purposes. |
|
441 |
* |
|
442 |
* Return value: an XML string representation of @node |
|
443 |
**/ |
|
444 |
gchar * |
|
445 |
lm_message_node_to_string (LmMessageNode *node) |
|
446 |
{ |
|
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
|
447 |
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
|
448 |
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
|
449 |
LmMessageNode *child; |
166
2e6fae54b2fb
2006-08-22 Mikael Hallendal <micke@imendio.com>
hallski <hallski>
parents:
99
diff
changeset
|
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 |
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
|
452 |
|
cdd6a0c5b439
Went 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 |
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
|
454 |
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
|
455 |
} |
cdd6a0c5b439
Went 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 |
|
cdd6a0c5b439
Went 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 |
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
|
458 |
g_string_append (ret, 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
|
459 |
|
cdd6a0c5b439
Went 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 |
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
|
461 |
KeyValuePair *kvp = (KeyValuePair *) l->data; |
184
4e16d32b2410
2006-10-16 Mikael Hallendal <micke@imendio.com>
hallski <hallski>
parents:
168
diff
changeset
|
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 |
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
|
464 |
gchar *escaped; |
184
4e16d32b2410
2006-10-16 Mikael Hallendal <micke@imendio.com>
hallski <hallski>
parents:
168
diff
changeset
|
465 |
|
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 |
escaped = g_markup_escape_text (kvp->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
|
467 |
g_string_append_printf (ret, " %s=\"%s\"", |
cdd6a0c5b439
Went 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 |
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
|
469 |
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
|
470 |
} 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
|
471 |
g_string_append_printf (ret, " %s=\"%s\"", |
cdd6a0c5b439
Went 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 |
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
|
473 |
} |
cdd6a0c5b439
Went 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 |
|
cdd6a0c5b439
Went 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 |
} |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
476 |
|
cdd6a0c5b439
Went 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 |
g_string_append_c (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
|
478 |
|
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
479 |
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
|
480 |
gchar *tmp; |
1 | 481 |
|
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
|
482 |
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
|
483 |
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
|
484 |
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
|
485 |
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
|
486 |
} 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
|
487 |
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
|
488 |
} |
cdd6a0c5b439
Went 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 |
} |
1 | 490 |
|
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
|
491 |
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
|
492 |
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
|
493 |
/* 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
|
494 |
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
|
495 |
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
|
496 |
} |
1 | 497 |
|
576
18caa29fe013
Removed some whitespace insertions that were altering the structure of the
Kirk Haines <wyhaines@gmail.com>
parents:
518
diff
changeset
|
498 |
/* 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
|
499 |
g_string_append_printf (ret, "</%s>", node->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
|
500 |
|
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
501 |
return g_string_free (ret, FALSE); |
1 | 502 |
} |