Mercurial > pidgin.yaz
annotate src/value.c @ 14053:96ef9966aa24
[gaim-migrate @ 16666]
When not connecting with "Use TLS (if available)" enabled, it's still possible to reach the JABBER_STREAM_REINITIALIZING connection stage. This is step 4 of the 5-step non-SSL connection process. In this situation, jabber_recv_cb_ssl() won't be called, so the delayed reintialization via js_>reinit being TRUE never occurs. jabber_stream_init() is immediately called in that situation.
This may cause the same problems when using libxml which js->reinit was introduced to fix in [16585]. I'm not using libxml, so I couldn't test that... if so, a check against js->reinit and a subsequent jabber_stream_init() call is needed somewhere in the connection path taken when not using SSL.
committer: Tailor Script <tailor@pidgin.im>
author | Evan Schoenberg <evan.s@dreskin.net> |
---|---|
date | Mon, 07 Aug 2006 19:23:42 +0000 |
parents | 8bda65b88e49 |
children |
rev | line source |
---|---|
6562 | 1 /** |
2 * @file value.c Value wrapper API | |
3 * @ingroup core | |
4 * | |
5 * gaim | |
6 * | |
8046 | 7 * Gaim is the legal property of its developers, whose names are too numerous |
8 * to list here. Please refer to the COPYRIGHT file distributed with this | |
9 * source distribution. | |
6562 | 10 * |
11 * This program is free software; you can redistribute it and/or modify | |
12 * it under the terms of the GNU General Public License as published by | |
13 * the Free Software Foundation; either version 2 of the License, or | |
14 * (at your option) any later version. | |
15 * | |
16 * This program is distributed in the hope that it will be useful, | |
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
19 * GNU General Public License for more details. | |
20 * | |
21 * You should have received a copy of the GNU General Public License | |
22 * along with this program; if not, write to the Free Software | |
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
24 */ | |
25 #include "internal.h" | |
26 | |
27 #include "value.h" | |
28 | |
29 #define OUTGOING_FLAG 0x01 | |
30 | |
31 GaimValue * | |
32 gaim_value_new(GaimType type, ...) | |
33 { | |
34 GaimValue *value; | |
35 va_list args; | |
36 | |
37 g_return_val_if_fail(type != GAIM_TYPE_UNKNOWN, NULL); | |
38 | |
39 value = g_new0(GaimValue, 1); | |
40 | |
41 value->type = type; | |
42 | |
43 va_start(args, type); | |
44 | |
45 if (type == GAIM_TYPE_SUBTYPE) | |
46 value->u.subtype = va_arg(args, int); | |
47 else if (type == GAIM_TYPE_BOXED) | |
48 value->u.specific_type = g_strdup(va_arg(args, char *)); | |
49 | |
50 va_end(args); | |
51 | |
52 return value; | |
53 } | |
54 | |
55 GaimValue * | |
56 gaim_value_new_outgoing(GaimType type, ...) | |
57 { | |
58 GaimValue *value; | |
59 va_list args; | |
60 | |
61 g_return_val_if_fail(type != GAIM_TYPE_UNKNOWN, NULL); | |
62 | |
63 value = g_new0(GaimValue, 1); | |
64 | |
65 value->type = type; | |
66 | |
67 va_start(args, type); | |
68 | |
69 if (type == GAIM_TYPE_SUBTYPE) | |
70 value->u.subtype = va_arg(args, int); | |
71 else if (type == GAIM_TYPE_BOXED) | |
72 value->u.specific_type = g_strdup(va_arg(args, char *)); | |
73 | |
74 va_end(args); | |
75 | |
76 value->flags |= OUTGOING_FLAG; | |
77 | |
78 return value; | |
79 } | |
80 | |
81 void | |
82 gaim_value_destroy(GaimValue *value) | |
83 { | |
84 g_return_if_fail(value != NULL); | |
85 | |
86 if (gaim_value_get_type(value) == GAIM_TYPE_BOXED) | |
87 { | |
14035 | 88 g_free(value->u.specific_type); |
6562 | 89 } |
90 else if (gaim_value_get_type(value) == GAIM_TYPE_STRING) | |
91 { | |
14035 | 92 g_free(value->data.string_data); |
6562 | 93 } |
94 | |
95 g_free(value); | |
96 } | |
97 | |
8809
fde4101fa183
[gaim-migrate @ 9571]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
98 GaimValue * |
fde4101fa183
[gaim-migrate @ 9571]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
99 gaim_value_dup(const GaimValue *value) |
fde4101fa183
[gaim-migrate @ 9571]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
100 { |
fde4101fa183
[gaim-migrate @ 9571]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
101 GaimValue *new_value; |
fde4101fa183
[gaim-migrate @ 9571]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
102 GaimType type; |
fde4101fa183
[gaim-migrate @ 9571]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
103 |
fde4101fa183
[gaim-migrate @ 9571]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
104 g_return_val_if_fail(value != NULL, NULL); |
fde4101fa183
[gaim-migrate @ 9571]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
105 |
fde4101fa183
[gaim-migrate @ 9571]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
106 type = gaim_value_get_type(value); |
fde4101fa183
[gaim-migrate @ 9571]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
107 |
fde4101fa183
[gaim-migrate @ 9571]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
108 if (type == GAIM_TYPE_SUBTYPE) |
fde4101fa183
[gaim-migrate @ 9571]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
109 { |
fde4101fa183
[gaim-migrate @ 9571]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
110 new_value = gaim_value_new(GAIM_TYPE_SUBTYPE, |
fde4101fa183
[gaim-migrate @ 9571]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
111 gaim_value_get_subtype(value)); |
fde4101fa183
[gaim-migrate @ 9571]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
112 } |
fde4101fa183
[gaim-migrate @ 9571]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
113 else if (type == GAIM_TYPE_BOXED) |
fde4101fa183
[gaim-migrate @ 9571]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
114 { |
fde4101fa183
[gaim-migrate @ 9571]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
115 new_value = gaim_value_new(GAIM_TYPE_BOXED, |
fde4101fa183
[gaim-migrate @ 9571]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
116 gaim_value_get_specific_type(value)); |
fde4101fa183
[gaim-migrate @ 9571]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
117 } |
fde4101fa183
[gaim-migrate @ 9571]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
118 else |
fde4101fa183
[gaim-migrate @ 9571]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
119 new_value = gaim_value_new(type); |
fde4101fa183
[gaim-migrate @ 9571]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
120 |
fde4101fa183
[gaim-migrate @ 9571]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
121 new_value->flags = value->flags; |
fde4101fa183
[gaim-migrate @ 9571]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
122 |
fde4101fa183
[gaim-migrate @ 9571]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
123 switch (type) |
fde4101fa183
[gaim-migrate @ 9571]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
124 { |
fde4101fa183
[gaim-migrate @ 9571]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
125 case GAIM_TYPE_CHAR: |
fde4101fa183
[gaim-migrate @ 9571]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
126 gaim_value_set_char(new_value, gaim_value_get_char(value)); |
fde4101fa183
[gaim-migrate @ 9571]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
127 break; |
fde4101fa183
[gaim-migrate @ 9571]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
128 |
fde4101fa183
[gaim-migrate @ 9571]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
129 case GAIM_TYPE_UCHAR: |
fde4101fa183
[gaim-migrate @ 9571]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
130 gaim_value_set_uchar(new_value, gaim_value_get_uchar(value)); |
fde4101fa183
[gaim-migrate @ 9571]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
131 break; |
fde4101fa183
[gaim-migrate @ 9571]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
132 |
fde4101fa183
[gaim-migrate @ 9571]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
133 case GAIM_TYPE_BOOLEAN: |
fde4101fa183
[gaim-migrate @ 9571]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
134 gaim_value_set_boolean(new_value, gaim_value_get_boolean(value)); |
fde4101fa183
[gaim-migrate @ 9571]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
135 break; |
fde4101fa183
[gaim-migrate @ 9571]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
136 |
fde4101fa183
[gaim-migrate @ 9571]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
137 case GAIM_TYPE_SHORT: |
fde4101fa183
[gaim-migrate @ 9571]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
138 gaim_value_set_short(new_value, gaim_value_get_short(value)); |
fde4101fa183
[gaim-migrate @ 9571]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
139 break; |
fde4101fa183
[gaim-migrate @ 9571]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
140 |
fde4101fa183
[gaim-migrate @ 9571]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
141 case GAIM_TYPE_USHORT: |
fde4101fa183
[gaim-migrate @ 9571]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
142 gaim_value_set_ushort(new_value, gaim_value_get_ushort(value)); |
fde4101fa183
[gaim-migrate @ 9571]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
143 break; |
fde4101fa183
[gaim-migrate @ 9571]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
144 |
fde4101fa183
[gaim-migrate @ 9571]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
145 case GAIM_TYPE_INT: |
fde4101fa183
[gaim-migrate @ 9571]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
146 gaim_value_set_int(new_value, gaim_value_get_int(value)); |
fde4101fa183
[gaim-migrate @ 9571]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
147 break; |
fde4101fa183
[gaim-migrate @ 9571]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
148 |
fde4101fa183
[gaim-migrate @ 9571]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
149 case GAIM_TYPE_UINT: |
fde4101fa183
[gaim-migrate @ 9571]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
150 gaim_value_set_uint(new_value, gaim_value_get_uint(value)); |
fde4101fa183
[gaim-migrate @ 9571]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
151 break; |
fde4101fa183
[gaim-migrate @ 9571]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
152 |
fde4101fa183
[gaim-migrate @ 9571]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
153 case GAIM_TYPE_LONG: |
fde4101fa183
[gaim-migrate @ 9571]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
154 gaim_value_set_long(new_value, gaim_value_get_long(value)); |
fde4101fa183
[gaim-migrate @ 9571]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
155 break; |
fde4101fa183
[gaim-migrate @ 9571]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
156 |
fde4101fa183
[gaim-migrate @ 9571]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
157 case GAIM_TYPE_ULONG: |
fde4101fa183
[gaim-migrate @ 9571]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
158 gaim_value_set_ulong(new_value, gaim_value_get_ulong(value)); |
fde4101fa183
[gaim-migrate @ 9571]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
159 break; |
fde4101fa183
[gaim-migrate @ 9571]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
160 |
fde4101fa183
[gaim-migrate @ 9571]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
161 case GAIM_TYPE_INT64: |
fde4101fa183
[gaim-migrate @ 9571]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
162 gaim_value_set_int64(new_value, gaim_value_get_int64(value)); |
fde4101fa183
[gaim-migrate @ 9571]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
163 break; |
fde4101fa183
[gaim-migrate @ 9571]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
164 |
fde4101fa183
[gaim-migrate @ 9571]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
165 case GAIM_TYPE_UINT64: |
fde4101fa183
[gaim-migrate @ 9571]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
166 gaim_value_set_uint64(new_value, gaim_value_get_uint64(value)); |
fde4101fa183
[gaim-migrate @ 9571]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
167 break; |
fde4101fa183
[gaim-migrate @ 9571]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
168 |
fde4101fa183
[gaim-migrate @ 9571]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
169 case GAIM_TYPE_STRING: |
fde4101fa183
[gaim-migrate @ 9571]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
170 gaim_value_set_string(new_value, gaim_value_get_string(value)); |
fde4101fa183
[gaim-migrate @ 9571]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
171 break; |
fde4101fa183
[gaim-migrate @ 9571]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
172 |
fde4101fa183
[gaim-migrate @ 9571]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
173 case GAIM_TYPE_OBJECT: |
fde4101fa183
[gaim-migrate @ 9571]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
174 gaim_value_set_object(new_value, gaim_value_get_object(value)); |
fde4101fa183
[gaim-migrate @ 9571]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
175 break; |
fde4101fa183
[gaim-migrate @ 9571]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
176 |
fde4101fa183
[gaim-migrate @ 9571]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
177 case GAIM_TYPE_POINTER: |
fde4101fa183
[gaim-migrate @ 9571]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
178 gaim_value_set_pointer(new_value, gaim_value_get_pointer(value)); |
fde4101fa183
[gaim-migrate @ 9571]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
179 break; |
fde4101fa183
[gaim-migrate @ 9571]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
180 |
fde4101fa183
[gaim-migrate @ 9571]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
181 case GAIM_TYPE_ENUM: |
fde4101fa183
[gaim-migrate @ 9571]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
182 gaim_value_set_enum(new_value, gaim_value_get_enum(value)); |
fde4101fa183
[gaim-migrate @ 9571]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
183 break; |
fde4101fa183
[gaim-migrate @ 9571]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
184 |
fde4101fa183
[gaim-migrate @ 9571]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
185 case GAIM_TYPE_BOXED: |
fde4101fa183
[gaim-migrate @ 9571]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
186 gaim_value_set_boxed(new_value, gaim_value_get_boxed(value)); |
fde4101fa183
[gaim-migrate @ 9571]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
187 break; |
fde4101fa183
[gaim-migrate @ 9571]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
188 |
fde4101fa183
[gaim-migrate @ 9571]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
189 default: |
fde4101fa183
[gaim-migrate @ 9571]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
190 break; |
fde4101fa183
[gaim-migrate @ 9571]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
191 } |
fde4101fa183
[gaim-migrate @ 9571]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
192 |
fde4101fa183
[gaim-migrate @ 9571]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
193 return new_value; |
fde4101fa183
[gaim-migrate @ 9571]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
194 } |
fde4101fa183
[gaim-migrate @ 9571]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
195 |
6562 | 196 GaimType |
197 gaim_value_get_type(const GaimValue *value) | |
198 { | |
199 g_return_val_if_fail(value != NULL, GAIM_TYPE_UNKNOWN); | |
200 | |
201 return value->type; | |
202 } | |
203 | |
204 unsigned int | |
205 gaim_value_get_subtype(const GaimValue *value) | |
206 { | |
207 g_return_val_if_fail(value != NULL, 0); | |
208 g_return_val_if_fail(gaim_value_get_type(value) == GAIM_TYPE_SUBTYPE, 0); | |
209 | |
210 return value->u.subtype; | |
211 } | |
212 | |
213 const char * | |
214 gaim_value_get_specific_type(const GaimValue *value) | |
215 { | |
216 g_return_val_if_fail(value != NULL, NULL); | |
217 g_return_val_if_fail(gaim_value_get_type(value) == GAIM_TYPE_BOXED, NULL); | |
218 | |
219 return value->u.specific_type; | |
220 } | |
221 | |
222 gboolean | |
223 gaim_value_is_outgoing(const GaimValue *value) | |
224 { | |
225 g_return_val_if_fail(value != NULL, FALSE); | |
226 | |
227 return (value->flags & OUTGOING_FLAG); | |
228 } | |
229 | |
230 void | |
231 gaim_value_set_char(GaimValue *value, char data) | |
232 { | |
233 g_return_if_fail(value != NULL); | |
234 | |
235 value->data.char_data = data; | |
236 } | |
237 | |
238 void | |
239 gaim_value_set_uchar(GaimValue *value, unsigned char data) | |
240 { | |
241 g_return_if_fail(value != NULL); | |
242 | |
243 value->data.uchar_data = data; | |
244 } | |
245 | |
246 void | |
247 gaim_value_set_boolean(GaimValue *value, gboolean data) | |
248 { | |
249 g_return_if_fail(value != NULL); | |
250 | |
251 value->data.boolean_data = data; | |
252 } | |
253 | |
254 void | |
255 gaim_value_set_short(GaimValue *value, short data) | |
256 { | |
257 g_return_if_fail(value != NULL); | |
258 | |
259 value->data.short_data = data; | |
260 } | |
261 | |
262 void | |
263 gaim_value_set_ushort(GaimValue *value, unsigned short data) | |
264 { | |
265 g_return_if_fail(value != NULL); | |
266 | |
267 value->data.ushort_data = data; | |
268 } | |
269 | |
270 void | |
271 gaim_value_set_int(GaimValue *value, int data) | |
272 { | |
273 g_return_if_fail(value != NULL); | |
274 | |
275 value->data.int_data = data; | |
276 } | |
277 | |
278 void | |
279 gaim_value_set_uint(GaimValue *value, unsigned int data) | |
280 { | |
281 g_return_if_fail(value != NULL); | |
282 | |
283 value->data.int_data = data; | |
284 } | |
285 | |
286 void | |
287 gaim_value_set_long(GaimValue *value, long data) | |
288 { | |
289 g_return_if_fail(value != NULL); | |
290 | |
291 value->data.long_data = data; | |
292 } | |
293 | |
294 void | |
295 gaim_value_set_ulong(GaimValue *value, unsigned long data) | |
296 { | |
297 g_return_if_fail(value != NULL); | |
298 | |
299 value->data.long_data = data; | |
300 } | |
301 | |
302 void | |
303 gaim_value_set_int64(GaimValue *value, gint64 data) | |
304 { | |
305 g_return_if_fail(value != NULL); | |
306 | |
307 value->data.int64_data = data; | |
308 } | |
309 | |
310 void | |
311 gaim_value_set_uint64(GaimValue *value, guint64 data) | |
312 { | |
313 g_return_if_fail(value != NULL); | |
314 | |
315 value->data.uint64_data = data; | |
316 } | |
317 | |
318 void | |
319 gaim_value_set_string(GaimValue *value, const char *data) | |
320 { | |
321 g_return_if_fail(value != NULL); | |
322 | |
14035 | 323 g_free(value->data.string_data); |
324 value->data.string_data = g_strdup(data); | |
6562 | 325 } |
326 | |
327 void | |
328 gaim_value_set_object(GaimValue *value, void *data) | |
329 { | |
330 g_return_if_fail(value != NULL); | |
331 | |
332 value->data.object_data = data; | |
333 } | |
334 | |
335 void | |
336 gaim_value_set_pointer(GaimValue *value, void *data) | |
337 { | |
338 g_return_if_fail(value != NULL); | |
339 | |
340 value->data.pointer_data = data; | |
341 } | |
342 | |
343 void | |
344 gaim_value_set_enum(GaimValue *value, int data) | |
345 { | |
346 g_return_if_fail(value != NULL); | |
347 | |
348 value->data.enum_data = data; | |
349 } | |
350 | |
351 void | |
352 gaim_value_set_boxed(GaimValue *value, void *data) | |
353 { | |
354 g_return_if_fail(value != NULL); | |
355 | |
356 value->data.boxed_data = data; | |
357 } | |
358 | |
359 char | |
360 gaim_value_get_char(const GaimValue *value) | |
361 { | |
362 g_return_val_if_fail(value != NULL, 0); | |
363 | |
364 return value->data.char_data; | |
365 } | |
366 | |
367 unsigned char | |
368 gaim_value_get_uchar(const GaimValue *value) | |
369 { | |
370 g_return_val_if_fail(value != NULL, 0); | |
371 | |
372 return value->data.uchar_data; | |
373 } | |
374 | |
375 gboolean | |
376 gaim_value_get_boolean(const GaimValue *value) | |
377 { | |
378 g_return_val_if_fail(value != NULL, FALSE); | |
379 | |
380 return value->data.boolean_data; | |
381 } | |
382 | |
383 short | |
384 gaim_value_get_short(const GaimValue *value) | |
385 { | |
386 g_return_val_if_fail(value != NULL, 0); | |
387 | |
388 return value->data.short_data; | |
389 } | |
390 | |
391 unsigned short | |
392 gaim_value_get_ushort(const GaimValue *value) | |
393 { | |
394 g_return_val_if_fail(value != NULL, 0); | |
395 | |
396 return value->data.ushort_data; | |
397 } | |
398 | |
399 int | |
400 gaim_value_get_int(const GaimValue *value) | |
401 { | |
402 g_return_val_if_fail(value != NULL, 0); | |
403 | |
404 return value->data.int_data; | |
405 } | |
406 | |
407 unsigned int | |
408 gaim_value_get_uint(const GaimValue *value) | |
409 { | |
410 g_return_val_if_fail(value != NULL, 0); | |
411 | |
412 return value->data.int_data; | |
413 } | |
414 | |
415 long | |
416 gaim_value_get_long(const GaimValue *value) | |
417 { | |
418 g_return_val_if_fail(value != NULL, 0); | |
419 | |
420 return value->data.long_data; | |
421 } | |
422 | |
423 unsigned long | |
424 gaim_value_get_ulong(const GaimValue *value) | |
425 { | |
426 g_return_val_if_fail(value != NULL, 0); | |
427 | |
428 return value->data.long_data; | |
429 } | |
430 | |
431 gint64 | |
432 gaim_value_get_int64(const GaimValue *value) | |
433 { | |
434 g_return_val_if_fail(value != NULL, 0); | |
435 | |
436 return value->data.int64_data; | |
437 } | |
438 | |
439 guint64 | |
440 gaim_value_get_uint64(const GaimValue *value) | |
441 { | |
442 g_return_val_if_fail(value != NULL, 0); | |
443 | |
444 return value->data.uint64_data; | |
445 } | |
446 | |
447 const char * | |
448 gaim_value_get_string(const GaimValue *value) | |
449 { | |
450 g_return_val_if_fail(value != NULL, NULL); | |
451 | |
452 return value->data.string_data; | |
453 } | |
454 | |
455 void * | |
456 gaim_value_get_object(const GaimValue *value) | |
457 { | |
458 g_return_val_if_fail(value != NULL, NULL); | |
459 | |
460 return value->data.object_data; | |
461 } | |
462 | |
463 void * | |
464 gaim_value_get_pointer(const GaimValue *value) | |
465 { | |
466 g_return_val_if_fail(value != NULL, NULL); | |
467 | |
468 return value->data.pointer_data; | |
469 } | |
470 | |
471 int | |
472 gaim_value_get_enum(const GaimValue *value) | |
473 { | |
474 g_return_val_if_fail(value != NULL, -1); | |
475 | |
476 return value->data.enum_data; | |
477 } | |
478 | |
479 void * | |
480 gaim_value_get_boxed(const GaimValue *value) | |
481 { | |
482 g_return_val_if_fail(value != NULL, NULL); | |
483 | |
484 return value->data.boxed_data; | |
485 } | |
486 |