Mercurial > pidgin
annotate src/value.c @ 13306:b9048e9ed019
[gaim-migrate @ 15672]
I noted this extraneous < and the translator confirmed that it was a bug.
committer: Tailor Script <tailor@pidgin.im>
author | Richard Laager <rlaager@wiktel.com> |
---|---|
date | Fri, 17 Feb 2006 21:40:01 +0000 |
parents | fde4101fa183 |
children | 8bda65b88e49 |
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 { | |
88 if (value->u.specific_type != NULL) | |
89 g_free(value->u.specific_type); | |
90 } | |
91 else if (gaim_value_get_type(value) == GAIM_TYPE_STRING) | |
92 { | |
93 if (value->data.string_data != NULL) | |
94 g_free(value->data.string_data); | |
95 } | |
96 | |
97 g_free(value); | |
98 } | |
99 | |
8809
fde4101fa183
[gaim-migrate @ 9571]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
100 GaimValue * |
fde4101fa183
[gaim-migrate @ 9571]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
101 gaim_value_dup(const GaimValue *value) |
fde4101fa183
[gaim-migrate @ 9571]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
102 { |
fde4101fa183
[gaim-migrate @ 9571]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
103 GaimValue *new_value; |
fde4101fa183
[gaim-migrate @ 9571]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
104 GaimType type; |
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 g_return_val_if_fail(value != NULL, NULL); |
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 type = gaim_value_get_type(value); |
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 if (type == GAIM_TYPE_SUBTYPE) |
fde4101fa183
[gaim-migrate @ 9571]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
111 { |
fde4101fa183
[gaim-migrate @ 9571]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
112 new_value = gaim_value_new(GAIM_TYPE_SUBTYPE, |
fde4101fa183
[gaim-migrate @ 9571]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
113 gaim_value_get_subtype(value)); |
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 else if (type == GAIM_TYPE_BOXED) |
fde4101fa183
[gaim-migrate @ 9571]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
116 { |
fde4101fa183
[gaim-migrate @ 9571]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
117 new_value = gaim_value_new(GAIM_TYPE_BOXED, |
fde4101fa183
[gaim-migrate @ 9571]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
118 gaim_value_get_specific_type(value)); |
fde4101fa183
[gaim-migrate @ 9571]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
119 } |
fde4101fa183
[gaim-migrate @ 9571]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
120 else |
fde4101fa183
[gaim-migrate @ 9571]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
121 new_value = gaim_value_new(type); |
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 new_value->flags = value->flags; |
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 switch (type) |
fde4101fa183
[gaim-migrate @ 9571]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
126 { |
fde4101fa183
[gaim-migrate @ 9571]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
127 case GAIM_TYPE_CHAR: |
fde4101fa183
[gaim-migrate @ 9571]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
128 gaim_value_set_char(new_value, gaim_value_get_char(value)); |
fde4101fa183
[gaim-migrate @ 9571]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
129 break; |
fde4101fa183
[gaim-migrate @ 9571]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
130 |
fde4101fa183
[gaim-migrate @ 9571]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
131 case GAIM_TYPE_UCHAR: |
fde4101fa183
[gaim-migrate @ 9571]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
132 gaim_value_set_uchar(new_value, gaim_value_get_uchar(value)); |
fde4101fa183
[gaim-migrate @ 9571]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
133 break; |
fde4101fa183
[gaim-migrate @ 9571]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
134 |
fde4101fa183
[gaim-migrate @ 9571]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
135 case GAIM_TYPE_BOOLEAN: |
fde4101fa183
[gaim-migrate @ 9571]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
136 gaim_value_set_boolean(new_value, gaim_value_get_boolean(value)); |
fde4101fa183
[gaim-migrate @ 9571]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
137 break; |
fde4101fa183
[gaim-migrate @ 9571]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
138 |
fde4101fa183
[gaim-migrate @ 9571]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
139 case GAIM_TYPE_SHORT: |
fde4101fa183
[gaim-migrate @ 9571]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
140 gaim_value_set_short(new_value, gaim_value_get_short(value)); |
fde4101fa183
[gaim-migrate @ 9571]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
141 break; |
fde4101fa183
[gaim-migrate @ 9571]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
142 |
fde4101fa183
[gaim-migrate @ 9571]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
143 case GAIM_TYPE_USHORT: |
fde4101fa183
[gaim-migrate @ 9571]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
144 gaim_value_set_ushort(new_value, gaim_value_get_ushort(value)); |
fde4101fa183
[gaim-migrate @ 9571]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
145 break; |
fde4101fa183
[gaim-migrate @ 9571]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
146 |
fde4101fa183
[gaim-migrate @ 9571]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
147 case GAIM_TYPE_INT: |
fde4101fa183
[gaim-migrate @ 9571]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
148 gaim_value_set_int(new_value, gaim_value_get_int(value)); |
fde4101fa183
[gaim-migrate @ 9571]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
149 break; |
fde4101fa183
[gaim-migrate @ 9571]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
150 |
fde4101fa183
[gaim-migrate @ 9571]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
151 case GAIM_TYPE_UINT: |
fde4101fa183
[gaim-migrate @ 9571]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
152 gaim_value_set_uint(new_value, gaim_value_get_uint(value)); |
fde4101fa183
[gaim-migrate @ 9571]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
153 break; |
fde4101fa183
[gaim-migrate @ 9571]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
154 |
fde4101fa183
[gaim-migrate @ 9571]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
155 case GAIM_TYPE_LONG: |
fde4101fa183
[gaim-migrate @ 9571]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
156 gaim_value_set_long(new_value, gaim_value_get_long(value)); |
fde4101fa183
[gaim-migrate @ 9571]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
157 break; |
fde4101fa183
[gaim-migrate @ 9571]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
158 |
fde4101fa183
[gaim-migrate @ 9571]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
159 case GAIM_TYPE_ULONG: |
fde4101fa183
[gaim-migrate @ 9571]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
160 gaim_value_set_ulong(new_value, gaim_value_get_ulong(value)); |
fde4101fa183
[gaim-migrate @ 9571]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
161 break; |
fde4101fa183
[gaim-migrate @ 9571]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
162 |
fde4101fa183
[gaim-migrate @ 9571]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
163 case GAIM_TYPE_INT64: |
fde4101fa183
[gaim-migrate @ 9571]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
164 gaim_value_set_int64(new_value, gaim_value_get_int64(value)); |
fde4101fa183
[gaim-migrate @ 9571]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
165 break; |
fde4101fa183
[gaim-migrate @ 9571]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
166 |
fde4101fa183
[gaim-migrate @ 9571]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
167 case GAIM_TYPE_UINT64: |
fde4101fa183
[gaim-migrate @ 9571]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
168 gaim_value_set_uint64(new_value, gaim_value_get_uint64(value)); |
fde4101fa183
[gaim-migrate @ 9571]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
169 break; |
fde4101fa183
[gaim-migrate @ 9571]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
170 |
fde4101fa183
[gaim-migrate @ 9571]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
171 case GAIM_TYPE_STRING: |
fde4101fa183
[gaim-migrate @ 9571]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
172 gaim_value_set_string(new_value, gaim_value_get_string(value)); |
fde4101fa183
[gaim-migrate @ 9571]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
173 break; |
fde4101fa183
[gaim-migrate @ 9571]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
174 |
fde4101fa183
[gaim-migrate @ 9571]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
175 case GAIM_TYPE_OBJECT: |
fde4101fa183
[gaim-migrate @ 9571]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
176 gaim_value_set_object(new_value, gaim_value_get_object(value)); |
fde4101fa183
[gaim-migrate @ 9571]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
177 break; |
fde4101fa183
[gaim-migrate @ 9571]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
178 |
fde4101fa183
[gaim-migrate @ 9571]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
179 case GAIM_TYPE_POINTER: |
fde4101fa183
[gaim-migrate @ 9571]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
180 gaim_value_set_pointer(new_value, gaim_value_get_pointer(value)); |
fde4101fa183
[gaim-migrate @ 9571]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
181 break; |
fde4101fa183
[gaim-migrate @ 9571]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
182 |
fde4101fa183
[gaim-migrate @ 9571]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
183 case GAIM_TYPE_ENUM: |
fde4101fa183
[gaim-migrate @ 9571]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
184 gaim_value_set_enum(new_value, gaim_value_get_enum(value)); |
fde4101fa183
[gaim-migrate @ 9571]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
185 break; |
fde4101fa183
[gaim-migrate @ 9571]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
186 |
fde4101fa183
[gaim-migrate @ 9571]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
187 case GAIM_TYPE_BOXED: |
fde4101fa183
[gaim-migrate @ 9571]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
188 gaim_value_set_boxed(new_value, gaim_value_get_boxed(value)); |
fde4101fa183
[gaim-migrate @ 9571]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
189 break; |
fde4101fa183
[gaim-migrate @ 9571]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
190 |
fde4101fa183
[gaim-migrate @ 9571]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
191 default: |
fde4101fa183
[gaim-migrate @ 9571]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
192 break; |
fde4101fa183
[gaim-migrate @ 9571]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
193 } |
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 return new_value; |
fde4101fa183
[gaim-migrate @ 9571]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
196 } |
fde4101fa183
[gaim-migrate @ 9571]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
197 |
6562 | 198 GaimType |
199 gaim_value_get_type(const GaimValue *value) | |
200 { | |
201 g_return_val_if_fail(value != NULL, GAIM_TYPE_UNKNOWN); | |
202 | |
203 return value->type; | |
204 } | |
205 | |
206 unsigned int | |
207 gaim_value_get_subtype(const GaimValue *value) | |
208 { | |
209 g_return_val_if_fail(value != NULL, 0); | |
210 g_return_val_if_fail(gaim_value_get_type(value) == GAIM_TYPE_SUBTYPE, 0); | |
211 | |
212 return value->u.subtype; | |
213 } | |
214 | |
215 const char * | |
216 gaim_value_get_specific_type(const GaimValue *value) | |
217 { | |
218 g_return_val_if_fail(value != NULL, NULL); | |
219 g_return_val_if_fail(gaim_value_get_type(value) == GAIM_TYPE_BOXED, NULL); | |
220 | |
221 return value->u.specific_type; | |
222 } | |
223 | |
224 gboolean | |
225 gaim_value_is_outgoing(const GaimValue *value) | |
226 { | |
227 g_return_val_if_fail(value != NULL, FALSE); | |
228 | |
229 return (value->flags & OUTGOING_FLAG); | |
230 } | |
231 | |
232 void | |
233 gaim_value_set_char(GaimValue *value, char data) | |
234 { | |
235 g_return_if_fail(value != NULL); | |
236 | |
237 value->data.char_data = data; | |
238 } | |
239 | |
240 void | |
241 gaim_value_set_uchar(GaimValue *value, unsigned char data) | |
242 { | |
243 g_return_if_fail(value != NULL); | |
244 | |
245 value->data.uchar_data = data; | |
246 } | |
247 | |
248 void | |
249 gaim_value_set_boolean(GaimValue *value, gboolean data) | |
250 { | |
251 g_return_if_fail(value != NULL); | |
252 | |
253 value->data.boolean_data = data; | |
254 } | |
255 | |
256 void | |
257 gaim_value_set_short(GaimValue *value, short data) | |
258 { | |
259 g_return_if_fail(value != NULL); | |
260 | |
261 value->data.short_data = data; | |
262 } | |
263 | |
264 void | |
265 gaim_value_set_ushort(GaimValue *value, unsigned short data) | |
266 { | |
267 g_return_if_fail(value != NULL); | |
268 | |
269 value->data.ushort_data = data; | |
270 } | |
271 | |
272 void | |
273 gaim_value_set_int(GaimValue *value, int data) | |
274 { | |
275 g_return_if_fail(value != NULL); | |
276 | |
277 value->data.int_data = data; | |
278 } | |
279 | |
280 void | |
281 gaim_value_set_uint(GaimValue *value, unsigned int data) | |
282 { | |
283 g_return_if_fail(value != NULL); | |
284 | |
285 value->data.int_data = data; | |
286 } | |
287 | |
288 void | |
289 gaim_value_set_long(GaimValue *value, long data) | |
290 { | |
291 g_return_if_fail(value != NULL); | |
292 | |
293 value->data.long_data = data; | |
294 } | |
295 | |
296 void | |
297 gaim_value_set_ulong(GaimValue *value, unsigned long data) | |
298 { | |
299 g_return_if_fail(value != NULL); | |
300 | |
301 value->data.long_data = data; | |
302 } | |
303 | |
304 void | |
305 gaim_value_set_int64(GaimValue *value, gint64 data) | |
306 { | |
307 g_return_if_fail(value != NULL); | |
308 | |
309 value->data.int64_data = data; | |
310 } | |
311 | |
312 void | |
313 gaim_value_set_uint64(GaimValue *value, guint64 data) | |
314 { | |
315 g_return_if_fail(value != NULL); | |
316 | |
317 value->data.uint64_data = data; | |
318 } | |
319 | |
320 void | |
321 gaim_value_set_string(GaimValue *value, const char *data) | |
322 { | |
323 g_return_if_fail(value != NULL); | |
324 | |
325 if (value->data.string_data != NULL) | |
326 g_free(value->data.string_data); | |
327 | |
328 value->data.string_data = (data == NULL ? NULL : g_strdup(data)); | |
329 } | |
330 | |
331 void | |
332 gaim_value_set_object(GaimValue *value, void *data) | |
333 { | |
334 g_return_if_fail(value != NULL); | |
335 | |
336 value->data.object_data = data; | |
337 } | |
338 | |
339 void | |
340 gaim_value_set_pointer(GaimValue *value, void *data) | |
341 { | |
342 g_return_if_fail(value != NULL); | |
343 | |
344 value->data.pointer_data = data; | |
345 } | |
346 | |
347 void | |
348 gaim_value_set_enum(GaimValue *value, int data) | |
349 { | |
350 g_return_if_fail(value != NULL); | |
351 | |
352 value->data.enum_data = data; | |
353 } | |
354 | |
355 void | |
356 gaim_value_set_boxed(GaimValue *value, void *data) | |
357 { | |
358 g_return_if_fail(value != NULL); | |
359 | |
360 value->data.boxed_data = data; | |
361 } | |
362 | |
363 char | |
364 gaim_value_get_char(const GaimValue *value) | |
365 { | |
366 g_return_val_if_fail(value != NULL, 0); | |
367 | |
368 return value->data.char_data; | |
369 } | |
370 | |
371 unsigned char | |
372 gaim_value_get_uchar(const GaimValue *value) | |
373 { | |
374 g_return_val_if_fail(value != NULL, 0); | |
375 | |
376 return value->data.uchar_data; | |
377 } | |
378 | |
379 gboolean | |
380 gaim_value_get_boolean(const GaimValue *value) | |
381 { | |
382 g_return_val_if_fail(value != NULL, FALSE); | |
383 | |
384 return value->data.boolean_data; | |
385 } | |
386 | |
387 short | |
388 gaim_value_get_short(const GaimValue *value) | |
389 { | |
390 g_return_val_if_fail(value != NULL, 0); | |
391 | |
392 return value->data.short_data; | |
393 } | |
394 | |
395 unsigned short | |
396 gaim_value_get_ushort(const GaimValue *value) | |
397 { | |
398 g_return_val_if_fail(value != NULL, 0); | |
399 | |
400 return value->data.ushort_data; | |
401 } | |
402 | |
403 int | |
404 gaim_value_get_int(const GaimValue *value) | |
405 { | |
406 g_return_val_if_fail(value != NULL, 0); | |
407 | |
408 return value->data.int_data; | |
409 } | |
410 | |
411 unsigned int | |
412 gaim_value_get_uint(const GaimValue *value) | |
413 { | |
414 g_return_val_if_fail(value != NULL, 0); | |
415 | |
416 return value->data.int_data; | |
417 } | |
418 | |
419 long | |
420 gaim_value_get_long(const GaimValue *value) | |
421 { | |
422 g_return_val_if_fail(value != NULL, 0); | |
423 | |
424 return value->data.long_data; | |
425 } | |
426 | |
427 unsigned long | |
428 gaim_value_get_ulong(const GaimValue *value) | |
429 { | |
430 g_return_val_if_fail(value != NULL, 0); | |
431 | |
432 return value->data.long_data; | |
433 } | |
434 | |
435 gint64 | |
436 gaim_value_get_int64(const GaimValue *value) | |
437 { | |
438 g_return_val_if_fail(value != NULL, 0); | |
439 | |
440 return value->data.int64_data; | |
441 } | |
442 | |
443 guint64 | |
444 gaim_value_get_uint64(const GaimValue *value) | |
445 { | |
446 g_return_val_if_fail(value != NULL, 0); | |
447 | |
448 return value->data.uint64_data; | |
449 } | |
450 | |
451 const char * | |
452 gaim_value_get_string(const GaimValue *value) | |
453 { | |
454 g_return_val_if_fail(value != NULL, NULL); | |
455 | |
456 return value->data.string_data; | |
457 } | |
458 | |
459 void * | |
460 gaim_value_get_object(const GaimValue *value) | |
461 { | |
462 g_return_val_if_fail(value != NULL, NULL); | |
463 | |
464 return value->data.object_data; | |
465 } | |
466 | |
467 void * | |
468 gaim_value_get_pointer(const GaimValue *value) | |
469 { | |
470 g_return_val_if_fail(value != NULL, NULL); | |
471 | |
472 return value->data.pointer_data; | |
473 } | |
474 | |
475 int | |
476 gaim_value_get_enum(const GaimValue *value) | |
477 { | |
478 g_return_val_if_fail(value != NULL, -1); | |
479 | |
480 return value->data.enum_data; | |
481 } | |
482 | |
483 void * | |
484 gaim_value_get_boxed(const GaimValue *value) | |
485 { | |
486 g_return_val_if_fail(value != NULL, NULL); | |
487 | |
488 return value->data.boxed_data; | |
489 } | |
490 |